claudecode-omc 5.6.8 → 5.9.1

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 (121) hide show
  1. package/.local/skills/prompt-optimizer/SKILL.md +262 -19
  2. package/.omc-curation/ecc-selection.json +80 -0
  3. package/.omc-curation/governance.json +113 -0
  4. package/.omc-curation/sources.lock.json +25 -0
  5. package/README.md +69 -4
  6. package/bundled/manifest.json +5 -5
  7. package/bundled/upstream/anthropic-skills/.omc-source/bundle.json +18 -0
  8. package/bundled/upstream/anthropic-skills/.omc-source/provenance.json +399 -0
  9. package/bundled/upstream/anthropic-skills/skills/claude-api/SKILL.md +18 -17
  10. package/bundled/upstream/anthropic-skills/skills/claude-api/curl/examples.md +9 -9
  11. package/bundled/upstream/anthropic-skills/skills/claude-api/curl/managed-agents.md +4 -4
  12. package/bundled/upstream/anthropic-skills/skills/claude-api/go/managed-agents/README.md +2 -2
  13. package/bundled/upstream/anthropic-skills/skills/claude-api/java/claude-api.md +2 -2
  14. package/bundled/upstream/anthropic-skills/skills/claude-api/java/managed-agents/README.md +2 -2
  15. package/bundled/upstream/anthropic-skills/skills/claude-api/php/claude-api.md +10 -10
  16. package/bundled/upstream/anthropic-skills/skills/claude-api/php/managed-agents/README.md +2 -2
  17. package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/README.md +16 -16
  18. package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/batches.md +3 -3
  19. package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/files-api.md +3 -3
  20. package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/streaming.md +7 -7
  21. package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/tool-use.md +19 -19
  22. package/bundled/upstream/anthropic-skills/skills/claude-api/python/managed-agents/README.md +3 -3
  23. package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/claude-api.md +4 -4
  24. package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/managed-agents/README.md +2 -2
  25. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/error-codes.md +5 -5
  26. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/live-sources.md +3 -1
  27. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-api-reference.md +10 -4
  28. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-core.md +19 -1
  29. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-environments.md +6 -2
  30. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-multiagent.md +1 -1
  31. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-onboarding.md +3 -3
  32. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-overview.md +3 -2
  33. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +173 -0
  34. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-tools.md +10 -4
  35. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/model-migration.md +113 -13
  36. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/models.md +14 -11
  37. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/prompt-caching.md +2 -2
  38. package/bundled/upstream/anthropic-skills/skills/claude-api/shared/tool-use-concepts.md +4 -4
  39. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/README.md +15 -15
  40. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/batches.md +2 -2
  41. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/files-api.md +1 -1
  42. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/streaming.md +5 -5
  43. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/tool-use.md +15 -15
  44. package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/managed-agents/README.md +3 -3
  45. package/bundled/upstream/ecc/.omc-source/bundle.json +2 -1
  46. package/bundled/upstream/ecc/.omc-source/last-plan-apply.json +108 -24
  47. package/bundled/upstream/ecc/.omc-source/manifests/.claude-plugin/marketplace.json +3 -3
  48. package/bundled/upstream/ecc/.omc-source/provenance.json +563 -0
  49. package/bundled/upstream/ecc/agents/marketing-agent.md +159 -0
  50. package/bundled/upstream/ecc/agents/react-build-resolver.md +215 -0
  51. package/bundled/upstream/ecc/agents/react-reviewer.md +167 -0
  52. package/bundled/upstream/ecc/agents/typescript-reviewer.md +3 -0
  53. package/bundled/upstream/ecc/commands/harness-audit.md +17 -10
  54. package/bundled/upstream/ecc/commands/marketing-campaign.md +129 -0
  55. package/bundled/upstream/ecc/commands/react-build.md +187 -0
  56. package/bundled/upstream/ecc/commands/react-review.md +170 -0
  57. package/bundled/upstream/ecc/commands/react-test.md +265 -0
  58. package/bundled/upstream/ecc/skills/benchmark-optimization-loop/SKILL.md +69 -0
  59. package/bundled/upstream/ecc/skills/blender-motion-state-inspection/SKILL.md +164 -0
  60. package/bundled/upstream/ecc/skills/canary-watch/SKILL.md +9 -1
  61. package/bundled/upstream/ecc/skills/continuous-learning-v2/hooks/observe.sh +31 -9
  62. package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/detect-project.sh +38 -4
  63. package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/instinct-cli.py +319 -12
  64. package/bundled/upstream/ecc/skills/data-throughput-accelerator/SKILL.md +72 -0
  65. package/bundled/upstream/ecc/skills/dynamic-workflow-mode/SKILL.md +123 -0
  66. package/bundled/upstream/ecc/skills/frontend-a11y/SKILL.md +446 -0
  67. package/bundled/upstream/ecc/skills/ito-basket-compare/SKILL.md +63 -0
  68. package/bundled/upstream/ecc/skills/ito-data-atlas-agent/SKILL.md +63 -0
  69. package/bundled/upstream/ecc/skills/ito-market-intelligence/SKILL.md +60 -0
  70. package/bundled/upstream/ecc/skills/ito-trade-planner/SKILL.md +67 -0
  71. package/bundled/upstream/ecc/skills/latency-critical-systems/SKILL.md +73 -0
  72. package/bundled/upstream/ecc/skills/marketing-campaign/SKILL.md +113 -0
  73. package/bundled/upstream/ecc/skills/nextjs-turbopack/SKILL.md +13 -0
  74. package/bundled/upstream/ecc/skills/parallel-execution-optimizer/SKILL.md +72 -0
  75. package/bundled/upstream/ecc/skills/prediction-market-oracle-research/SKILL.md +63 -0
  76. package/bundled/upstream/ecc/skills/prediction-market-risk-review/SKILL.md +60 -0
  77. package/bundled/upstream/ecc/skills/react-patterns/SKILL.md +341 -0
  78. package/bundled/upstream/ecc/skills/react-performance/SKILL.md +574 -0
  79. package/bundled/upstream/ecc/skills/react-testing/SKILL.md +423 -0
  80. package/bundled/upstream/ecc/skills/recsys-pipeline-architect/SKILL.md +114 -0
  81. package/bundled/upstream/ecc/skills/recursive-decision-ledger/SKILL.md +79 -0
  82. package/bundled/upstream/ecc/skills/social-publisher/SKILL.md +115 -0
  83. package/bundled/upstream/ecc/skills/team-agent-orchestration/SKILL.md +110 -0
  84. package/bundled/upstream/ecc/skills/uncloud/SKILL.md +343 -0
  85. package/bundled/upstream/ecc/skills/windows-desktop-e2e/SKILL.md +99 -0
  86. package/bundled/upstream/oh-my-claudecode/.omc-source/bundle.json +2 -1
  87. package/bundled/upstream/oh-my-claudecode/.omc-source/provenance.json +116 -0
  88. package/bundled/upstream/oh-my-claudecode/skills/autopilot/SKILL.md +7 -0
  89. package/bundled/upstream/oh-my-claudecode/skills/cancel/SKILL.md +1 -0
  90. package/bundled/upstream/oh-my-claudecode/skills/deep-interview/SKILL.md +39 -5
  91. package/bundled/upstream/oh-my-claudecode/skills/hud/SKILL.md +1 -0
  92. package/bundled/upstream/oh-my-claudecode/skills/local-build-reminder/SKILL.md +78 -0
  93. package/bundled/upstream/oh-my-claudecode/skills/omc-doctor/SKILL.md +1 -1
  94. package/bundled/upstream/oh-my-claudecode/skills/omc-setup/SKILL.md +26 -10
  95. package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/01-install-claude-md.md +3 -3
  96. package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/02-configure.md +6 -4
  97. package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/03-integrations.md +1 -1
  98. package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/04-welcome.md +2 -2
  99. package/bundled/upstream/oh-my-claudecode/skills/omc-teams/SKILL.md +6 -6
  100. package/bundled/upstream/oh-my-claudecode/skills/plan/SKILL.md +44 -32
  101. package/bundled/upstream/oh-my-claudecode/skills/ralph/SKILL.md +45 -21
  102. package/bundled/upstream/oh-my-claudecode/skills/ralplan/SKILL.md +1 -1
  103. package/bundled/upstream/oh-my-claudecode/skills/self-improve/SKILL.md +7 -0
  104. package/bundled/upstream/oh-my-claudecode/skills/self-improve/scripts/resolve-paths.mjs +39 -15
  105. package/bundled/upstream/oh-my-claudecode/skills/team/SKILL.md +132 -90
  106. package/bundled/upstream/oh-my-claudecode/skills/ultragoal/SKILL.md +93 -0
  107. package/bundled/upstream/oh-my-claudecode/skills/ultraqa/SKILL.md +28 -13
  108. package/bundled/upstream/oh-my-claudecode/skills/ultrawork/SKILL.md +7 -0
  109. package/bundled/upstream/superpowers/.omc-source/bundle.json +2 -1
  110. package/bundled/upstream/superpowers/.omc-source/provenance.json +63 -0
  111. package/package.json +2 -1
  112. package/src/catalog/source-catalog.js +10 -4
  113. package/src/cli/index.js +4 -0
  114. package/src/cli/plan.js +14 -2
  115. package/src/cli/setup.js +52 -13
  116. package/src/cli/skill.js +1 -1
  117. package/src/cli/source.js +265 -14
  118. package/src/config/sources.js +67 -1
  119. package/src/merge/content-patch.js +84 -0
  120. package/templates/merge-config.json +1 -8
  121. package/bundled/upstream/ecc/skills/strategic-compact/suggest-compact.sh +0 -54
