@claudetools/tools 0.9.1 → 0.9.2
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/dist/cli.js +9 -1
- package/dist/codedna/__tests__/examples/mongoose-example.d.ts +6 -0
- package/dist/codedna/__tests__/examples/mongoose-example.js +163 -0
- package/dist/codedna/__tests__/fixtures/typeorm-production-test.d.ts +1 -0
- package/dist/codedna/__tests__/fixtures/typeorm-production-test.js +231 -0
- package/dist/codedna/__tests__/fixtures/typeorm-test.d.ts +1 -0
- package/dist/codedna/__tests__/fixtures/typeorm-test.js +124 -0
- package/dist/codedna/__tests__/laravel-output-review.d.ts +1 -0
- package/dist/codedna/__tests__/laravel-output-review.js +249 -0
- package/dist/codedna/__tests__/mongoose-output-test.d.ts +1 -0
- package/dist/codedna/__tests__/mongoose-output-test.js +178 -0
- package/dist/codedna/examples/radix-example.d.ts +2 -0
- package/dist/codedna/examples/radix-example.js +259 -0
- package/dist/codedna/index.d.ts +5 -3
- package/dist/codedna/index.js +6 -3
- package/dist/codedna/kappa-ast.d.ts +143 -5
- package/dist/codedna/kappa-drizzle-generator.js +8 -5
- package/dist/codedna/kappa-gofiber-generator.d.ts +65 -0
- package/dist/codedna/kappa-gofiber-generator.js +587 -0
- package/dist/codedna/kappa-laravel-generator.d.ts +68 -0
- package/dist/codedna/kappa-laravel-generator.js +741 -0
- package/dist/codedna/kappa-lexer.d.ts +44 -0
- package/dist/codedna/kappa-lexer.js +124 -0
- package/dist/codedna/kappa-mantine-generator.d.ts +65 -0
- package/dist/codedna/kappa-mantine-generator.js +518 -0
- package/dist/codedna/kappa-mongoose-generator.d.ts +44 -0
- package/dist/codedna/kappa-mongoose-generator.js +442 -0
- package/dist/codedna/kappa-parser.d.ts +43 -1
- package/dist/codedna/kappa-parser.js +601 -0
- package/dist/codedna/kappa-radix-generator.d.ts +61 -0
- package/dist/codedna/kappa-radix-generator.js +566 -0
- package/dist/codedna/kappa-typeorm-generator.d.ts +59 -0
- package/dist/codedna/kappa-typeorm-generator.js +723 -0
- package/dist/codedna/kappa-vitest-generator.d.ts +85 -0
- package/dist/codedna/kappa-vitest-generator.js +739 -0
- package/dist/codedna/parser.js +26 -1
- package/dist/codegen/cloud-client.d.ts +160 -0
- package/dist/codegen/cloud-client.js +195 -0
- package/dist/codegen/codegen-tool.d.ts +35 -0
- package/dist/codegen/codegen-tool.js +312 -0
- package/dist/codegen/field-inference.d.ts +24 -0
- package/dist/codegen/field-inference.js +101 -0
- package/dist/codegen/form-parser.d.ts +13 -0
- package/dist/codegen/form-parser.js +186 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +4 -0
- package/dist/codegen/natural-parser.d.ts +50 -0
- package/dist/codegen/natural-parser.js +769 -0
- package/dist/handlers/codedna-handlers.d.ts +1 -1
- package/dist/handlers/codegen-handlers.d.ts +20 -0
- package/dist/handlers/codegen-handlers.js +60 -0
- package/dist/handlers/kappa-handlers.d.ts +97 -0
- package/dist/handlers/kappa-handlers.js +408 -0
- package/dist/handlers/tool-handlers.js +124 -221
- package/dist/helpers/api-client.js +48 -3
- package/dist/helpers/compact-formatter.d.ts +9 -2
- package/dist/helpers/compact-formatter.js +26 -2
- package/dist/helpers/config.d.ts +7 -2
- package/dist/helpers/config.js +25 -10
- package/dist/helpers/session-validation.d.ts +1 -1
- package/dist/helpers/session-validation.js +2 -4
- package/dist/helpers/tasks.d.ts +21 -0
- package/dist/helpers/tasks.js +52 -0
- package/dist/helpers/workers.d.ts +1 -1
- package/dist/helpers/workers.js +19 -19
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +49 -16
- package/dist/templates/claude-md.d.ts +1 -1
- package/dist/templates/claude-md.js +37 -152
- package/dist/templates/orchestrator-prompt.d.ts +2 -2
- package/dist/templates/orchestrator-prompt.js +31 -38
- package/dist/templates/self-critique.d.ts +50 -0
- package/dist/templates/self-critique.js +209 -0
- package/dist/templates/worker-prompt.d.ts +3 -3
- package/dist/templates/worker-prompt.js +18 -18
- package/dist/tools.js +77 -413
- package/docs/codedna/generator-testing-summary.md +205 -0
- package/docs/codedna/radix-ui-generator.md +478 -0
- package/docs/kappa-gofiber-generator.md +274 -0
- package/docs/kappa-laravel-fixes.md +172 -0
- package/docs/kappa-mongoose-generator.md +322 -0
- package/docs/kappa-vitest-generator.md +337 -0
- package/package.json +1 -1
- package/dist/context/deduplication.test.d.ts +0 -6
- package/dist/context/deduplication.test.js +0 -84
|
@@ -85,22 +85,17 @@ export function buildOrchestratorPrompt(params) {
|
|
|
85
85
|
- File-by-file change lists
|
|
86
86
|
</behavior>
|
|
87
87
|
|
|
88
|
-
<behavior id="
|
|
88
|
+
<behavior id="codegen_specs" priority="MANDATORY">
|
|
89
89
|
When tasks involve creating entities/models/APIs:
|
|
90
90
|
|
|
91
|
-
INSTEAD OF writing code
|
|
92
|
-
|
|
93
|
-
interface User {
|
|
94
|
-
id: string;
|
|
95
|
-
email: string;
|
|
96
|
-
password: string;
|
|
97
|
-
}
|
|
98
|
-
\`\`\`
|
|
91
|
+
INSTEAD OF writing code, USE natural language:
|
|
92
|
+
"User with email, password, role (admin/user)"
|
|
99
93
|
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
Workers use codegen() which infers types from field names:
|
|
95
|
+
- email → email type, password → hashed, createdAt → timestamp
|
|
96
|
+
- (admin/user) → enum, price → decimal, isActive → boolean
|
|
102
97
|
|
|
103
|
-
|
|
98
|
+
Token savings: 95-99% vs manual coding.
|
|
104
99
|
</behavior>
|
|
105
100
|
|
|
106
101
|
<behavior id="parallel_dispatch" priority="IMPORTANT">
|
|
@@ -161,19 +156,18 @@ export function buildOrchestratorPrompt(params) {
|
|
|
161
156
|
- Random .md files scattered in src/ or root
|
|
162
157
|
</documentation_standards>
|
|
163
158
|
|
|
164
|
-
<
|
|
165
|
-
When defining data models, use
|
|
159
|
+
<entity_format>
|
|
160
|
+
When defining data models, use natural language:
|
|
166
161
|
|
|
167
|
-
FORMAT: EntityName
|
|
168
|
-
|
|
169
|
-
TYPES: string, integer, decimal, boolean, datetime, ref(Entity), enum(val1|val2)
|
|
170
|
-
CONSTRAINTS: unique, required, min(n), max(n), hashed, default(val)
|
|
162
|
+
FORMAT: "EntityName with field1, field2, field3 (enum values)"
|
|
171
163
|
|
|
172
164
|
EXAMPLES:
|
|
173
|
-
- "User
|
|
174
|
-
- "Product
|
|
175
|
-
- "Order
|
|
176
|
-
|
|
165
|
+
- "User with email, password, role (admin/user)"
|
|
166
|
+
- "Product with name, price, categoryId"
|
|
167
|
+
- "Order with userId, total, status (pending/paid/shipped)"
|
|
168
|
+
|
|
169
|
+
Types are inferred from field names (email→email, password→hashed, price→decimal)
|
|
170
|
+
</entity_format>
|
|
177
171
|
|
|
178
172
|
<acceptance_criteria_format>
|
|
179
173
|
Good acceptance criteria are:
|
|
@@ -219,24 +213,23 @@ export function buildOrchestratorPrompt(params) {
|
|
|
219
213
|
- general-expert: Tasks that don't fit other domains`}
|
|
220
214
|
</available_workers>
|
|
221
215
|
|
|
222
|
-
<
|
|
223
|
-
|
|
216
|
+
<codegen priority="CRITICAL">
|
|
217
|
+
codegen() generates production code from natural language descriptions.
|
|
224
218
|
|
|
225
|
-
|
|
226
|
-
1. Workers should call codedna_list_generators() to see available generators
|
|
227
|
-
2. If a generator exists, use it instead of writing code manually
|
|
219
|
+
USAGE: codegen({ describe: "User with email, password, role (admin/user)" })
|
|
228
220
|
|
|
229
|
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
221
|
+
GENERATES:
|
|
222
|
+
- Drizzle schema (database tables)
|
|
223
|
+
- TypeScript types
|
|
224
|
+
- Zod validators
|
|
225
|
+
- API routes (Hono/Express)
|
|
233
226
|
|
|
234
227
|
INCLUDE IN TASK DESCRIPTIONS:
|
|
235
|
-
When tasks involve entities,
|
|
236
|
-
"Create user registration. Entity: User
|
|
228
|
+
When tasks involve entities, describe them naturally:
|
|
229
|
+
"Create user registration. Entity: User with email, password, role (admin/user)"
|
|
237
230
|
|
|
238
|
-
Token savings: 95-99% vs manual coding
|
|
239
|
-
</
|
|
231
|
+
Stack auto-detected from package.json. Token savings: 95-99% vs manual coding.
|
|
232
|
+
</codegen>
|
|
240
233
|
|
|
241
234
|
${epicTitle ? `<epic_context>
|
|
242
235
|
<title>${epicTitle}</title>
|
|
@@ -259,10 +252,10 @@ export function buildOrchestratorPrompt(params) {
|
|
|
259
252
|
</user_input>`;
|
|
260
253
|
}
|
|
261
254
|
/**
|
|
262
|
-
* Get
|
|
255
|
+
* Get codegen usage hint for task descriptions
|
|
263
256
|
*/
|
|
264
|
-
export function
|
|
265
|
-
return `Entity
|
|
257
|
+
export function getCodegenHint(entityDescription) {
|
|
258
|
+
return `Entity: ${entityDescription} (workers will use codegen)`;
|
|
266
259
|
}
|
|
267
260
|
/**
|
|
268
261
|
* Validate task description doesn't contain code
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface SelfCritiqueContext {
|
|
2
|
+
taskDescription: string;
|
|
3
|
+
proposedSolution: string;
|
|
4
|
+
codeSnippet?: string;
|
|
5
|
+
targetAudience?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SelfCritiqueResult {
|
|
8
|
+
passed: boolean;
|
|
9
|
+
issues: SelfCritiqueIssue[];
|
|
10
|
+
suggestions: string[];
|
|
11
|
+
overallScore: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SelfCritiqueIssue {
|
|
14
|
+
category: 'universality' | 'simplicity' | 'hardcoding' | 'assumptions';
|
|
15
|
+
severity: 'low' | 'medium' | 'high';
|
|
16
|
+
description: string;
|
|
17
|
+
suggestion: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generate a self-critique prompt for AI agents.
|
|
21
|
+
* This prompt guides the AI to check its own work for common issues.
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateSelfCritiquePrompt(context: SelfCritiqueContext): string;
|
|
24
|
+
/**
|
|
25
|
+
* Quick check prompts for specific concerns.
|
|
26
|
+
* Use these for targeted self-critique on specific aspects.
|
|
27
|
+
*/
|
|
28
|
+
export declare const QUICK_CRITIQUE_PROMPTS: {
|
|
29
|
+
universality: string;
|
|
30
|
+
simplicity: string;
|
|
31
|
+
hardcoding: string;
|
|
32
|
+
assumptions: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Generate a pre-commit checklist for AI agents.
|
|
36
|
+
* A lightweight version of self-critique for quick checks.
|
|
37
|
+
*/
|
|
38
|
+
export declare function generatePreCommitChecklist(taskType: 'code' | 'design' | 'analysis'): string;
|
|
39
|
+
/**
|
|
40
|
+
* Parse a self-critique response from an LLM.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseSelfCritiqueResponse(response: string): SelfCritiqueResult | null;
|
|
43
|
+
/**
|
|
44
|
+
* Determine if a self-critique result warrants action.
|
|
45
|
+
*/
|
|
46
|
+
export declare function shouldTakeAction(result: SelfCritiqueResult): {
|
|
47
|
+
shouldRevise: boolean;
|
|
48
|
+
shouldAskUser: boolean;
|
|
49
|
+
reason: string;
|
|
50
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Self-Critique Prompt Template
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// A template for AI agents to self-critique their work before finalizing.
|
|
5
|
+
// Catches issues like hardcoded patterns, over-engineering, and assumptions
|
|
6
|
+
// before they require user intervention.
|
|
7
|
+
// =============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Generate a self-critique prompt for AI agents.
|
|
10
|
+
* This prompt guides the AI to check its own work for common issues.
|
|
11
|
+
*/
|
|
12
|
+
export function generateSelfCritiquePrompt(context) {
|
|
13
|
+
const codeSection = context.codeSnippet
|
|
14
|
+
? `\n## Code to Review\n\`\`\`\n${context.codeSnippet.slice(0, 2000)}\n\`\`\``
|
|
15
|
+
: '';
|
|
16
|
+
const audienceNote = context.targetAudience
|
|
17
|
+
? `Target audience: ${context.targetAudience}`
|
|
18
|
+
: 'Target audience: All users (universal)';
|
|
19
|
+
return `# Self-Critique Review
|
|
20
|
+
|
|
21
|
+
You are reviewing your own proposed solution before finalizing. Be critical and honest.
|
|
22
|
+
|
|
23
|
+
## Task
|
|
24
|
+
${context.taskDescription}
|
|
25
|
+
|
|
26
|
+
## Proposed Solution
|
|
27
|
+
${context.proposedSolution}
|
|
28
|
+
${codeSection}
|
|
29
|
+
|
|
30
|
+
## Review Criteria
|
|
31
|
+
|
|
32
|
+
${audienceNote}
|
|
33
|
+
|
|
34
|
+
Evaluate the solution against these criteria:
|
|
35
|
+
|
|
36
|
+
### 1. Universality (Does this work for ALL users?)
|
|
37
|
+
- Does this assume a specific communication style?
|
|
38
|
+
- Would this work for users from different cultures/backgrounds?
|
|
39
|
+
- Are there hardcoded patterns that only match certain phrasings?
|
|
40
|
+
- Would a user with a different vocabulary trigger this correctly?
|
|
41
|
+
|
|
42
|
+
### 2. Simplicity (Is this over-engineered?)
|
|
43
|
+
- Is there a simpler way to achieve the same result?
|
|
44
|
+
- Are there unnecessary abstractions or indirections?
|
|
45
|
+
- Is the complexity justified by the requirements?
|
|
46
|
+
- Would a junior developer understand this easily?
|
|
47
|
+
|
|
48
|
+
### 3. Hardcoding (Am I hardcoding things that should be inferred?)
|
|
49
|
+
- Are there magic strings that should be configurable?
|
|
50
|
+
- Are there hardcoded patterns that limit flexibility?
|
|
51
|
+
- Should any of this logic be LLM-inferred instead of rule-based?
|
|
52
|
+
- Are there assumptions baked into constants that might not hold?
|
|
53
|
+
|
|
54
|
+
### 4. Assumptions (What am I assuming that might be wrong?)
|
|
55
|
+
- What implicit assumptions does this solution make?
|
|
56
|
+
- Are these assumptions documented or validated?
|
|
57
|
+
- What happens if an assumption is violated?
|
|
58
|
+
- Would a user from a different context have different expectations?
|
|
59
|
+
|
|
60
|
+
## Output Format
|
|
61
|
+
|
|
62
|
+
Respond with a JSON object:
|
|
63
|
+
{
|
|
64
|
+
"passed": true/false,
|
|
65
|
+
"issues": [
|
|
66
|
+
{
|
|
67
|
+
"category": "universality|simplicity|hardcoding|assumptions",
|
|
68
|
+
"severity": "low|medium|high",
|
|
69
|
+
"description": "What the issue is",
|
|
70
|
+
"suggestion": "How to fix it"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"suggestions": ["List of improvement suggestions"],
|
|
74
|
+
"overallScore": 0-100
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
A solution passes if:
|
|
78
|
+
- No high-severity issues
|
|
79
|
+
- overallScore >= 70
|
|
80
|
+
- All critical universality concerns addressed
|
|
81
|
+
|
|
82
|
+
Be critical. It's better to catch issues now than to require user intervention later.`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Quick check prompts for specific concerns.
|
|
86
|
+
* Use these for targeted self-critique on specific aspects.
|
|
87
|
+
*/
|
|
88
|
+
export const QUICK_CRITIQUE_PROMPTS = {
|
|
89
|
+
universality: `Before finalizing, ask yourself:
|
|
90
|
+
- Would this work for a user who communicates differently than me?
|
|
91
|
+
- Am I assuming English idioms or Western communication patterns?
|
|
92
|
+
- Would this handle indirect, polite, or terse communication styles?
|
|
93
|
+
- If I replaced keywords with synonyms, would it still work?`,
|
|
94
|
+
simplicity: `Before finalizing, ask yourself:
|
|
95
|
+
- Can I explain this in one sentence?
|
|
96
|
+
- Is there a 3-line solution I'm missing?
|
|
97
|
+
- Would a code reviewer ask "why is this so complicated?"
|
|
98
|
+
- Am I solving future problems that don't exist yet?`,
|
|
99
|
+
hardcoding: `Before finalizing, ask yourself:
|
|
100
|
+
- Am I matching specific strings that could be phrased differently?
|
|
101
|
+
- Should this regex be an LLM inference instead?
|
|
102
|
+
- Are my constants actually universal, or just common in my experience?
|
|
103
|
+
- Would this break if the user uses different terminology?`,
|
|
104
|
+
assumptions: `Before finalizing, ask yourself:
|
|
105
|
+
- What am I assuming about the user's environment?
|
|
106
|
+
- What am I assuming about their technical level?
|
|
107
|
+
- What am I assuming about their preferences?
|
|
108
|
+
- What happens if any of these assumptions are wrong?`,
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Generate a pre-commit checklist for AI agents.
|
|
112
|
+
* A lightweight version of self-critique for quick checks.
|
|
113
|
+
*/
|
|
114
|
+
export function generatePreCommitChecklist(taskType) {
|
|
115
|
+
const baseChecks = `
|
|
116
|
+
## Pre-Commit Checklist
|
|
117
|
+
|
|
118
|
+
Before finalizing, verify:
|
|
119
|
+
|
|
120
|
+
☐ **Universality**: Works for diverse users, not just specific communication styles
|
|
121
|
+
☐ **Simplicity**: No unnecessary complexity; a simpler solution doesn't exist
|
|
122
|
+
☐ **No Hardcoding**: Dynamic where needed; LLM inference over rigid patterns
|
|
123
|
+
☐ **Assumptions Documented**: Any assumptions are explicit and validated
|
|
124
|
+
`;
|
|
125
|
+
const typeSpecificChecks = {
|
|
126
|
+
code: `
|
|
127
|
+
### Code-Specific
|
|
128
|
+
☐ No magic strings that should be configurable
|
|
129
|
+
☐ No regex patterns that could be LLM inference
|
|
130
|
+
☐ Error messages are helpful, not cryptic
|
|
131
|
+
☐ Edge cases are handled, not assumed away
|
|
132
|
+
`,
|
|
133
|
+
design: `
|
|
134
|
+
### Design-Specific
|
|
135
|
+
☐ Scales to 10x users without architecture changes
|
|
136
|
+
☐ Failure modes are graceful, not catastrophic
|
|
137
|
+
☐ New developers can understand the design in 5 minutes
|
|
138
|
+
☐ No premature optimization or over-abstraction
|
|
139
|
+
`,
|
|
140
|
+
analysis: `
|
|
141
|
+
### Analysis-Specific
|
|
142
|
+
☐ Conclusions are supported by evidence
|
|
143
|
+
☐ Alternative interpretations are considered
|
|
144
|
+
☐ Limitations are acknowledged
|
|
145
|
+
☐ Recommendations are actionable
|
|
146
|
+
`,
|
|
147
|
+
};
|
|
148
|
+
return baseChecks + (typeSpecificChecks[taskType] || '');
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parse a self-critique response from an LLM.
|
|
152
|
+
*/
|
|
153
|
+
export function parseSelfCritiqueResponse(response) {
|
|
154
|
+
try {
|
|
155
|
+
// Extract JSON from response (handles markdown code blocks)
|
|
156
|
+
let jsonStr = response.trim();
|
|
157
|
+
if (jsonStr.startsWith('```')) {
|
|
158
|
+
jsonStr = jsonStr.replace(/```json?\n?/g, '').replace(/```$/g, '').trim();
|
|
159
|
+
}
|
|
160
|
+
const parsed = JSON.parse(jsonStr);
|
|
161
|
+
// Validate structure
|
|
162
|
+
if (typeof parsed.passed !== 'boolean')
|
|
163
|
+
return null;
|
|
164
|
+
if (!Array.isArray(parsed.issues))
|
|
165
|
+
return null;
|
|
166
|
+
if (typeof parsed.overallScore !== 'number')
|
|
167
|
+
return null;
|
|
168
|
+
return parsed;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Determine if a self-critique result warrants action.
|
|
176
|
+
*/
|
|
177
|
+
export function shouldTakeAction(result) {
|
|
178
|
+
// High severity issues always require revision
|
|
179
|
+
const highSeverityIssues = result.issues.filter(i => i.severity === 'high');
|
|
180
|
+
if (highSeverityIssues.length > 0) {
|
|
181
|
+
return {
|
|
182
|
+
shouldRevise: true,
|
|
183
|
+
shouldAskUser: false,
|
|
184
|
+
reason: `${highSeverityIssues.length} high-severity issue(s) found: ${highSeverityIssues.map(i => i.description).join('; ')}`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// Low score requires revision
|
|
188
|
+
if (result.overallScore < 70) {
|
|
189
|
+
return {
|
|
190
|
+
shouldRevise: true,
|
|
191
|
+
shouldAskUser: false,
|
|
192
|
+
reason: `Score ${result.overallScore}/100 is below threshold (70)`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
// Multiple medium issues warrant user consultation
|
|
196
|
+
const mediumIssues = result.issues.filter(i => i.severity === 'medium');
|
|
197
|
+
if (mediumIssues.length >= 3) {
|
|
198
|
+
return {
|
|
199
|
+
shouldRevise: false,
|
|
200
|
+
shouldAskUser: true,
|
|
201
|
+
reason: `Multiple medium-severity issues found. User should review: ${mediumIssues.map(i => i.description).join('; ')}`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
shouldRevise: false,
|
|
206
|
+
shouldAskUser: false,
|
|
207
|
+
reason: 'Solution passed self-critique',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
@@ -27,15 +27,15 @@ export interface WorkerPromptParams {
|
|
|
27
27
|
tier?: 'minimal' | 'standard' | 'professional';
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Build worker system prompt
|
|
30
|
+
* Build worker system prompt
|
|
31
31
|
*
|
|
32
32
|
* Workers:
|
|
33
33
|
* - Execute specific implementation tasks
|
|
34
|
-
* - Use
|
|
34
|
+
* - Use codegen for boilerplate code
|
|
35
35
|
* - Use tools (memory, codebase) before writing from scratch
|
|
36
36
|
* - Report completion with detailed summaries
|
|
37
37
|
*/
|
|
38
|
-
export declare function
|
|
38
|
+
export declare function buildWorkerPrompt(params: WorkerPromptParams): string;
|
|
39
39
|
/**
|
|
40
40
|
* Build a minimal prompt for simple tasks
|
|
41
41
|
*/
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
|
-
// Worker Prompt Template
|
|
2
|
+
// Worker Prompt Template
|
|
3
3
|
// =============================================================================
|
|
4
4
|
//
|
|
5
5
|
// Standard tier (~2000 tokens) prompt template for worker agents.
|
|
6
|
-
// Instructs workers to use
|
|
6
|
+
// Instructs workers to use codegen and tools before writing code.
|
|
7
7
|
//
|
|
8
8
|
// Based on 10/10 AI System Prompt Architecture Framework
|
|
9
9
|
//
|
|
10
10
|
/**
|
|
11
|
-
* Build worker system prompt
|
|
11
|
+
* Build worker system prompt
|
|
12
12
|
*
|
|
13
13
|
* Workers:
|
|
14
14
|
* - Execute specific implementation tasks
|
|
15
|
-
* - Use
|
|
15
|
+
* - Use codegen for boilerplate code
|
|
16
16
|
* - Use tools (memory, codebase) before writing from scratch
|
|
17
17
|
* - Report completion with detailed summaries
|
|
18
18
|
*/
|
|
19
|
-
export function
|
|
19
|
+
export function buildWorkerPrompt(params) {
|
|
20
20
|
const { task, worker, epicContext, attachedContext = [], siblingTasks = [], tier = 'standard' } = params;
|
|
21
21
|
// Build sections based on tier
|
|
22
22
|
const sections = [];
|
|
@@ -67,9 +67,9 @@ function buildIdentitySection(worker) {
|
|
|
67
67
|
function buildBehavioralSection(taskId) {
|
|
68
68
|
return `<!-- Layer 2: Behavioral Guidelines -->
|
|
69
69
|
<behavioral_guidelines>
|
|
70
|
-
<behavior id="
|
|
71
|
-
BEFORE writing
|
|
72
|
-
|
|
70
|
+
<behavior id="codegen_first" priority="MANDATORY">
|
|
71
|
+
BEFORE writing boilerplate: codegen({ describe: "..." }) → generates schema, types, validators, routes
|
|
72
|
+
Natural language: "User with email, password, role (admin/user)"
|
|
73
73
|
Only write manually for: complex logic, modifications, custom business rules
|
|
74
74
|
</behavior>
|
|
75
75
|
|
|
@@ -109,12 +109,12 @@ function buildStandardsSection() {
|
|
|
109
109
|
function buildDomainSection(worker) {
|
|
110
110
|
return `<!-- Layer 4: Domain Knowledge -->
|
|
111
111
|
<domain_knowledge>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</
|
|
112
|
+
<codegen>
|
|
113
|
+
Usage: codegen({ describe: "User with email, password, role (admin/user)" })
|
|
114
|
+
Generates: Drizzle schema, TypeScript types, Zod validators, API routes
|
|
115
|
+
Smart inference: email→email type, password→hashed, createdAt→timestamp, price→decimal
|
|
116
|
+
Stack auto-detected from package.json (Drizzle, Hono, Express, etc.)
|
|
117
|
+
</codegen>
|
|
118
118
|
|
|
119
119
|
<worker_expertise>
|
|
120
120
|
${worker.promptTemplate}
|
|
@@ -126,7 +126,7 @@ function buildCrossCuttingSection() {
|
|
|
126
126
|
<cross_cutting_concerns>
|
|
127
127
|
<error_handling>Validate boundaries. Fail fast. Clear messages. Actionable guidance.</error_handling>
|
|
128
128
|
<security>OWASP Top 10. No exposed secrets. Sanitize inputs. Parameterized queries. Least privilege.</security>
|
|
129
|
-
<performance>No premature optimization. Token efficiency.
|
|
129
|
+
<performance>No premature optimization. Token efficiency. codegen for boilerplate.</performance>
|
|
130
130
|
</cross_cutting_concerns>`;
|
|
131
131
|
}
|
|
132
132
|
function buildTaskSection(task, epicContext) {
|
|
@@ -178,7 +178,7 @@ function buildProtocolSection(taskId) {
|
|
|
178
178
|
return `<!-- Protocol -->
|
|
179
179
|
<protocol>
|
|
180
180
|
<step number="1">task_start(task_id="${taskId}")</step>
|
|
181
|
-
<step number="2">Check
|
|
181
|
+
<step number="2">Check codegen for entities/APIs, else use tools (memory_search, codebase_find)</step>
|
|
182
182
|
<step number="3">Implement requirements. Minimal changes.</step>
|
|
183
183
|
<step number="4">task_complete(task_id="${taskId}", summary="impl, files, decisions, testing")</step>
|
|
184
184
|
|
|
@@ -195,11 +195,11 @@ function buildProtocolSection(taskId) {
|
|
|
195
195
|
* Build a minimal prompt for simple tasks
|
|
196
196
|
*/
|
|
197
197
|
export function buildMinimalWorkerPrompt(params) {
|
|
198
|
-
return
|
|
198
|
+
return buildWorkerPrompt({ ...params, tier: 'minimal' });
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Build a professional prompt for complex tasks
|
|
202
202
|
*/
|
|
203
203
|
export function buildProfessionalWorkerPrompt(params) {
|
|
204
|
-
return
|
|
204
|
+
return buildWorkerPrompt({ ...params, tier: 'professional' });
|
|
205
205
|
}
|