@claudetools/tools 0.6.0 → 0.7.1
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/codedna/generators/base.d.ts +11 -2
- package/dist/codedna/generators/base.js +91 -8
- package/dist/codedna/generators/react-frontend.js +2 -1
- package/dist/codedna/parser.d.ts +6 -0
- package/dist/codedna/parser.js +7 -0
- package/dist/codedna/registry.d.ts +23 -17
- package/dist/codedna/registry.js +103 -263
- package/dist/codedna/template-engine.js +23 -0
- package/dist/codedna/types.d.ts +22 -0
- package/dist/handlers/codedna-handlers.d.ts +219 -6
- package/dist/handlers/codedna-handlers.js +379 -11
- package/dist/handlers/tool-handlers.js +45 -2
- package/dist/helpers/workers.js +60 -7
- package/dist/templates/orchestrator-prompt.js +34 -7
- package/dist/templates/worker-prompt.js +56 -31
- package/dist/tools.js +101 -2
- package/package.json +1 -1
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
export interface CodeDNAPattern {
|
|
2
|
+
pattern_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
category: 'components' | 'hooks' | 'forms' | 'state' | 'validation' | 'styling' | 'anti-patterns';
|
|
5
|
+
description: string;
|
|
6
|
+
conditions: string[];
|
|
7
|
+
anti_conditions: string[];
|
|
8
|
+
code_signals: string[];
|
|
9
|
+
package_signals: string[];
|
|
10
|
+
related_patterns: string[];
|
|
11
|
+
migrates_from: string[];
|
|
12
|
+
is_recommended: boolean;
|
|
13
|
+
is_anti_pattern: boolean;
|
|
14
|
+
version: string;
|
|
15
|
+
r2_key?: string;
|
|
16
|
+
}
|
|
1
17
|
/**
|
|
2
18
|
* Handle codedna_generate_api tool call
|
|
19
|
+
*
|
|
20
|
+
* Pattern-aware generation:
|
|
21
|
+
* - If package_json is provided, patterns are detected automatically
|
|
22
|
+
* - If patterns is provided in options, those are used directly
|
|
23
|
+
* - Generated code will use template variants matching detected patterns
|
|
3
24
|
*/
|
|
4
25
|
export declare function handleGenerateApi(args: any): Promise<{
|
|
5
26
|
error: string;
|
|
@@ -8,6 +29,7 @@ export declare function handleGenerateApi(args: any): Promise<{
|
|
|
8
29
|
success?: undefined;
|
|
9
30
|
files?: undefined;
|
|
10
31
|
metadata?: undefined;
|
|
32
|
+
patternsApplied?: undefined;
|
|
11
33
|
tokenSavings?: undefined;
|
|
12
34
|
message?: undefined;
|
|
13
35
|
} | {
|
|
@@ -17,12 +39,14 @@ export declare function handleGenerateApi(args: any): Promise<{
|
|
|
17
39
|
success?: undefined;
|
|
18
40
|
files?: undefined;
|
|
19
41
|
metadata?: undefined;
|
|
42
|
+
patternsApplied?: undefined;
|
|
20
43
|
tokenSavings?: undefined;
|
|
21
44
|
message?: undefined;
|
|
22
45
|
} | {
|
|
23
46
|
success: boolean;
|
|
24
47
|
files: Record<string, string>;
|
|
25
48
|
metadata: import("../codedna/types.js").GenerationMetadata;
|
|
49
|
+
patternsApplied: string[] | undefined;
|
|
26
50
|
tokenSavings: {
|
|
27
51
|
traditional: number;
|
|
28
52
|
codedna: number;
|
|
@@ -41,10 +65,16 @@ export declare function handleGenerateApi(args: any): Promise<{
|
|
|
41
65
|
success?: undefined;
|
|
42
66
|
files?: undefined;
|
|
43
67
|
metadata?: undefined;
|
|
68
|
+
patternsApplied?: undefined;
|
|
44
69
|
tokenSavings?: undefined;
|
|
45
70
|
}>;
|
|
46
71
|
/**
|
|
47
72
|
* Handle codedna_generate_frontend tool call
|
|
73
|
+
*
|
|
74
|
+
* Pattern-aware generation:
|
|
75
|
+
* - If package_json is provided, patterns are detected automatically
|
|
76
|
+
* - Detects React Hook Form, Zod, TanStack Query, etc.
|
|
77
|
+
* - Uses template variants matching detected patterns
|
|
48
78
|
*/
|
|
49
79
|
export declare function handleGenerateFrontend(args: any): Promise<{
|
|
50
80
|
error: string;
|
|
@@ -53,6 +83,7 @@ export declare function handleGenerateFrontend(args: any): Promise<{
|
|
|
53
83
|
success?: undefined;
|
|
54
84
|
files?: undefined;
|
|
55
85
|
metadata?: undefined;
|
|
86
|
+
patternsApplied?: undefined;
|
|
56
87
|
tokenSavings?: undefined;
|
|
57
88
|
message?: undefined;
|
|
58
89
|
} | {
|
|
@@ -62,12 +93,14 @@ export declare function handleGenerateFrontend(args: any): Promise<{
|
|
|
62
93
|
success?: undefined;
|
|
63
94
|
files?: undefined;
|
|
64
95
|
metadata?: undefined;
|
|
96
|
+
patternsApplied?: undefined;
|
|
65
97
|
tokenSavings?: undefined;
|
|
66
98
|
message?: undefined;
|
|
67
99
|
} | {
|
|
68
100
|
success: boolean;
|
|
69
101
|
files: Record<string, string>;
|
|
70
102
|
metadata: import("../codedna/types.js").GenerationMetadata;
|
|
103
|
+
patternsApplied: string[] | undefined;
|
|
71
104
|
tokenSavings: {
|
|
72
105
|
traditional: number;
|
|
73
106
|
codedna: number;
|
|
@@ -86,10 +119,15 @@ export declare function handleGenerateFrontend(args: any): Promise<{
|
|
|
86
119
|
success?: undefined;
|
|
87
120
|
files?: undefined;
|
|
88
121
|
metadata?: undefined;
|
|
122
|
+
patternsApplied?: undefined;
|
|
89
123
|
tokenSavings?: undefined;
|
|
90
124
|
}>;
|
|
91
125
|
/**
|
|
92
126
|
* Handle codedna_generate_component tool call
|
|
127
|
+
*
|
|
128
|
+
* Pattern-aware generation:
|
|
129
|
+
* - If package_json is provided, patterns are detected automatically
|
|
130
|
+
* - Uses matching patterns for form libraries, validation, etc.
|
|
93
131
|
*/
|
|
94
132
|
export declare function handleGenerateComponent(args: any): Promise<{
|
|
95
133
|
error: string;
|
|
@@ -98,6 +136,7 @@ export declare function handleGenerateComponent(args: any): Promise<{
|
|
|
98
136
|
success?: undefined;
|
|
99
137
|
files?: undefined;
|
|
100
138
|
metadata?: undefined;
|
|
139
|
+
patternsApplied?: undefined;
|
|
101
140
|
tokenSavings?: undefined;
|
|
102
141
|
message?: undefined;
|
|
103
142
|
} | {
|
|
@@ -107,12 +146,14 @@ export declare function handleGenerateComponent(args: any): Promise<{
|
|
|
107
146
|
success?: undefined;
|
|
108
147
|
files?: undefined;
|
|
109
148
|
metadata?: undefined;
|
|
149
|
+
patternsApplied?: undefined;
|
|
110
150
|
tokenSavings?: undefined;
|
|
111
151
|
message?: undefined;
|
|
112
152
|
} | {
|
|
113
153
|
success: boolean;
|
|
114
154
|
files: Record<string, string>;
|
|
115
155
|
metadata: import("../codedna/types.js").GenerationMetadata;
|
|
156
|
+
patternsApplied: string[] | undefined;
|
|
116
157
|
tokenSavings: {
|
|
117
158
|
traditional: number;
|
|
118
159
|
codedna: number;
|
|
@@ -131,24 +172,36 @@ export declare function handleGenerateComponent(args: any): Promise<{
|
|
|
131
172
|
success?: undefined;
|
|
132
173
|
files?: undefined;
|
|
133
174
|
metadata?: undefined;
|
|
175
|
+
patternsApplied?: undefined;
|
|
134
176
|
tokenSavings?: undefined;
|
|
135
177
|
}>;
|
|
136
178
|
/**
|
|
137
179
|
* Handle codedna_list_generators tool call
|
|
180
|
+
* @param args.domain Optional domain filter: 'api' | 'frontend' | 'component'
|
|
138
181
|
*/
|
|
139
|
-
export declare function handleListGenerators(
|
|
140
|
-
|
|
182
|
+
export declare function handleListGenerators(args?: {
|
|
183
|
+
domain?: 'api' | 'frontend' | 'component';
|
|
184
|
+
}): Promise<{
|
|
141
185
|
summary: {
|
|
186
|
+
byFramework: Record<string, number>;
|
|
187
|
+
byDomain: Record<string, number> | undefined;
|
|
188
|
+
availableUiLibraries: string[];
|
|
189
|
+
filteredByDomain?: "api" | "frontend" | "component" | undefined;
|
|
142
190
|
total: number;
|
|
143
|
-
byFramework: any;
|
|
144
191
|
};
|
|
192
|
+
usage: {
|
|
193
|
+
api: string;
|
|
194
|
+
frontend: string;
|
|
195
|
+
component: string;
|
|
196
|
+
note: string;
|
|
197
|
+
};
|
|
198
|
+
byDomain?: Record<string, import("../codedna/types.js").GeneratorMetadata[]> | undefined;
|
|
199
|
+
generators: import("../codedna/types.js").GeneratorMetadata[];
|
|
145
200
|
error?: undefined;
|
|
146
201
|
message?: undefined;
|
|
147
202
|
} | {
|
|
148
203
|
error: string;
|
|
149
204
|
message: string;
|
|
150
|
-
generators?: undefined;
|
|
151
|
-
summary?: undefined;
|
|
152
205
|
}>;
|
|
153
206
|
/**
|
|
154
207
|
* Handle codedna_validate_spec tool call
|
|
@@ -160,7 +213,7 @@ export declare function handleValidateSpec(args: any): Promise<{
|
|
|
160
213
|
fields: {
|
|
161
214
|
name: string;
|
|
162
215
|
type: import("../codedna/parser.js").FieldType;
|
|
163
|
-
constraints: ("default" | "length" | "email" | "min" | "max" | "url" | "required" | "pattern" | "nullable" | "unique" | "hashed" | "index" | "immutable")[];
|
|
216
|
+
constraints: ("default" | "length" | "email" | "min" | "max" | "url" | "required" | "pattern" | "nullable" | "unique" | "hashed" | "index" | "immutable" | "textarea" | "switch" | "radio")[];
|
|
164
217
|
}[];
|
|
165
218
|
};
|
|
166
219
|
summary: {
|
|
@@ -176,3 +229,163 @@ export declare function handleValidateSpec(args: any): Promise<{
|
|
|
176
229
|
entity?: undefined;
|
|
177
230
|
summary?: undefined;
|
|
178
231
|
}>;
|
|
232
|
+
/**
|
|
233
|
+
* Handle codedna_list_patterns tool call
|
|
234
|
+
* Lists patterns from the library, optionally filtered by category
|
|
235
|
+
*/
|
|
236
|
+
export declare function handleListPatterns(args?: {
|
|
237
|
+
category?: CodeDNAPattern['category'];
|
|
238
|
+
recommended_only?: boolean;
|
|
239
|
+
include_anti_patterns?: boolean;
|
|
240
|
+
}): Promise<{
|
|
241
|
+
patterns: CodeDNAPattern[];
|
|
242
|
+
byCategory: Record<string, CodeDNAPattern[]>;
|
|
243
|
+
summary: {
|
|
244
|
+
total: number;
|
|
245
|
+
recommended: number;
|
|
246
|
+
antiPatterns: number;
|
|
247
|
+
categories: string[];
|
|
248
|
+
};
|
|
249
|
+
usage: {
|
|
250
|
+
getDetails: string;
|
|
251
|
+
detect: string;
|
|
252
|
+
init: string;
|
|
253
|
+
};
|
|
254
|
+
error?: undefined;
|
|
255
|
+
message?: undefined;
|
|
256
|
+
} | {
|
|
257
|
+
error: string;
|
|
258
|
+
message: string;
|
|
259
|
+
patterns?: undefined;
|
|
260
|
+
byCategory?: undefined;
|
|
261
|
+
summary?: undefined;
|
|
262
|
+
usage?: undefined;
|
|
263
|
+
}>;
|
|
264
|
+
/**
|
|
265
|
+
* Handle codedna_get_pattern tool call
|
|
266
|
+
* Gets detailed pattern information including full markdown documentation
|
|
267
|
+
*/
|
|
268
|
+
export declare function handleGetPattern(args: {
|
|
269
|
+
pattern_id: string;
|
|
270
|
+
}): Promise<{
|
|
271
|
+
error: string;
|
|
272
|
+
pattern?: undefined;
|
|
273
|
+
sections?: undefined;
|
|
274
|
+
detection?: undefined;
|
|
275
|
+
content?: undefined;
|
|
276
|
+
message?: undefined;
|
|
277
|
+
} | {
|
|
278
|
+
pattern: CodeDNAPattern & {
|
|
279
|
+
content?: string;
|
|
280
|
+
};
|
|
281
|
+
sections: {
|
|
282
|
+
description: string;
|
|
283
|
+
whenToUse: string[];
|
|
284
|
+
whenNotToUse: string[];
|
|
285
|
+
relatedPatterns: string[];
|
|
286
|
+
migratesFrom: string[];
|
|
287
|
+
};
|
|
288
|
+
detection: {
|
|
289
|
+
codeSignals: string[];
|
|
290
|
+
packageSignals: string[];
|
|
291
|
+
};
|
|
292
|
+
content: string | undefined;
|
|
293
|
+
error?: undefined;
|
|
294
|
+
message?: undefined;
|
|
295
|
+
} | {
|
|
296
|
+
error: string;
|
|
297
|
+
message: string;
|
|
298
|
+
pattern?: undefined;
|
|
299
|
+
sections?: undefined;
|
|
300
|
+
detection?: undefined;
|
|
301
|
+
content?: undefined;
|
|
302
|
+
}>;
|
|
303
|
+
/**
|
|
304
|
+
* Handle codedna_detect_patterns tool call
|
|
305
|
+
* Detects patterns in a project based on code and package.json signals
|
|
306
|
+
*/
|
|
307
|
+
export declare function handleDetectPatterns(args: {
|
|
308
|
+
project_path?: string;
|
|
309
|
+
package_json?: Record<string, unknown>;
|
|
310
|
+
code_samples?: string[];
|
|
311
|
+
}): Promise<{
|
|
312
|
+
detected: {
|
|
313
|
+
pattern: CodeDNAPattern;
|
|
314
|
+
confidence: number;
|
|
315
|
+
signals: string[];
|
|
316
|
+
}[];
|
|
317
|
+
warnings: {
|
|
318
|
+
message: string;
|
|
319
|
+
patterns: {
|
|
320
|
+
pattern: CodeDNAPattern;
|
|
321
|
+
confidence: number;
|
|
322
|
+
signals: string[];
|
|
323
|
+
}[];
|
|
324
|
+
} | undefined;
|
|
325
|
+
summary: {
|
|
326
|
+
totalDetected: number;
|
|
327
|
+
goodPatterns: number;
|
|
328
|
+
antiPatterns: number;
|
|
329
|
+
highConfidence: number;
|
|
330
|
+
};
|
|
331
|
+
recommendations: {
|
|
332
|
+
pattern_id: string;
|
|
333
|
+
name: string;
|
|
334
|
+
description: string;
|
|
335
|
+
reason: string;
|
|
336
|
+
}[];
|
|
337
|
+
error?: undefined;
|
|
338
|
+
message?: undefined;
|
|
339
|
+
} | {
|
|
340
|
+
error: string;
|
|
341
|
+
message: string;
|
|
342
|
+
detected?: undefined;
|
|
343
|
+
warnings?: undefined;
|
|
344
|
+
summary?: undefined;
|
|
345
|
+
recommendations?: undefined;
|
|
346
|
+
}>;
|
|
347
|
+
/**
|
|
348
|
+
* Handle codedna_init_project tool call
|
|
349
|
+
* Initializes a new project with recommended patterns
|
|
350
|
+
*/
|
|
351
|
+
export declare function handleInitProject(args: {
|
|
352
|
+
project_id: string;
|
|
353
|
+
patterns?: string[];
|
|
354
|
+
auto_detect?: boolean;
|
|
355
|
+
project_type?: 'new' | 'existing';
|
|
356
|
+
}): Promise<{
|
|
357
|
+
error: string;
|
|
358
|
+
success?: undefined;
|
|
359
|
+
project_id?: undefined;
|
|
360
|
+
project_type?: undefined;
|
|
361
|
+
patterns?: undefined;
|
|
362
|
+
summary?: undefined;
|
|
363
|
+
nextSteps?: undefined;
|
|
364
|
+
message?: undefined;
|
|
365
|
+
} | {
|
|
366
|
+
success: boolean;
|
|
367
|
+
project_id: string;
|
|
368
|
+
project_type: "new" | "existing";
|
|
369
|
+
patterns: {
|
|
370
|
+
pattern_id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
category: "hooks" | "components" | "forms" | "state" | "validation" | "styling" | "anti-patterns";
|
|
373
|
+
description: string;
|
|
374
|
+
}[];
|
|
375
|
+
summary: {
|
|
376
|
+
totalPatterns: number;
|
|
377
|
+
byCategory: Record<string, number>;
|
|
378
|
+
};
|
|
379
|
+
nextSteps: string[];
|
|
380
|
+
error?: undefined;
|
|
381
|
+
message?: undefined;
|
|
382
|
+
} | {
|
|
383
|
+
error: string;
|
|
384
|
+
message: string;
|
|
385
|
+
success?: undefined;
|
|
386
|
+
project_id?: undefined;
|
|
387
|
+
project_type?: undefined;
|
|
388
|
+
patterns?: undefined;
|
|
389
|
+
summary?: undefined;
|
|
390
|
+
nextSteps?: undefined;
|
|
391
|
+
}>;
|