@@ -13,25 +13,28 @@ Plan creates comprehensive, actionable work plans through intelligent interactio
13
13
  </Purpose>
14
14
 
15
15
  <Use_When>
16
+
16
17
  - User wants to plan before implementing -- "plan this", "plan the", "let's plan"
17
18
  - User wants structured requirements gathering for a vague idea
18
19
  - User wants an existing plan reviewed -- "review this plan", `--review`
19
20
  - User wants multi-perspective consensus on a plan -- `--consensus`, "ralplan"
20
21
  - Task is broad or vague and needs scoping before any code is written
21
- </Use_When>
22
+ </Use_When>
22
23
 
23
24
  <Do_Not_Use_When>
25
+
24
26
  - User wants autonomous end-to-end execution -- use `autopilot` instead
25
27
  - User wants to start coding immediately with a clear task -- use `ralph` or delegate to executor
26
28
  - User asks a simple question that can be answered directly -- just answer it
27
29
  - Task is a single focused fix with obvious scope -- use an execution skill instead of running it from this planning module
28
- </Do_Not_Use_When>
30
+ </Do_Not_Use_When>
29
31
 
30
32
  <Why_This_Exists>
31
33
  Jumping into code without understanding requirements leads to rework, scope creep, and missed edge cases. Plan provides structured requirements gathering, expert analysis, and quality-gated plans so that execution starts from a solid foundation. The consensus mode adds multi-perspective validation for high-stakes projects.
32
34
  </Why_This_Exists>
33
35
 
34
36
  <Execution_Policy>
37
+
35
38
  - Auto-detect interview vs direct mode based on request specificity
36
39
  - Ask one question at a time during interviews -- never batch multiple questions
37
40
  - Gather codebase facts via `explore` agent before asking the user about them
@@ -39,18 +42,20 @@ Jumping into code without understanding requirements leads to rework, scope cree
39
42
  - Consensus mode runs fully automated by default; add `--interactive` to enable user prompts at draft review and final approval steps
40
43
  - Consensus mode uses RALPLAN-DR short mode by default; switch to deliberate mode with `--deliberate` or when the request explicitly signals high risk (auth/security, data migration, destructive/irreversible changes, production incident, compliance/PII, public API breakage)
41
44
  - **Planning/execution boundary:** planning modes inspect context and produce plans/specs/proposals only. They MUST mark artifacts as `pending approval` unless the user has explicitly opted into execution in the current turn or via the structured approval UI. Before explicit execution approval, planning modes MUST NOT run mutation-oriented shell commands, edit source files, commit, push, open PRs, invoke execution skills, or delegate implementation tasks.
