@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
|
@@ -127,6 +127,25 @@ export function buildOrchestratorPrompt(params) {
|
|
|
127
127
|
4. Effort estimate (xs/s/m/l/xl): Based on complexity
|
|
128
128
|
</task_structure>
|
|
129
129
|
|
|
130
|
+
<documentation_standards priority="MANDATORY">
|
|
131
|
+
When creating plans, research, or documentation:
|
|
132
|
+
|
|
133
|
+
DIRECTORY STRUCTURE:
|
|
134
|
+
- docs/ → Project documentation
|
|
135
|
+
- docs/research/ → Research and analysis
|
|
136
|
+
- docs/decisions/ → Architecture Decision Records
|
|
137
|
+
|
|
138
|
+
NAMING CONVENTIONS:
|
|
139
|
+
- lowercase-with-hyphens.md (NEVER underscores or spaces)
|
|
140
|
+
- Date prefix for temporal docs: YYYY-MM-DD-topic.md
|
|
141
|
+
- Example: docs/research/2025-12-05-auth-comparison.md
|
|
142
|
+
|
|
143
|
+
ANTI-PATTERNS (NEVER DO):
|
|
144
|
+
- PLAN.md, NOTES.md, TODO.md in project root
|
|
145
|
+
- SCREAMING_CASE_FILENAMES.md
|
|
146
|
+
- Random .md files scattered in src/ or root
|
|
147
|
+
</documentation_standards>
|
|
148
|
+
|
|
130
149
|
<entity_dsl_format>
|
|
131
150
|
When defining data models, use Entity DSL:
|
|
132
151
|
|
|
@@ -168,15 +187,23 @@ export function buildOrchestratorPrompt(params) {
|
|
|
168
187
|
- general-expert: Tasks that don't fit other domains`}
|
|
169
188
|
</available_workers>
|
|
170
189
|
|
|
171
|
-
<codedna_generators>
|
|
172
|
-
|
|
190
|
+
<codedna_generators priority="CRITICAL">
|
|
191
|
+
CodeDNA generates production code from Entity DSL - workers MUST check availability first.
|
|
192
|
+
|
|
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
|
+
|
|
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)
|
|
173
201
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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)"
|
|
177
205
|
|
|
178
|
-
|
|
179
|
-
Workers will use CodeDNA automatically.
|
|
206
|
+
Token savings: 95-99% vs manual coding
|
|
180
207
|
</codedna_generators>
|
|
181
208
|
|
|
182
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)
|
|
@@ -131,6 +133,38 @@ function buildStandardsSection() {
|
|
|
131
133
|
- Include file paths with line numbers in references
|
|
132
134
|
</formatting>
|
|
133
135
|
|
|
136
|
+
<documentation_files priority="MANDATORY">
|
|
137
|
+
NEVER create .md files in random locations. Follow these rules:
|
|
138
|
+
|
|
139
|
+
DIRECTORY STRUCTURE:
|
|
140
|
+
- docs/ → Project documentation, guides, specs
|
|
141
|
+
- docs/research/ → Research notes, analysis, investigations
|
|
142
|
+
- docs/decisions/ → Architecture Decision Records (ADRs)
|
|
143
|
+
- CHANGELOG.md → Only in project root
|
|
144
|
+
- README.md → Only in project root or package roots
|
|
145
|
+
|
|
146
|
+
NAMING CONVENTIONS:
|
|
147
|
+
- Use lowercase with hyphens: user-authentication-guide.md
|
|
148
|
+
- NEVER use spaces or underscores in filenames
|
|
149
|
+
- Include date prefix for time-sensitive docs: YYYY-MM-DD-topic.md
|
|
150
|
+
Example: 2025-12-05-api-migration-plan.md
|
|
151
|
+
- Research docs: YYYY-MM-DD-research-topic.md
|
|
152
|
+
- Decision records: NNNN-decision-title.md (e.g., 0001-use-jwt-auth.md)
|
|
153
|
+
|
|
154
|
+
ANTI-PATTERNS (NEVER DO):
|
|
155
|
+
- Creating PLAN.md, NOTES.md, TODO.md in project root
|
|
156
|
+
- Random capitalised filenames like IMPLEMENTATION_GUIDE.md
|
|
157
|
+
- Nested docs in src/ or lib/ directories
|
|
158
|
+
- Multiple README files outside package roots
|
|
159
|
+
- Temporary docs without dates (impossible to clean up later)
|
|
160
|
+
|
|
161
|
+
BEFORE CREATING ANY .md FILE:
|
|
162
|
+
1. Check if docs/ directory exists - create if needed
|
|
163
|
+
2. Determine correct subdirectory (research/, decisions/, etc.)
|
|
164
|
+
3. Use proper naming convention with date if temporal
|
|
165
|
+
4. Ask user if uncertain about placement
|
|
166
|
+
</documentation_files>
|
|
167
|
+
|
|
134
168
|
<completion_summary>
|
|
135
169
|
When calling task_complete, include:
|
|
136
170
|
- Implementation: What you built/changed
|
|
@@ -145,16 +179,12 @@ function buildDomainSection(worker) {
|
|
|
145
179
|
return `<!-- Layer 4: Domain Knowledge -->
|
|
146
180
|
<domain_knowledge>
|
|
147
181
|
<codedna_capabilities>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
2. codedna_validate_spec(spec)
|
|
156
|
-
- Validates Entity DSL syntax before generation
|
|
157
|
-
- 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
|
|
158
188
|
|
|
159
189
|
ENTITY DSL FORMAT:
|
|
160
190
|
EntityName(field:type:constraint, field:type:constraint, ...)
|
|
@@ -165,20 +195,15 @@ function buildDomainSection(worker) {
|
|
|
165
195
|
- enum(val1|val2|val3) - enumeration
|
|
166
196
|
|
|
167
197
|
CONSTRAINTS:
|
|
168
|
-
- unique
|
|
169
|
-
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
framework: "express",
|
|
178
|
-
options: { auth: true, validation: true }
|
|
179
|
-
})
|
|
180
|
-
→ Generates 6 production files in ~5 seconds
|
|
181
|
-
→ 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
|
|
182
207
|
</codedna_capabilities>
|
|
183
208
|
|
|
184
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
|
}
|