create-codemodekit 0.3.0 → 0.5.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 (39) hide show
  1. package/README.md +45 -5
  2. package/dist/agent-plugin.d.ts +6 -7
  3. package/dist/agent-plugin.d.ts.map +1 -1
  4. package/dist/agent-plugin.js +34 -27
  5. package/dist/agent-plugin.js.map +1 -1
  6. package/dist/authoring-skill.d.ts +8 -1
  7. package/dist/authoring-skill.d.ts.map +1 -1
  8. package/dist/authoring-skill.js +17 -38
  9. package/dist/authoring-skill.js.map +1 -1
  10. package/dist/catalog-files.d.ts +28 -0
  11. package/dist/catalog-files.d.ts.map +1 -0
  12. package/dist/catalog-files.js +193 -0
  13. package/dist/catalog-files.js.map +1 -0
  14. package/dist/cli.d.ts +14 -1
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +345 -39
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.d.ts +4 -3
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +2 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/scaffold.d.ts +14 -6
  23. package/dist/scaffold.d.ts.map +1 -1
  24. package/dist/scaffold.js +177 -70
  25. package/dist/scaffold.js.map +1 -1
  26. package/dist/source-template.d.ts +31 -0
  27. package/dist/source-template.d.ts.map +1 -0
  28. package/dist/source-template.js +356 -0
  29. package/dist/source-template.js.map +1 -0
  30. package/dist/verify-template.d.ts +2 -0
  31. package/dist/verify-template.d.ts.map +1 -0
  32. package/dist/verify-template.js +113 -0
  33. package/dist/verify-template.js.map +1 -0
  34. package/package.json +5 -5
  35. package/skills/build-codemodekit-plugin/SKILL.md +0 -44
  36. package/skills/build-codemodekit-plugin/agents/openai.yaml +0 -4
  37. package/skills/build-codemodekit-plugin/references/generator.md +0 -42
  38. package/skills/build-codemodekit-plugin/references/plugin-layout.md +0 -38
  39. package/skills/build-codemodekit-plugin/references/programmatic-api.md +0 -48
package/README.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # create-codemodekit
2
2
 
3
- Scaffold a runnable, one-file Code Mode MCP server from an upstream MCP command.
3
+ Scaffold a runnable, one-file Code Mode MCP server from Local Tools, an upstream MCP command, or a remote MCP URL.
4
+
5
+ ## Build with a coding agent
6
+
7
+ Install CodeModeKit's development skills, then ask your agent to build the server:
8
+
9
+ ```sh
10
+ npx skills add stjbrown/codemodekit
11
+ ```
12
+
13
+ The skills can also be installed separately with `--skill build-codemodekit-server` or `--skill author-codemode-skill`. The generator below installs both automatically, so this step is for existing projects or a skill-first workflow.
14
+
15
+ ## Interactive weather starter
16
+
17
+ ```sh
18
+ npm create codemodekit@latest
19
+ ```
20
+
21
+ The default creates an editable Open-Meteo weather project, companion skill, and portable Agent Plugin. The equivalent non-interactive command is:
22
+
23
+ ```sh
24
+ npm create codemodekit@latest weather-code-mode -- --example weather
25
+ ```
26
+
27
+ The generated server uses two Local Tools—`findLocation` and `getCurrentWeather`—to demonstrate multi-call composition inside one `run_typescript` execution. No API key is required for Open-Meteo's limited non-commercial endpoint. Use the generated `.env.example` for customer or self-hosted endpoints.
28
+
29
+ ## Wrap an MCP command
4
30
 
5
31
  ```sh
6
32
  npm create codemodekit@latest my-code-mode -- \
@@ -8,13 +34,27 @@ npm create codemodekit@latest my-code-mode -- \
8
34
  --mcp-command 'uvx my-mcp-server'
9
35
 
10
36
  cd my-code-mode
37
+ npm run verify
11
38
  npm start
12
39
  ```
13
40
 
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.
41
+ 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. The `build-codemodekit-server` and `author-codemode-skill` development skills are installed under `.agents/skills` by default; use `--no-authoring-skill` to omit both.
15
42
 
16
43
  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
44
 
