agileflow 2.90.7 → 2.91.0

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 (73) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +6 -6
  3. package/lib/codebase-indexer.js +810 -0
  4. package/lib/validate-names.js +3 -3
  5. package/package.json +4 -1
  6. package/scripts/obtain-context.js +238 -0
  7. package/scripts/precompact-context.sh +13 -1
  8. package/scripts/query-codebase.js +430 -0
  9. package/scripts/tui/blessed/data/watcher.js +175 -0
  10. package/scripts/tui/blessed/index.js +244 -0
  11. package/scripts/tui/blessed/panels/output.js +95 -0
  12. package/scripts/tui/blessed/panels/sessions.js +143 -0
  13. package/scripts/tui/blessed/panels/trace.js +91 -0
  14. package/scripts/tui/blessed/ui/help.js +77 -0
  15. package/scripts/tui/blessed/ui/screen.js +52 -0
  16. package/scripts/tui/blessed/ui/statusbar.js +51 -0
  17. package/scripts/tui/blessed/ui/tabbar.js +99 -0
  18. package/scripts/tui/index.js +38 -30
  19. package/scripts/validators/README.md +143 -0
  20. package/scripts/validators/component-validator.js +212 -0
  21. package/scripts/validators/json-schema-validator.js +179 -0
  22. package/scripts/validators/markdown-validator.js +153 -0
  23. package/scripts/validators/migration-validator.js +117 -0
  24. package/scripts/validators/security-validator.js +276 -0
  25. package/scripts/validators/story-format-validator.js +176 -0
  26. package/scripts/validators/test-result-validator.js +99 -0
  27. package/scripts/validators/workflow-validator.js +240 -0
  28. package/src/core/agents/accessibility.md +6 -0
  29. package/src/core/agents/adr-writer.md +6 -0
  30. package/src/core/agents/analytics.md +6 -0
  31. package/src/core/agents/api.md +6 -0
  32. package/src/core/agents/ci.md +6 -0
  33. package/src/core/agents/codebase-query.md +237 -0
  34. package/src/core/agents/compliance.md +6 -0
  35. package/src/core/agents/configuration-damage-control.md +6 -0
  36. package/src/core/agents/configuration-visual-e2e.md +6 -0
  37. package/src/core/agents/database.md +10 -0
  38. package/src/core/agents/datamigration.md +6 -0
  39. package/src/core/agents/design.md +6 -0
  40. package/src/core/agents/devops.md +6 -0
  41. package/src/core/agents/documentation.md +6 -0
  42. package/src/core/agents/epic-planner.md +6 -0
  43. package/src/core/agents/integrations.md +6 -0
  44. package/src/core/agents/mentor.md +6 -0
  45. package/src/core/agents/mobile.md +6 -0
  46. package/src/core/agents/monitoring.md +6 -0
  47. package/src/core/agents/multi-expert.md +6 -0
  48. package/src/core/agents/performance.md +6 -0
  49. package/src/core/agents/product.md +6 -0
  50. package/src/core/agents/qa.md +6 -0
  51. package/src/core/agents/readme-updater.md +6 -0
  52. package/src/core/agents/refactor.md +6 -0
  53. package/src/core/agents/research.md +6 -0
  54. package/src/core/agents/security.md +6 -0
  55. package/src/core/agents/testing.md +10 -0
  56. package/src/core/agents/ui.md +6 -0
  57. package/src/core/commands/audit.md +401 -0
  58. package/src/core/commands/board.md +1 -0
  59. package/src/core/commands/epic.md +92 -1
  60. package/src/core/commands/help.md +1 -0
  61. package/src/core/commands/metrics.md +1 -0
  62. package/src/core/commands/research/analyze.md +1 -0
  63. package/src/core/commands/research/ask.md +2 -0
  64. package/src/core/commands/research/import.md +1 -0
  65. package/src/core/commands/research/list.md +2 -0
  66. package/src/core/commands/research/synthesize.md +584 -0
  67. package/src/core/commands/research/view.md +2 -0
  68. package/src/core/commands/status.md +126 -1
  69. package/src/core/commands/story/list.md +9 -9
  70. package/src/core/commands/story/view.md +1 -0
  71. package/src/core/experts/codebase-query/expertise.yaml +190 -0
  72. package/src/core/experts/codebase-query/question.md +73 -0
  73. package/src/core/experts/codebase-query/self-improve.md +105 -0
