arkaos 2.15.0 → 2.16.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 (156) hide show
  1. package/VERSION +1 -1
  2. package/arka/SKILL.md +13 -0
  3. package/arka/skills/comfyui/SKILL.md +82 -0
  4. package/arka/skills/comfyui/references/squads.md +80 -0
  5. package/arka/skills/comfyui/references/workflows.md +435 -0
  6. package/arka/skills/forge/SKILL.md +35 -599
  7. package/arka/skills/forge/references/complexity-engine.md +77 -0
  8. package/arka/skills/forge/references/critic-synthesis.md +154 -0
  9. package/arka/skills/forge/references/workflows.md +408 -0
  10. package/arka/skills/fovory/SKILL.md +91 -0
  11. package/arka/skills/fovory/references/integration.md +186 -0
  12. package/arka/skills/fovory/references/workflows.md +209 -0
  13. package/arka/skills/platform-arka/SKILL.md +121 -0
  14. package/arka/skills/platform-arka/references/workflows.md +202 -0
  15. package/arka/skills/rothbard100/SKILL.md +113 -0
  16. package/arka/skills/rothbard100/references/squad.md +111 -0
  17. package/arka/skills/rothbard100/references/workflows.md +175 -0
  18. package/config/constitution.yaml +8 -0
  19. package/config/hooks/pre-compact.sh +11 -5
  20. package/config/hooks/session-start.sh +4 -5
  21. package/config/hooks/token-hygiene.sh +120 -0
  22. package/config/hooks/user-prompt-submit.sh +28 -10
  23. package/core/agents/__pycache__/schema.cpython-313.pyc +0 -0
  24. package/core/agents/schema.py +20 -1
  25. package/core/synapse/__pycache__/layers.cpython-313.pyc +0 -0
  26. package/core/synapse/layers.py +7 -0
  27. package/core/workflow/__pycache__/schema.cpython-313.pyc +0 -0
  28. package/core/workflow/schema.py +4 -1
  29. package/departments/brand/SKILL.md +13 -0
  30. package/departments/brand/agents/brand-director.yaml +1 -0
  31. package/departments/brand/agents/brand-strategist.yaml +1 -0
  32. package/departments/brand/agents/ux-designer.yaml +1 -0
  33. package/departments/brand/agents/visual-designer.yaml +1 -0
  34. package/departments/brand/workflows/identity.yaml +1 -0
  35. package/departments/brand/workflows/naming.yaml +1 -0
  36. package/departments/community/SKILL.md +13 -0
  37. package/departments/community/agents/community-manager.yaml +1 -0
  38. package/departments/community/agents/community-strategist.yaml +1 -0
  39. package/departments/community/agents/engagement-designer.yaml +1 -0
  40. package/departments/community/workflows/setup.yaml +1 -0
  41. package/departments/content/SKILL.md +13 -0
  42. package/departments/content/agents/content-strategist.yaml +1 -0
  43. package/departments/content/agents/repurpose-distributor.yaml +1 -0
  44. package/departments/content/agents/scriptwriter.yaml +1 -0
  45. package/departments/content/agents/viral-engineer.yaml +1 -0
  46. package/departments/content/workflows/viral.yaml +1 -0
  47. package/departments/dev/SKILL.md +13 -0
  48. package/departments/dev/agents/architect.yaml +1 -0
  49. package/departments/dev/agents/backend-dev.yaml +1 -0
  50. package/departments/dev/agents/cto.yaml +1 -0
  51. package/departments/dev/agents/dba.yaml +1 -0
  52. package/departments/dev/agents/devops-eng.yaml +1 -0
  53. package/departments/dev/agents/frontend-dev.yaml +1 -0
  54. package/departments/dev/agents/qa-eng.yaml +1 -0
  55. package/departments/dev/agents/research-assistant.yaml +1 -0
  56. package/departments/dev/agents/security-eng.yaml +1 -0
  57. package/departments/dev/agents/tech-lead.yaml +1 -0
  58. package/departments/dev/skills/onboard/SKILL.md +21 -353
  59. package/departments/dev/skills/onboard/references/mcp-config.md +284 -0
  60. package/departments/dev/skills/onboard/references/stack-detection.md +83 -0
  61. package/departments/dev/workflows/debug.yaml +1 -0
  62. package/departments/dev/workflows/feature.yaml +3 -0
  63. package/departments/dev/workflows/refactor.yaml +1 -0
  64. package/departments/ecom/SKILL.md +13 -0
  65. package/departments/ecom/agents/commerce-engineer.yaml +1 -0
  66. package/departments/ecom/agents/cro-specialist.yaml +1 -0
  67. package/departments/ecom/agents/ecom-director.yaml +1 -0
  68. package/departments/ecom/agents/retention-manager.yaml +1 -0
  69. package/departments/ecom/skills/ecommerce/SKILL.md +66 -0
  70. package/departments/ecom/skills/ecommerce/references/audit-flow.md +109 -0
  71. package/departments/ecom/skills/ecommerce/references/playbooks.md +141 -0
  72. package/departments/ecom/workflows/product-page.yaml +1 -0
  73. package/departments/finance/SKILL.md +13 -0
  74. package/departments/finance/agents/cfo.yaml +1 -0
  75. package/departments/finance/agents/financial-analyst.yaml +1 -0
  76. package/departments/finance/agents/investment-strategist.yaml +1 -0
  77. package/departments/finance/workflows/cashflow.yaml +1 -0
  78. package/departments/finance/workflows/model.yaml +1 -0
  79. package/departments/kb/SKILL.md +13 -0
  80. package/departments/kb/agents/data-collector.yaml +1 -0
  81. package/departments/kb/agents/knowledge-curator.yaml +1 -0
  82. package/departments/kb/agents/knowledge-director.yaml +1 -0
  83. package/departments/kb/agents/research-analyst.yaml +1 -0
  84. package/departments/kb/skills/knowledge/SKILL.md +94 -0
  85. package/departments/kb/skills/knowledge/references/async-processing.md +89 -0
  86. package/departments/kb/skills/knowledge/references/ingestion-pipeline.md +308 -0
  87. package/departments/kb/skills/knowledge/scripts/kb-check-capabilities.sh +143 -0
  88. package/departments/kb/skills/knowledge/scripts/kb-cleanup.sh +135 -0
  89. package/departments/kb/skills/knowledge/scripts/kb-queue.sh +156 -0
  90. package/departments/kb/skills/knowledge/scripts/kb-status.sh +195 -0
  91. package/departments/kb/skills/knowledge/scripts/kb-worker.sh +217 -0
  92. package/departments/kb/workflows/learn.yaml +1 -0
  93. package/departments/landing/SKILL.md +13 -0
  94. package/departments/landing/agents/affiliate-manager.yaml +1 -0
  95. package/departments/landing/agents/conversion-strategist.yaml +1 -0
  96. package/departments/landing/agents/cro-specialist.yaml +1 -0
  97. package/departments/landing/agents/sales-copywriter.yaml +1 -0
  98. package/departments/landing/workflows/launch.yaml +1 -0
  99. package/departments/landing/workflows/offer.yaml +3 -0
  100. package/departments/leadership/SKILL.md +13 -0
  101. package/departments/leadership/agents/culture-coach.yaml +1 -0
  102. package/departments/leadership/agents/hr-specialist.yaml +1 -0
  103. package/departments/leadership/agents/leadership-director.yaml +1 -0
  104. package/departments/leadership/workflows/team-build.yaml +1 -0
  105. package/departments/marketing/SKILL.md +13 -0
  106. package/departments/marketing/agents/content-marketer.yaml +1 -0
  107. package/departments/marketing/agents/marketing-director.yaml +1 -0
  108. package/departments/marketing/agents/paid-specialist.yaml +1 -0
  109. package/departments/marketing/agents/seo-specialist.yaml +1 -0
  110. package/departments/marketing/workflows/campaign.yaml +1 -0
  111. package/departments/marketing/workflows/social.yaml +1 -0
  112. package/departments/ops/SKILL.md +13 -0
  113. package/departments/ops/agents/automation-engineer.yaml +1 -0
  114. package/departments/ops/agents/doc-writer.yaml +1 -0
  115. package/departments/ops/agents/ops-lead.yaml +1 -0
  116. package/departments/ops/skills/operations/SKILL.md +83 -0
  117. package/departments/ops/skills/operations/references/calendar-email.md +73 -0
  118. package/departments/ops/skills/operations/references/clickup-ops.md +224 -0
  119. package/departments/ops/skills/update/SKILL.md +19 -45
  120. package/departments/ops/skills/update/references/sync-engine.md +93 -0
  121. package/departments/ops/skills/update/references/workflows.md +84 -0
  122. package/departments/ops/workflows/lean-audit.yaml +1 -0
  123. package/departments/org/SKILL.md +13 -0
  124. package/departments/org/agents/coo.yaml +1 -0
  125. package/departments/org/agents/org-designer.yaml +1 -0
  126. package/departments/org/agents/people-ops.yaml +1 -0
  127. package/departments/org/workflows/design.yaml +2 -0
  128. package/departments/pm/SKILL.md +13 -0
  129. package/departments/pm/agents/pm-director.yaml +1 -0
  130. package/departments/pm/agents/product-owner.yaml +1 -0
  131. package/departments/pm/agents/scrum-master.yaml +1 -0
  132. package/departments/quality/SKILL.md +13 -0
  133. package/departments/quality/agents/copy-director.yaml +1 -0
  134. package/departments/quality/agents/cqo.yaml +1 -0
  135. package/departments/quality/agents/tech-director.yaml +1 -0
  136. package/departments/saas/SKILL.md +13 -0
  137. package/departments/saas/agents/cs-manager.yaml +1 -0
  138. package/departments/saas/agents/growth-engineer.yaml +1 -0
  139. package/departments/saas/agents/metrics-analyst.yaml +1 -0
  140. package/departments/saas/agents/saas-strategist.yaml +1 -0
  141. package/departments/saas/workflows/metrics.yaml +1 -0
  142. package/departments/saas/workflows/validate.yaml +1 -0
  143. package/departments/sales/SKILL.md +13 -0
  144. package/departments/sales/agents/sales-closer.yaml +1 -0
  145. package/departments/sales/agents/sales-director.yaml +1 -0
  146. package/departments/sales/agents/sales-ops.yaml +1 -0
  147. package/departments/sales/workflows/pipeline.yaml +1 -0
  148. package/departments/strategy/SKILL.md +13 -0
  149. package/departments/strategy/agents/business-model-designer.yaml +1 -0
  150. package/departments/strategy/agents/market-analyst.yaml +1 -0
  151. package/departments/strategy/agents/strategy-director.yaml +1 -0
  152. package/departments/strategy/workflows/analysis.yaml +1 -0
  153. package/departments/strategy/workflows/swot.yaml +1 -0
  154. package/installer/index.js +19 -0
  155. package/package.json +1 -1
  156. package/pyproject.toml +1 -1
