create-codemodekit 0.1.0 → 0.3.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.
Files changed (38) hide show
  1. package/README.md +41 -1
  2. package/dist/agent-plugin.d.ts +70 -0
  3. package/dist/agent-plugin.d.ts.map +1 -0
  4. package/dist/agent-plugin.js +285 -0
  5. package/dist/agent-plugin.js.map +1 -0
  6. package/dist/authoring-skill.d.ts +7 -0
  7. package/dist/authoring-skill.d.ts.map +1 -0
  8. package/dist/authoring-skill.js +42 -0
  9. package/dist/authoring-skill.js.map +1 -0
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +100 -0
  12. package/dist/cli.js.map +1 -1
  13. package/dist/cursor-plugin.d.ts +25 -0
  14. package/dist/cursor-plugin.d.ts.map +1 -0
  15. package/dist/cursor-plugin.js +177 -0
  16. package/dist/cursor-plugin.js.map +1 -0
  17. package/dist/index.d.ts +5 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/plugin-build.d.ts +19 -0
  22. package/dist/plugin-build.d.ts.map +1 -0
  23. package/dist/plugin-build.js +177 -0
  24. package/dist/plugin-build.js.map +1 -0
  25. package/dist/plugin-cli.d.ts +3 -0
  26. package/dist/plugin-cli.d.ts.map +1 -0
  27. package/dist/plugin-cli.js +102 -0
  28. package/dist/plugin-cli.js.map +1 -0
  29. package/dist/scaffold.d.ts +28 -0
  30. package/dist/scaffold.d.ts.map +1 -1
  31. package/dist/scaffold.js +247 -6
  32. package/dist/scaffold.js.map +1 -1
  33. package/package.json +11 -5
  34. package/skills/build-codemodekit-plugin/SKILL.md +44 -0
  35. package/skills/build-codemodekit-plugin/agents/openai.yaml +4 -0
  36. package/skills/build-codemodekit-plugin/references/generator.md +42 -0
  37. package/skills/build-codemodekit-plugin/references/plugin-layout.md +38 -0
  38. package/skills/build-codemodekit-plugin/references/programmatic-api.md +48 -0
package/README.md CHANGED
@@ -11,6 +11,46 @@ cd my-code-mode
11
11
  npm start
12
12
  ```
13
13
 
14
- The command is parsed directly into an executable and argument array. Shell operators, shell expansion, and leading environment assignments are rejected; no shell is invoked. Dependency installation is automatic unless `--no-install` is supplied.
14
+ The command is parsed directly into an executable and argument array. Shell operators, shell expansion, and leading environment assignments are rejected; no shell is invoked. Dependency installation is automatic unless `--no-install` is supplied. A project-level CodeModeKit authoring skill is installed at `.agents/skills/build-codemodekit-plugin` by default; use `--no-authoring-skill` to omit it.
15
15
 
16
16
  Generated servers use `--policy allow-all` by default so the project runs immediately. Use `--policy deny-all` when you want the generated server to start closed while you define a narrower tool policy.
17
+
18
+ ## Generate an Agent Plugin
19
+
20
+ Add `--agent-plugin` to create a portable Agent Plugins 1.0 package around the Code Mode server:
21
+
22
+ ```sh
23
+ npm create codemodekit@latest my-code-mode -- \
24
+ --mcp-name upstream \
25
+ --mcp-command 'uvx my-mcp-server' \
26
+ --agent-plugin
27
+ ```
28
+
29
+ This adds root `plugin.json` and `mcp.json` files plus `skills/use-upstream-codemode/`. The companion skill teaches a runtime agent to compose calls through `run_typescript`; its `references/tools.d.ts` is generated from CodeModeKit's live normalized catalog. After installation, the generator also builds a self-contained `dist/plugin` artifact containing the server bundle, QuickJS WASM, manifests, and runtime skill.
30
+
31
+ The generator attempts catalog sync after dependency installation. If the upstream MCP still needs credentials or connectivity, the project remains valid with pending references. Configure the source and run:
32
+
33
+ ```sh
34
+ npm run plugin:sync
35
+ npm run plugin:build
36
+ ```
37
+
38
+ Use `--no-sync` to skip the initial attempt intentionally. The artifact deliberately excludes `node_modules`, `.env`, source files, and the development-time authoring skill.
39
+
40
+ ## Cursor lifecycle
41
+
42
+ Cursor currently requires concrete executable and server paths for local plugins. The generated commands handle that adapter without changing the portable artifact:
43
+
44
+ ```sh
45
+ npm run plugin:install:cursor
46
+ npm run plugin:status:cursor
47
+ npm run plugin:uninstall:cursor
48
+ ```
49
+
50
+ Installation rebuilds first, copies the artifact beneath `~/.cursor/plugins/local`, resolves the active Node executable, and reports that Cursor should be reloaded. Reinstall after source, policy, metadata, or catalog changes.
51
+
52
+ ## Plugin metadata
53
+
54
+ Use `--plugin-name`, `--skill-name`, `--plugin-description`, and `--plugin-license` with `--agent-plugin` to override the portable defaults.
55
+
56
+ Programmatic consumers can call `scaffoldCodeModeMcp`, `scaffoldAgentPlugin`, `syncAgentPluginSkill`, `buildAgentPlugin`, `installProjectAuthoringSkill`, and the Cursor lifecycle functions directly.
@@ -0,0 +1,70 @@
1
+ export interface AgentPluginCatalogSource {
2
+ start(signal?: AbortSignal): Promise<AgentPluginStartupReport>;
3
+ getTypeScriptCatalog(signal?: AbortSignal): Promise<AgentPluginTypeScriptCatalog>;
4
+ }
5
+ export interface AgentPluginStartupReport {
6
+ readonly status: "ready" | "degraded";
7
+ readonly catalogRevision: string;
8
+ readonly sources: readonly AgentPluginSourceReport[];
9
+ }
10
+ export interface AgentPluginSourceReport {
11
+ readonly source: string;
12
+ readonly status: "healthy" | "unavailable";
13
+ readonly toolCount: number;
14
+ readonly message?: string;
15
+ readonly rejectedToolCount?: number;
16
+ }
17
+ export interface AgentPluginTypeScriptCatalog {
18
+ readonly catalogRevision: string;
19
+ readonly declarations: string;
20
+ }
21
+ export interface ScaffoldAgentPluginOptions {
22
+ readonly root: string;
23
+ readonly pluginName: string;
24
+ readonly serverName: string;
25
+ readonly skillName: string;
26
+ readonly description?: string;
27
+ readonly version?: string;
28
+ readonly license?: string;
29
+ readonly entrypoint?: string;
30
+ }
31
+ export interface ScaffoldAgentPluginResult {
32
+ readonly root: string;
33
+ readonly manifest: string;
34
+ readonly mcpConfig: string;
35
+ readonly skillDirectory: string;
36
+ readonly skillName: string;
37
+ }
38
+ export interface SyncAgentPluginSkillOptions {
39
+ readonly root: string;
40
+ readonly skillName: string;
41
+ readonly serverName: string;
42
+ readonly codeMode: AgentPluginCatalogSource;
43
+ readonly signal?: AbortSignal;
44
+ }
45
+ export interface SyncAgentPluginSkillResult {
46
+ readonly skillDirectory: string;
47
+ readonly catalogRevision: string;
48
+ readonly declarations: string;
49
+ readonly metadata: string;
50
+ readonly sources: readonly AgentPluginSourceReport[];
51
+ }
52
+ /**
53
+ * Writes the portable Agent Plugins 1.0 wrapper and a compact companion skill.
54
+ * Tool-specific declarations are populated later by syncAgentPluginSkill.
55
+ */
56
+ export declare function scaffoldAgentPlugin(options: ScaffoldAgentPluginOptions): Promise<ScaffoldAgentPluginResult>;
57
+ /**
58
+ * Snapshots CodeModeKit's active catalog into an already-scaffolded companion
59
+ * skill. A degraded catalog is rejected so a partial tool surface is never
60
+ * presented as complete documentation.
61
+ */
62
+ export declare function syncAgentPluginSkill(options: SyncAgentPluginSkillOptions): Promise<SyncAgentPluginSkillResult>;
63
+ export declare function normalizePortableName(value: string, label?: string): string;
64
+ interface RenderCompanionSkillOptions {
65
+ readonly skillName: string;
66
+ readonly serverName: string;
67
+ }
68
+ export declare function renderCompanionSkill(options: RenderCompanionSkillOptions): string;
69
+ export {};
70
+ //# sourceMappingURL=agent-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-plugin.d.ts","sourceRoot":"","sources":["../src/agent-plugin.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC/D,oBAAoB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACtD;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE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AAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACtD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAkFpC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,0BAA0B,CAAC,CAqDrC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,GAAG,MAAM,CAU3E;AAED,UAAU,2BAA2B;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,2BAA2B,GACnC,MAAM,CAuBR"}
@@ -0,0 +1,285 @@
1
+ import { mkdir, rename, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
4
+ const MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
5
+ const PORTABLE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
6
+ /**
7
+ * Writes the portable Agent Plugins 1.0 wrapper and a compact companion skill.
8
+ * Tool-specific declarations are populated later by syncAgentPluginSkill.
9
+ */
10
+ export async function scaffoldAgentPlugin(options) {
11
+ const root = path.resolve(options.root);
12
+ const pluginName = validatePortableName(options.pluginName, "Plugin name");
13
+ const skillName = validatePortableName(options.skillName, "Skill name");
14
+ const serverName = required(options.serverName, "Server name");
15
+ const version = required(options.version ?? "0.1.0", "Plugin version");
16
+ const entrypoint = options.entrypoint ?? "src/server.mjs";
17
+ validatePluginRelativePath(entrypoint, "Plugin entrypoint");
18
+ const manifestPath = path.join(root, "plugin.json");
19
+ const mcpConfigPath = path.join(root, "mcp.json");
20
+ const skillDirectory = path.join(root, "skills", skillName);
21
+ const referencesDirectory = path.join(skillDirectory, "references");
22
+ await mkdir(referencesDirectory, { recursive: true });
23
+ const description = options.description ??
24
+ `Use ${serverName} through a sandboxed TypeScript Code Mode interface.`;
25
+ const manifest = {
26
+ $schema: PLUGIN_SCHEMA,
27
+ name: pluginName,
28
+ version,
29
+ description,
30
+ ...(options.license === undefined
31
+ ? {}
32
+ : { license: required(options.license, "Plugin license") }),
33
+ keywords: ["code-mode", "mcp", "agent-skill"],
34
+ };
35
+ const mcpConfig = {
36
+ $schema: MCP_SCHEMA,
37
+ mcpServers: {
38
+ [serverName]: {
39
+ type: "stdio",
40
+ command: "node",
41
+ args: ["${PLUGIN_ROOT}/dist/plugin/server.mjs"],
42
+ },
43
+ },
44
+ };
45
+ await Promise.all([
46
+ writeJson(manifestPath, manifest),
47
+ writeJson(mcpConfigPath, mcpConfig),
48
+ writeFile(path.join(skillDirectory, "SKILL.md"), renderCompanionSkill({ skillName, serverName }), "utf8"),
49
+ writeFile(path.join(referencesDirectory, "runtime.md"), renderRuntimeReference(serverName), "utf8"),
50
+ writeFile(path.join(referencesDirectory, "result-contract.md"), renderResultContractReference(), "utf8"),
51
+ writeFile(path.join(referencesDirectory, "examples.md"), renderExamplesReference(), "utf8"),
52
+ writeFile(path.join(referencesDirectory, "tools.d.ts"), renderPendingDeclarations(), "utf8"),
53
+ writeJson(path.join(referencesDirectory, "catalog-metadata.json"), {
54
+ schemaVersion: 1,
55
+ status: "pending",
56
+ serverName,
57
+ message: "Run npm run plugin:sync after the upstream tool source is available.",
58
+ }),
59
+ ]);
60
+ return {
61
+ root,
62
+ manifest: manifestPath,
63
+ mcpConfig: mcpConfigPath,
64
+ skillDirectory,
65
+ skillName,
66
+ };
67
+ }
68
+ /**
69
+ * Snapshots CodeModeKit's active catalog into an already-scaffolded companion
70
+ * skill. A degraded catalog is rejected so a partial tool surface is never
71
+ * presented as complete documentation.
72
+ */
73
+ export async function syncAgentPluginSkill(options) {
74
+ const root = path.resolve(options.root);
75
+ const skillName = validatePortableName(options.skillName, "Skill name");
76
+ const serverName = required(options.serverName, "Server name");
77
+ const snapshot = await stableCatalogSnapshot(options.codeMode, options.signal);
78
+ if (snapshot.startup.status !== "ready") {
79
+ const unavailable = snapshot.startup.sources
80
+ .filter((source) => source.status === "unavailable")
81
+ .map((source) => source.source)
82
+ .join(", ");
83
+ throw new Error(unavailable === ""
84
+ ? "Cannot sync an Agent Plugin skill from a degraded catalog"
85
+ : `Cannot sync an Agent Plugin skill while sources are unavailable: ${unavailable}`);
86
+ }
87
+ const skillDirectory = path.join(root, "skills", skillName);
88
+ const referencesDirectory = path.join(skillDirectory, "references");
89
+ await mkdir(referencesDirectory, { recursive: true });
90
+ const declarationsPath = path.join(referencesDirectory, "tools.d.ts");
91
+ const metadataPath = path.join(referencesDirectory, "catalog-metadata.json");
92
+ const declarations = renderCatalogDeclarations(snapshot.catalog.catalogRevision, snapshot.catalog.declarations);
93
+ const metadata = {
94
+ schemaVersion: 1,
95
+ status: "ready",
96
+ serverName,
97
+ catalogRevision: snapshot.catalog.catalogRevision,
98
+ sources: snapshot.startup.sources.map((source) => ({
99
+ source: source.source,
100
+ status: source.status,
101
+ toolCount: source.toolCount,
102
+ ...(source.rejectedToolCount === undefined
103
+ ? {}
104
+ : { rejectedToolCount: source.rejectedToolCount }),
105
+ })),
106
+ };
107
+ await Promise.all([
108
+ atomicWrite(declarationsPath, declarations),
109
+ atomicWrite(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`),
110
+ ]);
111
+ return {
112
+ skillDirectory,
113
+ catalogRevision: snapshot.catalog.catalogRevision,
114
+ declarations: declarationsPath,
115
+ metadata: metadataPath,
116
+ sources: snapshot.startup.sources,
117
+ };
118
+ }
119
+ export function normalizePortableName(value, label = "Name") {
120
+ const normalized = value
121
+ .trim()
122
+ .toLowerCase()
123
+ .replace(/[^a-z0-9]+/gu, "-")
124
+ .replace(/-+/gu, "-")
125
+ .replace(/^-|-$/gu, "")
126
+ .slice(0, 64)
127
+ .replace(/-$/u, "");
128
+ return validatePortableName(normalized, label);
129
+ }
130
+ export function renderCompanionSkill(options) {
131
+ const skillName = validatePortableName(options.skillName, "Skill name");
132
+ const serverName = required(options.serverName, "Server name");
133
+ const description = `Use the ${serverName} Code Mode MCP server for requests that require its upstream tools. ` +
134
+ "Apply the generated TypeScript catalog, compose calls in run_typescript, and return only the requested result.";
135
+ return `---
136
+ name: ${skillName}
137
+ description: ${JSON.stringify(description)}
138
+ ---
139
+
140
+ # Use ${serverName} Code Mode
141
+
142
+ Use \`run_typescript\` as the primary interface to the tools wrapped by this server.
143
+
144
+ 1. Locate the relevant declarations in [references/tools.d.ts](references/tools.d.ts) before authoring calls. Search large files by capability, source, or tool name and read only focused matches.
145
+ 2. Put related calls, result extraction, filtering, and reshaping into one \`run_typescript\` execution.
146
+ 3. Return only the bounded value needed to answer the user.
147
+ 4. Use \`search_tools\` when the generated catalog is pending or stale, does not contain the needed capability, or the client cannot search a large declaration reference efficiently.
148
+ 5. Treat tool errors as data you can catch and handle; do not bypass tool policy or sandbox limits.
149
+
150
+ Read [references/runtime.md](references/runtime.md) for execution rules, [references/result-contract.md](references/result-contract.md) for MCP result extraction, and [references/examples.md](references/examples.md) for composition patterns.
151
+ `;
152
+ }
153
+ function renderRuntimeReference(serverName) {
154
+ return `# ${serverName} runtime
155
+
156
+ The server exposes a small Code Mode surface:
157
+
158
+ - \`run_typescript\` compiles and executes an async TypeScript function body in a sandbox. Top-level \`await\` and \`return\` are supported.
159
+ - \`search_tools\` searches the current runtime catalog and can return focused TypeScript declarations.
160
+
161
+ The sandbox exposes \`tools\` and a limited set of safe JavaScript globals. It does not expose Node.js modules, filesystem APIs, process APIs, network APIs, dynamic imports, or arbitrary package imports.
162
+
163
+ Prefer one execution that calls, combines, and reduces upstream results. Use \`Promise.all\` only for independent operations. Keep the final return value small; do not return raw payloads when a projection or summary is sufficient.
164
+
165
+ The generated declaration snapshot is authoritative for its recorded catalog revision. If a call is missing or fails with \`TOOL_NOT_FOUND\`, use \`search_tools\` to inspect the live catalog and then refresh the snapshot with \`npm run plugin:sync\` when maintaining the plugin.
166
+ `;
167
+ }
168
+ function renderResultContractReference() {
169
+ return `# Tool result contract
170
+
171
+ Every \`tools.*\` call resolves to an MCP result wrapper rather than directly to the upstream payload:
172
+
173
+ \`\`\`ts
174
+ interface ToolContentBlock {
175
+ readonly type: string;
176
+ readonly [key: string]: unknown;
177
+ }
178
+
179
+ interface ToolResult<TStructured = unknown> {
180
+ readonly content: readonly ToolContentBlock[];
181
+ readonly structuredContent?: TStructured;
182
+ }
183
+ \`\`\`
184
+
185
+ Prefer \`structuredContent\` when present. Some servers nest the useful value under \`structuredContent.result\`. When structured content is absent, inspect text blocks in \`content\` and call \`JSON.parse\` only after confirming the selected block has a string \`text\` field.
186
+
187
+ Tool failures throw a catchable \`ToolCallError\` with \`code\`, \`phase\`, and optional \`source\` and \`tool\` fields. Catch an error only when the workflow can recover or return a more useful bounded result.
188
+ `;
189
+ }
190
+ function renderExamplesReference() {
191
+ return `# Composition examples
192
+
193
+ Replace the source, tool, and input names with declarations from \`tools.d.ts\`.
194
+
195
+ ## Extract structured data
196
+
197
+ \`\`\`ts
198
+ const result = await tools["source-name"]["tool-name"]({});
199
+ const structured = result.structuredContent;
200
+ return structured !== null &&
201
+ typeof structured === "object" &&
202
+ !Array.isArray(structured) &&
203
+ "result" in structured
204
+ ? structured.result
205
+ : structured;
206
+ \`\`\`
207
+
208
+ ## Run independent calls concurrently
209
+
210
+ \`\`\`ts
211
+ const [first, second] = await Promise.all([
212
+ tools["source-name"]["first-tool"]({}),
213
+ tools["source-name"]["second-tool"]({}),
214
+ ]);
215
+ return {
216
+ first: first.structuredContent,
217
+ second: second.structuredContent,
218
+ };
219
+ \`\`\`
220
+
221
+ ## Recover from an optional call
222
+
223
+ \`\`\`ts
224
+ try {
225
+ const result = await tools["source-name"]["optional-tool"]({});
226
+ return { available: true, value: result.structuredContent };
227
+ } catch (error) {
228
+ return {
229
+ available: false,
230
+ code: error instanceof ToolCallError ? error.code : "UNKNOWN",
231
+ };
232
+ }
233
+ \`\`\`
234
+ `;
235
+ }
236
+ function renderPendingDeclarations() {
237
+ return `// CodeModeKit catalog snapshot pending.
238
+ // Run: npm run plugin:sync
239
+ `;
240
+ }
241
+ function renderCatalogDeclarations(revision, declarations) {
242
+ return `// Generated by CodeModeKit from catalog revision ${revision}.
243
+ // Refresh with: npm run plugin:sync
244
+
245
+ ${declarations.trim()}\n`;
246
+ }
247
+ async function stableCatalogSnapshot(codeMode, signal) {
248
+ for (let attempt = 0; attempt < 3; attempt += 1) {
249
+ const startup = await codeMode.start(signal);
250
+ const catalog = await codeMode.getTypeScriptCatalog(signal);
251
+ if (startup.catalogRevision === catalog.catalogRevision) {
252
+ return { startup, catalog };
253
+ }
254
+ }
255
+ throw new Error("The Code Mode catalog changed repeatedly while creating the snapshot");
256
+ }
257
+ async function writeJson(file, value) {
258
+ await writeFile(file, `${JSON.stringify(value, null, 2)}\n`, "utf8");
259
+ }
260
+ async function atomicWrite(file, contents) {
261
+ const temporary = `${file}.${String(process.pid)}.tmp`;
262
+ await writeFile(temporary, contents, "utf8");
263
+ await rename(temporary, file);
264
+ }
265
+ function validatePortableName(value, label) {
266
+ const name = required(value, label);
267
+ if (name.length > 64 || !PORTABLE_NAME.test(name)) {
268
+ throw new TypeError(`${label} must contain at most 64 lowercase letters, digits, and single hyphens`);
269
+ }
270
+ return name;
271
+ }
272
+ function validatePluginRelativePath(value, label) {
273
+ if (value === "" ||
274
+ path.isAbsolute(value) ||
275
+ value.split(/[\\/]/u).some((segment) => segment === "..")) {
276
+ throw new TypeError(`${label} must stay within the plugin root`);
277
+ }
278
+ }
279
+ function required(value, label) {
280
+ if (value.trim() === "") {
281
+ throw new TypeError(`${label} must not be empty`);
282
+ }
283
+ return value;
284
+ }
285
+ //# sourceMappingURL=agent-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-plugin.js","sourceRoot":"","sources":["../src/agent-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,aAAa,GACjB,4DAA4D,CAAC;AAC/D,MAAM,UAAU,GACd,yDAAyD,CAAC;AAC5D,MAAM,aAAa,GAAG,6BAA6B,CAAC;AA6DpD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAmC;IAEnC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IACxE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,gBAAgB,CAAC;IAC1D,0BAA0B,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;IAE5D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,MAAM,cAAc,GAAG,I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AC,IAAY,EAAE,QAAgB;IACvD,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;IACvD,MAAM,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa,EAAE,KAAa;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,SAAS,CACjB,GAAG,KAAK,wEAAwE,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa,EAAE,KAAa;IAC9D,IACE,KAAK,KAAK,EAAE;QACZ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;QACtB,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC,EACzD,CAAC;QACD,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,mCAAmC,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface InstallProjectAuthoringSkillOptions {
2
+ readonly root: string;
3
+ readonly overwrite?: boolean;
4
+ }
5
+ /** Installs CodeModeKit's development-time skill into the universal project path. */
6
+ export declare function installProjectAuthoringSkill(options: InstallProjectAuthoringSkillOptions): Promise<string>;
7
+ //# sourceMappingURL=authoring-skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-skill.d.ts","sourceRoot":"","sources":["../src/authoring-skill.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,qFAAqF;AACrF,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
@@ -0,0 +1,42 @@
1
+ import { cp, lstat, mkdir, rename, rm } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const AUTHORING_SKILL_NAME = "build-codemodekit-plugin";
5
+ const BUNDLED_SKILL_DIRECTORY = fileURLToPath(new URL(`../skills/${AUTHORING_SKILL_NAME}`, import.meta.url));
6
+ /** Installs CodeModeKit's development-time skill into the universal project path. */
7
+ export async function installProjectAuthoringSkill(options) {
8
+ const root = path.resolve(options.root);
9
+ const skillsRoot = path.join(root, ".agents", "skills");
10
+ const destination = path.join(skillsRoot, AUTHORING_SKILL_NAME);
11
+ const staging = path.join(skillsRoot, `.${AUTHORING_SKILL_NAME}.${String(process.pid)}.${String(Date.now())}.tmp`);
12
+ if ((await pathExists(destination)) && options.overwrite !== true) {
13
+ throw new Error(`Authoring skill already exists: ${destination}`);
14
+ }
15
+ await mkdir(skillsRoot, { recursive: true });
16
+ await rm(staging, { recursive: true, force: true });
17
+ await cp(BUNDLED_SKILL_DIRECTORY, staging, { recursive: true });
18
+ try {
19
+ await rm(destination, { recursive: true, force: true });
20
+ await rename(staging, destination);
21
+ }
22
+ catch (error) {
23
+ await rm(staging, { recursive: true, force: true });
24
+ throw error;
25
+ }
26
+ return destination;
27
+ }
28
+ async function pathExists(file) {
29
+ try {
30
+ await lstat(file);
31
+ return true;
32
+ }
33
+ catch (error) {
34
+ if (error instanceof Error &&
35
+ "code" in error &&
36
+ error.code === "ENOENT") {
37
+ return false;
38
+ }
39
+ throw error;
40
+ }
41
+ }
42
+ //# sourceMappingURL=authoring-skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authoring-skill.js","sourceRoot":"","sources":["../src/authoring-skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AACxD,MAAM,uBAAuB,GAAG,aAAa,CAC3C,IAAI,GAAG,CAAC,aAAa,oBAAoB,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC9D,CAAC;AAOF,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAA4C;IAE5C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CACvB,UAAU,EACV,IAAI,oBAAoB,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAC5E,CAAC;IACF,IAAI,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,C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M,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBnE"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAsBA,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DnE"}
package/dist/cli.js CHANGED
@@ -15,10 +15,46 @@ export async function runCli(args) {
15
15
  ? {}
16
16
  : { serverName: options.serverName }),