@@ -12,11 +12,14 @@ compact_context:
12
12
  - "MUST show diff preview before confirming (diff-first pattern)"
13
13
  - "Status values: ready|in-progress|blocked|in-review|done"
14
14
  - "MUST escape user text automatically (jq handles escaping)"
15
+ - "PHASE HANDOFF: Prompt for summary on phase transitions (ready→in-progress, in-progress→in-review, in-review→done)"
15
16
  state_fields:
16
17
  - story_id
17
18
  - current_status
18
19
  - new_status
19
20
  - pr_url
21
+ - phase_from
22
+ - phase_to
20
23
  ---
21
24
 
22
25
  # status
@@ -105,6 +108,7 @@ TO=<agent-id> # Recipient agent for bus message (optional)
105
108
  "stories": {
106
109
  "US-0042": {
107
110
  "status": "in-progress",
111
+ "phase": "execute",
108
112
  "summary": "Started work on login form",
109
113
  "pr": "https://github.com/.../pull/42",
110
114
  "last_update": "ISO-timestamp"
@@ -113,6 +117,15 @@ TO=<agent-id> # Recipient agent for bus message (optional)
113
117
  }
114
118
  ```
115
119
 
120
+ **Phase Field** (auto-set based on status):
121
+ | Status | Phase |
122
+ |--------|-------|
123
+ | ready | plan |
124
+ | in-progress | execute |
125
+ | blocked | execute |
126
+ | in-review | audit |
127
+ | done | complete |
128
+
116
129
  **Append to bus/log.jsonl**:
117
130
  ```json
118
131
  {"ts":"ISO-timestamp","from":"SYSTEM","to":"<TO or ALL>","type":"status","story":"<STORY>","status":"<STATUS>","text":"<SUMMARY>"}
@@ -146,6 +159,7 @@ docs/09-agents/status.json
146
159
 
147
160
  - "status": "ready",
148
161
  + "status": "in-progress",
162
+ + "phase": "execute",
149
163
  + "summary": "Started work on login form",
150
164
  + "pr": "https://github.com/.../pull/42",
151
165
  ```
@@ -178,6 +192,7 @@ docs/09-agents/status.json
178
192
  - ALWAYS show diff before confirming
179
193
  - Status values: ready, in-progress, blocked, in-review, done
180
194
  - Text escaping handled automatically by jq
195
+ - **PHASE HANDOFF**: On phase transitions (ready→in-progress, in-progress→in-review, in-review→done), prompt for handoff summary and log to bus/log.jsonl with type "phase_handoff"
181
196
 
182
197
  <!-- COMPACT_SUMMARY_END -->
183
198
 
@@ -192,7 +207,8 @@ STORY=<US-ID> STATUS=in-progress|blocked|in-review|done
192
207
  SUMMARY=<1–2 lines> PR=<url optional> TO=<agent id optional>
193
208
 
194
209
  ACTIONS
195
- 1) Update docs/09-agents/status.json (status,summary,last_update,pr).
210
+ 1) Update docs/09-agents/status.json (status,phase,summary,last_update,pr).
211
+ - Set phase based on status: ready→plan, in-progress/blocked→execute, in-review→audit, done→complete
196
212
  **CRITICAL**: Always use jq for JSON operations to prevent corruption.
197
213
  2) **Validate JSON after update**:
198
214
  ```bash
@@ -212,3 +228,112 @@ ACTIONS
212
228
  - If validation fails, restore from backup: docs/09-agents/status.json.backup
213
229
 
214
230
  Diff-first; YES/NO.
231
+
232
+ ---
233
+
234
+ ## Phase Handoff (GSD Integration)
235
+
236
+ When status transitions indicate a phase change, prompt for a handoff summary to capture context for the next phase.
237
+
238
+ ### Phase Transitions
239
+
240
+ | Status Change | Phase Transition | Handoff Prompt |
241
+ |--------------|------------------|----------------|
242
+ | ready → in-progress | plan → execute | "What's the plan for implementing this story?" |
243
+ | in-progress → in-review | execute → audit | "What was implemented? Any issues encountered?" |
244
+ | in-review → done | audit → complete | "Final summary: What was delivered?" |
245
+
246
+ ### Handoff Workflow
247
+
248
+ **Step 1: Detect Phase Transition**
249
+
250
+ Before updating status, check if this is a phase-changing transition:
251
+ ```javascript
252
+ const phaseTransitions = {
253
+ 'ready→in-progress': { from: 'plan', to: 'execute' },
254
+ 'in-progress→in-review': { from: 'execute', to: 'audit' },
255
+ 'in-review→done': { from: 'audit', to: 'complete' }
256
+ };
257
+ const key = `${currentStatus}→${newStatus}`;
258
+ const transition = phaseTransitions[key];
259
+ ```
260
+
261
+ **Step 2: Prompt for Handoff Summary**
262
+
263
+ If a phase transition is detected, prompt BEFORE the status confirmation:
264
+
265
+ ```xml
266
+ <invoke name="AskUserQuestion">
267
+ <parameter name="questions">[{
268
+ "question": "Phase transition: {{FROM}} → {{TO}}. Summarize what was accomplished:",
269
+ "header": "Handoff",
270
+ "multiSelect": false,
271
+ "options": [
272
+ {"label": "Enter summary", "description": "Capture context for next phase"},
273
+ {"label": "Skip handoff", "description": "No summary needed"}
274
+ ]
275
+ }]</parameter>
276
+ </invoke>
277
+ ```
278
+
279
+ **Step 3: Log Phase Handoff**
280
+
281
+ If summary provided, append to bus/log.jsonl:
282
+ ```json
283
+ {
284
+ "ts": "2026-01-19T12:00:00Z",
285
+ "type": "phase_handoff",
286
+ "story": "US-0130",
287
+ "from": "plan",
288
+ "to": "execute",
289
+ "summary": "User's handoff summary here"
290
+ }
291
+ ```
292
+
293
+ ### Example Flow
294
+
295
+ ```
296
+ User: /agileflow:status US-0042 STATUS=in-progress
297
+
298
+ Claude:
299
+ 📋 Phase Transition Detected: plan → execute
300
+
301
+ Before updating status, let's capture a handoff summary.
302
+
303
+ [AskUserQuestion: "What's the plan for implementing this story?"]
304
+
305
+ User: "Adding login form with email/password validation, using React Hook Form"
306
+
307
+ Claude:
308
+ ✅ Handoff captured
309
+
310
+ docs/09-agents/status.json
311
+ - "status": "ready",
312
+ + "status": "in-progress",
313
+ + "last_update": "2026-01-19T12:00:00Z"
314
+
315
+ [AskUserQuestion: "Update US-0042 to in-progress?"]
316
+
317
+ User: "Yes, update"
318
+
319
+ Claude:
320
+ ✅ Status updated: US-0042 → in-progress
321
+ ✅ Phase handoff logged: plan → execute
322
+ ```
323
+
324
+ ### Handoff Prompts by Transition
325
+
326
+ **plan → execute** (ready → in-progress):
327
+ - "What's the implementation approach?"
328
+ - "Any architectural decisions made?"
329
+ - "Key files to be modified?"
330
+
331
+ **execute → audit** (in-progress → in-review):
332
+ - "What was implemented?"
333
+ - "Any issues or blockers encountered?"
334
+ - "Tests passing? Coverage notes?"
335
+
336
+ **audit → complete** (in-review → done):
337
+ - "Final summary of what was delivered"
338
+ - "Any technical debt introduced?"
339
+ - "Lessons learned?"
@@ -76,17 +76,17 @@ Format output as table grouped by epic:
76
76
  ## Stories
77
77
 
78
78
  ### EP-0001: Authentication System
79
- | Story | Title | Status | Owner | Estimate |
80
- |-------|-------|--------|-------|----------|
81
- | US-0001 | Login form | done | AG-UI | 2h |
82
- | US-0002 | Password reset | in_progress | AG-API | 3h |
83
- | US-0003 | Session management | ready | AG-API | 4h |
79
+ | Story | Title | Status | Phase | Owner | Estimate |
80
+ |-------|-------|--------|-------|-------|----------|
81
+ | US-0001 | Login form | done | complete | AG-UI | 2h |
82
+ | US-0002 | Password reset | in_progress | execute | AG-API | 3h |
83
+ | US-0003 | Session management | ready | plan | AG-API | 4h |
84
84
 
85
85
  ### EP-0002: User Dashboard
86
- | Story | Title | Status | Owner | Estimate |
87
- |-------|-------|--------|-------|----------|
88
- | US-0004 | Dashboard layout | ready | AG-UI | 2h |
89
- | US-0005 | Activity feed | ready | AG-UI | 3h |
86
+ | Story | Title | Status | Phase | Owner | Estimate |
87
+ |-------|-------|--------|-------|-------|----------|
88
+ | US-0004 | Dashboard layout | ready | plan | AG-UI | 2h |
89
+ | US-0005 | Activity feed | ready | plan | AG-UI | 3h |
90
90
 
91
91
  ---
92
92
  **Summary**: 5 stories (1 done, 1 in_progress, 3 ready)
@@ -92,6 +92,7 @@ cat docs/07-testing/test-cases/<STORY>.md
92
92
 
93
93
  **Epic**: EP-0001 (Authentication System)
94
94
  **Status**: in_progress
95
+ **Phase**: execute
95
96
  **Owner**: AG-UI
96
97
  **Estimate**: 3h
97
98
  **Created**: 2024-12-28
@@ -0,0 +1,190 @@
1
+ # Codebase Query Expert - Domain Knowledge
2
+ # This file is the agent's "mental model" of codebase querying
3
+ # AUTO-UPDATED by self-improve.md after completing work
4
+
5
+ domain: codebase-query
6
+ last_updated: 2026-01-19
7
+ version: 1.0
8
+
9
+ # Query interface components
10
+ files:
11
+ query_script:
12
+ - path: packages/cli/scripts/query-codebase.js
13
+ purpose: "CLI for codebase queries"
14
+ commands:
15
+ - "--build-index: Build/rebuild codebase index"
16
+ - "--query=<pattern>: Smart search (glob + tag + export)"
17
+ - "--content=<regex>: Search file content"
18
+ - "--tag=<tag>: Search by tag"
19
+ - "--export=<symbol>: Find export locations"
20
+ - "--deps=<file>: Show file dependencies"
21
+
22
+ indexer:
23
+ - path: packages/cli/lib/codebase-indexer.js
24
+ purpose: "Core indexing logic"
25
+ functions:
26
+ - "buildIndex(rootDir): Full index build"
27
+ - "updateIndex(rootDir): Incremental update"
28
+ - "getIndex(rootDir): Get cached or build"
29
+ - "queryFiles(index, pattern): Glob matching"
30
+ - "queryByTag(index, tag): Tag lookup"
31
+ - "queryByExport(index, symbol): Export search"
32
+ - "getDependencies(index, file): Import graph"
33
+
34
+ cache:
35
+ - path: .agileflow/cache/codebase-index.json
36
+ purpose: "Persistent index storage"
37
+ ttl: "60 seconds in-memory, persistent on disk"
38
+
39
+ # Query type mappings
40
+ query_types:
41
+ files:
42
+ flag: "--query"
43
+ description: "Smart search combining glob, tag, and export matching"
44
+ examples:
45
+ - input: "auth files"
46
+ translation: '--query="auth"'
47
+ - input: "api routes"
48
+ translation: '--query="src/api/**/*.ts"'
49
+ - input: "test files"
50
+ translation: '--query="**/*.test.{js,ts}"'
51
+
52
+ content:
53
+ flag: "--content"
54
+ description: "Grep-style regex content search"
55
+ examples:
56
+ - input: "files with validateToken"
57
+ translation: '--content="validateToken"'
58
+ - input: "error handling patterns"
59
+ translation: '--content="try.*catch|\.catch\\("'
60
+ - input: "React hooks usage"
61
+ translation: '--content="use(State|Effect|Ref|Context)"'
62
+
63
+ tag:
64
+ flag: "--tag"
65
+ description: "Search by auto-detected tag"
66
+ examples:
67
+ - input: "API endpoints"
68
+ translation: '--tag="api"'
69
+ - input: "UI components"
70
+ translation: '--tag="ui"'
71
+ - input: "database models"
72
+ translation: '--tag="database"'
73
+
74
+ export:
75
+ flag: "--export"
76
+ description: "Find files exporting a symbol"
77
+ examples:
78
+ - input: "where is login defined"
79
+ translation: '--export="login"'
80
+ - input: "UserService export"
81
+ translation: '--export="UserService"'
82
+
83
+ deps:
84
+ flag: "--deps"
85
+ description: "Show file dependencies"
86
+ examples:
87
+ - input: "what depends on auth.ts"
88
+ translation: '--deps="src/auth.ts"'
89
+ - input: "utils dependencies"
90
+ translation: '--deps="src/lib/utils.js"'
91
+
92
+ # Available tags (auto-detected from paths)
93
+ available_tags:
94
+ api:
95
+ patterns: ["/api/", "/routes/", "/endpoints/", "/controllers/"]
96
+ description: "API endpoints and routes"
97
+ ui:
98
+ patterns: ["/components/", "/ui/", "/views/", "/pages/"]
99
+ description: "UI components and views"
100
+ database:
101
+ patterns: ["/db/", "/database/", "/models/", "/schema/", "/migrations/"]
102
+ description: "Database models and migrations"
103
+ auth:
104
+ patterns: ["/auth/", "/login/", "/session/", "/jwt/", "/oauth/"]
105
+ description: "Authentication logic"
106
+ test:
107
+ patterns: ["/test/", "/tests/", "/__tests__/", "/spec/", "/specs/"]
108
+ description: "Test files"
109
+ config:
110
+ patterns: ["/config/", "/settings/", "/env/"]
111
+ description: "Configuration files"
112
+ lib:
113
+ patterns: ["/lib/", "/utils/", "/helpers/", "/shared/"]
114
+ description: "Utility libraries"
115
+ docs:
116
+ patterns: ["/docs/", "/documentation/"]
117
+ description: "Documentation files"
118
+ scripts:
119
+ patterns: ["/scripts/", "/bin/", "/tools/"]
120
+ description: "Build and utility scripts"
121
+ types:
122
+ patterns: ["/types/", "/typings/", "/interfaces/"]
123
+ description: "Type definitions"
124
+
125
+ # Natural language patterns
126
+ nl_patterns:
127
+ - pattern: "where is * defined"
128
+ query_type: export
129
+ extraction: "symbol from *"
130
+ - pattern: "what files use *"
131
+ query_type: export
132
+ extraction: "symbol from *"
133
+ - pattern: "* files"
134
+ query_type: query
135
+ extraction: "keyword from *"
136
+ - pattern: "files with *"
137
+ query_type: content
138
+ extraction: "regex from *"
139
+ - pattern: "* in the codebase"
140
+ query_type: query
141
+ extraction: "keyword from *"
142
+ - pattern: "dependencies of *"
143
+ query_type: deps
144
+ extraction: "file path from *"
145
+ - pattern: "what depends on *"
146
+ query_type: deps
147
+ extraction: "file path from *"
148
+
149
+ # Fallback strategies
150
+ fallbacks:
151
+ index_unavailable:
152
+ description: "When index cannot be built or is corrupted"
153
+ strategy:
154
+ - "Use Glob tool for file pattern matching"
155
+ - "Use Grep tool for content searching"
156
+ - "Combine results manually"
157
+
158
+ no_results:
159
+ description: "When query returns no matches"
160
+ strategy:
161
+ - "Try broader search terms"
162
+ - "Check for typos in symbol names"
163
+ - "Try content search instead of export search"
164
+ - "Suggest related tags"
165
+
166
+ # Conventions
167
+ conventions:
168
+ - "Always check index status before querying"
169
+ - "Translate natural language to structured queries"
170
+ - "Combine multiple query types for complex searches"
171
+ - "Respect token budget (default 15000 chars)"
172
+ - "Show file counts and truncation notices"
173
+ - "READ-ONLY: Never use Write/Edit tools"
174
+
175
+ # Learnings from codebase exploration
176
+ learnings:
177
+ - date: 2026-01-19
178
+ context: "Initial indexer implementation"
179
+ insight: "Index build takes ~6.5s for 1777 files, use incremental updates for speed"
180
+ source: "packages/cli/lib/codebase-indexer.js"
181
+
182
+ - date: 2026-01-19
183
+ context: "Tag detection"
184
+ insight: "9 auto-detected tags available: api, ui, database, auth, test, config, lib, docs, scripts"
185
+ source: "packages/cli/lib/codebase-indexer.js:TAG_PATTERNS"
186
+
187
+ - date: 2026-01-19
188
+ context: "Export tracking"
189
+ insight: "477 exports tracked across codebase, searchable via --export flag"
190
+ source: "query-codebase.js --build-index output"
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: Ask questions about codebase-query - uses expertise for fast, accurate answers
3
+ argument-hint: <your question>
4
+ variables:
5
+ EXPERTISE_FILE: packages/cli/src/core/experts/codebase-query/expertise.yaml
6
+ ---
7
+
8
+ # Codebase Query Expert - Question
9
+
10
+ You are an expert on the codebase-query domain for this codebase. You maintain a mental model (expertise file) that helps you answer questions quickly and accurately.
11
+
12
+ ## CRITICAL: Expertise-First Workflow
13
+
14
+ **You MUST follow this workflow. Do not skip steps.**
15
+
16
+ ### Step 1: Load Your Expertise
17
+ Read your expertise file at `packages/cli/src/core/experts/codebase-query/expertise.yaml` FIRST, before doing anything else.
18
+
19
+ This file contains:
20
+ - Query types and their translations
21
+ - Available tags and patterns
22
+ - Natural language pattern mappings
23
+ - Fallback strategies
24
+ - Recent learnings from past queries
25
+
26
+ ### Step 2: Validate Against Actual Code
27
+ Your expertise is a mental model, NOT the source of truth. The code is always the source of truth.
28
+
29
+ For each relevant piece of expertise:
30
+ 1. Check if the query script still works as documented
31
+ 2. Verify your understanding matches current behavior
32
+ 3. Note any discrepancies (for self-improve later)
33
+
34
+ ### Step 3: Answer the Question
35
+ With your validated mental model:
36
+ 1. Answer based on your expertise + validation
37
+ 2. Be specific - include exact query commands
38
+ 3. If expertise was wrong, note it in your answer
39
+ 4. If you don't know, say so (don't guess)
40
+
41
+ ## Key Principles
42
+
43
+ - **Speed**: Use expertise to skip unnecessary testing
44
+ - **Accuracy**: Always validate against actual behavior
45
+ - **Honesty**: Acknowledge when expertise is stale
46
+ - **Learning**: Note discrepancies for self-improve
47
+
48
+ ## Common Questions
49
+
50
+ ### "How do I search for X?"
51
+ 1. Check `query_types` in expertise for matching type
52
+ 2. Check `nl_patterns` for natural language mapping
53
+ 3. Provide the exact command
54
+
55
+ ### "What tags are available?"
56
+ Reference `available_tags` in expertise, validate they exist in TAG_PATTERNS.
57
+
58
+ ### "Why did my query return no results?"
59
+ Check `fallbacks.no_results` for strategies, suggest alternatives.
60
+
61
+ ### "How does the index work?"
62
+ Reference `files.indexer` for implementation details.
63
+
64
+ ## Anti-Patterns to Avoid
65
+
66
+ - Reading expertise but ignoring it
67
+ - Testing queries before checking expertise
68
+ - Trusting expertise blindly without validation
69
+ - Giving vague answers when expertise has specifics
70
+
71
+ ## Question
72
+
73
+ {{argument}}
@@ -0,0 +1,105 @@
1
+ ---
2
+ description: Update codebase-query expertise after making changes
3
+ argument-hint: [optional context about what changed]
4
+ variables:
5
+ EXPERTISE_FILE: packages/cli/src/core/experts/codebase-query/expertise.yaml
6
+ ---
7
+
8
+ # Codebase Query Expert - Self-Improve
9
+
10
+ You are updating your mental model (expertise file) to reflect changes in the codebase. This keeps your expertise accurate and useful for future tasks.
11
+
12
+ ## CRITICAL: Self-Improve Workflow
13
+
14
+ ### Step 1: Read Current Expertise
15
+ Load your expertise file at `packages/cli/src/core/experts/codebase-query/expertise.yaml`.
16
+
17
+ Understand what you currently know about:
18
+ - Query types and translations
19
+ - Available tags
20
+ - Natural language patterns
21
+ - Fallback strategies
22
+
23
+ ### Step 2: Analyze What Changed
24
+
25
+ **If git diff available:**
26
+ ```bash
27
+ git diff HEAD~1 --name-only | grep -E "(codebase-indexer|query-codebase)"
28
+ ```
29
+
30
+ **If context provided:**
31
+ Use the argument/context to understand what changed.
32
+
33
+ **If neither:**
34
+ Compare expertise file against actual codebase state.
35
+
36
+ ### Step 3: Update Expertise
37
+
38
+ **Update `query_types` section if:**
39
+ - New query flags added
40
+ - Query behavior changed
41
+ - New examples discovered
42
+
43
+ **Update `available_tags` section if:**
44
+ - New tags added to TAG_PATTERNS
45
+ - Tag patterns changed
46
+ - Tag descriptions updated
47
+
48
+ **Update `nl_patterns` section if:**
49
+ - New natural language patterns discovered
50
+ - Better translations found
51
+ - User preferences learned
52
+
53
+ **Update `fallbacks` section if:**
54
+ - New fallback strategies needed
55
+ - Edge cases discovered
56
+ - Error handling improved
57
+
58
+ **ALWAYS add to `learnings` section:**
59
+ ```yaml
60
+ learnings:
61
+ - date: YYYY-MM-DD
62
+ context: "What prompted this update"
63
+ insight: "What you learned"
64
+ source: "Where you learned it"
65
+ ```
66
+
67
+ ### Step 4: Save Updated Expertise
68
+ Edit the expertise file with your updates.
69
+
70
+ ### Learning Signals
71
+
72
+ **High-confidence signals** (definitely add to learnings):
73
+ - User explicitly corrected a translation
74
+ - Query returned wrong results
75
+ - New query pattern worked well
76
+ - Index build revealed new patterns
77
+
78
+ **Medium-confidence signals** (consider adding):
79
+ - User rephrased query differently
80
+ - Multiple query types combined
81
+ - Fallback strategy used
82
+
83
+ **Low-confidence signals** (observe but don't add yet):
84
+ - Single-use query patterns
85
+ - Unusual file structures
86
+
87
+ ### Example Learning Entry
88
+
89
+ ```yaml
90
+ learnings:
91
+ - date: 2026-01-19
92
+ context: "User asked for 'authentication middleware'"
93
+ insight: "Combine --tag='auth' with --query='middleware' for auth middleware files"
94
+ source: "User query feedback"
95
+ ```
96
+
97
+ ## Output Format
98
+
99
+ After updating, confirm:
100
+ ```
101
+ Updated expertise.yaml:
102
+ - Added learning: [brief description]
103
+ - Updated [section]: [what changed]
104
+ - Version: [new version]
105
+ ```