create-codemodekit 0.2.0 → 0.4.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 +51 -4
- package/dist/agent-plugin.d.ts +3 -2
- package/dist/agent-plugin.d.ts.map +1 -1
- package/dist/agent-plugin.js +6 -4
- package/dist/agent-plugin.js.map +1 -1
- package/dist/authoring-skill.d.ts +14 -0
- package/dist/authoring-skill.d.ts.map +1 -0
- package/dist/authoring-skill.js +21 -0
- package/dist/authoring-skill.js.map +1 -0
- package/dist/cli.d.ts +14 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +306 -36
- 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 +16 -5
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +176 -53
- package/dist/scaffold.js.map +1 -1
- package/dist/source-template.d.ts +21 -0
- package/dist/source-template.d.ts.map +1 -0
- package/dist/source-template.js +289 -0
- package/dist/source-template.js.map +1 -0
- package/package.json +22 -7
package/dist/scaffold.js
CHANGED
|
@@ -3,25 +3,29 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { normalizePortableName, scaffoldAgentPlugin, } from "./agent-plugin.js";
|
|
6
|
+
import { installProjectAuthoringSkills } from "./authoring-skill.js";
|
|
7
|
+
import { renderEnvExample, renderSource, renderSourceReadme, } from "./source-template.js";
|
|
6
8
|
const PACKAGE_VERSION = readPackageVersion();
|
|
7
9
|
// The generator and batteries-included runtime release independently.
|
|
8
|
-
const DEFAULT_CODEMODEKIT_VERSION = "^0.
|
|
10
|
+
const DEFAULT_CODEMODEKIT_VERSION = "^0.3.0";
|
|
9
11
|
const DEFAULT_CREATE_CODEMODEKIT_VERSION = `^${PACKAGE_VERSION}`;
|
|
10
12
|
export async function scaffoldCodeModeMcp(options) {
|
|
11
13
|
const cwd = options.cwd ?? process.cwd();
|
|
12
14
|
const directory = path.resolve(cwd, options.targetDirectory);
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
+
const source = resolveSource(options);
|
|
16
|
+
const sourceName = source.type === "weather" ? "weather" : source.name;
|
|
17
|
+
const serverName = required(options.serverName ?? `${sourceName}-code-mode`, "Server name");
|
|
15
18
|
const packageName = validPackageName(options.packageName ?? packageNameFromDirectory(directory));
|
|
16
19
|
const policy = options.policy ?? "allow-all";
|
|
17
20
|
const install = options.install ?? true;
|
|
21
|
+
const includeAuthoringSkill = options.authoringSkill ?? true;
|
|
18
22
|
const agentPluginOptions = resolveAgentPluginOptions(options.agentPlugin);
|
|
19
23
|
const pluginName = agentPluginOptions === undefined
|
|
20
24
|
? undefined
|
|
21
25
|
: normalizePortableName(agentPluginOptions.pluginName ?? path.basename(directory), "Plugin name");
|
|
22
26
|
const skillName = agentPluginOptions === undefined
|
|
23
27
|
? undefined
|
|
24
|
-
: normalizePortableName(agentPluginOptions.skillName ?? `use-${
|
|
28
|
+
: normalizePortableName(agentPluginOptions.skillName ?? `use-${sourceName}-codemode`, "Skill name");
|
|
25
29
|
const codemodekitVersion = required(options.codemodekitVersion ?? DEFAULT_CODEMODEKIT_VERSION, "CodeModeKit dependency version");
|
|
26
30
|
const createCodemodekitVersion = required(options.createCodemodekitVersion ?? DEFAULT_CREATE_CODEMODEKIT_VERSION, "create-codemodekit dependency version");
|
|
27
31
|
await ensureEmptyDirectory(directory);
|
|
@@ -36,7 +40,13 @@ export async function scaffoldCodeModeMcp(options) {
|
|
|
36
40
|
start: "node src/server.mjs",
|
|
37
41
|
...(agentPluginOptions === undefined
|
|
38
42
|
? {}
|
|
39
|
-
: {
|
|
43
|
+
: {
|
|
44
|
+
"plugin:sync": "node src/server.mjs --sync-plugin",
|
|
45
|
+
"plugin:build": "codemodekit-plugin build",
|
|
46
|
+
"plugin:install:cursor": "codemodekit-plugin install cursor",
|
|
47
|
+
"plugin:status:cursor": "codemodekit-plugin status cursor",
|
|
48
|
+
"plugin:uninstall:cursor": "codemodekit-plugin uninstall cursor",
|
|
49
|
+
}),
|
|
40
50
|
},
|
|
41
51
|
dependencies: { "codemodekit": codemodekitVersion },
|
|
42
52
|
...(agentPluginOptions === undefined
|
|
@@ -51,16 +61,31 @@ export async function scaffoldCodeModeMcp(options) {
|
|
|
51
61
|
await Promise.all([
|
|
52
62
|
writeFile(path.join(directory, "package.json"), `${JSON.stringify(packageJson, null, 2)}\n`, "utf8"),
|
|
53
63
|
writeFile(path.join(directory, ".gitignore"), "node_modules/\n.env\n.env.*\n!.env.example\n", "utf8"),
|
|
64
|
+
writeFile(path.join(directory, ".env.example"), renderEnvExample(source), "utf8"),
|
|
65
|
+
writeFile(path.join(directory, "README.md"), renderProjectReadme({
|
|
66
|
+
packageName,
|
|
67
|
+
serverName,
|
|
68
|
+
source,
|
|
69
|
+
policy,
|
|
70
|
+
agentPlugin: agentPluginOptions !== undefined,
|
|
71
|
+
authoringSkill: includeAuthoringSkill,
|
|
72
|
+
}), "utf8"),
|
|
54
73
|
writeFile(entrypoint, renderServer({
|
|
55
74
|
serverName,
|
|
56
|
-
|
|
57
|
-
mcpCommand: options.mcpCommand,
|
|
75
|
+
source,
|
|
58
76
|
policy,
|
|
59
77
|
...(skillName === undefined
|
|
60
78
|
? {}
|
|
61
79
|
: { agentPlugin: { skillName } }),
|
|
62
80
|
}), "utf8"),
|
|
63
81
|
]);
|
|
82
|
+
const authoringSkills = includeAuthoringSkill
|
|
83
|
+
? await installProjectAuthoringSkills({ root: directory })
|
|
84
|
+
: undefined;
|
|
85
|
+
const authoringSkillDirectories = authoringSkills === undefined
|
|
86
|
+
? undefined
|
|
87
|
+
: Object.values(authoringSkills.directories).filter((value) => value !== undefined);
|
|
88
|
+
const authoringSkillDirectory = authoringSkillDirectories?.[0];
|
|
64
89
|
let generatedPlugin;
|
|
65
90
|
if (agentPluginOptions !== undefined &&
|
|
66
91
|
pluginName !== undefined &&
|
|
@@ -93,81 +118,124 @@ export async function scaffoldCodeModeMcp(options) {
|
|
|
93
118
|
syncError = error instanceof Error ? error.message : String(error);
|
|
94
119
|
}
|
|
95
120
|
}
|
|
121
|
+
let built = false;
|
|
122
|
+
let artifactDirectory;
|
|
123
|
+
if (generatedPlugin !== undefined && install) {
|
|
124
|
+
await runPluginBuild(directory);
|
|
125
|
+
built = true;
|
|
126
|
+
artifactDirectory = path.join(directory, "dist", "plugin");
|
|
127
|
+
}
|
|
96
128
|
return {
|
|
97
129
|
directory,
|
|
98
130
|
entrypoint,
|
|
99
131
|
installed: install,
|
|
132
|
+
...(authoringSkillDirectory === undefined
|
|
133
|
+
? {}
|
|
134
|
+
: { authoringSkillDirectory }),
|
|
135
|
+
...(authoringSkillDirectories === undefined
|
|
136
|
+
? {}
|
|
137
|
+
: { authoringSkillDirectories }),
|
|
100
138
|
...(generatedPlugin === undefined
|
|
101
139
|
? {}
|
|
102
140
|
: {
|
|
103
141
|
agentPlugin: {
|
|
104
142
|
...generatedPlugin,
|
|
105
143
|
synced,
|
|
144
|
+
built,
|
|
106
145
|
...(syncError === undefined ? {} : { syncError }),
|
|
146
|
+
...(artifactDirectory === undefined ? {} : { artifactDirectory }),
|
|
107
147
|
},
|
|
108
148
|
}),
|
|
109
149
|
};
|
|
110
150
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
return `import {
|
|
117
|
-
${policyFactory},
|
|
118
|
-
mcp,
|
|
119
|
-
serveCodeModeStdio,
|
|
120
|
-
} from "codemodekit";
|
|
151
|
+
function renderProjectReadme(options) {
|
|
152
|
+
const pluginSection = options.agentPlugin
|
|
153
|
+
? `
|
|
154
|
+
## Agent Plugin
|
|
121
155
|
|
|
122
|
-
|
|
123
|
-
name: ${JSON.stringify(options.serverName)},
|
|
124
|
-
version: "0.1.0",
|
|
125
|
-
toolPolicy: ${policyFactory}(),
|
|
126
|
-
sources: [
|
|
127
|
-
mcp.stdio({
|
|
128
|
-
name: ${JSON.stringify(options.mcpName)},
|
|
129
|
-
command: ${JSON.stringify(options.mcpCommand.command)},
|
|
130
|
-
args: ${JSON.stringify(options.mcpCommand.args)},
|
|
131
|
-
}),
|
|
132
|
-
],
|
|
133
|
-
});
|
|
134
|
-
`;
|
|
135
|
-
}
|
|
136
|
-
function renderAgentPluginServer(options, policyFactory) {
|
|
137
|
-
const skillName = options.agentPlugin?.skillName;
|
|
138
|
-
if (skillName === undefined) {
|
|
139
|
-
throw new TypeError("Agent Plugin skill name is required");
|
|
140
|
-
}
|
|
141
|
-
return `import { fileURLToPath } from "node:url";
|
|
156
|
+
Refresh the companion skill after the upstream tool catalog changes, then rebuild the self-contained plugin:
|
|
142
157
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
\`\`\`sh
|
|
159
|
+
npm run plugin:sync
|
|
160
|
+
npm run plugin:build
|
|
161
|
+
\`\`\`
|
|
162
|
+
|
|
163
|
+
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.
|
|
164
|
+
|
|
165
|
+
For Cursor, install a concrete local copy and reload the window:
|
|
166
|
+
|
|
167
|
+
\`\`\`sh
|
|
168
|
+
npm run plugin:install:cursor
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
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.
|
|
172
|
+
`
|
|
173
|
+
: "";
|
|
174
|
+
const authoringSection = options.authoringSkill
|
|
175
|
+
? `
|
|
176
|
+
## Development guidance
|
|
177
|
+
|
|
178
|
+
The project-local \`.agents/skills/build-codemodekit-server\` and \`.agents/skills/author-codemode-skill\` skills let compatible coding agents build the server, then author domain-aware runtime guidance and maintain its Agent Plugin.
|
|
179
|
+
|
|
180
|
+
After the catalog is synchronized, ask the coding agent to use \`$author-codemode-skill\` before distributing the generated runtime skill.
|
|
181
|
+
`
|
|
182
|
+
: "";
|
|
183
|
+
const sourceSection = renderSourceReadme(options.source);
|
|
184
|
+
return `# ${options.packageName}
|
|
185
|
+
|
|
186
|
+
Code Mode MCP server generated by [CodeModeKit](https://github.com/stjbrown/codemodekit).
|
|
187
|
+
|
|
188
|
+
## Run
|
|
149
189
|
|
|
150
|
-
|
|
190
|
+
\`\`\`sh
|
|
191
|
+
npm start
|
|
192
|
+
\`\`\`
|
|
193
|
+
|
|
194
|
+
The downstream server is \`${options.serverName}\`.
|
|
195
|
+
|
|
196
|
+
${sourceSection}
|
|
197
|
+
|
|
198
|
+
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.
|
|
199
|
+
${pluginSection}${authoringSection}
|
|
200
|
+
`;
|
|
201
|
+
}
|
|
202
|
+
export function renderServer(options) {
|
|
203
|
+
const policyFactory = options.policy === "allow-all" ? "allowAllToolCalls" : "denyAllToolCalls";
|
|
204
|
+
const source = renderSource(options.source);
|
|
205
|
+
const plugin = options.agentPlugin;
|
|
206
|
+
const nodeImport = plugin === undefined ? "" : 'import { fileURLToPath } from "node:url";\n\n';
|
|
207
|
+
const imports = [
|
|
208
|
+
policyFactory,
|
|
209
|
+
...(plugin === undefined ? [] : ["createCodeModeMcp"]),
|
|
210
|
+
...source.imports,
|
|
211
|
+
"serveCodeModeStdio",
|
|
212
|
+
].sort();
|
|
213
|
+
const application = `const options = {
|
|
151
214
|
name: ${JSON.stringify(options.serverName)},
|
|
152
215
|
version: "0.1.0",
|
|
153
216
|
toolPolicy: ${policyFactory}(),
|
|
154
|
-
sources: [
|
|
155
|
-
mcp.stdio({
|
|
156
|
-
name: ${JSON.stringify(options.mcpName)},
|
|
157
|
-
command: ${JSON.stringify(options.mcpCommand.command)},
|
|
158
|
-
args: ${JSON.stringify(options.mcpCommand.args)},
|
|
159
|
-
}),
|
|
160
|
-
],
|
|
217
|
+
sources: [${source.expression}],
|
|
161
218
|
};
|
|
219
|
+
`;
|
|
220
|
+
const launch = plugin === undefined
|
|
221
|
+
? "await serveCodeModeStdio(options);\n"
|
|
222
|
+
: renderAgentPluginLaunch(plugin.skillName, options.serverName);
|
|
223
|
+
return `${nodeImport}import {
|
|
224
|
+
${imports.map((name) => ` ${name},`).join("\n")}
|
|
225
|
+
} from "codemodekit";
|
|
162
226
|
|
|
163
|
-
|
|
227
|
+
${source.prelude}${application}
|
|
228
|
+
${launch}`;
|
|
229
|
+
}
|
|
230
|
+
function renderAgentPluginLaunch(skillName, serverName) {
|
|
231
|
+
return `if (process.argv.includes("--sync-plugin")) {
|
|
164
232
|
const { syncAgentPluginSkill } = await import("create-codemodekit");
|
|
165
233
|
const application = createCodeModeMcp(options);
|
|
166
234
|
try {
|
|
167
235
|
const result = await syncAgentPluginSkill({
|
|
168
236
|
root: fileURLToPath(new URL("../", import.meta.url)),
|
|
169
237
|
skillName: ${JSON.stringify(skillName)},
|
|
170
|
-
serverName: ${JSON.stringify(
|
|
238
|
+
serverName: ${JSON.stringify(serverName)},
|
|
171
239
|
codeMode: application.codeMode,
|
|
172
240
|
});
|
|
173
241
|
process.stdout.write(
|
|
@@ -181,6 +249,58 @@ if (process.argv.includes("--sync-plugin")) {
|
|
|
181
249
|
}
|
|
182
250
|
`;
|
|
183
251
|
}
|
|
252
|
+
function resolveSource(options) {
|
|
253
|
+
if (options.source !== undefined &&
|
|
254
|
+
(options.mcpName !== undefined || options.mcpCommand !== undefined)) {
|
|
255
|
+
throw new TypeError("Use either source or mcpName/mcpCommand, not both");
|
|
256
|
+
}
|
|
257
|
+
if (options.source !== undefined) {
|
|
258
|
+
switch (options.source.type) {
|
|
259
|
+
case "weather":
|
|
260
|
+
return options.source;
|
|
261
|
+
case "mcp-stdio":
|
|
262
|
+
return {
|
|
263
|
+
type: "mcp-stdio",
|
|
264
|
+
name: required(options.source.name, "MCP name"),
|
|
265
|
+
command: validateCommand(options.source.command),
|
|
266
|
+
};
|
|
267
|
+
case "mcp-http":
|
|
268
|
+
return {
|
|
269
|
+
type: "mcp-http",
|
|
270
|
+
name: required(options.source.name, "MCP name"),
|
|
271
|
+
url: validateHttpUrl(options.source.url),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (options.mcpName === undefined || options.mcpCommand === undefined) {
|
|
276
|
+
throw new TypeError("A source or mcpName/mcpCommand pair is required");
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
type: "mcp-stdio",
|
|
280
|
+
name: required(options.mcpName, "MCP name"),
|
|
281
|
+
command: validateCommand(options.mcpCommand),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function validateCommand(command) {
|
|
285
|
+
return {
|
|
286
|
+
command: required(command.command, "MCP command"),
|
|
287
|
+
args: command.args.map((argument) => String(argument)),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function validateHttpUrl(value) {
|
|
291
|
+
const candidate = required(value, "MCP URL");
|
|
292
|
+
let url;
|
|
293
|
+
try {
|
|
294
|
+
url = new URL(candidate);
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
throw new TypeError(`Invalid MCP URL: ${candidate}`);
|
|
298
|
+
}
|
|
299
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
300
|
+
throw new TypeError("MCP URL must use http or https");
|
|
301
|
+
}
|
|
302
|
+
return url.toString();
|
|
303
|
+
}
|
|
184
304
|
async function ensureEmptyDirectory(directory) {
|
|
185
305
|
try {
|
|
186
306
|
const entries = await readdir(directory);
|
|
@@ -202,6 +322,9 @@ function runNpmInstall(directory) {
|
|
|
202
322
|
function runPluginSync(directory) {
|
|
203
323
|
return runCommand("npm", ["run", "plugin:sync"], directory, "Agent Plugin catalog sync");
|
|
204
324
|
}
|
|
325
|
+
function runPluginBuild(directory) {
|
|
326
|
+
return runCommand("npm", ["run", "plugin:build"], directory, "Agent Plugin build");
|
|
327
|
+
}
|
|
205
328
|
function runCommand(command, args, directory, label) {
|
|
206
329
|
return new Promise((resolve, reject) => {
|
|
207
330
|
const child = spawn(command, [...args], {
|
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,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;AAG3B,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;AAC7C,sEAAsE;AACtE,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AAC7C,MAAM,kCAAkC,GAAG,IAAI,eAAe,EAAE,CAAC;AAwCjE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAmC;IAEnC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OA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,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;QACpC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAC9B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC;AAC1B,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAiB;IACjD,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,iBAAiB,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ParsedCommand } from "./command.js";
|
|
2
|
+
export type ScaffoldSource = {
|
|
3
|
+
readonly type: "mcp-stdio";
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly command: ParsedCommand;
|
|
6
|
+
} | {
|
|
7
|
+
readonly type: "mcp-http";
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly type: "weather";
|
|
12
|
+
};
|
|
13
|
+
export interface RenderedSource {
|
|
14
|
+
readonly imports: readonly string[];
|
|
15
|
+
readonly prelude: string;
|
|
16
|
+
readonly expression: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function renderSource(source: ScaffoldSource): RenderedSource;
|
|
19
|
+
export declare function renderSourceReadme(source: ScaffoldSource): string;
|
|
20
|
+
export declare function renderEnvExample(source: ScaffoldSource): string;
|
|
21
|
+
//# sourceMappingURL=source-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-template.d.ts","sourceRoot":"","sources":["../src/source-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,MAAM,cAAc,GACtB;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAqCnE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAejE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAY/D"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
export function renderSource(source) {
|
|
2
|
+
switch (source.type) {
|
|
3
|
+
case "mcp-stdio":
|
|
4
|
+
return {
|
|
5
|
+
imports: ["mcp"],
|
|
6
|
+
prelude: "",
|
|
7
|
+
expression: `
|
|
8
|
+
mcp.stdio({
|
|
9
|
+
name: ${JSON.stringify(source.name)},
|
|
10
|
+
command: ${JSON.stringify(source.command.command)},
|
|
11
|
+
args: ${JSON.stringify(source.command.args)},
|
|
12
|
+
}),
|
|
13
|
+
`,
|
|
14
|
+
};
|
|
15
|
+
case "mcp-http":
|
|
16
|
+
return {
|
|
17
|
+
imports: ["mcp"],
|
|
18
|
+
prelude: "",
|
|
19
|
+
expression: `
|
|
20
|
+
mcp.http({
|
|
21
|
+
name: ${JSON.stringify(source.name)},
|
|
22
|
+
url: ${JSON.stringify(source.url)},
|
|
23
|
+
}),
|
|
24
|
+
`,
|
|
25
|
+
};
|
|
26
|
+
case "weather":
|
|
27
|
+
return {
|
|
28
|
+
imports: ["defineTool", "local", "ToolError"],
|
|
29
|
+
prelude: renderWeatherPrelude(),
|
|
30
|
+
expression: `
|
|
31
|
+
local({
|
|
32
|
+
name: "weather",
|
|
33
|
+
tools: { findLocation, getCurrentWeather },
|
|
34
|
+
}),
|
|
35
|
+
`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function renderSourceReadme(source) {
|
|
40
|
+
switch (source.type) {
|
|
41
|
+
case "mcp-stdio":
|
|
42
|
+
return `It wraps the \`${source.name}\` MCP source using this shell-free process configuration:
|
|
43
|
+
|
|
44
|
+
\`\`\`json
|
|
45
|
+
${JSON.stringify(source.command, null, 2)}
|
|
46
|
+
\`\`\``;
|
|
47
|
+
case "mcp-http":
|
|
48
|
+
return `It wraps the \`${source.name}\` Streamable HTTP MCP source at \`${source.url}\`.`;
|
|
49
|
+
case "weather":
|
|
50
|
+
return `This is the editable, keyless weather starter. It exposes two local tools—\`weather.findLocation\` and \`weather.getCurrentWeather\`—so an agent can compose geocoding and current-weather lookup inside one \`run_typescript\` call.
|
|
51
|
+
|
|
52
|
+
It uses Open-Meteo's public endpoints by default. The free endpoint is intended for non-commercial use within Open-Meteo's published limits; review their terms before production use. Set \`OPEN_METEO_GEOCODING_URL\` and \`OPEN_METEO_FORECAST_URL\` to use customer or self-hosted endpoints.`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function renderEnvExample(source) {
|
|
56
|
+
switch (source.type) {
|
|
57
|
+
case "weather":
|
|
58
|
+
return `# Optional Open-Meteo customer or self-hosted endpoints.
|
|
59
|
+
# OPEN_METEO_GEOCODING_URL=https://geocoding-api.open-meteo.com/v1/search
|
|
60
|
+
# OPEN_METEO_FORECAST_URL=https://api.open-meteo.com/v1/forecast
|
|
61
|
+
`;
|
|
62
|
+
case "mcp-http":
|
|
63
|
+
return "# Add any credentials required by the remote MCP source here.\n";
|
|
64
|
+
case "mcp-stdio":
|
|
65
|
+
return "# Add any credentials required by the upstream MCP process here.\n";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function renderWeatherPrelude() {
|
|
69
|
+
return `const geocodingEndpoint =
|
|
70
|
+
process.env.OPEN_METEO_GEOCODING_URL ??
|
|
71
|
+
"https://geocoding-api.open-meteo.com/v1/search";
|
|
72
|
+
const forecastEndpoint =
|
|
73
|
+
process.env.OPEN_METEO_FORECAST_URL ??
|
|
74
|
+
"https://api.open-meteo.com/v1/forecast";
|
|
75
|
+
|
|
76
|
+
const findLocation = defineTool({
|
|
77
|
+
description: "Find the best matching city and its coordinates",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
query: {
|
|
82
|
+
type: "string",
|
|
83
|
+
minLength: 2,
|
|
84
|
+
maxLength: 200,
|
|
85
|
+
description: "City, postal code, or city and administrative area",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ["query"],
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
},
|
|
91
|
+
outputSchema: {
|
|
92
|
+
type: "object",
|
|
93
|
+
properties: {
|
|
94
|
+
name: { type: "string" },
|
|
95
|
+
country: { type: "string" },
|
|
96
|
+
latitude: { type: "number" },
|
|
97
|
+
longitude: { type: "number" },
|
|
98
|
+
timezone: { type: "string" },
|
|
99
|
+
},
|
|
100
|
+
required: ["name", "country", "latitude", "longitude", "timezone"],
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
},
|
|
103
|
+
annotations: {
|
|
104
|
+
title: "Find Location",
|
|
105
|
+
readOnlyHint: true,
|
|
106
|
+
destructiveHint: false,
|
|
107
|
+
idempotentHint: true,
|
|
108
|
+
openWorldHint: true,
|
|
109
|
+
},
|
|
110
|
+
execute: async ({ query }, { signal }) => {
|
|
111
|
+
const url = new URL(geocodingEndpoint);
|
|
112
|
+
url.searchParams.set("name", query);
|
|
113
|
+
url.searchParams.set("count", "1");
|
|
114
|
+
url.searchParams.set("language", "en");
|
|
115
|
+
url.searchParams.set("format", "json");
|
|
116
|
+
const payload = await fetchJson(url, signal, "Location lookup");
|
|
117
|
+
const results = Array.isArray(payload.results) ? payload.results : [];
|
|
118
|
+
const match = asRecord(results[0]);
|
|
119
|
+
if (match === undefined) {
|
|
120
|
+
throw new ToolError("No matching location was found");
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
name: stringField(match, "name", "Location lookup"),
|
|
124
|
+
country: optionalString(match.country),
|
|
125
|
+
latitude: numberField(match, "latitude", "Location lookup"),
|
|
126
|
+
longitude: numberField(match, "longitude", "Location lookup"),
|
|
127
|
+
timezone: optionalString(match.timezone),
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const getCurrentWeather = defineTool({
|
|
133
|
+
description: "Get current weather for latitude and longitude",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
latitude: { type: "number", minimum: -90, maximum: 90 },
|
|
138
|
+
longitude: { type: "number", minimum: -180, maximum: 180 },
|
|
139
|
+
},
|
|
140
|
+
required: ["latitude", "longitude"],
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
},
|
|
143
|
+
outputSchema: {
|
|
144
|
+
type: "object",
|
|
145
|
+
properties: {
|
|
146
|
+
time: { type: "string" },
|
|
147
|
+
temperature: { type: "number" },
|
|
148
|
+
apparentTemperature: { type: "number" },
|
|
149
|
+
relativeHumidity: { type: "number" },
|
|
150
|
+
precipitation: { type: "number" },
|
|
151
|
+
weatherCode: { type: "number" },
|
|
152
|
+
condition: { type: "string" },
|
|
153
|
+
windSpeed: { type: "number" },
|
|
154
|
+
units: {
|
|
155
|
+
type: "object",
|
|
156
|
+
properties: {
|
|
157
|
+
temperature: { type: "string" },
|
|
158
|
+
precipitation: { type: "string" },
|
|
159
|
+
windSpeed: { type: "string" },
|
|
160
|
+
},
|
|
161
|
+
required: ["temperature", "precipitation", "windSpeed"],
|
|
162
|
+
additionalProperties: false,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
required: [
|
|
166
|
+
"time",
|
|
167
|
+
"temperature",
|
|
168
|
+
"apparentTemperature",
|
|
169
|
+
"relativeHumidity",
|
|
170
|
+
"precipitation",
|
|
171
|
+
"weatherCode",
|
|
172
|
+
"condition",
|
|
173
|
+
"windSpeed",
|
|
174
|
+
"units",
|
|
175
|
+
],
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
},
|
|
178
|
+
annotations: {
|
|
179
|
+
title: "Get Current Weather",
|
|
180
|
+
readOnlyHint: true,
|
|
181
|
+
destructiveHint: false,
|
|
182
|
+
idempotentHint: true,
|
|
183
|
+
openWorldHint: true,
|
|
184
|
+
},
|
|
185
|
+
execute: async ({ latitude, longitude }, { signal }) => {
|
|
186
|
+
const url = new URL(forecastEndpoint);
|
|
187
|
+
url.searchParams.set("latitude", String(latitude));
|
|
188
|
+
url.searchParams.set("longitude", String(longitude));
|
|
189
|
+
url.searchParams.set(
|
|
190
|
+
"current",
|
|
191
|
+
"temperature_2m,apparent_temperature,relative_humidity_2m,precipitation,weather_code,wind_speed_10m",
|
|
192
|
+
);
|
|
193
|
+
url.searchParams.set("timezone", "auto");
|
|
194
|
+
const payload = await fetchJson(url, signal, "Weather lookup");
|
|
195
|
+
const current = requiredRecord(payload.current, "Weather lookup");
|
|
196
|
+
const units = requiredRecord(payload.current_units, "Weather lookup");
|
|
197
|
+
const weatherCode = numberField(current, "weather_code", "Weather lookup");
|
|
198
|
+
return {
|
|
199
|
+
time: stringField(current, "time", "Weather lookup"),
|
|
200
|
+
temperature: numberField(current, "temperature_2m", "Weather lookup"),
|
|
201
|
+
apparentTemperature: numberField(
|
|
202
|
+
current,
|
|
203
|
+
"apparent_temperature",
|
|
204
|
+
"Weather lookup",
|
|
205
|
+
),
|
|
206
|
+
relativeHumidity: numberField(
|
|
207
|
+
current,
|
|
208
|
+
"relative_humidity_2m",
|
|
209
|
+
"Weather lookup",
|
|
210
|
+
),
|
|
211
|
+
precipitation: numberField(current, "precipitation", "Weather lookup"),
|
|
212
|
+
weatherCode,
|
|
213
|
+
condition: weatherCondition(weatherCode),
|
|
214
|
+
windSpeed: numberField(current, "wind_speed_10m", "Weather lookup"),
|
|
215
|
+
units: {
|
|
216
|
+
temperature: stringField(units, "temperature_2m", "Weather lookup"),
|
|
217
|
+
precipitation: stringField(units, "precipitation", "Weather lookup"),
|
|
218
|
+
windSpeed: stringField(units, "wind_speed_10m", "Weather lookup"),
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
async function fetchJson(url, signal, label) {
|
|
225
|
+
try {
|
|
226
|
+
const response = await fetch(url, {
|
|
227
|
+
signal,
|
|
228
|
+
headers: { accept: "application/json" },
|
|
229
|
+
});
|
|
230
|
+
if (!response.ok) {
|
|
231
|
+
throw new ToolError(label + " returned HTTP " + response.status);
|
|
232
|
+
}
|
|
233
|
+
return requiredRecord(await response.json(), label);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (signal.aborted || error instanceof ToolError) throw error;
|
|
236
|
+
throw new ToolError(label + " failed", { cause: error });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function requiredRecord(value, label) {
|
|
241
|
+
const record = asRecord(value);
|
|
242
|
+
if (record === undefined) {
|
|
243
|
+
throw new ToolError(label + " returned an unexpected response");
|
|
244
|
+
}
|
|
245
|
+
return record;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function asRecord(value) {
|
|
249
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
250
|
+
? value
|
|
251
|
+
: undefined;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function stringField(record, key, label) {
|
|
255
|
+
const value = record[key];
|
|
256
|
+
if (typeof value !== "string") {
|
|
257
|
+
throw new ToolError(label + " returned an unexpected response");
|
|
258
|
+
}
|
|
259
|
+
return value;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function numberField(record, key, label) {
|
|
263
|
+
const value = record[key];
|
|
264
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
265
|
+
throw new ToolError(label + " returned an unexpected response");
|
|
266
|
+
}
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function optionalString(value) {
|
|
271
|
+
return typeof value === "string" ? value : "";
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function weatherCondition(code) {
|
|
275
|
+
if (code === 0) return "clear sky";
|
|
276
|
+
if (code <= 3) return "partly cloudy";
|
|
277
|
+
if (code === 45 || code === 48) return "fog";
|
|
278
|
+
if (code <= 57) return "drizzle";
|
|
279
|
+
if (code <= 67) return "rain";
|
|
280
|
+
if (code <= 77) return "snow";
|
|
281
|
+
if (code <= 82) return "rain showers";
|
|
282
|
+
if (code <= 86) return "snow showers";
|
|
283
|
+
if (code >= 95) return "thunderstorm";
|
|
284
|
+
return "unknown";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=source-template.js.map
|