aiox-core 5.0.0 → 5.0.2

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 (91) hide show
  1. package/.aiox-core/data/entity-registry.yaml +5297 -1814
  2. package/.aiox-core/data/registry-update-log.jsonl +2 -0
  3. package/.aiox-core/development/templates/service-template/README.md.hbs +158 -158
  4. package/.aiox-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
  5. package/.aiox-core/development/templates/service-template/client.ts.hbs +403 -403
  6. package/.aiox-core/development/templates/service-template/errors.ts.hbs +182 -182
  7. package/.aiox-core/development/templates/service-template/index.ts.hbs +120 -120
  8. package/.aiox-core/development/templates/service-template/package.json.hbs +87 -87
  9. package/.aiox-core/development/templates/service-template/types.ts.hbs +145 -145
  10. package/.aiox-core/development/templates/squad-template/LICENSE +21 -21
  11. package/.aiox-core/infrastructure/scripts/tool-resolver.js +4 -4
  12. package/.aiox-core/infrastructure/templates/aiox-sync.yaml.template +182 -182
  13. package/.aiox-core/infrastructure/templates/coderabbit.yaml.template +279 -279
  14. package/.aiox-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
  15. package/.aiox-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
  16. package/.aiox-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
  17. package/.aiox-core/infrastructure/templates/gitignore/gitignore-aiox-base.tmpl +63 -63
  18. package/.aiox-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
  19. package/.aiox-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
  20. package/.aiox-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
  21. package/.aiox-core/install-manifest.yaml +58 -58
  22. package/.aiox-core/local-config.yaml.template +71 -71
  23. package/.aiox-core/monitor/hooks/lib/__init__.py +1 -1
  24. package/.aiox-core/monitor/hooks/lib/enrich.py +58 -58
  25. package/.aiox-core/monitor/hooks/lib/send_event.py +47 -47
  26. package/.aiox-core/monitor/hooks/notification.py +29 -29
  27. package/.aiox-core/monitor/hooks/post_tool_use.py +45 -45
  28. package/.aiox-core/monitor/hooks/pre_compact.py +29 -29
  29. package/.aiox-core/monitor/hooks/pre_tool_use.py +40 -40
  30. package/.aiox-core/monitor/hooks/stop.py +29 -29
  31. package/.aiox-core/monitor/hooks/subagent_stop.py +29 -29
  32. package/.aiox-core/monitor/hooks/user_prompt_submit.py +38 -38
  33. package/.aiox-core/product/templates/adr.hbs +125 -125
  34. package/.aiox-core/product/templates/dbdr.hbs +241 -241
  35. package/.aiox-core/product/templates/engine/elicitation.js +2 -3
  36. package/.aiox-core/product/templates/epic.hbs +212 -212
  37. package/.aiox-core/product/templates/pmdr.hbs +186 -186
  38. package/.aiox-core/product/templates/prd-v2.0.hbs +216 -216
  39. package/.aiox-core/product/templates/prd.hbs +201 -201
  40. package/.aiox-core/product/templates/story.hbs +263 -263
  41. package/.aiox-core/product/templates/task.hbs +170 -170
  42. package/.aiox-core/product/templates/tmpl-comment-on-examples.sql +158 -158
  43. package/.aiox-core/product/templates/tmpl-migration-script.sql +91 -91
  44. package/.aiox-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
  45. package/.aiox-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
  46. package/.aiox-core/product/templates/tmpl-rls-roles.sql +135 -135
  47. package/.aiox-core/product/templates/tmpl-rls-simple.sql +77 -77
  48. package/.aiox-core/product/templates/tmpl-rls-tenant.sql +152 -152
  49. package/.aiox-core/product/templates/tmpl-rollback-script.sql +77 -77
  50. package/.aiox-core/product/templates/tmpl-seed-data.sql +140 -140
  51. package/.aiox-core/product/templates/tmpl-smoke-test.sql +16 -16
  52. package/.aiox-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
  53. package/.aiox-core/product/templates/tmpl-stored-proc.sql +140 -140
  54. package/.aiox-core/product/templates/tmpl-trigger.sql +152 -152
  55. package/.aiox-core/product/templates/tmpl-view-materialized.sql +133 -133
  56. package/.aiox-core/product/templates/tmpl-view.sql +177 -177
  57. package/.aiox-core/scripts/pm.sh +0 -0
  58. package/.claude/hooks/code-intel-pretool.cjs +107 -0
  59. package/.claude/hooks/enforce-architecture-first.py +196 -196
  60. package/.claude/hooks/mind-clone-governance.py +192 -192
  61. package/.claude/hooks/read-protection.py +151 -151
  62. package/.claude/hooks/slug-validation.py +176 -176
  63. package/.claude/hooks/sql-governance.py +182 -182
  64. package/.claude/hooks/write-path-validation.py +194 -194
  65. package/LICENSE +33 -33
  66. package/bin/aiox-graph.js +0 -0
  67. package/bin/aiox-minimal.js +0 -0
  68. package/bin/aiox.js +0 -0
  69. package/docs/guides/aios-workflows/README.md +247 -0
  70. package/docs/guides/aios-workflows/bob-orchestrator-workflow.md +1536 -0
  71. package/package.json +1 -1
  72. package/packages/aiox-install/bin/aiox-install.js +0 -0
  73. package/packages/aiox-install/bin/edmcp.js +0 -0
  74. package/packages/aiox-pro-cli/bin/aiox-pro.js +0 -0
  75. package/packages/installer/src/wizard/pro-setup.js +210 -123
  76. package/pro/README.md +66 -0
  77. package/pro/license/degradation.js +220 -0
  78. package/pro/license/errors.js +450 -0
  79. package/pro/license/feature-gate.js +354 -0
  80. package/pro/license/index.js +181 -0
  81. package/pro/license/license-api.js +679 -0
  82. package/pro/license/license-cache.js +523 -0
  83. package/pro/license/license-crypto.js +303 -0
  84. package/scripts/check-markdown-links.py +352 -352
  85. package/scripts/dashboard-parallel-dev.sh +0 -0
  86. package/scripts/dashboard-parallel-phase3.sh +0 -0
  87. package/scripts/dashboard-parallel-phase4.sh +0 -0
  88. package/scripts/glue/README.md +355 -0
  89. package/scripts/glue/compose-agent-prompt.cjs +362 -0
  90. package/scripts/install-monitor-hooks.sh +0 -0
  91. package/.aiox-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}