@skillsmith/cli 0.2.2 → 0.2.4

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 (35) hide show
  1. package/README.md +147 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/commands/author.d.ts +44 -1
  4. package/dist/src/commands/author.d.ts.map +1 -1
  5. package/dist/src/commands/author.js +524 -4
  6. package/dist/src/commands/author.js.map +1 -1
  7. package/dist/src/commands/index.d.ts +1 -1
  8. package/dist/src/commands/index.d.ts.map +1 -1
  9. package/dist/src/commands/index.js +1 -1
  10. package/dist/src/commands/index.js.map +1 -1
  11. package/dist/src/index.js +16 -6
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/src/templates/index.d.ts +2 -0
  14. package/dist/src/templates/index.d.ts.map +1 -1
  15. package/dist/src/templates/index.js +2 -0
  16. package/dist/src/templates/index.js.map +1 -1
  17. package/dist/src/templates/mcp-server.template.d.ts +97 -0
  18. package/dist/src/templates/mcp-server.template.d.ts.map +1 -0
  19. package/dist/src/templates/mcp-server.template.js +529 -0
  20. package/dist/src/templates/mcp-server.template.js.map +1 -0
  21. package/dist/src/templates/subagent.md.template.d.ts +38 -0
  22. package/dist/src/templates/subagent.md.template.d.ts.map +1 -0
  23. package/dist/src/templates/subagent.md.template.js +128 -0
  24. package/dist/src/templates/subagent.md.template.js.map +1 -0
  25. package/dist/src/utils/tool-analyzer.d.ts +54 -0
  26. package/dist/src/utils/tool-analyzer.d.ts.map +1 -0
  27. package/dist/src/utils/tool-analyzer.js +156 -0
  28. package/dist/src/utils/tool-analyzer.js.map +1 -0
  29. package/dist/tests/author.test.js +419 -0
  30. package/dist/tests/author.test.js.map +1 -1
  31. package/dist/tests/mcp-server-template.test.d.ts +7 -0
  32. package/dist/tests/mcp-server-template.test.d.ts.map +1 -0
  33. package/dist/tests/mcp-server-template.test.js +351 -0
  34. package/dist/tests/mcp-server-template.test.js.map +1 -0
  35. package/package.json +1 -1
