Skip to content

Commit eb62a84

Browse files
antfubotopencode
andauthored
refactor: unify plugin RPC namespaces to devframes:plugin:<slug>:<fn> (#105)
Co-authored-by: opencode <noreply@opencode.ai>
1 parent 44d9420 commit eb62a84

108 files changed

Lines changed: 315 additions & 315 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The `pnpm test` script intentionally runs `build` first so `tsnapi` snapshots co
3535

3636
## Conventions
3737

38-
- RPC functions must use `defineRpcFunction`; always namespace IDs (`my-plugin:fn-name`).
38+
- RPC functions must use `defineRpcFunction`; always namespace IDs `devframes:plugin:<slug>:<fn-name>` (matching the plugin's `@devframes/plugin-<slug>` package name).
3939
- Shared state via `devframe/utils/shared-state`; keep values serializable.
4040
- Utility imports use the package-path form `devframe/utils/*`, never relative `../utils/*`.
4141
- Dependencies go through the pnpm catalogs in `pnpm-workspace.yaml` (`cli`, `inlined`, `testing`, `types`) — add to a catalog and reference as `catalog:<name>`, don't pin versions in `package.json`.

docs/errors/DF8107.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ This is a warning, not a thrown error: the activation is still broadcast so a do
1616

1717
## Fix
1818

19-
Pass a `dockId` that matches a registered dock entry. Ids are case-sensitive, so check for typos, and make sure the target dock is registered before activating it. For the terminals dock the id is `devframes-plugin-terminals`:
19+
Pass a `dockId` that matches a registered dock entry. Ids are case-sensitive, so check for typos, and make sure the target dock is registered before activating it. For the terminals dock the id is `devframes_plugin_terminals`:
2020

2121
```ts
2222
await rpc.call('hub:docks:activate', {
23-
dockId: 'devframes-plugin-terminals',
23+
dockId: 'devframes_plugin_terminals',
2424
params: { sessionId },
2525
})
2626
```

docs/guide/hub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The viewer's active dock is client-local state — which dock is on screen lives
3535
```ts
3636
// From inside a mounted devframe's iframe (its own RPC client):
3737
await rpc.call('hub:docks:activate', {
38-
dockId: 'devframes-plugin-terminals',
38+
dockId: 'devframes_plugin_terminals',
3939
params: { sessionId }, // opaque bag the target dock interprets
4040
})
4141
```

docs/plugins/code-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default createCodeServerDevframe({
4949

5050
## RPC surface
5151

52-
All functions are namespaced `devframes-plugin-code-server:*`:
52+
All functions are namespaced `devframes:plugin:code-server:*`:
5353

5454
| Function | Type | Purpose |
5555
|----------|------|---------|

docs/plugins/git.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ await createCac(createGitDevframe({ repoRoot: process.cwd() })).parse()
4141

4242
The read functions are each a `query` with `snapshot: true` — resolved live over WebSocket in dev, and served from a snapshot baked at build time for static deploys. Each degrades to an empty, `isRepo: false` result outside a git repository.
4343

44-
- `git:status` — branch, upstream tracking, and staged / unstaged / untracked files.
45-
- `git:log` — paginated commit history including parent hashes, which drive the commit graph.
46-
- `git:branches` — local branches with SHA, upstream, ahead / behind, and tip subject.
47-
- `git:diff` — per-file added / deleted counts plus a unified patch for a selected file.
44+
- `devframes:plugin:git:status` — branch, upstream tracking, and staged / unstaged / untracked files.
45+
- `devframes:plugin:git:log` — paginated commit history including parent hashes, which drive the commit graph.
46+
- `devframes:plugin:git:branches` — local branches with SHA, upstream, ahead / behind, and tip subject.
47+
- `devframes:plugin:git:diff` — per-file added / deleted counts plus a unified patch for a selected file.
4848

49-
Write actions (`git:stage`, `git:unstage`, `git:commit`) are `action` functions, registered only when write mode is enabled.
49+
Write actions (`devframes:plugin:git:stage`, `devframes:plugin:git:unstage`, `devframes:plugin:git:commit`) are `action` functions, registered only when write mode is enabled.
5050

5151
## Source
5252

docs/plugins/inspect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ await createCac(createInspectDevframe({ port: 9100 })).parse()
5252

5353
## RPC surface
5454

55-
All functions are namespaced `devframes-plugin-inspect:*`:
55+
All functions are namespaced `devframes:plugin:inspect:*`:
5656

5757
| Function | Type | Returns |
5858
|----------|------|---------|

docs/plugins/terminals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ export default createTerminalsDevframe({
5252

5353
## Hub aggregation
5454

55-
Mounted into a hub, the plugin owns PTY/child-process spawning and its own streaming channel (`devframes-plugin-terminals:output`) — that's what the panel renders. It also mirrors every session it spawns into `ctx.terminals` (the hub's aggregate registry, streaming on `devframe:terminals`) so other tools — a launcher dock, a custom panel — see the same session list without depending on the plugin's own types. A session started the other way, via `ctx.terminals.startChildProcess` / `startPtySession` directly (e.g. from a launcher dock), shows up in the terminals panel too — the plugin reads foreign hub sessions read-only and renders them alongside its own, subscribing to the hub's channel for their output.
55+
Mounted into a hub, the plugin owns PTY/child-process spawning and its own streaming channel (`devframes:plugin:terminals:output`) — that's what the panel renders. It also mirrors every session it spawns into `ctx.terminals` (the hub's aggregate registry, streaming on `devframe:terminals`) so other tools — a launcher dock, a custom panel — see the same session list without depending on the plugin's own types. A session started the other way, via `ctx.terminals.startChildProcess` / `startPtySession` directly (e.g. from a launcher dock), shows up in the terminals panel too — the plugin reads foreign hub sessions read-only and renders them alongside its own, subscribing to the hub's channel for their output.
5656

5757
`ctx.terminals` is the source of truth for "what sessions exist"; the plugin is the panel that renders them and the one PTY-capable provider among possibly several session sources. The plugin never imports `@devframes/hub`'s types to stay mountable without a hub — it duck-types the minimal `register` / `update` / `events` shape it needs.
5858

5959
A session from `ctx.terminals.startChildProcess()` carries a `getResult()` accessor shaped like `tinyexec`'s `Result``await`able to `{ stdout, stderr, exitCode }` (captured separately from the merged display stream), with live `pid` / `exitCode` / `killed` getters and `kill()` in the meantime. That's the seam for migrating an existing `tinyexec`/`execa`-based "run a subprocess and get its result" API onto the hub's terminals: keep the same calling code, swap the runner for `startChildProcess()`, and the session's output shows up in every hub-aware terminal panel for free.
6060

6161
## Focusing a session
6262

63-
The panel reacts to the hub's [cross-iframe dock activation](/guide/hub#cross-iframe-dock-activation): when an activation targets this dock (`dockId: 'devframes-plugin-terminals'`) and carries a `sessionId`, the panel selects that session. This lets another tool spawn a build and jump the user straight to its output:
63+
The panel reacts to the hub's [cross-iframe dock activation](/guide/hub#cross-iframe-dock-activation): when an activation targets this dock (`dockId: 'devframes_plugin_terminals'`) and carries a `sessionId`, the panel selects that session. This lets another tool spawn a build and jump the user straight to its output:
6464

6565
```ts
6666
// e.g. right after ctx.terminals.startChildProcess(..., { id: sessionId, ... })
6767
await rpc.call('hub:docks:activate', {
68-
dockId: 'devframes-plugin-terminals',
68+
dockId: 'devframes_plugin_terminals',
6969
params: { sessionId },
7070
})
7171
```

examples/minimal-next-devframe-hub/tests/minimal-next-devframe-hub.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ describe('minimal-next-devframe-hub (example)', () => {
3939
expect(dockIds).toContain('~settings')
4040
expect(docks.find(d => d.id === '~settings')?.category).toBe('~builtin')
4141
// The dogfooded built-in plugin packages mount their own docks.
42-
expect(dockIds).toContain('devframes-plugin-terminals')
43-
expect(dockIds).toContain('devframes-plugin-messages')
42+
expect(dockIds).toContain('devframes_plugin_terminals')
43+
expect(dockIds).toContain('devframes_plugin_messages')
4444
})
4545

4646
it('lists startup and demo messages through the kit-local RPC', async () => {

packages/hub/src/client/__tests__/host.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@ describe('createDevframeClientHost', () => {
125125
it('switches the active dock when the hub broadcasts devframe:docks:activate', async () => {
126126
const { rpc, states, definitions } = createStubRpc()
127127
const host = await createDevframeClientHost({ rpc })
128-
states.get('devframe:docks')!.push([iframeEntry('one'), iframeEntry('devframes-plugin-terminals')])
128+
states.get('devframe:docks')!.push([iframeEntry('one'), iframeEntry('devframes_plugin_terminals')])
129129

130130
// Simulate the hub's server→client broadcast.
131131
const handler = definitions.get('devframe:docks:activate')!.handler!
132-
handler({ dockId: 'devframes-plugin-terminals', params: { sessionId: 'sess-1' } })
133-
await vi.waitFor(() => expect(host.context.docks.selectedId).toBe('devframes-plugin-terminals'))
132+
handler({ dockId: 'devframes_plugin_terminals', params: { sessionId: 'sess-1' } })
133+
await vi.waitFor(() => expect(host.context.docks.selectedId).toBe('devframes_plugin_terminals'))
134134

135135
// Unknown dock ids degrade to a no-op (the previous selection stands).
136136
handler({ dockId: 'ghost' })
137137
await new Promise(r => setTimeout(r, 0))
138-
expect(host.context.docks.selectedId).toBe('devframes-plugin-terminals')
138+
expect(host.context.docks.selectedId).toBe('devframes_plugin_terminals')
139139
host.dispose()
140140
})
141141

packages/hub/src/node/__tests__/context.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ describe('createHubContext dock activation', () => {
3737
})
3838
context.docks.register({
3939
type: 'iframe',
40-
id: 'devframes-plugin-terminals',
40+
id: 'devframes_plugin_terminals',
4141
title: 'Terminals',
4242
icon: 'ph:terminal-window-duotone',
43-
url: '/__devframes-plugin-terminals/',
43+
url: '/__devframes_plugin_terminals/',
4444
})
4545

4646
const broadcast = vi.spyOn(context.rpc, 'broadcast').mockResolvedValue()
47-
context.docks.activate('devframes-plugin-terminals', { sessionId: 'sess-1' })
47+
context.docks.activate('devframes_plugin_terminals', { sessionId: 'sess-1' })
4848

4949
const active = await context.rpc.sharedState.get<{ activation: unknown }>('devframe:docks:active')
5050
expect(active.value().activation).toEqual({
51-
dockId: 'devframes-plugin-terminals',
51+
dockId: 'devframes_plugin_terminals',
5252
params: { sessionId: 'sess-1' },
5353
})
5454
expect(broadcast).toHaveBeenCalledWith({
5555
method: 'devframe:docks:activate',
56-
args: [{ dockId: 'devframes-plugin-terminals', params: { sessionId: 'sess-1' } }],
56+
args: [{ dockId: 'devframes_plugin_terminals', params: { sessionId: 'sess-1' } }],
5757
})
5858
broadcast.mockRestore()
5959
})

0 commit comments

Comments
 (0)