@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.
Files changed (85) hide show
  1. package/dist/cli.js +9 -1
  2. package/dist/codedna/__tests__/examples/mongoose-example.d.ts +6 -0
  3. package/dist/codedna/__tests__/examples/mongoose-example.js +163 -0
  4. package/dist/codedna/__tests__/fixtures/typeorm-production-test.d.ts +1 -0
  5. package/dist/codedna/__tests__/fixtures/typeorm-production-test.js +231 -0
  6. package/dist/codedna/__tests__/fixtures/typeorm-test.d.ts +1 -0
  7. package/dist/codedna/__tests__/fixtures/typeorm-test.js +124 -0
  8. package/dist/codedna/__tests__/laravel-output-review.d.ts +1 -0
  9. package/dist/codedna/__tests__/laravel-output-review.js +249 -0
  10. package/dist/codedna/__tests__/mongoose-output-test.d.ts +1 -0
  11. package/dist/codedna/__tests__/mongoose-output-test.js +178 -0
  12. package/dist/codedna/examples/radix-example.d.ts +2 -0
  13. package/dist/codedna/examples/radix-example.js +259 -0
  14. package/dist/codedna/index.d.ts +5 -3
  15. package/dist/codedna/index.js +6 -3
  16. package/dist/codedna/kappa-ast.d.ts +143 -5
  17. package/dist/codedna/kappa-drizzle-generator.js +8 -5
  18. package/dist/codedna/kappa-gofiber-generator.d.ts +65 -0
  19. package/dist/codedna/kappa-gofiber-generator.js +587 -0
  20. package/dist/codedna/kappa-laravel-generator.d.ts +68 -0
  21. package/dist/codedna/kappa-laravel-generator.js +741 -0
  22. package/dist/codedna/kappa-lexer.d.ts +44 -0
  23. package/dist/codedna/kappa-lexer.js +124 -0
  24. package/dist/codedna/kappa-mantine-generator.d.ts +65 -0
  25. package/dist/codedna/kappa-mantine-generator.js +518 -0
  26. package/dist/codedna/kappa-mongoose-generator.d.ts +44 -0
  27. package/dist/codedna/kappa-mongoose-generator.js +442 -0
  28. package/dist/codedna/kappa-parser.d.ts +43 -1
  29. package/dist/codedna/kappa-parser.js +601 -0
  30. package/dist/codedna/kappa-radix-generator.d.ts +61 -0
  31. package/dist/codedna/kappa-radix-generator.js +566 -0
  32. package/dist/codedna/kappa-typeorm-generator.d.ts +59 -0
  33. package/dist/codedna/kappa-typeorm-generator.js +723 -0
  34. package/dist/codedna/kappa-vitest-generator.d.ts +85 -0
  35. package/dist/codedna/kappa-vitest-generator.js +739 -0
  36. package/dist/codedna/parser.js +26 -1
  37. package/dist/codegen/cloud-client.d.ts +160 -0
  38. package/dist/codegen/cloud-client.js +195 -0
  39. package/dist/codegen/codegen-tool.d.ts +35 -0
  40. package/dist/codegen/codegen-tool.js +312 -0
  41. package/dist/codegen/field-inference.d.ts +24 -0
  42. package/dist/codegen/field-inference.js +101 -0
  43. package/dist/codegen/form-parser.d.ts +13 -0
  44. package/dist/codegen/form-parser.js +186 -0
  45. package/dist/codegen/index.d.ts +2 -0
  46. package/dist/codegen/index.js +4 -0
  47. package/dist/codegen/natural-parser.d.ts +50 -0
  48. package/dist/codegen/natural-parser.js +769 -0
  49. package/dist/handlers/codedna-handlers.d.ts +1 -1
  50. package/dist/handlers/codegen-handlers.d.ts +20 -0
  51. package/dist/handlers/codegen-handlers.js +60 -0
  52. package/dist/handlers/kappa-handlers.d.ts +97 -0
  53. package/dist/handlers/kappa-handlers.js +408 -0
  54. package/dist/handlers/tool-handlers.js +124 -221
  55. package/dist/helpers/api-client.js +48 -3
  56. package/dist/helpers/compact-formatter.d.ts +9 -2
  57. package/dist/helpers/compact-formatter.js +26 -2
  58. package/dist/helpers/config.d.ts +7 -2
  59. package/dist/helpers/config.js +25 -10
  60. package/dist/helpers/session-validation.d.ts +1 -1
  61. package/dist/helpers/session-validation.js +2 -4
  62. package/dist/helpers/tasks.d.ts +21 -0
  63. package/dist/helpers/tasks.js +52 -0
  64. package/dist/helpers/workers.d.ts +1 -1
  65. package/dist/helpers/workers.js +19 -19
  66. package/dist/setup.d.ts +1 -0
  67. package/dist/setup.js +49 -16
  68. package/dist/templates/claude-md.d.ts +1 -1
  69. package/dist/templates/claude-md.js +37 -152
  70. package/dist/templates/orchestrator-prompt.d.ts +2 -2
  71. package/dist/templates/orchestrator-prompt.js +31 -38
  72. package/dist/templates/self-critique.d.ts +50 -0
  73. package/dist/templates/self-critique.js +209 -0
  74. package/dist/templates/worker-prompt.d.ts +3 -3
  75. package/dist/templates/worker-prompt.js +18 -18
  76. package/dist/tools.js +77 -413
  77. package/docs/codedna/generator-testing-summary.md +205 -0
  78. package/docs/codedna/radix-ui-generator.md +478 -0
  79. package/docs/kappa-gofiber-generator.md +274 -0
  80. package/docs/kappa-laravel-fixes.md +172 -0
  81. package/docs/kappa-mongoose-generator.md +322 -0
  82. package/docs/kappa-vitest-generator.md +337 -0
  83. package/package.json +1 -1
  84. package/dist/context/deduplication.test.d.ts +0 -6
  85. package/dist/context/deduplication.test.js +0 -84