@@ -0,0 +1,529 @@
1
+ /**
2
+ * SMI-1433: MCP Server Template
3
+ *
4
+ * Templates for scaffolding TypeScript MCP servers with stdio transport.
5
+ * Generated servers are npx-ready and follow @modelcontextprotocol/sdk patterns.
6
+ *
7
+ * @example Basic Usage
8
+ * ```typescript
9
+ * import { renderMcpServerTemplates } from './mcp-server.template.js'
10
+ *
11
+ * const files = renderMcpServerTemplates({
12
+ * name: 'my-mcp-server',
13
+ * description: 'Does cool things',
14
+ * author: 'developer',
15
+ * tools: []
16
+ * })
17
+ *
18
+ * // files is a Map<string, string> of file paths to content
19
+ * // Keys: package.json, tsconfig.json, src/index.ts, src/server.ts,
20
+ * // src/tools/index.ts, src/tools/example.ts, README.md, .gitignore
21
+ * ```
22
+ *
23
+ * @example With Custom Tools
24
+ * ```typescript
25
+ * const files = renderMcpServerTemplates({
26
+ * name: 'slack-mcp',
27
+ * description: 'Slack integration MCP server',
28
+ * author: 'team',
29
+ * tools: [
30
+ * {
31
+ * name: 'send_message',
32
+ * description: 'Send a Slack message',
33
+ * parameters: [
34
+ * { name: 'channel', type: 'string', description: 'Channel ID', required: true },
35
+ * { name: 'text', type: 'string', description: 'Message text', required: true }
36
+ * ]
37
+ * }
38
+ * ]
39
+ * })
40
+ * ```
41
+ *
42
+ * @module mcp-server-template
43
+ */
44
+ /**
45
+ * Dependency version constants for easier maintenance
46
+ */
47
+ const VERSIONS = {
48
+ MCP_SDK: '^1.0.0',
49
+ TYPES_NODE: '^20.0.0',
50
+ TSX: '^4.0.0',
51
+ TYPESCRIPT: '^5.0.0',
52
+ NODE_ENGINE: '>=18.0.0',
53
+ };
54
+ /**
55
+ * package.json template for MCP server
56
+ */
57
+ export const PACKAGE_JSON_TEMPLATE = `{
58
+ "name": "{{name}}",
59
+ "version": "0.1.0",
60
+ "description": "{{description}}",
61
+ "type": "module",
62
+ "main": "dist/index.js",
63
+ "bin": {
64
+ "{{name}}": "./dist/index.js"
65
+ },
66
+ "scripts": {
67
+ "build": "tsc",
68
+ "start": "node dist/index.js",
69
+ "dev": "tsx src/index.ts",
70
+ "watch": "tsc --watch",
71
+ "prepublishOnly": "npm run build"
72
+ },
73
+ "keywords": [
74
+ "mcp",
75
+ "mcp-server",
76
+ "claude",
77
+ "ai"
78
+ ],
79
+ "author": "{{author}}",
80
+ "license": "MIT",
81
+ "dependencies": {
82
+ "@modelcontextprotocol/sdk": "${VERSIONS.MCP_SDK}"
83
+ },
84
+ "devDependencies": {
85
+ "@types/node": "${VERSIONS.TYPES_NODE}",
86
+ "tsx": "${VERSIONS.TSX}",
87
+ "typescript": "${VERSIONS.TYPESCRIPT}"
88
+ },
89
+ "engines": {
90
+ "node": "${VERSIONS.NODE_ENGINE}"
91
+ }
92
+ }
93
+ `;
94
+ /**
95
+ * tsconfig.json template for MCP server
96
+ */
97
+ export const TSCONFIG_JSON_TEMPLATE = `{
98
+ "compilerOptions": {
99
+ "target": "ES2022",
100
+ "module": "NodeNext",
101
+ "moduleResolution": "NodeNext",
102
+ "lib": ["ES2022"],
103
+ "outDir": "./dist",
104
+ "rootDir": "./src",
105
+ "strict": true,
106
+ "esModuleInterop": true,
107
+ "skipLibCheck": true,
108
+ "forceConsistentCasingInFileNames": true,
109
+ "declaration": true,
110
+ "declarationMap": true,
111
+ "sourceMap": true
112
+ },
113
+ "include": ["src/**/*"],
114
+ "exclude": ["node_modules", "dist"]
115
+ }
116
+ `;
117
+ /**
118
+ * Main entry point (src/index.ts) template
119
+ */
120
+ export const INDEX_TS_TEMPLATE = `#!/usr/bin/env node
121
+ /**
122
+ * {{name}} - MCP Server
123
+ *
124
+ * {{description}}
125
+ */
126
+
127
+ import { createServer, createTransport } from './server.js'
128
+
129
+ async function main(): Promise<void> {
130
+ const server = createServer()
131
+ const transport = createTransport()
132
+ await server.connect(transport)
133
+ }
134
+
135
+ main().catch((error) => {
136
+ console.error('Server error:', error)
137
+ process.exit(1)
138
+ })
139
+ `;
140
+ /**
141
+ * Server setup (src/server.ts) template
142
+ */
143
+ export const SERVER_TS_TEMPLATE = `/**
144
+ * MCP Server Configuration
145
+ *
146
+ * Sets up the MCP server with tool handlers.
147
+ */
148
+
149
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js'
150
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
151
+ import {
152
+ CallToolRequestSchema,
153
+ ListToolsRequestSchema,
154
+ } from '@modelcontextprotocol/sdk/types.js'
155
+
156
+ import { tools, handleToolCall } from './tools/index.js'
157
+
158
+ /**
159
+ * Create and configure the MCP server
160
+ */
161
+ export function createServer(): Server {
162
+ const server = new Server(
163
+ {
164
+ name: '{{name}}',
165
+ version: '0.1.0',
166
+ },
167
+ {
168
+ capabilities: {
169
+ tools: {},
170
+ },
171
+ }
172
+ )
173
+
174
+ // Register tool listing handler
175
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
176
+ return { tools }
177
+ })
178
+
179
+ // Register tool execution handler
180
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
181
+ const { name, arguments: args } = request.params
182
+
183
+ try {
184
+ const result = await handleToolCall(name, args || {})
185
+ return {
186
+ content: [
187
+ {
188
+ type: 'text',
189
+ text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
190
+ },
191
+ ],
192
+ }
193
+ } catch (error) {
194
+ const message = error instanceof Error ? error.message : 'Unknown error'
195
+ return {
196
+ content: [{ type: 'text', text: \`Error: \${message}\` }],
197
+ isError: true,
198
+ }
199
+ }
200
+ })
201
+
202
+ return server
203
+ }
204
+
205
+ /**
206
+ * Create a stdio transport for the server
207
+ */
208
+ export function createTransport(): StdioServerTransport {
209
+ return new StdioServerTransport()
210
+ }
211
+ `;
212
+ /**
213
+ * Tools index (src/tools/index.ts) template
214
+ */
215
+ export const TOOLS_INDEX_TS_TEMPLATE = `/**
216
+ * Tool Definitions and Handlers
217
+ *
218
+ * Register your MCP tools here.
219
+ */
220
+
221
+ import { Tool } from '@modelcontextprotocol/sdk/types.js'
222
+ {{toolImports}}
223
+
224
+ /**
225
+ * Tool definitions exposed by this MCP server
226
+ */
227
+ export const tools: Tool[] = [
228
+ {{toolDefinitions}}
229
+ ]
230
+
231
+ /**
232
+ * Route tool calls to appropriate handlers
233
+ */
234
+ export async function handleToolCall(
235
+ name: string,
236
+ args: Record<string, unknown>
237
+ ): Promise<unknown> {
238
+ switch (name) {
239
+ {{toolCases}}
240
+ default:
241
+ throw new Error(\`Unknown tool: \${name}\`)
242
+ }
243
+ }
244
+ `;
245
+ /**
246
+ * Example tool implementation template
247
+ */
248
+ export const EXAMPLE_TOOL_TS_TEMPLATE = `/**
249
+ * Example Tool Implementation
250
+ *
251
+ * This is a sample tool to demonstrate the pattern.
252
+ * Replace with your actual tool logic.
253
+ */
254
+
255
+ import { Tool } from '@modelcontextprotocol/sdk/types.js'
256
+
257
+ export const exampleToolDefinition: Tool = {
258
+ name: 'example',
259
+ description: 'An example tool that echoes input',
260
+ inputSchema: {
261
+ type: 'object',
262
+ properties: {
263
+ message: {
264
+ type: 'string',
265
+ description: 'Message to echo back',
266
+ },
267
+ },
268
+ required: ['message'],
269
+ },
270
+ }
271
+
272
+ export interface ExampleToolArgs {
273
+ message: string
274
+ }
275
+
276
+ export async function handleExampleTool(args: ExampleToolArgs): Promise<string> {
277
+ return \`Echo: \${args.message}\`
278
+ }
279
+ `;
280
+ /**
281
+ * README.md template for MCP server
282
+ */
283
+ export const MCP_README_TEMPLATE = `# {{name}}
284
+
285
+ {{description}}
286
+
287
+ ## Installation
288
+
289
+ \`\`\`bash
290
+ npm install -g {{name}}
291
+ \`\`\`
292
+
293
+ Or use directly with npx:
294
+
295
+ \`\`\`bash
296
+ npx {{name}}
297
+ \`\`\`
298
+
299
+ ## Configuration
300
+
301
+ Add to your Claude configuration (\`~/.claude/settings.json\`):
302
+
303
+ \`\`\`json
304
+ {
305
+ "mcpServers": {
306
+ "{{name}}": {
307
+ "command": "npx",
308
+ "args": ["-y", "{{name}}"]
309
+ }
310
+ }
311
+ }
312
+ \`\`\`
313
+
314
+ ## Available Tools
315
+
316
+ {{toolDocs}}
317
+
318
+ ## Development
319
+
320
+ \`\`\`bash
321
+ # Install dependencies
322
+ npm install
323
+
324
+ # Run in development mode
325
+ npm run dev
326
+
327
+ # Build for production
328
+ npm run build
329
+
330
+ # Run production build
331
+ npm start
332
+ \`\`\`
333
+
334
+ ## License
335
+
336
+ MIT
337
+ `;
338
+ /**
339
+ * .gitignore template for MCP server
340
+ */
341
+ export const MCP_GITIGNORE_TEMPLATE = `# Dependencies
342
+ node_modules/
343
+
344
+ # Build output
345
+ dist/
346
+
347
+ # Environment
348
+ .env
349
+ .env.local
350
+ .env.*.local
351
+
352
+ # IDE
353
+ .idea/
354
+ .vscode/
355
+ *.swp
356
+ *.swo
357
+
358
+ # OS
359
+ .DS_Store
360
+ Thumbs.db
361
+
362
+ # Logs
363
+ *.log
364
+ npm-debug.log*
365
+
366
+ # Test coverage
367
+ coverage/
368
+ `;
369
+ /**
370
+ * Escape single quotes in strings for safe template interpolation
371
+ */
372
+ function escapeQuotes(str) {
373
+ return str.replace(/'/g, "\\'");
374
+ }
375
+ /**
376
+ * Generate tool definition code for a single tool
377
+ */
378
+ function generateToolDefinition(tool, indent = ' ') {
379
+ const properties = [];
380
+ const required = [];
381
+ for (const param of tool.parameters || []) {
382
+ properties.push(`${indent} ${param.name}: {
383
+ ${indent} type: '${param.type}',
384
+ ${indent} description: '${escapeQuotes(param.description)}',
385
+ ${indent} },`);
386
+ if (param.required) {
387
+ required.push(`'${param.name}'`);
388
+ }
389
+ }
390
+ const propertiesStr = properties.length > 0 ? properties.join('\n') : '';
391
+ const requiredStr = required.length > 0 ? `\n${indent} required: [${required.join(', ')}],` : '';
392
+ return `${indent}{
393
+ ${indent} name: '${escapeQuotes(tool.name)}',
394
+ ${indent} description: '${escapeQuotes(tool.description)}',
395
+ ${indent} inputSchema: {
396
+ ${indent} type: 'object',
397
+ ${indent} properties: {
398
+ ${propertiesStr}
399
+ ${indent} },${requiredStr}
400
+ ${indent} },
401
+ ${indent}},`;
402
+ }
403
+ /**
404
+ * Generate tool handler case for switch statement
405
+ */
406
+ function generateToolCase(tool) {
407
+ const handlerName = `handle${tool.name.charAt(0).toUpperCase()}${tool.name.slice(1).replace(/-/g, '')}Tool`;
408
+ const argsType = `${tool.name.charAt(0).toUpperCase()}${tool.name.slice(1).replace(/-/g, '')}ToolArgs`;
409
+ return ` case '${tool.name}':
410
+ return ${handlerName}(args as unknown as ${argsType})`;
411
+ }
412
+ /**
413
+ * Generate tool import statement
414
+ */
415
+ function generateToolImport(tool) {
416
+ const baseName = tool.name.charAt(0).toUpperCase() + tool.name.slice(1).replace(/-/g, '');
417
+ return `import { handle${baseName}Tool, type ${baseName}ToolArgs } from './${tool.name}.js'`;
418
+ }
419
+ /**
420
+ * Generate a stub implementation file for a custom tool
421
+ */
422
+ function generateToolImplementation(tool) {
423
+ const baseName = tool.name.charAt(0).toUpperCase() + tool.name.slice(1).replace(/-/g, '');
424
+ const params = tool.parameters || [];
425
+ // Generate TypeScript interface properties
426
+ const interfaceProps = params
427
+ .map((p) => {
428
+ const tsType = p.type === 'array' ? 'unknown[]' : p.type === 'object' ? 'Record<string, unknown>' : p.type;
429
+ return ` ${p.name}${p.required ? '' : '?'}: ${tsType}`;
430
+ })
431
+ .join('\n');
432
+ // Generate implementation placeholder
433
+ const returnPlaceholder = params.length > 0
434
+ ? `\`${tool.name} called with: \${JSON.stringify({ ${params.map((p) => `${p.name}: args.${p.name}`).join(', ')} })}\``
435
+ : `'${tool.name} called'`;
436
+ return `/**
437
+ * ${baseName} Tool Implementation
438
+ *
439
+ * ${escapeQuotes(tool.description)}
440
+ * TODO: Implement your tool logic here.
441
+ */
442
+
443
+ export interface ${baseName}ToolArgs {
444
+ ${interfaceProps || ' // No parameters'}
445
+ }
446
+
447
+ export async function handle${baseName}Tool(args: ${baseName}ToolArgs): Promise<string> {
448
+ // TODO: Implement ${tool.name} logic
449
+ return ${returnPlaceholder}
450
+ }
451
+ `;
452
+ }
453
+ /**
454
+ * Generate tool documentation for README
455
+ */
456
+ function generateToolDocs(tools) {
457
+ if (tools.length === 0) {
458
+ return '- `example` - An example tool that echoes input';
459
+ }
460
+ return tools
461
+ .map((tool) => {
462
+ const params = tool.parameters?.map((p) => `\`${p.name}\``).join(', ') || 'none';
463
+ return `- \`${tool.name}\` - ${tool.description}\n - Parameters: ${params}`;
464
+ })
465
+ .join('\n');
466
+ }
467
+ /**
468
+ * Render MCP server templates
469
+ */
470
+ export function renderMcpServerTemplates(data) {
471
+ const files = new Map();
472
+ // Use example tool if no tools specified
473
+ const toolsToUse = data.tools.length > 0
474
+ ? data.tools
475
+ : [
476
+ {
477
+ name: 'example',
478
+ description: 'An example tool that echoes input',
479
+ parameters: [
480
+ {
481
+ name: 'message',
482
+ type: 'string',
483
+ description: 'Message to echo back',
484
+ required: true,
485
+ },
486
+ ],
487
+ },
488
+ ];
489
+ // Generate tool-specific code
490
+ const toolImports = toolsToUse.map(generateToolImport).join('\n');
491
+ const toolDefinitions = toolsToUse.map((t) => generateToolDefinition(t)).join('\n');
492
+ const toolCases = toolsToUse.map(generateToolCase).join('\n');
493
+ const toolDocs = generateToolDocs(data.tools);
494
+ // package.json
495
+ files.set('package.json', PACKAGE_JSON_TEMPLATE.replace(/\{\{name\}\}/g, data.name)
496
+ .replace(/\{\{description\}\}/g, data.description)
497
+ .replace(/\{\{author\}\}/g, data.author));
498
+ // tsconfig.json
499
+ files.set('tsconfig.json', TSCONFIG_JSON_TEMPLATE);
500
+ // src/index.ts
501
+ files.set('src/index.ts', INDEX_TS_TEMPLATE.replace(/\{\{name\}\}/g, data.name).replace(/\{\{description\}\}/g, data.description));
502
+ // src/server.ts
503
+ files.set('src/server.ts', SERVER_TS_TEMPLATE.replace(/\{\{name\}\}/g, data.name));
504
+ // src/tools/index.ts
505
+ files.set('src/tools/index.ts', TOOLS_INDEX_TS_TEMPLATE.replace(/\{\{toolImports\}\}/g, toolImports)
506
+ .replace(/\{\{toolDefinitions\}\}/g, toolDefinitions)
507
+ .replace(/\{\{toolCases\}\}/g, toolCases));
508
+ // Generate tool implementation files
509
+ if (data.tools.length > 0) {
510
+ // Generate stub implementations for custom tools
511
+ for (const tool of data.tools) {
512
+ files.set(`src/tools/${tool.name}.ts`, generateToolImplementation(tool));
513
+ }
514
+ // Include example.ts as reference
515
+ files.set('src/tools/example.ts', EXAMPLE_TOOL_TS_TEMPLATE);
516
+ }
517
+ else {
518
+ // No custom tools - just use example tool (already imported in index.ts)
519
+ files.set('src/tools/example.ts', EXAMPLE_TOOL_TS_TEMPLATE);
520
+ }
521
+ // README.md
522
+ files.set('README.md', MCP_README_TEMPLATE.replace(/\{\{name\}\}/g, data.name)
523
+ .replace(/\{\{description\}\}/g, data.description)
524
+ .replace(/\{\{toolDocs\}\}/g, toolDocs));
525
+ // .gitignore
526
+ files.set('.gitignore', MCP_GITIGNORE_TEMPLATE);
527
+ return files;
528
+ }
529
+ //# sourceMappingURL=mcp-server.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.template.js","sourceRoot":"","sources":["../../../src/templates/mcp-server.template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAsBH;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE,SAAS;IACrB,GAAG,EAAE,QAAQ;IACb,UAAU,EAAE,QAAQ;IACpB,WAAW,EAAE,UAAU;CACf,CAAA;AAEV;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;oCAyBD,QAAQ,CAAC,OAAO;;;sBAG9B,QAAQ,CAAC,UAAU;cAC3B,QAAQ,CAAC,GAAG;qBACL,QAAQ,CAAC,UAAU;;;eAGzB,QAAQ,CAAC,WAAW;;;CAGlC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;CAmBrC,C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AAO,CAAC,sBAAsB,EAAE,WAAW,CAAC;SACjE,OAAO,CAAC,0BAA0B,EAAE,eAAe,CAAC;SACpD,OAAO,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAC5C,CAAA;IAED,qCAAqC;IACrC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,iDAAiD;QACjD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,IAAI,KAAK,EAAE,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1E,CAAC;QACD,kCAAkC;QAClC,KAAK,CAAC,GAAG,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAA;IAC7D,CAAC;SAAM,CAAC;QACN,yEAAyE;QACzE,KAAK,CAAC,GAAG,CAAC,sBAAsB,EAAE,wBAAwB,CAAC,CAAA;IAC7D,CAAC;IAED,YAAY;IACZ,KAAK,CAAC,GAAG,CACP,WAAW,EACX,mBAAmB,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC;SACpD,OAAO,CAAC,sBAAsB,EAAE,IAAI,CAAC,WAAW,CAAC;SACjD,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAC1C,CAAA;IAED,aAAa;IACb,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAA;IAE/C,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * SMI-1389: Subagent Definition Template
3
+ *
4
+ * Templates for generating companion specialist agents that enable
5
+ * parallel skill execution with 37-97% token savings.
6
+ */
7
+ export interface SubagentTemplateData {
8
+ skillName: string;
9
+ description: string;
10
+ triggerPhrases: string[];
11
+ tools: string[];
12
+ model: 'sonnet' | 'opus' | 'haiku';
13
+ }
14
+ /**
15
+ * Main subagent definition template
16
+ * Generates ~/.claude/agents/[skill-name]-specialist.md
17
+ */
18
+ export declare const SUBAGENT_MD_TEMPLATE = "---\nname: {{skillName}}-specialist\ndescription: {{description}} Use when {{triggerPhrases}}.\nskills: {{skillName}}\ntools: {{tools}}\nmodel: {{model}}\n---\n\n## Operating Protocol\n\n1. Execute the {{skillName}} skill for the delegated task\n2. Process all intermediate results internally\n3. Return ONLY a structured summary to the orchestrator\n\n## Output Format\n\n- **Task:** [what was requested]\n- **Actions:** [what you did]\n- **Results:** [key outcomes, max 3-5 bullet points]\n- **Artifacts:** [file paths or outputs created]\n\nKeep response under 500 tokens unless explicitly requested otherwise.\n\n## Tool Usage Guidelines\n\n{{toolGuidelines}}\n\n## Error Handling\n\nIf the task cannot be completed:\n- Report specific blocking issue\n- Suggest alternative approaches\n- Do not retry indefinitely\n";
19
+ /**
20
+ * CLAUDE.md integration snippet template
21
+ * Users can copy this to their project's CLAUDE.md
22
+ */
23
+ export declare const CLAUDE_MD_SNIPPET_TEMPLATE = "\n### Subagent Delegation: {{skillName}}\n\nWhen tasks match {{skillName}} triggers, delegate to the {{skillName}}-specialist\nsubagent instead of executing directly. This provides context isolation and\n~37-97% token savings.\n\n**Trigger Patterns:**\n{{triggerPatterns}}\n\n**Delegation Example:**\n```\nTask(\"{{skillName}}-specialist\", \"{{exampleTask}}\", \"{{skillName}}-specialist\")\n```\n";
24
+ /**
25
+ * Render the subagent definition template
26
+ *
27
+ * @param data - Template data including skill name, description, tools, etc.
28
+ * @returns Rendered subagent markdown content
29
+ */
30
+ export declare function renderSubagentTemplate(data: SubagentTemplateData): string;
31
+ /**
32
+ * Render the CLAUDE.md integration snippet
33
+ *
34
+ * @param data - Template data
35
+ * @returns Rendered CLAUDE.md snippet
36
+ */
37
+ export declare function renderClaudeMdSnippet(data: SubagentTemplateData): string;
38
+ //# sourceMappingURL=subagent.md.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent.md.template.d.ts","sourceRoot":"","sources":["../../../src/templates/subagent.md.template.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;CACnC;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,wzBAiChC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,mZActC,CAAA;AAoCD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAazE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAYxE"}