@claudetools/tools 0.3.9 → 0.5.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 +60 -4
- package/dist/cli.js +0 -0
- package/dist/codedna/generators/base.d.ts +41 -0
- package/dist/codedna/generators/base.js +102 -0
- package/dist/codedna/generators/express-api.d.ts +12 -0
- package/dist/codedna/generators/express-api.js +61 -0
- package/dist/codedna/index.d.ts +4 -0
- package/dist/codedna/index.js +7 -0
- package/dist/codedna/parser.d.ts +117 -0
- package/dist/codedna/parser.js +233 -0
- package/dist/codedna/registry.d.ts +60 -0
- package/dist/codedna/registry.js +217 -0
- package/dist/codedna/template-engine.d.ts +17 -0
- package/dist/codedna/template-engine.js +183 -0
- package/dist/codedna/types.d.ts +64 -0
- package/dist/codedna/types.js +4 -0
- package/dist/handlers/codedna-handlers.d.ts +122 -0
- package/dist/handlers/codedna-handlers.js +194 -0
- package/dist/handlers/tool-handlers.js +593 -14
- package/dist/helpers/api-client.d.ts +37 -0
- package/dist/helpers/api-client.js +70 -0
- package/dist/helpers/codedna-monitoring.d.ts +34 -0
- package/dist/helpers/codedna-monitoring.js +159 -0
- package/dist/helpers/error-tracking.d.ts +73 -0
- package/dist/helpers/error-tracking.js +164 -0
- package/dist/helpers/library-detection.d.ts +26 -0
- package/dist/helpers/library-detection.js +145 -0
- package/dist/helpers/tasks-retry.d.ts +49 -0
- package/dist/helpers/tasks-retry.js +168 -0
- package/dist/helpers/tasks.d.ts +24 -1
- package/dist/helpers/tasks.js +146 -50
- package/dist/helpers/usage-analytics.d.ts +91 -0
- package/dist/helpers/usage-analytics.js +256 -0
- package/dist/helpers/workers.d.ts +25 -0
- package/dist/helpers/workers.js +80 -0
- package/dist/templates/claude-md.d.ts +1 -1
- package/dist/templates/claude-md.js +16 -5
- package/dist/tools.js +314 -0
- package/docs/AUTO-REGISTRATION.md +353 -0
- package/docs/CLAUDE4_PROMPT_ANALYSIS.md +589 -0
- package/docs/ENTITY_DSL_REFERENCE.md +685 -0
- package/docs/MODERN_STACK_COMPLETE_GUIDE.md +706 -0
- package/docs/PROMPT_STANDARDIZATION_RESULTS.md +324 -0
- package/docs/PROMPT_TIER_TEMPLATES.md +787 -0
- package/docs/RESEARCH_METHODOLOGY_EXTRACTION.md +336 -0
- package/package.json +14 -3
- package/scripts/verify-prompt-compliance.sh +197 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export interface UsageEvent {
|
|
2
|
+
timestamp: string;
|
|
3
|
+
operation: 'generate_api' | 'generate_frontend' | 'generate_component' | 'validate_spec';
|
|
4
|
+
generator?: string;
|
|
5
|
+
framework?: string;
|
|
6
|
+
entityName?: string;
|
|
7
|
+
fieldCount?: number;
|
|
8
|
+
specLength?: number;
|
|
9
|
+
filesGenerated?: number;
|
|
10
|
+
linesOfCode?: number;
|
|
11
|
+
tokensSaved?: number;
|
|
12
|
+
options?: {
|
|
13
|
+
auth?: boolean;
|
|
14
|
+
validation?: boolean;
|
|
15
|
+
tests?: boolean;
|
|
16
|
+
database?: string;
|
|
17
|
+
};
|
|
18
|
+
success: boolean;
|
|
19
|
+
executionTimeMs?: number;
|
|
20
|
+
projectId?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class UsageAnalytics {
|
|
23
|
+
private static instance;
|
|
24
|
+
private constructor();
|
|
25
|
+
static getInstance(): UsageAnalytics;
|
|
26
|
+
/**
|
|
27
|
+
* Track a successful generation
|
|
28
|
+
*/
|
|
29
|
+
trackGeneration(event: Omit<UsageEvent, 'timestamp' | 'success'>): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Track a validation
|
|
32
|
+
*/
|
|
33
|
+
trackValidation(spec: string, valid: boolean, entityName?: string, fieldCount?: number, projectId?: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare const analytics: UsageAnalytics;
|
|
36
|
+
/**
|
|
37
|
+
* Analytics query interface
|
|
38
|
+
*/
|
|
39
|
+
export interface AnalyticsQuery {
|
|
40
|
+
startTime: string;
|
|
41
|
+
endTime: string;
|
|
42
|
+
operation?: UsageEvent['operation'];
|
|
43
|
+
generator?: string;
|
|
44
|
+
framework?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface AnalyticsResult {
|
|
47
|
+
totalGenerations: number;
|
|
48
|
+
totalTokensSaved: number;
|
|
49
|
+
avgTokensSavedPerGeneration: number;
|
|
50
|
+
totalLinesOfCode: number;
|
|
51
|
+
totalFiles: number;
|
|
52
|
+
generatorStats: Record<string, {
|
|
53
|
+
count: number;
|
|
54
|
+
tokensSaved: number;
|
|
55
|
+
linesOfCode: number;
|
|
56
|
+
filesGenerated: number;
|
|
57
|
+
}>;
|
|
58
|
+
frameworkStats: Record<string, number>;
|
|
59
|
+
optionsUsage: {
|
|
60
|
+
auth: number;
|
|
61
|
+
validation: number;
|
|
62
|
+
tests: number;
|
|
63
|
+
};
|
|
64
|
+
entityPatterns: Record<string, number>;
|
|
65
|
+
avgExecutionTime?: number;
|
|
66
|
+
recentGenerations: UsageEvent[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Query usage analytics
|
|
70
|
+
*/
|
|
71
|
+
export declare function getUsageAnalytics(query: AnalyticsQuery): Promise<AnalyticsResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Get analytics for last 24 hours
|
|
74
|
+
*/
|
|
75
|
+
export declare function getLast24HoursAnalytics(): Promise<AnalyticsResult>;
|
|
76
|
+
/**
|
|
77
|
+
* Get analytics for last 7 days
|
|
78
|
+
*/
|
|
79
|
+
export declare function getLast7DaysAnalytics(): Promise<AnalyticsResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Get analytics for last 30 days
|
|
82
|
+
*/
|
|
83
|
+
export declare function getLast30DaysAnalytics(): Promise<AnalyticsResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Print analytics report
|
|
86
|
+
*/
|
|
87
|
+
export declare function printAnalytics(result: AnalyticsResult, title?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Weekly analytics summary
|
|
90
|
+
*/
|
|
91
|
+
export declare function weeklyAnalyticsSummary(): Promise<void>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// CodeDNA Usage Analytics
|
|
3
|
+
// =============================================================================
|
|
4
|
+
//
|
|
5
|
+
// Track CodeDNA usage patterns, token savings, and generator popularity
|
|
6
|
+
// for analytics and optimization insights.
|
|
7
|
+
//
|
|
8
|
+
import { storeFact, searchMemory } from './api-client.js';
|
|
9
|
+
import { DEFAULT_USER_ID, resolveProjectId } from './config.js';
|
|
10
|
+
export class UsageAnalytics {
|
|
11
|
+
static instance;
|
|
12
|
+
constructor() { }
|
|
13
|
+
static getInstance() {
|
|
14
|
+
if (!UsageAnalytics.instance) {
|
|
15
|
+
UsageAnalytics.instance = new UsageAnalytics();
|
|
16
|
+
}
|
|
17
|
+
return UsageAnalytics.instance;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Track a successful generation
|
|
21
|
+
*/
|
|
22
|
+
async trackGeneration(event) {
|
|
23
|
+
try {
|
|
24
|
+
const usageEvent = {
|
|
25
|
+
...event,
|
|
26
|
+
timestamp: new Date().toISOString(),
|
|
27
|
+
success: true,
|
|
28
|
+
};
|
|
29
|
+
const userId = DEFAULT_USER_ID;
|
|
30
|
+
const projectId = event.projectId || resolveProjectId();
|
|
31
|
+
// Store as fact in memory system
|
|
32
|
+
await storeFact(projectId, 'CodeDNA', 'GENERATION_COMPLETED', event.generator || event.operation, JSON.stringify(usageEvent), userId);
|
|
33
|
+
console.log('[CodeDNA Analytics]', {
|
|
34
|
+
operation: event.operation,
|
|
35
|
+
generator: event.generator,
|
|
36
|
+
tokensSaved: event.tokensSaved,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
// Don't fail the operation if analytics fails
|
|
41
|
+
console.error('[CodeDNA Analytics Failed]', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Track a validation
|
|
46
|
+
*/
|
|
47
|
+
async trackValidation(spec, valid, entityName, fieldCount, projectId) {
|
|
48
|
+
await this.trackGeneration({
|
|
49
|
+
operation: 'validate_spec',
|
|
50
|
+
entityName,
|
|
51
|
+
fieldCount,
|
|
52
|
+
specLength: spec.length,
|
|
53
|
+
success: valid,
|
|
54
|
+
projectId,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Export singleton instance
|
|
59
|
+
export const analytics = UsageAnalytics.getInstance();
|
|
60
|
+
/**
|
|
61
|
+
* Query usage analytics
|
|
62
|
+
*/
|
|
63
|
+
export async function getUsageAnalytics(query) {
|
|
64
|
+
const userId = DEFAULT_USER_ID;
|
|
65
|
+
const projectId = resolveProjectId();
|
|
66
|
+
// Search for usage facts
|
|
67
|
+
const searchQuery = `CodeDNA GENERATION_COMPLETED ${query.operation || ''}`;
|
|
68
|
+
const result = await searchMemory(projectId, searchQuery, 500, userId);
|
|
69
|
+
// Parse usage events from facts
|
|
70
|
+
const events = result.relevant_facts
|
|
71
|
+
.map((fact) => {
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(fact.fact);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.filter((e) => e !== null)
|
|
80
|
+
.filter((e) => {
|
|
81
|
+
const eventTime = new Date(e.timestamp).getTime();
|
|
82
|
+
const start = new Date(query.startTime).getTime();
|
|
83
|
+
const end = new Date(query.endTime).getTime();
|
|
84
|
+
return eventTime >= start && eventTime <= end;
|
|
85
|
+
})
|
|
86
|
+
.filter((e) => !query.operation || e.operation === query.operation)
|
|
87
|
+
.filter((e) => !query.generator || e.generator === query.generator)
|
|
88
|
+
.filter((e) => !query.framework || e.framework === query.framework);
|
|
89
|
+
// Calculate statistics
|
|
90
|
+
const totalTokensSaved = events.reduce((sum, e) => sum + (e.tokensSaved || 0), 0);
|
|
91
|
+
const totalLinesOfCode = events.reduce((sum, e) => sum + (e.linesOfCode || 0), 0);
|
|
92
|
+
const totalFiles = events.reduce((sum, e) => sum + (e.filesGenerated || 0), 0);
|
|
93
|
+
// Generator statistics
|
|
94
|
+
const generatorStats = {};
|
|
95
|
+
events.forEach(event => {
|
|
96
|
+
const gen = event.generator || 'unknown';
|
|
97
|
+
if (!generatorStats[gen]) {
|
|
98
|
+
generatorStats[gen] = { count: 0, tokensSaved: 0, linesOfCode: 0, filesGenerated: 0 };
|
|
99
|
+
}
|
|
100
|
+
generatorStats[gen].count++;
|
|
101
|
+
generatorStats[gen].tokensSaved += event.tokensSaved || 0;
|
|
102
|
+
generatorStats[gen].linesOfCode += event.linesOfCode || 0;
|
|
103
|
+
generatorStats[gen].filesGenerated += event.filesGenerated || 0;
|
|
104
|
+
});
|
|
105
|
+
// Framework statistics
|
|
106
|
+
const frameworkStats = {};
|
|
107
|
+
events.forEach(event => {
|
|
108
|
+
if (event.framework) {
|
|
109
|
+
frameworkStats[event.framework] = (frameworkStats[event.framework] || 0) + 1;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// Options usage
|
|
113
|
+
let authCount = 0;
|
|
114
|
+
let validationCount = 0;
|
|
115
|
+
let testsCount = 0;
|
|
116
|
+
events.forEach(event => {
|
|
117
|
+
if (event.options?.auth)
|
|
118
|
+
authCount++;
|
|
119
|
+
if (event.options?.validation)
|
|
120
|
+
validationCount++;
|
|
121
|
+
if (event.options?.tests)
|
|
122
|
+
testsCount++;
|
|
123
|
+
});
|
|
124
|
+
// Entity patterns
|
|
125
|
+
const entityPatterns = {};
|
|
126
|
+
events.forEach(event => {
|
|
127
|
+
if (event.entityName) {
|
|
128
|
+
entityPatterns[event.entityName] = (entityPatterns[event.entityName] || 0) + 1;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// Average execution time
|
|
132
|
+
const executionTimes = events.filter(e => e.executionTimeMs).map(e => e.executionTimeMs);
|
|
133
|
+
const avgExecutionTime = executionTimes.length > 0
|
|
134
|
+
? executionTimes.reduce((sum, t) => sum + t, 0) / executionTimes.length
|
|
135
|
+
: undefined;
|
|
136
|
+
return {
|
|
137
|
+
totalGenerations: events.length,
|
|
138
|
+
totalTokensSaved,
|
|
139
|
+
avgTokensSavedPerGeneration: events.length > 0 ? totalTokensSaved / events.length : 0,
|
|
140
|
+
totalLinesOfCode,
|
|
141
|
+
totalFiles,
|
|
142
|
+
generatorStats,
|
|
143
|
+
frameworkStats,
|
|
144
|
+
optionsUsage: {
|
|
145
|
+
auth: authCount,
|
|
146
|
+
validation: validationCount,
|
|
147
|
+
tests: testsCount,
|
|
148
|
+
},
|
|
149
|
+
entityPatterns,
|
|
150
|
+
avgExecutionTime,
|
|
151
|
+
recentGenerations: events.slice(0, 10).reverse(),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get analytics for last 24 hours
|
|
156
|
+
*/
|
|
157
|
+
export async function getLast24HoursAnalytics() {
|
|
158
|
+
const endTime = new Date().toISOString();
|
|
159
|
+
const startTime = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
|
|
160
|
+
return getUsageAnalytics({ startTime, endTime });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get analytics for last 7 days
|
|
164
|
+
*/
|
|
165
|
+
export async function getLast7DaysAnalytics() {
|
|
166
|
+
const endTime = new Date().toISOString();
|
|
167
|
+
const startTime = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
168
|
+
return getUsageAnalytics({ startTime, endTime });
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get analytics for last 30 days
|
|
172
|
+
*/
|
|
173
|
+
export async function getLast30DaysAnalytics() {
|
|
174
|
+
const endTime = new Date().toISOString();
|
|
175
|
+
const startTime = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
176
|
+
return getUsageAnalytics({ startTime, endTime });
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Print analytics report
|
|
180
|
+
*/
|
|
181
|
+
export function printAnalytics(result, title = 'CodeDNA Usage Analytics') {
|
|
182
|
+
console.log('\n=================================================');
|
|
183
|
+
console.log(title);
|
|
184
|
+
console.log('=================================================\n');
|
|
185
|
+
console.log('Overview:');
|
|
186
|
+
console.log(` Total Generations: ${result.totalGenerations}`);
|
|
187
|
+
console.log(` Total Tokens Saved: ${result.totalTokensSaved.toLocaleString()}`);
|
|
188
|
+
console.log(` Avg Tokens/Generation: ${Math.round(result.avgTokensSavedPerGeneration).toLocaleString()}`);
|
|
189
|
+
console.log(` Total Lines of Code: ${result.totalLinesOfCode.toLocaleString()}`);
|
|
190
|
+
console.log(` Total Files Generated: ${result.totalFiles}`);
|
|
191
|
+
if (result.avgExecutionTime) {
|
|
192
|
+
console.log(` Avg Execution Time: ${Math.round(result.avgExecutionTime)}ms`);
|
|
193
|
+
}
|
|
194
|
+
console.log();
|
|
195
|
+
if (Object.keys(result.generatorStats).length > 0) {
|
|
196
|
+
console.log('Generator Usage:');
|
|
197
|
+
Object.entries(result.generatorStats)
|
|
198
|
+
.sort((a, b) => b[1].count - a[1].count)
|
|
199
|
+
.forEach(([gen, stats]) => {
|
|
200
|
+
console.log(` ${gen}:`);
|
|
201
|
+
console.log(` Count: ${stats.count}`);
|
|
202
|
+
console.log(` Tokens Saved: ${stats.tokensSaved.toLocaleString()}`);
|
|
203
|
+
console.log(` Lines of Code: ${stats.linesOfCode.toLocaleString()}`);
|
|
204
|
+
console.log(` Files Generated: ${stats.filesGenerated}`);
|
|
205
|
+
});
|
|
206
|
+
console.log();
|
|
207
|
+
}
|
|
208
|
+
if (Object.keys(result.frameworkStats).length > 0) {
|
|
209
|
+
console.log('Framework Popularity:');
|
|
210
|
+
Object.entries(result.frameworkStats)
|
|
211
|
+
.sort((a, b) => b[1] - a[1])
|
|
212
|
+
.forEach(([framework, count]) => {
|
|
213
|
+
console.log(` ${framework}: ${count} generations`);
|
|
214
|
+
});
|
|
215
|
+
console.log();
|
|
216
|
+
}
|
|
217
|
+
console.log('Options Usage:');
|
|
218
|
+
console.log(` Auth: ${result.optionsUsage.auth} generations`);
|
|
219
|
+
console.log(` Validation: ${result.optionsUsage.validation} generations`);
|
|
220
|
+
console.log(` Tests: ${result.optionsUsage.tests} generations`);
|
|
221
|
+
console.log();
|
|
222
|
+
if (Object.keys(result.entityPatterns).length > 0) {
|
|
223
|
+
console.log('Popular Entities:');
|
|
224
|
+
Object.entries(result.entityPatterns)
|
|
225
|
+
.sort((a, b) => b[1] - a[1])
|
|
226
|
+
.slice(0, 10)
|
|
227
|
+
.forEach(([entity, count]) => {
|
|
228
|
+
console.log(` ${entity}: ${count} times`);
|
|
229
|
+
});
|
|
230
|
+
console.log();
|
|
231
|
+
}
|
|
232
|
+
if (result.recentGenerations.length > 0) {
|
|
233
|
+
console.log('Recent Generations:');
|
|
234
|
+
result.recentGenerations.forEach((gen, i) => {
|
|
235
|
+
console.log(` ${i + 1}. [${gen.timestamp}] ${gen.operation}`);
|
|
236
|
+
console.log(` Generator: ${gen.generator || 'N/A'}`);
|
|
237
|
+
console.log(` Entity: ${gen.entityName || 'N/A'}`);
|
|
238
|
+
console.log(` Tokens Saved: ${(gen.tokensSaved || 0).toLocaleString()}`);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
console.log('\n=================================================\n');
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Weekly analytics summary
|
|
245
|
+
*/
|
|
246
|
+
export async function weeklyAnalyticsSummary() {
|
|
247
|
+
console.log('Generating weekly CodeDNA analytics summary...\n');
|
|
248
|
+
const result = await getLast7DaysAnalytics();
|
|
249
|
+
printAnalytics(result, 'CodeDNA Weekly Analytics Summary');
|
|
250
|
+
// Calculate ROI
|
|
251
|
+
const estimatedCost = result.totalTokensSaved * 0.00001; // ~$0.01 per 1000 tokens
|
|
252
|
+
console.log('💰 Estimated Cost Savings:');
|
|
253
|
+
console.log(` Traditional approach: $${estimatedCost.toFixed(2)}`);
|
|
254
|
+
console.log(` With CodeDNA: $${(estimatedCost * 0.01).toFixed(2)} (99% savings)`);
|
|
255
|
+
console.log(` Total saved: $${(estimatedCost * 0.99).toFixed(2)}\n`);
|
|
256
|
+
}
|
|
@@ -7,6 +7,31 @@ export interface ExpertWorker {
|
|
|
7
7
|
promptTemplate: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const EXPERT_WORKERS: Record<string, ExpertWorker>;
|
|
10
|
+
/**
|
|
11
|
+
* Build a structured worker prompt that includes task context, protocol, error handling
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildWorkerPrompt(params: {
|
|
14
|
+
task: {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
acceptance_criteria?: string | string[];
|
|
19
|
+
};
|
|
20
|
+
worker: ExpertWorker;
|
|
21
|
+
epicContext?: {
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
attachedContext?: Array<{
|
|
26
|
+
type: string;
|
|
27
|
+
content: string;
|
|
28
|
+
source?: string;
|
|
29
|
+
}>;
|
|
30
|
+
siblingTasks?: Array<{
|
|
31
|
+
title: string;
|
|
32
|
+
status: string;
|
|
33
|
+
}>;
|
|
34
|
+
}): string;
|
|
10
35
|
/**
|
|
11
36
|
* Match a task to the best expert worker based on domain patterns
|
|
12
37
|
*/
|
package/dist/helpers/workers.js
CHANGED
|
@@ -92,6 +92,86 @@ When complete, provide a concise summary of integrations configured.`,
|
|
|
92
92
|
When complete, provide a concise summary of work done.`,
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Build a structured worker prompt that includes task context, protocol, error handling
|
|
97
|
+
*/
|
|
98
|
+
export function buildWorkerPrompt(params) {
|
|
99
|
+
const { task, worker, epicContext, attachedContext, siblingTasks } = params;
|
|
100
|
+
let prompt = '';
|
|
101
|
+
// Worker domain introduction
|
|
102
|
+
prompt += `${worker.promptTemplate}\n\n`;
|
|
103
|
+
prompt += `---\n\n`;
|
|
104
|
+
// Task header
|
|
105
|
+
prompt += `## Task: ${task.title}\n`;
|
|
106
|
+
prompt += `**Task ID:** ${task.id}\n\n`;
|
|
107
|
+
// Task description
|
|
108
|
+
if (task.description) {
|
|
109
|
+
prompt += `## Description\n${task.description}\n\n`;
|
|
110
|
+
}
|
|
111
|
+
// Acceptance criteria
|
|
112
|
+
const criteria = Array.isArray(task.acceptance_criteria)
|
|
113
|
+
? task.acceptance_criteria
|
|
114
|
+
: (task.acceptance_criteria ? [task.acceptance_criteria] : []);
|
|
115
|
+
if (criteria.length > 0) {
|
|
116
|
+
prompt += `## Acceptance Criteria\n`;
|
|
117
|
+
criteria.forEach((criterion, index) => {
|
|
118
|
+
prompt += `${index + 1}. ${criterion}\n`;
|
|
119
|
+
});
|
|
120
|
+
prompt += '\n';
|
|
121
|
+
}
|
|
122
|
+
// Epic context
|
|
123
|
+
if (epicContext) {
|
|
124
|
+
prompt += `## Epic Context\n`;
|
|
125
|
+
prompt += `**Epic:** ${epicContext.title}\n`;
|
|
126
|
+
if (epicContext.description) {
|
|
127
|
+
prompt += `**Goal:** ${epicContext.description}\n`;
|
|
128
|
+
}
|
|
129
|
+
prompt += '\n';
|
|
130
|
+
}
|
|
131
|
+
// Attached context
|
|
132
|
+
if (attachedContext && attachedContext.length > 0) {
|
|
133
|
+
prompt += `## Attached Context\n`;
|
|
134
|
+
for (const ctx of attachedContext) {
|
|
135
|
+
prompt += `### ${ctx.type.toUpperCase()}${ctx.source ? ` (${ctx.source})` : ''}\n`;
|
|
136
|
+
prompt += `${ctx.content}\n\n`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Related tasks
|
|
140
|
+
if (siblingTasks && siblingTasks.length > 0) {
|
|
141
|
+
prompt += `## Related Tasks (for awareness)\n`;
|
|
142
|
+
for (const sibling of siblingTasks.slice(0, 5)) {
|
|
143
|
+
prompt += `- ${sibling.title} [${sibling.status}]\n`;
|
|
144
|
+
}
|
|
145
|
+
prompt += '\n';
|
|
146
|
+
}
|
|
147
|
+
// Protocol instructions
|
|
148
|
+
prompt += `## Protocol\n`;
|
|
149
|
+
prompt += `You MUST follow this protocol:\n\n`;
|
|
150
|
+
prompt += `1. **Start the task:** Call \`task_start(task_id="${task.id}", agent_id="<your-agent-id>")\` to claim this task\n`;
|
|
151
|
+
prompt += `2. **Complete the work:** Implement the requirements described above\n`;
|
|
152
|
+
prompt += `3. **Complete the task:** Call \`task_complete(task_id="${task.id}", summary="<detailed-summary>")\` with:\n`;
|
|
153
|
+
prompt += ` - What you implemented\n`;
|
|
154
|
+
prompt += ` - Files modified or created\n`;
|
|
155
|
+
prompt += ` - Any important decisions made\n`;
|
|
156
|
+
prompt += ` - Testing performed (if applicable)\n\n`;
|
|
157
|
+
// Error handling
|
|
158
|
+
prompt += `## Error Handling\n`;
|
|
159
|
+
prompt += `If you encounter blocking errors or issues:\n\n`;
|
|
160
|
+
prompt += `1. **Log the error:** Call \`task_add_context(task_id="${task.id}", context_type="work_log", content="ERROR: <description>", added_by="<your-agent-id>")\`\n`;
|
|
161
|
+
prompt += `2. **Release the task:** Call \`task_release(task_id="${task.id}", agent_id="<your-agent-id>", new_status="blocked", work_log="<summary-of-issue>")\`\n`;
|
|
162
|
+
prompt += `3. **Do NOT mark the task as complete** if the work is not finished\n\n`;
|
|
163
|
+
// Result format
|
|
164
|
+
prompt += `## Result Format\n`;
|
|
165
|
+
prompt += `When calling task_complete, your summary should include:\n\n`;
|
|
166
|
+
prompt += `- **Implementation:** What you built/changed\n`;
|
|
167
|
+
prompt += `- **Files:** List of modified files with paths\n`;
|
|
168
|
+
prompt += `- **Decisions:** Any architectural or design choices\n`;
|
|
169
|
+
prompt += `- **Testing:** How the changes were verified\n`;
|
|
170
|
+
prompt += `- **Notes:** Any caveats, limitations, or follow-up needed\n\n`;
|
|
171
|
+
prompt += `---\n\n`;
|
|
172
|
+
prompt += `**Begin work now. Remember to call task_start first!**\n`;
|
|
173
|
+
return prompt;
|
|
174
|
+
}
|
|
95
175
|
/**
|
|
96
176
|
* Match a task to the best expert worker based on domain patterns
|
|
97
177
|
*/
|
|
@@ -5,7 +5,7 @@ export declare const PROJECT_SECTION_END = "<!-- CLAUDETOOLS:PROJECT:END -->";
|
|
|
5
5
|
/**
|
|
6
6
|
* Global CLAUDE.md content - added to ~/.claude/CLAUDE.md
|
|
7
7
|
*/
|
|
8
|
-
export declare const GLOBAL_TEMPLATE = "\n<!-- CLAUDETOOLS:START -->\n# ClaudeTools Memory System\n\nYou have access to a persistent memory system via the `claudetools_memory` MCP server. Use it to remember context across sessions.\n\n## Memory Tools\n\n### Searching Memory\n```\nmemory_search(query: \"authentication patterns\")\n```\nSearch for relevant facts, entities, and past context. Use this when:\n- Starting work on a feature to recall past decisions\n- Looking for patterns or conventions used before\n- Finding related code or architectural context\n\n### Storing Facts\n```\nmemory_store_fact(\n entity1: \"UserService\",\n relationship: \"USES\",\n entity2: \"bcrypt\",\n context: \"Password hashing uses bcrypt with 12 rounds\"\n)\n```\nStore important facts as relationships between entities. Use for:\n- Architectural decisions\n- Code patterns and conventions\n- Dependencies and relationships\n- User preferences learned during conversation\n\n### Context Injection\nContext is automatically injected at the start of each session based on the current project. Check `~/.claudetools/session-context.md` for project-specific context.\n\n## Task Management\n\n### Creating Work Plans\n```\ntask_plan(\n goal: \"Add user authentication\",\n epic_title: \"User Auth System\",\n tasks: [...]\n)\n```\nBreak down complex work into tracked tasks.\n\n###
|
|
8
|
+
export declare const GLOBAL_TEMPLATE = "\n<!-- CLAUDETOOLS:START -->\n# ClaudeTools Memory System\n\nYou have access to a persistent memory system via the `claudetools_memory` MCP server. Use it to remember context across sessions.\n\n## Memory Tools\n\n### Searching Memory\n```\nmemory_search(query: \"authentication patterns\")\n```\nSearch for relevant facts, entities, and past context. Use this when:\n- Starting work on a feature to recall past decisions\n- Looking for patterns or conventions used before\n- Finding related code or architectural context\n\n### Storing Facts\n```\nmemory_store_fact(\n entity1: \"UserService\",\n relationship: \"USES\",\n entity2: \"bcrypt\",\n context: \"Password hashing uses bcrypt with 12 rounds\"\n)\n```\nStore important facts as relationships between entities. Use for:\n- Architectural decisions\n- Code patterns and conventions\n- Dependencies and relationships\n- User preferences learned during conversation\n\n### Context Injection\nContext is automatically injected at the start of each session based on the current project. Check `~/.claudetools/session-context.md` for project-specific context.\n\n## Task Management\n\n### Creating Work Plans with Auto-Dispatch\n```\ntask_plan(\n goal: \"Add user authentication\",\n epic_title: \"User Auth System\",\n tasks: [...]\n)\n```\nBreak down complex work into tracked tasks. **Tasks are automatically set to `ready` status.**\n\nAfter `task_plan` completes, you will receive Task tool invocations to spawn parallel agents.\n**Execute ALL Task tool calls in a SINGLE message** to enable parallel execution.\n\n### Parallel Agent Workflow\n1. User describes work needed\n2. Call `task_plan_draft` to present the plan\n3. User says \"go\" to approve\n4. Call `task_plan` - tasks created in `ready` status\n5. Execute the provided Task tool calls in ONE message\n6. Agents work in parallel, each calling `task_complete` when done\n\n### Manual Task Start (Sequential)\n```\ntask_start(task_id: \"task_xxx\")\n```\nClaim a task before working on it. Use for sequential execution.\n\n### Completing Tasks\n```\ntask_complete(task_id: \"task_xxx\", summary: \"Implemented JWT auth with refresh tokens\")\n```\nMark tasks done with a summary of work completed. **Always call this when a task is finished.**\n\n## Codebase Intelligence\n\n### Finding Code\n```\ncodebase_map() # Get overview of project structure\ncodebase_find(\"UserService\") # Find symbols/files\ncodebase_context(\"src/auth.ts\") # Get file dependencies\n```\n\n### Impact Analysis\n```\nanalyze_impact(function_name: \"validateToken\")\n```\nSee what would be affected by changing a function.\n\n## Best Practices\n\n1. **Search before implementing** - Check memory for existing patterns\n2. **Store decisions** - Save architectural choices as facts\n3. **Use task tracking** - Break complex work into tasks\n4. **Complete tasks** - Always mark tasks done with summaries\n<!-- CLAUDETOOLS:END -->\n";
|
|
9
9
|
/**
|
|
10
10
|
* Project-level CLAUDE.md content - added to .claude/CLAUDE.md
|
|
11
11
|
*/
|
|
@@ -47,7 +47,7 @@ Context is automatically injected at the start of each session based on the curr
|
|
|
47
47
|
|
|
48
48
|
## Task Management
|
|
49
49
|
|
|
50
|
-
### Creating Work Plans
|
|
50
|
+
### Creating Work Plans with Auto-Dispatch
|
|
51
51
|
\`\`\`
|
|
52
52
|
task_plan(
|
|
53
53
|
goal: "Add user authentication",
|
|
@@ -55,19 +55,30 @@ task_plan(
|
|
|
55
55
|
tasks: [...]
|
|
56
56
|
)
|
|
57
57
|
\`\`\`
|
|
58
|
-
Break down complex work into tracked tasks.
|
|
58
|
+
Break down complex work into tracked tasks. **Tasks are automatically set to \`ready\` status.**
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
After \`task_plan\` completes, you will receive Task tool invocations to spawn parallel agents.
|
|
61
|
+
**Execute ALL Task tool calls in a SINGLE message** to enable parallel execution.
|
|
62
|
+
|
|
63
|
+
### Parallel Agent Workflow
|
|
64
|
+
1. User describes work needed
|
|
65
|
+
2. Call \`task_plan_draft\` to present the plan
|
|
66
|
+
3. User says "go" to approve
|
|
67
|
+
4. Call \`task_plan\` - tasks created in \`ready\` status
|
|
68
|
+
5. Execute the provided Task tool calls in ONE message
|
|
69
|
+
6. Agents work in parallel, each calling \`task_complete\` when done
|
|
70
|
+
|
|
71
|
+
### Manual Task Start (Sequential)
|
|
61
72
|
\`\`\`
|
|
62
73
|
task_start(task_id: "task_xxx")
|
|
63
74
|
\`\`\`
|
|
64
|
-
Claim a task before working on it.
|
|
75
|
+
Claim a task before working on it. Use for sequential execution.
|
|
65
76
|
|
|
66
77
|
### Completing Tasks
|
|
67
78
|
\`\`\`
|
|
68
79
|
task_complete(task_id: "task_xxx", summary: "Implemented JWT auth with refresh tokens")
|
|
69
80
|
\`\`\`
|
|
70
|
-
Mark tasks done with a summary of work completed.
|
|
81
|
+
Mark tasks done with a summary of work completed. **Always call this when a task is finished.**
|
|
71
82
|
|
|
72
83
|
## Codebase Intelligence
|
|
73
84
|
|