@claudetools/tools 0.8.2 → 0.8.3

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.
@@ -67,136 +67,42 @@ function buildIdentitySection(worker) {
67
67
  function buildBehavioralSection(taskId) {
68
68
  return `<!-- Layer 2: Behavioral Guidelines -->
69
69
  <behavioral_guidelines>
70
- <core_behaviors>
71
- <behavior id="codedna_first" priority="MANDATORY">
72
- BEFORE writing code manually, check if CodeDNA can generate it:
73
-
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:
83
- → Saves 95-99% tokens vs manual coding
84
- → Generates production-ready code with validation, auth, tests
85
-
86
- ONLY write code manually when:
87
- - Logic is too complex for generation
88
- - Modifying existing code (not creating new)
89
- - Custom business rules that can't be templated
90
- </behavior>
91
-
92
- <behavior id="tool_first" priority="MANDATORY">
93
- BEFORE writing code, use available tools:
94
-
95
- 1. codebase_map: START HERE - Get project overview
96
- → Understand project structure and key entry points
97
- → Identify frameworks and patterns in use
98
- → Find relevant directories before diving in
99
- → Use BEFORE Grep/Glob for unfamiliar code
100
-
101
- 2. memory_search: Check for existing patterns and decisions
102
- → "How was authentication implemented?"
103
- → "What patterns are used for X?"
104
-
105
- 3. codebase_find: Find specific symbols/files
106
- → Search for existing code to extend/adapt
107
-
108
- 4. codebase_context: Understand file dependencies
109
- → See what a file imports/exports
110
-
111
- 5. docs_get: Retrieve cached documentation
112
- → Get up-to-date API references
113
- </behavior>
114
-
115
- <behavior id="minimal_changes" priority="IMPORTANT">
116
- Make ONLY the changes required for this task.
117
- NEVER:
118
- - Refactor unrelated code
119
- - Add features not requested
120
- - Over-engineer solutions
121
- - Add unnecessary abstractions
122
- </behavior>
123
- </core_behaviors>
70
+ <behavior id="codedna_first" priority="MANDATORY">
71
+ BEFORE writing code: codedna_list_generators() → check if task matches generator
72
+ Entity DSL: "User(email:string:unique, password:string:hashed)"
73
+ Only write manually for: complex logic, modifications, custom business rules
74
+ </behavior>
75
+
76
+ <behavior id="tool_first" priority="MANDATORY">
77
+ Tool precedence: codebase_map → memory_search → codebase_find → docs_get
78
+ </behavior>
79
+
80
+ <behavior id="minimal_changes" priority="IMPORTANT">
81
+ Make ONLY task-required changes. No refactoring, features, or abstractions.
82
+ </behavior>
124
83
  </behavioral_guidelines>`;
125
84
  }
126
85
  function buildStandardsSection() {
127
86
  return `<!-- Layer 3: Standards & Best Practices -->
128
87
  <standards>
129
88
  <code_quality>
130
- - Write code that others can understand
131
- - Prefer explicit over implicit
132
- - Validate inputs at system boundaries
133
- - Handle errors with clear messages
89
+ Australian English. Explicit over implicit. Validate boundaries. Clear errors.
134
90
  </code_quality>
135
91
 
136
- <formatting>
137
- - Use Australian English in comments and messages
138
- - Follow existing code style in the project
139
- - Include file paths with line numbers in references
140
- </formatting>
141
-
142
92
  <memory_usage priority="CRITICAL">
143
- When storing facts with memory_store_fact(), follow these rules:
144
-
145
- STORE (learned contextual knowledge):
146
- - Project discoveries: Anti-patterns found, bugs fixed, patterns discovered
147
- - User preferences: Workflows, communication styles learned through interaction
148
- - Architectural decisions WHY: Reasoning behind choices, rejected alternatives
149
- - Solutions that worked: Specific implementations with context
150
-
151
- ❌ DON'T STORE (generic documentation):
152
- - Tool behavior: How the tool system works (already in API docs)
153
- - Universal knowledge: Programming concepts, language features
154
- - Temporary state: Current task status, session-specific data
155
-
156
- Rule of thumb: "Would I need to rediscover this in 3 months?"
157
- → YES = store it (learned pattern, specific to this context)
158
- → NO = don't store it (universal knowledge, temporary state)
93
+ Store: project discoveries, user preferences, decision rationale, working solutions
94
+ Don't store: tool behavior, universal knowledge, temporary state
95
+ Rule: "Would I rediscover this in 3 months?" → YES = store
159
96
  </memory_usage>
160
97
 
161
98
  <documentation_files priority="MANDATORY">
162
- NEVER create .md files in random locations. Follow these rules:
163
-
164
- DIRECTORY STRUCTURE:
165
- - docs/ → Project documentation, guides, specs
166
- - docs/research/ → Research notes, analysis, investigations
167
- - docs/decisions/ → Architecture Decision Records (ADRs)
168
- - CHANGELOG.md → Only in project root
169
- - README.md → Only in project root or package roots
170
-
171
- NAMING CONVENTIONS:
172
- - Use lowercase with hyphens: user-authentication-guide.md
173
- - NEVER use spaces or underscores in filenames
174
- - Include date prefix for time-sensitive docs: YYYY-MM-DD-topic.md
175
- Example: 2025-12-05-api-migration-plan.md
176
- - Research docs: YYYY-MM-DD-research-topic.md
177
- - Decision records: NNNN-decision-title.md (e.g., 0001-use-jwt-auth.md)
178
-
179
- ANTI-PATTERNS (NEVER DO):
180
- - Creating PLAN.md, NOTES.md, TODO.md in project root
181
- - Random capitalised filenames like IMPLEMENTATION_GUIDE.md
182
- - Nested docs in src/ or lib/ directories
183
- - Multiple README files outside package roots
184
- - Temporary docs without dates (impossible to clean up later)
185
-
186
- BEFORE CREATING ANY .md FILE:
187
- 1. Check if docs/ directory exists - create if needed
188
- 2. Determine correct subdirectory (research/, decisions/, etc.)
189
- 3. Use proper naming convention with date if temporal
190
- 4. Ask user if uncertain about placement
99
+ Structure: docs/research/, docs/decisions/, README.md/CHANGELOG.md in root only
100
+ Naming: lowercase-with-hyphens.md, YYYY-MM-DD-topic.md for temporal docs
101
+ Never: PLAN.md/NOTES.md in root, random caps, nested in src/, undated temp files
191
102
  </documentation_files>
192
103
 
193
104
  <completion_summary>
194
- When calling task_complete, include:
195
- - Implementation: What you built/changed
196
- - Files: List of modified files with paths
197
- - Decisions: Any architectural choices made
198
- - Testing: How changes were verified
199
- - Notes: Caveats, limitations, follow-up needed
105
+ Include: implementation, files modified, decisions, testing, notes
200
106
  </completion_summary>
201
107
  </standards>`;
202
108
  }
@@ -204,31 +110,10 @@ function buildDomainSection(worker) {
204
110
  return `<!-- Layer 4: Domain Knowledge -->
205
111
  <domain_knowledge>
206
112
  <codedna_capabilities>
207
- CODEDNA DISCOVERY PATTERN:
208
- 1. Call codedna_list_generators() to see available generators
209
- 2. Each generator lists supported frameworks and options
210
- 3. Detect project framework from package.json/pyproject.toml
211
- 4. Match detected framework to generator capabilities
212
- 5. If no match, ASK the user which framework to use
213
-
214
- ENTITY DSL FORMAT:
215
- EntityName(field:type:constraint, field:type:constraint, ...)
216
-
217
- TYPES:
218
- - string, integer, decimal, boolean, datetime
219
- - ref(EntityName) - foreign key reference
220
- - enum(val1|val2|val3) - enumeration
221
-
222
- CONSTRAINTS:
223
- - unique, required, min(n), max(n), hashed, default(value)
224
- - UI hints: textarea, switch, radio (for form rendering)
225
-
226
- WORKFLOW:
227
- 1. codedna_list_generators() → discover capabilities
228
- 2. codedna_validate_spec(spec) → validate DSL syntax
229
- 3. codedna_generate_*(spec, framework, options) → generate code
230
-
231
- DO NOT assume frameworks exist - always discover via codedna_list_generators
113
+ Discovery: codedna_list_generators() → detect framework → validate spec → generate
114
+ DSL: EntityName(field:type:constraint, ...)
115
+ Types: string, integer, decimal, boolean, datetime, ref(Entity), enum(a|b)
116
+ Constraints: unique, required, min(n), max(n), hashed, default(v), textarea, switch
232
117
  </codedna_capabilities>
233
118
 
234
119
  <worker_expertise>
@@ -239,26 +124,9 @@ function buildDomainSection(worker) {
239
124
  function buildCrossCuttingSection() {
240
125
  return `<!-- Layer 5: Cross-Cutting Concerns -->
241
126
  <cross_cutting_concerns>
242
- <error_handling>
243
- - Validate inputs at boundaries (API, CLI, file I/O)
244
- - Fail fast with clear error messages
245
- - Log errors with sufficient context for debugging
246
- - Provide actionable guidance to users
247
- </error_handling>
248
-
249
- <security>
250
- CRITICAL: Follow OWASP Top 10 guidelines
251
- - Never expose sensitive data (API keys, passwords, tokens)
252
- - Sanitize all user inputs
253
- - Use parameterized queries (never string concat for SQL)
254
- - Apply principle of least privilege
255
- </security>
256
-
257
- <performance>
258
- - Don't optimise prematurely
259
- - Consider token efficiency in prompts
260
- - Use CodeDNA for boilerplate (saves 95%+ tokens)
261
- </performance>
127
+ <error_handling>Validate boundaries. Fail fast. Clear messages. Actionable guidance.</error_handling>
128
+ <security>OWASP Top 10. No exposed secrets. Sanitize inputs. Parameterized queries. Least privilege.</security>
129
+ <performance>No premature optimization. Token efficiency. CodeDNA for boilerplate.</performance>
262
130
  </cross_cutting_concerns>`;
263
131
  }
264
132
  function buildTaskSection(task, epicContext) {
@@ -309,54 +177,19 @@ function buildSiblingSection(siblingTasks) {
309
177
  function buildProtocolSection(taskId) {
310
178
  return `<!-- Protocol -->
311
179
  <protocol>
312
- <step number="1" action="START">
313
- Call: task_start(task_id="${taskId}", agent_id="your-agent-id")
314
- This claims the task and prevents conflicts.
315
- </step>
316
-
317
- <step number="2" action="CHECK_CODEDNA">
318
- IF task involves creating entities/APIs:
319
- → Look for Entity DSL in task description
320
- → Call codedna_generate_api with the spec
321
- → Review generated code, make adjustments if needed
322
-
323
- IF task is modification/complex logic:
324
- → Use memory_search and codebase_find first
325
- → Write code manually only when necessary
326
- </step>
327
-
328
- <step number="3" action="IMPLEMENT">
329
- Complete the requirements described in the task.
330
- Make minimal changes. Don't over-engineer.
331
- </step>
332
-
333
- <step number="4" action="COMPLETE">
334
- Call: task_complete(task_id="${taskId}", summary="detailed summary")
335
-
336
- Include in summary:
337
- - What you implemented
338
- - Files created/modified
339
- - Decisions made
340
- - How you verified it works
341
- </step>
180
+ <step number="1">task_start(task_id="${taskId}")</step>
181
+ <step number="2">Check CodeDNA for entities/APIs, else use tools (memory_search, codebase_find)</step>
182
+ <step number="3">Implement requirements. Minimal changes.</step>
183
+ <step number="4">task_complete(task_id="${taskId}", summary="impl, files, decisions, testing")</step>
342
184
 
343
185
  <error_handling>
344
- IF you encounter blocking issues:
345
-
346
- 1. Log error:
347
- task_add_context(task_id="${taskId}", context_type="work_log",
348
- content="ERROR: description", added_by="your-agent-id")
349
-
350
- 2. Release task:
351
- task_release(task_id="${taskId}", agent_id="your-agent-id",
352
- new_status="blocked", work_log="summary of issue")
353
-
354
- Do NOT mark incomplete work as complete.
186
+ Blocking issues: task_add_context + task_release(status="blocked")
187
+ Never mark incomplete work as complete.
355
188
  </error_handling>
356
189
  </protocol>
357
190
 
358
191
  ---
359
- **Begin work now. Remember to call task_start first!**`;
192
+ **Begin work now. Call task_start first!**`;
360
193
  }
361
194
  /**
362
195
  * Build a minimal prompt for simple tasks
package/dist/tools.js CHANGED
@@ -7,7 +7,14 @@ export function registerToolDefinitions(server) {
7
7
  tools: [
8
8
  {
9
9
  name: 'memory_search',
10
- description: 'Search the memory system for relevant facts and entities based on a query. Use this to recall past conversations, facts, and relationships. NOTE: Context is now automatically injected - use this only for explicit searches.',
10
+ description: `⚠️ RARELY NEEDED - Context is AUTO-INJECTED via hooks on every message.
11
+
12
+ Only use this tool when:
13
+ - You need to search with DIFFERENT parameters than the user's query
14
+ - You're debugging what's in memory
15
+ - The user explicitly asks to search memory
16
+
17
+ DO NOT use this tool to "recall context" - that happens automatically.`,
11
18
  inputSchema: {
12
19
  type: 'object',
13
20
  properties: {
@@ -29,7 +36,7 @@ export function registerToolDefinitions(server) {
29
36
  },
30
37
  {
31
38
  name: 'memory_explain',
32
- description: 'Explain what memory context was automatically injected in the last response. Use this when you want to understand what memories are being used.',
39
+ description: 'Debug tool: Show what memory context was auto-injected. Only use if debugging memory injection.',
33
40
  inputSchema: {
34
41
  type: 'object',
35
42
  properties: {},
@@ -37,7 +44,13 @@ export function registerToolDefinitions(server) {
37
44
  },
38
45
  {
39
46
  name: 'memory_inject',
40
- description: 'Manually trigger context injection for a specific query. Normally context is injected automatically, but use this for explicit control.',
47
+ description: `⚠️ RARELY NEEDED - Context is AUTO-INJECTED via user-prompt-submit hook.
48
+
49
+ Only use this tool when:
50
+ - You need to inject context for a DIFFERENT query than the user's message
51
+ - The user explicitly asks to refresh context
52
+
53
+ DO NOT call this routinely - it wastes context tokens.`,
41
54
  inputSchema: {
42
55
  type: 'object',
43
56
  properties: {
@@ -139,7 +152,9 @@ EXAMPLES:
139
152
  },
140
153
  {
141
154
  name: 'memory_get_context',
142
- description: 'Get the current memory context, optionally filtered by a query. Returns recent facts and entities.',
155
+ description: `⚠️ RARELY NEEDED - Context is AUTO-INJECTED via hooks.
156
+
157
+ Only use for debugging or when user explicitly asks "what context do you have?"`,
143
158
  inputSchema: {
144
159
  type: 'object',
145
160
  properties: {
@@ -185,23 +200,10 @@ EXAMPLES:
185
200
  // =========================================================================
186
201
  {
187
202
  name: 'memory_index',
188
- description: `Get a lightweight index of available memories WITHOUT fetching full content. Use this FIRST to scan what context is available before deciding what to retrieve.
189
-
190
- Returns for each memory:
191
- - id: Unique identifier for fetching details
192
- - topic: Short topic/subject description
193
- - relevance: Score (0-1) indicating how relevant to query
194
- - token_cost: Estimated tokens if fetched
195
- - importance: "critical" | "high" | "normal" - Critical facts are auto-injected
196
- - category: "architecture" | "pattern" | "decision" | "preference" | "fact"
197
- - last_accessed: When this memory was last used
198
-
199
- WORKFLOW:
200
- 1. Call memory_index with your query to see what's available
201
- 2. Review the index - critical items are auto-injected
202
- 3. Call memory_detail for specific IDs you want full content for
203
+ description: `⚠️ RARELY NEEDED - Critical facts are AUTO-INJECTED via hooks.
203
204
 
204
- This saves tokens by letting you selectively fetch only relevant memories.`,
205
+ Only use when you need to browse ALL available memories or debug what's stored.
206
+ For normal work, context is injected automatically - don't call this.`,
205
207
  inputSchema: {
206
208
  type: 'object',
207
209
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claudetools/tools",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Persistent AI memory, task management, and codebase intelligence for Claude Code",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,7 +26,9 @@
26
26
  "codedna:analytics": "tsx -e \"import { weeklyAnalyticsSummary } from './src/helpers/usage-analytics.js'; weeklyAnalyticsSummary()\"",
27
27
  "codedna:analytics:24h": "tsx -e \"import { getLast24HoursAnalytics, printAnalytics } from './src/helpers/usage-analytics.js'; const r = await getLast24HoursAnalytics(); printAnalytics(r, 'Last 24 Hours')\"",
28
28
  "codedna:analytics:30d": "tsx -e \"import { getLast30DaysAnalytics, printAnalytics } from './src/helpers/usage-analytics.js'; const r = await getLast30DaysAnalytics(); printAnalytics(r, 'Last 30 Days')\"",
29
- "prompt:verify": "scripts/verify-prompt-compliance.sh"
29
+ "prompt:verify": "scripts/verify-prompt-compliance.sh",
30
+ "eval:build-dataset": "tsx src/evaluation/build-dataset.ts",
31
+ "eval:threshold": "tsx src/evaluation/threshold-eval.ts"
30
32
  },
31
33
  "repository": {
32
34
  "type": "git",