42
- </Execution_Policy>
45
+ - **Goal workflow boundary:** when a plan compares Claude Code `/goal`, Ralph, Team, UltraQA, or artifact-only Ultragoal, identify exactly one primary loop authority and use the deterministic conflict policies `refuse`, `adopt_existing`, and `artifact_only` rather than non-deterministic warning handling. `/goal` facts must cite Claude Code/Anthropic sources only (Claude Code `/goal` docs: https://code.claude.com/docs/en/goal; Anthropic Claude Code changelog: https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md), and plans MUST NOT claim the `/goal` evaluator independently runs commands or reads files; require surfaced proof evidence before any completion claim.
46
+ - **Goal workflow doc target:** for user-facing comparisons, keep examples aligned with `docs/shared/mode-selection-guide.md#goal-oriented-workflow-selection` and `docs/REFERENCE.md#goal-workflow-ux-goal-ralph-team-ultraqa-ultragoal`.
47
+ </Execution_Policy>
43
48
 
44
49
  <Steps>
45
50
 
46
51
  ### Mode Selection
47
52
 
48
- | Mode | Trigger | Behavior |
49
- |------|---------|----------|
50
- | Interview | Default for broad requests | Interactive requirements gathering |
51
- | Direct | `--direct`, or detailed request | Skip interview, generate plan directly |
52
- | Consensus | `--consensus`, "ralplan" | Planner -> Architect -> Critic loop until agreement with RALPLAN-DR structured deliberation (short by default, `--deliberate` for high-risk); add `--interactive` for user prompts at draft and approval steps |
53
- | Review | `--review`, "review this plan" | Critic evaluation of existing plan |
53
+ | Mode | Trigger | Behavior |
54
+ | --------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
+ | Interview | Default for broad requests | Interactive requirements gathering |
56
+ | Direct | `--direct`, or detailed request | Skip interview, generate plan directly |
57
+ | Consensus | `--consensus`, "ralplan" | Planner -> Architect -> Critic loop until agreement with RALPLAN-DR structured deliberation (short by default, `--deliberate` for high-risk); add `--interactive` for user prompts at draft and approval steps |
58
+ | Review | `--review`, "review this plan" | Critic evaluation of existing plan |
54
59
 
55
60
  ### Interview Mode (broad/vague requests)
56
61
 
@@ -72,11 +77,13 @@ Jumping into code without understanding requirements leads to rework, scope cree
72
77
  **RALPLAN-DR modes**: **Short** (default, bounded structure) and **Deliberate** (for `--deliberate` or explicit high-risk requests). Both modes keep the same Planner -> Architect -> Critic sequence and the same `AskUserQuestion` gates.
73
78
 
74
79
  **Provider overrides (supported when the provider CLI is installed):**
80
+
75
81
  - `--architect codex` — replace the Claude Architect pass with `omc ask codex --agent-prompt architect "..."` for implementation-heavy architecture review
76
82
  - `--critic codex` — replace the Claude Critic pass with `omc ask codex --agent-prompt critic "..."` for an external review pass before execution
77
83
  - If the requested provider is unavailable, briefly note that and continue with the default Claude Architect/Critic step for that stage
78
84
 
79
85
  **State lifecycle**: The persistent-mode stop hook uses `ralplan-state.json` to enforce continuation during the consensus loop. The skill **MUST** manage this state:
86
+
80
87
  - **On entry**: Call `state_write(mode="ralplan", active=true, session_id=<current_session_id>)` before step 1
81
88
  - **On handoff to execution** (approval → ralph/team): Call `state_write(mode="ralplan", active=false, session_id=<current_session_id>)`. Do NOT use `state_clear` here — `state_clear` writes a 30-second cancel signal that disables stop-hook enforcement for ALL modes, leaving the newly launched execution mode unprotected.
82
89
  - **On true terminal exit** (rejection, non-interactive plan output, error/abort): Call `state_clear(mode="ralplan", session_id=<current_session_id>)` — no execution mode follows, so the cancel signal window is harmless.
@@ -90,11 +97,11 @@ Without cleanup, the stop hook blocks all subsequent stops with `[RALPLAN - CONS
90
97
  - **Viable Options** (>=2) with bounded pros/cons for each option
91
98
  - If only one viable option remains, an explicit **invalidation rationale** for the alternatives that were rejected
92
99
  - In **deliberate mode**: a **pre-mortem** (3 failure scenarios) and an **expanded test plan** covering **unit / integration / e2e / observability**
93
- 2. **User feedback** *(--interactive only)*: If running with `--interactive`, **MUST** use `AskUserQuestion` to present the draft plan **plus the RALPLAN-DR Principles / Decision Drivers / Options summary for early direction alignment** with these options:
100
+ 2. **User feedback** _(--interactive only)_: If running with `--interactive`, **MUST** use `AskUserQuestion` to present the draft plan **plus the RALPLAN-DR Principles / Decision Drivers / Options summary for early direction alignment** with these options:
94
101
  - **Proceed to review** — send to Architect and Critic for evaluation
95
102
  - **Request changes** — return to step 1 with user feedback incorporated
96
103
  - **Skip review** — go directly to final approval (step 7)
97
- If NOT running with `--interactive`, automatically proceed to review (step 3).
104
+ If NOT running with `--interactive`, automatically proceed to review (step 3).
98
105
  3. **Architect** reviews for architectural soundness using `Task(subagent_type="oh-my-claudecode:architect", ...)`. Architect review **MUST** include: strongest steelman counterargument (antithesis) against the favored option, at least one meaningful tradeoff tension, and (when possible) a synthesis path. In deliberate mode, Architect should explicitly flag principle violations. **Wait for this step to complete before proceeding to step 4.** Do NOT run steps 3 and 4 in parallel.
99
106
  4. **Critic** evaluates against quality criteria using `Task(subagent_type="oh-my-claudecode:critic", ...)`. Critic **MUST** verify principle-option consistency, fair alternative exploration, risk mitigation clarity, testable acceptance criteria, and concrete verification steps. Critic **MUST** explicitly reject shallow alternatives, driver contradictions, vague risks, or weak verification. In deliberate mode, Critic **MUST** reject missing/weak pre-mortem or missing/weak expanded test plan. Run only after step 3 is complete.
100
107
  5. **Re-review loop** (max 5 iterations): If Critic rejects, execute this closed loop:
@@ -109,18 +116,18 @@ Without cleanup, the stop hook blocks all subsequent stops with `[RALPLAN - CONS
109
116
  b. Deduplicate and categorize the suggestions
110
117
  c. Update the plan file in `.omc/plans/` with the accepted improvements (add missing details, refine steps, strengthen acceptance criteria, ADR updates, etc.)
111
118
  d. Note which improvements were applied in a brief changelog section at the end of the plan
112
- 7. On Critic approval (with improvements applied): mark the plan status as `pending approval` unless explicit execution approval has already been captured. *(--interactive only)* If running with `--interactive`, use `AskUserQuestion` to present the plan with these options:
119
+ 7. On Critic approval (with improvements applied): mark the plan status as `pending approval` unless explicit execution approval has already been captured. _(--interactive only)_ If running with `--interactive`, use `AskUserQuestion` to present the plan with these options:
113
120
  - **Approve execution via team** (Recommended) — explicit opt-in to proceed via coordinated parallel team agents (`/team`). Team is the canonical orchestration surface since v4.1.7.
114
121
  - **Approve execution via ralph** — explicit opt-in to proceed via ralph+ultrawork (sequential execution with verification)
115
- - **Approve execution after clearing context** — explicit opt-in to compact the context window first (recommended when context is large after planning), then start fresh implementation via ralph with the saved plan file
122
+ - **Compact then return for execution approval** — explicit opt-in to compact the context window first (recommended when context is large after planning), then stop at the saved pending-approval plan and ask again before launching execution
116
123
  - **Request changes** — return to step 1 with user feedback
117
124
  - **Reject** — discard the plan entirely
118
- If NOT running with `--interactive`, output the final plan marked `pending approval`, call `state_clear(mode="ralplan", session_id=<current_session_id>)`, and stop. Do NOT auto-execute.
119
- 8. *(--interactive only)* User chooses via the structured `AskUserQuestion` UI (never ask for approval in plain text). If user selects **Reject**, call `state_clear(mode="ralplan", session_id=<current_session_id>)` and stop.
125
+ If NOT running with `--interactive`, output the final plan marked `pending approval`, call `state_clear(mode="ralplan", session_id=<current_session_id>)`, and stop. Do NOT auto-execute.
126
+ 8. _(--interactive only)_ User chooses via the structured `AskUserQuestion` UI (never ask for approval in plain text). If user selects **Reject**, call `state_clear(mode="ralplan", session_id=<current_session_id>)` and stop.
120
127
  9. On user approval (--interactive only): Call `state_write(mode="ralplan", active=false, session_id=<current_session_id>)` **before** invoking the execution skill (ralph/team), so the stop hook does not interfere with the execution mode's own enforcement. Do NOT use `state_clear` here — it writes a cancel signal that disables enforcement for the newly launched mode.
121
128
  - **Approve execution via team**: **MUST** invoke `Skill("oh-my-claudecode:team")` with the approved plan path from `.omc/plans/` as context. Do NOT implement directly. The team skill coordinates parallel agents across the staged pipeline for faster execution on large tasks. This is the recommended default execution path.
122
129
  - **Approve execution via ralph**: **MUST** invoke `Skill("oh-my-claudecode:ralph")` with the approved plan path from `.omc/plans/` as context. Do NOT implement directly. Do NOT edit source code files in the planning agent. The ralph skill handles execution via ultrawork parallel agents.
123
- - **Approve execution after clearing context**: First invoke `Skill("compact")` to compress the context window (reduces token usage accumulated during planning), then invoke `Skill("oh-my-claudecode:ralph")` with the approved plan path from `.omc/plans/`. This path is recommended when the context window is 50%+ full after the planning session.
130
+ - **Compact then return for execution approval**: First invoke `Skill("compact")` to compress the context window (reduces token usage accumulated during planning), then return with the saved pending-approval plan path and require a fresh explicit execution approval before any ralph/team launch. This path is recommended when the context window is 50%+ full after the planning session.
124
131
 
125
132
  ### Review Mode (`--review`)
126
133
 
@@ -131,6 +138,7 @@ Without cleanup, the stop hook blocks all subsequent stops with `[RALPLAN - CONS
131
138
  ### Plan Output Format
132
139
 
133
140
  Every plan includes:
141
+
134
142
  - Requirements Summary
135
143
  - Acceptance Criteria (testable)
136
144
  - Implementation Steps (with file references)
@@ -144,6 +152,7 @@ Plans are saved to `.omc/plans/`. Drafts go to `.omc/drafts/`.
144
152
  </Steps>
145
153
 
146
154
  <Tool_Usage>
155
+
147
156
  - Use `AskUserQuestion` for preference questions (scope, priority, timeline, risk tolerance) -- provides clickable UI
148
157
  - Use plain text for questions needing specific values (port numbers, names, follow-up clarifications)
149
158
  - Use `explore` agent (Haiku, 30s timeout) to gather codebase facts before asking the user
@@ -155,9 +164,9 @@ Plans are saved to `.omc/plans/`. Drafts go to `.omc/drafts/`.
155
164
  - In consensus mode with `--interactive`: use `AskUserQuestion` for the user feedback step (step 2) and the final approval step (step 7) -- never ask for approval in plain text. Without `--interactive`, skip both prompts, mark the plan `pending approval`, output the final plan, and stop.
156
165
  - In consensus mode with `--interactive`, on explicit user approval **MUST** invoke `Skill("oh-my-claudecode:ralph")` or `Skill("oh-my-claudecode:team")` for execution (step 9) -- never implement directly in the planning agent
157
166
  - Before explicit execution approval, planning mode MUST NOT run mutation-oriented shell commands, edit files, commit, push, open PRs, invoke execution skills, or delegate implementation tasks; it may only inspect context and draft/update plan/spec/proposal artifacts.
158
- - When user selects "Approve execution after clearing context" in step 7 (--interactive only): call `state_write(mode="ralplan", active=false, session_id=<current_session_id>)` first, then invoke `Skill("compact")` to compress the accumulated planning context, then immediately invoke `Skill("oh-my-claudecode:ralph")` with the plan path -- the compact step is critical to free up context before the implementation loop begins
167
+ - When user selects "Compact then return for execution approval" in step 7 (--interactive only): keep the plan marked `pending approval`, call `state_write(mode="ralplan", active=false, current_phase="pending_approval", session_id=<current_session_id>)`, then invoke `Skill("compact")` to compress the accumulated planning context. After compact, require a fresh explicit execution approval before any ralph/team launch; never auto-start implementation from compact continuation
159
168
  - **CRITICAL — Consensus mode state lifecycle**: Always deactivate ralplan state before stopping or handing off to execution. Use `state_write(active=false)` for handoff paths (approval → ralph/team) and `state_clear` for true terminal exits (rejection, error). Never use `state_clear` before launching an execution mode — its cancel signal disables stop-hook enforcement for 30 seconds.
160
- </Tool_Usage>
169
+ </Tool_Usage>
161
170
 
162
171
  <Examples>
163
172
  <Good>
@@ -210,14 +219,16 @@ Why bad: Decision fatigue. Present one option with trade-offs, get reaction, the
210
219
  </Examples>
211
220
 
212
221
  <Escalation_And_Stop_Conditions>
222
+
213
223
  - Stop interviewing when requirements are clear enough to plan -- do not over-interview
214
224
  - In consensus mode, stop after 5 Planner/Architect/Critic iterations and present the best version. Do NOT clear ralplan state here — the user may still select "Request changes" in the subsequent step. State is cleared only on the user's final choice (approval/rejection) or when outputting the plan in non-interactive mode.
215
225
  - Consensus mode without `--interactive` outputs the final plan marked `pending approval` and stops; with `--interactive`, requires explicit user approval before any implementation begins. **Always** call `state_clear(mode="ralplan", session_id=<current_session_id>)` before stopping.
216
226
  - If the user says "just do it" or "skip planning" without explicitly naming an execution path, treat it as a request to end planning: output the current plan/spec/proposal as `pending approval` and ask for explicit execution approval via the structured approval UI. Do NOT invoke `Skill("oh-my-claudecode:ralph")`, mutate files, delegate implementation, commit, push, or open a PR from the planning module until that approval exists.
217
227
  - Escalate to the user when there are irreconcilable trade-offs that require a business decision
218
- </Escalation_And_Stop_Conditions>
228
+ </Escalation_And_Stop_Conditions>
219
229
 
220
230
  <Final_Checklist>
231
+
221
232
  - [ ] Plan has testable acceptance criteria (90%+ concrete)
222
233
  - [ ] Plan references specific files/lines where applicable (80%+ claims)
223
234
  - [ ] All risks have mitigations identified
@@ -228,7 +239,7 @@ Why bad: Decision fatigue. Present one option with trade-offs, get reaction, the
228
239
  - [ ] In deliberate consensus mode: pre-mortem (3 scenarios) + expanded test plan (unit/integration/e2e/observability) included
229
240
  - [ ] In consensus mode with `--interactive`: user explicitly approved before any execution; without `--interactive`: plan output marked `pending approval` only, no auto-execution
230
241
  - [ ] In consensus mode: ralplan state deactivated on every exit path — `state_write(active=false)` for handoff to execution, `state_clear` for terminal exits (rejection, error, non-interactive stop)
231
- </Final_Checklist>
242
+ </Final_Checklist>
232
243
 
233
244
  <Advanced>
234
245
  ## Design Option Presentation
@@ -243,6 +254,7 @@ When presenting design choices during interviews, chunk them:
243
254
  6. **Recommendation** (only after options discussed)
244
255
 
245
256
  Format for each option:
257
+
246
258
  ```
247
259
  ### Option A: [Name]
248
260
  **Approach:** [1 sentence]
@@ -256,21 +268,21 @@ What's your reaction to this approach?
256
268
 
257
269
  Before asking any interview question, classify it:
258
270
 
259
- | Type | Examples | Action |
260
- |------|----------|--------|
261
- | Codebase Fact | "What patterns exist?", "Where is X?" | Explore first, do not ask user |
262
- | User Preference | "Priority?", "Timeline?" | Ask user via AskUserQuestion |
263
- | Scope Decision | "Include feature Y?" | Ask user |
264
- | Requirement | "Performance constraints?" | Ask user |
271
+ | Type | Examples | Action |
272
+ | --------------- | ------------------------------------- | ------------------------------ |
273
+ | Codebase Fact | "What patterns exist?", "Where is X?" | Explore first, do not ask user |
274
+ | User Preference | "Priority?", "Timeline?" | Ask user via AskUserQuestion |
275
+ | Scope Decision | "Include feature Y?" | Ask user |
276
+ | Requirement | "Performance constraints?" | Ask user |
265
277
 
266
278
  ## Review Quality Criteria
267
279
 
268
- | Criterion | Standard |
269
- |-----------|----------|
270
- | Clarity | 80%+ claims cite file/line |
271
- | Testability | 90%+ criteria are concrete |
272
- | Verification | All file refs exist |
273
- | Specificity | No vague terms |
280
+ | Criterion | Standard |
281
+ | ------------ | -------------------------- |
282
+ | Clarity | 80%+ claims cite file/line |
283
+ | Testability | 90%+ criteria are concrete |
284
+ | Verification | All file refs exist |
285
+ | Specificity | No vague terms |
274
286
 
275
287
  ## Deprecation Notice
276
288
 
@@ -14,26 +14,30 @@ Ralph is a PRD-driven persistence loop that keeps working on a task until ALL us
14
14
  </Purpose>
15
15
 
16
16
  <Use_When>
17
+
17
18
  - Task requires guaranteed completion with verification (not just "do your best")
18
19
  - User says "ralph", "don't stop", "must complete", "finish this", or "keep going until done"
19
20
  - Work may span multiple iterations and needs persistence across retries
20
21
  - Task benefits from structured PRD-driven execution with reviewer sign-off
21
- </Use_When>
22
+ </Use_When>
22
23
 
23
24
  <Do_Not_Use_When>
25
+
24
26
  - User wants a full autonomous pipeline from idea to code -- use `autopilot` instead
25
27
  - User wants to explore or plan before committing -- use `plan` skill instead
26
28
  - User wants a quick one-shot fix -- delegate directly to an executor agent
27
29
  - User wants manual control over completion -- use `ultrawork` directly
28
- </Do_Not_Use_When>
30
+ - User already has an active Claude Code `/goal` and only wants that native goal loop monitored -- adopt the existing `/goal` explicitly or use artifact-only Ultragoal notes instead of starting Ralph as a competing persistence loop
31
+ </Do_Not_Use_When>
29
32
 
30
33
  <Why_This_Exists>
31
34
  Complex tasks often fail silently: partial implementations get declared "done", tests get skipped, edge cases get forgotten. Ralph prevents this by:
35
+
32
36
  1. Structuring work into discrete user stories with testable acceptance criteria (prd.json)
33
37
  2. Iterating story-by-story until each one passes
34
38
  3. Tracking progress and learnings across iterations (progress.txt)
35
39
  4. Requiring fresh reviewer verification against specific acceptance criteria before completion
36
- </Why_This_Exists>
40
+ </Why_This_Exists>
37
41
 
38
42
  <PRD_Mode>
39
43
  By default, ralph operates in PRD mode. A scaffold `prd.json` is auto-generated when ralph starts if none exists. Active transient PRD state is session-scoped at `.omc/state/sessions/{sessionId}/prd.json` when a session ID is available; legacy project-level `prd.json` / `.omc/prd.json` files are read as startup migration inputs.
@@ -46,12 +50,14 @@ By default, ralph operates in PRD mode. A scaffold `prd.json` is auto-generated
46
50
  </PRD_Mode>
47
51
 
48
52
  <Execution_Policy>
53
+
49
54
  - Fire independent agent calls simultaneously -- never wait sequentially for independent work
50
55
  - Use `run_in_background: true` for long operations (installs, builds, test suites)
51
56
  - Always pass the `model` parameter explicitly when delegating to agents
52
57
  - Read `docs/shared/agent-tiers.md` before first delegation to select correct agent tiers
53
58
  - Deliver the full implementation: no scope reduction, no partial completion, no deleting tests to make them pass
54
- </Execution_Policy>
59
+ - If a Claude Code `/goal` is mentioned, treat it as a native session-loop handoff/evidence source only and use the deterministic conflict policies `refuse`, `adopt_existing`, and `artifact_only` rather than non-deterministic warning handling. Ralph remains the OMC loop authority for this run; do not claim `/goal` independently ran tests or read files, and do not treat evaluator success as a substitute for Ralph reviewer verification.
60
+ </Execution_Policy>
55
61
 
56
62
  <Steps>
57
63
  1. **PRD Setup** (first iteration only):
@@ -94,7 +100,7 @@ By default, ralph operates in PRD mode. A scaffold `prd.json` is auto-generated
94
100
  7. **Reviewer verification** (tiered, against acceptance criteria):
95
101
  - <5 files, <100 lines with full tests: STANDARD tier minimum (architect-medium / Sonnet)
96
102
  - Standard changes: STANDARD tier (architect-medium / Sonnet)
97
- - >20 files or security/architectural changes: THOROUGH tier (architect / Opus)
103
+ - > 20 files or security/architectural changes: THOROUGH tier (architect / Opus)
98
104
  - If `--critic=critic`, use the Claude `critic` agent for the approval pass
99
105
  - If `--critic=codex`, run `omc ask codex --agent-prompt critic "..."` for the approval pass. The Codex critic prompt MUST include:
100
106
  1. The full list of acceptance criteria from prd.json for verification
@@ -106,23 +112,26 @@ By default, ralph operates in PRD mode. A scaffold `prd.json` is auto-generated
106
112
  - **On APPROVAL: immediately proceed to Step 7.5 in the same turn. Do NOT pause to report the verdict to the user — reporting happens only at Step 8 (`/oh-my-claudecode:cancel`) or on rejection (Step 9). Treating an approved verdict as a reporting checkpoint is a polite-stop anti-pattern.**
107
113
 
108
114
  7.5 **Mandatory Deslop Pass** (runs unconditionally after Step 7 approval, unless `{{PROMPT}}` contains `--no-deslop`):
109
- - **Invoke the `ai-slop-cleaner` skill via the Skill tool: `Skill("ai-slop-cleaner")`.** Run in standard mode (not `--review`) on the files changed during the current Ralph session only.
110
- - **ai-slop-cleaner is a SKILL, not an agent.** Do NOT call it via `Task(subagent_type="oh-my-claudecode:ai-slop-cleaner")` — that subagent type does not exist and the call will fail with "Agent type not found". If you see that error, retry with the Skill tool — do NOT substitute a similarly-named agent like `code-simplifier` as a "closest match".
111
- - Keep the scope bounded to the Ralph changed-file set; do not broaden the cleanup pass to unrelated files.
112
- - If the reviewer approved the implementation but the deslop pass introduces follow-up edits, keep those edits inside the same changed-file scope before proceeding.
113
115
 
114
- 7.6 **Regression Re-verification**:
115
- - After the deslop pass, re-run all relevant tests, build, and lint checks for the Ralph session.
116
- - Read the output and confirm the post-deslop regression run actually passes.
117
- - If regression fails, roll back the cleaner changes or fix the regression, then rerun the verification loop until it passes.
118
- - Only proceed to completion after the post-deslop regression run passes (or `--no-deslop` was explicitly specified).
116
+ - **Invoke the `ai-slop-cleaner` skill via the Skill tool: `Skill("ai-slop-cleaner")`.** Run in standard mode (not `--review`) on the files changed during the current Ralph session only.
117
+ - **ai-slop-cleaner is a SKILL, not an agent.** Do NOT call it via `Task(subagent_type="oh-my-claudecode:ai-slop-cleaner")` that subagent type does not exist and the call will fail with "Agent type not found". If you see that error, retry with the Skill tool — do NOT substitute a similarly-named agent like `code-simplifier` as a "closest match".
118
+ - Keep the scope bounded to the Ralph changed-file set; do not broaden the cleanup pass to unrelated files.
119
+ - If the reviewer approved the implementation but the deslop pass introduces follow-up edits, keep those edits inside the same changed-file scope before proceeding.
120
+
121
+ 7.6 **Regression Re-verification**:
122
+
123
+ - After the deslop pass, re-run all relevant tests, build, and lint checks for the Ralph session.
124
+ - Read the output and confirm the post-deslop regression run actually passes.
125
+ - If regression fails, roll back the cleaner changes or fix the regression, then rerun the verification loop until it passes.
126
+ - Only proceed to completion after the post-deslop regression run passes (or `--no-deslop` was explicitly specified).
119
127
 
120
128
  8. **On approval**: After Step 7.6 passes (with Step 7.5 completed, or skipped via `--no-deslop`), run `/oh-my-claudecode:cancel` to cleanly exit and clean up all state files
121
129
 
122
130
  9. **On rejection**: Fix the issues raised, re-verify with the same reviewer, then loop back to check if the story needs to be marked incomplete
123
- </Steps>
131
+ </Steps>
124
132
 
125
133
  <Tool_Usage>
134
+
126
135
  - Use `Task(subagent_type="oh-my-claudecode:architect", ...)` for architect verification cross-checks when changes are security-sensitive, architectural, or involve complex multi-system integration
127
136
  - Use `Task(subagent_type="oh-my-claudecode:critic", ...)` when `--critic=critic`
128
137
  - Use `omc ask codex --agent-prompt critic "..."` when `--critic=codex`. Construct the prompt to include: (a) prd.json acceptance criteria, (b) files changed + related files, (c) explicit optimality question: "Is there a meaningfully simpler, faster, or more maintainable approach that achieves the same acceptance criteria?"
@@ -130,7 +139,7 @@ By default, ralph operates in PRD mode. A scaffold `prd.json` is auto-generated
130
139
  - Proceed with architect agent verification alone -- never block on unavailable tools
131
140
  - Use `state_write` / `state_read` for ralph mode state persistence between iterations
132
141
  - **Skill vs agent invocation**: `ai-slop-cleaner` is a skill, invoke via `Skill("ai-slop-cleaner")`. `architect`, `critic`, `executor` etc. are agents, invoke via `Task(subagent_type="oh-my-claudecode:<name>")`. If you ever get "Agent type ... not found" for an `oh-my-claudecode:<name>` identifier, the item is a skill — retry with the Skill tool. Do NOT substitute a similarly-named agent as a "closest match".
133
- </Tool_Usage>
142
+ </Tool_Usage>
134
143
 
135
144
  <Examples>
136
145
  <Good>
@@ -140,11 +149,12 @@ Auto-generated scaffold has:
140
149
  acceptanceCriteria: ["Implementation is complete", "Code compiles without errors"]
141
150
 
142
151
  After refinement:
143
- acceptanceCriteria: [
144
- "Legacy --no-prd text is stripped from the Ralph working prompt",
145
- "Ralph startup still creates or validates prd.json when legacy --no-prd text is present",
146
- "TypeScript compiles with no errors (npm run build)"
147
- ]
152
+ acceptanceCriteria: [
153
+ "Legacy --no-prd text is stripped from the Ralph working prompt",
154
+ "Ralph startup still creates or validates prd.json when legacy --no-prd text is present",
155
+ "TypeScript compiles with no errors (npm run build)"
156
+ ]
157
+
148
158
  ```
149
159
  Why good: Generic criteria replaced with specific, testable criteria.
150
160
  </Good>
@@ -152,9 +162,11 @@ Why good: Generic criteria replaced with specific, testable criteria.
152
162
  <Good>
153
163
  Correct parallel delegation:
154
164
  ```
165
+
155
166
  Task(subagent_type="oh-my-claudecode:executor", model="haiku", prompt="Add type export for UserConfig")
156
167
  Task(subagent_type="oh-my-claudecode:executor", model="sonnet", prompt="Implement the caching layer for API responses")
157
168
  Task(subagent_type="oh-my-claudecode:executor", model="opus", prompt="Refactor auth module to support OAuth2 flow")
169
+
158
170
  ```
159
171
  Why good: Three independent tasks fired simultaneously at appropriate tiers.
160
172
  </Good>
@@ -162,12 +174,14 @@ Why good: Three independent tasks fired simultaneously at appropriate tiers.
162
174
  <Good>
163
175
  Story-by-story verification:
164
176
  ```
177
+
165
178
  1. Story US-001: "Add flag detection helpers"
166
179
  - Criterion: "Legacy --no-prd is stripped from the working prompt" → Run test → PASS
167
180
  - Criterion: "TypeScript compiles" → Run build → PASS
168
181
  - Mark US-001 passes: true
169
182
  2. Story US-002: "Wire PRD into bridge.ts"
170
183
  - Continue to next story...
184
+
171
185
  ```
172
186
  Why good: Each story verified against its own acceptance criteria before marking complete.
173
187
  </Good>
@@ -181,9 +195,11 @@ Why bad: Uses "should" and "look good" -- no fresh evidence, no story-by-story v
181
195
  <Bad>
182
196
  Sequential execution of independent tasks:
183
197
  ```
198
+
184
199
  Task(executor, "Add type export") → wait →
185
200
  Task(executor, "Implement caching") → wait →
186
201
  Task(executor, "Refactor auth")
202
+
187
203
  ```
188
204
  Why bad: These are independent tasks that should run in parallel, not sequentially.
189
205
  </Bad>
@@ -219,6 +235,13 @@ Why bad: Did not refine scaffold criteria into task-specific ones. This is PRD t
219
235
  - [ ] `/oh-my-claudecode:cancel` run for clean state cleanup
220
236
  </Final_Checklist>
221
237
 
238
+ ## Parallel session caveats
239
+
240
+ - **Multi-repo workspace anchor:** drop a `.omc-workspace` marker at the parent directory so multiple sessions across sub-repos share one `.omc/`. Resolution order: `OMC_STATE_DIR > .omc-workspace > git > cwd`. See `docs/REFERENCE.md`.
241
+ - **Session id source:** OMC_SESSION_ID env var wins in CLI contexts; hook payload data.session_id wins in hook contexts.
242
+ - **Plan id (when applicable):** Two ralph runs in the same workspace will conflict on `prd.json`. Use distinct session IDs (the hook payload session_id is already isolated per Claude Code session). For parallel ultragoal-backed ralph runs, use `--plan-id`.
243
+ - **Parallel verdict:** supported (each session writes its own session-scoped state)
244
+
222
245
  <Advanced>
223
246
  ## Background Execution Rules
224
247
 
@@ -236,3 +259,4 @@ Why bad: Did not refine scaffold criteria into task-specific ones. This is PRD t
236
259
 
237
260
  Original task:
238
261
  {{PROMPT}}
262
+ ```
@@ -58,7 +58,7 @@ The consensus workflow:
58
58
  d. Return to Critic evaluation
59
59
  e. Repeat this loop until Critic returns `APPROVE` or 5 iterations are reached
60
60
  f. If 5 iterations are reached without `APPROVE`, present the best version to the user
61
- 6. On Critic approval, mark the plan `pending approval` unless explicit execution approval has already been captured. *(--interactive only)* If `--interactive` is set, use `AskUserQuestion` to present the plan with approval options (Approve execution via team (Recommended) / Approve execution via ralph / Approve execution after clearing context / Request changes / Reject). Final plan must include ADR (Decision, Drivers, Alternatives considered, Why chosen, Consequences, Follow-ups). Otherwise, output the final plan and stop before any mutation or delegation.
61
+ 6. On Critic approval, mark the plan `pending approval` unless explicit execution approval has already been captured. *(--interactive only)* If `--interactive` is set, use `AskUserQuestion` to present the plan with approval options (Approve execution via team (Recommended) / Approve execution via ralph / Compact then return for execution approval / Request changes / Reject). Final plan must include ADR (Decision, Drivers, Alternatives considered, Why chosen, Consequences, Follow-ups). Otherwise, output the final plan and stop before any mutation or delegation.
62
62
  7. *(--interactive only)* User chooses: Approve (team or ralph), Request changes, or Reject
63
63
  8. *(--interactive only)* On approval: invoke `Skill("oh-my-claudecode:team")` for parallel team execution (recommended) or `Skill("oh-my-claudecode:ralph")` for sequential execution -- never implement directly
64
64
 
@@ -375,6 +375,13 @@ When the loop exits:
375
375
 
376
376
  ---
377
377
 
378
+ ## Parallel session caveats
379
+
380
+ - **Multi-repo workspace anchor:** drop a `.omc-workspace` marker at the parent directory so multiple sessions across sub-repos share one `.omc/`. Resolution order: `OMC_STATE_DIR > .omc-workspace > git > cwd`. See `docs/REFERENCE.md`.
381
+ - **Session id source:** OMC_SESSION_ID env var wins in CLI contexts; hook payload data.session_id wins in hook contexts.
382
+ - **Plan id (when applicable):** Self-improve artifact dirs are topic-slug-scoped; for parallel runs with the same topic in the same workspace, expect Wave B2's session-id suffix to land.
383
+ - **Parallel verdict:** supported-with-caveats (topic-slug collision possible; see Wave B2)
384
+
378
385
  ## Approach Family Taxonomy
379
386
 
380
387
  Every plan must be tagged with exactly one:
@@ -2,9 +2,12 @@
2
2
 
3
3
  import { existsSync, mkdirSync } from 'node:fs';
4
4
  import { join, resolve } from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ import { resolveOmcStateRoot } from '../../../scripts/lib/state-root.mjs';
5
7
 
6
8
  const DEFAULT_TOPIC_SLUG = 'default';
7
9
  const TOPICS_DIR = 'topics';
10
+ const SESSIONS_DIR = 'sessions';
8
11
 
9
12
  function slugify(value) {
10
13
  const normalized = String(value ?? '')
@@ -24,6 +27,7 @@ function parseArgs(argv) {
24
27
  projectRoot: process.cwd(),
25
28
  topic: '',
26
29
  slug: '',
30
+ sessionId: '',
27
31
  format: 'json',
28
32
  ensureDirs: false,
29
33
  };
@@ -47,6 +51,11 @@ function parseArgs(argv) {
47
51
  index += 1;
48
52
  } else if (arg.startsWith('--slug=')) {
49
53
  result.slug = arg.slice('--slug='.length);
54
+ } else if (arg === '--session-id' && next) {
55
+ result.sessionId = next;
56
+ index += 1;
57
+ } else if (arg.startsWith('--session-id=')) {
58
+ result.sessionId = arg.slice('--session-id='.length);
50
59
  } else if (arg === '--format' && next) {
51
60
  result.format = next;
52
61
  index += 1;
@@ -73,13 +82,13 @@ function hasLegacyLayout(baseRoot) {
73
82
  || existsSync(join(baseRoot, 'state', 'agent-settings.json'));
74
83
  }
75
84
 
76
- function buildPaths(root, projectRoot, topicSlug, scopeMode) {
85
+ function buildPaths(root, projectRoot, topicSlug, scopeMode, baseRoot) {
77
86
  const configDir = join(root, 'config');
78
87
  const stateDir = join(root, 'state');
79
88
  const trackingDir = join(root, 'tracking');
80
89
  const paths = {
81
90
  project_root: projectRoot,
82
- base_root: join(projectRoot, '.omc', 'self-improve'),
91
+ base_root: baseRoot,
83
92
  topic_slug: topicSlug,
84
93
  scope_mode: scopeMode,
85
94
  root,
@@ -120,21 +129,36 @@ function ensureDirs(paths) {
120
129
  }
121
130
  }
122
131
 
123
- export function resolveSelfImprovePaths({ projectRoot = process.cwd(), topic = '', slug = '' } = {}) {
132
+ export async function resolveSelfImprovePaths({ projectRoot = process.cwd(), topic = '', slug = '', sessionId = '' } = {}) {
124
133
  const resolvedProjectRoot = resolve(projectRoot);
125
- const baseRoot = join(resolvedProjectRoot, '.omc', 'self-improve');
134
+ const omcRoot = await resolveOmcStateRoot(resolvedProjectRoot);
135
+ const baseRoot = join(omcRoot, 'self-improve');
126
136
  const explicitSlug = slugify(slug || topic);
127
137
  const legacyLayout = hasLegacyLayout(baseRoot);
128
138
  const shouldUseLegacyRoot = !slug && !topic && legacyLayout;
129
139
  const topicSlug = shouldUseLegacyRoot ? DEFAULT_TOPIC_SLUG : explicitSlug;
140
+
141
+ // When a sessionId is provided, scope beneath topics/<slug>/sessions/<sid>/
142
+ // so concurrent runs sharing the same topic slug don't collide.
143
+ // Falls back to OMC_SESSION_ID env var when explicit arg is absent.
144
+ // Legacy layout (no topic/slug supplied, flat .omc/self-improve/ exists) is
145
+ // preserved as-is — session scoping only applies to the topic-scoped layout.
146
+ const rawSessionId = sessionId && sessionId.trim()
147
+ ? sessionId.trim()
148
+ : (process.env.OMC_SESSION_ID && process.env.OMC_SESSION_ID.trim() ? process.env.OMC_SESSION_ID.trim() : '');
149
+ const effectiveSessionId = shouldUseLegacyRoot ? '' : rawSessionId;
130
150
  const root = shouldUseLegacyRoot
131
151
  ? baseRoot
132
- : join(baseRoot, TOPICS_DIR, topicSlug);
152
+ : effectiveSessionId
153
+ ? join(baseRoot, TOPICS_DIR, topicSlug, SESSIONS_DIR, effectiveSessionId)
154
+ : join(baseRoot, TOPICS_DIR, topicSlug);
133
155
  const scopeMode = shouldUseLegacyRoot
134
156
  ? 'legacy-flat-root'
135
- : (slug || topic ? 'topic-scoped' : 'default-scoped');
157
+ : effectiveSessionId
158
+ ? 'session-scoped'
159
+ : (slug || topic ? 'topic-scoped' : 'default-scoped');
136
160
 
137
- return buildPaths(root, resolvedProjectRoot, topicSlug, scopeMode);
161
+ return { ...buildPaths(root, resolvedProjectRoot, topicSlug, scopeMode, baseRoot), session_id: effectiveSessionId || null };
138
162
  }
139
163
 
140
164
  function renderShell(paths) {
@@ -146,27 +170,29 @@ function renderShell(paths) {
146
170
  function printHelp() {
147
171
  process.stdout.write(
148
172
  [
149
- 'Usage: node resolve-paths.mjs [--project-root PATH] [--topic TEXT | --slug SLUG] [--ensure-dirs] [--format json|shell]',
173
+ 'Usage: node resolve-paths.mjs [--project-root PATH] [--topic TEXT | --slug SLUG] [--session-id SID] [--ensure-dirs] [--format json|shell]',
150
174
  '',
151
175
  'Resolves self-improve artifact paths.',
152
176
  '- New runs default to .omc/self-improve/topics/<topic-slug>/',
177
+ '- Pass --session-id to isolate parallel runs: .omc/self-improve/topics/<slug>/sessions/<sid>/',
153
178
  '- Legacy flat .omc/self-improve/ is preserved only when no topic/slug is supplied and a flat layout already exists',
154
179
  '',
155
180
  ].join('\n'),
156
181
  );
157
182
  }
158
183
 
159
- function main() {
184
+ async function main() {
160
185
  const args = parseArgs(process.argv.slice(2));
161
186
  if (args.help) {
162
187
  printHelp();
163
188
  return;
164
189
  }
165
190
 
166
- const paths = resolveSelfImprovePaths({
191
+ const paths = await resolveSelfImprovePaths({
167
192
  projectRoot: args.projectRoot,
168
193
  topic: args.topic,
169
194
  slug: args.slug,
195
+ sessionId: args.sessionId,
170
196
  });
171
197
 
172
198
  if (args.ensureDirs) {
@@ -181,12 +207,10 @@ function main() {
181
207
  process.stdout.write(`${JSON.stringify(paths, null, 2)}\n`);
182
208
  }
183
209
 
184
- if (import.meta.url === `file://${process.argv[1]}`) {
185
- try {
186
- main();
187
- } catch (error) {
210
+ if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
211
+ main().catch((error) => {
188
212
  const message = error instanceof Error ? error.message : String(error);
189
213
  process.stderr.write(`${message}\n`);
190
214
  process.exit(1);
191
- }
215
+ });
192
216
  }