aios-core 4.1.0 → 4.2.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 (145) hide show
  1. package/.aios-core/.session/current-session.json +14 -0
  2. package/.aios-core/core/registry/registry-schema.json +166 -166
  3. package/.aios-core/core/registry/service-registry.json +6585 -6585
  4. package/.aios-core/data/entity-registry.yaml +208 -8
  5. package/.aios-core/data/registry-update-log.jsonl +165 -0
  6. package/.aios-core/development/scripts/approval-workflow.js +642 -642
  7. package/.aios-core/development/scripts/backup-manager.js +606 -606
  8. package/.aios-core/development/scripts/branch-manager.js +389 -389
  9. package/.aios-core/development/scripts/code-quality-improver.js +1311 -1311
  10. package/.aios-core/development/scripts/commit-message-generator.js +849 -849
  11. package/.aios-core/development/scripts/conflict-resolver.js +674 -674
  12. package/.aios-core/development/scripts/dependency-analyzer.js +637 -637
  13. package/.aios-core/development/scripts/diff-generator.js +351 -351
  14. package/.aios-core/development/scripts/elicitation-engine.js +384 -384
  15. package/.aios-core/development/scripts/elicitation-session-manager.js +299 -299
  16. package/.aios-core/development/scripts/git-wrapper.js +461 -461
  17. package/.aios-core/development/scripts/manifest-preview.js +244 -244
  18. package/.aios-core/development/scripts/metrics-tracker.js +775 -775
  19. package/.aios-core/development/scripts/modification-validator.js +554 -554
  20. package/.aios-core/development/scripts/pattern-learner.js +1224 -1224
  21. package/.aios-core/development/scripts/performance-analyzer.js +757 -757
  22. package/.aios-core/development/scripts/refactoring-suggester.js +1138 -1138
  23. package/.aios-core/development/scripts/rollback-handler.js +530 -530
  24. package/.aios-core/development/scripts/security-checker.js +358 -358
  25. package/.aios-core/development/scripts/template-engine.js +239 -239
  26. package/.aios-core/development/scripts/template-validator.js +278 -278
  27. package/.aios-core/development/scripts/test-generator.js +843 -843
  28. package/.aios-core/development/scripts/transaction-manager.js +589 -589
  29. package/.aios-core/development/scripts/usage-tracker.js +673 -673
  30. package/.aios-core/development/scripts/validate-filenames.js +226 -226
  31. package/.aios-core/development/scripts/version-tracker.js +526 -526
  32. package/.aios-core/development/scripts/yaml-validator.js +396 -396
  33. package/.aios-core/development/tasks/validate-next-story.md +99 -2
  34. package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
  35. package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
  36. package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
  37. package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
  38. package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
  39. package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
  40. package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
  41. package/.aios-core/development/templates/squad-template/LICENSE +21 -21
  42. package/.aios-core/docs/SHARD-TRANSLATION-GUIDE.md +335 -0
  43. package/.aios-core/docs/component-creation-guide.md +458 -0
  44. package/.aios-core/docs/session-update-pattern.md +307 -0
  45. package/.aios-core/docs/standards/AIOS-FRAMEWORK-MASTER.md +1963 -0
  46. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-SUMMARY.md +1190 -0
  47. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1.md +439 -0
  48. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO.md +5398 -0
  49. package/.aios-core/docs/standards/V3-ARCHITECTURAL-DECISIONS.md +523 -0
  50. package/.aios-core/docs/template-syntax.md +267 -0
  51. package/.aios-core/docs/troubleshooting-guide.md +625 -0
  52. package/.aios-core/infrastructure/templates/aios-sync.yaml.template +193 -193
  53. package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
  54. package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
  55. package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
  56. package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
  57. package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
  58. package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
  59. package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
  60. package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
  61. package/.aios-core/infrastructure/tests/utilities-audit-results.json +501 -0
  62. package/.aios-core/install-manifest.yaml +101 -101
  63. package/.aios-core/local-config.yaml.template +70 -70
  64. package/.aios-core/manifests/agents.csv +29 -0
  65. package/.aios-core/manifests/schema/manifest-schema.json +190 -190
  66. package/.aios-core/manifests/tasks.csv +198 -0
  67. package/.aios-core/manifests/workers.csv +204 -0
  68. package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
  69. package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
  70. package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
  71. package/.aios-core/monitor/hooks/notification.py +29 -29
  72. package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
  73. package/.aios-core/monitor/hooks/pre_compact.py +29 -29
  74. package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
  75. package/.aios-core/monitor/hooks/stop.py +29 -29
  76. package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
  77. package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
  78. package/.aios-core/product/templates/adr.hbs +125 -125
  79. package/.aios-core/product/templates/component-react-tmpl.tsx +98 -98
  80. package/.aios-core/product/templates/dbdr.hbs +241 -241
  81. package/.aios-core/product/templates/engine/schemas/adr.schema.json +102 -102
  82. package/.aios-core/product/templates/engine/schemas/dbdr.schema.json +205 -205
  83. package/.aios-core/product/templates/engine/schemas/epic.schema.json +175 -175
  84. package/.aios-core/product/templates/engine/schemas/pmdr.schema.json +175 -175
  85. package/.aios-core/product/templates/engine/schemas/prd-v2.schema.json +300 -300
  86. package/.aios-core/product/templates/engine/schemas/prd.schema.json +152 -152
  87. package/.aios-core/product/templates/engine/schemas/story.schema.json +222 -222
  88. package/.aios-core/product/templates/engine/schemas/task.schema.json +154 -154
  89. package/.aios-core/product/templates/epic.hbs +212 -212
  90. package/.aios-core/product/templates/eslintrc-security.json +32 -32
  91. package/.aios-core/product/templates/github-actions-cd.yml +212 -212
  92. package/.aios-core/product/templates/github-actions-ci.yml +172 -172
  93. package/.aios-core/product/templates/pmdr.hbs +186 -186
  94. package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
  95. package/.aios-core/product/templates/prd.hbs +201 -201
  96. package/.aios-core/product/templates/shock-report-tmpl.html +502 -502
  97. package/.aios-core/product/templates/story.hbs +263 -263
  98. package/.aios-core/product/templates/task.hbs +170 -170
  99. package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
  100. package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
  101. package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
  102. package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
  103. package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
  104. package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
  105. package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
  106. package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
  107. package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
  108. package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
  109. package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
  110. package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
  111. package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
  112. package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
  113. package/.aios-core/product/templates/tmpl-view.sql +177 -177
  114. package/.aios-core/product/templates/token-exports-css-tmpl.css +240 -240
  115. package/.aios-core/quality/schemas/quality-metrics.schema.json +233 -233
  116. package/.aios-core/scripts/migrate-framework-docs.sh +300 -300
  117. package/.aios-core/scripts/pm.sh +0 -0
  118. package/.claude/hooks/enforce-architecture-first.py +196 -196
  119. package/.claude/hooks/mind-clone-governance.py +192 -192
  120. package/.claude/hooks/read-protection.py +151 -151
  121. package/.claude/hooks/slug-validation.py +176 -176
  122. package/.claude/hooks/sql-governance.py +182 -182
  123. package/.claude/hooks/write-path-validation.py +194 -194
  124. package/.claude/rules/agent-authority.md +105 -0
  125. package/.claude/rules/coderabbit-integration.md +93 -0
  126. package/.claude/rules/ids-principles.md +112 -0
  127. package/.claude/rules/story-lifecycle.md +139 -0
  128. package/.claude/rules/workflow-execution.md +150 -0
  129. package/LICENSE +48 -48
  130. package/bin/aios-minimal.js +0 -0
  131. package/bin/aios.js +0 -0
  132. package/package.json +1 -1
  133. package/packages/aios-install/bin/aios-install.js +0 -0
  134. package/packages/aios-install/bin/edmcp.js +0 -0
  135. package/packages/aios-pro-cli/bin/aios-pro.js +0 -0
  136. package/packages/installer/src/wizard/pro-setup.js +433 -49
  137. package/scripts/check-markdown-links.py +352 -352
  138. package/scripts/code-intel-health-check.js +343 -0
  139. package/scripts/dashboard-parallel-dev.sh +0 -0
  140. package/scripts/dashboard-parallel-phase3.sh +0 -0
  141. package/scripts/dashboard-parallel-phase4.sh +0 -0
  142. package/scripts/glue/README.md +355 -0
  143. package/scripts/glue/compose-agent-prompt.cjs +362 -0
  144. package/scripts/install-monitor-hooks.sh +0 -0
  145. package/.aios-core/lib/build.json +0 -1
@@ -0,0 +1,343 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Code Intelligence Health Check
5
+ *
6
+ * Validates that the Code Graph MCP provider is installed, responsive,
7
+ * and its tools are operational. Outputs structured JSON for consumption
8
+ * by NOG-1 abstraction layer and other automation.
9
+ *
10
+ * Usage: node scripts/code-intel-health-check.js [--smoke] [--project-root <path>]
11
+ *
12
+ * Flags:
13
+ * --smoke Run smoke tests with real tool calls
14
+ * --project-root Override project root (default: process.cwd())
15
+ *
16
+ * Exit codes:
17
+ * 0 = available (all checks pass)
18
+ * 1 = degraded (some tools unavailable)
19
+ * 2 = unavailable (server not responding)
20
+ *
21
+ * @story NOG-0
22
+ * @agent @devops (Gage)
23
+ */
24
+
25
+ const { execFile } = require('node:child_process')
26
+ const { promisify } = require('node:util')
27
+ const { existsSync, readFileSync } = require('node:fs')
28
+ const { resolve, join } = require('node:path')
29
+
30
+ const execFileAsync = promisify(execFile)
31
+
32
+ const RESPONSE_TIMEOUT_MS = 5000
33
+ const EXPECTED_TOOLS = [
34
+ 'get_usage_guide',
35
+ 'analyze_codebase',
36
+ 'find_definition',
37
+ 'find_references',
38
+ 'find_callers',
39
+ 'find_callees',
40
+ 'complexity_analysis',
41
+ 'dependency_analysis',
42
+ 'project_statistics'
43
+ ]
44
+
45
+ function parseArgs() {
46
+ const args = process.argv.slice(2)
47
+ return {
48
+ smoke: args.includes('--smoke'),
49
+ projectRoot: getArgValue(args, '--project-root') || process.cwd()
50
+ }
51
+ }
52
+
53
+ function getArgValue(args, flag) {
54
+ const idx = args.indexOf(flag)
55
+ if (idx === -1 || idx + 1 >= args.length) return null
56
+ return args[idx + 1]
57
+ }
58
+
59
+ async function checkBinaryInstalled() {
60
+ try {
61
+ const { stdout } = await execFileAsync('code-graph-mcp', ['--help'], {
62
+ timeout: RESPONSE_TIMEOUT_MS
63
+ })
64
+ return { installed: true, output: stdout.trim() }
65
+ } catch (error) {
66
+ return {
67
+ installed: false,
68
+ error: error.code === 'ENOENT'
69
+ ? 'code-graph-mcp binary not found in PATH'
70
+ : `Binary check failed: ${error.message}`
71
+ }
72
+ }
73
+ }
74
+
75
+ function checkMcpConfig(projectRoot) {
76
+ const mcpJsonPath = join(projectRoot, '.mcp.json')
77
+ if (!existsSync(mcpJsonPath)) {
78
+ return { configured: false, error: '.mcp.json not found' }
79
+ }
80
+
81
+ try {
82
+ const config = JSON.parse(readFileSync(mcpJsonPath, 'utf-8'))
83
+ const servers = config.mcpServers || {}
84
+ const codeGraphEntry = servers['code-graph'] || servers['code-graph-mcp']
85
+
86
+ if (!codeGraphEntry) {
87
+ return { configured: false, error: 'No code-graph entry in .mcp.json mcpServers' }
88
+ }
89
+
90
+ return {
91
+ configured: true,
92
+ serverName: servers['code-graph'] ? 'code-graph' : 'code-graph-mcp',
93
+ config: codeGraphEntry
94
+ }
95
+ } catch (error) {
96
+ return { configured: false, error: `Failed to parse .mcp.json: ${error.message}` }
97
+ }
98
+ }
99
+
100
+ async function checkServerAndTools(projectRoot) {
101
+ const start = Date.now()
102
+ try {
103
+ const child = execFile('code-graph-mcp', ['--project-root', projectRoot])
104
+
105
+ return new Promise((resolvePromise) => {
106
+ let stdout = ''
107
+ let stderr = ''
108
+ let settled = false
109
+
110
+ const settle = (result) => {
111
+ if (settled) return
112
+ settled = true
113
+ resolvePromise(result)
114
+ }
115
+
116
+ child.stdout.on('data', (data) => {
117
+ stdout += data.toString()
118
+ })
119
+
120
+ child.stderr.on('data', (data) => {
121
+ stderr += data.toString()
122
+ })
123
+
124
+ // Send MCP initialize + tools/list via JSON-RPC over stdio
125
+ const initMsg = JSON.stringify({
126
+ jsonrpc: '2.0', id: 1, method: 'initialize',
127
+ params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'health-check', version: '1.0' } }
128
+ })
129
+ const notifyMsg = JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' })
130
+ const listMsg = JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list', params: {} })
131
+
132
+ child.stdin.write(initMsg + '\n')
133
+ child.stdin.write(notifyMsg + '\n')
134
+ child.stdin.write(listMsg + '\n')
135
+
136
+ // Parse JSON-RPC responses as they arrive
137
+ let responseCount = 0
138
+ let actualTools = null
139
+
140
+ const checkResponses = () => {
141
+ const lines = stdout.split('\n').filter((l) => l.trim())
142
+ for (const line of lines) {
143
+ try {
144
+ const msg = JSON.parse(line)
145
+ if (msg.id === 1) responseCount++
146
+ if (msg.id === 2 && msg.result && msg.result.tools) {
147
+ responseCount++
148
+ actualTools = msg.result.tools.map((t) => t.name)
149
+ }
150
+ } catch {
151
+ // partial line
152
+ }
153
+ }
154
+ }
155
+
156
+ // Poll for responses, timeout after RESPONSE_TIMEOUT_MS
157
+ const pollInterval = setInterval(() => {
158
+ checkResponses()
159
+ if (responseCount >= 2) {
160
+ clearInterval(pollInterval)
161
+ clearTimeout(timer)
162
+ child.kill('SIGTERM')
163
+
164
+ const toolReport = EXPECTED_TOOLS.map((name) => ({
165
+ name,
166
+ available: actualTools ? actualTools.includes(name) : false
167
+ }))
168
+
169
+ settle({
170
+ responding: true,
171
+ responseTimeMs: Date.now() - start,
172
+ tools: toolReport,
173
+ actualToolCount: actualTools ? actualTools.length : 0,
174
+ note: 'Server responded via JSON-RPC, tools verified via tools/list'
175
+ })
176
+ }
177
+ }, 200)
178
+
179
+ const timer = setTimeout(() => {
180
+ clearInterval(pollInterval)
181
+ child.kill('SIGTERM')
182
+ checkResponses()
183
+
184
+ // If we got at least the init response, server is alive
185
+ if (responseCount >= 1) {
186
+ settle({
187
+ responding: true,
188
+ responseTimeMs: Date.now() - start,
189
+ tools: EXPECTED_TOOLS.map((name) => ({ name, available: true })),
190
+ actualToolCount: EXPECTED_TOOLS.length,
191
+ note: 'Server responded to initialize but tools/list timed out; using expected tool list'
192
+ })
193
+ } else {
194
+ settle({
195
+ responding: false,
196
+ responseTimeMs: Date.now() - start,
197
+ tools: EXPECTED_TOOLS.map((name) => ({ name, available: false })),
198
+ actualToolCount: 0,
199
+ error: 'Server did not respond within timeout'
200
+ })
201
+ }
202
+ }, RESPONSE_TIMEOUT_MS)
203
+
204
+ child.on('error', (error) => {
205
+ clearInterval(pollInterval)
206
+ clearTimeout(timer)
207
+ settle({
208
+ responding: false,
209
+ responseTimeMs: Date.now() - start,
210
+ tools: EXPECTED_TOOLS.map((name) => ({ name, available: false })),
211
+ actualToolCount: 0,
212
+ error: `Server failed to start: ${error.message}`
213
+ })
214
+ })
215
+
216
+ child.on('exit', (code) => {
217
+ clearInterval(pollInterval)
218
+ clearTimeout(timer)
219
+ if (code !== null && code !== 0) {
220
+ settle({
221
+ responding: false,
222
+ responseTimeMs: Date.now() - start,
223
+ tools: EXPECTED_TOOLS.map((name) => ({ name, available: false })),
224
+ actualToolCount: 0,
225
+ error: `Server exited with code ${code}. stderr: ${stderr}`
226
+ })
227
+ }
228
+ })
229
+ })
230
+ } catch (error) {
231
+ return {
232
+ responding: false,
233
+ responseTimeMs: Date.now() - start,
234
+ tools: EXPECTED_TOOLS.map((name) => ({ name, available: false })),
235
+ actualToolCount: 0,
236
+ error: `Server check failed: ${error.message}`
237
+ }
238
+ }
239
+ }
240
+
241
+ async function runHealthCheck() {
242
+ const { smoke, projectRoot } = parseArgs()
243
+ const resolvedRoot = resolve(projectRoot)
244
+
245
+ const report = {
246
+ status: 'unknown',
247
+ provider: 'code-graph-mcp',
248
+ version: null,
249
+ projectRoot: resolvedRoot,
250
+ timestamp: new Date().toISOString(),
251
+ checks: {},
252
+ tools: [],
253
+ responseTimeMs: null,
254
+ errors: []
255
+ }
256
+
257
+ // Check 1: Binary installed
258
+ const binaryCheck = await checkBinaryInstalled()
259
+ report.checks.binaryInstalled = binaryCheck.installed
260
+ if (!binaryCheck.installed) {
261
+ report.status = 'unavailable'
262
+ report.errors.push(binaryCheck.error)
263
+ outputReport(report, 2)
264
+ return
265
+ }
266
+
267
+ // Check 2: MCP config present
268
+ const configCheck = checkMcpConfig(resolvedRoot)
269
+ report.checks.mcpConfigured = configCheck.configured
270
+ if (!configCheck.configured) {
271
+ report.errors.push(configCheck.error)
272
+ // Not a blocker — binary works, just no MCP config
273
+ }
274
+
275
+ // Check 3: Server responds and tools verified via MCP tools/list
276
+ const serverCheck = await checkServerAndTools(resolvedRoot)
277
+ report.checks.serverResponding = serverCheck.responding
278
+ report.responseTimeMs = serverCheck.responseTimeMs
279
+
280
+ if (!serverCheck.responding) {
281
+ report.status = 'unavailable'
282
+ report.errors.push(serverCheck.error)
283
+ report.tools = serverCheck.tools
284
+ outputReport(report, 2)
285
+ return
286
+ }
287
+
288
+ // Tool report from real MCP tools/list query
289
+ report.tools = serverCheck.tools
290
+ const availableCount = report.tools.filter((t) => t.available).length
291
+
292
+ if (availableCount === EXPECTED_TOOLS.length) {
293
+ report.status = 'available'
294
+ } else if (availableCount > 0) {
295
+ report.status = 'degraded'
296
+ } else {
297
+ report.status = 'unavailable'
298
+ }
299
+
300
+ // Version detection (try pip, fallback to python -m pip for Windows compatibility)
301
+ for (const cmd of [
302
+ { file: 'pip', args: ['show', 'code-graph-mcp', '--no-color'] },
303
+ { file: 'python', args: ['-m', 'pip', 'show', 'code-graph-mcp', '--no-color'] },
304
+ { file: 'python3', args: ['-m', 'pip', 'show', 'code-graph-mcp', '--no-color'] }
305
+ ]) {
306
+ try {
307
+ const { stdout } = await execFileAsync(cmd.file, cmd.args, { timeout: 5000 })
308
+ const versionMatch = stdout.match(/Version:\s*(.+)/)
309
+ if (versionMatch) {
310
+ report.version = versionMatch[1].trim()
311
+ break
312
+ }
313
+ } catch {
314
+ // Try next command
315
+ }
316
+ }
317
+
318
+ // Smoke tests (optional)
319
+ if (smoke) {
320
+ report.smokeTests = {
321
+ note: 'Smoke tests require running inside Claude Code session with code-graph MCP active',
322
+ instructions: [
323
+ 'Use find_definition tool with symbol "UnifiedActivationPipeline"',
324
+ 'Use find_references tool with symbol "entity-registry"',
325
+ 'Use dependency_analysis tool on ".aios-core/core/"',
326
+ 'Use project_statistics tool on project root'
327
+ ]
328
+ }
329
+ }
330
+
331
+ const exitCode = report.status === 'available' ? 0
332
+ : report.status === 'degraded' ? 1
333
+ : 2
334
+
335
+ outputReport(report, exitCode)
336
+ }
337
+
338
+ function outputReport(report, exitCode) {
339
+ console.log(JSON.stringify(report, null, 2))
340
+ process.exit(exitCode)
341
+ }
342
+
343
+ runHealthCheck()
File without changes
File without changes
File without changes
@@ -0,0 +1,355 @@
1
+ # Glue Script: Compose Agent Prompt
2
+
3
+ Deterministic prompt composition for autonomous AIOS agents.
4
+
5
+ ## Overview
6
+
7
+ The glue script (`compose-agent-prompt.cjs`) composes complete prompts for autonomous agents by combining:
8
+
9
+ 1. **Agent Persona** - From `.aios-core/development/agents/{id}.md`
10
+ 2. **Task Workflow** - From Mission Router → `.aios-core/development/tasks/{file}.md`
11
+ 3. **Extra Resources** - Checklists, templates specified in Mission Router
12
+ 4. **Context** - Story files, accumulated context, etc.
13
+ 5. **Execution Directive** - Mission-specific instructions
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ Skill (orchestrator) → Calls glue script
19
+
20
+ Glue Script → Deterministic composition (~240 lines)
21
+ ↓ outputs 1500-2000 lines
22
+ Task(general-purpose) → Agent receives COMPLETE prompt
23
+
24
+ Autonomous Execution → No additional Reads needed
25
+ ```
26
+
27
+ **Benefits:**
28
+ - Lead doesn't burn context with Reads per spawn
29
+ - Agent receives everything upfront (fresh context)
30
+ - Deterministic: same inputs → same output
31
+ - Validatable and testable
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ # Already included in project
37
+ # No additional dependencies needed
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### Basic Usage
43
+
44
+ ```bash
45
+ # Develop a story
46
+ node scripts/glue/compose-agent-prompt.cjs \
47
+ --agent dev \
48
+ --mission develop-story \
49
+ --context path/to/story.md
50
+
51
+ # Validate a story
52
+ node scripts/glue/compose-agent-prompt.cjs \
53
+ --agent po \
54
+ --mission validate-story \
55
+ --context path/to/expanded.md
56
+
57
+ # Review implementation
58
+ node scripts/glue/compose-agent-prompt.cjs \
59
+ --agent qa \
60
+ --mission gate \
61
+ --context path/to/story.md \
62
+ --context path/to/impl-log.md
63
+ ```
64
+
65
+ ### Options
66
+
67
+ | Option | Description | Example |
68
+ |--------|-------------|---------|
69
+ | `--agent <id>` | Agent ID (dev, qa, po, db-sage, etc.) | `--agent dev` |
70
+ | `--mission <keyword>` | Mission from Agent's Router | `--mission develop-story` |
71
+ | `--context <path>` | Context file (repeatable) | `--context story.md` |
72
+ | `--squad <name>` | Explicit squad name for agent resolution | `--squad design` |
73
+ | `--extra-instruction` | Additional instruction | `--extra-instruction "Focus on tests"` |
74
+ | `--verbose` | Show debug info to stderr | `--verbose` |
75
+ | `--list-missions` | List available missions | `--list-missions` |
76
+
77
+ ### Multiple Contexts
78
+
79
+ ```bash
80
+ # Story + accumulated context
81
+ node scripts/glue/compose-agent-prompt.cjs \
82
+ --agent po \
83
+ --mission validate \
84
+ --context story.md \
85
+ --context accumulated-context.md
86
+
87
+ # Story + implementation log
88
+ node scripts/glue/compose-agent-prompt.cjs \
89
+ --agent qa \
90
+ --mission gate \
91
+ --context expanded.md \
92
+ --context impl-log.md
93
+ ```
94
+
95
+ ### Mission Aliases
96
+
97
+ Common shortcuts for mission keywords:
98
+
99
+ | Alias | Resolves To |
100
+ |-------|-------------|
101
+ | `review` | `gate` |
102
+ | `validate` | `validate-story` |
103
+ | `expand` | `create-story` |
104
+ | `develop` | `develop-story` |
105
+ | `implement` | `develop-story` |
106
+ | `backlog` | `backlog-review` |
107
+ | `draft` | `create-story` |
108
+
109
+ ### List Available Missions
110
+
111
+ ```bash
112
+ # List missions for QA agent
113
+ node scripts/glue/compose-agent-prompt.cjs --agent qa --list-missions
114
+
115
+ # List missions for PO agent
116
+ node scripts/glue/compose-agent-prompt.cjs --agent po --list-missions
117
+ ```
118
+
119
+ ## Integration with Task Tool
120
+
121
+ ```javascript
122
+ // 1. Compose the prompt
123
+ const prompt = await Bash(
124
+ `node scripts/glue/compose-agent-prompt.cjs \
125
+ --agent dev \
126
+ --mission develop-story \
127
+ --context ${storyPath}`
128
+ );
129
+
130
+ // 2. Spawn agent with complete prompt
131
+ Task({
132
+ subagent_type: "general-purpose",
133
+ model: "opus", // or "sonnet" for mechanical tasks
134
+ mode: "bypassPermissions",
135
+ prompt: prompt.stdout
136
+ });
137
+ ```
138
+
139
+ ## Execute-Epic Pipeline
140
+
141
+ The glue script supports the full execute-epic pipeline:
142
+
143
+ ### Phase 1: Backlog Review (PO)
144
+ ```bash
145
+ node scripts/glue/compose-agent-prompt.cjs \
146
+ --agent po \
147
+ --mission backlog-review \
148
+ --context path/to/epic.md
149
+ ```
150
+
151
+ ### Phase 2: Development Cycle
152
+
153
+ **2.1 Expand Story (SM)**
154
+ ```bash
155
+ node scripts/glue/compose-agent-prompt.cjs \
156
+ --agent sm \
157
+ --mission expand \
158
+ --context path/to/epic.md \
159
+ --extra-instruction "Extract story X"
160
+ ```
161
+
162
+ **2.2 Validate Story (PO)**
163
+ ```bash
164
+ node scripts/glue/compose-agent-prompt.cjs \
165
+ --agent po \
166
+ --mission validate \
167
+ --context path/to/expanded.md
168
+ ```
169
+
170
+ **2.3 Implement (Dev)**
171
+ ```bash
172
+ node scripts/glue/compose-agent-prompt.cjs \
173
+ --agent dev \
174
+ --mission develop \
175
+ --context path/to/expanded.md \
176
+ --context path/to/accumulated-context.md
177
+ ```
178
+
179
+ **2.4 Review (QA)**
180
+ ```bash
181
+ node scripts/glue/compose-agent-prompt.cjs \
182
+ --agent qa \
183
+ --mission review \
184
+ --context path/to/expanded.md \
185
+ --context path/to/impl-log.md
186
+ ```
187
+
188
+ ### Phase 3: Retrospective (PO)
189
+ ```bash
190
+ node scripts/glue/compose-agent-prompt.cjs \
191
+ --agent po \
192
+ --mission retrospective \
193
+ --context path/to/accumulated-context.md
194
+ ```
195
+
196
+ ## Agent Reference
197
+
198
+ ### Agent Resolution Priority
199
+
200
+ The glue script resolves agents in this order:
201
+
202
+ 1. `.claude/agents/aios-{id}.md` (AIOS core agents)
203
+ 2. `.claude/agents/{id}.md` (standalone agents like db-sage)
204
+ 3. `squads/{squad}/agents/{id}.md` (squad-specific agents)
205
+
206
+ ### AIOS Core Agents
207
+
208
+ | Agent ID | Role | Common Missions |
209
+ |----------|------|-----------------|
210
+ | `dev` | Developer | `develop-story`, `apply-qa-fixes` |
211
+ | `qa` | Quality Assurance | `gate`, `review-story`, `security-scan` |
212
+ | `po` | Product Owner | `validate-story`, `backlog-review` |
213
+ | `sm` | Scrum Master | `create-story`, `expand` |
214
+ | `architect` | Architect | `analyze-impact`, `create-fullstack-arch` |
215
+ | `devops` | DevOps | `commit`, `pre-push`, `create-pr` |
216
+ | `analyst` | Analyst | `market-research`, `competitor-analysis` |
217
+ | `data-engineer` | Data Engineer | `develop-story`, `migration`, `schema-audit` |
218
+ | `ux` | UX Designer | `wireframe`, `audit`, `develop-story` |
219
+ | `pm` | Product Manager | `create-prd`, `create-epic` |
220
+
221
+ ### Specialized Squad Agents
222
+
223
+ | Agent ID | Squad | Replaces | Common Missions |
224
+ |----------|-------|----------|-----------------|
225
+ | `db-sage` | db-sage | data-engineer (for DB) | `kiss`, `kiss-schema-check`, `setup` |
226
+ | `brad-frost` | design | — | Uses internal `*command` system |
227
+ | `design-chief` | design | — | Squad orchestration |
228
+ | `cyber-chief` | cybersecurity | — | Security audits |
229
+
230
+ **Note:** Squad agents may use different mission systems. Use `--list-missions` to check available missions for each agent.
231
+
232
+ ### Squad Agent Usage
233
+
234
+ ```bash
235
+ # db-sage uses Mission Router
236
+ node scripts/glue/compose-agent-prompt.cjs --agent db-sage --mission kiss
237
+
238
+ # brad-frost uses internal command system (load persona only)
239
+ node scripts/glue/compose-agent-prompt.cjs --agent brad-frost --mission audit \
240
+ --extra-instruction "Execute *audit command from your configuration"
241
+
242
+ # Explicit squad specification
243
+ node scripts/glue/compose-agent-prompt.cjs --agent my-agent --squad my-squad --mission task
244
+ ```
245
+
246
+ ## Prompt Structure
247
+
248
+ The output prompt has the following structure:
249
+
250
+ ```markdown
251
+ ## Agent Persona
252
+
253
+ [Full agent definition from .aios-core/development/agents/{id}.md]
254
+
255
+ ---
256
+
257
+ ## Task Workflow: {mission}
258
+
259
+ [Task workflow from .aios-core/development/tasks/{file}.md]
260
+
261
+ ---
262
+
263
+ ## Checklist: {resource}.md
264
+
265
+ [Checklists specified in Mission Router]
266
+
267
+ ---
268
+
269
+ ## Context
270
+
271
+ ### Context 1: {filename}
272
+
273
+ [File content]
274
+
275
+ ### Context 2: {filename}
276
+
277
+ [File content]
278
+
279
+ ---
280
+
281
+ ## Execution Directive
282
+
283
+ Execute the mission "{mission}" following the task workflow above.
284
+ - Follow ALL steps in the task workflow exactly
285
+ - Use Self-Critique checkpoints if defined in the workflow
286
+ - Output artifacts as specified in the workflow
287
+ - Mark success/failure clearly at the end
288
+
289
+ **Additional Instruction:** {extra-instruction if provided}
290
+ ```
291
+
292
+ ## Verbose Mode
293
+
294
+ Use `--verbose` to see debug information:
295
+
296
+ ```bash
297
+ node scripts/glue/compose-agent-prompt.cjs \
298
+ --agent dev \
299
+ --mission develop \
300
+ --context story.md \
301
+ --verbose
302
+ ```
303
+
304
+ Output (to stderr):
305
+ ```
306
+ [glue] Agent: dev, Mission: develop, Resolved: develop-story
307
+ [glue] Task file: dev-develop-story.md
308
+ [glue] Extra resources: story-dod-checklist.md, self-critique-checklist.md
309
+ [glue] Loading context: story.md
310
+
311
+ [glue] Prompt stats: 1773 lines, 60117 chars
312
+ [glue] Sections: 6 (persona, task, 2 checklists, 1 contexts, directive)
313
+ ```
314
+
315
+ ## Troubleshooting
316
+
317
+ ### Agent file not found
318
+ ```
319
+ Error: Agent file not found: .claude/agents/aios-foo.md
320
+ ```
321
+ Check that the agent ID is valid. Use one of: dev, qa, po, sm, architect, devops, analyst, data-engineer, ux, pm.
322
+
323
+ ### Mission not found
324
+ ```
325
+ ## Mission: foo
326
+ No router entry found. Execute mission based on agent expertise.
327
+ ```
328
+ Use `--list-missions` to see available missions for the agent.
329
+
330
+ ### Context file not found
331
+ ```
332
+ ### Context 1
333
+ File not found: /path/to/missing.md
334
+ ```
335
+ Verify the context file path is correct.
336
+
337
+ ## Test Results
338
+
339
+ Pipeline tested with MMOS epic stories:
340
+
341
+ | Story | Phase | Agent | Duration | Result |
342
+ |-------|-------|-------|----------|--------|
343
+ | MMOS-001 | Develop | dev | 227s | ✅ COMPLETED (verified existing impl) |
344
+ | MMOS-002 | Validate | po | 60s | ✅ APPROVED (impl exists) |
345
+ | MMOS-002 | Review | qa | 345s | ✅ APPROVED (38/38 tests pass) |
346
+
347
+ **Key Metrics:**
348
+ - Prompt size: 1500-1850 lines per agent
349
+ - Agent autonomy: 100% (no manual intervention)
350
+ - Test pass rate: 100%
351
+
352
+ ---
353
+
354
+ *Created: 2026-02-06*
355
+ *Version: 1.0.0*