17
17
  policy: options.policy,
18
+ authoringSkill: options.authoringSkill,
18
19
  install: options.install,
20
+ ...(options.codemodekitVersion === undefined
21
+ ? {}
22
+ : { codemodekitVersion: options.codemodekitVersion }),
23
+ ...(options.createCodemodekitVersion === undefined
24
+ ? {}
25
+ : { createCodemodekitVersion: options.createCodemodekitVersion }),
26
+ ...(options.agentPlugin
27
+ ? {
28
+ agentPlugin: {
29
+ sync: options.sync && options.install,
30
+ ...(options.pluginName === undefined
31
+ ? {}
32
+ : { pluginName: options.pluginName }),
33
+ ...(options.skillName === undefined
34
+ ? {}
35
+ : { skillName: options.skillName }),
36
+ ...(options.pluginDescription === undefined
37
+ ? {}
38
+ : { description: options.pluginDescription }),
39
+ ...(options.pluginLicense === undefined
40
+ ? {}
41
+ : { license: options.pluginLicense }),
42
+ },
43
+ }
44
+ : {}),
19
45
  });
46
+ const pluginSummary = result.agentPlugin === undefined
47
+ ? ""
48
+ : `Agent Plugin: ${result.agentPlugin.built ? "built" : "scaffolded"} (${result.agentPlugin.skillName})\n` +
49
+ `${result.agentPlugin.synced ? "Catalog: synchronized\n" : "Catalog: pending\n"}` +
50
+ `${result.agentPlugin.syncError === undefined ? "" : `Catalog sync pending: ${result.agentPlugin.syncError}\n`}` +
51
+ `${result.agentPlugin.synced ? "" : " npm run plugin:sync\n"}` +
52
+ `${result.agentPlugin.built ? "" : " npm run plugin:build\n"}` +
53
+ " npm run plugin:install:cursor\n";
20
54
  process.stdout.write(`\nCreated ${options.serverName ?? `${options.mcpName}-code-mode`} in ${result.directory}\n\n` +
21
55
  `${result.installed ? "" : " npm install\n"} npm start\n\n` +
56
+ `${result.authoringSkillDirectory === undefined ? "" : "Authoring skill: .agents/skills/build-codemodekit-plugin\n"}` +
57
+ pluginSummary +
22
58
  `Tool policy: ${options.policy}\n`);