@@ -142,6 +142,27 @@ export declare const LOCK_DURATION_BY_EFFORT: {
142
142
  readonly xl: 240;
143
143
  };
144
144
  export declare const DEFAULT_CAPACITY_BUDGET = 20;
145
+ /**
146
+ * Workflow violation types for enforcement
147
+ */
148
+ export interface WorkflowViolation {
149
+ type: 'no_active_task' | 'no_task_plan' | 'task_not_started';
150
+ message: string;
151
+ severity: 'warning' | 'error';
152
+ }
153
+ /**
154
+ * Get the active task for a specific agent (if any)
155
+ * Returns the task that is currently claimed by this agent
156
+ */
157
+ export declare function getActiveTaskForAgent(userId: string, projectId: string, agentId: string): Promise<Task | null>;
158
+ /**
159
+ * Check workflow compliance and return any violations
160
+ * Call this before completing significant work to ensure proper workflow was followed
161
+ */
162
+ export declare function checkWorkflowCompliance(userId: string, projectId: string, agentId: string, context?: {
163
+ isCompletingTask?: boolean;
164
+ taskId?: string;
165
+ }): Promise<WorkflowViolation[]>;
145
166
  /**
146
167
  * Get effort-weighted load of currently active tasks
147
168
  * Returns both in_progress and claimed (locked) task counts, plus effort-weighted load
@@ -112,6 +112,58 @@ export const LOCK_DURATION_BY_EFFORT = {
112
112
  // Configuration: Default capacity budget in effort units
113
113
  // 20 units allows: 20 xs tasks OR 1 xl + 1 m task OR 5 m tasks, etc.
114
114
  export const DEFAULT_CAPACITY_BUDGET = 20;
115
+ /**
116
+ * Get the active task for a specific agent (if any)
117
+ * Returns the task that is currently claimed by this agent
118
+ */
119
+ export async function getActiveTaskForAgent(userId, projectId, agentId) {
120
+ const result = await listTasks(userId, projectId, {
121
+ status: 'in_progress',
122
+ assigned_to: agentId,
123
+ limit: 1,
124
+ });
125
+ if (!result.success || result.data.length === 0) {
126
+ return null;
127
+ }
128
+ // Check if the lock is still valid
129
+ const task = result.data[0];
130
+ if (task.lock_expires_at) {
131
+ const lockExpires = new Date(task.lock_expires_at);
132
+ if (lockExpires > new Date()) {
133
+ return task;
134
+ }
135
+ }
136
+ return null;
137
+ }
138
+ /**
139
+ * Check workflow compliance and return any violations
140
+ * Call this before completing significant work to ensure proper workflow was followed
141
+ */
142
+ export async function checkWorkflowCompliance(userId, projectId, agentId, context = {}) {
143
+ const violations = [];
144
+ // Check 1: Is there an active task for this agent?
145
+ const activeTask = await getActiveTaskForAgent(userId, projectId, agentId);
146
+ if (!activeTask && !context.isCompletingTask) {
147
+ violations.push({
148
+ type: 'no_active_task',
149
+ message: '⚠️ No active task. Use task_start before beginning work.',
150
+ severity: 'warning',
151
+ });
152
+ }
153
+ // Check 2: If completing a task, was it properly started?
154
+ if (context.isCompletingTask && context.taskId) {
155
+ // We'll just note if the task wasn't claimed - the handler already handles this
156
+ // by auto-claiming, but we can still warn about the pattern
157
+ if (!activeTask || activeTask.id !== context.taskId) {
158
+ violations.push({
159
+ type: 'task_not_started',
160
+ message: '⚠️ Task was not started with task_start. Consider using proper workflow.',
161
+ severity: 'warning',
162
+ });
163
+ }
164
+ }
165
+ return violations;
166
+ }
115
167
  /**
116
168
  * Get effort-weighted load of currently active tasks
117
169
  * Returns both in_progress and claimed (locked) task counts, plus effort-weighted load
@@ -14,7 +14,7 @@ export declare const EXPERT_WORKERS: Record<string, ExpertWorker>;
14
14
  *
15
15
  * This function uses the new template system that includes:
16
16
  * - XML semantic boundaries for machine-parseable structure
17
- * - CodeDNA integration instructions (95-99% token savings for CRUD)
17
+ * - Codegen integration instructions (95-99% token savings for CRUD)
18
18
  * - Tool usage priorities (memory_search, codebase_find before writing)
19
19
  * - Tier-based complexity (minimal/standard/professional)
20
20
  *
@@ -2,10 +2,10 @@
2
2
  // Expert Worker Definitions (Orchestration System)
3
3
  // =============================================================================
4
4
  //
5
- // Updated with 10/10 AI System Prompt Architecture and CodeDNA integration.
6
- // Workers now know to use CodeDNA generators before writing boilerplate code.
5
+ // Updated with 10/10 AI System Prompt Architecture.
6
+ // Workers know to use codegen before writing boilerplate code.
7
7
  //
8
- import { buildWorkerPromptWithCodeDNA, } from '../templates/worker-prompt.js';
8
+ import { buildWorkerPrompt as templateBuildWorkerPrompt, } from '../templates/worker-prompt.js';
9
9
  export const EXPERT_WORKERS = {
10
10
  'schema-expert': {
11
11
  id: 'schema-expert',
@@ -19,7 +19,7 @@ export const EXPERT_WORKERS = {
19
19
  - Index optimisation
20
20
  - Data modelling decisions
21
21
 
22
- CODEDNA: If task includes Entity DSL (e.g., "User(email:string:unique)"),
22
+ CODEGEN: If task includes Entity DSL (e.g., "User(email:string:unique)"),
23
23
  the API layer will be generated automatically. Focus only on SQL schema.
24
24
 
25
25
  Focus only on schema-related changes. Do not modify application code.
@@ -38,15 +38,15 @@ When complete, provide a concise summary of changes made.`,
38
38
  - Error handling for endpoints
39
39
 
40
40
  PATTERN DETECTION (for existing projects):
41
- 1. Call codedna_detect_patterns(package_json) to find existing patterns
41
+ 1. Check package.json for existing patterns
42
42
  2. MATCH detected patterns - don't introduce conflicting libraries
43
43
  3. Check for: zod vs yup validation, tanstack-query vs swr, etc.
44
44
 
45
- CODEDNA PRIORITY: Before writing CRUD code manually:
46
- 1. Call codedna_list_generators() to discover available generators
45
+ CODEGEN PRIORITY: Before writing CRUD code manually:
46
+ 1. Call codegen_list() to discover available generators
47
47
  2. Look for Entity DSL in task (e.g., "User(email:string:unique, password:string:hashed)")
48
48
  3. Detect framework from project (check package.json, existing patterns)
49
- 4. Call codedna_generate_api(spec, framework="<detected>", options={...})
49
+ 4. Call codegen({ describe: "...", generate: [...], stack: {...} })
50
50
  5. Only write manually for complex business logic that can't be generated
51
51
 
52
52
  Focus only on API-related changes. Do not modify schema or extraction code.
@@ -119,20 +119,20 @@ When complete, provide a concise summary of integrations configured.`,
119
119
  - Client-side state management
120
120
 
121
121
  PATTERN DETECTION (CRITICAL for existing projects):
122
- 1. Call codedna_detect_patterns(package_json) to detect existing patterns
122
+ 1. Check package.json to detect existing patterns
123
123
  2. RESPECT detected patterns - consistency > "better":
124
124
  - Compound components? Use compound pattern
125
125
  - React Hook Form? Don't introduce Formik
126
126
  - Zustand? Don't add Redux
127
127
  - Tailwind? Match styling approach
128
- 3. Check codedna_list_patterns(category="anti-patterns") for code smells to avoid
128
+ 3. Check for common anti-patterns
129
129
 
130
- CODEDNA PRIORITY: Before writing UI components manually:
131
- 1. Call codedna_list_generators() to discover available generators
130
+ CODEGEN PRIORITY: Before writing UI components manually:
131
+ 1. Call codegen_list() to discover available generators
132
132
  2. Detect UI framework from project (check package.json for react, vue, etc.)
133
133
  3. Check for UI library (package.json: @shadcn/ui, @mui/material, @chakra-ui, etc.)
134
- 4. Call codedna_generate_frontend or codedna_generate_component with detected settings
135
- 5. DO NOT assume any specific framework/library - discover via list_generators, detect from project
134
+ 4. Call codegen({ describe: "...", generate: ["components"], stack: {...} })
135
+ 5. DO NOT assume any specific framework/library - discover via codegen_list, detect from project
136
136
 
137
137
  TOOLS: Use codebase_find to discover existing component patterns.
138
138
  TOOLS: Use memory_search for past UI decisions.
@@ -148,8 +148,8 @@ When complete, provide a concise summary of components created.`,
148
148
  capabilities: ['general-development', 'refactoring', 'documentation', 'testing'],
149
149
  promptTemplate: `You are a general purpose development expert.
150
150
 
151
- CODEDNA - DISCOVER THEN DETECT:
152
- 1. Call codedna_list_generators() to see what's available
151
+ CODEGEN - DISCOVER THEN DETECT:
152
+ 1. Call codegen_list() to see what's available
153
153
  2. Detect project framework from package.json/pyproject.toml
154
154
  3. Match detected framework to generator capabilities
155
155
  4. If no match, ASK the user which framework to use
@@ -170,7 +170,7 @@ When complete, provide a concise summary of work done.`,
170
170
  *
171
171
  * This function uses the new template system that includes:
172
172
  * - XML semantic boundaries for machine-parseable structure
173
- * - CodeDNA integration instructions (95-99% token savings for CRUD)
173
+ * - Codegen integration instructions (95-99% token savings for CRUD)
174
174
  * - Tool usage priorities (memory_search, codebase_find before writing)
175
175
  * - Tier-based complexity (minimal/standard/professional)
176
176
  *
@@ -189,8 +189,8 @@ export function buildWorkerPrompt(params, tier = 'standard') {
189
189
  content: ctx.content,
190
190
  source: ctx.source,
191
191
  }));
192
- // Use the new 10/10 template system
193
- return buildWorkerPromptWithCodeDNA({
192
+ // Use the 10/10 template system
193
+ return templateBuildWorkerPrompt({
194
194
  task: {
195
195
  id: task.id,
196
196
  title: task.title,
package/dist/setup.d.ts CHANGED
@@ -2,3 +2,4 @@ export declare function runSetup(): Promise<void>;
2
2
  export declare function runUninstall(): Promise<void>;
3
3
  export declare function runInit(): Promise<void>;
4
4
  export declare function runCleanup(): Promise<void>;
5
+ export declare function runOnboard(): Promise<void>;
package/dist/setup.js CHANGED
@@ -1040,31 +1040,33 @@ docs_cache({ library: "tanstack-query" })
1040
1040
 
1041
1041
  This enables future sessions to reference up-to-date documentation.
1042
1042
 
1043
- ### Code Generation Tools
1043
+ ### Code Generation
1044
1044
 
1045
- **IMPORTANT**: When the project involves APIs, frontends, or full-stack development, inform the user about available code generation tools that can save 95%+ tokens:
1045
+ **IMPORTANT**: When the project involves APIs or data models, use the \`codegen\` tool to save 95%+ tokens:
1046
1046
 
1047
- **Kappa v2.5** - For full-stack applications:
1048
- - Use when: Multiple entities, pages, forms, API routes
1049
- - Tools: \`kappa_parse\`, \`kappa_generate_all\`, \`kappa_generate_schema\`, etc.
1050
- - Generates: Drizzle schemas, Zod validators, API routes, pages, forms, design tokens
1047
+ \`\`\`typescript
1048
+ codegen({ describe: "User with email, password, role (admin/user)" })
1049
+ \`\`\`
1051
1050
 
1052
- **CodeDNA** - For individual components:
1053
- - Use when: Single entity, specific component, or targeted generation
1054
- - Tools: \`codedna_generate_api\`, \`codedna_generate_frontend\`, \`codedna_generate_component\`
1055
- - Supports: Express, FastAPI, NestJS, Hono, React, Vue, SvelteKit
1051
+ **What it generates:**
1052
+ - Drizzle schema (database tables)
1053
+ - TypeScript types
1054
+ - Zod validators
1055
+ - API routes (Hono/Express)
1056
1056
 
1057
- During onboarding, if the user is building:
1058
- - **Full-stack app with multiple entities** Suggest Kappa: "For your Next.js app with User, Task, and Project entities, I can use Kappa to generate your entire backend and frontend from a compact spec. Would you like to see an example?"
1059
- - **Single API or component** Suggest CodeDNA: "For this API, I can use CodeDNA to generate the routes, validation, and types. This saves significant time and tokens."
1057
+ **Smart field inference:**
1058
+ - \`email\`email type, \`password\` hashed, \`createdAt\` timestamp
1059
+ - \`price\`decimal, \`isActive\` boolean, \`(admin/user)\` enum
1060
+
1061
+ Stack is auto-detected from package.json (Drizzle, Hono, Express, etc.)
1060
1062
 
1061
1063
  Store code generation preferences:
1062
1064
  \`\`\`typescript
1063
1065
  memory_store_fact({
1064
1066
  entity1: "ProjectName",
1065
- relationship: "PREFERS",
1066
- entity2: "Kappa",
1067
- context: "User prefers Kappa for full-stack generation"
1067
+ relationship: "USES",
1068
+ entity2: "codegen",
1069
+ context: "Project uses codegen for schema/types/validators generation"
1068
1070
  })
1069
1071
  \`\`\`
1070
1072
 
@@ -2033,3 +2035,34 @@ export async function runCleanup() {
2033
2035
  console.log('\n' + chalk.green(' Cleanup complete!'));
2034
2036
  console.log(chalk.dim(' Restart Claude Code for changes to take effect.\n'));
2035
2037
  }
2038
+ // -----------------------------------------------------------------------------
2039
+ // Onboard Command (standalone)
2040
+ // -----------------------------------------------------------------------------
2041
+ export async function runOnboard() {
2042
+ const cwd = process.cwd();
2043
+ const projectName = basename(cwd);
2044
+ // Load config
2045
+ const config = await loadConfigFromFile();
2046
+ if (!config?.apiKey) {
2047
+ error('Not configured. Run: claudetools --setup');
2048
+ process.exit(1);
2049
+ }
2050
+ const apiUrl = config.apiUrl || DEFAULT_CONFIG.apiUrl;
2051
+ const apiKey = config.apiKey;
2052
+ // Find project for current directory
2053
+ if (!existsSync(PROJECTS_FILE)) {
2054
+ error('No projects registered. Run: claudetools init');
2055
+ process.exit(1);
2056
+ }
2057
+ const projectsData = JSON.parse(readFileSync(PROJECTS_FILE, 'utf-8'));
2058
+ const binding = projectsData.bindings?.find((b) => b.local_path === cwd);
2059
+ if (!binding) {
2060
+ error('Current directory is not a registered project.');
2061
+ info('Run: claudetools init');
2062
+ process.exit(1);
2063
+ }
2064
+ const projectId = binding.project_id;
2065
+ const displayName = binding.project_name || projectName;
2066
+ // Run the onboarding flow
2067
+ await runOnboarding(apiUrl, apiKey, projectId, displayName);
2068
+ }
@@ -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. **Context is AUTO-INJECTED via hooks** - you rarely need to call memory tools explicitly.\n\n## \u26A0\uFE0F IMPORTANT: Hooks vs MCP Tools\n\n**AUTOMATIC (via hooks - zero context cost):**\n- Context injection \u2192 `user-prompt-submit` hook runs on every message\n- Fact extraction \u2192 `post-tool-use` hook extracts from your work\n- Session context \u2192 `session-start` hook provides initial context\n\n**EXPLICIT (MCP tools - costs context):**\n- `memory_store_fact` \u2192 Store a specific fact you learned\n- `task_plan` / `task_start` / `task_complete` \u2192 Task management\n\n**DO NOT CALL these tools routinely (context already injected):**\n- `memory_search` - only if you need DIFFERENT search params\n- `memory_inject` - only if you need to refresh for a different query\n- `memory_get_context` - only for debugging\n- `memory_index` - only for debugging\n\n## Storing Facts (DO use this)\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 when you learn something concrete. The `post-tool-use` hook also extracts facts automatically.\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### Start with codebase_map() - ALWAYS\n```\ncodebase_map() # FIRST TOOL when exploring unfamiliar code\n```\n**When to use:** Starting a new task, exploring unfamiliar code, understanding project structure, finding entry points.\n\nThe map shows:\n- Project structure and key directories\n- Entry points and their exports\n- Framework detection (React, Express, etc.)\n- Key symbols and their locations\n\n**Use codebase_map BEFORE using Grep/Glob** - it gives you the lay of the land so you know where to look.\n\n### Then use targeted tools\n```\ncodebase_find(\"UserService\") # Find specific symbols/files\ncodebase_context(\"src/auth.ts\") # Get file dependencies\nanalyze_impact(\"validateToken\") # See what changing a function affects\n```\n\n## CodeDNA: Generate Code, Save 99% Tokens\n\n**BEFORE writing ANY code, check if CodeDNA can generate it.** Call `codedna_list_generators()` to see available generators.\n\n### Available Generators (20+)\n\n| Category | Frameworks | Tool |\n|----------|------------|------|\n| **API** | Express, FastAPI, NestJS, Hono, Elysia, tRPC | `codedna_generate_api` |\n| **Frontend** | React, Vue, SvelteKit, Astro, React Router v7, TanStack Start | `codedna_generate_frontend` |\n| **ORM** | Prisma, Drizzle | `codedna_generate_api` with database option |\n| **Auth** | Better Auth, Auth.js, Lucia | `codedna_generate_api` with auth option |\n| **Components** | Forms, Tables, Cards, Modals (React/Vue/Svelte) | `codedna_generate_component` |\n\n### Usage Examples\n\n```typescript\n// API with auth and validation\ncodedna_generate_api({\n spec: \"User(email:string:unique, password:string:hashed)\",\n framework: \"express\", // or: fastapi, nestjs, hono, elysia, trpc\n options: { auth: true, validation: true, tests: true }\n})\n\n// Frontend with forms and data fetching\ncodedna_generate_frontend({\n spec: \"User(email:string, name:string, role:enum(admin,user))\",\n framework: \"react\", // or: vue, nextjs, sveltekit, astro\n options: { forms: true, tables: true, ui: \"shadcn\" }\n})\n\n// Single component\ncodedna_generate_component({\n spec: \"Product(name:string, price:decimal, inStock:boolean)\",\n type: \"form\", // or: table, card, modal\n framework: \"react\",\n options: { validation: true, ui: \"shadcn\" }\n})\n```\n\n### Entity DSL Quick Reference\n\n```\nEntityName(field:type:modifier, field2:type:modifier)\n\nTypes: string, integer, decimal, boolean, datetime, text, json\nModifiers: unique, required, optional, hashed, email, min(n), max(n), default(v)\nRelations: userId:User (reference), posts:Post[] (array)\nEnums: role:enum(admin,user,guest)\n```\n\n**Token savings:** 30,000 tokens \u2192 200 tokens (99% reduction per generation)\n\n## Kappa v2.5: Declarative Full-Stack Generation\n\n**For even higher-level generation**, use Kappa DSL - a declarative specification language that generates complete applications from compact specs.\n\n### When to Use Kappa vs CodeDNA\n\n| Use Case | Tool |\n|----------|------|\n| Single entity/component | CodeDNA (`codedna_generate_*`) |\n| Full application with multiple entities | Kappa (`kappa_generate_all`) |\n| Pages, forms, routing together | Kappa |\n| Design system + components | Kappa |\n\n### Kappa Tools\n\n| Tool | Purpose |\n|------|---------|\n| `kappa_parse` | Parse and validate Kappa spec |\n| `kappa_generate_schema` | Generate Drizzle schema + Zod + types |\n| `kappa_generate_api` | Generate API routes (Hono/Express/tRPC) |\n| `kappa_generate_pages` | Generate pages (TanStack Start/Next.js) |\n| `kappa_generate_forms` | Generate forms (React Hook Form + Zod + shadcn) |\n| `kappa_generate_components` | Generate React components (compound, forwardRef) |\n| `kappa_generate_design` | Generate CSS variables + Tailwind config |\n| `kappa_generate_all` | Generate complete full-stack application |\n\n### Kappa DSL Example\n\n```\n// Complete app specification in ~50 lines\nproject TaskManager {\n database postgres\n framework tanstack-start\n}\n\nentity Task {\n title string required max(100)\n description text\n status enum(todo, in_progress, done) default(todo)\n dueDate datetime\n assignee User\n}\n\nentity User {\n email string unique email\n name string required\n tasks Task[]\n}\n\napi /tasks {\n GET / -> list Task[]\n POST / -> create Task\n GET /:id -> get Task\n PUT /:id -> update Task\n DELETE /:id -> delete Task\n}\n\npage /tasks {\n layout dashboard\n load tasks from /api/tasks\n components [TaskList, TaskForm]\n}\n\nform TaskForm for Task {\n fields [title, description, status, dueDate]\n submit POST /api/tasks\n}\n\ndesign {\n colors {\n primary #3B82F6\n secondary #6B7280\n }\n typography {\n fontFamily \"Inter\"\n scale { sm: \"0.875rem\", base: \"1rem\", lg: \"1.125rem\" }\n }\n}\n```\n\n### Usage\n\n```typescript\n// Generate everything from spec\nkappa_generate_all({\n spec: `project MyApp { ... }`,\n options: {\n framework: \"tanstack-start\",\n ui: \"shadcn\",\n dbDialect: \"postgres\"\n }\n})\n\n// Or generate incrementally\nkappa_parse({ spec: \"...\" }) // Validate first\nkappa_generate_schema({ spec: \"...\", outputs: [\"drizzle\", \"zod\", \"types\"] })\nkappa_generate_api({ spec: \"...\", framework: \"hono\" })\nkappa_generate_pages({ spec: \"...\", framework: \"tanstack-start\" })\n```\n\n**Token savings:** ~50 lines of Kappa \u2192 thousands of lines of production code (95%+ reduction)\n\n## Best Practices\n\n1. **Trust auto-injection** - Context is injected automatically, don't call memory_search\n2. **Store decisions** - Use `memory_store_fact` for architectural choices\n3. **Use task tracking** - Break complex work into tasks\n4. **Use Kappa for full apps** - For multi-entity apps with pages/forms, use `kappa_generate_all`\n5. **Use CodeDNA for single components** - For individual entities or components, use `codedna_generate_*`\n6. **Minimize tool calls** - Every MCP call costs context tokens\n<!-- CLAUDETOOLS:END -->\n";
8
+ export declare const GLOBAL_TEMPLATE = "\n<!-- CLAUDETOOLS:START -->\n# ClaudeTools Memory System\n\nYou have access to a persistent memory system. **Context is AUTO-INJECTED via hooks** - you rarely need to call memory tools explicitly.\n\n## \u26A0\uFE0F IMPORTANT: Hooks vs MCP Tools\n\n**AUTOMATIC (via hooks - zero context cost):**\n- Context injection \u2192 `user-prompt-submit` hook runs on every message\n- Fact extraction \u2192 `post-tool-use` hook extracts from your work\n- Session context \u2192 `session-start` hook provides initial context\n\n**EXPLICIT (MCP tools - costs context):**\n- `memory_store_fact` \u2192 Store a specific fact you learned\n- `task_plan` / `task_start` / `task_complete` \u2192 Task management\n\n**DO NOT CALL these tools routinely (context already injected):**\n- `memory_search` - only if you need DIFFERENT search params\n- `memory_inject` - only if you need to refresh for a different query\n- `memory_get_context` - only for debugging\n- `memory_index` - only for debugging\n\n## Storing Facts (DO use this)\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 when you learn something concrete. The `post-tool-use` hook also extracts facts automatically.\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### Start with codebase_map() - ALWAYS\n```\ncodebase_map() # FIRST TOOL when exploring unfamiliar code\n```\n**When to use:** Starting a new task, exploring unfamiliar code, understanding project structure, finding entry points.\n\nThe map shows:\n- Project structure and key directories\n- Entry points and their exports\n- Framework detection (React, Express, etc.)\n- Key symbols and their locations\n\n**Use codebase_map BEFORE using Grep/Glob** - it gives you the lay of the land so you know where to look.\n\n### Then use targeted tools\n```\ncodebase_find(\"UserService\") # Find specific symbols/files\ncodebase_context(\"src/auth.ts\") # Get file dependencies\nanalyze_impact(\"validateToken\") # See what changing a function affects\n```\n\n## Code Generation (saves 95-99% tokens)\n\n**ALWAYS use `codegen` instead of writing boilerplate.** One line of natural language \u2192 10+ production files.\n\n### Quick Reference\n\n```typescript\n// Entities \u2192 schema + types + validators + API + tests\ncodegen({ describe: \"User with email, password, role (admin/user)\" })\ncodegen({ describe: \"Post with title, content, belongs to User as author\" })\n\n// Forms \u2192 React Hook Form + Zod + shadcn inputs\ncodegen({ describe: \"Login form with email, password, submit to /auth/login\" })\n\n// Components \u2192 Radix/shadcn with variants\ncodegen({ describe: \"Button with label, onClick, variant (primary/secondary)\" })\n\n// Pages \u2192 TanStack Start or Next.js routes\ncodegen({ describe: \"Dashboard page at /dashboard, requires auth, loads User\" })\n\n// Generate specific outputs\ncodegen({ describe: \"User with email\", generate: ['schema', 'types'] })\ncodegen({ describe: \"User with email\", generate: ['tests'] })\ncodegen({ describe: \"User with email\", generate: ['all'] }) // everything\n```\n\n### What It Generates\n| Type | Output Files |\n|------|-------------|\n| Entity | schema.ts, types.ts, validators.ts, routes.ts |\n| Tests | *.test.ts, *.factory.ts, *.mock.ts |\n| Form | *-form.tsx (RHF + Zod + shadcn) |\n| Component | *.tsx (Radix primitives + Tailwind) |\n| Page | route.tsx (loaders, guards, layouts) |\n\n### Smart Inference\n- Field names \u2192 types: `email` \u2192 email, `password` \u2192 hashed, `price` \u2192 decimal\n- Enums: `role (admin/user)` \u2192 enum type\n- Relationships: `belongs to User as author` \u2192 foreign key + relation\n- Forms: `email` \u2192 email input, `message` \u2192 textarea\n- Pages: `requires auth` \u2192 guard, `loads User` \u2192 data loader\n\n## Best Practices\n\n1. **Trust auto-injection** - Context is injected automatically, don't call memory_search\n2. **Store decisions** - Use `memory_store_fact` for architectural choices\n3. **Use task tracking** - Break complex work into tasks\n4. **Use codegen for boilerplate** - Generate schemas, types, validators, routes\n5. **Minimize tool calls** - Every MCP call costs context tokens\n<!-- CLAUDETOOLS:END -->\n";
9
9
  /**
10
10
  * Project-level CLAUDE.md content - added to .claude/CLAUDE.md
11
11
  */
