Skip to content

Commit 3cba445

Browse files
committed
refactor(recipes): rename openHelpers to commonRpcFunctions
Move the open-in-editor/open-in-finder RPC recipe bundle from devframe/recipes/open-helpers to devframe/recipes/common-rpc-functions, renaming the exported openHelpers array to commonRpcFunctions. devframe/recipes/open-helpers remains as a deprecated compatibility shim (openHelpers aliased to commonRpcFunctions) so existing imports keep working.
1 parent 51c8b29 commit 3cba445

18 files changed

Lines changed: 183 additions & 112 deletions

File tree

alias.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const alias = {
7373
'@devframes/plugin-terminals': p('terminals/src/index.ts'),
7474
'@devframes/plugin-git': p('git/src/index.ts'),
7575
'devframe/recipes/interactive-auth': r('devframe/src/recipes/interactive-auth.ts'),
76+
'devframe/recipes/common-rpc-functions': r('devframe/src/recipes/common-rpc-functions.ts'),
7677
'devframe/recipes/open-helpers': r('devframe/src/recipes/open-helpers.ts'),
7778
'devframe/client': r('devframe/src/client/index.ts'),
7879
'devframe': r('devframe/src'),

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function helpersItems(prefix: string) {
5656
{ text: 'Vite Bridge', link: `${prefix}/helpers/vite-bridge` },
5757
{ text: 'Nuxt Module', link: `${prefix}/helpers/nuxt` },
5858
{ text: 'Next Helper', link: `${prefix}/helpers/next` },
59-
{ text: 'Open Helpers', link: `${prefix}/helpers/open-helpers` },
59+
{ text: 'Common RPC Functions', link: `${prefix}/helpers/common-rpc-functions` },
6060
{ text: 'Interactive Auth', link: `${prefix}/helpers/interactive-auth` },
6161
] satisfies DefaultTheme.NavItemWithLink[]
6262
}

