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,362 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Compose Agent Prompt - Glue Script for Execute-Epic
4
+ *
5
+ * Deterministic prompt composition for autonomous agents.
6
+ * Reads agent file + task file + context → outputs complete prompt to stdout.
7
+ *
8
+ * Usage:
9
+ * node compose-agent-prompt.cjs --agent dev --mission develop-story --context path/to/story.md
10
+ * node compose-agent-prompt.cjs --agent qa --mission gate --context path/to/story.md
11
+ * node compose-agent-prompt.cjs --agent po --mission validate-story --context story.md --context accumulated.md
12
+ * node compose-agent-prompt.cjs --agent dev --mission develop-story --context story.md --extra-instruction "Focus on tests"
13
+ *
14
+ * Options:
15
+ * --agent <id> Agent ID (dev, qa, po, sm, architect, etc.)
16
+ * --mission <keyword> Mission keyword from agent's Mission Router
17
+ * --context <path> Context file (can be repeated for multiple files)
18
+ * --extra-instruction <s> Additional instruction to append
19
+ * --verbose Show debug info to stderr
20
+ * --list-missions List available missions for the agent
21
+ *
22
+ * Output: Complete prompt ready for Task(subagent_type: "general-purpose", prompt: <output>)
23
+ *
24
+ * Architecture: Clockwork Stage 1 - Thin Glue Script
25
+ */
26
+
27
+ const fs = require('fs');
28
+ const path = require('path');
29
+
30
+ // Parse arguments (supports repeated --context)
31
+ const args = process.argv.slice(2);
32
+ const getArg = (name) => {
33
+ const idx = args.indexOf(`--${name}`);
34
+ return idx !== -1 && args[idx + 1] && !args[idx + 1].startsWith('--') ? args[idx + 1] : null;
35
+ };
36
+ const getAllArgs = (name) => {
37
+ const results = [];
38
+ for (let i = 0; i < args.length; i++) {
39
+ if (args[i] === `--${name}` && args[i + 1] && !args[i + 1].startsWith('--')) {
40
+ results.push(args[i + 1]);
41
+ }
42
+ }
43
+ return results;
44
+ };
45
+ const hasFlag = (name) => args.includes(`--${name}`);
46
+
47
+ const agentId = getArg('agent');
48
+ const mission = getArg('mission');
49
+ const contextPaths = getAllArgs('context');
50
+ const extraInstruction = getArg('extra-instruction');
51
+ const verbose = hasFlag('verbose');
52
+ const listMissions = hasFlag('list-missions');
53
+
54
+ // Mission aliases (common shortcuts)
55
+ const missionAliases = {
56
+ 'review': 'gate',
57
+ 'review-story': 'gate',
58
+ 'expand': 'create-story',
59
+ 'expand-story': 'create-story',
60
+ 'draft': 'create-story',
61
+ 'validate': 'validate-story',
62
+ 'backlog': 'backlog-review',
63
+ 'develop': 'develop-story',
64
+ 'implement': 'develop-story'
65
+ };
66
+
67
+ const log = (msg) => verbose && console.error(`[glue] ${msg}`);
68
+
69
+ if (!agentId) {
70
+ console.error('Usage: compose-agent-prompt.cjs --agent <id> --mission <keyword> [--context <path>...]');
71
+ console.error(' compose-agent-prompt.cjs --agent <id> --list-missions');
72
+ console.error('');
73
+ console.error('Examples:');
74
+ console.error(' compose-agent-prompt.cjs --agent dev --mission develop-story --context story.md');
75
+ console.error(' compose-agent-prompt.cjs --agent qa --mission gate --context story.md --context impl-log.md');
76
+ console.error(' compose-agent-prompt.cjs --agent po --list-missions');
77
+ process.exit(1);
78
+ }
79
+
80
+ // Paths
81
+ const projectRoot = process.cwd();
82
+ const aiosCoreTasks = path.join(projectRoot, '.aios-core', 'development', 'tasks');
83
+ const aiosCoreAgents = path.join(projectRoot, '.aios-core', 'development', 'agents');
84
+
85
+ // Agent file resolution (priority order)
86
+ // 1. .claude/agents/aios-{id}.md (AIOS core)
87
+ // 2. .claude/agents/{id}.md (standalone like db-sage)
88
+ // 3. squads/{squad}/agents/{id}.md (squad agents - derive squad from agent id or use --squad)
89
+ const squadId = getArg('squad');
90
+ const agentPaths = [
91
+ path.join(projectRoot, '.claude', 'agents', `aios-${agentId}.md`),
92
+ path.join(projectRoot, '.claude', 'agents', `${agentId}.md`),
93
+ ];
94
+
95
+ // Add squad paths if squad is specified or try common squads
96
+ if (squadId) {
97
+ agentPaths.push(path.join(projectRoot, 'squads', squadId, 'agents', `${agentId}.md`));
98
+ } else {
99
+ // Try common squad mappings
100
+ const squadMappings = {
101
+ 'db-sage': 'db-sage',
102
+ 'brad-frost': 'design',
103
+ 'design-chief': 'design',
104
+ 'cyber-chief': 'cybersecurity',
105
+ 'copy-chief': 'copy',
106
+ 'story-chief': 'storytelling',
107
+ 'finops-chief': 'finops',
108
+ 'hr-chief': 'hr',
109
+ 'legal-chief': 'legal',
110
+ 'data-chief': 'data',
111
+ };
112
+ const mappedSquad = squadMappings[agentId];
113
+ if (mappedSquad) {
114
+ agentPaths.push(path.join(projectRoot, 'squads', mappedSquad, 'agents', `${agentId}.md`));
115
+ }
116
+ // Also try .claude/commands/{Squad}/agents/ (synced from squads)
117
+ agentPaths.push(path.join(projectRoot, '.claude', 'commands', 'db-sage', 'agents', `${agentId}.md`));
118
+ }
119
+
120
+ // Find first existing agent file and track its source
121
+ let agentFile = null;
122
+ let agentSource = null; // 'aios-core', 'standalone', 'squad:{name}'
123
+ for (const p of agentPaths) {
124
+ if (fs.existsSync(p)) {
125
+ agentFile = p;
126
+ // Determine source for task resolution
127
+ if (p.includes('.claude/agents/aios-')) {
128
+ agentSource = 'aios-core';
129
+ } else if (p.includes('.claude/agents/')) {
130
+ agentSource = 'standalone';
131
+ } else if (p.includes('squads/')) {
132
+ const match = p.match(/squads\/([^/]+)\//);
133
+ agentSource = match ? `squad:${match[1]}` : 'squad';
134
+ }
135
+ log(`Agent file found: ${p} (source: ${agentSource})`);
136
+ break;
137
+ }
138
+ }
139
+
140
+ if (!agentFile) {
141
+ console.error(`Agent file not found. Tried:`);
142
+ agentPaths.forEach(p => console.error(` - ${p}`));
143
+ console.error(`\nHint: Use --squad <squad-name> to specify squad, or check agent ID.`);
144
+ process.exit(1);
145
+ }
146
+ const agentContent = fs.readFileSync(agentFile, 'utf8');
147
+
148
+ // Parse Mission Router from agent file (format: "## 3. Mission Router" or "## Mission Router")
149
+ const missionRouterMatch = agentContent.match(/## (?:\d+\. )?Mission Router[\s\S]*?(\|.*\|[\s\S]*?)(?=\n## |\n###|$)/);
150
+ let taskFile = null;
151
+ let extraResources = [];
152
+ const availableMissions = [];
153
+
154
+ if (missionRouterMatch) {
155
+ const tableContent = missionRouterMatch[1];
156
+ const rows = tableContent.split('\n').filter(r => r.includes('|') && !r.includes('---') && !r.includes('Mission Keyword'));
157
+
158
+ for (const row of rows) {
159
+ const cols = row.split('|').map(c => c.trim()).filter(Boolean);
160
+ if (cols.length >= 2) {
161
+ // Extract mission keyword (remove backticks, parenthetical notes like "(default)")
162
+ const rawKeyword = cols[0].replace(/`/g, '').trim();
163
+ // Handle multiple keywords like "create-story / draft"
164
+ const keywords = rawKeyword.split('/').map(k => k.replace(/\s*\([^)]*\)/g, '').trim());
165
+ const taskFileName = cols[1].replace(/`/g, '').trim();
166
+
167
+ // Collect for --list-missions
168
+ availableMissions.push({ keywords, taskFile: taskFileName, extras: cols[2] || '' });
169
+
170
+ // Skip if we're just listing missions
171
+ if (listMissions) continue;
172
+
173
+ // Resolve alias
174
+ const resolvedMission = missionAliases[mission?.toLowerCase()] || mission;
175
+
176
+ // Check if any keyword matches
177
+ for (const keyword of keywords) {
178
+ if (keyword.toLowerCase() === resolvedMission?.toLowerCase()) {
179
+ taskFile = taskFileName;
180
+ // Extract extra resources if present
181
+ if (cols[2]) {
182
+ const resourceMatches = cols[2].match(/`([^`]+\.md)`/g);
183
+ if (resourceMatches) {
184
+ extraResources = resourceMatches.map(r => r.replace(/`/g, ''));
185
+ }
186
+ }
187
+ break;
188
+ }
189
+ }
190
+ if (taskFile) break;
191
+ }
192
+ }
193
+ }
194
+
195
+ // Handle --list-missions
196
+ if (listMissions) {
197
+ console.log(`\n## Available Missions for agent: ${agentId}\n`);
198
+ console.log('| Mission Keyword(s) | Task File | Extra Resources |');
199
+ console.log('|-------------------|-----------|-----------------|');
200
+ for (const m of availableMissions) {
201
+ console.log(`| ${m.keywords.join(' / ')} | ${m.taskFile} | ${m.extras || '—'} |`);
202
+ }
203
+ console.log('\n## Aliases (shortcuts)\n');
204
+ for (const [alias, target] of Object.entries(missionAliases)) {
205
+ console.log(` ${alias} → ${target}`);
206
+ }
207
+ process.exit(0);
208
+ }
209
+
210
+ // Now require mission if not listing
211
+ if (!mission) {
212
+ console.error('Error: --mission is required (or use --list-missions to see available missions)');
213
+ process.exit(1);
214
+ }
215
+
216
+ log(`Agent: ${agentId}, Mission: ${mission}, Resolved: ${missionAliases[mission?.toLowerCase()] || mission}`);
217
+ log(`Task file: ${taskFile || 'not found'}`);
218
+ log(`Extra resources: ${extraResources.join(', ') || 'none'}`);
219
+
220
+ // Build the prompt
221
+ const promptParts = [];
222
+
223
+ // 1. Agent persona (from .aios-core/development/agents/ if exists, else from agent file)
224
+ const fullAgentFile = path.join(aiosCoreAgents, `${agentId}.md`);
225
+ if (fs.existsSync(fullAgentFile)) {
226
+ promptParts.push(`## Agent Persona\n\n${fs.readFileSync(fullAgentFile, 'utf8')}`);
227
+ } else {
228
+ promptParts.push(`## Agent Instructions\n\n${agentContent}`);
229
+ }
230
+
231
+ // 2. Task workflow (if found in router) - check multiple paths
232
+ if (taskFile) {
233
+ // Build task path candidates based on agent source
234
+ const taskPaths = [path.join(aiosCoreTasks, taskFile)];
235
+
236
+ // If agent is from a squad, also check squad tasks
237
+ if (agentSource && agentSource.startsWith('squad:')) {
238
+ const squadName = agentSource.split(':')[1];
239
+ taskPaths.unshift(path.join(projectRoot, 'squads', squadName, 'tasks', taskFile));
240
+ }
241
+
242
+ // For standalone agents, check if there's a matching squad
243
+ if (agentSource === 'standalone') {
244
+ const squadMappings = {
245
+ 'db-sage': 'db-sage',
246
+ 'brad-frost': 'design',
247
+ 'design-chief': 'design',
248
+ 'cyber-chief': 'cybersecurity',
249
+ };
250
+ const mappedSquad = squadMappings[agentId];
251
+ if (mappedSquad) {
252
+ taskPaths.unshift(path.join(projectRoot, 'squads', mappedSquad, 'tasks', taskFile));
253
+ }
254
+ }
255
+
256
+ // Find first existing task file
257
+ let foundTaskPath = null;
258
+ for (const tp of taskPaths) {
259
+ if (fs.existsSync(tp)) {
260
+ foundTaskPath = tp;
261
+ log(`Task file found: ${tp}`);
262
+ break;
263
+ }
264
+ }
265
+
266
+ if (foundTaskPath) {
267
+ promptParts.push(`## Task Workflow: ${mission}\n\n${fs.readFileSync(foundTaskPath, 'utf8')}`);
268
+ } else {
269
+ log(`Task file not found. Tried: ${taskPaths.join(', ')}`);
270
+ promptParts.push(`## Mission: ${mission}\n\nTask file not found: ${taskFile}. Execute mission based on agent expertise.`);
271
+ }
272
+ } else {
273
+ promptParts.push(`## Mission: ${mission}\n\nNo router entry found. Execute mission based on agent expertise.`);
274
+ }
275
+
276
+ // 2.5. Extra resources (checklists, templates) - check multiple paths
277
+ const aiosCoreChecklists = path.join(projectRoot, '.aios-core', 'development', 'checklists');
278
+ const aiosCoreProductChecklists = path.join(projectRoot, '.aios-core', 'product', 'checklists');
279
+
280
+ for (const resource of extraResources) {
281
+ // Build checklist path candidates based on agent source
282
+ const checklistPaths = [];
283
+
284
+ // If agent is from a squad, check squad checklists first
285
+ if (agentSource && agentSource.startsWith('squad:')) {
286
+ const squadName = agentSource.split(':')[1];
287
+ checklistPaths.push(path.join(projectRoot, 'squads', squadName, 'checklists', resource));
288
+ }
289
+
290
+ // For standalone agents with squad mappings
291
+ if (agentSource === 'standalone') {
292
+ const squadMappings = {
293
+ 'db-sage': 'db-sage',
294
+ 'brad-frost': 'design',
295
+ 'design-chief': 'design',
296
+ 'cyber-chief': 'cybersecurity',
297
+ };
298
+ const mappedSquad = squadMappings[agentId];
299
+ if (mappedSquad) {
300
+ checklistPaths.push(path.join(projectRoot, 'squads', mappedSquad, 'checklists', resource));
301
+ }
302
+ }
303
+
304
+ // Always fallback to AIOS core checklists
305
+ checklistPaths.push(path.join(aiosCoreChecklists, resource));
306
+ checklistPaths.push(path.join(aiosCoreProductChecklists, resource));
307
+
308
+ // Find first existing checklist
309
+ let foundChecklistPath = null;
310
+ for (const cp of checklistPaths) {
311
+ if (fs.existsSync(cp)) {
312
+ foundChecklistPath = cp;
313
+ log(`Checklist found: ${cp}`);
314
+ break;
315
+ }
316
+ }
317
+
318
+ if (foundChecklistPath) {
319
+ promptParts.push(`## Checklist: ${resource}\n\n${fs.readFileSync(foundChecklistPath, 'utf8')}`);
320
+ } else {
321
+ log(`Checklist not found: ${resource}`);
322
+ }
323
+ }
324
+
325
+ // 3. Context files (supports multiple)
326
+ if (contextPaths.length > 0) {
327
+ const contextSections = [];
328
+ for (let i = 0; i < contextPaths.length; i++) {
329
+ const ctxPath = contextPaths[i];
330
+ const ctxLabel = contextPaths.length === 1 ? 'Context' : `Context ${i + 1}`;
331
+ if (fs.existsSync(ctxPath)) {
332
+ log(`Loading context: ${ctxPath}`);
333
+ contextSections.push(`### ${ctxLabel}: ${path.basename(ctxPath)}\n\nFile: ${ctxPath}\n\n${fs.readFileSync(ctxPath, 'utf8')}`);
334
+ } else {
335
+ contextSections.push(`### ${ctxLabel}\n\nFile not found: ${ctxPath}`);
336
+ log(`Warning: context file not found: ${ctxPath}`);
337
+ }
338
+ }
339
+ promptParts.push(`## Context\n\n${contextSections.join('\n\n---\n\n')}`);
340
+ }
341
+
342
+ // 4. Execution directive
343
+ const extraInstructionBlock = extraInstruction ? `\n\n**Additional Instruction:** ${extraInstruction}` : '';
344
+ promptParts.push(`## Execution Directive
345
+
346
+ Execute the mission "${mission}" following the task workflow above.
347
+ - Follow ALL steps in the task workflow exactly
348
+ - Use Self-Critique checkpoints if defined in the workflow
349
+ - Output artifacts as specified in the workflow
350
+ - Mark success/failure clearly at the end${extraInstructionBlock}`);
351
+
352
+ // Output complete prompt
353
+ const output = promptParts.join('\n\n---\n\n');
354
+ console.log(output);
355
+
356
+ // Stats to stderr (always shown in verbose mode)
357
+ if (verbose) {
358
+ const lineCount = output.split('\n').length;
359
+ const charCount = output.length;
360
+ console.error(`\n[glue] Prompt stats: ${lineCount} lines, ${charCount} chars`);
361
+ console.error(`[glue] Sections: ${promptParts.length} (persona, task${extraResources.length > 0 ? ', ' + extraResources.length + ' checklists' : ''}, ${contextPaths.length} contexts, directive)`);
362
+ }
File without changes
@@ -1 +0,0 @@
1
- {"built": true}