@codemodekit/skills 0.1.0
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 +45 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +70 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
- package/skills/author-codemode-skill/SKILL.md +76 -0
- package/skills/author-codemode-skill/agents/openai.yaml +4 -0
- package/skills/author-codemode-skill/references/discovery.md +36 -0
- package/skills/author-codemode-skill/references/evaluation.md +34 -0
- package/skills/author-codemode-skill/references/plugin-maintenance.md +26 -0
- package/skills/author-codemode-skill/references/runtime-skill-design.md +73 -0
- package/skills/build-codemodekit-server/SKILL.md +47 -0
- package/skills/build-codemodekit-server/agents/openai.yaml +4 -0
- package/skills/build-codemodekit-server/references/generator.md +55 -0
- package/skills/build-codemodekit-server/references/policy-and-security.md +28 -0
- package/skills/build-codemodekit-server/references/server-api.md +77 -0
- package/skills/build-codemodekit-server/references/verification.md +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# CodeModeKit skills
|
|
2
|
+
|
|
3
|
+
Install CodeModeKit's two project-level Agent Skills with the open skills CLI:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx skills add stjbrown/codemodekit
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The repository contains:
|
|
10
|
+
|
|
11
|
+
- `build-codemodekit-server` builds and verifies Code Mode MCP servers from Local Tools or MCP sources.
|
|
12
|
+
- `author-codemode-skill` turns a generated companion skill into domain-aware runtime guidance and maintains its Agent Plugin package.
|
|
13
|
+
|
|
14
|
+
Install either one independently:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx skills add stjbrown/codemodekit --skill build-codemodekit-server
|
|
18
|
+
npx skills add stjbrown/codemodekit --skill author-codemode-skill
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For an explicit, non-interactive install of both into Cursor:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx skills add stjbrown/codemodekit \
|
|
25
|
+
--skill '*' \
|
|
26
|
+
--agent cursor \
|
|
27
|
+
--copy \
|
|
28
|
+
--yes
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## npm and programmatic installation
|
|
32
|
+
|
|
33
|
+
The `@codemodekit/skills` npm package backs `create-codemodekit` and can also copy both skills directly into the current project's portable `.agents/skills` directory:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npx @codemodekit/skills
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Install one from the npm package with `--skill`:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npx @codemodekit/skills --skill build-codemodekit-server
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
CodeModeKit-generated projects install both automatically. Use the skills CLI for agent-specific destinations, global installation, symlinks, updates, or discovery through [skills.sh](https://skills.sh/).
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { CODEMODEKIT_SKILL_NAMES, installCodeModeKitSkills, } from "./index.js";
|
|
6
|
+
async function run(args) {
|
|
7
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
8
|
+
process.stdout.write(usage());
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
let root;
|
|
12
|
+
let overwrite = false;
|
|
13
|
+
const skills = [];
|
|
14
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
15
|
+
const argument = args[index];
|
|
16
|
+
if (argument === "--overwrite") {
|
|
17
|
+
overwrite = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (argument === "--skill") {
|
|
21
|
+
const value = args[index + 1];
|
|
22
|
+
if (value === undefined || !isSkillName(value)) {
|
|
23
|
+
throw new TypeError(`--skill must be one of: ${CODEMODEKIT_SKILL_NAMES.join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
skills.push(value);
|
|
26
|
+
index += 1;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (argument?.startsWith("-") === true) {
|
|
30
|
+
throw new TypeError(`Unknown option: ${argument}`);
|
|
31
|
+
}
|
|
32
|
+
if (argument !== undefined) {
|
|
33
|
+
if (root !== undefined)
|
|
34
|
+
throw new TypeError(`Unexpected argument: ${argument}`);
|
|
35
|
+
root = argument;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const result = await installCodeModeKitSkills({
|
|
39
|
+
root: root ?? process.cwd(),
|
|
40
|
+
...(skills.length === 0 ? {} : { skills }),
|
|
41
|
+
overwrite,
|
|
42
|
+
});
|
|
43
|
+
process.stdout.write(`Installed CodeModeKit skills in ${result.skillsRoot}\n` +
|
|
44
|
+
(skills.length === 0 ? CODEMODEKIT_SKILL_NAMES : skills)
|
|
45
|
+
.map((skill) => ` ${skill}\n`)
|
|
46
|
+
.join(""));
|
|
47
|
+
}
|
|
48
|
+
function isSkillName(value) {
|
|
49
|
+
return CODEMODEKIT_SKILL_NAMES.includes(value);
|
|
50
|
+
}
|
|
51
|
+
function usage() {
|
|
52
|
+
return `Install CodeModeKit development skills into .agents/skills.
|
|
53
|
+
|
|
54
|
+
Usage:
|
|
55
|
+
npx @codemodekit/skills [project-directory]
|
|
56
|
+
codemodekit-skills [project-directory] [--skill <name>] [--overwrite]
|
|
57
|
+
|
|
58
|
+
Skills:
|
|
59
|
+
build-codemodekit-server
|
|
60
|
+
author-codemode-skill
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
if (process.argv[1] !== undefined &&
|
|
64
|
+
realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
|
|
65
|
+
run(process.argv.slice(2)).catch((error) => {
|
|
66
|
+
process.stderr.write(`codemodekit-skills: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const CODEMODEKIT_SKILL_NAMES: readonly ["build-codemodekit-server", "author-codemode-skill"];
|
|
2
|
+
export type CodeModeKitSkillName = (typeof CODEMODEKIT_SKILL_NAMES)[number];
|
|
3
|
+
export interface InstallCodeModeKitSkillsOptions {
|
|
4
|
+
readonly root: string;
|
|
5
|
+
readonly skills?: readonly CodeModeKitSkillName[];
|
|
6
|
+
readonly overwrite?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface InstallCodeModeKitSkillsResult {
|
|
9
|
+
readonly root: string;
|
|
10
|
+
readonly skillsRoot: string;
|
|
11
|
+
readonly directories: Readonly<Partial<Record<CodeModeKitSkillName, string>>>;
|
|
12
|
+
}
|
|
13
|
+
/** Install CodeModeKit's development-time skills into the portable project path. */
|
|
14
|
+
export declare function installCodeModeKitSkills(options: InstallCodeModeKitSkillsOptions): Promise<InstallCodeModeKitSkillsResult>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,gEAG1B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAClD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAC/E;AAID,oFAAoF;AACpF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,8BAA8B,CAAC,CA6CzC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { cp, lstat, mkdir, rename, rm } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
export const CODEMODEKIT_SKILL_NAMES = [
|
|
5
|
+
"build-codemodekit-server",
|
|
6
|
+
"author-codemode-skill",
|
|
7
|
+
];
|
|
8
|
+
const BUNDLED_SKILLS_ROOT = fileURLToPath(new URL("../skills", import.meta.url));
|
|
9
|
+
/** Install CodeModeKit's development-time skills into the portable project path. */
|
|
10
|
+
export async function installCodeModeKitSkills(options) {
|
|
11
|
+
const root = path.resolve(options.root);
|
|
12
|
+
const skillsRoot = path.join(root, ".agents", "skills");
|
|
13
|
+
const selected = options.skills ?? CODEMODEKIT_SKILL_NAMES;
|
|
14
|
+
const unique = [...new Set(selected)];
|
|
15
|
+
if (unique.length === 0) {
|
|
16
|
+
throw new TypeError("Select at least one CodeModeKit skill to install");
|
|
17
|
+
}
|
|
18
|
+
for (const skillName of unique) {
|
|
19
|
+
if (!isCodeModeKitSkillName(skillName)) {
|
|
20
|
+
throw new TypeError(`Unknown CodeModeKit skill: ${String(skillName)}`);
|
|
21
|
+
}
|
|
22
|
+
const destination = path.join(skillsRoot, skillName);
|
|
23
|
+
if ((await pathExists(destination)) && options.overwrite !== true) {
|
|
24
|
+
throw new Error(`CodeModeKit skill already exists: ${destination}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
await mkdir(skillsRoot, { recursive: true });
|
|
28
|
+
const installed = new Map();
|
|
29
|
+
for (const skillName of unique) {
|
|
30
|
+
const destination = path.join(skillsRoot, skillName);
|
|
31
|
+
const staging = path.join(skillsRoot, `.${skillName}.${String(process.pid)}.${String(Date.now())}.tmp`);
|
|
32
|
+
await rm(staging, { recursive: true, force: true });
|
|
33
|
+
await cp(path.join(BUNDLED_SKILLS_ROOT, skillName), staging, {
|
|
34
|
+
recursive: true,
|
|
35
|
+
});
|
|
36
|
+
try {
|
|
37
|
+
await rm(destination, { recursive: true, force: true });
|
|
38
|
+
await rename(staging, destination);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await rm(staging, { recursive: true, force: true });
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
installed.set(skillName, destination);
|
|
45
|
+
}
|
|
46
|
+
const directories = Object.fromEntries(installed);
|
|
47
|
+
return { root, skillsRoot, directories };
|
|
48
|
+
}
|
|
49
|
+
function isCodeModeKitSkillName(value) {
|
|
50
|
+
return CODEMODEKIT_SKILL_NAMES.includes(value);
|
|
51
|
+
}
|
|
52
|
+
async function pathExists(file) {
|
|
53
|
+
try {
|
|
54
|
+
await lstat(file);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof Error &&
|
|
59
|
+
"code" in error &&
|
|
60
|
+
error.code === "ENOENT") {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codemodekit/skills",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agent Skills for building CodeModeKit servers and authoring their runtime skills.",
|
|
5
|
+
"author": "Stephen Brown",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/stjbrown/codemodekit.git",
|
|
10
|
+
"directory": "packages/skills"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/stjbrown/codemodekit#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/stjbrown/codemodekit/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"bin": {
|
|
21
|
+
"codemodekit-skills": "dist/cli.js"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": ["dist/*.js", "dist/*.d.ts", "dist/*.map", "skills/**/*"],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"code-mode",
|
|
35
|
+
"mcp",
|
|
36
|
+
"agent-skill",
|
|
37
|
+
"agent-skills",
|
|
38
|
+
"agent-plugin",
|
|
39
|
+
"skills.sh"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: author-codemode-skill
|
|
3
|
+
description: Author, refine, or evaluate the domain-aware runtime Agent Skill inside a CodeModeKit Agent Plugin. Use after a Code Mode MCP server is scaffolded or its catalog changes, when generated skill guidance is too generic, when adding user workflows and exact multi-tool examples, when defining safe write behavior and result expectations, or when updating plugin.json, skill references, catalog sync, build, and release metadata for an Agent Plugins package.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Author a Code Mode Skill
|
|
7
|
+
|
|
8
|
+
Turn a mechanically valid CodeModeKit plugin into a useful domain product. The catalog explains what calls exist; infer how people should use them from repository evidence and the user, never from tool names alone.
|
|
9
|
+
|
|
10
|
+
## 1. Establish current truth
|
|
11
|
+
|
|
12
|
+
1. Locate `plugin.json`, `mcp.json`, `src/server.mjs`, `package.json`, and every immediate `skills/*/SKILL.md`.
|
|
13
|
+
2. Run `npm run plugin:sync` when the configured sources are available. If it fails, preserve the current generated files and report the connectivity or credential blocker.
|
|
14
|
+
3. Read `references/catalog-metadata.json` and search focused sections of `references/tools.d.ts`. Never edit either file; CodeModeKit owns them.
|
|
15
|
+
4. Inspect project documentation, tests, source configuration, tool descriptions, policy, and existing examples for domain evidence.
|
|
16
|
+
5. Read [references/discovery.md](references/discovery.md) and create a concise authoring brief. Ask the user only for high-impact facts that cannot be recovered locally. Do not invent organization policy, approval boundaries, or intended users.
|
|
17
|
+
|
|
18
|
+
Current truth is established when every configured source and runtime skill is accounted for, generated catalog status is known, and the brief separates evidence from unanswered consequential questions.
|
|
19
|
+
|
|
20
|
+
## 2. Design around jobs, not inventory
|
|
21
|
+
|
|
22
|
+
Choose the few user jobs that justify activating this skill. For each one, identify:
|
|
23
|
+
|
|
24
|
+
- the user intent and expected answer or artifact;
|
|
25
|
+
- the exact source tools and required sequence;
|
|
26
|
+
- which calls are independent versus dependent;
|
|
27
|
+
- ambiguity that requires clarification;
|
|
28
|
+
- write, destructive, external-communication, or privacy risk;
|
|
29
|
+
- the smallest useful final value; and
|
|
30
|
+
- common failure and recovery behavior.
|
|
31
|
+
|
|
32
|
+
Read [references/runtime-skill-design.md](references/runtime-skill-design.md) before editing. A good runtime skill teaches decisions and workflows that cannot be derived from `tools.d.ts`; it does not restate the whole catalog.
|
|
33
|
+
|
|
34
|
+
Design is complete when each selected job maps to exact current tools, a result contract, its ambiguity and safety decisions, and a checkable completion condition.
|
|
35
|
+
|
|
36
|
+
## 3. Author the runtime package
|
|
37
|
+
|
|
38
|
+
Edit the companion runtime skill under `skills/<name>/`:
|
|
39
|
+
|
|
40
|
+
- Rewrite `SKILL.md` with a specific trigger description and compact workflow routing.
|
|
41
|
+
- Preserve the stable Code Mode execution rules or link to `references/runtime.md` and `references/result-contract.md`.
|
|
42
|
+
- Replace generic `references/examples.md` with real, type-correct compositions for the selected jobs.
|
|
43
|
+
- Add focused references such as `workflows.md`, `domain-rules.md`, or `write-safety.md` only when each has a clear loading condition from `SKILL.md`.
|
|
44
|
+
- Delete obsolete agent-authored references. Do not add README, changelog, or process-history files inside the skill.
|
|
45
|
+
- Keep references one level below `SKILL.md` and use relative links.
|
|
46
|
+
|
|
47
|
+
Update the root Agent Plugin when the semantic product changed. Read [references/plugin-maintenance.md](references/plugin-maintenance.md) before editing `plugin.json`, `mcp.json`, or the plugin version.
|
|
48
|
+
|
|
49
|
+
Authorship is complete when every line in `SKILL.md` changes runtime behavior, every context pointer says when to load its target, and each meaning has one source of truth.
|
|
50
|
+
|
|
51
|
+
## 4. Evaluate behavior
|
|
52
|
+
|
|
53
|
+
Use [references/evaluation.md](references/evaluation.md) to create realistic should-trigger, should-not-trigger, read, composition, ambiguity, failure, and write-safety cases. Test the skill through an agent with the built plugin when available; do not judge it only by reading Markdown.
|
|
54
|
+
|
|
55
|
+
Run the project checks, then:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
npm run plugin:sync
|
|
59
|
+
npm run plugin:build
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Re-read the built `dist/plugin/skills/<name>/SKILL.md` and references. Confirm the build contains the authored files and current generated catalog but no secrets or development-only authoring skills.
|
|
63
|
+
|
|
64
|
+
Evaluation is complete when every minimum case has an observed result and each failed assertion is either fixed or recorded as a specific remaining limitation.
|
|
65
|
+
|
|
66
|
+
## Quality gate
|
|
67
|
+
|
|
68
|
+
Do not report the runtime skill as polished unless:
|
|
69
|
+
|
|
70
|
+
- its description names concrete triggering requests and avoids claiming unrelated tasks;
|
|
71
|
+
- every documented tool call exists in the current `tools.d.ts` and matches its input shape;
|
|
72
|
+
- examples return bounded user-relevant values rather than raw provider payloads;
|
|
73
|
+
- write workflows state when to clarify, preview, confirm, or stop based on the user's actual policy;
|
|
74
|
+
- live `search_tools` remains the recovery path for stale or dynamic catalogs;
|
|
75
|
+
- plugin and MCP manifests still target the same Agent Plugins version; and
|
|
76
|
+
- at least one realistic evaluation demonstrates a multi-tool Code Mode advantage.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Domain discovery
|
|
2
|
+
|
|
3
|
+
Build an authoring brief before changing the runtime skill.
|
|
4
|
+
|
|
5
|
+
## Recover locally first
|
|
6
|
+
|
|
7
|
+
Inspect:
|
|
8
|
+
|
|
9
|
+
- product README and examples;
|
|
10
|
+
- `src/server.mjs` source names, Local Tool implementations, annotations, and policy;
|
|
11
|
+
- generated `tools.d.ts` and catalog metadata;
|
|
12
|
+
- tests and evaluation prompts;
|
|
13
|
+
- existing skill instructions and references;
|
|
14
|
+
- plugin name, description, keywords, version, and license; and
|
|
15
|
+
- domain documentation already committed to the project.
|
|
16
|
+
|
|
17
|
+
## Authoring brief
|
|
18
|
+
|
|
19
|
+
Record concise answers for:
|
|
20
|
+
|
|
21
|
+
1. Who invokes this skill?
|
|
22
|
+
2. What jobs should reliably trigger it?
|
|
23
|
+
3. What nearby jobs should not trigger it?
|
|
24
|
+
4. Which two or three workflows provide the most value?
|
|
25
|
+
5. What must the agent clarify before acting?
|
|
26
|
+
6. Which operations read, write, delete, communicate externally, spend money, or affect access?
|
|
27
|
+
7. What authorization or confirmation policy did the user actually specify?
|
|
28
|
+
8. What result shape is useful to the user?
|
|
29
|
+
9. What domain vocabulary or identifiers are easy to confuse?
|
|
30
|
+
10. Which upstream failures have a meaningful recovery path?
|
|
31
|
+
|
|
32
|
+
## Ask only consequential questions
|
|
33
|
+
|
|
34
|
+
Ask one to three short questions when missing answers would materially change the skill. Prioritize intended users and jobs, write/approval boundaries, and required output. Do not block on naming or prose preferences that can be revised safely.
|
|
35
|
+
|
|
36
|
+
Never infer a permissive write policy from tool availability. Never describe an organization-specific workflow as required unless repository evidence or the user establishes it.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Skill evaluation
|
|
2
|
+
|
|
3
|
+
Test behavior, not prose coverage. Keep a small table or JSON fixture outside the runtime skill directory so evaluation artifacts are not shipped as instructions unless intentionally useful.
|
|
4
|
+
|
|
5
|
+
## Minimum cases
|
|
6
|
+
|
|
7
|
+
Create at least:
|
|
8
|
+
|
|
9
|
+
- two requests that should activate the skill;
|
|
10
|
+
- one nearby request that should not activate it;
|
|
11
|
+
- one simple read workflow;
|
|
12
|
+
- one dependent multi-tool workflow;
|
|
13
|
+
- one ambiguous request that should trigger a focused question;
|
|
14
|
+
- one upstream failure or missing-result case; and
|
|
15
|
+
- one write or destructive case when such tools exist.
|
|
16
|
+
|
|
17
|
+
## Assertions
|
|
18
|
+
|
|
19
|
+
Grade whether the agent:
|
|
20
|
+
|
|
21
|
+
- activates the intended skill and avoids unrelated activation;
|
|
22
|
+
- uses `run_typescript` rather than trying to call hidden upstream tools directly;
|
|
23
|
+
- chooses tools and arguments present in the current declarations;
|
|
24
|
+
- composes related work into one execution;
|
|
25
|
+
- asks only consequential questions;
|
|
26
|
+
- respects tool policy and documented write boundaries;
|
|
27
|
+
- handles missing structured content or tool failure safely; and
|
|
28
|
+
- returns a bounded answer shaped for the request.
|
|
29
|
+
|
|
30
|
+
## Forward test
|
|
31
|
+
|
|
32
|
+
When an agent runner is available, run representative cases with the authored skill and with the generated baseline or prior version. Use fresh contexts and compare tool traces, outputs, retries, and user-facing quality. Do not reveal the expected implementation or suspected defect to the test agent.
|
|
33
|
+
|
|
34
|
+
Repeat flaky trigger cases several times before changing the description. A description succeeds when relevant prompts activate reliably without capturing adjacent unrelated work.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Agent Plugin maintenance
|
|
2
|
+
|
|
3
|
+
Target the current Agent Plugins schema already declared by the project. For Agent Plugins 1.0:
|
|
4
|
+
|
|
5
|
+
- `plugin.json` is required at the plugin root.
|
|
6
|
+
- Skills are immediate child directories of `skills/`, each with a conforming `SKILL.md` whose name matches its directory.
|
|
7
|
+
- `mcp.json` is the only portable MCP configuration location.
|
|
8
|
+
- `plugin.json` and `mcp.json` must target the same specification version.
|
|
9
|
+
- Package-owned paths must stay inside the plugin root.
|
|
10
|
+
- stdio `command` is one bare executable or plugin-relative token; arguments remain separate.
|
|
11
|
+
- `${PLUGIN_ROOT}` and `${PLUGIN_DATA}` are supported only in the fields defined by the specification.
|
|
12
|
+
- Portable `env` and HTTP headers are visible package data, not secret storage.
|
|
13
|
+
|
|
14
|
+
## What to edit
|
|
15
|
+
|
|
16
|
+
Update `plugin.json` description and keywords when the plugin's user-facing purpose becomes more specific. Preserve its name unless the user intends an identity change. Use Semantic Versioning: workflow additions are normally minor; corrections are patch; removing or incompatibly changing a promised workflow is major.
|
|
17
|
+
|
|
18
|
+
Edit `mcp.json` only when the server connection itself changes. Runtime-skill improvements do not require an MCP configuration change.
|
|
19
|
+
|
|
20
|
+
Do not add portable manifest fields outside the closed schema. Client-specific behavior belongs under a reverse-domain extension namespace and should be added only for a client the user explicitly targets.
|
|
21
|
+
|
|
22
|
+
## Build boundary
|
|
23
|
+
|
|
24
|
+
`npm run plugin:build` recreates `dist/plugin`. Never hand-edit the artifact. Verify it contains root manifests, the bundled server, QuickJS WASM, and runtime skills. It must exclude `.env`, source files, `node_modules`, and `.agents/skills` development guidance.
|
|
25
|
+
|
|
26
|
+
Cursor uses a concrete installed copy rather than the portable `${PLUGIN_ROOT}` configuration. Re-run `npm run plugin:install:cursor` and reload Cursor after rebuilding for local testing.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Runtime skill design
|
|
2
|
+
|
|
3
|
+
## Optimize for predictability
|
|
4
|
+
|
|
5
|
+
A runtime skill should make the agent follow a predictable process while allowing the answer to vary with the request and tool results.
|
|
6
|
+
|
|
7
|
+
- Front-load the description with the domain action users will actually request.
|
|
8
|
+
- Give each genuine invocation branch one trigger. Collapse synonyms that merely rename the same branch.
|
|
9
|
+
- Keep steps required on every run in `SKILL.md`. End each step with a condition the agent can verify before moving on.
|
|
10
|
+
- Move branch-specific rules and examples behind context pointers that state exactly when to read them.
|
|
11
|
+
- Co-locate a concept's rule, exception, and caveat instead of scattering them.
|
|
12
|
+
- Keep one source of truth for each behavior. Generated types define call shapes; domain references define domain rules; do not duplicate either in the body.
|
|
13
|
+
- Prune lines that merely tell a capable agent to be helpful, careful, or thorough. Remove stale instructions rather than layering corrections over them.
|
|
14
|
+
|
|
15
|
+
## Separate generated and authored truth
|
|
16
|
+
|
|
17
|
+
CodeModeKit owns:
|
|
18
|
+
|
|
19
|
+
- `references/tools.d.ts`;
|
|
20
|
+
- `references/catalog-metadata.json`; and
|
|
21
|
+
- `dist/plugin`.
|
|
22
|
+
|
|
23
|
+
The skill author owns:
|
|
24
|
+
|
|
25
|
+
- the runtime `SKILL.md`;
|
|
26
|
+
- domain workflows and rules;
|
|
27
|
+
- worked examples; and
|
|
28
|
+
- routing to focused references.
|
|
29
|
+
|
|
30
|
+
`npm run plugin:sync` updates generated catalog files only. `npm run plugin:build` packages both generated and authored files.
|
|
31
|
+
|
|
32
|
+
## Description
|
|
33
|
+
|
|
34
|
+
Write the description for activation. Include what the skill enables and concrete request classes that should trigger it. Use domain language users will say. Avoid generic phrases such as “use upstream tools,” which collide with other skills and fail to disclose actual value.
|
|
35
|
+
|
|
36
|
+
## Body
|
|
37
|
+
|
|
38
|
+
Keep `SKILL.md` procedural and compact:
|
|
39
|
+
|
|
40
|
+
1. state the primary interface (`run_typescript`);
|
|
41
|
+
2. route the agent among the supported jobs;
|
|
42
|
+
3. specify critical clarification and safety decisions;
|
|
43
|
+
4. link to exact references with a condition for reading each; and
|
|
44
|
+
5. define the completion standard.
|
|
45
|
+
|
|
46
|
+
Do not paste the entire catalog into the body. Search `tools.d.ts` for exact names and shapes. Preserve `search_tools` as the live recovery path when declarations are pending, stale, incomplete, or too large to search efficiently.
|
|
47
|
+
|
|
48
|
+
## Code Mode examples
|
|
49
|
+
|
|
50
|
+
Every example must compile as the body of an async function:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const first = await tools.source.firstTool({ query: "value" });
|
|
54
|
+
const second = await tools.source.secondTool({
|
|
55
|
+
id: first.structuredContent.id,
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
name: first.structuredContent.name,
|
|
59
|
+
status: second.structuredContent.status,
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- Use exact names and schemas from `tools.d.ts`.
|
|
64
|
+
- Prefer `structuredContent`; inspect text content defensively only when the provider lacks structured output.
|
|
65
|
+
- Use `Promise.all` only for independent calls.
|
|
66
|
+
- Pass the smallest necessary data between calls.
|
|
67
|
+
- Filter, join, aggregate, and reshape in the sandbox.
|
|
68
|
+
- Return only what the user needs.
|
|
69
|
+
- Catch a tool error only when the workflow can recover or add a useful bounded outcome.
|
|
70
|
+
|
|
71
|
+
## Write workflows
|
|
72
|
+
|
|
73
|
+
Document writes separately from reads. Base preview, clarification, confirmation, and execution rules on the user's policy and host behavior. The runtime skill cannot bypass CodeModeKit tool policy; explain a denial as a policy result rather than suggesting workarounds.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-codemodekit-server
|
|
3
|
+
description: Build, retrofit, debug, or verify CodeModeKit Code Mode MCP servers from application-owned Local Tools, stdio MCP commands, or remote MCP URLs. Use when scaffolding a CodeModeKit project, defining local tools and schemas, composing multiple sources, setting tool policy and limits, packaging an Agent Plugin, or troubleshooting run_typescript, search_tools, plugin sync, build, or Cursor installation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build a CodeModeKit Server
|
|
7
|
+
|
|
8
|
+
Build a walking skeleton for the user's actual source, then verify it through the downstream MCP surface. Keep model-authored code in CodeModeKit's sandbox and host integrations behind tool providers.
|
|
9
|
+
|
|
10
|
+
## Build workflow
|
|
11
|
+
|
|
12
|
+
1. Inspect the repository, package manager, local instructions, existing MCP configuration, and relevant application functions. Do not overwrite unrelated work.
|
|
13
|
+
2. Choose the source boundary:
|
|
14
|
+
- Use Local Tools for functions or APIs the application owns.
|
|
15
|
+
- Use `mcp.stdio` for a shell-free executable and argument array.
|
|
16
|
+
- Use `mcp.http` for a Streamable HTTP MCP endpoint.
|
|
17
|
+
- Compose sources when one authored program needs more than one namespace.
|
|
18
|
+
3. For a new project, prefer the generator. Read [references/generator.md](references/generator.md) for commands and generated-file ownership.
|
|
19
|
+
4. For a retrofit or custom server, read [references/server-api.md](references/server-api.md), preserve the batteries-included facade, and expose compiler or sandbox configuration only when the user needs an expert override.
|
|
20
|
+
5. Define an explicit tool policy. Read [references/policy-and-security.md](references/policy-and-security.md) before enabling writes, handling credentials, or binding Streamable HTTP beyond loopback.
|
|
21
|
+
6. Keep the initial implementation compact. A single `src/server.mjs` is the default; split it only when domain code already has a natural module boundary.
|
|
22
|
+
7. If the project includes an Agent Plugin, run catalog sync and build, but do not pretend the generated runtime skill understands the domain. Invoke `$author-codemode-skill` after the server works.
|
|
23
|
+
8. Verify the downstream behavior using [references/verification.md](references/verification.md). Exercise `run_typescript`, not merely imports or direct provider functions.
|
|
24
|
+
|
|
25
|
+
The walking skeleton is complete when one realistic downstream execution crosses compilation, QuickJS, policy, the bridge, and the chosen provider and returns the expected bounded value.
|
|
26
|
+
|
|
27
|
+
## Local Tool quality bar
|
|
28
|
+
|
|
29
|
+
- Give tools stable action-oriented names and descriptions that distinguish them from siblings.
|
|
30
|
+
- Use bounded input and output schemas. Prefer Standard JSON Schema-compatible schemas when the project already uses one; plain JSON Schema requires no extra dependency.
|
|
31
|
+
- Return plain JSON values and declare an output schema when the result has a stable shape.
|
|
32
|
+
- Use the execution context's `signal` for fetches and other cancellable work.
|
|
33
|
+
- Throw `ToolError` only when its message is safe for model-authored code. Keep credentials, raw upstream responses, stack traces, and internal paths out of it.
|
|
34
|
+
- Keep authentication and network access in the trusted host function. Never add ambient `fetch`, filesystem, process, or package access to the sandbox to make a tool work.
|
|
35
|
+
- Mark read-only, destructive, idempotent, and open-world annotations accurately. Treat annotations as policy hints, not authorization.
|
|
36
|
+
|
|
37
|
+
## Completion criteria
|
|
38
|
+
|
|
39
|
+
Do not call the server ready until:
|
|
40
|
+
|
|
41
|
+
- dependencies install and typecheck or syntax checks pass;
|
|
42
|
+
- the server advertises `run_typescript` and, unless intentionally disabled, `search_tools`;
|
|
43
|
+
- at least one realistic TypeScript execution calls the configured source and returns a bounded value;
|
|
44
|
+
- policy denials and a representative invalid input fail safely;
|
|
45
|
+
- plugin catalog sync is current or its exact connectivity blocker is documented;
|
|
46
|
+
- `dist/plugin` builds when an Agent Plugin is requested; and
|
|
47
|
+
- the domain-aware runtime skill has either been authored or is explicitly reported as a generated baseline requiring `$author-codemode-skill`.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Generator and lifecycle
|
|
2
|
+
|
|
3
|
+
## New weather Local Tools project
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create codemodekit@latest
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The noninteractive equivalent is:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm create codemodekit@latest weather-code-mode -- --example weather
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Wrap a stdio MCP server
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm create codemodekit@latest my-code-mode -- \
|
|
19
|
+
--mcp-name upstream \
|
|
20
|
+
--mcp-command 'uvx upstream-mcp' \
|
|
21
|
+
--agent-plugin
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The command is parsed into one executable and an argument array. Do not pass pipes, redirection, command substitution, or leading environment assignments.
|
|
25
|
+
|
|
26
|
+
## Wrap a remote MCP server
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm create codemodekit@latest my-code-mode -- \
|
|
30
|
+
--mcp-name upstream \
|
|
31
|
+
--mcp-url https://example.com/mcp \
|
|
32
|
+
--agent-plugin
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Useful options
|
|
36
|
+
|
|
37
|
+
- `--policy deny-all`: scaffold closed while a narrower policy is implemented.
|
|
38
|
+
- `--no-install`: write files without installing dependencies.
|
|
39
|
+
- `--no-sync`: defer live catalog capture when credentials or connectivity are not ready.
|
|
40
|
+
- `--no-agent-plugin`: omit portable plugin packaging.
|
|
41
|
+
- `--plugin-name`, `--skill-name`, `--plugin-description`, `--plugin-license`: override portable metadata.
|
|
42
|
+
- `--no-authoring-skill`: omit both project development skills.
|
|
43
|
+
|
|
44
|
+
## Generated project lifecycle
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm start
|
|
48
|
+
npm run plugin:sync
|
|
49
|
+
npm run plugin:build
|
|
50
|
+
npm run plugin:install:cursor
|
|
51
|
+
npm run plugin:status:cursor
|
|
52
|
+
npm run plugin:uninstall:cursor
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Catalog sync owns `references/tools.d.ts` and `references/catalog-metadata.json`. Plugin build owns `dist/plugin`. The developer or `$author-codemode-skill` owns the runtime `SKILL.md`, domain workflows, and examples.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Policy and security
|
|
2
|
+
|
|
3
|
+
## Tool authorization
|
|
4
|
+
|
|
5
|
+
CodeModeKit requires a host-side tool policy. `allowAllToolCalls()` is suitable for a runnable starter only when every visible tool is authorized for the model's users. `denyAllToolCalls()` starts closed. A custom policy receives validated source, tool, input, annotations, execution IDs, and cancellation signal.
|
|
6
|
+
|
|
7
|
+
For write-capable catalogs:
|
|
8
|
+
|
|
9
|
+
- prefer an upstream read-only mode or allowlist when available;
|
|
10
|
+
- authorize by source and exact tool, not by description text;
|
|
11
|
+
- inspect arguments for tenant, repository, channel, or resource boundaries when needed;
|
|
12
|
+
- fail closed when an approval or policy dependency is unavailable; and
|
|
13
|
+
- never infer authorization from read-only or destructive annotations.
|
|
14
|
+
|
|
15
|
+
## Secret handling
|
|
16
|
+
|
|
17
|
+
- Keep secrets in the host environment, an ignored `.env`, or the upstream provider's credential mechanism.
|
|
18
|
+
- Never write credentials into `plugin.json`, `mcp.json`, runtime skills, generated references, tool errors, or portable artifacts.
|
|
19
|
+
- Agent Plugins 1.0 has no portable credential-reference or OAuth configuration field.
|
|
20
|
+
- Treat configured plugin `env` and HTTP headers as visible package data.
|
|
21
|
+
|
|
22
|
+
## Sandbox boundary
|
|
23
|
+
|
|
24
|
+
Model-authored TypeScript receives `tools`, bounded console support, and safe JavaScript globals. Do not expose Node modules, `process`, filesystem access, ambient network access, dynamic imports, `eval`, or `Function` to solve an integration problem. Put the capability in a provider.
|
|
25
|
+
|
|
26
|
+
## HTTP exposure
|
|
27
|
+
|
|
28
|
+
`serveCodeModeHttp` binds to loopback by default. A non-loopback unauthenticated bind requires an explicit acknowledgement but does not create authentication. Put an authenticated gateway in front of it or integrate authentication at the owning host.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Server API
|
|
2
|
+
|
|
3
|
+
## Application-owned Local Tools
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import {
|
|
7
|
+
allowAllToolCalls,
|
|
8
|
+
defineTool,
|
|
9
|
+
local,
|
|
10
|
+
serveCodeModeStdio,
|
|
11
|
+
ToolError,
|
|
12
|
+
} from "codemodekit";
|
|
13
|
+
|
|
14
|
+
const lookup = defineTool({
|
|
15
|
+
description: "Look up one record by identifier",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: { id: { type: "string", minLength: 1 } },
|
|
19
|
+
required: ["id"],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
outputSchema: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: { id: { type: "string" }, status: { type: "string" } },
|
|
25
|
+
required: ["id", "status"],
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
},
|
|
28
|
+
execute: async ({ id }, { signal }) => {
|
|
29
|
+
const response = await fetch(`https://example.com/records/${id}`, { signal });
|
|
30
|
+
if (!response.ok) throw new ToolError(`Record lookup failed with HTTP ${response.status}`);
|
|
31
|
+
return await response.json();
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await serveCodeModeStdio({
|
|
36
|
+
name: "records-code-mode",
|
|
37
|
+
version: "0.1.0",
|
|
38
|
+
toolPolicy: allowAllToolCalls(),
|
|
39
|
+
sources: [local({ name: "records", tools: { lookup } })],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`defineTool` accepts plain JSON Schema or Standard JSON Schema-compatible schemas. Local executors run in the trusted host; the model's TypeScript still runs in QuickJS.
|
|
44
|
+
|
|
45
|
+
## MCP source
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { allowAllToolCalls, mcp, serveCodeModeStdio } from "codemodekit";
|
|
49
|
+
|
|
50
|
+
await serveCodeModeStdio({
|
|
51
|
+
name: "github-code-mode",
|
|
52
|
+
version: "0.1.0",
|
|
53
|
+
toolPolicy: allowAllToolCalls(),
|
|
54
|
+
sources: [
|
|
55
|
+
mcp.stdio({
|
|
56
|
+
name: "github",
|
|
57
|
+
command: "docker",
|
|
58
|
+
args: ["run", "-i", "--rm", "ghcr.io/github/github-mcp-server"],
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use `mcp.http({ name, url })` for Streamable HTTP. Source names become the first segment below `tools`; preserve them exactly and use bracket notation for names that are not TypeScript identifiers.
|
|
65
|
+
|
|
66
|
+
## Composition
|
|
67
|
+
|
|
68
|
+
Every source is a provider in one normalized catalog:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
sources: [
|
|
72
|
+
local({ name: "application", tools: { lookup } }),
|
|
73
|
+
mcp.http({ name: "tickets", url: "https://example.com/mcp" }),
|
|
74
|
+
]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The low-level `CodeMode`, compiler, sandbox, and provider classes are expert APIs. Stay on the facade unless a custom host or sandbox is an explicit requirement.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Verification
|
|
2
|
+
|
|
3
|
+
Verify from the downstream MCP boundary because direct provider calls bypass compilation, sandboxing, policy, bridge limits, and result projection.
|
|
4
|
+
|
|
5
|
+
## Minimum smoke
|
|
6
|
+
|
|
7
|
+
1. Start the generated server over stdio.
|
|
8
|
+
2. List tools and assert `run_typescript` is present. Expect `search_tools` unless disabled intentionally.
|
|
9
|
+
3. Call `search_tools` with a narrow capability query and inspect its generated TypeScript call shape.
|
|
10
|
+
4. Call `run_typescript` with one realistic workflow:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const result = await tools.source.tool({ value: "test" });
|
|
14
|
+
return result.structuredContent;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
5. Compose two dependent calls when the source supports it; pass only the required fields from the first result into the second.
|
|
18
|
+
6. Send one schema-invalid input and assert the provider is not invoked.
|
|
19
|
+
7. Exercise one denied call when a custom or deny-all policy is used.
|
|
20
|
+
8. Confirm errors contain bounded safe diagnostics rather than credentials, stack traces, or raw upstream payloads.
|
|
21
|
+
|
|
22
|
+
## Agent Plugin
|
|
23
|
+
|
|
24
|
+
Run:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm run plugin:sync
|
|
28
|
+
npm run plugin:build
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then verify:
|
|
32
|
+
|
|
33
|
+
- `dist/plugin/plugin.json`, `mcp.json`, `server.mjs`, QuickJS WASM, and runtime skill exist;
|
|
34
|
+
- `dist/plugin` contains no `.env`, source tree, or `node_modules`;
|
|
35
|
+
- the bundled server starts from outside the project directory; and
|
|
36
|
+
- a downstream MCP client can execute the same realistic `run_typescript` call through the artifact.
|
|
37
|
+
|
|
38
|
+
Use `$author-codemode-skill` after this mechanical verification to author and evaluate the user-facing runtime guidance.
|