45
+ Use `--mcp-url https://example.com/mcp` instead of `--mcp-command` for a Streamable HTTP source. Add `--mcp-bearer-env MCP_TOKEN` or repeat `--mcp-header-env Header-Name=ENV_NAME` to assemble authentication headers from the host environment without writing credential values to source, manifests, or plugin artifacts.
46
+
47
+ Repeat a complete source group to combine MCPs in one generated catalog:
48
+
49
+ ```sh
50
+ npm create codemodekit@latest work-code-mode -- \
51
+ --mcp-name github --mcp-command 'docker run -i --rm ghcr.io/github/github-mcp-server' \
52
+ --mcp-name tickets --mcp-url https://tickets.example.com/mcp \
53
+ --mcp-bearer-env TICKETS_TOKEN
54
+ ```
55
+
56
+ Every scaffold includes `npm run verify`. It validates source discovery, the two-tool downstream surface, invalid calls, and sandbox isolation without calling provider tools. For a semantic live check, set `CODEMODEKIT_VERIFY_CODE_FILE` to a bounded TypeScript composition that returns `{ verified: true }`. The generated `.env.example` is documentation; export its variables with your preferred environment manager.
57
+
18
58
  ## Generate an Agent Plugin
19
59
 
20
60
  Add `--agent-plugin` to create a portable Agent Plugins 1.0 package around the Code Mode server:
@@ -26,7 +66,7 @@ npm create codemodekit@latest my-code-mode -- \
26
66
  --agent-plugin
27
67
  ```
28
68
 
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.
69
+ This adds root `plugin.json` and `mcp.json` files plus `skills/use-upstream-codemode/`. The generated companion skill is a mechanically correct runtime baseline. Catalog sync writes a complete `references/tools.d.ts`, one file per source, and bounded tool-prefix shards for large sources; `catalog-metadata.json` indexes the set. Use the installed `author-codemode-skill` to add domain triggers, real workflows, safety decisions, and type-correct compositions. After installation, the generator builds a self-contained `dist/plugin` artifact containing the server bundle, QuickJS WASM, manifests, and runtime skill.
30
70
 
31
71
  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
72
 
@@ -35,7 +75,7 @@ npm run plugin:sync
35
75
  npm run plugin:build
36
76
  ```
37
77
 
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.
78
+ Use `--no-sync` to skip the initial attempt intentionally. The artifact deliberately excludes `node_modules`, `.env`, source files, and both development-time authoring skills.
39
79
 
40
80
  ## Cursor lifecycle
41
81
 