@@ -102,169 +102,55 @@ codebase_context("src/auth.ts") # Get file dependencies
102
102
  analyze_impact("validateToken") # See what changing a function affects
103
103
  \`\`\`
104
104
 
105
- ## CodeDNA: Generate Code, Save 99% Tokens
105
+ ## Code Generation (saves 95-99% tokens)
106
106
 
107
- **BEFORE writing ANY code, check if CodeDNA can generate it.** Call \`codedna_list_generators()\` to see available generators.
107
+ **ALWAYS use \`codegen\` instead of writing boilerplate.** One line of natural language 10+ production files.
108
108
 
109
- ### Available Generators (20+)
110
-
111
- | Category | Frameworks | Tool |
112
- |----------|------------|------|
113
- | **API** | Express, FastAPI, NestJS, Hono, Elysia, tRPC | \`codedna_generate_api\` |
114
- | **Frontend** | React, Vue, SvelteKit, Astro, React Router v7, TanStack Start | \`codedna_generate_frontend\` |
115
- | **ORM** | Prisma, Drizzle | \`codedna_generate_api\` with database option |
116
- | **Auth** | Better Auth, Auth.js, Lucia | \`codedna_generate_api\` with auth option |
117
- | **Components** | Forms, Tables, Cards, Modals (React/Vue/Svelte) | \`codedna_generate_component\` |
118
-
119
- ### Usage Examples
109
+ ### Quick Reference
120
110
 
121
111
  \`\`\`typescript
122
- // API with auth and validation
123
- codedna_generate_api({
124
- spec: "User(email:string:unique, password:string:hashed)",
125
- framework: "express", // or: fastapi, nestjs, hono, elysia, trpc
126
- options: { auth: true, validation: true, tests: true }
127
- })
128
-
129
- // Frontend with forms and data fetching
130
- codedna_generate_frontend({
131
- spec: "User(email:string, name:string, role:enum(admin,user))",
132
- framework: "react", // or: vue, nextjs, sveltekit, astro
133
- options: { forms: true, tables: true, ui: "shadcn" }
134
- })
135
-
136
- // Single component
137
- codedna_generate_component({
138
- spec: "Product(name:string, price:decimal, inStock:boolean)",
139
- type: "form", // or: table, card, modal
140
- framework: "react",
141
- options: { validation: true, ui: "shadcn" }
142
- })
143
- \`\`\`
144
-
145
- ### Entity DSL Quick Reference
146
-
147
- \`\`\`
148
- EntityName(field:type:modifier, field2:type:modifier)
149
-
150
- Types: string, integer, decimal, boolean, datetime, text, json
151
- Modifiers: unique, required, optional, hashed, email, min(n), max(n), default(v)
152
- Relations: userId:User (reference), posts:Post[] (array)
153
- Enums: role:enum(admin,user,guest)
154
- \`\`\`
155
-
156
- **Token savings:** 30,000 tokens → 200 tokens (99% reduction per generation)
157
-
158
- ## Kappa v2.5: Declarative Full-Stack Generation
159
-
160
- **For even higher-level generation**, use Kappa DSL - a declarative specification language that generates complete applications from compact specs.
161
-
162
- ### When to Use Kappa vs CodeDNA
163
-
164
- | Use Case | Tool |
165
- |----------|------|
166
- | Single entity/component | CodeDNA (\`codedna_generate_*\`) |
167
- | Full application with multiple entities | Kappa (\`kappa_generate_all\`) |
168
- | Pages, forms, routing together | Kappa |
169
- | Design system + components | Kappa |
170
-
171
- ### Kappa Tools
172
-
173
- | Tool | Purpose |
174
- |------|---------|
175
- | \`kappa_parse\` | Parse and validate Kappa spec |
176
- | \`kappa_generate_schema\` | Generate Drizzle schema + Zod + types |
177
- | \`kappa_generate_api\` | Generate API routes (Hono/Express/tRPC) |
178
- | \`kappa_generate_pages\` | Generate pages (TanStack Start/Next.js) |
179
- | \`kappa_generate_forms\` | Generate forms (React Hook Form + Zod + shadcn) |
180
- | \`kappa_generate_components\` | Generate React components (compound, forwardRef) |
181
- | \`kappa_generate_design\` | Generate CSS variables + Tailwind config |
182
- | \`kappa_generate_all\` | Generate complete full-stack application |
183
-
184
- ### Kappa DSL Example
112
+ // Entities schema + types + validators + API + tests
113
+ codegen({ describe: "User with email, password, role (admin/user)" })
114
+ codegen({ describe: "Post with title, content, belongs to User as author" })
185
115
 
186
- \`\`\`
187
- // Complete app specification in ~50 lines
188
- project TaskManager {
189
- database postgres
190
- framework tanstack-start
191
- }
192
-
193
- entity Task {
194
- title string required max(100)
195
- description text
196
- status enum(todo, in_progress, done) default(todo)
197
- dueDate datetime
198
- assignee User
199
- }
200
-
201
- entity User {
202
- email string unique email
203
- name string required
204
- tasks Task[]
205
- }
206
-
207
- api /tasks {
208
- GET / -> list Task[]
209
- POST / -> create Task
210
- GET /:id -> get Task
211
- PUT /:id -> update Task
212
- DELETE /:id -> delete Task
213
- }
116
+ // Forms → React Hook Form + Zod + shadcn inputs
117
+ codegen({ describe: "Login form with email, password, submit to /auth/login" })
214
118
 
215
- page /tasks {
216
- layout dashboard
217
- load tasks from /api/tasks
218
- components [TaskList, TaskForm]
219
- }
119
+ // Components → Radix/shadcn with variants
120
+ codegen({ describe: "Button with label, onClick, variant (primary/secondary)" })
220
121
 
221
- form TaskForm for Task {
222
- fields [title, description, status, dueDate]
223
- submit POST /api/tasks
224
- }
122
+ // Pages TanStack Start or Next.js routes
123
+ codegen({ describe: "Dashboard page at /dashboard, requires auth, loads User" })
225
124
 
226
- design {
227
- colors {
228
- primary #3B82F6
229
- secondary #6B7280
230
- }
231
- typography {
232
- fontFamily "Inter"
233
- scale { sm: "0.875rem", base: "1rem", lg: "1.125rem" }
234
- }
235
- }
125
+ // Generate specific outputs
126
+ codegen({ describe: "User with email", generate: ['schema', 'types'] })
127
+ codegen({ describe: "User with email", generate: ['tests'] })
128
+ codegen({ describe: "User with email", generate: ['all'] }) // everything
236
129
  \`\`\`
237
130
 
238
- ### Usage
239
-
240
- \`\`\`typescript
241
- // Generate everything from spec
242
- kappa_generate_all({
243
- spec: \`project MyApp { ... }\`,
244
- options: {
245
- framework: "tanstack-start",
246
- ui: "shadcn",
247
- dbDialect: "postgres"
248
- }
249
- })
250
-
251
- // Or generate incrementally
252
- kappa_parse({ spec: "..." }) // Validate first
253
- kappa_generate_schema({ spec: "...", outputs: ["drizzle", "zod", "types"] })
254
- kappa_generate_api({ spec: "...", framework: "hono" })
255
- kappa_generate_pages({ spec: "...", framework: "tanstack-start" })
256
- \`\`\`
131
+ ### What It Generates
132
+ | Type | Output Files |
133
+ |------|-------------|
134
+ | Entity | schema.ts, types.ts, validators.ts, routes.ts |
135
+ | Tests | *.test.ts, *.factory.ts, *.mock.ts |
136
+ | Form | *-form.tsx (RHF + Zod + shadcn) |
137
+ | Component | *.tsx (Radix primitives + Tailwind) |
138
+ | Page | route.tsx (loaders, guards, layouts) |
257
139
 
258
- **Token savings:** ~50 lines of Kappa → thousands of lines of production code (95%+ reduction)
140
+ ### Smart Inference
141
+ - Field names → types: \`email\` → email, \`password\` → hashed, \`price\` → decimal
142
+ - Enums: \`role (admin/user)\` → enum type
143
+ - Relationships: \`belongs to User as author\` → foreign key + relation
144
+ - Forms: \`email\` → email input, \`message\` → textarea
145
+ - Pages: \`requires auth\` → guard, \`loads User\` → data loader
259
146
 
260
147
  ## Best Practices
261
148
 
262
149
  1. **Trust auto-injection** - Context is injected automatically, don't call memory_search
263
150
  2. **Store decisions** - Use \`memory_store_fact\` for architectural choices
264
151
  3. **Use task tracking** - Break complex work into tasks
265
- 4. **Use Kappa for full apps** - For multi-entity apps with pages/forms, use \`kappa_generate_all\`
266
- 5. **Use CodeDNA for single components** - For individual entities or components, use \`codedna_generate_*\`
267
- 6. **Minimize tool calls** - Every MCP call costs context tokens
152
+ 4. **Use codegen for boilerplate** - Generate schemas, types, validators, routes
153
+ 5. **Minimize tool calls** - Every MCP call costs context tokens
268
154
  ${SECTION_END}
269
155
  `;