docs/guide/standalone-cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ defineDevframe({
199199

200200
The adapter derives each flag's CAC option from its schema — booleans become `--verbose` / `--no-verbose`; everything else becomes `--depth <value>`. Keys are camelCase in TypeScript, kebab-case on the command line (`configFile``--config-file`). Flags that aren't in your schema (`--host`, `--port`, or anything added via `cli.configure`) still pass through untouched.
201201

202-
## Open helpers
202+
## Common RPC functions
203203

204-
For the two actions every CLI devtool needs — open a file in the editor, reveal a path in the OS file explorer — use the prebuilt recipes from `devframe/recipes/open-helpers` instead of re-implementing them. See [Helpers → Open Helpers](/helpers/open-helpers) for the full reference.
204+
For the two actions every CLI devtool needs — open a file in the editor, reveal a path in the OS file explorer — use the prebuilt recipes from `devframe/recipes/common-rpc-functions` instead of re-implementing them. See [Helpers → Common RPC Functions](/helpers/common-rpc-functions) for the full reference.
205205

206206
## Snapshot queries for static builds
207207

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
outline: deep
33
---
44

5-
# Open Helpers
5+
# Common RPC Functions
66

77
Prebuilt RPC actions for the two file-system actions every CLI devtool needs — opening a file in the editor, revealing a path in the OS file explorer. Use the recipe instead of re-implementing them so every devframe converges on the same registered names and payload shape.
88

99
```ts
10-
import { openHelpers } from 'devframe/recipes/open-helpers'
10+
import { commonRpcFunctions } from 'devframe/recipes/common-rpc-functions'
1111

1212
defineDevframe({
1313
id: 'my-tool',
1414
name: 'My Tool',
1515
setup(ctx) {
16-
openHelpers.forEach(fn => ctx.rpc.register(fn))
16+
commonRpcFunctions.forEach(fn => ctx.rpc.register(fn))
1717
},
1818
})
1919
```
@@ -24,16 +24,18 @@ defineDevframe({
2424
|--------|------------------|------|------|---------|
2525
| `openInEditor` | `devframe:open-in-editor` | `action` | `[filename: string]` | Open the file in the user's editor via [`launchEditor`](./utilities#devframe-utils-launch-editor). Accepts `file`, `file:line`, or `file:line:column`. |
2626
| `openInFinder` | `devframe:open-in-finder` | `action` | `[path: string]` | Reveal the path in the OS file explorer via [`open`](./utilities#devframe-utils-open). |
27-
| `openHelpers` || `readonly [openInEditor, openInFinder]` || Convenience array for batch registration. |
27+
| `commonRpcFunctions` || `readonly [openInEditor, openInFinder]` || Convenience array for batch registration. |
2828

2929
Both functions are `action`-type RPCs returning `void` and use `valibot` schemas (`v.string()`) for their single argument.
3030

31+
The `devframe/recipes/open-helpers` entry (`openHelpers`) remains as a deprecated alias for this module — new code should import `commonRpcFunctions` from `devframe/recipes/common-rpc-functions`.
32+
3133
## Pick and choose
3234

3335
Register only the helper you need rather than the whole array:
3436

3537
```ts
36-
import { openInEditor } from 'devframe/recipes/open-helpers'
38+
import { openInEditor } from 'devframe/recipes/common-rpc-functions'
3739

3840
defineDevframe({
3941
id: 'my-tool',

docs/helpers/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Helpers are the optional, opt-in surface around the core `defineDevframe` API: s
1212
| [Vite Bridge](./vite-bridge) | `devframe/helpers/vite` | Vite plugin for mounting a devframe inside any Vite-based host (Astro, SolidStart, plain Vite). |
1313
| [Nuxt Module](./nuxt) | `@devframes/nuxt` | Nuxt module that wires a Nuxt SPA as a devframe client and serves the dev-time RPC bridge. |
1414
| [Next Helper](./next) | `@devframes/next` | Route-handler host + React client for mounting devframes inside a Next.js App Router app (experimental). |
15-
| [Open Helpers](./open-helpers) | `devframe/recipes/open-helpers` | Prebuilt RPC actions for "open in editor" and "reveal in Finder". |
15+
| [Common RPC Functions](./common-rpc-functions) | `devframe/recipes/common-rpc-functions` | Prebuilt RPC actions for "open in editor" and "reveal in Finder". |
1616
| [Interactive Auth](./interactive-auth) | `devframe/recipes/interactive-auth` | Ready-made OTP auth layer — handshake, resolver gate, connect-time trust, and the code/link banner. |
1717

1818
Helpers vs. [adapters](/adapters/): an adapter takes a `DevframeDefinition` and deploys it as a runnable surface (CLI, dev server, static build, MCP server). A helper is a smaller piece — a Vite plugin, a Nuxt module, a recipe, a utility function — that you compose alongside an adapter.

docs/helpers/utilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ launchEditor('src/main.ts:42:7')
4646
launchEditor('src/main.ts:42:7', 'code')
4747
```
4848

49-
The auto-detection reads the `LAUNCH_EDITOR` environment variable and falls back to common defaults. Most devframes consume this through the prebuilt `openInEditor` recipe — see [Open helpers](./open-helpers).
49+
The auto-detection reads the `LAUNCH_EDITOR` environment variable and falls back to common defaults. Most devframes consume this through the prebuilt `openInEditor` recipe — see [Common RPC Functions](./common-rpc-functions).
5050

5151
### `devframe/utils/hash`
5252

packages/devframe/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"./node": "./dist/node/index.mjs",
3333
"./node/auth": "./dist/node/auth.mjs",
3434
"./node/hub-internals": "./dist/node/hub-internals.mjs",
35+
"./recipes/common-rpc-functions": "./dist/recipes/common-rpc-functions.mjs",
3536
"./recipes/interactive-auth": "./dist/recipes/interactive-auth.mjs",
3637
"./recipes/open-helpers": "./dist/recipes/open-helpers.mjs",
3738
"./rpc": "./dist/rpc/index.mjs",

packages/devframe/src/recipes/__tests__/open-helpers.test.ts renamed to packages/devframe/src/recipes/__tests__/common-rpc-functions.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { describe, expect, it } from 'vitest'
2-
import { openHelpers, openInEditor, openInFinder } from '../open-helpers'
2+
import { commonRpcFunctions, openInEditor, openInFinder } from '../common-rpc-functions'
3+
import { openHelpers } from '../open-helpers'
34

4-
describe('recipes/open-helpers', () => {
5+
describe('recipes/common-rpc-functions', () => {
56
it('exposes `openInEditor` as a devframe-namespaced action', () => {
67
expect(openInEditor.name).toBe('devframe:open-in-editor')
78
expect(openInEditor.type).toBe('action')
@@ -16,9 +17,13 @@ describe('recipes/open-helpers', () => {
1617
expect(typeof openInFinder.handler).toBe('function')
1718
})
1819

19-
it('bundles both helpers in `openHelpers`', () => {
20-
expect(openHelpers).toHaveLength(2)
21-
expect(openHelpers).toContain(openInEditor)
22-
expect(openHelpers).toContain(openInFinder)
20+
it('bundles both helpers in `commonRpcFunctions`', () => {
21+
expect(commonRpcFunctions).toHaveLength(2)
22+
expect(commonRpcFunctions).toContain(openInEditor)
23+
expect(commonRpcFunctions).toContain(openInFinder)
24+
})
25+
26+
it('keeps the deprecated `devframe/recipes/open-helpers` entry working as an alias', () => {
27+
expect(openHelpers).toBe(commonRpcFunctions)
2328
})
2429
})
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { launchEditor } from 'devframe/utils/launch-editor'
2+
import { open } from 'devframe/utils/open'
3+
import * as v from 'valibot'
4+
import { defineRpcFunction } from '../rpc/define'
5+
6+
/**
7+
* Prebuilt RPC action that opens a file in the user's configured editor.
8+
*
9+
* Registered name: `devframe:open-in-editor`.
10+
*
11+
* ```ts
12+
* import { openInEditor } from 'devframe/recipes/common-rpc-functions'
13+
*
14+
* defineDevframe({
15+
* id: 'my-tool',
16+
* name: 'My Tool',
17+
* setup(ctx) {
18+
* ctx.rpc.register(openInEditor)
19+
* },
20+
* })
21+
* ```
22+
*/
23+
export const openInEditor = defineRpcFunction({
24+
name: 'devframe:open-in-editor',
25+
type: 'action',
26+
jsonSerializable: true,
27+
args: [v.string()],
28+
returns: v.void(),
29+
async handler(filename: string) {
30+
launchEditor(filename)
31+
},
32+
})
33+
34+
/**
35+
* Prebuilt RPC action that reveals a path in the OS file explorer.
36+
*
37+
* Registered name: `devframe:open-in-finder`.
38+
*
39+
* ```ts
40+
* import { openInFinder } from 'devframe/recipes/common-rpc-functions'
41+
*
42+
* ctx.rpc.register(openInFinder)
43+
* ```
44+
*/
45+
export const openInFinder = defineRpcFunction({
46+
name: 'devframe:open-in-finder',
47+
type: 'action',
48+
jsonSerializable: true,
49+
args: [v.string()],
50+
returns: v.void(),
51+
async handler(path: string) {
52+
await open(path)
53+
},
54+
})
55+
56+
/**
57+
* Convenience array bundling both helpers so callers can register them
58+
* in a single `forEach`.
59+
*
60+
* ```ts
61+
* import { commonRpcFunctions } from 'devframe/recipes/common-rpc-functions'
62+
*
63+
* commonRpcFunctions.forEach(fn => ctx.rpc.register(fn))
64+
* ```
65+
*/
66+
export const commonRpcFunctions = [openInEditor, openInFinder] as const
Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,12 @@
1-
import { launchEditor } from 'devframe/utils/launch-editor'
2-
import { open } from 'devframe/utils/open'
3-
import * as v from 'valibot'
4-
import { defineRpcFunction } from '../rpc/define'
1+
// Deprecated compatibility shim for the open helpers recipe.
2+
//
3+
// Prefer the canonical `devframe/recipes/common-rpc-functions` entry. This
4+
// module re-exports the same implementation under the historical name so
5+
// existing imports keep working. It will be removed in a future major
6+
// release.
7+
import { commonRpcFunctions } from './common-rpc-functions'
58

6-
/**
7-
* Prebuilt RPC action that opens a file in the user's configured editor.
8-
*
9-
* Registered name: `devframe:open-in-editor`.
10-
*
11-
* ```ts
12-
* import { openInEditor } from 'devframe/recipes/open-helpers'
13-
*
14-
* defineDevframe({
15-
* id: 'my-tool',
16-
* name: 'My Tool',
17-
* setup(ctx) {
18-
* ctx.rpc.register(openInEditor)
19-
* },
20-
* })
21-
* ```
22-
*/
23-
export const openInEditor = defineRpcFunction({
24-
name: 'devframe:open-in-editor',
25-
type: 'action',
26-
jsonSerializable: true,
27-
args: [v.string()],
28-
returns: v.void(),
29-
async handler(filename: string) {
30-
launchEditor(filename)
31-
},
32-
})
9+
export { openInEditor, openInFinder } from './common-rpc-functions'
3310

34-
/**
35-
* Prebuilt RPC action that reveals a path in the OS file explorer.
36-
*
37-
* Registered name: `devframe:open-in-finder`.
38-
*
39-
* ```ts
40-
* import { openInFinder } from 'devframe/recipes/open-helpers'
41-
*
42-
* ctx.rpc.register(openInFinder)
43-
* ```
44-
*/
45-
export const openInFinder = defineRpcFunction({
46-
name: 'devframe:open-in-finder',
47-
type: 'action',
48-
jsonSerializable: true,
49-
args: [v.string()],
50-
returns: v.void(),
51-
async handler(path: string) {
52-
await open(path)
53-
},
54-
})
55-
56-
/**
57-
* Convenience array bundling both helpers so callers can register them
58-
* in a single `forEach`.
59-
*
60-
* ```ts
61-
* import { openHelpers } from 'devframe/recipes/open-helpers'
62-
*
63-
* openHelpers.forEach(fn => ctx.rpc.register(fn))
64-
* ```
65-
*/
66-
export const openHelpers = [openInEditor, openInFinder] as const
11+
/** @deprecated Use `commonRpcFunctions` from `devframe/recipes/common-rpc-functions` instead. */
12+
export const openHelpers: typeof commonRpcFunctions = commonRpcFunctions

0 commit comments

Comments
 (0)