@claudetools/tools 0.7.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 +15 -7
- package/dist/templates/worker-prompt.js +24 -31
- package/dist/tools.js +101 -2
- package/package.json +1 -1
|
@@ -187,15 +187,23 @@ export function buildOrchestratorPrompt(params) {
|
|
|
187
187
|
- general-expert: Tasks that don't fit other domains`}
|
|
188
188
|
</available_workers>
|
|
189
189
|
|
|
190
|
-
<codedna_generators>
|
|
191
|
-
|
|
190
|
+
<codedna_generators priority="CRITICAL">
|
|
191
|
+
CodeDNA generates production code from Entity DSL - workers MUST check availability first.
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
BEFORE creating any task involving APIs, CRUD, or UI components:
|
|
194
|
+
1. Workers should call codedna_list_generators() to see available generators
|
|
195
|
+
2. If a generator exists, use it instead of writing code manually
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
AVAILABLE DOMAINS:
|
|
198
|
+
- api: Express, FastAPI, NestJS (full CRUD with auth, validation, tests)
|
|
199
|
+
- frontend: React/Next.js, Vue 3 (pages, forms, tables)
|
|
200
|
+
- component: Forms, tables, cards, modals (React, Vue, Svelte)
|
|
201
|
+
|
|
202
|
+
INCLUDE IN TASK DESCRIPTIONS:
|
|
203
|
+
When tasks involve entities, include the DSL spec so workers know to use CodeDNA:
|
|
204
|
+
"Create user registration. Entity: User(email:string:unique, password:string:hashed)"
|
|
205
|
+
|
|
206
|
+
Token savings: 95-99% vs manual coding
|
|
199
207
|
</codedna_generators>
|
|
200
208
|
|
|
201
209
|
${epicTitle ? `<epic_context>
|
|
@@ -71,16 +71,18 @@ function buildBehavioralSection(taskId) {
|
|
|
71
71
|
<behavior id="codedna_first" priority="MANDATORY">
|
|
72
72
|
BEFORE writing code manually, check if CodeDNA can generate it:
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
DISCOVERY WORKFLOW:
|
|
75
|
+
1. Call codedna_list_generators() to see available generators
|
|
76
|
+
2. Check if task includes Entity DSL format
|
|
77
|
+
Example: "User(email:string:unique, password:string:hashed)"
|
|
78
|
+
3. Detect framework from project (package.json, existing code)
|
|
79
|
+
4. Match detected framework to generator capabilities
|
|
80
|
+
5. Call appropriate generator with detected settings
|
|
81
|
+
|
|
82
|
+
BENEFITS:
|
|
76
83
|
→ Saves 95-99% tokens vs manual coding
|
|
77
84
|
→ Generates production-ready code with validation, auth, tests
|
|
78
85
|
|
|
79
|
-
FOR Entity definitions:
|
|
80
|
-
→ Check if task includes Entity DSL format
|
|
81
|
-
→ Example: "User(email:string:unique, password:string:hashed)"
|
|
82
|
-
→ Call codedna_generate_api with the spec
|
|
83
|
-
|
|
84
86
|
ONLY write code manually when:
|
|
85
87
|
- Logic is too complex for generation
|
|
86
88
|
- Modifying existing code (not creating new)
|
|
@@ -177,16 +179,12 @@ function buildDomainSection(worker) {
|
|
|
177
179
|
return `<!-- Layer 4: Domain Knowledge -->
|
|
178
180
|
<domain_knowledge>
|
|
179
181
|
<codedna_capabilities>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
2. codedna_validate_spec(spec)
|
|
188
|
-
- Validates Entity DSL syntax before generation
|
|
189
|
-
- Returns parsed structure or errors
|
|
182
|
+
CODEDNA DISCOVERY PATTERN:
|
|
183
|
+
1. Call codedna_list_generators() to see available generators
|
|
184
|
+
2. Each generator lists supported frameworks and options
|
|
185
|
+
3. Detect project framework from package.json/pyproject.toml
|
|
186
|
+
4. Match detected framework to generator capabilities
|
|
187
|
+
5. If no match, ASK the user which framework to use
|
|
190
188
|
|
|
191
189
|
ENTITY DSL FORMAT:
|
|
192
190
|
EntityName(field:type:constraint, field:type:constraint, ...)
|
|
@@ -197,20 +195,15 @@ function buildDomainSection(worker) {
|
|
|
197
195
|
- enum(val1|val2|val3) - enumeration
|
|
198
196
|
|
|
199
197
|
CONSTRAINTS:
|
|
200
|
-
- unique
|
|
201
|
-
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
framework: "express",
|
|
210
|
-
options: { auth: true, validation: true }
|
|
211
|
-
})
|
|
212
|
-
→ Generates 6 production files in ~5 seconds
|
|
213
|
-
→ Saves ~30,000 tokens vs manual implementation
|
|
198
|
+
- unique, required, min(n), max(n), hashed, default(value)
|
|
199
|
+
- UI hints: textarea, switch, radio (for form rendering)
|
|
200
|
+
|
|
201
|
+
WORKFLOW:
|
|
202
|
+
1. codedna_list_generators() → discover capabilities
|
|
203
|
+
2. codedna_validate_spec(spec) → validate DSL syntax
|
|
204
|
+
3. codedna_generate_*(spec, framework, options) → generate code
|
|
205
|
+
|
|
206
|
+
DO NOT assume frameworks exist - always discover via codedna_list_generators
|
|
214
207
|
</codedna_capabilities>
|
|
215
208
|
|
|
216
209
|
<worker_expertise>
|
package/dist/tools.js
CHANGED
|
@@ -952,6 +952,10 @@ export function registerToolDefinitions(server) {
|
|
|
952
952
|
},
|
|
953
953
|
},
|
|
954
954
|
},
|
|
955
|
+
package_json: {
|
|
956
|
+
type: 'object',
|
|
957
|
+
description: 'Optional: package.json content for pattern detection. If provided, generator will detect patterns (zod, yup, etc.) and use matching template variants.',
|
|
958
|
+
},
|
|
955
959
|
},
|
|
956
960
|
required: ['spec', 'framework'],
|
|
957
961
|
},
|
|
@@ -993,6 +997,10 @@ export function registerToolDefinitions(server) {
|
|
|
993
997
|
},
|
|
994
998
|
},
|
|
995
999
|
},
|
|
1000
|
+
package_json: {
|
|
1001
|
+
type: 'object',
|
|
1002
|
+
description: 'Optional: package.json content for pattern detection. Detects React Hook Form, Zod, TanStack Query, etc. and uses matching template variants.',
|
|
1003
|
+
},
|
|
996
1004
|
},
|
|
997
1005
|
required: ['spec', 'framework'],
|
|
998
1006
|
},
|
|
@@ -1031,16 +1039,26 @@ export function registerToolDefinitions(server) {
|
|
|
1031
1039
|
},
|
|
1032
1040
|
},
|
|
1033
1041
|
},
|
|
1042
|
+
package_json: {
|
|
1043
|
+
type: 'object',
|
|
1044
|
+
description: 'Optional: package.json content for pattern detection. Detects form libraries, validation tools, etc. and uses matching template variants.',
|
|
1045
|
+
},
|
|
1034
1046
|
},
|
|
1035
1047
|
required: ['spec', 'type', 'framework'],
|
|
1036
1048
|
},
|
|
1037
1049
|
},
|
|
1038
1050
|
{
|
|
1039
1051
|
name: 'codedna_list_generators',
|
|
1040
|
-
description: '
|
|
1052
|
+
description: 'CALL THIS BEFORE writing any API, CRUD, or UI component code. Lists available code generators that save 95-99% tokens vs manual coding. Returns generators grouped by domain (api/frontend/component) with their capabilities. If a generator exists for your task, use codedna_generate_* instead of writing code manually.',
|
|
1041
1053
|
inputSchema: {
|
|
1042
1054
|
type: 'object',
|
|
1043
|
-
properties: {
|
|
1055
|
+
properties: {
|
|
1056
|
+
domain: {
|
|
1057
|
+
type: 'string',
|
|
1058
|
+
enum: ['api', 'frontend', 'component'],
|
|
1059
|
+
description: 'Filter by domain: "api" for backend APIs, "frontend" for full frontend apps, "component" for individual UI components',
|
|
1060
|
+
},
|
|
1061
|
+
},
|
|
1044
1062
|
},
|
|
1045
1063
|
},
|
|
1046
1064
|
{
|
|
@@ -1057,6 +1075,87 @@ export function registerToolDefinitions(server) {
|
|
|
1057
1075
|
required: ['spec'],
|
|
1058
1076
|
},
|
|
1059
1077
|
},
|
|
1078
|
+
// =========================================================================
|
|
1079
|
+
// CodeDNA Pattern Library Tools
|
|
1080
|
+
// =========================================================================
|
|
1081
|
+
{
|
|
1082
|
+
name: 'codedna_list_patterns',
|
|
1083
|
+
description: 'List coding patterns from the library. Returns best practices (compound components, TanStack Query, Zod) and anti-patterns to avoid (prop drilling, useEffect fetch). Use to understand what patterns are available for a project.',
|
|
1084
|
+
inputSchema: {
|
|
1085
|
+
type: 'object',
|
|
1086
|
+
properties: {
|
|
1087
|
+
category: {
|
|
1088
|
+
type: 'string',
|
|
1089
|
+
enum: ['components', 'hooks', 'forms', 'state', 'validation', 'styling', 'anti-patterns'],
|
|
1090
|
+
description: 'Filter by category',
|
|
1091
|
+
},
|
|
1092
|
+
recommended_only: {
|
|
1093
|
+
type: 'boolean',
|
|
1094
|
+
description: 'Only return recommended best-practice patterns',
|
|
1095
|
+
},
|
|
1096
|
+
include_anti_patterns: {
|
|
1097
|
+
type: 'boolean',
|
|
1098
|
+
description: 'Include anti-patterns in results (default: true)',
|
|
1099
|
+
},
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: 'codedna_get_pattern',
|
|
1105
|
+
description: 'Get detailed documentation for a specific pattern including code examples, when to use/avoid, and migration guides. Use after codedna_list_patterns to get full details.',
|
|
1106
|
+
inputSchema: {
|
|
1107
|
+
type: 'object',
|
|
1108
|
+
properties: {
|
|
1109
|
+
pattern_id: {
|
|
1110
|
+
type: 'string',
|
|
1111
|
+
description: 'Pattern ID (e.g., "compound-components", "tanstack-query", "prop-drilling")',
|
|
1112
|
+
},
|
|
1113
|
+
},
|
|
1114
|
+
required: ['pattern_id'],
|
|
1115
|
+
},
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: 'codedna_detect_patterns',
|
|
1119
|
+
description: 'Detect which patterns are used in an existing codebase. Analyzes package.json dependencies and code samples to identify patterns and anti-patterns. Use before making changes to understand project conventions.',
|
|
1120
|
+
inputSchema: {
|
|
1121
|
+
type: 'object',
|
|
1122
|
+
properties: {
|
|
1123
|
+
package_json: {
|
|
1124
|
+
type: 'object',
|
|
1125
|
+
description: 'The project package.json object (with dependencies/devDependencies)',
|
|
1126
|
+
},
|
|
1127
|
+
code_samples: {
|
|
1128
|
+
type: 'array',
|
|
1129
|
+
items: { type: 'string' },
|
|
1130
|
+
description: 'Code snippets to analyze for pattern signals',
|
|
1131
|
+
},
|
|
1132
|
+
},
|
|
1133
|
+
},
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: 'codedna_init_project',
|
|
1137
|
+
description: 'Initialize a project with recommended patterns. For NEW projects, applies best-practice defaults. For EXISTING projects, use with auto_detect to match existing conventions.',
|
|
1138
|
+
inputSchema: {
|
|
1139
|
+
type: 'object',
|
|
1140
|
+
properties: {
|
|
1141
|
+
project_id: {
|
|
1142
|
+
type: 'string',
|
|
1143
|
+
description: 'Project ID from claudetools',
|
|
1144
|
+
},
|
|
1145
|
+
patterns: {
|
|
1146
|
+
type: 'array',
|
|
1147
|
+
items: { type: 'string' },
|
|
1148
|
+
description: 'Specific pattern IDs to apply (optional - uses recommended if not specified)',
|
|
1149
|
+
},
|
|
1150
|
+
project_type: {
|
|
1151
|
+
type: 'string',
|
|
1152
|
+
enum: ['new', 'existing'],
|
|
1153
|
+
description: '"new" for greenfield (uses recommended), "existing" for updating (detects patterns)',
|
|
1154
|
+
},
|
|
1155
|
+
},
|
|
1156
|
+
required: ['project_id'],
|
|
1157
|
+
},
|
|
1158
|
+
},
|
|
1060
1159
|
],
|
|
1061
1160
|
}));
|
|
1062
1161
|
}
|