270
156
  /**
@@ -297,12 +183,11 @@ task_start({ task_id: "task_xxx" })
297
183
  task_complete({ task_id: "task_xxx", summary: "What was done" })
298
184
  \`\`\`
299
185
 
300
- ## CodeDNA (saves 95-99% tokens)
301
- \`\`\`
302
- codedna_list_generators() // See all available generators
303
- codedna_generate_api("User(email:string:unique, password:string)", "express")
304
- codedna_generate_frontend("User(email:string, name:string)", "react")
305
- codedna_generate_component("Product(name:string, price:decimal)", "form", "react")
186
+ ## Code Generation (95-99% token savings)
187
+ \`\`\`typescript
188
+ codegen({ describe: "User with email, password, role (admin/user)" }) // schema + types + API + tests
189
+ codegen({ describe: "Login form with email, password" }) // → RHF + Zod form
190
+ codegen({ describe: "Dashboard page at /dashboard, requires auth" }) // → TanStack/Next route
306
191
  \`\`\`
307
192
  ${SECTION_END}
308
193
  `;
@@ -18,9 +18,9 @@ export declare function buildOrchestratorPrompt(params: {
18
18
  availableWorkers?: string[];
19
19
  }): string;
20
20
  /**
21
- * Get CodeDNA usage hint for task descriptions
21
+ * Get codegen usage hint for task descriptions
22
22
  */
23
- export declare function getCodeDNAHint(entitySpec: string): string;
23
+ export declare function getCodegenHint(entityDescription: string): string;
24
24
  /**
25
25
  * Validate task description doesn't contain code
26
26
  */