@@ -53,4 +93,4 @@ Installation rebuilds first, copies the artifact beneath `~/.cursor/plugins/loca
53
93
 
54
94
  Use `--plugin-name`, `--skill-name`, `--plugin-description`, and `--plugin-license` with `--agent-plugin` to override the portable defaults.
55
95
 
56
- Programmatic consumers can call `scaffoldCodeModeMcp`, `scaffoldAgentPlugin`, `syncAgentPluginSkill`, `buildAgentPlugin`, `installProjectAuthoringSkill`, and the Cursor lifecycle functions directly.
96
+ Programmatic consumers can call `scaffoldCodeModeMcp`, `scaffoldAgentPlugin`, `syncAgentPluginSkill`, `buildAgentPlugin`, `installProjectAuthoringSkills`, and the Cursor lifecycle functions directly. The singular `installProjectAuthoringSkill` remains available for compatibility.
@@ -1,3 +1,5 @@
1
+ import { type AgentPluginTypeScriptCatalog } from "./catalog-files.js";
2
+ export type { AgentPluginTypeScriptCatalog, AgentPluginTypeScriptCatalogShard, AgentPluginTypeScriptCatalogSource, } from "./catalog-files.js";
1
3
  export interface AgentPluginCatalogSource {
2
4
  start(signal?: AbortSignal): Promise<AgentPluginStartupReport>;
3
5
  getTypeScriptCatalog(signal?: AbortSignal): Promise<AgentPluginTypeScriptCatalog>;
@@ -14,10 +16,6 @@ export interface AgentPluginSourceReport {
14
16
  readonly message?: string;
15
17
  readonly rejectedToolCount?: number;
16
18
  }
17
- export interface AgentPluginTypeScriptCatalog {
18
- readonly catalogRevision: string;
19
- readonly declarations: string;
20
- }
21
19
  export interface ScaffoldAgentPluginOptions {
22
20
  readonly root: string;
23
21
  readonly pluginName: string;
@@ -46,12 +44,14 @@ export interface SyncAgentPluginSkillResult {
46
44
  readonly skillDirectory: string;
47
45
  readonly catalogRevision: string;
48
46
  readonly declarations: string;
47
+ readonly declarationFiles: readonly string[];
49
48
  readonly metadata: string;
50
49
  readonly sources: readonly AgentPluginSourceReport[];
51
50
  }
52
51
  /**
53
- * Writes the portable Agent Plugins 1.0 wrapper and a compact companion skill.
54
- * Tool-specific declarations are populated later by syncAgentPluginSkill.
52
+ * Writes the portable Agent Plugins 1.0 wrapper and a mechanical runtime-skill
53
+ * baseline. Tool-specific declarations are populated by syncAgentPluginSkill;
54
+ * domain workflows remain agent- and developer-authored.
55
55
  */
56
56
  export declare function scaffoldAgentPlugin(options: ScaffoldAgentPluginOptions): Promise<ScaffoldAgentPluginResult>;
57
57
  /**
@@ -66,5 +66,4 @@ interface RenderCompanionSkillOptions {
66
66
  readonly serverName: string;
67
67
  }
68
68
  export declare function renderCompanionSkill(options: RenderCompanionSkillOptions): string;
69
- export {};
70
69
  //# sourceMappingURL=agent-plugin.d.ts.map
@@ -1 +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,W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AE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,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,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACtD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,yBAAyB,CAAC,CAsFpC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,0BAA0B,CAAC,CAqErC;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,CAyBR"}
@@ -1,11 +1,13 @@
1
- import { mkdir, rename, writeFile } from "node:fs/promises";
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { catalogDeclarationFiles, commitCatalogSnapshot, } from "./catalog-files.js";
3
4
  const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
4
5
  const MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
5
6
  const PORTABLE_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
6
7
  /**
7
- * Writes the portable Agent Plugins 1.0 wrapper and a compact companion skill.
8
- * Tool-specific declarations are populated later by syncAgentPluginSkill.
8
+ * Writes the portable Agent Plugins 1.0 wrapper and a mechanical runtime-skill
9
+ * baseline. Tool-specific declarations are populated by syncAgentPluginSkill;
10
+ * domain workflows remain agent- and developer-authored.
9
11
  */
10
12
  export async function scaffoldAgentPlugin(options) {
11
13
  const root = path.resolve(options.root);
@@ -51,9 +53,13 @@ export async function scaffoldAgentPlugin(options) {
51
53
  writeFile(path.join(referencesDirectory, "examples.md"), renderExamplesReference(), "utf8"),
52
54
  writeFile(path.join(referencesDirectory, "tools.d.ts"), renderPendingDeclarations(), "utf8"),
53
55
  writeJson(path.join(referencesDirectory, "catalog-metadata.json"), {
54
- schemaVersion: 1,
56
+ schemaVersion: 2,
55
57
  status: "pending",
56
58
  serverName,
59
+ declarations: [
60
+ { path: "tools.d.ts", scope: "catalog", toolCount: 0 },
61
+ ],
62
+ generatedFiles: ["tools.d.ts"],
57
63
  message: "Run npm run plugin:sync after the upstream tool source is available.",
58
64
  }),
59
65
  ]);
@@ -87,11 +93,12 @@ export async function syncAgentPluginSkill(options) {
87
93
  const skillDirectory = path.join(root, "skills", skillName);
88
94
  const referencesDirectory = path.join(skillDirectory, "references");
89
95
  await mkdir(referencesDirectory, { recursive: true });
96
+ const declarationFiles = catalogDeclarationFiles(snapshot.catalog);
90
97
  const declarationsPath = path.join(referencesDirectory, "tools.d.ts");
91
98
  const metadataPath = path.join(referencesDirectory, "catalog-metadata.json");
92
- const declarations = renderCatalogDeclarations(snapshot.catalog.catalogRevision, snapshot.catalog.declarations);
99
+ const totalToolCount = snapshot.startup.sources.reduce((total, source) => total + source.toolCount, 0);
93
100
  const metadata = {
94
- schemaVersion: 1,
101
+ schemaVersion: 2,
95
102
  status: "ready",
96
103
  serverName,
97
104
  catalogRevision: snapshot.catalog.catalogRevision,
@@ -103,15 +110,24 @@ export async function syncAgentPluginSkill(options) {
103
110
  ? {}
104
111
  : { rejectedToolCount: source.rejectedToolCount }),
105
112
  })),
113
+ declarations: declarationFiles.map((file) => ({
114
+ path: file.path,
115
+ scope: file.scope,
116
+ toolCount: file.scope === "catalog" ? totalToolCount : file.toolCount,
117
+ ...(file.source === undefined ? {} : { source: file.source }),
118
+ ...(file.prefixes === undefined ? {} : { prefixes: file.prefixes }),
119
+ })),
120
+ generatedFiles: declarationFiles.map((file) => file.path),
106
121
  };
107
- await Promise.all([
108
- atomicWrite(declarationsPath, declarations),
109
- atomicWrite(metadataPath, `${JSON.stringify(metadata, null, 2)}\n`),
110
- ]);
122
+ await commitCatalogSnapshot(referencesDirectory, new Map([
123
+ ...declarationFiles.map((file) => [file.path, file.contents]),
124
+ ["catalog-metadata.json", `${JSON.stringify(metadata, null, 2)}\n`],
125
+ ]));
111
126
  return {
112
127
  skillDirectory,
113
128
  catalogRevision: snapshot.catalog.catalogRevision,
114
129
  declarations: declarationsPath,
130
+ declarationFiles: declarationFiles.map((file) => path.join(referencesDirectory, file.path)),
115
131
  metadata: metadataPath,
116
132
  sources: snapshot.startup.sources,
117
133
  };
@@ -139,12 +155,14 @@ description: ${JSON.stringify(description)}
139
155
 
140
156
  # Use ${serverName} Code Mode
141
157
 
158
+ This generated baseline covers Code Mode mechanics and the live tool catalog. Maintainers should tailor its trigger description, workflows, safety decisions, and examples to the integration's real users before distribution.
159
+
142
160
  Use \`run_typescript\` as the primary interface to the tools wrapped by this server.
143
161
 
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.
162
+ 1. Read [references/catalog-metadata.json](references/catalog-metadata.json) as the declaration-file index. Open the narrowest listed prefix or source shard that covers the request; use [references/tools.d.ts](references/tools.d.ts) only for cross-source work or when no narrower shard applies.
145
163
  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.
164
+ 3. Return only the bounded value needed to answer the user. Project requested fields, omit empty metadata, cap collections, and summarize large result sets instead of returning raw upstream payloads.
165
+ 4. Use \`search_tools\` when the generated catalog is pending or stale, does not contain the needed capability, or the available client cannot search declaration files efficiently.
148
166
  5. Treat tool errors as data you can catch and handle; do not bypass tool policy or sandbox limits.
149
167
 
150
168
  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.
@@ -160,9 +178,9 @@ The server exposes a small Code Mode surface:
160
178
 
161
179
  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
180
 
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.
181
+ Prefer one execution that calls, combines, and reduces upstream results. Use \`Promise.all\` only for independent operations. Project requested fields, remove null or empty metadata, cap collections to the smallest useful number of rows, and return counts or summaries for larger sets. Do not return raw upstream payloads.
164
182
 
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.
183
+ The generated declaration snapshot is authoritative for its recorded catalog revision. \`catalog-metadata.json\` indexes the complete catalog, per-source files, and bounded tool-prefix shards. Start with the narrowest applicable shard so unrelated declarations stay out of context. 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
184
  `;
