@kbediako/codex-orchestrator 0.1.35 → 0.1.36

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.
package/README.md CHANGED
@@ -51,6 +51,7 @@ Use this when you want Codex to drive work inside another repo with the CO defau
51
51
  ```bash
52
52
  codex-orchestrator init codex --codex-cli --yes
53
53
  ```
54
+ This seeds `AGENTS.md`, `mcp-client.json`, and downstream .codex/config.toml + .codex/agents/* role files (sourced from `templates/codex/.codex/*`), plus `codex.orchestrator.json`.
54
55
  2. Register the delegation MCP server (one-time per machine):
55
56
  ```bash
56
57
  codex mcp add delegation -- codex-orchestrator delegate-server --repo /path/to/repo
@@ -64,7 +65,13 @@ Use this when you want Codex to drive work inside another repo with the CO defau
64
65
  ```bash
65
66
  export CODEX_CLI_USE_MANAGED=1
66
67
  ```
67
- 4. Optional (fast refresh helper for downstream users):
68
+ 4. Optional (additive global defaults in `~/.codex/config.toml`):
69
+ ```bash
70
+ codex-orchestrator codex defaults
71
+ codex-orchestrator codex defaults --yes
72
+ ```
73
+ This updates only the CO baseline keys/role wiring and preserves unrelated config entries.
74
+ 5. Optional (fast refresh helper for downstream users):
68
75
  ```bash
69
76
  scripts/codex-cli-refresh.sh --repo /path/to/codex --align-only
70
77
  ```
@@ -87,55 +94,57 @@ codex -c 'mcp_servers.delegation.enabled=true' ...
87
94
 
88
95
  ## Agent role defaults (recommended)
89
96
 
90
- Codex built-ins are `default`, `explorer`, and `worker`. `researcher` is user-defined.
91
- - `spawn_agent` defaults to `default` when `agent_type` is omitted, so always set `agent_type` explicitly when using collab subagents.
97
+ Codex built-ins are `default`, `explorer`, `worker`, and `awaiter`. `researcher` is user-defined.
98
+ - `spawn_agent` defaults to `default` when `agent_type` is omitted, so always set `agent_type` explicitly.
99
+ - Multi-turn loops are supported (`spawn_agent` -> `send_input` -> `wait`/`resume_agent` -> `close_agent`), so subagents can iterate before parent synthesis.
92
100
 
93
- Built-in `explorer` in Codex currently uses `gpt-5.1-codex-mini` with `medium` reasoning unless you override it. If you want latest-codex defaults end-to-end, add role overrides in `~/.codex/config.toml`:
101
+ In Codex CLI `0.105.0`, built-in `explorer` no longer pins an older model profile; it inherits top-level defaults unless you attach a role `config_file`.
102
+ CO now ships this downstream starter config via `init codex` (source template: `templates/codex/.codex/config.toml`; installed as .codex/config.toml in target repos):
94
103
 
95
104
  ```toml
96
105
  model = "gpt-5.3-codex"
97
106
  model_reasoning_effort = "xhigh"
98
107
 
99
108
  [agents]
100
- max_threads = 8
101
-
102
- [agents.explorer]
103
- description = "Explorer role override (no config_file): keep built-in explorer on top-level model defaults."
109
+ max_threads = 12
110
+ max_depth = 4
111
+ max_spawn_depth = 4
104
112
 
105
113
  [agents.explorer_fast]
106
114
  description = "Fast explorer (spark text-only)."
107
- config_file = "/absolute/path/to/.codex/agents/explorer-fast.toml"
108
-
109
- [agents.explorer_detailed]
110
- description = "Detailed explorer."
111
- config_file = "/absolute/path/to/.codex/agents/explorer-detailed.toml"
115
+ config_file = "./agents/explorer-fast.toml"
112
116
 
113
117
  [agents.worker_complex]
114
118
  description = "Complex worker role."
115
- config_file = "/absolute/path/to/.codex/agents/worker-complex.toml"
119
+ config_file = "./agents/worker-complex.toml"
120
+
121
+ [agents.awaiter]
122
+ description = "Awaiter override (keeps awaiter behavior with latest codex/high reasoning)."
123
+ config_file = "./agents/awaiter-high.toml"
116
124
  ```
117
125
 
118
126
  ```toml
119
- # ~/.codex/agents/explorer-fast.toml
127
+ # .codex/agents/explorer-fast.toml
120
128
  model = "gpt-5.3-codex-spark"
121
129
  model_reasoning_effort = "xhigh"
122
130
  ```
123
131
 
124
132
  ```toml
125
- # ~/.codex/agents/explorer-detailed.toml
126
- model = "gpt-5.3-codex"
127
- model_reasoning_effort = "high"
128
- ```
129
-
130
- ```toml
131
- # ~/.codex/agents/worker-complex.toml
133
+ # .codex/agents/worker-complex.toml
132
134
  model = "gpt-5.3-codex"
133
135
  model_reasoning_effort = "xhigh"
134
136
  ```
135
137
 
138
+ `init codex` also writes downstream .codex/agents/awaiter-high.toml from `templates/codex/.codex/agents/awaiter-high.toml` so CO users can keep awaiter semantics while meeting a high-reasoning minimum.
139
+
136
140
  Caveats:
137
141
  - `gpt-5.3-codex-spark` is text-only (no image inputs). Keep it for fast search/synthesis.
138
- - Use `max_threads = 8` as a balanced default; only move to `12` after verifying your machine/tooling stays stable under higher concurrency.
142
+ - Leave `agents.explorer` undefined unless you intentionally want to override built-in explorer behavior.
143
+ - Keep RLM/collab built-ins-first by default; add specialist custom roles only when a measured benefit justifies ongoing maintenance.
144
+ - `max_threads = 12`, `max_depth = 4`, and `max_spawn_depth = 4` are CO's standard multi-agent baseline.
145
+ - Fallbacks are contingency-only: use `8/2/2` on constrained hosts or deterministic high-risk lanes; use `6/1/1` only as break-glass under severe contention.
146
+ - Awaiter triage: long waits are expected for long-running jobs; treat it as stuck only after multiple polling windows with no status/progress movement.
147
+ - `codex review` delegates with collab tools disabled in review threads; keep review expectations single-agent even when multi-agent is enabled elsewhere.
139
148
 
140
149
  Delegation guard profile:
141
150
  - `CODEX_ORCHESTRATOR_GUARD_PROFILE=auto` (default): strict in CO-style repos, warn in lightweight repos.
@@ -147,6 +156,7 @@ Delegation guard profile:
147
156
  RLM (Recursive Language Model) is the long-horizon loop used by the `rlm` pipeline (`codex-orchestrator rlm "<goal>"` or `codex-orchestrator start rlm --goal "<goal>"`). Delegated runs only enter RLM when the child is launched with the `rlm` pipeline (or the rlm runner directly). In auto mode it resolves to symbolic only when context is large (`RLM_SYMBOLIC_MIN_BYTES`) and an explicit context signal is present (`RLM_CONTEXT_PATH` or delegated run); otherwise it stays iterative. The runner writes state to `.runs/<task-id>/cli/<run-id>/rlm/state.json` and stops when the validator passes or budgets are exhausted.
148
157
  For symbolic mode, the Option 2 alignment checker is enabled by default (`RLM_ALIGNMENT_CHECKER=1`) and writes append-only alignment artifacts under `.runs/<task-id>/cli/<run-id>/rlm/alignment/` (ledger + projection). Rollback toggle: set `RLM_ALIGNMENT_CHECKER=0`. Enforcement is opt-in via `RLM_ALIGNMENT_CHECKER_ENFORCE=1`.
149
158
  Symbolic subcalls can optionally use collab tools. Fast path: `codex-orchestrator rlm --multi-agent auto "<goal>"` (legacy alias: `--collab auto`; sets `RLM_SYMBOLIC_MULTI_AGENT=1` plus legacy `RLM_SYMBOLIC_COLLAB=1` for compatibility, and implies symbolic mode). Collab requires `multi_agent=true` in `codex features list` (`collab` remains a legacy alias). Collab tool calls parsed from `codex exec --json --enable multi_agent` are stored in `manifest.collab_tool_calls` (bounded by `CODEX_ORCHESTRATOR_COLLAB_MAX_EVENTS`, set to `0` to disable). For auditable role routing, prefix spawned prompts with `[agent_type:<role>]` and set `spawn_agent.agent_type` when supported; lifecycle validation enforces prompt-role evidence and validates `agent_type` when present (`RLM_SYMBOLIC_MULTI_AGENT_ROLE_POLICY=warn|off`, legacy alias `RLM_COLLAB_ROLE_POLICY`; `RLM_SYMBOLIC_MULTI_AGENT_ALLOW_DEFAULT_ROLE=1`, legacy alias `RLM_COLLAB_ALLOW_DEFAULT_ROLE`). `codex-orchestrator codex setup` remains available when you want a managed/pinned CLI path (opt-in via `CODEX_CLI_USE_MANAGED=1`).
159
+ For batch fan-out jobs, prefer native `spawn_agents_on_csv` before building custom orchestration wrappers.
150
160
 
151
161
  ### Delegation flow
152
162
  ```mermaid
@@ -212,7 +222,9 @@ Bundled skills (may vary by release):
212
222
  - `docs-first`
213
223
  - `collab-evals`
214
224
  - `collab-deliberation`
225
+ - `long-poll-wait`
215
226
  - `release`
227
+ - `agent-first-adoption-steering`
216
228
  - `delegate-early` (compatibility alias; use `delegation-usage`)
217
229
 
218
230
  ## DevTools readiness
@@ -232,6 +244,7 @@ Usage snapshot (scans local `.runs/`):
232
244
  codex-orchestrator doctor --usage
233
245
  ```
234
246
  `doctor --usage` prints adoption KPIs (advanced/cloud/rlm/collab/delegation coverage), and per-run `run-summary.json` now includes a `usageKpi` section plus cloud fallback metadata when preflight downgrades to MCP.
247
+ `doctor` also includes a codex-defaults advisory section (model/reasoning/agent baseline drift) and points to additive remediation via `codex-orchestrator codex defaults --yes`.
235
248
 
236
249
  Issue bundle logging (downstream dogfooding / repro handoff):
237
250
  ```bash
@@ -257,8 +270,13 @@ codex-orchestrator doctor --cloud-preflight
257
270
  - Enable required MCP servers with least privilege: `codex-orchestrator mcp enable --servers delegation --yes` (plan with `--format json`; omit `--servers` only when you intentionally want all disabled servers enabled; env/secret values are redacted in displayed command lines)
258
271
  - Low-friction docs->implementation guardrails: `codex-orchestrator flow --task <task-id>`
259
272
  - Validate + measure adoption locally: `codex-orchestrator doctor --usage --format json`
273
+ - Run docs relevance as an advisory lane (non-blocking): `codex-orchestrator start docs-relevance-advisory --task <task-id>`
260
274
  - Capture reproducible downstream failures: `codex-orchestrator doctor --issue-log --issue-title "<title>" --issue-notes "<notes>"`
261
275
  - Auto-capture failed run issue bundles: `codex-orchestrator start <pipeline> --auto-issue-log` or `codex-orchestrator flow --auto-issue-log`
276
+ - Active PR watch-resolve-merge loop: `codex-orchestrator pr resolve-merge --pr <number> --quiet-minutes <window>` (add `--auto-merge` when approved; exits early when author action is required).
277
+ - Passive PR monitor loop: `codex-orchestrator pr watch-merge --pr <number> --quiet-minutes <window>` (monitor-only behavior; keeps waiting unless terminal/timeout).
278
+ - Review checkpoints (npm-only safe): `NOTES="Goal: ... | Summary: ... | Risks: ..." codex-orchestrator review --task <task-id>` for manifest-backed standalone review wrapper behavior (auto-skips repo-only diff-budget script when unavailable in downstream installs); use `codex review "<focus>"` for quick prompt-only checks; use `codex-orchestrator start implementation-gate --task <task-id> --format json` when you want a full gate run.
279
+ - Downstream simulation before shipping wrapper/skill changes: `npm run pack:smoke` (packaged CLI in temp mock repo; validates `review` artifacts and `long-poll-wait` install path).
262
280
  - Delegation: `codex-orchestrator doctor --apply --yes`, then enable for a Codex run with: `codex -c 'mcp_servers.delegation.enabled=true' ...`
263
281
  - Collab (symbolic RLM subagents): `codex-orchestrator rlm --multi-agent auto "<goal>"` (legacy alias: `--collab auto`; requires Codex `features.multi_agent=true`)
264
282
  - Cloud: set `CODEX_CLOUD_ENV_ID` (and optional `CODEX_CLOUD_BRANCH`), then run: `codex-orchestrator start <pipeline> --cloud --target <stage-id>`
@@ -275,17 +293,21 @@ codex-orchestrator devtools setup
275
293
 
276
294
  - `codex-orchestrator start <pipeline>` — run a pipeline (add `--auto-issue-log` for automatic failure bundle capture; add `--repo-config-required` for strict repo-local config mode).
277
295
  - `codex-orchestrator flow --task <task-id>` — run `docs-review` then `implementation-gate` in sequence (supports `--auto-issue-log` and `--repo-config-required`).
296
+ - `codex-orchestrator start docs-relevance-advisory --task <task-id>` — run non-blocking docs relevance signals (warn-mode freshness + advisory review lane).
297
+ - `NOTES="Goal: ... | Summary: ... | Risks: ..." codex-orchestrator review --task <task-id>` — run standalone review wrapper with manifest-backed evidence (supports run-review flags/env).
278
298
  - `codex-orchestrator plan <pipeline>` — preview pipeline stages.
279
299
  - `codex-orchestrator exec <cmd>` — run a one-off command with the exec runtime.
280
- - `codex-orchestrator init codex` — install starter templates (`mcp-client.json`, `AGENTS.md`, `codex.orchestrator.json`) into a repo.
300
+ - `codex-orchestrator init codex` — install starter templates (`mcp-client.json`, `AGENTS.md`, downstream .codex/config.toml + .codex/agents/* role files sourced from `templates/codex/.codex/*`, `codex.orchestrator.json`) into a repo.
281
301
  - `codex-orchestrator setup --yes` — install bundled skills and configure delegation + DevTools wiring (add `--refresh-skills` to overwrite existing skills in `$CODEX_HOME/skills`).
282
302
  - `codex-orchestrator init codex --codex-cli --yes --codex-source <path>` — optionally provision a CO-managed Codex CLI binary (build-from-source default; set `CODEX_CLI_SOURCE` to avoid passing `--codex-source` every time, and `CODEX_CLI_USE_MANAGED=1` to route runs to it).
283
303
  - `codex-orchestrator init codex --codex-cli --yes --codex-download-url <url> --codex-download-sha256 <sha>` — opt-in to a prebuilt Codex CLI download.
284
304
  - `codex-orchestrator codex setup` — plan/apply a CO-managed Codex CLI install (optional managed/pinned path; use `--download-url` + `--download-sha256` for prebuilts; activate with `CODEX_CLI_USE_MANAGED=1`).
305
+ - `codex-orchestrator codex defaults` — plan/apply additive global defaults in `~/.codex/config.toml` and `~/.codex/agents/*.toml` (`--yes` applies, `--force` allows role file overwrite).
285
306
  - `codex-orchestrator delegation setup --yes` — configure delegation MCP server wiring.
286
307
  - `codex-orchestrator mcp enable --servers <csv> --yes` — enable specific disabled MCP servers from existing Codex config entries.
287
308
  - `codex-orchestrator self-check --format json` — JSON health payload.
288
309
  - `codex-orchestrator mcp serve` — Codex MCP stdio server.
310
+ - `npm run pack:smoke` — maintainer smoke gate for packaged downstream behavior (tarball install + review/skill checks).
289
311
 
290
312
  ## What ships in the npm release
291
313
 
@@ -302,7 +324,8 @@ Repo internals, development workflows, and deeper architecture notes (contributo
302
324
  - `docs/guides/collab-vs-mcp.md` (agent-first decision guide)
303
325
  - `docs/guides/rlm-recursion-v2.md` (RLM recursion reference)
304
326
  - `docs/guides/cloud-mode-preflight.md` (cloud-mode preflight + fallback guidance)
305
- - `docs/guides/review-artifacts.md` (where `npm run review` writes prompt/output artifacts)
327
+ - `docs/guides/review-artifacts.md` (where `codex-orchestrator review` / `npm run review` write prompt/output artifacts)
328
+ - `docs/standalone-review-guide.md` (repo-local wrapper behavior + downstream-safe review alternatives)
306
329
 
307
330
  ## RLM benchmark graphs
308
331
 
@@ -50,6 +50,29 @@
50
50
  "command": "npm run docs:freshness"
51
51
  }
52
52
  ],
53
+ "docs-relevance-advisory-checks": [
54
+ {
55
+ "kind": "command",
56
+ "id": "docs-freshness-advisory",
57
+ "title": "npm run docs:freshness -- --warn",
58
+ "command": "npm run docs:freshness -- --warn",
59
+ "allowFailure": true,
60
+ "summaryHint": "Advisory docs-freshness signal (non-blocking)"
61
+ },
62
+ {
63
+ "kind": "command",
64
+ "id": "docs-relevance-review",
65
+ "title": "npm run review (docs relevance advisory)",
66
+ "command": "npm run review",
67
+ "env": {
68
+ "SKIP_DIFF_BUDGET": "1",
69
+ "CODEX_REVIEW_NON_INTERACTIVE": "1",
70
+ "NOTES": "Goal: docs relevance advisory | Summary: semantic docs relevance review lane with manifest context | Risks: advisory-only lane; false positives/negatives possible"
71
+ },
72
+ "allowFailure": true,
73
+ "summaryHint": "Agent-first docs relevance advisory review"
74
+ }
75
+ ],
53
76
  "design-artifacts": [
54
77
  {
55
78
  "kind": "command",
@@ -190,6 +213,22 @@
190
213
  }
191
214
  ]
192
215
  },
216
+ {
217
+ "id": "docs-relevance-advisory",
218
+ "title": "Docs Relevance Advisory",
219
+ "description": "Runs a non-blocking docs relevance signal lane (warn-mode freshness + advisory review).",
220
+ "tags": [
221
+ "docs",
222
+ "advisory"
223
+ ],
224
+ "guardrailsRequired": false,
225
+ "stages": [
226
+ {
227
+ "kind": "stage-set",
228
+ "ref": "docs-relevance-advisory-checks"
229
+ }
230
+ ]
231
+ },
193
232
  {
194
233
  "id": "frontend-testing",
195
234
  "title": "Frontend Testing",
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
2
3
  import { existsSync } from 'node:fs';
3
4
  import { opendir, readFile } from 'node:fs/promises';
4
5
  import { basename, join } from 'node:path';
5
6
  import process from 'node:process';
7
+ import { fileURLToPath } from 'node:url';
6
8
  import { CodexOrchestrator } from '../orchestrator/src/cli/orchestrator.js';
7
9
  import { formatPlanPreview } from '../orchestrator/src/cli/utils/planFormatter.js';
8
10
  import { executeExecCommand } from '../orchestrator/src/cli/exec/command.js';
@@ -18,9 +20,10 @@ import { formatDoctorUsageSummary, runDoctorUsage } from '../orchestrator/src/cl
18
20
  import { formatDoctorIssueLogSummary, writeDoctorIssueLog } from '../orchestrator/src/cli/doctorIssueLog.js';
19
21
  import { formatDevtoolsSetupSummary, runDevtoolsSetup } from '../orchestrator/src/cli/devtoolsSetup.js';
20
22
  import { formatCodexCliSetupSummary, runCodexCliSetup } from '../orchestrator/src/cli/codexCliSetup.js';
23
+ import { formatCodexDefaultsSetupSummary, runCodexDefaultsSetup } from '../orchestrator/src/cli/codexDefaultsSetup.js';
21
24
  import { formatDelegationSetupSummary, runDelegationSetup } from '../orchestrator/src/cli/delegationSetup.js';
22
25
  import { formatSkillsInstallSummary, installSkills, listBundledSkills } from '../orchestrator/src/cli/skills.js';
23
- import { loadPackageInfo } from '../orchestrator/src/cli/utils/packageInfo.js';
26
+ import { findPackageRoot, loadPackageInfo } from '../orchestrator/src/cli/utils/packageInfo.js';
24
27
  import { slugify } from '../orchestrator/src/cli/utils/strings.js';
25
28
  import { serveMcp } from '../orchestrator/src/cli/mcp.js';
26
29
  import { formatMcpEnableSummary, runMcpEnable } from '../orchestrator/src/cli/mcpEnable.js';
@@ -52,6 +55,9 @@ async function main() {
52
55
  case 'flow':
53
56
  await handleFlow(orchestrator, args);
54
57
  break;
58
+ case 'review':
59
+ await handleReview(args);
60
+ break;
55
61
  case 'plan':
56
62
  await handlePlan(orchestrator, args);
57
63
  break;
@@ -795,6 +801,65 @@ async function handleFlow(orchestrator, rawArgs) {
795
801
  throw withAutoIssueLogContext(error, issueLogCapture);
796
802
  }
797
803
  }
804
+ function runningFromSourceRuntime() {
805
+ return fileURLToPath(import.meta.url).endsWith('.ts');
806
+ }
807
+ function resolveReviewRunner() {
808
+ const packageRoot = findPackageRoot(import.meta.url);
809
+ const sourceRunner = join(packageRoot, 'scripts', 'run-review.ts');
810
+ const distRunner = join(packageRoot, 'dist', 'scripts', 'run-review.js');
811
+ if (runningFromSourceRuntime() && existsSync(sourceRunner)) {
812
+ return {
813
+ command: process.execPath,
814
+ args: ['--loader', 'ts-node/esm', sourceRunner]
815
+ };
816
+ }
817
+ if (existsSync(distRunner)) {
818
+ return {
819
+ command: process.execPath,
820
+ args: [distRunner]
821
+ };
822
+ }
823
+ if (existsSync(sourceRunner)) {
824
+ return {
825
+ command: process.execPath,
826
+ args: ['--loader', 'ts-node/esm', sourceRunner]
827
+ };
828
+ }
829
+ throw new Error('Unable to locate review runner. Expected dist/scripts/run-review.js (npm) or scripts/run-review.ts (source checkout).');
830
+ }
831
+ async function runPassthroughCommand(command, args, options = {}) {
832
+ return await new Promise((resolve, reject) => {
833
+ const child = spawn(command, args, {
834
+ env: options.env ?? process.env,
835
+ cwd: options.cwd ?? process.cwd(),
836
+ stdio: 'inherit'
837
+ });
838
+ child.once('error', (error) => reject(error instanceof Error ? error : new Error(String(error))));
839
+ child.once('close', (code, signal) => {
840
+ if (signal) {
841
+ resolve(1);
842
+ return;
843
+ }
844
+ resolve(typeof code === 'number' ? code : 1);
845
+ });
846
+ });
847
+ }
848
+ async function handleReview(rawArgs) {
849
+ const { positionals, flags } = parseArgs(rawArgs);
850
+ if (isHelpRequest(positionals, flags)) {
851
+ printReviewHelp();
852
+ return;
853
+ }
854
+ const runner = resolveReviewRunner();
855
+ const exitCode = await runPassthroughCommand(runner.command, [...runner.args, ...rawArgs], {
856
+ cwd: process.cwd(),
857
+ env: process.env
858
+ });
859
+ if (exitCode !== 0) {
860
+ process.exitCode = exitCode;
861
+ }
862
+ }
798
863
  async function handlePlan(orchestrator, rawArgs) {
799
864
  const { positionals, flags } = parseArgs(rawArgs);
800
865
  if (isHelpRequest(positionals, flags)) {
@@ -1243,6 +1308,7 @@ function buildSetupGuidance() {
1243
1308
  'codex-orchestrator flow --task <task-id>',
1244
1309
  'codex-orchestrator doctor --usage',
1245
1310
  'codex-orchestrator rlm --multi-agent auto "<goal>"',
1311
+ 'codex-orchestrator codex defaults --yes',
1246
1312
  'codex-orchestrator mcp enable --servers delegation --yes'
1247
1313
  ]
1248
1314
  };
@@ -1460,35 +1526,55 @@ async function handleDelegation(rawArgs) {
1460
1526
  async function handleCodex(rawArgs) {
1461
1527
  const { positionals, flags } = parseArgs(rawArgs);
1462
1528
  const subcommand = positionals.shift();
1463
- if (!subcommand) {
1464
- throw new Error('codex requires a subcommand (setup).');
1465
- }
1466
- if (subcommand !== 'setup') {
1467
- throw new Error(`Unknown codex subcommand: ${subcommand}`);
1529
+ if (flags['help'] === true || flags['--help'] === true || flags['h'] === true || !subcommand || subcommand === 'help' || subcommand === '--help' || subcommand === '-h') {
1530
+ printCodexHelp();
1531
+ return;
1468
1532
  }
1469
- const format = flags['format'] === 'json' ? 'json' : 'text';
1470
- const apply = Boolean(flags['yes']);
1471
- const source = readStringFlag(flags, 'source');
1472
- const ref = readStringFlag(flags, 'ref');
1473
- const downloadUrl = readStringFlag(flags, 'download-url');
1474
- const downloadSha256 = readStringFlag(flags, 'download-sha256');
1475
- const force = Boolean(flags['force']);
1476
- const result = await runCodexCliSetup({
1477
- apply,
1478
- force,
1479
- source,
1480
- ref,
1481
- downloadUrl,
1482
- downloadSha256
1483
- });
1484
- if (format === 'json') {
1485
- console.log(JSON.stringify(result, null, 2));
1533
+ if (subcommand === 'setup') {
1534
+ const format = flags['format'] === 'json' ? 'json' : 'text';
1535
+ const apply = Boolean(flags['yes']);
1536
+ const source = readStringFlag(flags, 'source');
1537
+ const ref = readStringFlag(flags, 'ref');
1538
+ const downloadUrl = readStringFlag(flags, 'download-url');
1539
+ const downloadSha256 = readStringFlag(flags, 'download-sha256');
1540
+ const force = Boolean(flags['force']);
1541
+ const result = await runCodexCliSetup({
1542
+ apply,
1543
+ force,
1544
+ source,
1545
+ ref,
1546
+ downloadUrl,
1547
+ downloadSha256
1548
+ });
1549
+ if (format === 'json') {
1550
+ console.log(JSON.stringify(result, null, 2));
1551
+ return;
1552
+ }
1553
+ const summary = formatCodexCliSetupSummary(result);
1554
+ for (const line of summary) {
1555
+ console.log(line);
1556
+ }
1486
1557
  return;
1487
1558
  }
1488
- const summary = formatCodexCliSetupSummary(result);
1489
- for (const line of summary) {
1490
- console.log(line);
1559
+ if (subcommand === 'defaults') {
1560
+ const format = flags['format'] === 'json' ? 'json' : 'text';
1561
+ const apply = Boolean(flags['yes']);
1562
+ const force = Boolean(flags['force']);
1563
+ const result = await runCodexDefaultsSetup({
1564
+ apply,
1565
+ force
1566
+ });
1567
+ if (format === 'json') {
1568
+ console.log(JSON.stringify(result, null, 2));
1569
+ return;
1570
+ }
1571
+ const summary = formatCodexDefaultsSetupSummary(result);
1572
+ for (const line of summary) {
1573
+ console.log(line);
1574
+ }
1575
+ return;
1491
1576
  }
1577
+ throw new Error(`Unknown codex subcommand: ${subcommand}`);
1492
1578
  }
1493
1579
  async function handleSkills(rawArgs) {
1494
1580
  const { positionals, flags } = parseArgs(rawArgs);
@@ -1668,10 +1754,20 @@ async function handlePr(rawArgs) {
1668
1754
  return;
1669
1755
  }
1670
1756
  const [subcommand, ...subcommandArgs] = rawArgs;
1671
- if (subcommand !== 'watch-merge') {
1757
+ const modeBySubcommand = {
1758
+ 'watch-merge': {
1759
+ usage: 'codex-orchestrator pr watch-merge'
1760
+ },
1761
+ 'resolve-merge': {
1762
+ usage: 'codex-orchestrator pr resolve-merge',
1763
+ defaultExitOnActionRequired: true
1764
+ }
1765
+ };
1766
+ const mode = modeBySubcommand[subcommand];
1767
+ if (!mode) {
1672
1768
  throw new Error(`Unknown pr subcommand: ${subcommand}`);
1673
1769
  }
1674
- const exitCode = await runPrWatchMerge(subcommandArgs, { usage: 'codex-orchestrator pr watch-merge' });
1770
+ const exitCode = await runPrWatchMerge(subcommandArgs, mode);
1675
1771
  if (exitCode !== 0) {
1676
1772
  process.exitCode = exitCode;
1677
1773
  }
@@ -1953,6 +2049,18 @@ Commands:
1953
2049
  --interactive | --ui Enable read-only HUD when running in a TTY.
1954
2050
  --no-interactive Force disable HUD (default is off unless requested).
1955
2051
 
2052
+ review [options] Run manifest-backed standalone review wrapper.
2053
+ Forwards flags/env to scripts/run-review (source) or dist/scripts/run-review.js (npm).
2054
+ Common flags:
2055
+ --manifest <path> Explicit manifest path for review evidence.
2056
+ --task <id> Task id used for prompt context.
2057
+ --uncommitted Review uncommitted diff scope.
2058
+ --base <branch> Review against base branch.
2059
+ --commit <sha> Review specific commit.
2060
+ --non-interactive Force non-interactive review behavior.
2061
+ --auto-issue-log [true|false] Auto-capture issue bundle on review failure.
2062
+ --disable-delegation-mcp [true|false] Disable delegation MCP for this review.
2063
+
1956
2064
  plan [pipeline] Preview pipeline stages without executing.
1957
2065
  --task <id> Override task identifier.
1958
2066
  --format json Emit machine-readable output.
@@ -1981,7 +2089,7 @@ Commands:
1981
2089
 
1982
2090
  self-check [--format json]
1983
2091
  init codex [--cwd <path>] [--force]
1984
- Installs AGENTS.md, mcp-client.json, and codex.orchestrator.json.
2092
+ Installs AGENTS.md, mcp-client.json, .codex/config.toml (+ role files), and codex.orchestrator.json.
1985
2093
  --codex-cli Also run CO-managed Codex CLI setup (plan unless --yes; activate with CODEX_CLI_USE_MANAGED=1).
1986
2094
  --codex-source <path> Build from local Codex repo (or git URL).
1987
2095
  --codex-ref <ref> Git ref (branch/tag/sha) when building from repo.
@@ -2016,6 +2124,10 @@ Commands:
2016
2124
  --force Overwrite existing CO-managed codex binary.
2017
2125
  --yes Apply setup (otherwise plan only; stock codex remains default until CODEX_CLI_USE_MANAGED=1).
2018
2126
  --format json Emit machine-readable output.
2127
+ codex defaults
2128
+ --yes Apply setup (otherwise dry-run plan only).
2129
+ --force Allow overwriting existing role files in ~/.codex/agents.
2130
+ --format json Emit machine-readable output.
2019
2131
  devtools setup Print DevTools MCP setup instructions.
2020
2132
  --yes Apply setup by running "codex mcp add ...".
2021
2133
  --format json Emit machine-readable output (dry-run only).
@@ -2036,6 +2148,9 @@ Commands:
2036
2148
  pr watch-merge [options]
2037
2149
  Monitor PR checks/reviews with polling and optional auto-merge after a quiet window.
2038
2150
  Use \`codex-orchestrator pr watch-merge --help\` for full options.
2151
+ pr resolve-merge [options]
2152
+ Monitor until merge-ready or actionable feedback appears; exits early when author action is required.
2153
+ Use \`codex-orchestrator pr resolve-merge --help\` for full options.
2039
2154
  delegate-server Run the delegation MCP server (stdio).
2040
2155
  --repo <path> Repo root for config + manifests (default cwd).
2041
2156
  --mode <full|question_only> Limit tool surface for child runs.
@@ -2046,6 +2161,7 @@ Commands:
2046
2161
 
2047
2162
  Quickstart (agent-first):
2048
2163
  codex-orchestrator flow --task <task-id>
2164
+ NOTES="Goal: ... | Summary: ... | Risks: ..." codex-orchestrator review --task <task-id>
2049
2165
  codex-orchestrator doctor --usage --window-days 30
2050
2166
  codex-orchestrator rlm --multi-agent auto "<goal>"
2051
2167
  codex-orchestrator start implementation-gate --cloud --target <stage-id>
@@ -2072,6 +2188,25 @@ Commands:
2072
2188
  --format json Emit machine-readable output.
2073
2189
  `);
2074
2190
  }
2191
+ function printCodexHelp() {
2192
+ console.log(`Usage: codex-orchestrator codex <subcommand> [options]
2193
+
2194
+ Subcommands:
2195
+ setup Plan/apply CO-managed Codex CLI install.
2196
+ --source <path> Build from local Codex repo (or git URL).
2197
+ --ref <ref> Git ref (branch/tag/sha) when building from repo.
2198
+ --download-url <url> Download a prebuilt codex binary.
2199
+ --download-sha256 <sha> Expected SHA256 for the prebuilt download.
2200
+ --force Overwrite existing CO-managed codex binary.
2201
+ --yes Apply setup (otherwise plan only).
2202
+ --format json Emit machine-readable output.
2203
+
2204
+ defaults Plan/apply additive global Codex defaults in ~/.codex/config.toml.
2205
+ --yes Apply setup (otherwise dry-run plan only).
2206
+ --force Overwrite existing role files in ~/.codex/agents.
2207
+ --format json Emit machine-readable output.
2208
+ `);
2209
+ }
2075
2210
  function printStatusHelp() {
2076
2211
  console.log(`Usage: codex-orchestrator status --run <id> [--watch] [--interval N] [--format json]
2077
2212
 
@@ -2127,10 +2262,14 @@ function printPrHelp() {
2127
2262
  Subcommands:
2128
2263
  watch-merge Monitor PR checks/reviews with polling and optional auto-merge.
2129
2264
  Supports PR_MONITOR_* env vars and standard flags (see: pr watch-merge --help).
2265
+ resolve-merge Watch for merge readiness but exit early on actionable feedback requiring author response.
2266
+ Inherits watch-merge flags; defaults exit-on-action-required to on.
2130
2267
 
2131
2268
  Examples:
2132
2269
  codex-orchestrator pr watch-merge --pr 211 --dry-run --quiet-minutes 10
2133
2270
  codex-orchestrator pr watch-merge --pr 211 --auto-merge --merge-method squash
2271
+ codex-orchestrator pr resolve-merge --pr 211 --quiet-minutes 15
2272
+ codex-orchestrator pr resolve-merge --pr 211 --auto-merge --quiet-minutes 10
2134
2273
 
2135
2274
  Guide:
2136
2275
  Review artifacts (prompt + output log paths): docs/guides/review-artifacts.md
@@ -2190,6 +2329,38 @@ Post-run check:
2190
2329
  codex-orchestrator doctor --usage --window-days 30 --task <task-id>
2191
2330
  `);
2192
2331
  }
2332
+ function printReviewHelp() {
2333
+ console.log(`Usage: codex-orchestrator review [options]
2334
+
2335
+ Runs the standalone review wrapper with manifest-backed evidence.
2336
+ This command forwards arguments/environment to run-review and preserves its behavior.
2337
+
2338
+ Common options:
2339
+ --manifest <path> Explicit manifest path for review evidence.
2340
+ --runs-dir <path> Root runs directory when auto-resolving manifest.
2341
+ --task <id> Task id used for prompt context.
2342
+ --uncommitted Review uncommitted diff scope.
2343
+ --base <branch> Review against a base branch.
2344
+ --commit <sha> Review a specific commit.
2345
+ --title "<text>" Optional review title in the prompt.
2346
+ --non-interactive Force non-interactive behavior.
2347
+ --auto-issue-log [true|false] Auto-capture issue bundle on review failure.
2348
+ --disable-delegation-mcp [true|false] Disable delegation MCP for this review.
2349
+ --enable-delegation-mcp [true|false] Legacy delegation MCP toggle (disable via false).
2350
+
2351
+ Environment controls (selected):
2352
+ NOTES Recommended review notes ("Goal | Summary | Risks ..."); fallback notes are generated when omitted.
2353
+ CODEX_REVIEW_ALLOW_HEAVY_COMMANDS=1 Allow unrestricted heavy commands.
2354
+ CODEX_REVIEW_ENFORCE_BOUNDED_MODE=1 Enforce bounded mode (hard-stop heavy commands).
2355
+ CODEX_REVIEW_TIMEOUT_SECONDS Optional overall timeout (0 disables when set).
2356
+ CODEX_REVIEW_STALL_TIMEOUT_SECONDS Optional stall timeout (0 disables when set).
2357
+ CODEX_REVIEW_MONITOR_INTERVAL_SECONDS Patience checkpoint cadence (0 disables).
2358
+
2359
+ Examples:
2360
+ TASK=<task-id> NOTES="Goal: ... | Summary: ... | Risks: ..." codex-orchestrator review
2361
+ TASK=<task-id> NOTES="Goal: ... | Summary: ... | Risks: ..." codex-orchestrator review --manifest .runs/<task-id>/cli/<run-id>/manifest.json
2362
+ `);
2363
+ }
2193
2364
  function printStartHelp() {
2194
2365
  console.log(`Usage: codex-orchestrator start [pipeline] [options]
2195
2366
 
@@ -2241,6 +2412,7 @@ function printInitHelp() {
2241
2412
  Install starter templates into the target repository:
2242
2413
  - AGENTS.md
2243
2414
  - mcp-client.json
2415
+ - .codex/config.toml (+ .codex/agents/* role files)
2244
2416
  - codex.orchestrator.json
2245
2417
 
2246
2418
  Options: