@claudetools/tools 0.5.2 → 0.7.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.
@@ -4,12 +4,35 @@
4
4
  export declare function handleGenerateApi(args: any): Promise<{
5
5
  error: string;
6
6
  details: string[] | undefined;
7
- message?: undefined;
8
7
  supported?: undefined;
9
8
  success?: undefined;
10
9
  files?: undefined;
11
10
  metadata?: undefined;
12
11
  tokenSavings?: undefined;
12
+ message?: undefined;
13
+ } | {
14
+ error: string;
15
+ supported: string[];
16
+ details?: undefined;
17
+ success?: undefined;
18
+ files?: undefined;
19
+ metadata?: undefined;
20
+ tokenSavings?: undefined;
21
+ message?: undefined;
22
+ } | {
23
+ success: boolean;
24
+ files: Record<string, string>;
25
+ metadata: import("../codedna/types.js").GenerationMetadata;
26
+ tokenSavings: {
27
+ traditional: number;
28
+ codedna: number;
29
+ saved: number;
30
+ percentSaved: string;
31
+ };
32
+ error?: undefined;
33
+ details?: undefined;
34
+ supported?: undefined;
35
+ message?: undefined;
13
36
  } | {
14
37
  error: string;
15
38
  message: string;
@@ -19,15 +42,28 @@ export declare function handleGenerateApi(args: any): Promise<{
19
42
  files?: undefined;
20
43
  metadata?: undefined;
21
44
  tokenSavings?: undefined;
45
+ }>;
46
+ /**
47
+ * Handle codedna_generate_frontend tool call
48
+ */
49
+ export declare function handleGenerateFrontend(args: any): Promise<{
50
+ error: string;
51
+ details: string[] | undefined;
52
+ supported?: undefined;
53
+ success?: undefined;
54
+ files?: undefined;
55
+ metadata?: undefined;
56
+ tokenSavings?: undefined;
57
+ message?: undefined;
22
58
  } | {
23
59
  error: string;
24
60
  supported: string[];
25
61
  details?: undefined;
26
- message?: undefined;
27
62
  success?: undefined;
28
63
  files?: undefined;
29
64
  metadata?: undefined;
30
65
  tokenSavings?: undefined;
66
+ message?: undefined;
31
67
  } | {
32
68
  success: boolean;
33
69
  files: Record<string, string>;
@@ -40,24 +76,17 @@ export declare function handleGenerateApi(args: any): Promise<{
40
76
  };
41
77
  error?: undefined;
42
78
  details?: undefined;
43
- message?: undefined;
44
79
  supported?: undefined;
45
- }>;
46
- /**
47
- * Handle codedna_generate_frontend tool call
48
- */
49
- export declare function handleGenerateFrontend(args: any): Promise<{
50
- error: string;
51
- details: string[] | undefined;
52
80
  message?: undefined;
53
- frameworks?: undefined;
54
- status?: undefined;
55
81
  } | {
56
82
  error: string;
57
83
  message: string;
58
- frameworks: string[];
59
- status: string;
60
84
  details?: undefined;
85
+ supported?: undefined;
86
+ success?: undefined;
87
+ files?: undefined;
88
+ metadata?: undefined;
89
+ tokenSavings?: undefined;
61
90
  }>;
62
91
  /**
63
92
  * Handle codedna_generate_component tool call
@@ -65,17 +94,44 @@ export declare function handleGenerateFrontend(args: any): Promise<{
65
94
  export declare function handleGenerateComponent(args: any): Promise<{
66
95
  error: string;
67
96
  details: string[] | undefined;
97
+ supported?: undefined;
98
+ success?: undefined;
99
+ files?: undefined;
100
+ metadata?: undefined;
101
+ tokenSavings?: undefined;
102
+ message?: undefined;
103
+ } | {
104
+ error: string;
105
+ supported: string[];
106
+ details?: undefined;
107
+ success?: undefined;
108
+ files?: undefined;
109
+ metadata?: undefined;
110
+ tokenSavings?: undefined;
111
+ message?: undefined;
112
+ } | {
113
+ success: boolean;
114
+ files: Record<string, string>;
115
+ metadata: import("../codedna/types.js").GenerationMetadata;
116
+ tokenSavings: {
117
+ traditional: number;
118
+ codedna: number;
119
+ saved: number;
120
+ percentSaved: string;
121
+ };
122
+ error?: undefined;
123
+ details?: undefined;
124
+ supported?: undefined;
68
125
  message?: undefined;
69
- types?: undefined;
70
- frameworks?: undefined;
71
- status?: undefined;
72
126
  } | {
73
127
  error: string;
74
128
  message: string;
75
- types: string[];
76
- frameworks: string[];
77
- status: string;
78
129
  details?: undefined;
130
+ supported?: undefined;
131
+ success?: undefined;
132
+ files?: undefined;
133
+ metadata?: undefined;
134
+ tokenSavings?: undefined;
79
135
  }>;
80
136
  /**
81
137
  * Handle codedna_list_generators tool call
@@ -8,6 +8,11 @@
8
8
  import { validateSpec } from '../codedna/parser.js';
9
9
  import { TemplateRegistry } from '../codedna/registry.js';
10
10
  import { ExpressApiGenerator } from '../codedna/generators/express-api.js';
11
+ import { FastAPIGenerator } from '../codedna/generators/fastapi-api.js';
12
+ import { NestJSGenerator } from '../codedna/generators/nestjs-api.js';
13
+ import { ReactFrontendGenerator } from '../codedna/generators/react-frontend.js';
14
+ import { VueFrontendGenerator } from '../codedna/generators/vue-frontend.js';
15
+ import { UIComponentGenerator } from '../codedna/generators/ui-component.js';
11
16
  import { errorTracker } from '../helpers/error-tracking.js';
12
17
  import { analytics } from '../helpers/usage-analytics.js';
13
18
  // Singleton registry instance
@@ -33,16 +38,10 @@ export async function handleGenerateApi(args) {
33
38
  generator = new ExpressApiGenerator(registry);
34
39
  }
35
40
  else if (framework === 'fastapi') {
36
- return {
37
- error: 'FastAPI generator not yet implemented',
38
- message: 'Currently only Express is supported. Coming soon: FastAPI, NestJS',
39
- };
41
+ generator = new FastAPIGenerator(registry);
40
42
  }
41
43
  else if (framework === 'nestjs') {
42
- return {
43
- error: 'NestJS generator not yet implemented',
44
- message: 'Currently only Express is supported. Coming soon: FastAPI, NestJS',
45
- };
44
+ generator = new NestJSGenerator(registry);
46
45
  }
47
46
  else {
48
47
  return {
@@ -103,13 +102,58 @@ export async function handleGenerateFrontend(args) {
103
102
  details: validation.errors,
104
103
  };
105
104
  }
106
- // Frontend generators not yet implemented
107
- return {
108
- error: 'Frontend generators not yet implemented',
109
- message: 'Coming soon: Next.js, React, Vue frontend generation',
110
- frameworks: ['nextjs', 'react', 'vue'],
111
- status: 'planned',
112
- };
105
+ // Select generator based on framework
106
+ let generator;
107
+ if (framework === 'nextjs' || framework === 'react') {
108
+ generator = new ReactFrontendGenerator(registry);
109
+ }
110
+ else if (framework === 'vue') {
111
+ generator = new VueFrontendGenerator(registry);
112
+ }
113
+ else {
114
+ return {
115
+ error: `Unsupported framework: ${framework}`,
116
+ supported: ['nextjs', 'react', 'vue'],
117
+ };
118
+ }
119
+ try {
120
+ const startTime = Date.now();
121
+ // Generate code
122
+ const result = await generator.generate(validation.parsed, options);
123
+ const executionTime = Date.now() - startTime;
124
+ // Track successful generation
125
+ await analytics.trackGeneration({
126
+ operation: 'generate_frontend',
127
+ generator: `${framework}-frontend`,
128
+ framework,
129
+ entityName: validation.parsed.name,
130
+ fieldCount: validation.parsed.fields.length,
131
+ specLength: spec.length,
132
+ filesGenerated: result.metadata.filesGenerated,
133
+ linesOfCode: result.metadata.linesOfCode,
134
+ tokensSaved: result.metadata.estimatedTokensSaved,
135
+ options: options,
136
+ executionTimeMs: executionTime,
137
+ });
138
+ return {
139
+ success: true,
140
+ files: result.files,
141
+ metadata: result.metadata,
142
+ tokenSavings: {
143
+ traditional: result.metadata.linesOfCode * 25,
144
+ codedna: 150,
145
+ saved: result.metadata.estimatedTokensSaved,
146
+ percentSaved: ((result.metadata.estimatedTokensSaved / (result.metadata.linesOfCode * 25)) * 100).toFixed(1) + '%',
147
+ },
148
+ };
149
+ }
150
+ catch (error) {
151
+ await errorTracker.trackGenerationError(framework, spec, error instanceof Error ? error : new Error(String(error)));
152
+ return {
153
+ error: 'Code generation failed',
154
+ message: error instanceof Error ? error.message : String(error),
155
+ };
156
+ }
113
157
  }
114
158
  /**
115
159
  * Handle codedna_generate_component tool call
@@ -124,14 +168,59 @@ export async function handleGenerateComponent(args) {
124
168
  details: validation.errors,
125
169
  };
126
170
  }
127
- // Component generators not yet implemented
128
- return {
129
- error: 'Component generators not yet implemented',
130
- message: 'Coming soon: Form, Table, Card, Modal components',
131
- types: ['form', 'table', 'card', 'modal'],
132
- frameworks: ['react', 'vue', 'svelte'],
133
- status: 'planned',
134
- };
171
+ // Validate component type
172
+ const validTypes = ['form', 'table', 'card', 'modal'];
173
+ if (!validTypes.includes(type)) {
174
+ return {
175
+ error: `Invalid component type: ${type}`,
176
+ supported: validTypes,
177
+ };
178
+ }
179
+ // Validate framework
180
+ const validFrameworks = ['react', 'vue', 'svelte'];
181
+ if (!validFrameworks.includes(framework)) {
182
+ return {
183
+ error: `Invalid framework: ${framework}`,
184
+ supported: validFrameworks,
185
+ };
186
+ }
187
+ try {
188
+ const startTime = Date.now();
189
+ const generator = new UIComponentGenerator(registry, type, framework);
190
+ const result = await generator.generate(validation.parsed, options);
191
+ const executionTime = Date.now() - startTime;
192
+ await analytics.trackGeneration({
193
+ operation: 'generate_component',
194
+ generator: `${framework}-${type}`,
195
+ framework,
196
+ entityName: validation.parsed.name,
197
+ fieldCount: validation.parsed.fields.length,
198
+ specLength: spec.length,
199
+ filesGenerated: result.metadata.filesGenerated,
200
+ linesOfCode: result.metadata.linesOfCode,
201
+ tokensSaved: result.metadata.estimatedTokensSaved,
202
+ options: options,
203
+ executionTimeMs: executionTime,
204
+ });
205
+ return {
206
+ success: true,
207
+ files: result.files,
208
+ metadata: result.metadata,
209
+ tokenSavings: {
210
+ traditional: result.metadata.linesOfCode * 25,
211
+ codedna: 100,
212
+ saved: result.metadata.estimatedTokensSaved,
213
+ percentSaved: ((result.metadata.estimatedTokensSaved / (result.metadata.linesOfCode * 25)) * 100).toFixed(1) + '%',
214
+ },
215
+ };
216
+ }
217
+ catch (error) {
218
+ await errorTracker.trackGenerationError(`${framework}-${type}`, spec, error instanceof Error ? error : new Error(String(error)));
219
+ return {
220
+ error: 'Component generation failed',
221
+ message: error instanceof Error ? error.message : String(error),
222
+ };
223
+ }
135
224
  }
136
225
  /**
137
226
  * Handle codedna_list_generators tool call
@@ -4,7 +4,8 @@
4
4
  import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
5
5
  import { mcpLogger } from '../logger.js';
6
6
  import { getDefaultProjectId, DEFAULT_USER_ID, lastContextUsed, setLastContextUsed, API_BASE_URL } from '../helpers/config.js';
7
- import { EXPERT_WORKERS, matchTaskToWorker } from '../helpers/workers.js';
7
+ import { EXPERT_WORKERS, matchTaskToWorker, buildWorkerPrompt } from '../helpers/workers.js';
8
+ import { validateTaskDescription } from '../templates/orchestrator-prompt.js';
8
9
  import { searchMemory, addMemory, storeFact, getContext, getSummary, getEntities, injectContext, apiRequest, listCachedDocs, getCachedDocs, cacheDocs } from '../helpers/api-client.js';
9
10
  import { queryDependencies, analyzeImpact } from '../helpers/dependencies.js';
10
11
  import { checkPatterns } from '../helpers/patterns.js';
@@ -432,8 +433,20 @@ export function registerToolHandlers(server) {
432
433
  });
433
434
  const epic = epicResult.data;
434
435
  const createdTasks = [];
436
+ // Track description validation warnings
437
+ const descriptionWarnings = [];
435
438
  // Create each task under the epic with worker assignment
436
439
  for (const taskDef of tasks) {
440
+ // Validate task description doesn't contain code (orchestrators should delegate, not implement)
441
+ if (taskDef.description) {
442
+ const validation = validateTaskDescription(taskDef.description);
443
+ if (!validation.valid) {
444
+ descriptionWarnings.push({
445
+ task: taskDef.title,
446
+ warnings: validation.warnings,
447
+ });
448
+ }
449
+ }
437
450
  // Match task to expert worker
438
451
  const worker = matchTaskToWorker({
439
452
  title: taskDef.title,
@@ -541,21 +554,60 @@ export function registerToolHandlers(server) {
541
554
  const worker = EXPERT_WORKERS[workerId];
542
555
  output += `- **${worker.name}**: ${items.length} task(s)\n`;
543
556
  }
557
+ // Show warnings if task descriptions contained code (orchestrator anti-pattern)
558
+ if (descriptionWarnings.length > 0) {
559
+ output += `\n## ⚠️ Task Description Warnings\n\n`;
560
+ output += `**Best Practice:** Task descriptions should define WHAT and WHY, not HOW.\n`;
561
+ output += `Orchestrators should delegate implementation details to worker agents.\n\n`;
562
+ for (const warning of descriptionWarnings) {
563
+ output += `**${warning.task}:**\n`;
564
+ for (const w of warning.warnings) {
565
+ output += ` - ${w}\n`;
566
+ }
567
+ }
568
+ output += `\n**Tip:** For entities, use DSL format: "User(email:string:unique, password:string:hashed)"\n`;
569
+ output += `Workers will use CodeDNA to generate code automatically.\n`;
570
+ }
544
571
  // Auto-dispatch section with exact Task tool invocations
545
572
  output += `\n---\n\n`;
546
573
  output += `## Auto-Dispatch: Spawn Parallel Agents Now\n\n`;
547
574
  output += `**IMPORTANT:** Execute these Task tool calls in a SINGLE message to spawn parallel workers:\n\n`;
548
575
  output += `\`\`\`\n`;
549
576
  for (const dt of dispatchable) {
550
- // Build a concise but complete prompt for the agent
551
- const taskPrompt = [
552
- `Execute task ${dt.task.id}: ${dt.task.title}`,
553
- dt.task.description ? `\nDescription: ${dt.task.description}` : '',
554
- `\nEpic: ${epic.title}`,
555
- `\nGoal: ${goal}`,
556
- `\nWhen complete, call task_complete(task_id="${dt.task.id}", summary="...") with a summary of work done.`,
557
- ].filter(Boolean).join('');
558
- output += `Task(subagent_type="general-purpose", prompt="${taskPrompt.replace(/"/g, '\\"')}")\n`;
577
+ // Build a comprehensive prompt using 10/10 template with CodeDNA instructions
578
+ const workerPrompt = buildWorkerPrompt({
579
+ task: {
580
+ id: dt.task.id,
581
+ title: dt.task.title,
582
+ description: dt.task.description,
583
+ acceptance_criteria: parseJsonArray(dt.task.acceptance_criteria),
584
+ },
585
+ worker: dt.worker,
586
+ epicContext: {
587
+ title: epic.title,
588
+ description: goal,
589
+ },
590
+ }, 'standard'); // Use standard tier for dispatched tasks
591
+ // Escape the prompt for embedding in Task() call
592
+ // Use a simplified version for the dispatch call that references the full context
593
+ const dispatchPrompt = [
594
+ `# Task: ${dt.task.title}`,
595
+ `**Task ID:** ${dt.task.id}`,
596
+ `**Epic:** ${epic.title}`,
597
+ ``,
598
+ dt.task.description || '',
599
+ ``,
600
+ `## CodeDNA Priority`,
601
+ `If this task involves CRUD/API operations, use codedna_generate_api FIRST.`,
602
+ `Look for Entity DSL in description (e.g., "User(email:string:unique)").`,
603
+ ``,
604
+ `## Protocol`,
605
+ `1. Call task_start(task_id="${dt.task.id}")`,
606
+ `2. Use memory_search and codebase_find before writing code`,
607
+ `3. Implement requirements`,
608
+ `4. Call task_complete(task_id="${dt.task.id}", summary="...")`,
609
+ ].join('\n');
610
+ output += `Task(subagent_type="general-purpose", prompt="${dispatchPrompt.replace(/"/g, '\\"').replace(/\n/g, '\\n')}")\n`;
559
611
  }
560
612
  output += `\`\`\`\n\n`;
561
613
  output += `**Note:** All ${dispatchable.length} tasks are ready for parallel execution. `;
@@ -1,3 +1,4 @@
1
+ import { type WorkerPromptParams, type TaskContext, type EpicContext, type AttachedContext, type SiblingTask } from '../templates/worker-prompt.js';
1
2
  export interface ExpertWorker {
2
3
  id: string;
3
4
  name: string;
@@ -6,9 +7,19 @@ export interface ExpertWorker {
6
7
  capabilities: string[];
7
8
  promptTemplate: string;
8
9
  }
10
+ export type { WorkerPromptParams, TaskContext, EpicContext, AttachedContext, SiblingTask };
9
11
  export declare const EXPERT_WORKERS: Record<string, ExpertWorker>;
10
12
  /**
11
- * Build a structured worker prompt that includes task context, protocol, error handling
13
+ * Build a structured worker prompt using the 10/10 AI System Prompt Architecture
14
+ *
15
+ * This function uses the new template system that includes:
16
+ * - XML semantic boundaries for machine-parseable structure
17
+ * - CodeDNA integration instructions (95-99% token savings for CRUD)
18
+ * - Tool usage priorities (memory_search, codebase_find before writing)
19
+ * - Tier-based complexity (minimal/standard/professional)
20
+ *
21
+ * @param params - Task, worker, and context information
22
+ * @param tier - Prompt complexity tier (default: 'standard')
12
23
  */
13
24
  export declare function buildWorkerPrompt(params: {
14
25
  task: {
@@ -31,6 +42,32 @@ export declare function buildWorkerPrompt(params: {
31
42
  title: string;
32
43
  status: string;
33
44
  }>;
45
+ }, tier?: 'minimal' | 'standard' | 'professional'): string;
46
+ /**
47
+ * Legacy buildWorkerPrompt for backwards compatibility
48
+ * @deprecated Use buildWorkerPrompt with tier parameter instead
49
+ */
50
+ export declare function buildWorkerPromptLegacy(params: {
51
+ task: {
52
+ id: string;
53
+ title: string;
54
+ description?: string;
55
+ acceptance_criteria?: string | string[];
56
+ };
57
+ worker: ExpertWorker;
58
+ epicContext?: {
59
+ title: string;
60
+ description?: string;
61
+ };
62
+ attachedContext?: Array<{
63
+ type: string;
64
+ content: string;
65
+ source?: string;
66
+ }>;
67
+ siblingTasks?: Array<{
68
+ title: string;
69
+ status: string;
70
+ }>;
34
71
  }): string;
35
72
  /**
36
73
  * Match a task to the best expert worker based on domain patterns
@@ -1,6 +1,11 @@
1
1
  // =============================================================================
2
2
  // Expert Worker Definitions (Orchestration System)
3
3
  // =============================================================================
4
+ //
5
+ // Updated with 10/10 AI System Prompt Architecture and CodeDNA integration.
6
+ // Workers now know to use CodeDNA generators before writing boilerplate code.
7
+ //
8
+ import { buildWorkerPromptWithCodeDNA, } from '../templates/worker-prompt.js';
4
9
  export const EXPERT_WORKERS = {
5
10
  'schema-expert': {
6
11
  id: 'schema-expert',
@@ -14,7 +19,10 @@ export const EXPERT_WORKERS = {
14
19
  - Index optimisation
15
20
  - Data modelling decisions
16
21
 
17
- Focus only on schema-related changes. Do not modify application code outside your domain.
22
+ CODEDNA: If task includes Entity DSL (e.g., "User(email:string:unique)"),
23
+ the API layer will be generated automatically. Focus only on SQL schema.
24
+
25
+ Focus only on schema-related changes. Do not modify application code.
18
26
  When complete, provide a concise summary of changes made.`,
19
27
  },
20
28
  'api-expert': {
@@ -28,7 +36,12 @@ When complete, provide a concise summary of changes made.`,
28
36
  - Request validation and parsing
29
37
  - Response formatting
30
38
  - Error handling for endpoints
31
- - API documentation
39
+
40
+ CODEDNA PRIORITY: Before writing CRUD code manually, check if CodeDNA can generate it:
41
+ - Look for Entity DSL in task (e.g., "User(email:string:unique, password:string:hashed)")
42
+ - Call codedna_generate_api(spec, framework="express", options={...})
43
+ - This generates models, controllers, routes, validation in seconds
44
+ - Only write manually for complex business logic that can't be generated
32
45
 
33
46
  Focus only on API-related changes. Do not modify schema or extraction code.
34
47
  When complete, provide a concise summary of endpoints created or modified.`,
@@ -45,6 +58,9 @@ When complete, provide a concise summary of endpoints created or modified.`,
45
58
  - MCP resources and prompts
46
59
  - Server configuration
47
60
 
61
+ TOOLS: Use memory_search to find existing MCP patterns before implementing.
62
+ TOOLS: Use codebase_find to locate similar tool definitions.
63
+
48
64
  Focus only on MCP-related changes. Follow MCP SDK patterns exactly.
49
65
  When complete, provide a concise summary of tools added or modified.`,
50
66
  },
@@ -60,6 +76,9 @@ When complete, provide a concise summary of tools added or modified.`,
60
76
  - Fact and relationship extraction
61
77
  - Multi-language support
62
78
 
79
+ TOOLS: Use codebase_context to understand file dependencies before changes.
80
+ TOOLS: Use memory_search for existing extraction patterns.
81
+
63
82
  Focus only on extraction logic. Follow the BaseExtractor pattern.
64
83
  When complete, provide a concise summary of extraction capabilities added.`,
65
84
  },
@@ -75,6 +94,9 @@ When complete, provide a concise summary of extraction capabilities added.`,
75
94
  - Import/export wiring
76
95
  - Dependency management
77
96
 
97
+ TOOLS: Use codebase_map to understand project structure before changes.
98
+ TOOLS: Use codebase_context to see file dependencies.
99
+
78
100
  Focus on integration without modifying core implementation logic.
79
101
  When complete, provide a concise summary of integrations configured.`,
80
102
  },
@@ -84,7 +106,12 @@ When complete, provide a concise summary of integrations configured.`,
84
106
  description: 'Handles tasks that do not fit other expert domains',
85
107
  domains: ['**/*'],
86
108
  capabilities: ['general-development', 'refactoring', 'documentation', 'testing'],
87
- promptTemplate: `You are a general purpose development expert. Handle this task with care:
109
+ promptTemplate: `You are a general purpose development expert.
110
+
111
+ CODEDNA: For CRUD/API tasks, use codedna_generate_api before writing code manually.
112
+ TOOLS: Use memory_search and codebase_find before implementing from scratch.
113
+
114
+ Handle this task with care:
88
115
  - Follow existing code patterns
89
116
  - Make minimal necessary changes
90
117
  - Document your reasoning
@@ -93,9 +120,49 @@ When complete, provide a concise summary of work done.`,
93
120
  },
94
121
  };
95
122
  /**
96
- * Build a structured worker prompt that includes task context, protocol, error handling
123
+ * Build a structured worker prompt using the 10/10 AI System Prompt Architecture
124
+ *
125
+ * This function uses the new template system that includes:
126
+ * - XML semantic boundaries for machine-parseable structure
127
+ * - CodeDNA integration instructions (95-99% token savings for CRUD)
128
+ * - Tool usage priorities (memory_search, codebase_find before writing)
129
+ * - Tier-based complexity (minimal/standard/professional)
130
+ *
131
+ * @param params - Task, worker, and context information
132
+ * @param tier - Prompt complexity tier (default: 'standard')
133
+ */
134
+ export function buildWorkerPrompt(params, tier = 'standard') {
135
+ const { task, worker, epicContext, attachedContext, siblingTasks } = params;
136
+ // Normalize acceptance_criteria to array
137
+ const criteria = Array.isArray(task.acceptance_criteria)
138
+ ? task.acceptance_criteria
139
+ : (task.acceptance_criteria ? [task.acceptance_criteria] : []);
140
+ // Normalize attached context to proper type
141
+ const normalizedContext = (attachedContext || []).map(ctx => ({
142
+ type: ctx.type,
143
+ content: ctx.content,
144
+ source: ctx.source,
145
+ }));
146
+ // Use the new 10/10 template system
147
+ return buildWorkerPromptWithCodeDNA({
148
+ task: {
149
+ id: task.id,
150
+ title: task.title,
151
+ description: task.description,
152
+ acceptance_criteria: criteria,
153
+ },
154
+ worker,
155
+ epicContext,
156
+ attachedContext: normalizedContext,
157
+ siblingTasks,
158
+ tier,
159
+ });
160
+ }
161
+ /**
162
+ * Legacy buildWorkerPrompt for backwards compatibility
163
+ * @deprecated Use buildWorkerPrompt with tier parameter instead
97
164
  */
98
- export function buildWorkerPrompt(params) {
165
+ export function buildWorkerPromptLegacy(params) {
99
166
  const { task, worker, epicContext, attachedContext, siblingTasks } = params;
100
167
  let prompt = '';
101
168
  // Worker domain introduction
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Build orchestrator system prompt
3
+ *
4
+ * Orchestrators:
5
+ * - Break down complex work into tasks
6
+ * - Delegate implementation to specialist workers
7
+ * - Coordinate parallel execution
8
+ * - Track progress and handle failures
9
+ *
10
+ * Orchestrators do NOT:
11
+ * - Write implementation code
12
+ * - Provide detailed technical solutions in task descriptions
13
+ * - Duplicate work that workers should do
14
+ */
15
+ export declare function buildOrchestratorPrompt(params: {
16
+ epicTitle?: string;
17
+ epicGoal?: string;
18
+ availableWorkers?: string[];
19
+ }): string;
20
+ /**
21
+ * Get CodeDNA usage hint for task descriptions
22
+ */
23
+ export declare function getCodeDNAHint(entitySpec: string): string;
24
+ /**
25
+ * Validate task description doesn't contain code
26
+ */
27
+ export declare function validateTaskDescription(description: string): {
28
+ valid: boolean;
29
+ warnings: string[];
30
+ };