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.
- package/README.md +41 -1
- package/dist/agent-plugin.d.ts +70 -0
- package/dist/agent-plugin.d.ts.map +1 -0
- package/dist/agent-plugin.js +285 -0
- package/dist/agent-plugin.js.map +1 -0
- package/dist/authoring-skill.d.ts +7 -0
- package/dist/authoring-skill.d.ts.map +1 -0
- package/dist/authoring-skill.js +42 -0
- package/dist/authoring-skill.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +100 -0
- package/dist/cli.js.map +1 -1
- package/dist/cursor-plugin.d.ts +25 -0
- package/dist/cursor-plugin.d.ts.map +1 -0
- package/dist/cursor-plugin.js +177 -0
- package/dist/cursor-plugin.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin-build.d.ts +19 -0
- package/dist/plugin-build.d.ts.map +1 -0
- package/dist/plugin-build.js +177 -0
- package/dist/plugin-build.js.map +1 -0
- package/dist/plugin-cli.d.ts +3 -0
- package/dist/plugin-cli.d.ts.map +1 -0
- package/dist/plugin-cli.js +102 -0
- package/dist/plugin-cli.js.map +1 -0
- package/dist/scaffold.d.ts +28 -0
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +247 -6
- package/dist/scaffold.js.map +1 -1
- package/package.json +11 -5
- package/skills/build-codemodekit-plugin/SKILL.md +44 -0
- package/skills/build-codemodekit-plugin/agents/openai.yaml +4 -0
- package/skills/build-codemodekit-plugin/references/generator.md +42 -0
- package/skills/build-codemodekit-plugin/references/plugin-layout.md +38 -0
- package/skills/build-codemodekit-plugin/references/programmatic-api.md +48 -0
package/dist/scaffold.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
import { type ScaffoldAgentPluginResult } from "./agent-plugin.js";
|
|
1
2
|
import type { ParsedCommand } from "./command.js";
|
|
3
|
+
export interface AgentPluginScaffoldOptions {
|
|
4
|
+
readonly pluginName?: string;
|
|
5
|
+
readonly skillName?: string;
|
|
6
|
+
readonly description?: string;
|
|
7
|
+
readonly license?: string;
|
|
8
|
+
/** Discover the live catalog and populate references after install. Defaults to true. */
|
|
9
|
+
readonly sync?: boolean;
|
|
10
|
+
}
|
|
2
11
|
export interface ScaffoldCodeModeMcpOptions {
|
|
3
12
|
readonly targetDirectory: string;
|
|
4
13
|
readonly mcpName: string;
|
|
@@ -6,13 +15,29 @@ export interface ScaffoldCodeModeMcpOptions {
|
|
|
6
15
|
readonly serverName?: string;
|
|
7
16
|
readonly packageName?: string;
|
|
8
17
|
readonly policy?: "allow-all" | "deny-all";
|
|
18
|
+
/** Generate a portable Agent Plugins 1.0 package and companion skill. */
|
|
19
|
+
readonly agentPlugin?: boolean | AgentPluginScaffoldOptions;
|
|
20
|
+
/** Install project-local authoring guidance under .agents/skills. Defaults to true. */
|
|
21
|
+
readonly authoringSkill?: boolean;
|
|
9
22
|
readonly install?: boolean;
|
|
23
|
+
/** Override the generated runtime dependency, including with a file: specifier. */
|
|
24
|
+
readonly codemodekitVersion?: string;
|
|
25
|
+
/** Override the generated sync-time dependency. */
|
|
26
|
+
readonly createCodemodekitVersion?: string;
|
|
10
27
|
readonly cwd?: string;
|
|
11
28
|
}
|
|
29
|
+
export interface GeneratedAgentPluginResult extends ScaffoldAgentPluginResult {
|
|
30
|
+
readonly synced: boolean;
|
|
31
|
+
readonly syncError?: string;
|
|
32
|
+
readonly built: boolean;
|
|
33
|
+
readonly artifactDirectory?: string;
|
|
34
|
+
}
|
|
12
35
|
export interface ScaffoldResult {
|
|
13
36
|
readonly directory: string;
|
|
14
37
|
readonly entrypoint: string;
|
|
15
38
|
readonly installed: boolean;
|
|
39
|
+
readonly authoringSkillDirectory?: string;
|
|
40
|
+
readonly agentPlugin?: GeneratedAgentPluginResult;
|
|
16
41
|
}
|
|
17
42
|
export declare function scaffoldCodeModeMcp(options: ScaffoldCodeModeMcpOptions): Promise<ScaffoldResult>;
|
|
18
43
|
interface RenderServerOptions {
|
|
@@ -20,6 +45,9 @@ interface RenderServerOptions {
|
|
|
20
45
|
readonly mcpName: string;
|
|
21
46
|
readonly mcpCommand: ParsedCommand;
|
|
22
47
|
readonly policy: "allow-all" | "deny-all";
|
|
48
|
+
readonly agentPlugin?: {
|
|
49
|
+
readonly skillName: string;
|
|
50
|
+
};
|
|
23
51
|
}
|
|
24
52
|
export declare function renderServer(options: RenderServerOptions): string;
|
|
25
53
|
export {};
|
package/dist/scaffold.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOlD,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,M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WAAW,GAAG,UAAU,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE;QACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH;AA+DD,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAyBjE"}
|
package/dist/scaffold.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
5
|
+
import { normalizePortableName, scaffoldAgentPlugin, } from "./agent-plugin.js";
|
|
6
|
+
import { installProjectAuthoringSkill } from "./authoring-skill.js";
|
|
7
|
+
const PACKAGE_VERSION = readPackageVersion();
|
|
8
|
+
// The generator and batteries-included runtime release independently.
|
|
9
|
+
const DEFAULT_CODEMODEKIT_VERSION = "^0.2.0";
|
|
10
|
+
const DEFAULT_CREATE_CODEMODEKIT_VERSION = `^${PACKAGE_VERSION}`;
|
|
4
11
|
export async function scaffoldCodeModeMcp(options) {
|
|
5
12
|
const cwd = options.cwd ?? process.cwd();
|
|
6
13
|
const directory = path.resolve(cwd, options.targetDirectory);
|
|
@@ -8,6 +15,17 @@ export async function scaffoldCodeModeMcp(options) {
|
|
|
8
15
|
const serverName = required(options.serverName ?? `${mcpName}-code-mode`, "Server name");
|
|
9
16
|
const packageName = validPackageName(options.packageName ?? packageNameFromDirectory(directory));
|
|
10
17
|
const policy = options.policy ?? "allow-all";
|
|
18
|
+
const install = options.install ?? true;
|
|
19
|
+
const includeAuthoringSkill = options.authoringSkill ?? true;
|
|
20
|
+
const agentPluginOptions = resolveAgentPluginOptions(options.agentPlugin);
|
|
21
|
+
const pluginName = agentPluginOptions === undefined
|
|
22
|
+
? undefined
|
|
23
|
+
: normalizePortableName(agentPluginOptions.pluginName ?? path.basename(directory), "Plugin name");
|
|
24
|
+
const skillName = agentPluginOptions === undefined
|
|
25
|
+
? undefined
|
|
26
|
+
: normalizePortableName(agentPluginOptions.skillName ?? `use-${mcpName}-codemode`, "Skill name");
|
|
27
|
+
const codemodekitVersion = required(options.codemodekitVersion ?? DEFAULT_CODEMODEKIT_VERSION, "CodeModeKit dependency version");
|
|
28
|
+
const createCodemodekitVersion = required(options.createCodemodekitVersion ?? DEFAULT_CREATE_CODEMODEKIT_VERSION, "create-codemodekit dependency version");
|
|
11
29
|
await ensureEmptyDirectory(directory);
|
|
12
30
|
await mkdir(path.join(directory, "src"), { recursive: true });
|
|
13
31
|
const packageJson = {
|
|
@@ -16,27 +34,167 @@ export async function scaffoldCodeModeMcp(options) {
|
|
|
16
34
|
private: true,
|
|
17
35
|
type: "module",
|
|
18
36
|
engines: { node: ">=20" },
|
|
19
|
-
scripts: {
|
|
20
|
-
|
|
37
|
+
scripts: {
|
|
38
|
+
start: "node src/server.mjs",
|
|
39
|
+
...(agentPluginOptions === undefined
|
|
40
|
+
? {}
|
|
41
|
+
: {
|
|
42
|
+
"plugin:sync": "node src/server.mjs --sync-plugin",
|
|
43
|
+
"plugin:build": "codemodekit-plugin build",
|
|
44
|
+
"plugin:install:cursor": "codemodekit-plugin install cursor",
|
|
45
|
+
"plugin:status:cursor": "codemodekit-plugin status cursor",
|
|
46
|
+
"plugin:uninstall:cursor": "codemodekit-plugin uninstall cursor",
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
dependencies: { "codemodekit": codemodekitVersion },
|
|
50
|
+
...(agentPluginOptions === undefined
|
|
51
|
+
? {}
|
|
52
|
+
: {
|
|
53
|
+
devDependencies: {
|
|
54
|
+
"create-codemodekit": createCodemodekitVersion,
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
21
57
|
};
|
|
22
58
|
const entrypoint = path.join(directory, "src", "server.mjs");
|
|
23
59
|
await Promise.all([
|
|
24
60
|
writeFile(path.join(directory, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`, "utf8"),
|
|
25
61
|
writeFile(path.join(directory, ".gitignore"), "node_modules/\n.env\n.env.*\n!.env.example\n", "utf8"),
|
|
62
|
+
writeFile(path.join(directory, "README.md"), renderProjectReadme({
|
|
63
|
+
packageName,
|
|
64
|
+
serverName,
|
|
65
|
+
mcpName,
|
|
66
|
+
mcpCommand: options.mcpCommand,
|
|
67
|
+
policy,
|
|
68
|
+
agentPlugin: agentPluginOptions !== undefined,
|
|
69
|
+
authoringSkill: includeAuthoringSkill,
|
|
70
|
+
}), "utf8"),
|
|
26
71
|
writeFile(entrypoint, renderServer({
|
|
27
72
|
serverName,
|
|
28
73
|
mcpName,
|
|
29
74
|
mcpCommand: options.mcpCommand,
|
|
30
75
|
policy,
|
|
76
|
+
...(skillName === undefined
|
|
77
|
+
? {}
|
|
78
|
+
: { agentPlugin: { skillName } }),
|
|
31
79
|
}), "utf8"),
|
|
32
80
|
]);
|
|
33
|
-
|
|
81
|
+
const authoringSkillDirectory = includeAuthoringSkill
|
|
82
|
+
? await installProjectAuthoringSkill({ root: directory })
|
|
83
|
+
: undefined;
|
|
84
|
+
let generatedPlugin;
|
|
85
|
+
if (agentPluginOptions !== undefined &&
|
|
86
|
+
pluginName !== undefined &&
|
|
87
|
+
skillName !== undefined) {
|
|
88
|
+
generatedPlugin = await scaffoldAgentPlugin({
|
|
89
|
+
root: directory,
|
|
90
|
+
pluginName,
|
|
91
|
+
serverName,
|
|
92
|
+
skillName,
|
|
93
|
+
...(agentPluginOptions.description === undefined
|
|
94
|
+
? {}
|
|
95
|
+
: { description: agentPluginOptions.description }),
|
|
96
|
+
...(agentPluginOptions.license === undefined
|
|
97
|
+
? {}
|
|
98
|
+
: { license: agentPluginOptions.license }),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (install) {
|
|
34
102
|
await runNpmInstall(directory);
|
|
35
103
|
}
|
|
36
|
-
|
|
104
|
+
let syncError;
|
|
105
|
+
let synced = false;
|
|
106
|
+
if (generatedPlugin !== undefined &&
|
|
107
|
+
(agentPluginOptions?.sync ?? install)) {
|
|
108
|
+
try {
|
|
109
|
+
await runPluginSync(directory);
|
|
110
|
+
synced = true;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
syncError = error instanceof Error ? error.message : String(error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
let built = false;
|
|
117
|
+
let artifactDirectory;
|
|
118
|
+
if (generatedPlugin !== undefined && install) {
|
|
119
|
+
await runPluginBuild(directory);
|
|
120
|
+
built = true;
|
|
121
|
+
artifactDirectory = path.join(directory, "dist", "plugin");
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
directory,
|
|
125
|
+
entrypoint,
|
|
126
|
+
installed: install,
|
|
127
|
+
...(authoringSkillDirectory === undefined
|
|
128
|
+
? {}
|
|
129
|
+
: { authoringSkillDirectory }),
|
|
130
|
+
...(generatedPlugin === undefined
|
|
131
|
+
? {}
|
|
132
|
+
: {
|
|
133
|
+
agentPlugin: {
|
|
134
|
+
...generatedPlugin,
|
|
135
|
+
synced,
|
|
136
|
+
built,
|
|
137
|
+
...(syncError === undefined ? {} : { syncError }),
|
|
138
|
+
...(artifactDirectory === undefined ? {} : { artifactDirectory }),
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function renderProjectReadme(options) {
|
|
144
|
+
const pluginSection = options.agentPlugin
|
|
145
|
+
? `
|
|
146
|
+
## Agent Plugin
|
|
147
|
+
|
|
148
|
+
Refresh the companion skill after the upstream tool catalog changes, then rebuild the self-contained plugin:
|
|
149
|
+
|
|
150
|
+
\`\`\`sh
|
|
151
|
+
npm run plugin:sync
|
|
152
|
+
npm run plugin:build
|
|
153
|
+
\`\`\`
|
|
154
|
+
|
|
155
|
+
The portable package is written to \`dist/plugin\`; it does not require this project's \`node_modules\`. Credentials and \`.env\` files are never copied into it.
|
|
156
|
+
|
|
157
|
+
For Cursor, install a concrete local copy and reload the window:
|
|
158
|
+
|
|
159
|
+
\`\`\`sh
|
|
160
|
+
npm run plugin:install:cursor
|
|
161
|
+
\`\`\`
|
|
162
|
+
|
|
163
|
+
Run \`npm run plugin:status:cursor\` to inspect it and \`npm run plugin:uninstall:cursor\` to remove it. Reinstall after changing source, policy, metadata, or generated references.
|
|
164
|
+
`
|
|
165
|
+
: "";
|
|
166
|
+
const authoringSection = options.authoringSkill
|
|
167
|
+
? `
|
|
168
|
+
## Development guidance
|
|
169
|
+
|
|
170
|
+
The project-local \`.agents/skills/build-codemodekit-plugin\` skill gives compatible coding agents the CodeModeKit authoring and maintenance workflow.
|
|
171
|
+
`
|
|
172
|
+
: "";
|
|
173
|
+
return `# ${options.packageName}
|
|
174
|
+
|
|
175
|
+
Code Mode MCP server generated by [CodeModeKit](https://github.com/stjbrown/codemodekit).
|
|
176
|
+
|
|
177
|
+
## Run
|
|
178
|
+
|
|
179
|
+
\`\`\`sh
|
|
180
|
+
npm start
|
|
181
|
+
\`\`\`
|
|
182
|
+
|
|
183
|
+
The downstream server is \`${options.serverName}\`. It wraps the \`${options.mcpName}\` source using this shell-free process configuration:
|
|
184
|
+
|
|
185
|
+
\`\`\`json
|
|
186
|
+
${JSON.stringify(options.mcpCommand, null, 2)}
|
|
187
|
+
\`\`\`
|
|
188
|
+
|
|
189
|
+
The generated tool policy is \`${options.policy}\`. Review \`src/server.mjs\` before exposing the server, and keep credentials in uncommitted environment files or the upstream tool's supported secret mechanism.
|
|
190
|
+
${pluginSection}${authoringSection}
|
|
191
|
+
`;
|
|
37
192
|
}
|
|
38
193
|
export function renderServer(options) {
|
|
39
194
|
const policyFactory = options.policy === "allow-all" ? "allowAllToolCalls" : "denyAllToolCalls";
|
|
195
|
+
if (options.agentPlugin !== undefined) {
|
|
196
|
+
return renderAgentPluginServer(options, policyFactory);
|
|
197
|
+
}
|
|
40
198
|
return `import {
|
|
41
199
|
${policyFactory},
|
|
42
200
|
mcp,
|
|
@@ -57,6 +215,54 @@ await serveCodeModeStdio({
|
|
|
57
215
|
});
|
|
58
216
|
`;
|
|
59
217
|
}
|
|
218
|
+
function renderAgentPluginServer(options, policyFactory) {
|
|
219
|
+
const skillName = options.agentPlugin?.skillName;
|
|
220
|
+
if (skillName === undefined) {
|
|
221
|
+
throw new TypeError("Agent Plugin skill name is required");
|
|
222
|
+
}
|
|
223
|
+
return `import { fileURLToPath } from "node:url";
|
|
224
|
+
|
|
225
|
+
import {
|
|
226
|
+
${policyFactory},
|
|
227
|
+
createCodeModeMcp,
|
|
228
|
+
mcp,
|
|
229
|
+
serveCodeModeStdio,
|
|
230
|
+
} from "codemodekit";
|
|
231
|
+
|
|
232
|
+
const options = {
|
|
233
|
+
name: ${JSON.stringify(options.serverName)},
|
|
234
|
+
version: "0.1.0",
|
|
235
|
+
toolPolicy: ${policyFactory}(),
|
|
236
|
+
sources: [
|
|
237
|
+
mcp.stdio({
|
|
238
|
+
name: ${JSON.stringify(options.mcpName)},
|
|
239
|
+
command: ${JSON.stringify(options.mcpCommand.command)},
|
|
240
|
+
args: ${JSON.stringify(options.mcpCommand.args)},
|
|
241
|
+
}),
|
|
242
|
+
],
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (process.argv.includes("--sync-plugin")) {
|
|
246
|
+
const { syncAgentPluginSkill } = await import("create-codemodekit");
|
|
247
|
+
const application = createCodeModeMcp(options);
|
|
248
|
+
try {
|
|
249
|
+
const result = await syncAgentPluginSkill({
|
|
250
|
+
root: fileURLToPath(new URL("../", import.meta.url)),
|
|
251
|
+
skillName: ${JSON.stringify(skillName)},
|
|
252
|
+
serverName: ${JSON.stringify(options.serverName)},
|
|
253
|
+
codeMode: application.codeMode,
|
|
254
|
+
});
|
|
255
|
+
process.stdout.write(
|
|
256
|
+
\`Synced Agent Plugin catalog \${result.catalogRevision} to \${result.skillDirectory}\\n\`,
|
|
257
|
+
);
|
|
258
|
+
} finally {
|
|
259
|
+
await application.close();
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
await serveCodeModeStdio(options);
|
|
263
|
+
}
|
|
264
|
+
`;
|
|
265
|
+
}
|
|
60
266
|
async function ensureEmptyDirectory(directory) {
|
|
61
267
|
try {
|
|
62
268
|
const entries = await readdir(directory);
|
|
@@ -73,11 +279,21 @@ async function ensureEmptyDirectory(directory) {
|
|
|
73
279
|
}
|
|
74
280
|
}
|
|
75
281
|
function runNpmInstall(directory) {
|
|
282
|
+
return runCommand("npm", ["install"], directory, "npm install");
|
|
283
|
+
}
|
|
284
|
+
function runPluginSync(directory) {
|
|
285
|
+
return runCommand("npm", ["run", "plugin:sync"], directory, "Agent Plugin catalog sync");
|
|
286
|
+
}
|
|
287
|
+
function runPluginBuild(directory) {
|
|
288
|
+
return runCommand("npm", ["run", "plugin:build"], directory, "Agent Plugin build");
|
|
289
|
+
}
|
|
290
|
+
function runCommand(command, args, directory, label) {
|
|
76
291
|
return new Promise((resolve, reject) => {
|
|
77
|
-
const child = spawn(
|
|
292
|
+
const child = spawn(command, [...args], {
|
|
78
293
|
cwd: directory,
|
|
79
294
|
stdio: "inherit",
|
|
80
295
|
shell: false,
|
|
296
|
+
env: projectCommandEnvironment(),
|
|
81
297
|
});
|
|
82
298
|
child.once("error", reject);
|
|
83
299
|
child.once("exit", (code, signal) => {
|
|
@@ -85,10 +301,35 @@ function runNpmInstall(directory) {
|
|
|
85
301
|
resolve();
|
|
86
302
|
return;
|
|
87
303
|
}
|
|
88
|
-
reject(new Error(
|
|
304
|
+
reject(new Error(`${label} failed${signal === null ? ` with exit code ${String(code)}` : ` from signal ${signal}`}`));
|
|
89
305
|
});
|
|
90
306
|
});
|
|
91
307
|
}
|
|
308
|
+
function projectCommandEnvironment() {
|
|
309
|
+
const environment = { ...process.env };
|
|
310
|
+
for (const key of Object.keys(environment)) {
|
|
311
|
+
if (key.toLowerCase() === "npm_config_allow_scripts") {
|
|
312
|
+
delete environment[key];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return environment;
|
|
316
|
+
}
|
|
317
|
+
function resolveAgentPluginOptions(value) {
|
|
318
|
+
if (value === undefined || value === false)
|
|
319
|
+
return undefined;
|
|
320
|
+
return value === true ? {} : value;
|
|
321
|
+
}
|
|
322
|
+
function readPackageVersion() {
|
|
323
|
+
const document = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
324
|
+
if (typeof document !== "object" ||
|
|
325
|
+
document === null ||
|
|
326
|
+
!("version" in document) ||
|
|
327
|
+
typeof document.version !== "string" ||
|
|
328
|
+
document.version.trim() === "") {
|
|
329
|
+
throw new Error("create-codemodekit package version is unavailable");
|
|
330
|
+
}
|
|
331
|
+
return document.version;
|
|
332
|
+
}
|
|
92
333
|
function packageNameFromDirectory(directory) {
|
|
93
334
|
return path.basename(directory).toLowerCase().replace(/[^a-z0-9._-]+/gu, "-");
|
|
94
335
|
}
|
package/dist/scaffold.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,MAAM,eAAe,GAAG,kBAAkB,EAAE,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iB,EAAE,GAAG,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7C,IAAI,CAAC,qCAAqC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,SAAS,CAAC,6BAA6B,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,oBAAoB,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK;QACtB,MAAM,IAAI,KAAK;QACd,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-codemodekit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Scaffold
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Scaffold runnable CodeModeKit servers and portable Agent Plugins from MCP commands.",
|
|
5
5
|
"author": "Stephen Brown",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
|
-
"create-codemodekit": "./dist/cli.js"
|
|
24
|
+
"create-codemodekit": "./dist/cli.js",
|
|
25
|
+
"codemodekit-plugin": "./dist/plugin-cli.js"
|
|
25
26
|
},
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
@@ -32,16 +33,21 @@
|
|
|
32
33
|
"files": [
|
|
33
34
|
"dist/*.js",
|
|
34
35
|
"dist/*.d.ts",
|
|
35
|
-
"dist/*.map"
|
|
36
|
+
"dist/*.map",
|
|
37
|
+
"skills/**/*"
|
|
36
38
|
],
|
|
37
39
|
"keywords": [
|
|
38
40
|
"code-mode",
|
|
39
41
|
"mcp",
|
|
40
42
|
"model-context-protocol",
|
|
43
|
+
"agent-plugin",
|
|
44
|
+
"agent-skill",
|
|
41
45
|
"scaffold"
|
|
42
46
|
],
|
|
43
47
|
"publishConfig": {
|
|
44
48
|
"access": "public"
|
|
45
49
|
},
|
|
46
|
-
"dependencies": {
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"esbuild": "0.28.1"
|
|
52
|
+
}
|
|
47
53
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: build-codemodekit-plugin
|
|
3
|
+
description: Scaffold, retrofit, or maintain CodeModeKit servers and portable Agent Plugins with companion runtime skills. Use when creating a Code Mode MCP wrapper from an MCP command, adding Agent Plugins 1.0 packaging, refreshing generated tool TypeScript, configuring tool policy, installing a plugin into Cursor, or diagnosing a generated CodeModeKit project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build a CodeModeKit Plugin
|
|
7
|
+
|
|
8
|
+
Prefer CodeModeKit's generator and lifecycle commands over hand-writing manifests, bundles, or generated tool declarations.
|
|
9
|
+
|
|
10
|
+
## Create a new project
|
|
11
|
+
|
|
12
|
+
1. Identify a short source name and a shell-free MCP executable plus arguments.
|
|
13
|
+
2. Run:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm create codemodekit@latest <directory> -- \
|
|
17
|
+
--mcp-name <source-name> \
|
|
18
|
+
--mcp-command '<executable> [args...]' \
|
|
19
|
+
--agent-plugin
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. Inspect `src/server.mjs`, `plugin.json`, `mcp.json`, and the generated runtime skill before changing defaults.
|
|
23
|
+
4. Keep credentials outside committed files. Pass an env-file argument to the upstream executable when it supports one; do not embed secrets in `mcp.json`.
|
|
24
|
+
5. Run `npm run plugin:sync` after credentials and the upstream MCP are available.
|
|
25
|
+
6. Run `npm run plugin:build` to recreate the self-contained `dist/plugin` package.
|
|
26
|
+
7. Test `npm start` through an MCP client and confirm both `run_typescript` and `search_tools` are advertised.
|
|
27
|
+
|
|
28
|
+
Read [references/generator.md](references/generator.md) for flags and lifecycle commands.
|
|
29
|
+
|
|
30
|
+
## Update an existing project
|
|
31
|
+
|
|
32
|
+
Preserve the one-file server unless the integration genuinely needs more structure. Use `scaffoldAgentPlugin` for portable manifests and the companion skill, and use `syncAgentPluginSkill` with the project's `CodeMode` instance to refresh catalog-derived references. Never hand-edit `tools.d.ts`; it is generated output.
|
|
33
|
+
|
|
34
|
+
Read [references/programmatic-api.md](references/programmatic-api.md) for the builder contracts and [references/plugin-layout.md](references/plugin-layout.md) for generated-file ownership.
|
|
35
|
+
|
|
36
|
+
## Validate
|
|
37
|
+
|
|
38
|
+
- Treat a failed dependency install or plugin build as a generator failure; do not report the project as ready.
|
|
39
|
+
- Treat a failed catalog sync as recoverable when the upstream MCP merely needs credentials or connectivity. Keep the pending references and report the exact `npm run plugin:sync` follow-up.
|
|
40
|
+
- Reject partial snapshots when any source is unavailable.
|
|
41
|
+
- Keep `SKILL.md` procedural and compact. Put generated schemas, TypeScript declarations, result semantics, and examples in `references/`.
|
|
42
|
+
- Tell runtime agents to search large declaration references for focused matches instead of loading an entire catalog into context.
|
|
43
|
+
- Preserve `search_tools` as a live fallback for pending, stale, or dynamic catalogs.
|
|
44
|
+
- Reinstall the Cursor copy after changing source, policy, metadata, or generated references.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Generator reference
|
|
2
|
+
|
|
3
|
+
## Minimal server
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm create codemodekit@latest my-code-mode -- \
|
|
7
|
+
--mcp-name upstream \
|
|
8
|
+
--mcp-command 'uvx upstream-mcp'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Dependency installation is automatic. Use `--no-install` only when installation must happen later. The generator also installs this development-time skill at `.agents/skills/build-codemodekit-plugin`; use `--no-authoring-skill` to omit it.
|
|
12
|
+
|
|
13
|
+
## Agent Plugin
|
|
14
|
+
|
|
15
|
+
Add `--agent-plugin` to generate the portable manifests, companion Agent Skill, catalog references, and self-contained `dist/plugin` artifact. After installation, the generator attempts a live catalog sync. Use `--no-sync` to leave the references pending intentionally.
|
|
16
|
+
|
|
17
|
+
The generated package includes:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "node src/server.mjs",
|
|
23
|
+
"plugin:sync": "node src/server.mjs --sync-plugin",
|
|
24
|
+
"plugin:build": "codemodekit-plugin build",
|
|
25
|
+
"plugin:install:cursor": "codemodekit-plugin install cursor",
|
|
26
|
+
"plugin:status:cursor": "codemodekit-plugin status cursor",
|
|
27
|
+
"plugin:uninstall:cursor": "codemodekit-plugin uninstall cursor"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`plugin:install:cursor` rebuilds the artifact, copies it into Cursor's local plugin directory, and resolves concrete Node and server paths for Cursor. Reload Cursor after install. Re-run the command after source or catalog changes.
|
|
33
|
+
|
|
34
|
+
## Tool policy
|
|
35
|
+
|
|
36
|
+
`--policy allow-all` is the runnable default. It allows every tool advertised by configured sources, subject to restrictions enforced by the upstream server itself.
|
|
37
|
+
|
|
38
|
+
Use `--policy deny-all` when the generated server must begin closed. Replace the policy in `src/server.mjs` with an explicit application policy before expecting tool calls to succeed.
|
|
39
|
+
|
|
40
|
+
## Command parsing
|
|
41
|
+
|
|
42
|
+
`--mcp-command` is parsed into one executable and an argument array without a shell. Quotes and backslash escaping are supported. Pipes, redirects, command substitution, and leading environment assignments are rejected.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Generated plugin layout
|
|
2
|
+
|
|
3
|
+
```text
|
|
4
|
+
my-code-mode/
|
|
5
|
+
├── .agents/skills/build-codemodekit-plugin/
|
|
6
|
+
├── dist/plugin/
|
|
7
|
+
│ ├── emscripten-module.wasm
|
|
8
|
+
│ ├── mcp.json
|
|
9
|
+
│ ├── plugin.json
|
|
10
|
+
│ ├── server.mjs
|
|
11
|
+
│ └── skills/
|
|
12
|
+
├── package.json
|
|
13
|
+
├── plugin.json
|
|
14
|
+
├── mcp.json
|
|
15
|
+
├── src/
|
|
16
|
+
│ └── server.mjs
|
|
17
|
+
└── skills/
|
|
18
|
+
└── use-upstream-codemode/
|
|
19
|
+
├── SKILL.md
|
|
20
|
+
└── references/
|
|
21
|
+
├── catalog-metadata.json
|
|
22
|
+
├── examples.md
|
|
23
|
+
├── result-contract.md
|
|
24
|
+
├── runtime.md
|
|
25
|
+
└── tools.d.ts
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Ownership
|
|
29
|
+
|
|
30
|
+
- The developer owns `src/server.mjs`, tool policy, provider configuration, and plugin metadata.
|
|
31
|
+
- CodeModeKit owns generated `tools.d.ts`, `catalog-metadata.json`, and `dist/plugin`.
|
|
32
|
+
- The generated runtime `SKILL.md` contains stable procedure and should stay small.
|
|
33
|
+
- `runtime.md`, `result-contract.md`, and `examples.md` are scaffolded reference templates and may be tailored when an integration needs additional guidance.
|
|
34
|
+
- `.agents/skills/build-codemodekit-plugin` is development-time authoring guidance and is intentionally excluded from the portable plugin artifact.
|
|
35
|
+
|
|
36
|
+
`mcp.json` exposes the bundled Code Mode server to an Agent Plugins client. The upstream MCP remains configured inside `src/server.mjs`; it is not exposed as a second direct server that would bypass Code Mode policy and sandboxing.
|
|
37
|
+
|
|
38
|
+
The portable `dist/plugin/mcp.json` uses `${PLUGIN_ROOT}` as required by Agent Plugins. Cursor installation produces a separate concrete copy because Cursor currently needs absolute executable and server paths for local plugins.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Programmatic API
|
|
2
|
+
|
|
3
|
+
Import the builders from `create-codemodekit`.
|
|
4
|
+
|
|
5
|
+
## Scaffold the full project
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { parseMcpCommand, scaffoldCodeModeMcp } from "create-codemodekit";
|
|
9
|
+
|
|
10
|
+
const result = await scaffoldCodeModeMcp({
|
|
11
|
+
targetDirectory: "my-code-mode",
|
|
12
|
+
mcpName: "upstream",
|
|
13
|
+
mcpCommand: parseMcpCommand("uvx upstream-mcp"),
|
|
14
|
+
agentPlugin: true,
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Installation and the project authoring skill default to enabled. Pass `install: false` or `authoringSkill: false` only when intentionally deferring those steps.
|
|
19
|
+
|
|
20
|
+
`agentPlugin` also accepts configuration:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
agentPlugin: {
|
|
24
|
+
pluginName: "my-code-mode",
|
|
25
|
+
skillName: "use-my-code-mode",
|
|
26
|
+
description: "Use the upstream service through Code Mode.",
|
|
27
|
+
license: "Apache-2.0",
|
|
28
|
+
sync: true,
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Scaffold only plugin components
|
|
33
|
+
|
|
34
|
+
Use `scaffoldAgentPlugin` when a project already owns its server entrypoint. It writes `plugin.json`, `mcp.json`, the companion `SKILL.md`, and pending references.
|
|
35
|
+
|
|
36
|
+
Use `buildAgentPlugin` to create the dependency-free `dist/plugin` artifact. Use `installCursorPlugin`, `getCursorPluginStatus`, and `uninstallCursorPlugin` for Cursor's concrete local copy.
|
|
37
|
+
|
|
38
|
+
Use `installProjectAuthoringSkill` to add the bundled development-time skill to an existing project at `.agents/skills/build-codemodekit-plugin`.
|
|
39
|
+
|
|
40
|
+
## Refresh references
|
|
41
|
+
|
|
42
|
+
Call `syncAgentPluginSkill` with a started or startable CodeModeKit `CodeMode` instance. The function reads the revisioned TypeScript catalog, rejects degraded or unstable snapshots, and atomically replaces `references/tools.d.ts` and `references/catalog-metadata.json`.
|
|
43
|
+
|
|
44
|
+
Close the Code Mode application in a `finally` block after syncing.
|
|
45
|
+
|
|
46
|
+
## Observe execution
|
|
47
|
+
|
|
48
|
+
The high- and low-level constructors accept an `observer` callback. Use it for metrics, tracing, and audit correlation. Events contain IDs, source/tool names, byte counts, durations, outcomes, and stable error codes; they intentionally exclude authored code, arguments, results, logs, and diagnostic messages. Keep payload logging as a separate, explicit host decision.
|