167
185
  }
168
186
  function renderResultContractReference() {
@@ -190,7 +208,7 @@ Tool failures throw a catchable \`ToolCallError\` with \`code\`, \`phase\`, and
190
208
  function renderExamplesReference() {
191
209
  return `# Composition examples
192
210
 
193
- Replace the source, tool, and input names with declarations from \`tools.d.ts\`.
211
+ Replace the source, tool, and input names with declarations from the narrowest file indexed by \`catalog-metadata.json\`.
194
212
 
195
213
  ## Extract structured data
196
214
 
@@ -238,12 +256,6 @@ function renderPendingDeclarations() {
238
256
  // Run: npm run plugin:sync
239
257
  `;
240
258
  }
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
259
  async function stableCatalogSnapshot(codeMode, signal) {
248
260
  for (let attempt = 0; attempt < 3; attempt += 1) {
249
261
  const startup = await codeMode.start(signal);
@@ -257,11 +269,6 @@ async function stableCatalogSnapshot(codeMode, signal) {
257
269
  async function writeJson(file, value) {
258
270
  await writeFile(file, `${JSON.stringify(value, null, 2)}\n`, "utf8");
259
271
  }
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
272
  function validatePortableName(value, label) {
266
273
  const name = required(value, label);
267
274
  if (name.length > 64 || !PORTABLE_NAME.test(name)) {
@@ -1 +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,C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AC,sEAAsE,CAAC,CAAC;AAC1F,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,KAAc;IACnD,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACvE,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"}
@@ -1,7 +1,14 @@
1
+ import { type InstallCodeModeKitSkillsResult } from "@codemodekit/skills";
1
2
  export interface InstallProjectAuthoringSkillOptions {
2
3
  readonly root: string;
3
4
  readonly overwrite?: boolean;
4
5
  }
5
- /** Installs CodeModeKit's development-time skill into the universal project path. */
6
+ /** Installs both CodeModeKit development skills into the universal project path. */
7
+ export declare function installProjectAuthoringSkills(options: InstallProjectAuthoringSkillOptions): Promise<InstallCodeModeKitSkillsResult>;
8
+ /**
9
+ * Installs the original server-building role for compatibility. New generators
10
+ * install both roles through installProjectAuthoringSkills.
11
+ */
6
12
  export declare function installProjectAuthoringSkill(options: InstallProjectAuthoringSkillOptions): Promise<string>;
13
+ export type { InstallCodeModeKitSkillsResult } from "@codemodekit/skills";
7
14
  //# sourceMappingURL=authoring-skill.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"authoring-skill.d.ts","sourceRoot":"","sources":["../src/authoring-skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,mCAAmC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,oFAAoF;AACpF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,8BAA8B,CAAC,CAEzC;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,YAAY,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,42 +1,21 @@
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;
1
+ import { installCodeModeKitSkills, } from "@codemodekit/skills";
2
+ /** Installs both CodeModeKit development skills into the universal project path. */
3
+ export function installProjectAuthoringSkills(options) {
4
+ return installCodeModeKitSkills(options);
27
5
  }
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;
6
+ /**
7
+ * Installs the original server-building role for compatibility. New generators
8
+ * install both roles through installProjectAuthoringSkills.
9
+ */
10
+ export async function installProjectAuthoringSkill(options) {
11
+ const result = await installCodeModeKitSkills({
12
+ ...options,
13
+ skills: ["build-codemodekit-server"],
14
+ });
15
+ const directory = result.directories["build-codemodekit-server"];
16
+ if (directory === undefined) {
17
+ throw new Error("The CodeModeKit server-building skill was not installed");
40
18
  }
19
+ return directory;
41
20
  }
42
21
  //# sourceMappingURL=authoring-skill.js.map
@@ -1 +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,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,KAAK,CAAC,UAAU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MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,OAA4C;IAE5C,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC;QAC5C,GAAG,OAAO;QACV,MAAM,EAAE,CAAC,0BAA0B,CAAC;KACrC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC;IACjE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface AgentPluginTypeScriptCatalog {
2
+ readonly catalogRevision: string;
3
+ readonly declarations: string;
4
+ readonly sources?: readonly AgentPluginTypeScriptCatalogSource[];
5
+ }
6
+ export interface AgentPluginTypeScriptCatalogSource {
7
+ readonly source: string;
8
+ readonly toolCount: number;
9
+ readonly declarations: string;
10
+ readonly shards: readonly AgentPluginTypeScriptCatalogShard[];
11
+ }
12
+ export interface AgentPluginTypeScriptCatalogShard {
13
+ readonly key: string;
14
+ readonly prefixes: readonly string[];
15
+ readonly toolCount: number;
16
+ readonly declarations: string;
17
+ }
18
+ export interface CatalogDeclarationFile {
19
+ readonly path: string;
20
+ readonly scope: "catalog" | "source" | "prefix";
21
+ readonly source?: string;
22
+ readonly prefixes?: readonly string[];
23
+ readonly toolCount: number;
24
+ readonly contents: string;
25
+ }
26
+ export declare function catalogDeclarationFiles(catalog: AgentPluginTypeScriptCatalog): readonly CatalogDeclarationFile[];
27
+ export declare function commitCatalogSnapshot(referencesDirectory: string, files: ReadonlyMap<string, string>): Promise<void>;
28
+ //# sourceMappingURL=catalog-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-files.d.ts","sourceRoot":"","sources":["../src/catalog-files.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,eAAe,EAAE,MAAM,C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promises";
3
+ import path from "node:path";
4
+ export function catalogDeclarationFiles(catalog) {
5
+ const files = [
6
+ {
7
+ path: "tools.d.ts",
8
+ scope: "catalog",
9
+ toolCount: catalog.sources?.reduce((total, source) => total + source.toolCount, 0) ?? 0,
10
+ contents: renderCatalogDeclarations(catalog.catalogRevision, catalog.declarations),
11
+ },
12
+ ];
13
+ const usedPaths = new Map([["tools.d.ts", "catalog"]]);
14
+ const sourceSegments = collisionSafeSegments((catalog.sources ?? []).map((source) => source.source));
15
+ for (const source of catalog.sources ?? []) {
16
+ const sourceSegment = sourceSegments.get(source.source) ?? safeFilenameSegment(source.source);
17
+ files.push({
18
+ path: allocateDeclarationPath([sourceSegment], `source:${source.source}`, usedPaths),
19
+ scope: "source",
20
+ source: source.source,
21
+ toolCount: source.toolCount,
22
+ contents: renderCatalogDeclarations(catalog.catalogRevision, source.declarations),
23
+ });
24
+ for (const shard of source.shards) {
25
+ const identity = `prefix:${source.source}:${shard.key}:` + shard.prefixes.join("\u0000");
26
+ files.push({
27
+ path: allocateDeclarationPath([sourceSegment, safeFilenameSegment(shard.key)], identity, usedPaths),
28
+ scope: "prefix",
29
+ source: source.source,
30
+ prefixes: shard.prefixes,
31
+ toolCount: shard.toolCount,
32
+ contents: renderCatalogDeclarations(catalog.catalogRevision, shard.declarations),
33
+ });
34
+ }
35
+ }
36
+ return files;
37
+ }
38
+ export async function commitCatalogSnapshot(referencesDirectory, files) {
39
+ const transaction = path.join(referencesDirectory, `.codemodekit-sync-${String(process.pid)}-${randomUUID()}`);
40
+ const incoming = path.join(transaction, "incoming");
41
+ const backup = path.join(transaction, "backup");
42
+ const incomingNames = [...files.keys()];
43
+ for (const name of incomingNames) {
44
+ validateGeneratedFilename(name);
45
+ }
46
+ await Promise.all([
47
+ mkdir(incoming, { recursive: true }),
48
+ mkdir(backup, { recursive: true }),
49
+ ]);
50
+ try {
51
+ await Promise.all([...files].map(([name, contents]) => writeFile(path.join(incoming, name), contents, "utf8")));
52
+ const existingNames = await ownedCatalogFiles(referencesDirectory);
53
+ const backedUp = [];
54
+ const committed = [];
55
+ try {
56
+ for (const name of existingNames) {
57
+ if (await fileExists(path.join(referencesDirectory, name))) {
58
+ await rename(path.join(referencesDirectory, name), path.join(backup, name));
59
+ backedUp.push(name);
60
+ }
61
+ }
62
+ const commitOrder = incomingNames
63
+ .filter((name) => name !== "catalog-metadata.json")
64
+ .concat(incomingNames.includes("catalog-metadata.json")
65
+ ? ["catalog-metadata.json"]
66
+ : []);
67
+ for (const name of commitOrder) {
68
+ await rename(path.join(incoming, name), path.join(referencesDirectory, name));
69
+ committed.push(name);
70
+ }
71
+ }
72
+ catch (error) {
73
+ await Promise.allSettled(committed.map((name) => rm(path.join(referencesDirectory, name), { force: true })));
74
+ for (const name of backedUp) {
75
+ await rename(path.join(backup, name), path.join(referencesDirectory, name));
76
+ }
77
+ throw error;
78
+ }
79
+ }
80
+ finally {
81
+ await rm(transaction, { recursive: true, force: true });
82
+ }
83
+ }
84
+ function collisionSafeSegments(values) {
85
+ const byBase = new Map();
86
+ for (const value of values) {
87
+ const base = safeFilenameSegment(value);
88
+ byBase.set(base, [...(byBase.get(base) ?? []), value]);
89
+ }
90
+ const result = new Map();
91
+ for (const [base, collisions] of byBase) {
92
+ for (const value of collisions) {
93
+ result.set(value, collisions.length === 1 ? base : `${base}-${shortHash(value)}`);
94
+ }
95
+ }
96
+ return result;
97
+ }
98
+ function allocateDeclarationPath(segments, identity, used) {
99
+ const base = `tools.${segments.join(".")}.d.ts`;
100
+ const existing = used.get(base);
101
+ if (existing === undefined || existing === identity) {
102
+ used.set(base, identity);
103
+ return base;
104
+ }
105
+ const stem = `tools.${segments.join(".")}-${shortHash(identity)}`;
106
+ let attempt = 1;
107
+ while (true) {
108
+ const candidate = `${stem}${attempt === 1 ? "" : `-${String(attempt)}`}.d.ts`;
109
+ const collision = used.get(candidate);
110
+ if (collision === undefined || collision === identity) {
111
+ used.set(candidate, identity);
112
+ return candidate;
113
+ }
114
+ attempt += 1;
115
+ }
116
+ }
117
+ function safeFilenameSegment(value) {
118
+ const normalized = value
119
+ .normalize("NFKD")
120
+ .replace(/[\u0300-\u036f]/gu, "")
121
+ .toLowerCase()
122
+ .replace(/[^a-z0-9]+/gu, "-")
123
+ .replace(/-+/gu, "-")
124
+ .replace(/^-|-$/gu, "");
125
+ if (normalized === "") {
126
+ return `item-${shortHash(value)}`;
127
+ }
128
+ if (normalized.length <= 48) {
129
+ return normalized;
130
+ }
131
+ return `${normalized.slice(0, 39).replace(/-$/u, "")}-${shortHash(value)}`;
132
+ }
133
+ function shortHash(value) {
134
+ return createHash("sha256").update(value).digest("hex").slice(0, 8);
135
+ }
136
+ function renderCatalogDeclarations(revision, declarations) {
137
+ return `// Generated by CodeModeKit from catalog revision ${revision}.
138
+ // Refresh with: npm run plugin:sync
139
+
140
+ ${declarations.trim()}\n`;
141
+ }
142
+ async function ownedCatalogFiles(referencesDirectory) {
143
+ const owned = new Set(["tools.d.ts", "catalog-metadata.json"]);
144
+ const metadataPath = path.join(referencesDirectory, "catalog-metadata.json");
145
+ try {
146
+ const metadata = JSON.parse(await readFile(metadataPath, "utf8"));
147
+ if (Array.isArray(metadata.generatedFiles)) {
148
+ for (const name of metadata.generatedFiles) {
149
+ if (typeof name === "string" && isGeneratedFilename(name)) {
150
+ owned.add(name);
151
+ }
152
+ }
153
+ }
154
+ }
155
+ catch {
156
+ // Legacy metadata is recovered by inspecting generated declaration headers.
157
+ }
158
+ try {
159
+ const entries = await readdir(referencesDirectory, { withFileTypes: true });
160
+ await Promise.all(entries.map(async (entry) => {
161
+ if (!entry.isFile() || !isGeneratedFilename(entry.name))
162
+ return;
163
+ const contents = await readFile(path.join(referencesDirectory, entry.name), "utf8");
164
+ if (contents.startsWith("// Generated by CodeModeKit") ||
165
+ contents.startsWith("// CodeModeKit catalog snapshot pending")) {
166
+ owned.add(entry.name);
167
+ }
168
+ }));
169
+ }
170
+ catch {
171
+ // The caller creates this directory; absence means there is no prior snapshot.
172
+ }
173
+ return [...owned].sort();
174
+ }
175
+ function validateGeneratedFilename(name) {
176
+ if (!isGeneratedFilename(name) && name !== "catalog-metadata.json") {
177
+ throw new TypeError(`Invalid generated catalog filename: ${name}`);
178
+ }
179
+ }
180
+ function isGeneratedFilename(name) {
181
+ return (path.basename(name) === name &&
182
+ /^tools(?:\.[a-z0-9-]+)*\.d\.ts$/u.test(name));
183
+ }
184
+ async function fileExists(file) {
185
+ try {
186
+ await access(file);
187
+ return true;
188
+ }
189
+ catch {
190
+ return false;
191
+ }
192
+ }
193
+ //# sourceMappingURL=catalog-files.js.map