@yaklabs-ai/plugin-sdk 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/THIRD-PARTY-INVENTORY.json +1 -1
- package/dist/disclosure.d.ts +32 -6
- package/dist/fs.js +1 -1
- package/dist/jev.d.ts +1 -1
- package/dist/kay-agent-testing.d.ts +30 -4
- package/dist/kay-agent.d.ts +255 -5
- package/dist/kay-agent.js +169 -2
- package/dist/kay-app.d.ts +172 -18
- package/dist/kay-app.js +8 -0
- package/dist/signals.d.ts +2 -2
- package/package.json +1 -1
- package/skills/directory-plugin-authoring/SKILL.md +18 -18
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: directory-plugin-authoring
|
|
3
|
-
description: "Author, scaffold, debug, or iterate on a Bonsai directory plugin (one the user writes in ~/.kay/plugins/<name>). Use when creating a new local plugin, when a plugin does not appear in Bonsai after installation, when enabling it fails with 'pluginActivation names a plugin that is not installed', when Settings → Plugins shows 'failed to load' with no toggle, when @
|
|
3
|
+
description: "Author, scaffold, debug, or iterate on a Bonsai directory plugin (one the user writes in ~/.kay/plugins/<name>). Use when creating a new local plugin, when a plugin does not appear in Bonsai after installation, when enabling it fails with 'pluginActivation names a plugin that is not installed', when Settings → Plugins shows 'failed to load' with no toggle, when @bonsai/plugin-sdk imports fail to resolve, when a plugin declares a ui.tsx that nothing typechecks, or when changes to a plugin do not take effect. For installing plugins from a git repository source, use the manage-plugins skill instead; for first-party bundled plugins under plugins/ in the kay repo, use the bundled-plugin guidance there."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Directory plugin authoring
|
|
@@ -14,7 +14,7 @@ keeps an agent on the paved path and out of the known pits.
|
|
|
14
14
|
|
|
15
15
|
`pnpm create-plugin` writes absolute type paths (`tsconfig.json`, `package.json`) pointing at
|
|
16
16
|
whichever Bonsai checkout invoked it, with no staleness warning. A checkout far behind `origin/main`
|
|
17
|
-
— one was 752 commits behind — typechecks the new plugin against stale `@
|
|
17
|
+
— one was 752 commits behind — typechecks the new plugin against stale `@bonsai/plugin-sdk` types,
|
|
18
18
|
and it looks clean: every wrong shape it produced (a `content` object instead of
|
|
19
19
|
`run`/`openBeside` on `PaneActionDescriptor`, `SearchField`'s `onChange` instead of
|
|
20
20
|
`onValueChange`, wrong `PageState` props) typechecked fine against the old types it was
|
|
@@ -27,7 +27,7 @@ git -C <kay-checkout> fetch origin && git -C <kay-checkout> rev-list --count HEA
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
A nonzero count means update that checkout first, or scaffold from a fresh `origin/main` worktree
|
|
30
|
-
and rebuild `@
|
|
30
|
+
and rebuild `@bonsai/plugin-sdk` there. A green typecheck against stale types is evidence of nothing.
|
|
31
31
|
The scaffold does the second half of this for you: it prints a warning when the checkout trails
|
|
32
32
|
its last-fetched `origin/main`, and stamps the checkout's commit into the generated
|
|
33
33
|
`tsconfig.json` header. It never fetches, so the `fetch` above is still yours to run; a checkout
|
|
@@ -36,7 +36,7 @@ that has not fetched in a week reads as current to the scaffold.
|
|
|
36
36
|
## Scaffold, never hand-roll
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
pnpm --filter @
|
|
39
|
+
pnpm --filter @bonsai/plugin-sdk build # once per checkout, if not built
|
|
40
40
|
pnpm create-plugin --id com.example.widgets
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -44,14 +44,14 @@ Run from the root of a Bonsai checkout. It writes a working plugin (manifest, en
|
|
|
44
44
|
README) that already typechecks and loads; `--tier starter` adds a URI module, a bundled skill,
|
|
45
45
|
and a standalone `node --test` test to copy from. Add `--ui` (either tier) when the plugin needs a
|
|
46
46
|
page: it writes `ui.tsx`, declares the `kay.ui` entrypoint, and generates the UI typecheck config
|
|
47
|
-
described below. `--ui` also needs `pnpm --filter @
|
|
47
|
+
described below. `--ui` also needs `pnpm --filter @bonsai/ui build` once per checkout; the scaffold
|
|
48
48
|
stops and says so when that build is missing.
|
|
49
49
|
|
|
50
50
|
Never hand-build a plugin as a tsc-compiled package and copy the output into `~/.kay/plugins/`.
|
|
51
|
-
That path produces a plugin whose built `dist/` imports `@
|
|
51
|
+
That path produces a plugin whose built `dist/` imports `@bonsai/plugin-sdk` through ordinary
|
|
52
52
|
`node_modules` resolution, which cannot work from outside the monorepo — it shipped a
|
|
53
53
|
failed-to-load plugin and a misfiled bug (#7732). The load fails with `ERR_MODULE_NOT_FOUND`,
|
|
54
|
-
and symlinking `node_modules/@
|
|
54
|
+
and symlinking `node_modules/@bonsai` into the copy does not rescue it either: pnpm's `.pnpm`
|
|
55
55
|
layout does not expose workspace packages that way. The scaffold exists precisely so this
|
|
56
56
|
cannot happen.
|
|
57
57
|
|
|
@@ -62,7 +62,7 @@ pnpm plugin:check ~/.kay/plugins/widgets
|
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Run from the root of a Bonsai checkout, against the plugin directory. It runs the daemon's OWN
|
|
65
|
-
manifest schema and contract resolver (imported from `@
|
|
65
|
+
manifest schema and contract resolver (imported from `@bonsai/plugin-protocol`, not re-implemented),
|
|
66
66
|
so it answers "would Kay accept this manifest?" in about a second instead of after a load cycle.
|
|
67
67
|
Run it after every manifest edit, and before concluding a plugin is broken for some deeper reason.
|
|
68
68
|
|
|
@@ -82,13 +82,13 @@ disclosure audit, or an id another installed plugin already claims.
|
|
|
82
82
|
|
|
83
83
|
## The SDK resolution contract
|
|
84
84
|
|
|
85
|
-
- Plugin source imports `@
|
|
86
|
-
(`@
|
|
85
|
+
- Plugin source imports `@bonsai/plugin-sdk/<subpath>` as a **bare specifier**
|
|
86
|
+
(`@bonsai/plugin-sdk/kay-agent`, `/kay-agent/testing`, `/kay-app`, `/disclosure` — only declared
|
|
87
87
|
exports exist).
|
|
88
88
|
- The daemon's chord loader bundles each declared TypeScript entrypoint and its relative imports.
|
|
89
|
-
It keeps `@
|
|
89
|
+
It keeps `@bonsai/plugin-sdk` imports external and resolves them to the running app's own built SDK.
|
|
90
90
|
Multi-file plugins are supported, and no plugin-local build is needed for Bonsai to load them.
|
|
91
|
-
- Corollary: **bare `node` outside the daemon cannot resolve `@
|
|
91
|
+
- Corollary: **bare `node` outside the daemon cannot resolve `@bonsai/plugin-sdk`** from the plugin
|
|
92
92
|
directory unless the plugin has its own SDK dependency. That failure says nothing about whether
|
|
93
93
|
the plugin will load in Bonsai. The `starter` tier's test setup creates the symlink needed for its
|
|
94
94
|
standalone test; a published SDK dependency is the other standalone option.
|
|
@@ -106,7 +106,7 @@ entrypoint may import other files in the plugin; `kay.agent` runs in the daemon
|
|
|
106
106
|
self-contained module: unlike the daemon targets, `ui.tsx` cannot import sibling files. A
|
|
107
107
|
plugin UI contributes through `api.slots` (`registerPage`, `registerSidebarItem`,
|
|
108
108
|
`registerPaneAction`, and the rest of `buildSlots` in
|
|
109
|
-
`
|
|
109
|
+
`packages/kay-renderer/src/renderer/src/extension-loader/build-extension-api.ts`). A page gets its own
|
|
110
110
|
activity-rail button when a `registerSidebarItem({ pageId, placement: "activityRail" })` from the
|
|
111
111
|
same plugin points at it.
|
|
112
112
|
|
|
@@ -119,17 +119,17 @@ and its rail item borrow each other's glyph, so one declaration covers the desti
|
|
|
119
119
|
precedence: `packages/kay-frontend-sdk/ARCHITECTURE.md`, "Plugin icon".
|
|
120
120
|
|
|
121
121
|
`ui.tsx` has no `node_modules` of its own. The renderer bundles it and rewrites its `react` and
|
|
122
|
-
`@
|
|
122
|
+
`@bonsai/*` imports to the host's `__KAY_UI_RUNTIME__` singletons, so the agent `tsconfig.json`
|
|
123
123
|
cannot cover it, and a plugin whose UI nothing typechecks has shipped three wrong API shapes at
|
|
124
124
|
once. `pnpm create-plugin --ui` generates `tsconfig.ui.json` for exactly this: its `paths` are
|
|
125
|
-
derived from the bundler's own shim set (`uiRuntimeShimModules` in `@
|
|
125
|
+
derived from the bundler's own shim set (`uiRuntimeShimModules` in `@bonsai/ui-app-bundler`), each
|
|
126
126
|
specifier mapped to the type entry the renderer binds it to, and `npm run typecheck` runs both
|
|
127
127
|
configs. Do not hand-write the map; when the bundler's set changes, the scaffold's test fails and
|
|
128
128
|
the generated config follows.
|
|
129
129
|
|
|
130
130
|
Two facts about that config worth knowing when you read errors from it:
|
|
131
131
|
|
|
132
|
-
- The bare `@
|
|
132
|
+
- The bare `@bonsai/frontend-sdk` is typed against the SDK's `ui-runtime` facade, because that is
|
|
133
133
|
what the renderer binds it to. The facade carries the SDK's whole type surface, so
|
|
134
134
|
`KayUiExtensionApi` and every descriptor type import fine; a **value** only the package's main
|
|
135
135
|
entry exports fails to compile there (TS1362, "exported using export type"), which is the
|
|
@@ -210,9 +210,9 @@ a failure class the load would otherwise be the first thing to surface:
|
|
|
210
210
|
|
|
211
211
|
1. **Run `pnpm plugin:check <dir>`** from a Bonsai checkout. It validates `kay-plugin.json` against
|
|
212
212
|
`KayPluginManifestV1` and resolves its contributions with the daemon's own resolver (both from
|
|
213
|
-
`@
|
|
213
|
+
`@bonsai/plugin-protocol`), not just "it is valid JSON": that schema and resolver are the gate the
|
|
214
214
|
scan actually runs. A non-zero exit means the plugin would be refused.
|
|
215
|
-
2. **Run the disclosure audit yourself**: `auditPluginDisclosure` from `@
|
|
215
|
+
2. **Run the disclosure audit yourself**: `auditPluginDisclosure` from `@bonsai/plugin-sdk/disclosure`.
|
|
216
216
|
It is not redundant with typecheck. A plugin shipped a `search` verb with no `verbDocs` entry
|
|
217
217
|
that typechecked clean and would have failed the whole `kay.agent` target.
|
|
218
218
|
3. **Typecheck every target**: `npm run typecheck` runs the agent config and, for a `--ui`
|