@@ -0,0 +1,77 @@
1
+ # arka-forge — complexity-engine
2
+
3
+ Referenced from SKILL.md. Read only when needed.
4
+
5
+ ## Complexity Tiers
6
+
7
+ | Tier | Score | Explorers | Critic | Companion | Model |
8
+ |------|-------|-----------|--------|-----------|-------|
9
+ | Simple (Shallow) | ≤ 30 | 1 (Pragmatic, inline) | Light | None | haiku |
10
+ | Standard | 31-65 | 2 (Pragmatic + Architectural, parallel) | Full | On request | sonnet |
11
+ | Complex (Deep) | 66-85 | 3 (Pragmatic + Architectural + Contrarian, parallel) | Full | Proactive | opus |
12
+ | Super | ≥ 86 | 3 + full synthesis | Full (highest judgment) | Proactive | opus |
13
+
14
+ Model routing: when dispatching explorer subagents and the critic via the Task tool, pass `model: <tier_model>` using the mapping above. Simple/standard tiers keep costs low; complex/super escalate to opus for the judgment-heavy work.
15
+
16
+ ## Dimensions (0-100 each)
17
+
18
+ | Dimension | Signal |
19
+ |-----------|--------|
20
+ | `scope` | Number of affected files, departments, breadth of change |
21
+ | `dependencies` | Cross-module coupling, external services touched |
22
+ | `ambiguity` | Prompt clarity, missing requirements, unknowns |
23
+ | `risk` | Production impact, security sensitivity, reversibility |
24
+ | `novelty` | Pattern reuse vs net-new territory (lower when similar plans/patterns exist) |
25
+
26
+ ## Step 3 — Complexity Analysis
27
+
28
+ Call the complexity scorer via Python:
29
+
30
+ ```python
31
+ import sys
32
+ sys.path.insert(0, '<repo_root>')
33
+ from core.forge.complexity import analyze_complexity
34
+
35
+ result = analyze_complexity(
36
+ prompt="<user prompt>",
37
+ affected_files=[], # estimate from prompt keywords: auth→auth/, db→core/db/, etc.
38
+ departments=[], # estimate from prompt: "deploy"→ops, "feature"→dev, etc.
39
+ similar_plans=similar_plans,
40
+ reused_patterns=reused_patterns,
41
+ )
42
+ print(f"score={result.score} tier={result.tier.value}")
43
+ print(f"scope={result.dimensions.scope} deps={result.dimensions.dependencies}")
44
+ print(f"ambiguity={result.dimensions.ambiguity} risk={result.dimensions.risk} novelty={result.dimensions.novelty}")
45
+ ```
46
+
47
+ Run this as a Bash command: `cd <repo_root> && python -c "..."`.
48
+
49
+ Display the complexity breakdown using the renderer:
50
+
51
+ ```python
52
+ from core.forge.renderer import render_complexity
53
+ print(render_complexity(result))
54
+ ```
55
+
56
+ ## Step 4 — Tier Confirmation
57
+
58
+ Display to user:
59
+
60
+ ```
61
+ ⚒ FORGE — Complexity Analysis
62
+
63
+ Score: <score>/100 (<Tier>)
64
+ │ Scope │ <n> │ ██████░░░░
65
+ │ Deps │ <n> │ ████░░░░░░
66
+ │ Ambig. │ <n> │ ███████░░░
67
+ │ Risk │ <n> │ █████░░░░░
68
+ │ Novelty │ <n> │ ██░░░░░░░░
69
+
70
+ Tier: <Tier> → <N> explorer(s) + <critic>
71
+ Similar plans: <list or "none found">
72
+ Reusing patterns: <list or "none">
73
+
74
+ Proceed with <Tier> tier? [Y/n/override shallow|standard|deep]
75
+ ```
76
+
77
+ Wait for user input. Accept `Y` or Enter to proceed. Accept `override <tier>` to change tier. Accept `n` to abort.
@@ -0,0 +1,154 @@
1
+ # arka-forge — critic-synthesis
2
+
3
+ Referenced from SKILL.md. Read only when needed.
4
+
5
+ ## Explorer Subagent Instructions
6
+
7
+ Each explorer subagent receives this preamble, then its specific lens instruction.
8
+
9
+ **Preamble (send to all explorers):**
10
+
11
+ ```
12
+ You are an expert planning agent within ArkaOS. Your task is to produce a
13
+ structured execution plan for the following prompt.
14
+
15
+ PROMPT: <original user prompt>
16
+
17
+ REPO CONTEXT:
18
+ Repo: <repo>
19
+ Branch: <branch>
20
+ Commit: <commit>
21
+ ArkaOS: <version>
22
+
23
+ OBSIDIAN KNOWLEDGE:
24
+ Similar plans found: <list or "none">
25
+ Reusable patterns: <list or "none">
26
+
27
+ CONSTITUTION RULES (non-negotiable):
28
+ - branch-isolation: all work on feature branches, never main
29
+ - spec-driven: spec must exist before implementation
30
+ - solid-clean-code: SOLID + Clean Code on all code
31
+ - mandatory-qa: tests must pass, coverage >= 80%
32
+ - quality-gate: Marta + Eduardo + Francisca must APPROVE before done
33
+ - conventional-commits: all commits follow conventional commit format
34
+
35
+ AVAILABLE DEPARTMENTS: dev, ops, mkt, brand, fin, strat, pm, saas,
36
+ landing, content, ecom, kb, sales, lead, community, org
37
+
38
+ AVAILABLE AGENTS (examples):
39
+ dev: Paulo (lead), Gabriel (architect), Andre (backend), Diana (frontend),
40
+ Bruno (security), Carlos (devops), Rita (qa), Vasco (dba)
41
+ ops: Daniel (lead), Lucas (automation)
42
+ mkt: Luna (lead), Sofia (growth), Pedro (analytics), Carla (email)
43
+ brand: Valentina (lead), Miguel (visual), Ana (copy), Joao (ux)
44
+ quality (cross-cutting): Marta (CQO), Eduardo (copy), Francisca (tech)
45
+
46
+ Your output MUST follow this exact format:
47
+ EXPLORER: <your lens name>
48
+ SUMMARY: <2-3 sentences>
49
+ KEY_DECISIONS:
50
+ - decision: <what>
51
+ rationale: <why>
52
+ PHASES:
53
+ - name: <phase name>
54
+ department: <dept>
55
+ agents: [<names>]
56
+ deliverables: [<items>]
57
+ acceptance_criteria: [<items>]
58
+ depends_on: [<phase names>]
59
+ ```
60
+
61
+ **Pragmatic Explorer lens instruction:**
62
+
63
+ ```
64
+ Your lens: PRAGMATIC
65
+ Question to answer: "What is the simplest thing that works?"
66
+ Principles:
67
+ - Minimum viable approach — reuse existing patterns, avoid over-engineering
68
+ - Maximum reuse of existing ArkaOS skills and workflows
69
+ - Fewer phases is better — collapse where safe to do so
70
+ - Prefer known, proven solutions over novel ones
71
+ - Identify what can be skipped without meaningful quality loss
72
+ Be direct. Challenge gold-plating. Propose the leanest plan that still
73
+ satisfies all Constitution rules.
74
+ ```
75
+
76
+ **Architectural Explorer lens instruction:**
77
+
78
+ ```
79
+ Your lens: ARCHITECTURAL
80
+ Question to answer: "What is the right way to build this for the long term?"
81
+ Principles:
82
+ - Long-term extensibility and maintainability over short-term speed
83
+ - Proper separation of concerns, clean boundaries
84
+ - Identify technical debt that would be created by a simpler approach
85
+ - Ensure observability, testability, and deployability are first-class
86
+ - Reference DDD, SOLID, Clean Architecture where applicable
87
+ Be thorough. Do not cut corners that will create future problems.
88
+ ```
89
+
90
+ **Contrarian Explorer lens instruction:**
91
+
92
+ ```
93
+ Your lens: CONTRARIAN
94
+ Question to answer: "What is everyone missing or assuming wrongly?"
95
+ Principles:
96
+ - Challenge the premise of the prompt — is this the right problem to solve?
97
+ - Surface hidden dependencies, risks, and blockers others would miss
98
+ - Question every assumed constraint — are they real?
99
+ - Propose an alternative framing if the original prompt is misguided
100
+ - Identify the single biggest risk in the other approaches
101
+ Be adversarial but constructive. Your job is to stress-test assumptions,
102
+ not to be contrarian for its own sake. You must still produce a valid plan.
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Critic Subagent Instructions
108
+
109
+ The critic receives anonymized approaches (lens labels stripped). Send this prompt:
110
+
111
+ ```
112
+ You are the Plan Critic within ArkaOS. You have received <N> independent
113
+ planning approaches for the same prompt. Your job is to synthesize the best
114
+ plan by combining the strongest elements from each approach.
115
+
116
+ PROMPT: <original user prompt>
117
+
118
+ APPROACHES:
119
+ <approach_1_phases_and_decisions — label stripped>
120
+ ---
121
+ <approach_2_phases_and_decisions — label stripped>
122
+ ---
123
+ <approach_3_phases_and_decisions — label stripped, if deep tier>
124
+
125
+ RULES:
126
+ - You MUST adopt the best elements from multiple approaches (do not just pick one)
127
+ - You MUST reject at least 1 element with a clear reason
128
+ - You MUST identify at least 1 risk in the final plan
129
+ - Confidence score must reflect genuine uncertainty (do not always output 0.9)
130
+ - The final phase list MUST include a Quality Gate phase as the penultimate step
131
+ - The final phase list MUST include an Obsidian persistence phase as the last step
132
+ - All Constitution rules apply to the final plan
133
+
134
+ Your output MUST follow this exact format:
135
+ CONFIDENCE: <0.0-1.0>
136
+ SYNTHESIS:
137
+ approach_1: [<adopted elements from approach 1>]
138
+ approach_2: [<adopted elements from approach 2>]
139
+ approach_3: [<adopted elements from approach 3, if applicable>]
140
+ REJECTED:
141
+ - element: <what>
142
+ reason: <why>
143
+ RISKS:
144
+ - risk: <description>
145
+ severity: high|medium|low
146
+ mitigation: <how to address>
147
+ FINAL_PHASES:
148
+ - name: <phase name>
149
+ department: <dept>
150
+ agents: [<names>]
151
+ deliverables: [<items>]
152
+ acceptance_criteria: [<items>]
153
+ depends_on: [<phase names>]
154
+ ```
@@ -0,0 +1,408 @@
1
+ # arka-forge — workflows
2
+
3
+ Referenced from SKILL.md. Read only when needed.
4
+
5
+ ## Main Flow: `/forge <prompt>`
6
+
7
+ Execute every step sequentially. Never skip steps. Announce each step before running it.
8
+
9
+ ### Step 1 — Context Snapshot
10
+
11
+ Collect the current repo context by running these Bash commands:
12
+
13
+ ```bash
14
+ git rev-parse HEAD # commit hash
15
+ git branch --show-current # branch name
16
+ git remote get-url origin # repo name
17
+ cat VERSION 2>/dev/null || echo "unknown" # ArkaOS version
18
+ ```
19
+
20
+ Build a context dict:
21
+ ```
22
+ repo: <origin url or directory name>
23
+ branch: <current branch>
24
+ commit_at_forge: <HEAD hash>
25
+ arkaos_version: <VERSION file content>
26
+ prompt: <original user prompt>
27
+ ```
28
+
29
+ ### Step 2 — Obsidian Knowledge Check
30
+
31
+ Search Obsidian for relevant patterns and past plans using the MCP obsidian tool:
32
+
33
+ 1. Search `ArkaOS/Forge/Patterns/` for patterns matching keywords from the prompt
34
+ 2. Search `ArkaOS/Forge/Plans/` for plans with similar names or tags
35
+
36
+ Collect:
37
+ - `similar_plans: list[str]` — IDs of plans with overlapping domain/scope
38
+ - `reused_patterns: list[str]` — pattern names that match this prompt's domain
39
+
40
+ If Obsidian is unavailable, set both to `[]` and continue.
41
+
42
+ ### Step 3 — Complexity Analysis
43
+
44
+ See `references/complexity-engine.md` for the full scoring flow and Python invocation.
45
+
46
+ ### Step 4 — Tier Confirmation
47
+
48
+ See `references/complexity-engine.md` for the tier confirmation prompt and override options.
49
+
50
+ ### Step 5 — Launch Explorer Subagents
51
+
52
+ Launch explorer subagents **in parallel** based on confirmed tier:
53
+
54
+ | Tier | Explorers | Run |
55
+ |------|-----------|-----|
56
+ | shallow | 1 — Pragmatic only | Sequential (inline) |
57
+ | standard | 2 — Pragmatic + Architectural | Parallel via Agent tool |
58
+ | deep | 3 — Pragmatic + Architectural + Contrarian | Parallel via Agent tool |
59
+
60
+ For **shallow**, run the Pragmatic explorer inline (no subagent needed — just generate the approach directly).
61
+
62
+ For **standard** and **deep**, use the Agent tool to dispatch each explorer as a subagent. Pass the full explorer prompt (see `references/critic-synthesis.md` → Explorer Subagent Instructions).
63
+
64
+ Each explorer must return a structured response:
65
+ ```
66
+ EXPLORER: <lens>
67
+ SUMMARY: <2-3 sentence description of the approach>
68
+ KEY_DECISIONS:
69
+ - decision: <what>
70
+ rationale: <why>
71
+ PHASES:
72
+ - name: <phase name>
73
+ department: <dev|ops|mkt|brand|fin|strat|pm|saas|landing|content|ecom|kb|sales|lead|community|org>
74
+ agents: [<agent names>]
75
+ deliverables: [<list>]
76
+ acceptance_criteria: [<list>]
77
+ depends_on: [<phase names that must complete first>]
78
+ ```
79
+
80
+ ### Step 6 — Launch Critic Subagent
81
+
82
+ Assemble all explorer outputs. Strip explorer lens labels (anonymize) before sending to critic.
83
+
84
+ Launch a Critic subagent via the Agent tool with the Critic Subagent Instructions (see `references/critic-synthesis.md`).
85
+
86
+ The critic must return:
87
+ ```
88
+ CONFIDENCE: <0.0-1.0>
89
+ SYNTHESIS:
90
+ pragmatic: [<adopted elements>]
91
+ architectural: [<adopted elements>]
92
+ contrarian: [<adopted elements>] # if applicable
93
+ REJECTED:
94
+ - element: <what was rejected>
95
+ reason: <why>
96
+ RISKS:
97
+ - risk: <description>
98
+ severity: high|medium|low
99
+ mitigation: <how to address>
100
+ FINAL_PHASES:
101
+ - name: <phase name>
102
+ department: <dept>
103
+ agents: [<list>]
104
+ deliverables: [<list>]
105
+ acceptance_criteria: [<list>]
106
+ depends_on: [<list>]
107
+ ```
108
+
109
+ ### Step 7 — Render Terminal Output
110
+
111
+ Build the ForgePlan object and render it:
112
+
113
+ ```python
114
+ from core.forge.renderer import render_terminal
115
+ from core.forge.handoff import select_execution_path
116
+
117
+ # Build plan object from collected data
118
+ # Call render_terminal(plan) to get the display string
119
+ # Call select_execution_path(plan.plan_phases) to determine execution route
120
+ ```
121
+
122
+ Display:
123
+ ```
124
+ ⚒ FORGE — <Plan Name>
125
+
126
+ ▸ Context Snapshot
127
+ Repo: <repo> @ <commit>
128
+ ArkaOS: <version> | Branch: <branch>
129
+
130
+ ▸ Complexity Analysis
131
+ <render_complexity output>
132
+
133
+ ▸ Critic Verdict
134
+ Confidence: <score>
135
+ ✓ <N> elements adopted
136
+ ✗ <N> elements rejected
137
+ ⚠ <N> risks identified
138
+
139
+ ▸ Plan: <N> phases across <N> department(s)
140
+ Phase 1: <name> [dept] ░░░░░░░░
141
+ Phase 2: <name> [dept] ░░░░░░░░
142
+ ...
143
+
144
+ Execution: <type> → <target>
145
+ Departments: <list>
146
+ QG required: yes
147
+
148
+ [A]pprove [R]evise [C]ompanion [D]etail phase [Q]uit
149
+ ```
150
+
151
+ ### Step 8 — User Decision
152
+
153
+ Wait for user input and handle each option:
154
+
155
+ | Input | Action |
156
+ |-------|--------|
157
+ | `A` or `approve` | Proceed to Step 9 (handoff) |
158
+ | `R <text>` or `revise <text>` | Proceed to Revision Flow |
159
+ | `C` or `companion` | Generate HTML companion (Step 6a), then re-show menu |
160
+ | `D <n>` or `detail <n>` | Show full detail for phase N (agents, deliverables, criteria), then re-show menu |
161
+ | `Q` or `quit` | Save plan as `draft`, clear active, exit |
162
+
163
+ ### Step 6a — Visual Companion (on C input)
164
+
165
+ Generate HTML via the renderer and serve locally:
166
+
167
+ ```python
168
+ from core.forge.renderer import render_html, should_suggest_companion
169
+
170
+ html_content = render_html(plan)
171
+ # Write to /tmp/forge-<plan_id>.html
172
+ ```
173
+
174
+ ```bash
175
+ # Write HTML file
176
+ python -c "
177
+ import sys
178
+ sys.path.insert(0, '<repo_root>')
179
+ # ... build plan, call render_html, write to /tmp/forge-<id>.html
180
+ "
181
+
182
+ # Serve on random available port
183
+ python -m http.server 0 --directory /tmp &
184
+ # Open in browser
185
+ open http://localhost:<port>/forge-<id>.html
186
+ ```
187
+
188
+ Tell user: "Visual companion available at http://localhost:<port>/forge-<id>.html"
189
+
190
+ Note: For `shallow` tier, companion is not generated (`should_suggest_companion()` returns `"none"`).
191
+ For `standard`, it is available on request. For `deep`, proactively suggest it.
192
+
193
+ ### Step 9 — Handoff (on Approve)
194
+
195
+ 1. Check for repo drift since the snapshot:
196
+
197
+ ```python
198
+ from core.forge.handoff import check_repo_drift
199
+ drift = check_repo_drift(plan.context.commit_at_forge)
200
+ if drift["changed"]:
201
+ # Warn user: "Repo changed since forge: X files modified"
202
+ # Ask: "Re-run complexity analysis? [y/N]"
203
+ ```
204
+
205
+ 2. Determine execution path:
206
+
207
+ ```python
208
+ from core.forge.handoff import select_execution_path, generate_workflow_yaml
209
+ path = select_execution_path(plan.plan_phases)
210
+ ```
211
+
212
+ 3. If path type is `workflow` or `enterprise_workflow`, generate and save the YAML:
213
+
214
+ ```python
215
+ workflow_yaml = generate_workflow_yaml(plan)
216
+ # Write to .arkaos/workflows/<plan_id>.yaml
217
+ ```
218
+
219
+ 4. Update plan status to `approved`, set `executed_at` timestamp.
220
+
221
+ 5. Save and set as active:
222
+
223
+ ```python
224
+ from core.forge.persistence import save_plan, set_active_plan
225
+ save_plan(plan)
226
+ set_active_plan(plan.id)
227
+ ```
228
+
229
+ 6. Announce:
230
+
231
+ ```
232
+ ⚒ FORGE — Approved
233
+
234
+ Plan ID: <id>
235
+ Execution: <type> → <target>
236
+ Branch: <suggested branch name>
237
+
238
+ Ready. Proceeding with execution.
239
+ ```
240
+
241
+ 7. Hand off to the appropriate executor:
242
+ - `skill` → invoke the named ArkaOS skill with plan context
243
+ - `workflow` or `enterprise_workflow` → invoke `/dev feature` or equivalent department command, passing forge context as preamble
244
+
245
+ ### Step 10 — Persist to YAML + Obsidian
246
+
247
+ After approval (or on quit/cancel):
248
+
249
+ ```python
250
+ from core.forge.persistence import save_plan, export_to_obsidian
251
+
252
+ path = save_plan(plan)
253
+ obsidian_path = export_to_obsidian(plan)
254
+ ```
255
+
256
+ For approved + completed plans, also extract patterns:
257
+
258
+ ```python
259
+ from core.forge.persistence import extract_patterns
260
+ patterns = extract_patterns(plan)
261
+ if patterns:
262
+ print(f" Patterns extracted: {len(patterns)}")
263
+ ```
264
+
265
+ ---
266
+
267
+ ## Revision Flow
268
+
269
+ Triggered when user inputs `R <revision text>` at the decision menu.
270
+
271
+ 1. Do NOT re-run explorers. The critic re-evaluates incrementally.
272
+ 2. Increment `plan.revision_count` by 1.
273
+ 3. Send the critic subagent the current plan + user revision text:
274
+
275
+ ```
276
+ REVISION REQUEST: <user revision text>
277
+ CURRENT PLAN VERSION: <revision_count>
278
+
279
+ Current phases:
280
+ <current final phases>
281
+
282
+ Current risks:
283
+ <current risks>
284
+
285
+ Update the plan to incorporate the revision. Apply the same output format.
286
+ Only change what the revision explicitly requests. Preserve everything else.
287
+ ```
288
+
289
+ 4. Update plan with new critic output.
290
+ 5. Re-render terminal output (Step 7) with updated plan.
291
+ 6. Re-show the `[A]pprove [R]evise [C]ompanion [D]etail [Q]uit` menu.
292
+
293
+ Maximum 5 revisions. After 5, warn user and offer approve-as-is or quit.
294
+
295
+ ---
296
+
297
+ ## Secondary Commands
298
+
299
+ ### `/forge resume`
300
+
301
+ 1. Call `get_active_plan()` from `core.forge.persistence`
302
+ 2. If no active plan: "No active forge plan. Run `/forge <prompt>` to start."
303
+ 3. If plan found:
304
+ - Call `check_repo_drift(plan.context.commit_at_forge)`
305
+ - If drift detected: warn user, offer to re-run complexity analysis
306
+ - Re-render terminal output (Step 7)
307
+ - Re-show decision menu (Step 8)
308
+
309
+ ### `/forge status`
310
+
311
+ 1. Call `get_active_plan()` from `core.forge.persistence`
312
+ 2. If none: "No active forge plan."
313
+ 3. Display:
314
+ ```
315
+ ⚒ FORGE — Active Plan
316
+
317
+ ID: <id>
318
+ Name: <name>
319
+ Status: <status>
320
+ Tier: <tier> | Score: <score>/100
321
+ Confidence: <critic confidence>
322
+ Phases: <N> across <depts>
323
+ Created: <timestamp>
324
+ Revisions: <count>
325
+ ```
326
+
327
+ ### `/forge history`
328
+
329
+ 1. Call `list_plans()` from `core.forge.persistence`
330
+ 2. If empty: "No forge plans found in ~/.arkaos/plans/"
331
+ 3. Display table:
332
+ ```
333
+ ⚒ FORGE — History
334
+
335
+ ID Name Status Tier Conf. Created
336
+ forge-20260411-abc1 Add auth module approved deep 0.87 2026-04-11
337
+ forge-20260410-def2 Refactor billing flow completed standard 0.74 2026-04-10
338
+ ...
339
+ ```
340
+
341
+ ### `/forge show <id>`
342
+
343
+ 1. Call `load_plan(id)` from `core.forge.persistence`
344
+ 2. If not found: "Plan <id> not found."
345
+ 3. Display full terminal render via `render_terminal(plan)`
346
+ 4. Then show all approaches (explorer summaries) and full critic verdict.
347
+
348
+ ### `/forge compare <id1> <id2>`
349
+
350
+ 1. Load both plans via `load_plan()`
351
+ 2. Display side-by-side:
352
+ ```
353
+ ⚒ FORGE — Comparing Plans
354
+
355
+ Left: <id1> (<name1>) | Right: <id2> (<name2>)
356
+ Score: <s1>/100 (<tier1>) | Score: <s2>/100 (<tier2>)
357
+ Confidence: <c1> | Confidence: <c2>
358
+ Phases: <n1> | Phases: <n2>
359
+
360
+ PHASES LEFT PHASES RIGHT
361
+ ─────────────────────────────── ───────────────────────────────
362
+ Phase 1: <name> [dept] Phase 1: <name> [dept]
363
+ Phase 2: <name> [dept] Phase 2: <name> [dept]
364
+ ...
365
+
366
+ RISK DELTA:
367
+ Left risks not in right: <list>
368
+ Right risks not in left: <list>
369
+ ```
370
+
371
+ ### `/forge patterns`
372
+
373
+ 1. Call `load_patterns()` from `core.forge.persistence`
374
+ 2. If empty: "No patterns found in ArkaOS/Forge/Patterns/"
375
+ 3. Display:
376
+ ```
377
+ ⚒ FORGE — Reusable Patterns
378
+
379
+ Name Tier Depts Phases Used
380
+ repo-dev-ops-pattern deep dev, ops 6 3
381
+ repo-dev-pattern standard dev 4 7
382
+ ...
383
+ ```
384
+
385
+ ### `/forge cancel`
386
+
387
+ 1. Load active plan via `get_active_plan()`
388
+ 2. If none: "No active plan to cancel."
389
+ 3. Confirm: "Cancel plan '<name>'? This cannot be undone. [y/N]"
390
+ 4. On confirm: set `plan.status = ForgeStatus.CANCELLED`, call `save_plan()`, call `clear_active_plan()`
391
+ 5. "Forge plan cancelled. No changes were made to the codebase."
392
+
393
+ ---
394
+
395
+ ## Constitution Compliance
396
+
397
+ The Forge enforces these Constitution rules at the plan level:
398
+
399
+ | Rule | Enforcement |
400
+ |------|-------------|
401
+ | `branch-isolation` | Every plan must include a "Create feature branch" step in Phase 1 |
402
+ | `spec-driven` | Plans touching code must have a Specification phase before Implementation |
403
+ | `mandatory-qa` | All plans must include a QA phase (Rita) before Quality Gate |
404
+ | `quality-gate` | All plans must end with a Quality Gate phase (Marta + Eduardo + Francisca) |
405
+ | `obsidian-output` | All plans must end with an Obsidian persistence step |
406
+ | `conventional-commits` | Remind in handoff message |
407
+
408
+ If a critic output violates any of these, inject the missing phases automatically before showing the plan to the user. Announce: "Constitution enforcement: added missing <phase name> phase."