23
59
  }
24
60
  function parseOptions(args) {
@@ -26,8 +62,17 @@ function parseOptions(args) {
26
62
  let mcpName;
27
63
  let mcpCommand;
28
64
  let serverName;
65
+ let pluginName;
66
+ let skillName;
67
+ let pluginDescription;
68
+ let pluginLicense;
29
69
  let policy = "allow-all";
70
+ let agentPlugin = false;
71
+ let authoringSkill = true;
72
+ let sync = true;
30
73
  let install = true;
74
+ let codemodekitVersion;
75
+ let createCodemodekitVersion;
31
76
  for (let index = 0; index < args.length; index += 1) {
32
77
  const argument = args[index];
33
78
  if (argument === undefined)
@@ -43,6 +88,18 @@ function parseOptions(args) {
43
88
  install = false;
44
89
  continue;
45
90
  }
91
+ if (argument === "--agent-plugin") {
92
+ agentPlugin = true;
93
+ continue;
94
+ }
95
+ if (argument === "--no-authoring-skill") {
96
+ authoringSkill = false;
97
+ continue;
98
+ }
99
+ if (argument === "--no-sync") {
100
+ sync = false;
101
+ continue;
102
+ }
46
103
  const value = args[index + 1];
47
104
  if (value === undefined || value.startsWith("--")) {
48
105
  throw new TypeError(`Missing value for ${argument}`);
@@ -58,12 +115,30 @@ function parseOptions(args) {
58
115
  case "--server-name":
59
116
  serverName = value;
60
117
  break;
118
+ case "--plugin-name":
119
+ pluginName = value;
120
+ break;
121
+ case "--skill-name":
122
+ skillName = value;
123
+ break;
124
+ case "--plugin-description":
125
+ pluginDescription = value;
126
+ break;
127
+ case "--plugin-license":
128
+ pluginLicense = value;
129
+ break;
61
130
  case "--policy":
62
131
  if (value !== "allow-all" && value !== "deny-all") {
63
132
  throw new TypeError("--policy must be allow-all or deny-all");
64
133
  }
65
134
  policy = value;
66
135
  break;
136
+ case "--codemodekit-version":
137
+ codemodekitVersion = value;
138
+ break;
139
+ case "--create-codemodekit-version":
140
+ createCodemodekitVersion = value;
141
+ break;
67
142
  default:
68
143
  throw new TypeError(`Unknown option: ${argument}`);
69
144
  }
@@ -77,13 +152,28 @@ function parseOptions(args) {
77
152
  if (mcpCommand === undefined) {
78
153
  throw new TypeError("--mcp-command is required");
79
154
  }
155
+ if (!agentPlugin &&
156
+ [pluginName, skillName, pluginDescription, pluginLicense].some((value) => value !== undefined)) {
157
+ throw new TypeError("Plugin metadata options require --agent-plugin");
158
+ }
80
159
  return {
81
160
  targetDirectory,
82
161
  mcpName,
83
162
  mcpCommand,
84
163
  ...(serverName === undefined ? {} : { serverName }),
164
+ ...(pluginName === undefined ? {} : { pluginName }),
165
+ ...(skillName === undefined ? {} : { skillName }),
166
+ ...(pluginDescription === undefined ? {} : { pluginDescription }),
167
+ ...(pluginLicense === undefined ? {} : { pluginLicense }),
85
168
  policy,
169
+ agentPlugin,
170
+ authoringSkill,
171
+ sync,
86
172
  install,
173
+ ...(codemodekitVersion === undefined ? {} : { codemodekitVersion }),
174
+ ...(createCodemodekitVersion === undefined
175
+ ? {}
176
+ : { createCodemodekitVersion }),
87
177
  };
88
178
  }
89
179
  function usage() {
@@ -98,7 +188,17 @@ Options:
98
188
  --server-name <name> Downstream MCP server name
99
189
  --policy allow-all Allow every discovered upstream tool (default)
100
190
  --policy deny-all Deny every upstream tool until policy is edited
191
+ --agent-plugin Add plugin.json, mcp.json, and a companion Agent Skill
192
+ --plugin-name <name> Override the portable plugin name
193
+ --skill-name <name> Override the runtime companion skill name
194
+ --plugin-description <s> Override the plugin manifest description
195
+ --plugin-license <SPDX> Add a license identifier to plugin.json
196
+ --no-authoring-skill Omit the project-local CodeModeKit authoring skill
197
+ --no-sync Do not snapshot tool types during Agent Plugin creation
101
198
  --no-install Generate files without running npm install
199
+ --codemodekit-version <v> Override the generated runtime dependency
200
+ --create-codemodekit-version <v>
201
+ Override the generated sync dependency
102
202
  -h, --help Show this help
103
203
  `;
104
204
  }