agileflow 2.90.7 → 2.92.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 (144) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +6 -6
  3. package/lib/README.md +178 -0
  4. package/lib/codebase-indexer.js +818 -0
  5. package/lib/colors.js +190 -12
  6. package/lib/consent.js +232 -0
  7. package/lib/correlation.js +277 -0
  8. package/lib/error-codes.js +46 -0
  9. package/lib/errors.js +48 -6
  10. package/lib/file-cache.js +182 -0
  11. package/lib/format-error.js +156 -0
  12. package/lib/path-resolver.js +155 -7
  13. package/lib/paths.js +212 -20
  14. package/lib/placeholder-registry.js +205 -0
  15. package/lib/registry-di.js +358 -0
  16. package/lib/result-schema.js +363 -0
  17. package/lib/result.js +210 -0
  18. package/lib/session-registry.js +13 -0
  19. package/lib/session-state-machine.js +465 -0
  20. package/lib/validate-commands.js +308 -0
  21. package/lib/validate-names.js +3 -3
  22. package/lib/validate.js +116 -52
  23. package/package.json +4 -1
  24. package/scripts/af +34 -0
  25. package/scripts/agent-loop.js +63 -9
  26. package/scripts/agileflow-configure.js +2 -2
  27. package/scripts/agileflow-welcome.js +435 -23
  28. package/scripts/archive-completed-stories.sh +57 -11
  29. package/scripts/claude-tmux.sh +102 -0
  30. package/scripts/damage-control-bash.js +3 -70
  31. package/scripts/damage-control-edit.js +3 -20
  32. package/scripts/damage-control-write.js +3 -20
  33. package/scripts/dependency-check.js +310 -0
  34. package/scripts/get-env.js +11 -4
  35. package/scripts/lib/configure-detect.js +23 -1
  36. package/scripts/lib/configure-features.js +43 -2
  37. package/scripts/lib/context-formatter.js +771 -0
  38. package/scripts/lib/context-loader.js +699 -0
  39. package/scripts/lib/damage-control-utils.js +107 -0
  40. package/scripts/lib/json-utils.sh +162 -0
  41. package/scripts/lib/state-migrator.js +353 -0
  42. package/scripts/lib/story-state-machine.js +437 -0
  43. package/scripts/obtain-context.js +118 -1048
  44. package/scripts/pre-push-check.sh +46 -0
  45. package/scripts/precompact-context.sh +36 -11
  46. package/scripts/query-codebase.js +538 -0
  47. package/scripts/ralph-loop.js +5 -5
  48. package/scripts/session-manager.js +220 -42
  49. package/scripts/spawn-parallel.js +651 -0
  50. package/scripts/tui/blessed/data/watcher.js +180 -0
  51. package/scripts/tui/blessed/index.js +244 -0
  52. package/scripts/tui/blessed/panels/output.js +101 -0
  53. package/scripts/tui/blessed/panels/sessions.js +150 -0
  54. package/scripts/tui/blessed/panels/trace.js +97 -0
  55. package/scripts/tui/blessed/ui/help.js +77 -0
  56. package/scripts/tui/blessed/ui/screen.js +52 -0
  57. package/scripts/tui/blessed/ui/statusbar.js +47 -0
  58. package/scripts/tui/blessed/ui/tabbar.js +99 -0
  59. package/scripts/tui/index.js +38 -30
  60. package/scripts/validators/README.md +143 -0
  61. package/scripts/validators/component-validator.js +239 -0
  62. package/scripts/validators/json-schema-validator.js +186 -0
  63. package/scripts/validators/markdown-validator.js +152 -0
  64. package/scripts/validators/migration-validator.js +129 -0
  65. package/scripts/validators/security-validator.js +380 -0
  66. package/scripts/validators/story-format-validator.js +197 -0
  67. package/scripts/validators/test-result-validator.js +114 -0
  68. package/scripts/validators/workflow-validator.js +247 -0
  69. package/src/core/agents/accessibility.md +6 -0
  70. package/src/core/agents/adr-writer.md +6 -0
  71. package/src/core/agents/analytics.md +6 -0
  72. package/src/core/agents/api.md +6 -0
  73. package/src/core/agents/ci.md +6 -0
  74. package/src/core/agents/codebase-query.md +261 -0
  75. package/src/core/agents/compliance.md +6 -0
  76. package/src/core/agents/configuration-damage-control.md +6 -0
  77. package/src/core/agents/configuration-visual-e2e.md +6 -0
  78. package/src/core/agents/database.md +10 -0
  79. package/src/core/agents/datamigration.md +6 -0
  80. package/src/core/agents/design.md +6 -0
  81. package/src/core/agents/devops.md +6 -0
  82. package/src/core/agents/documentation.md +6 -0
  83. package/src/core/agents/epic-planner.md +6 -0
  84. package/src/core/agents/integrations.md +6 -0
  85. package/src/core/agents/mentor.md +6 -0
  86. package/src/core/agents/mobile.md +6 -0
  87. package/src/core/agents/monitoring.md +6 -0
  88. package/src/core/agents/multi-expert.md +6 -0
  89. package/src/core/agents/performance.md +6 -0
  90. package/src/core/agents/product.md +6 -0
  91. package/src/core/agents/qa.md +6 -0
  92. package/src/core/agents/readme-updater.md +6 -0
  93. package/src/core/agents/refactor.md +6 -0
  94. package/src/core/agents/research.md +6 -0
  95. package/src/core/agents/security.md +6 -0
  96. package/src/core/agents/testing.md +10 -0
  97. package/src/core/agents/ui.md +6 -0
  98. package/src/core/commands/adr.md +114 -0
  99. package/src/core/commands/agent.md +120 -0
  100. package/src/core/commands/assign.md +145 -0
  101. package/src/core/commands/audit.md +401 -0
  102. package/src/core/commands/babysit.md +32 -5
  103. package/src/core/commands/board.md +1 -0
  104. package/src/core/commands/changelog.md +118 -0
  105. package/src/core/commands/configure.md +42 -6
  106. package/src/core/commands/diagnose.md +114 -0
  107. package/src/core/commands/epic.md +205 -1
  108. package/src/core/commands/handoff.md +128 -0
  109. package/src/core/commands/help.md +76 -0
  110. package/src/core/commands/metrics.md +1 -0
  111. package/src/core/commands/pr.md +96 -0
  112. package/src/core/commands/research/analyze.md +1 -0
  113. package/src/core/commands/research/ask.md +2 -0
  114. package/src/core/commands/research/import.md +1 -0
  115. package/src/core/commands/research/list.md +2 -0
  116. package/src/core/commands/research/synthesize.md +584 -0
  117. package/src/core/commands/research/view.md +2 -0
  118. package/src/core/commands/roadmap/analyze.md +400 -0
  119. package/src/core/commands/session/new.md +113 -6
  120. package/src/core/commands/session/spawn.md +197 -0
  121. package/src/core/commands/sprint.md +22 -0
  122. package/src/core/commands/status.md +200 -1
  123. package/src/core/commands/story/list.md +9 -9
  124. package/src/core/commands/story/view.md +1 -0
  125. package/src/core/commands/story.md +143 -4
  126. package/src/core/experts/codebase-query/expertise.yaml +190 -0
  127. package/src/core/experts/codebase-query/question.md +73 -0
  128. package/src/core/experts/codebase-query/self-improve.md +105 -0
  129. package/src/core/templates/agileflow-metadata.json +55 -2
  130. package/src/core/templates/plan-template.md +125 -0
  131. package/src/core/templates/story-lifecycle.md +213 -0
  132. package/src/core/templates/story-template.md +4 -0
  133. package/src/core/templates/tdd-test-template.js +241 -0
  134. package/tools/cli/commands/setup.js +86 -0
  135. package/tools/cli/installers/core/installer.js +94 -0
  136. package/tools/cli/installers/ide/_base-ide.js +20 -11
  137. package/tools/cli/installers/ide/codex.js +29 -47
  138. package/tools/cli/lib/config-manager.js +17 -2
  139. package/tools/cli/lib/content-transformer.js +271 -0
  140. package/tools/cli/lib/error-handler.js +14 -22
  141. package/tools/cli/lib/ide-error-factory.js +421 -0
  142. package/tools/cli/lib/ide-health-monitor.js +364 -0
  143. package/tools/cli/lib/ide-registry.js +114 -1
  144. package/tools/cli/lib/ui.js +14 -25
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Workflow Validator
4
+ *
5
+ * Validates GitHub Actions and other CI/CD workflow files.
6
+ *
7
+ * Exit codes:
8
+ * 0 = Success
9
+ * 2 = Error (Claude will attempt to fix)
10
+ * 1 = Warning (logged but not blocking)
11
+ *
12
+ * Usage in agent hooks:
13
+ * hooks:
14
+ * PostToolUse:
15
+ * - matcher: "Write"
16
+ * hooks:
17
+ * - type: command
18
+ * command: "node .agileflow/hooks/validators/workflow-validator.js"
19
+ */
20
+
21
+ const fs = require('fs');
22
+ const path = require('path');
23
+
24
+ let input = '';
25
+ process.stdin.on('data', chunk => (input += chunk));
26
+ process.stdin.on('end', () => {
27
+ try {
28
+ const context = JSON.parse(input);
29
+ const filePath = context.tool_input?.file_path;
30
+
31
+ // Only validate workflow files
32
+ if (!filePath || !isWorkflowFile(filePath)) {
33
+ process.exit(0);
34
+ }
35
+
36
+ // Skip if file doesn't exist
37
+ if (!fs.existsSync(filePath)) {
38
+ console.log(`File not found: ${filePath} (skipping validation)`);
39
+ process.exit(0);
40
+ }
41
+
42
+ const issues = validateWorkflow(filePath);
43
+
44
+ if (issues.length > 0) {
45
+ console.error(`Fix these workflow issues in ${filePath}:`);
46
+ issues.forEach(i => console.error(` - ${i}`));
47
+ process.exit(2); // Claude will fix
48
+ }
49
+
50
+ console.log(`Workflow validation passed: ${filePath}`);
51
+ process.exit(0);
52
+ } catch (e) {
53
+ console.error(`Validator error: ${e.message}`);
54
+ process.exit(1);
55
+ }
56
+ });
57
+
58
+ function isWorkflowFile(filePath) {
59
+ const normalizedPath = filePath.toLowerCase();
60
+
61
+ // GitHub Actions
62
+ if (normalizedPath.includes('.github/workflows/') && normalizedPath.endsWith('.yml')) {
63
+ return true;
64
+ }
65
+ if (normalizedPath.includes('.github/workflows/') && normalizedPath.endsWith('.yaml')) {
66
+ return true;
67
+ }
68
+
69
+ // GitLab CI
70
+ if (normalizedPath.endsWith('.gitlab-ci.yml') || normalizedPath.endsWith('.gitlab-ci.yaml')) {
71
+ return true;
72
+ }
73
+
74
+ // Circle CI
75
+ if (normalizedPath.includes('.circleci/config.yml')) {
76
+ return true;
77
+ }
78
+
79
+ // Azure Pipelines
80
+ if (
81
+ normalizedPath.endsWith('azure-pipelines.yml') ||
82
+ normalizedPath.endsWith('azure-pipelines.yaml')
83
+ ) {
84
+ return true;
85
+ }
86
+
87
+ return false;
88
+ }
89
+
90
+ function validateWorkflow(filePath) {
91
+ const issues = [];
92
+
93
+ try {
94
+ const content = fs.readFileSync(filePath, 'utf8');
95
+ const normalizedPath = filePath.toLowerCase();
96
+
97
+ // Check for empty file
98
+ if (!content.trim()) {
99
+ issues.push('Workflow file is empty');
100
+ return issues;
101
+ }
102
+
103
+ // Basic YAML structure check
104
+ if (!isValidYamlStructure(content)) {
105
+ issues.push('Invalid YAML structure - check indentation and syntax');
106
+ return issues;
107
+ }
108
+
109
+ // GitHub Actions specific validation
110
+ if (normalizedPath.includes('.github/workflows/')) {
111
+ issues.push(...validateGitHubActions(content));
112
+ }
113
+
114
+ // GitLab CI specific validation
115
+ if (normalizedPath.includes('.gitlab-ci.')) {
116
+ issues.push(...validateGitLabCI(content));
117
+ }
118
+
119
+ // General CI/CD security checks
120
+ issues.push(...validateCISecurity(content));
121
+ } catch (e) {
122
+ issues.push(`Read error: ${e.message}`);
123
+ }
124
+
125
+ return issues;
126
+ }
127
+
128
+ function isValidYamlStructure(content) {
129
+ // Basic checks for common YAML issues
130
+ const lines = content.split('\n');
131
+
132
+ for (let i = 0; i < lines.length; i++) {
133
+ const line = lines[i];
134
+
135
+ // Check for tabs (YAML should use spaces)
136
+ if (line.includes('\t')) {
137
+ return false;
138
+ }
139
+
140
+ // Check for invalid indentation (odd spaces at line start are suspicious)
141
+ const leadingSpaces = line.match(/^( *)/)[1].length;
142
+ if (leadingSpaces % 2 !== 0 && line.trim().length > 0) {
143
+ // Could be valid, but flag for review
144
+ console.log(`Note: Unusual indentation (${leadingSpaces} spaces) at line ${i + 1}`);
145
+ }
146
+ }
147
+
148
+ return true;
149
+ }
150
+
151
+ function validateGitHubActions(content) {
152
+ const issues = [];
153
+
154
+ // Check for 'on' trigger
155
+ if (!content.includes('on:')) {
156
+ issues.push('GitHub Actions workflow must have an "on:" trigger section');
157
+ }
158
+
159
+ // Check for jobs section
160
+ if (!content.includes('jobs:')) {
161
+ issues.push('GitHub Actions workflow must have a "jobs:" section');
162
+ }
163
+
164
+ // Check for runs-on in jobs
165
+ if (content.includes('jobs:') && !content.includes('runs-on:')) {
166
+ issues.push('Jobs must specify "runs-on:" for the runner');
167
+ }
168
+
169
+ // Check for deprecated set-output
170
+ if (content.includes('::set-output')) {
171
+ issues.push('::set-output is deprecated - use $GITHUB_OUTPUT instead');
172
+ }
173
+
174
+ // Check for deprecated save-state
175
+ if (content.includes('::save-state')) {
176
+ issues.push('::save-state is deprecated - use $GITHUB_STATE instead');
177
+ }
178
+
179
+ // Check for hardcoded action versions without SHA
180
+ const actionVersions = content.match(/uses:\s*[\w-]+\/[\w-]+@v?\d+/gi) || [];
181
+ if (actionVersions.length > 0) {
182
+ console.log('Note: Consider pinning actions to specific SHA for security');
183
+ }
184
+
185
+ // Check for potentially dangerous permissions
186
+ if (
187
+ content.includes('permissions: write-all') ||
188
+ content.includes('permissions:\n contents: write')
189
+ ) {
190
+ console.log('Note: Broad write permissions detected - ensure this is necessary');
191
+ }
192
+
193
+ // Check for secrets usage
194
+ if (content.includes('${{ secrets.') && !content.includes('secrets:')) {
195
+ // Using secrets but didn't declare them - common but worth noting
196
+ }
197
+
198
+ return issues;
199
+ }
200
+
201
+ function validateGitLabCI(content) {
202
+ const issues = [];
203
+
204
+ // Check for stages
205
+ if (!content.includes('stages:') && !content.includes('stage:')) {
206
+ console.log('Note: Consider defining stages for better pipeline organization');
207
+ }
208
+
209
+ // Check for image
210
+ if (!content.includes('image:')) {
211
+ console.log('Note: No default image specified - jobs should specify their image');
212
+ }
213
+
214
+ return issues;
215
+ }
216
+
217
+ function validateCISecurity(content) {
218
+ const issues = [];
219
+
220
+ // Check for hardcoded secrets (common patterns)
221
+ const secretPatterns = [
222
+ { pattern: /api[_-]?key\s*[:=]\s*["'][^$]/i, message: 'Possible hardcoded API key detected' },
223
+ { pattern: /password\s*[:=]\s*["'][^$]/i, message: 'Possible hardcoded password detected' },
224
+ { pattern: /secret\s*[:=]\s*["'][^$]/i, message: 'Possible hardcoded secret detected' },
225
+ { pattern: /token\s*[:=]\s*["'][^$]/i, message: 'Possible hardcoded token detected' },
226
+ ];
227
+
228
+ for (const { pattern, message } of secretPatterns) {
229
+ if (pattern.test(content)) {
230
+ issues.push(`${message} - use secrets/environment variables instead`);
231
+ }
232
+ }
233
+
234
+ // Check for curl | bash pattern (security risk)
235
+ if (content.includes('curl') && content.includes('| bash')) {
236
+ issues.push(
237
+ 'curl | bash pattern detected - this is a security risk, use verified installation methods'
238
+ );
239
+ }
240
+
241
+ // Check for npm install without lockfile
242
+ if (content.includes('npm install') && !content.includes('npm ci')) {
243
+ console.log('Note: Consider using "npm ci" instead of "npm install" for reproducible builds');
244
+ }
245
+
246
+ return issues;
247
+ }
@@ -3,6 +3,12 @@ name: agileflow-accessibility
3
3
  description: Accessibility specialist for WCAG compliance, inclusive design, assistive technology support, and accessibility testing.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/component-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-adr-writer
3
3
  description: Architecture Decision Record specialist. Use for documenting technical decisions, trade-offs, and alternatives considered. Ensures decisions are recorded for future reference.
4
4
  tools: Read, Write, Edit, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/markdown-validator.js"
6
12
  compact_context:
7
13
  priority: "high"
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-analytics
3
3
  description: Analytics specialist for event tracking, data analysis, metrics dashboards, user behavior analysis, and data-driven insights.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/security-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-api
3
3
  description: Services/data layer specialist. Use for implementing backend APIs, business logic, data models, database access, and stories tagged with owner AG-API.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/json-schema-validator.js"
6
12
  compact_context:
7
13
  priority: critical
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-ci
3
3
  description: CI/CD and quality specialist. Use for setting up workflows, test infrastructure, linting, type checking, coverage, and stories tagged with owner AG-CI.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/workflow-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -0,0 +1,261 @@
1
+ ---
2
+ name: agileflow-codebase-query
3
+ description: Intelligent codebase search using programmatic queries instead of RAG. Translates natural language to structured queries for fast, targeted code exploration.
4
+ tools: Read, Glob, Grep
5
+ model: haiku
6
+ compact_context:
7
+ priority: "high"
8
+ preserve_rules:
9
+ - "READ-ONLY: No Write/Edit tools - exploration only"
10
+ - "Translate natural language → structured queries"
11
+ - "Use codebase index for fast lookups"
12
+ - "Token-budget aware - truncate long results"
13
+ - "Fall back to grep/glob if index unavailable"
14
+ state_fields:
15
+ - "index_status: built | stale | missing"
16
+ - "last_query: Natural language query"
17
+ - "query_type: files | content | deps | tag | export"
18
+ - "result_count: Number of matches"
19
+ ---
20
+
21
+ ## STEP 0: Check Index Status
22
+
23
+ ```bash
24
+ node packages/cli/scripts/query-codebase.js --build-index --json 2>/dev/null | head -1
25
+ ```
26
+
27
+ ---
28
+
29
+ <!-- COMPACT_SUMMARY_START -->
30
+
31
+ ## COMPACT SUMMARY - CODEBASE QUERY AGENT
32
+
33
+ CRITICAL: You are a READ-ONLY search agent. Translate natural language queries into structured codebase searches. Use programmatic search (RLM pattern) instead of loading full context.
34
+
35
+ RULE #1: QUERY TRANSLATION
36
+ | Natural Language | Structured Query |
37
+ |-----------------|------------------|
38
+ | "auth files" | `--query="auth"` or `--tag="auth"` |
39
+ | "what uses login" | `--export="login"` |
40
+ | "files with validateToken" | `--content="validateToken"` |
41
+ | "api route files" | `--query="src/api/**/*.ts"` |
42
+ | "dependencies of auth.js" | `--deps="src/auth.js"` |
43
+ | "database models" | `--tag="database"` |
44
+ | "React components" | `--tag="ui"` + `--content="React"` |
45
+
46
+ RULE #2: QUERY TYPES
47
+ ```
48
+ --query="pattern" # Smart search (glob + tag + export)
49
+ --content="regex" # Grep-style content search
50
+ --tag="name" # Search by tag (api, ui, auth, database, test)
51
+ --export="symbol" # Find export locations
52
+ --deps="file" # Show file dependencies
53
+ --build-index # Rebuild index (when stale)
54
+ ```
55
+
56
+ RULE #3: AVAILABLE TAGS
57
+ | Tag | Matches |
58
+ |-----|---------|
59
+ | api | /api/, /routes/, /controllers/ |
60
+ | ui | /components/, /views/, /pages/ |
61
+ | auth | /auth/, /login/, /jwt/ |
62
+ | database | /db/, /models/, /migrations/ |
63
+ | test | /test/, /__tests__/, /spec/ |
64
+ | config | /config/, /settings/ |
65
+ | lib | /lib/, /utils/, /helpers/ |
66
+
67
+ RULE #4: FALLBACK STRATEGY
68
+ If index unavailable:
69
+ 1. Use Glob for file patterns: `Glob("**/*auth*.{js,ts}")`
70
+ 2. Use Grep for content: `Grep("validateToken")`
71
+ 3. Combine results, deduplicate
72
+
73
+ RULE #5: TOKEN BUDGET
74
+ - Default budget: 15000 characters
75
+ - For large results, use `--budget=5000` to summarize
76
+ - Show file count + truncation notice
77
+
78
+ ### Anti-Patterns (DON'T)
79
+ ❌ Use Write/Edit tools → You are READ-ONLY
80
+ ❌ Load entire codebase → Use targeted queries
81
+ ❌ Ignore index → Check/build index first
82
+ ❌ Return raw file contents → Return structured results
83
+ ❌ Exceed token budget → Truncate with notice
84
+
85
+ ### Correct Patterns (DO)
86
+ ✅ Translate natural language to query type
87
+ ✅ Check index status before querying
88
+ ✅ Combine query types for complex searches
89
+ ✅ Show match count and file paths
90
+ ✅ Explain what was searched and how
91
+
92
+ ### Query Script Usage
93
+ ```bash
94
+ # Build/check index
95
+ node packages/cli/scripts/query-codebase.js --build-index
96
+
97
+ # Search by pattern/keyword
98
+ node packages/cli/scripts/query-codebase.js --query="auth"
99
+
100
+ # Search file content
101
+ node packages/cli/scripts/query-codebase.js --content="validateToken"
102
+
103
+ # Search by tag
104
+ node packages/cli/scripts/query-codebase.js --tag="api"
105
+
106
+ # Find export locations
107
+ node packages/cli/scripts/query-codebase.js --export="login"
108
+
109
+ # Show dependencies
110
+ node packages/cli/scripts/query-codebase.js --deps="src/auth.js"
111
+
112
+ # Show equivalent bash workflow (educational)
113
+ node packages/cli/scripts/query-codebase.js --query="auth" --explain
114
+
115
+ # Verbose mode shows step-by-step exploration
116
+ node packages/cli/scripts/query-codebase.js --query="auth" --verbose
117
+ ```
118
+
119
+ ### Understanding the Approach (--explain)
120
+ Use `--explain` to see the equivalent bash commands:
121
+ ```
122
+ 📖 Equivalent Bash Workflow:
123
+
124
+ # Step 1: List available directories (ls)
125
+ ls -la /project/src/
126
+
127
+ # Step 2: Find files matching pattern (find)
128
+ find /project -name "*auth*" -type f
129
+
130
+ # Step 3: Search content within files (grep)
131
+ grep -rl "auth" /project/src/
132
+
133
+ # This tool combines all three with indexing for speed.
134
+ ```
135
+ This follows the Unix "everything is a file" philosophy - using file system navigation instead of vector databases (RAG).
136
+
137
+ ### Result Format
138
+ ```
139
+ Query: "authentication files"
140
+ Translation: --query="auth" + --tag="auth"
141
+ Found: 15 files
142
+
143
+ Files:
144
+ - src/api/auth.ts (api, auth)
145
+ - src/middleware/auth.ts (auth)
146
+ - src/lib/jwt.ts (auth, lib)
147
+ ...
148
+
149
+ [Showing 15 of 15 results]
150
+ ```
151
+
152
+ ### REMEMBER AFTER COMPACTION
153
+ 1. READ-ONLY agent - no Write/Edit
154
+ 2. Translate NL → structured query
155
+ 3. Check index, build if needed
156
+ 4. Return file paths + match context
157
+ 5. Truncate if over budget
158
+
159
+ <!-- COMPACT_SUMMARY_END -->
160
+
161
+ You are the AgileFlow Codebase Query Agent, a specialist in fast, targeted codebase exploration using programmatic search (RLM pattern).
162
+
163
+ ROLE & IDENTITY
164
+ - Agent ID: CODEBASE-QUERY
165
+ - Specialization: Natural language → structured codebase queries
166
+ - Model: Haiku (cost-efficient for focused search)
167
+ - Part of the RLM-inspired Codebase Query Interface (EP-0021)
168
+
169
+ SCOPE
170
+ - Translating natural language questions to structured queries
171
+ - Searching codebase by file pattern, content, tag, export, or dependencies
172
+ - Returning relevant file paths and match context
173
+ - Token-budget-aware result truncation
174
+
175
+ WHAT YOU CAN DO
176
+ - Query files by pattern/keyword
177
+ - Search file content (grep-style)
178
+ - Find files by tag (api, ui, auth, database, test)
179
+ - Find files exporting a symbol
180
+ - Show file dependencies (imports/importedBy)
181
+ - Build/update codebase index
182
+
183
+ WHAT YOU CANNOT DO (READ-ONLY)
184
+ - Write or edit files
185
+ - Create new files
186
+ - Modify the codebase in any way
187
+ - Execute code that changes state
188
+
189
+ QUERY TRANSLATION EXAMPLES
190
+
191
+ | User Says | Query Type | Translation |
192
+ |-----------|------------|-------------|
193
+ | "Where is authentication handled?" | tag + query | `--tag="auth"` + `--query="auth"` |
194
+ | "What files use the login function?" | export | `--export="login"` |
195
+ | "Find files with error handling" | content | `--content="try.*catch|\.catch\\("` |
196
+ | "Show me API routes" | tag | `--tag="api"` |
197
+ | "What does user.ts depend on?" | deps | `--deps="src/user.ts"` |
198
+ | "Database schema files" | tag + query | `--tag="database"` + `--query="schema"` |
199
+ | "React components using hooks" | content | `--content="use(State|Effect|Ref)"` |
200
+ | "All test files" | tag | `--tag="test"` |
201
+ | "Files exporting User class" | export | `--export="User"` |
202
+
203
+ WORKFLOW
204
+
205
+ 1. **Parse Query**: Understand what the user is looking for
206
+ 2. **Translate**: Convert to structured query type(s)
207
+ 3. **Check Index**: Ensure index is available (build if needed)
208
+ 4. **Execute Query**: Run query-codebase.js with appropriate flags
209
+ 5. **Format Results**: Return file paths with context
210
+ 6. **Truncate if Needed**: Respect token budget
211
+
212
+ FIRST ACTION
213
+
214
+ When invoked, check index status first:
215
+ ```bash
216
+ node packages/cli/scripts/query-codebase.js --build-index 2>&1 | head -10
217
+ ```
218
+
219
+ Then ask: "What would you like to find in the codebase?"
220
+
221
+ FALLBACK BEHAVIOR
222
+
223
+ If the query script is unavailable:
224
+ 1. Use Glob tool for file pattern matching
225
+ 2. Use Grep tool for content searching
226
+ 3. Use Read tool to examine specific files
227
+ 4. Combine and deduplicate results manually
228
+
229
+ AGENT COORDINATION
230
+
231
+ This agent is typically invoked by:
232
+ - **MENTOR**: To find relevant code for a feature
233
+ - **AG-API**: To locate existing implementations
234
+ - **REFACTOR**: To find code patterns to update
235
+ - **DEVOPS**: To find configuration files
236
+
237
+ Results are returned directly (no bus messaging needed for read-only queries).
238
+
239
+ OUTPUT FORMAT
240
+
241
+ Always structure your response as:
242
+ ```
243
+ Query: "[original natural language query]"
244
+ Translation: [query flags used]
245
+ Index Status: [built/stale/missing]
246
+ Found: [N] files
247
+
248
+ Files:
249
+ - path/to/file.ts (tags)
250
+ - path/to/other.ts (tags)
251
+ ...
252
+
253
+ [Context: brief explanation of what was searched]
254
+ ```
255
+
256
+ For content searches, include matching line context:
257
+ ```
258
+ Matches in path/to/file.ts:
259
+ 42: const token = validateToken(input);
260
+ 85: if (!validateToken(refreshToken)) {
261
+ ```
@@ -3,6 +3,12 @@ name: agileflow-compliance
3
3
  description: Compliance specialist for regulatory compliance, GDPR, HIPAA, SOC2, audit trails, legal requirements, and compliance documentation.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/security-validator.js"
6
12
  compact_context:
7
13
  priority: critical
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: configuration-damage-control
3
3
  description: Configure AgileFlow damage control to protect against destructive commands
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/json-schema-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: configuration-visual-e2e
3
3
  description: Configure Visual E2E testing infrastructure with Playwright and screenshot verification
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/json-schema-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -3,6 +3,16 @@ name: agileflow-database
3
3
  description: Database specialist for schema design, migrations, query optimization, data modeling, and database-intensive features.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/json-schema-validator.js"
12
+ - matcher: "Bash"
13
+ hooks:
14
+ - type: command
15
+ command: "node .agileflow/hooks/validators/migration-validator.js"
6
16
  compact_context:
7
17
  priority: high
8
18
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-datamigration
3
3
  description: Data migration specialist for zero-downtime migrations, data validation, rollback strategies, and large-scale data movements.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Bash"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/migration-validator.js"
6
12
  compact_context:
7
13
  priority: critical
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-design
3
3
  description: Design specialist for UI/UX design systems, visual design, design patterns, design documentation, and design-driven development.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/component-validator.js"
6
12
  compact_context:
7
13
  priority: "high"
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-devops
3
3
  description: DevOps and automation specialist. Use for dependency management, deployment setup, testing infrastructure, code quality, impact analysis, technical debt tracking, and changelog generation.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/json-schema-validator.js"
6
12
  compact_context:
7
13
  priority: high
8
14
  preserve_rules:
@@ -3,6 +3,12 @@ name: agileflow-documentation
3
3
  description: Documentation specialist for technical docs, API documentation, user guides, tutorials, and documentation maintenance.
4
4
  tools: Read, Write, Edit, Bash, Glob, Grep
5
5
  model: haiku
6
+ hooks:
7
+ PostToolUse:
8
+ - matcher: "Write"
9
+ hooks:
10
+ - type: command
11
+ command: "node .agileflow/hooks/validators/markdown-validator.js"
6
12
  compact_context:
7
13
  priority: medium
8
14
  preserve_rules: