@yaklabs-ai/plugin-sdk 0.12.3 → 0.12.4
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 +5 -3
- package/THIRD-PARTY-INVENTORY.json +8 -1
- package/dist/disclosure.d.ts +2 -1
- package/dist/disclosure.js +21 -8
- package/dist/kay-app.d.ts +127 -0
- package/package.json +3 -2
- package/skills/directory-plugin-authoring/SKILL.md +42 -8
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ it under the name your plugin code actually imports:
|
|
|
13
13
|
```json
|
|
14
14
|
{
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@kay/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.12.
|
|
16
|
+
"@kay/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.12.4"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
```
|
|
@@ -131,8 +131,10 @@ Pass the loader's inputs, not a subset — the audit judges what it is given:
|
|
|
131
131
|
violations Kay itself would not report.
|
|
132
132
|
|
|
133
133
|
`auditSkillCodegenPairs({ declaredSkills, exportedSkills, packageDir })` is the
|
|
134
|
-
companion check for a bundled-skill plugin.
|
|
135
|
-
|
|
134
|
+
companion check for a bundled-skill plugin. It compares the decoded YAML
|
|
135
|
+
`name` and `description` with the export, so quoting and block scalars are
|
|
136
|
+
supported; body content must match after trimming surrounding whitespace.
|
|
137
|
+
Both return violations rather than asserting, so any runner works. Both read from disk
|
|
136
138
|
and call your own `help()`, so run them in Node, and keep `activate` free of
|
|
137
139
|
side effects: the probe calls it.
|
|
138
140
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"package": "@yaklabs-ai/plugin-sdk",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.4",
|
|
5
5
|
"target": "npm",
|
|
6
6
|
"firstPartyLicense": "MIT",
|
|
7
7
|
"bundled": [
|
|
@@ -53,6 +53,13 @@
|
|
|
53
53
|
"source": "https://github.com/colinhacks/zod",
|
|
54
54
|
"note": "Installed as a consumer dependency; it is not bundled into the staged artifacts.",
|
|
55
55
|
"versionRange": "^4.0.0"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "yaml",
|
|
59
|
+
"license": "ISC",
|
|
60
|
+
"source": "https://github.com/eemeli/yaml",
|
|
61
|
+
"note": "Installed as a consumer dependency; it is not bundled into the staged artifacts.",
|
|
62
|
+
"versionRange": "^2.9.0"
|
|
56
63
|
}
|
|
57
64
|
]
|
|
58
65
|
}
|
package/dist/disclosure.d.ts
CHANGED
|
@@ -213,7 +213,8 @@ export declare interface AuditPluginDisclosureInput {
|
|
|
213
213
|
* The codegen-pair equivalence check every bundled-skill plugin hand-rolled (see
|
|
214
214
|
* `plugins/ARCHITECTURE.md` → "Bundled skills", step 4): every exported `PluginSkillDefinition`
|
|
215
215
|
* must have a matching manifest declaration (same `localId`, same `description`), and the
|
|
216
|
-
* declared `SKILL.md` file's
|
|
216
|
+
* declared `SKILL.md` file's decoded YAML name and description must match the export.
|
|
217
|
+
* The body is compared byte-for-byte after trimming surrounding whitespace.
|
|
217
218
|
*/
|
|
218
219
|
export declare function auditSkillCodegenPairs(input: AuditSkillCodegenPairsInput): Promise<readonly DisclosureViolation[]>;
|
|
219
220
|
|
package/dist/disclosure.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/plugin-sdk/dist/disclosure/disclosure-conformance.js
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
3
4
|
|
|
4
5
|
// packages/herd-uri/dist/connection.js
|
|
5
6
|
var CONNECTION_SELECTOR_RE = /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)@([^/]+)(?:\/(.*))?$/;
|
|
@@ -700,24 +701,36 @@ async function auditSkillCodegenPairFile(skill, declaration, packageDir) {
|
|
|
700
701
|
];
|
|
701
702
|
}
|
|
702
703
|
const codegenPairMatch = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/.exec(file);
|
|
703
|
-
const
|
|
704
|
-
|
|
704
|
+
const yaml = codegenPairMatch?.[1];
|
|
705
|
+
let frontmatter = {};
|
|
706
|
+
let parseError;
|
|
707
|
+
if (yaml !== void 0) {
|
|
708
|
+
try {
|
|
709
|
+
const parsed = parseYaml(yaml);
|
|
710
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
711
|
+
frontmatter = parsed;
|
|
712
|
+
} else {
|
|
713
|
+
parseError = "frontmatter must be a YAML mapping";
|
|
714
|
+
}
|
|
715
|
+
} catch (error) {
|
|
716
|
+
parseError = errorMessage(error);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const parseDetail = parseError === void 0 ? "" : ` Could not parse '${declaration.path}': ${parseError}`;
|
|
705
720
|
const body = codegenPairMatch?.[2];
|
|
706
721
|
const violations = [];
|
|
707
|
-
if (frontmatter
|
|
708
|
-
`)) {
|
|
722
|
+
if (frontmatter["name"] !== skill.name) {
|
|
709
723
|
violations.push({
|
|
710
724
|
moduleId: skill.name,
|
|
711
725
|
rule: "skill-twin-frontmatter-name-mismatch",
|
|
712
|
-
detail: `SKILL.md frontmatter does not
|
|
726
|
+
detail: `SKILL.md frontmatter name does not match the exported name '${skill.name}'.${parseDetail}`
|
|
713
727
|
});
|
|
714
728
|
}
|
|
715
|
-
if (frontmatter
|
|
716
|
-
`)) {
|
|
729
|
+
if (frontmatter["description"] !== skill.description) {
|
|
717
730
|
violations.push({
|
|
718
731
|
moduleId: skill.name,
|
|
719
732
|
rule: "skill-twin-frontmatter-description-mismatch",
|
|
720
|
-
detail:
|
|
733
|
+
detail: `SKILL.md frontmatter description does not match the exported description.${parseDetail}`
|
|
721
734
|
});
|
|
722
735
|
}
|
|
723
736
|
if (body === void 0 || body.trim() !== skill.content.trim()) {
|
package/dist/kay-app.d.ts
CHANGED
|
@@ -2322,6 +2322,30 @@ export declare interface KayAppEndpoints {
|
|
|
2322
2322
|
register(name: string, handler: (payload: unknown) => unknown | Promise<unknown>): void;
|
|
2323
2323
|
}
|
|
2324
2324
|
|
|
2325
|
+
/**
|
|
2326
|
+
* The plugin-facing `kay.app` repository contract: what git checkout encloses a folder, read by
|
|
2327
|
+
* the host.
|
|
2328
|
+
*
|
|
2329
|
+
* Ungated and always present, like `app.paths`: a plugin runs in the daemon's process and could
|
|
2330
|
+
* read these files itself. What `app.repos` adds is that the host reads them asynchronously, under
|
|
2331
|
+
* a time limit, and shares one cache with the daemon. A plugin that reads `.git` files with
|
|
2332
|
+
* `node:fs` sync calls blocks the daemon's event loop for as long as each read takes, which on a
|
|
2333
|
+
* protected or unresponsive folder can be a very long time (kay#11575).
|
|
2334
|
+
*/
|
|
2335
|
+
/** One `[remote "<name>"]` in the repository's common `config`. */
|
|
2336
|
+
export declare interface KayAppGitRemote {
|
|
2337
|
+
readonly name: string;
|
|
2338
|
+
/** The `url =` value as written, still usable to connect. */
|
|
2339
|
+
readonly url: string;
|
|
2340
|
+
/**
|
|
2341
|
+
* `url` reduced to a key that is the same however the repository is addressed: no scheme, user
|
|
2342
|
+
* or port, lowercase host, no trailing `.git` (`git@github.com:org/repo.git` and
|
|
2343
|
+
* `https://github.com/org/repo` are both `github.com/org/repo`). Absent when `url` reduces to
|
|
2344
|
+
* nothing. For `owner/repo`, take the last two `/` segments.
|
|
2345
|
+
*/
|
|
2346
|
+
readonly identity?: string;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2325
2349
|
/** A real human carrier projected into the source session's transcript. */
|
|
2326
2350
|
export declare interface KayAppHumanMessageSessionEvent extends KayAppSessionEventBase {
|
|
2327
2351
|
readonly type: "human-message";
|
|
@@ -2698,6 +2722,13 @@ export declare interface KayAppPluginApi {
|
|
|
2698
2722
|
* `Intl` or `process.env.TZ`; see {@link KayAppTime.snapshot}.
|
|
2699
2723
|
*/
|
|
2700
2724
|
readonly time: KayAppTime;
|
|
2725
|
+
/**
|
|
2726
|
+
* Git facts about any folder (its checkout, primary checkout, common dir, remotes, and git's
|
|
2727
|
+
* linked-worktree registry), read by the host asynchronously and under a time limit. Always
|
|
2728
|
+
* present and ungated, like {@link paths}. Use it instead of reading `.git` files with `node:fs`,
|
|
2729
|
+
* which blocks the daemon; see {@link KayAppRepos}.
|
|
2730
|
+
*/
|
|
2731
|
+
readonly repos: KayAppRepos;
|
|
2701
2732
|
/**
|
|
2702
2733
|
* Read/arrange access to the live desktop workspace. Present whenever the host has a workspace
|
|
2703
2734
|
* (a headless daemon may not); absence is a host fact, never a grant signal. Reading the snapshot
|
|
@@ -2872,6 +2903,102 @@ export declare interface KayAppRegisterUriModuleOptions {
|
|
|
2872
2903
|
readonly scope: "app";
|
|
2873
2904
|
}
|
|
2874
2905
|
|
|
2906
|
+
/** The git checkout that encloses a folder. Paths are absolute and not resolved through symlinks. */
|
|
2907
|
+
export declare interface KayAppRepoFacts {
|
|
2908
|
+
/** The directory holding the `.git` entry: the nearest checkout at or above the folder. */
|
|
2909
|
+
readonly repoRoot: string;
|
|
2910
|
+
/**
|
|
2911
|
+
* This checkout's own git directory: `<repoRoot>/.git`, or the target of a `.git` pointer file
|
|
2912
|
+
* (a linked worktree or a submodule). `null` when the pointer could not be read.
|
|
2913
|
+
*/
|
|
2914
|
+
readonly gitDir: string | null;
|
|
2915
|
+
/**
|
|
2916
|
+
* The git directory every worktree of the repository shares, as `git rev-parse
|
|
2917
|
+
* --git-common-dir` names it; for a submodule, its own `.git/modules/<name>`. `null` when the
|
|
2918
|
+
* host cannot place it (an unreadable pointer or `commondir` file).
|
|
2919
|
+
*/
|
|
2920
|
+
readonly commonDir: string | null;
|
|
2921
|
+
/**
|
|
2922
|
+
* The primary checkout that owns a linked worktree; `repoRoot` itself for an ordinary
|
|
2923
|
+
* checkout, a submodule, or a worktree of a bare repository. Every worktree of one repository
|
|
2924
|
+
* shares this value.
|
|
2925
|
+
*/
|
|
2926
|
+
readonly primaryCheckoutRoot: string;
|
|
2927
|
+
/** A stable name for the repository: the primary checkout's directory name. */
|
|
2928
|
+
readonly displayName: string;
|
|
2929
|
+
/** Every remote in the common `config`, in file order. Empty when the config is unreadable. */
|
|
2930
|
+
readonly remotes: readonly KayAppGitRemote[];
|
|
2931
|
+
/**
|
|
2932
|
+
* The `origin` remote. `absent` means the config was read and has no origin; `unavailable`
|
|
2933
|
+
* means the config could not be read, which is not the same answer and is usually temporary.
|
|
2934
|
+
*/
|
|
2935
|
+
readonly origin: {
|
|
2936
|
+
readonly kind: "origin";
|
|
2937
|
+
readonly url: string;
|
|
2938
|
+
readonly identity: string;
|
|
2939
|
+
} | {
|
|
2940
|
+
readonly kind: "absent";
|
|
2941
|
+
} | {
|
|
2942
|
+
readonly kind: "unavailable";
|
|
2943
|
+
readonly detail: string;
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
export declare interface KayAppRepoReadOptions {
|
|
2948
|
+
/**
|
|
2949
|
+
* How old a cached answer may be, in milliseconds. `0` asks the host to read again; `Infinity`
|
|
2950
|
+
* accepts any cached answer. Default 5000.
|
|
2951
|
+
*/
|
|
2952
|
+
readonly maxAgeMs?: number;
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
/** What the host knows about one folder. */
|
|
2956
|
+
export declare type KayAppRepoResolution = {
|
|
2957
|
+
readonly kind: "resolved";
|
|
2958
|
+
/** The folder asked about, as an absolute path. */
|
|
2959
|
+
readonly folder: string;
|
|
2960
|
+
/**
|
|
2961
|
+
* Whether the folder itself exists. A folder that is gone still reports the checkout that
|
|
2962
|
+
* encloses where it was, so a deleted subdirectory keeps its repository.
|
|
2963
|
+
*/
|
|
2964
|
+
readonly folderExists: boolean;
|
|
2965
|
+
/** `null` when no checkout encloses the folder. */
|
|
2966
|
+
readonly repo: KayAppRepoFacts | null;
|
|
2967
|
+
} | {
|
|
2968
|
+
/**
|
|
2969
|
+
* The host could not answer: `timeout` when the reads took longer than the host's time limit
|
|
2970
|
+
* (the folder may be on an unresponsive drive), `error` when they failed unexpectedly. Not
|
|
2971
|
+
* cached, so asking again later may succeed. Treat it as "do not know", never as "no repo".
|
|
2972
|
+
*/
|
|
2973
|
+
readonly kind: "unknown";
|
|
2974
|
+
readonly folder: string;
|
|
2975
|
+
readonly reason: "timeout" | "error";
|
|
2976
|
+
readonly detail: string;
|
|
2977
|
+
};
|
|
2978
|
+
|
|
2979
|
+
/**
|
|
2980
|
+
* `app.repos`: git facts about folders, read by the host. Added in SDK 0.12.4: a plugin that calls
|
|
2981
|
+
* it declares `compatibility.sdk` `^0.12.4`, so an older Bonsai refuses a directory or repository
|
|
2982
|
+
* plugin at load instead of the call failing.
|
|
2983
|
+
*
|
|
2984
|
+
* Both members never reject and do not use `this`, so they are safe to destructure. Call them
|
|
2985
|
+
* where you need the answer, not inside `activate()`.
|
|
2986
|
+
*/
|
|
2987
|
+
export declare interface KayAppRepos {
|
|
2988
|
+
/**
|
|
2989
|
+
* The checkout that encloses `folder` (an absolute path), or why the host could not tell. A
|
|
2990
|
+
* relative path answers `unknown`.
|
|
2991
|
+
*/
|
|
2992
|
+
readonly resolve: (folder: string, options?: KayAppRepoReadOptions) => Promise<KayAppRepoResolution>;
|
|
2993
|
+
/**
|
|
2994
|
+
* The working directories of the linked worktrees git has registered under `commonDir`
|
|
2995
|
+
* (`<commonDir>/worktrees/<name>/gitdir`), including ones whose directory has since been
|
|
2996
|
+
* deleted. Empty when there are none; `undefined` when the registry or one of its entries could
|
|
2997
|
+
* not be read, or not in time. `undefined` is not cached; treat it as "do not know".
|
|
2998
|
+
*/
|
|
2999
|
+
readonly linkedWorktrees: (commonDir: string, options?: KayAppRepoReadOptions) => Promise<readonly string[] | undefined>;
|
|
3000
|
+
}
|
|
3001
|
+
|
|
2875
3002
|
/** What the plugin is asking for, and what it intends to do with it. */
|
|
2876
3003
|
export declare interface KayAppResolveCredentialRequest {
|
|
2877
3004
|
/** An auth service this plugin's own manifest declares, by its LOCAL id. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaklabs-ai/plugin-sdk",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "The Kay plugin SDK — types and helpers for authoring a Kay directory plugin.",
|
|
5
5
|
"author": "YakLabs",
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"skills"
|
|
52
52
|
],
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"zod": "^4.0.0"
|
|
54
|
+
"zod": "^4.0.0",
|
|
55
|
+
"yaml": "^2.9.0"
|
|
55
56
|
},
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"registry": "https://registry.npmjs.org",
|
|
@@ -55,6 +55,31 @@ and symlinking `node_modules/@kay` into the copy does not rescue it either: pnpm
|
|
|
55
55
|
layout does not expose workspace packages that way. The scaffold exists precisely so this
|
|
56
56
|
cannot happen.
|
|
57
57
|
|
|
58
|
+
## Check the manifest before you wait for a load
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
pnpm plugin:check ~/.kay/plugins/widgets
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run from the root of a Kay checkout, against the plugin directory. It runs the daemon's OWN
|
|
65
|
+
manifest schema and contract resolver (imported from `@kay/plugin-protocol`, not re-implemented),
|
|
66
|
+
so it answers "would Kay accept this manifest?" in about a second instead of after a load cycle.
|
|
67
|
+
Run it after every manifest edit, and before concluding a plugin is broken for some deeper reason.
|
|
68
|
+
|
|
69
|
+
It prints the resolved global contribution ids, exits non-zero when the plugin would be refused,
|
|
70
|
+
and separates the two outcomes that look alike from outside:
|
|
71
|
+
|
|
72
|
+
- **Refused outright** — schema-invalid manifest, a reserved `kay.*` / `herd.*` id, a declared
|
|
73
|
+
path escaping the plugin directory, or contributions that do not resolve. Every contribution
|
|
74
|
+
shares ONE flat `<namespace>.<localId>` space ACROSS kinds, so a tool and an endpoint both
|
|
75
|
+
called `inspect` collide and the whole plugin is refused (#8936).
|
|
76
|
+
- **Loads, minus something** — a retired `compatibility` / `permissions.byTarget` key the parser
|
|
77
|
+
strips silently, a `toolName` that is not the namespace-derived name (that tool is excluded and
|
|
78
|
+
nothing tells the user), a missing entrypoint or skill file.
|
|
79
|
+
|
|
80
|
+
It reads the manifest only. A clean verdict says nothing about `activate()` throwing, the
|
|
81
|
+
disclosure audit, or an id another installed plugin already claims.
|
|
82
|
+
|
|
58
83
|
## The SDK resolution contract
|
|
59
84
|
|
|
60
85
|
- Plugin source imports `@kay/plugin-sdk/<subpath>` as a **bare specifier**
|
|
@@ -123,8 +148,10 @@ edited.
|
|
|
123
148
|
IS a git repository: a version is a commit, and a directory without git backing fails to
|
|
124
149
|
load (the plugin's row says exactly that, with the fix). So after writing the files, commit
|
|
125
150
|
them: `git init && git add -A && git commit -m "adopt plugin"` inside the plugin directory.
|
|
126
|
-
The daemon watches the root,
|
|
127
|
-
|
|
151
|
+
The daemon watches the root and, under the watch, checks each plugin's Git HEAD every 5
|
|
152
|
+
seconds, so it notices the plugin by itself within about 10 seconds even when file events
|
|
153
|
+
are not arriving: no verb called and no restart. The source refresh verb forces the walk if
|
|
154
|
+
you want it now.
|
|
128
155
|
|
|
129
156
|
The root is `<home>/.kay/plugins`, and **`<home>` is the running instance's home**: a dev
|
|
130
157
|
app launched against its own state root has its own plugins root, not your real
|
|
@@ -144,9 +171,13 @@ list` names the exact local root — because writing into the wrong one produces
|
|
|
144
171
|
commit** identifies the serving snapshot. Try new tools in a fresh session;
|
|
145
172
|
an existing session may still hold its previous generation.
|
|
146
173
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
174
|
+
Kay notices a commit within about 10 seconds even with no file events, and acquiring it may
|
|
175
|
+
take up to 30 seconds more. A **Running commit** still behind `git rev-parse --short HEAD` a
|
|
176
|
+
minute later, with a diagnostic on the plugin's row, is a failed read: fix what it names
|
|
177
|
+
instead of refreshing and waiting. Without a diagnostic, refresh the `local` source. A failed committed
|
|
178
|
+
update keeps the last working revision and shows that diagnostic. Fix and commit the
|
|
179
|
+
repair. Explicit source refresh skips the wait and retries a failed read; a commit
|
|
180
|
+
does not normally need it, and it never activates uncommitted files. Keep runtime data in
|
|
150
181
|
host-owned plugin storage, not beside the snapshot's source files.
|
|
151
182
|
|
|
152
183
|
4. **Grant what the manifest asks for, or activation is refused.** Anything declared under
|
|
@@ -177,9 +208,10 @@ list` names the exact local root — because writing into the wrong one produces
|
|
|
177
208
|
The commit is the activation boundary, so run these against the working tree first. Each catches
|
|
178
209
|
a failure class the load would otherwise be the first thing to surface:
|
|
179
210
|
|
|
180
|
-
1. **
|
|
181
|
-
|
|
182
|
-
|
|
211
|
+
1. **Run `pnpm plugin:check <dir>`** from a Kay checkout. It validates `kay-plugin.json` against
|
|
212
|
+
`KayPluginManifestV1` and resolves its contributions with the daemon's own resolver (both from
|
|
213
|
+
`@kay/plugin-protocol`), not just "it is valid JSON": that schema and resolver are the gate the
|
|
214
|
+
scan actually runs. A non-zero exit means the plugin would be refused.
|
|
183
215
|
2. **Run the disclosure audit yourself**: `auditPluginDisclosure` from `@kay/plugin-sdk/disclosure`.
|
|
184
216
|
It is not redundant with typecheck. A plugin shipped a `search` verb with no `verbDocs` entry
|
|
185
217
|
that typechecked clean and would have failed the whole `kay.agent` target.
|
|
@@ -229,6 +261,8 @@ on the plugin's row (or on the plugin source's row, when the whole source found
|
|
|
229
261
|
- **The disclosure audit is fail-closed** and runs on every directory plugin; a violation fails
|
|
230
262
|
the whole `kay.agent` target. Run `auditPluginDisclosure` yourself before committing, per the
|
|
231
263
|
pre-commit checks above.
|
|
264
|
+
- **Before any of the above, run `pnpm plugin:check <dir>`.** A manifest the daemon cannot
|
|
265
|
+
resolve produces a plugin that never appears, and the check names the reason without a load.
|
|
232
266
|
|
|
233
267
|
## Declaring a scheduled workflow
|
|
234
268
|
|