@sabaiway/agent-workflow-kit 1.6.0 → 1.8.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.
@@ -0,0 +1,65 @@
1
+ # Setting up Antigravity CLI (`agy`) on a clean machine
2
+
3
+ This setup is **secret-free**. `agy` itself is **not** bundled — it requires a binary install and a
4
+ one-time interactive sign-in with your own subscription. Do this once per machine, then the skill
5
+ works in any project.
6
+
7
+ ## 1. Install the binary
8
+
9
+ ```bash
10
+ curl -fsSL https://antigravity.google/cli/install.sh | bash
11
+ export PATH="$HOME/.local/bin:$PATH" # add to ~/.bashrc / ~/.zshrc to persist
12
+ agy --version # expect 1.0.10 or newer
13
+ ```
14
+
15
+ - The binary is **`agy`** (not `antigravity`); it installs to `~/.local/bin/agy`.
16
+ - Keep `$HOME/.local/bin` on `PATH` (the wrapper also prepends it defensively).
17
+
18
+ ## 2. Sign in once (subscription only)
19
+
20
+ Run `agy` once interactively and complete the **OAuth** sign-in with a **Google AI Pro/Ultra**
21
+ account:
22
+
23
+ ```bash
24
+ agy
25
+ ```
26
+
27
+ This caches an OAuth token under `~/.gemini/antigravity-cli/` (`antigravity-oauth-token`). That token
28
+ is **personal** — never copy, commit, package, print, or share that directory or token. This skill
29
+ needs no API keys and must not be configured with API-key billing; the wrapper unsets every
30
+ `*_API_KEY` so billing can never silently fall back to pay-as-you-go.
31
+
32
+ ## 3. Put the wrapper on `PATH` as `agy-run`
33
+
34
+ The skill ships the wrapper at `bin/agy.sh`. Expose it on `PATH` under the stable name `agy-run`
35
+ (idempotent; refuses to clobber a non-symlink):
36
+
37
+ ```bash
38
+ mkdir -p "$HOME/.local/bin"
39
+ skill_dir="$HOME/.claude/skills/antigravity-cli-bridge" # adjust if installed elsewhere
40
+ dst="$HOME/.local/bin/agy-run"
41
+ if [ -e "$dst" ] && [ ! -L "$dst" ]; then
42
+ echo "STOP: $dst exists and is not a symlink"; exit 1
43
+ fi
44
+ chmod +x "$skill_dir/bin/agy.sh"
45
+ ln -sfn "$skill_dir/bin/agy.sh" "$dst"
46
+ export PATH="$HOME/.local/bin:$PATH"
47
+ command -v agy-run
48
+ ```
49
+
50
+ ## 4. Smoke test
51
+
52
+ ```bash
53
+ agy --version
54
+ echo "say OK" | agy-run -
55
+ ```
56
+
57
+ Expected: the version prints (`1.0.10` or newer), then a short reply containing `OK`. If `agy-run`
58
+ reports `'agy' not found`, fix your `PATH` (step 1). If it asks you to sign in, complete step 2.
59
+
60
+ ## Notes
61
+
62
+ - `agy-run` is headless and plain-text only; there is no JSON output mode.
63
+ - `AGY_MODEL` selects the exact model display string; `AGY_TIMEOUT` controls `--print-timeout`.
64
+ - Extra `agy` flags go after `--`, e.g. `agy-run @prompt.md -- --add-dir .`.
65
+ - Re-run interactive `agy` only when the OAuth token expires or the account changes.
@@ -0,0 +1,148 @@
1
+ ---
2
+ name: codex-cli-bridge
3
+ description: Delegate work to the OpenAI Codex CLI (`codex`) under a ChatGPT subscription — run plan/instruction EXECUTION in a sandboxed workspace, or get a read-only ADVISORY review of a plan or working-tree diff — as a second delegated-execution backend beside Antigravity. Use when the user wants to hand a bounded coding task or plan to `codex exec`, get a second-opinion review from codex, install or authenticate Codex CLI, understand its sandbox/network/approval policy, drive codex efficiently from the main agent (exec vs review, resume, the commit boundary), bridge project context (`AGENTS.md`) into codex, or troubleshoot codex flags, models, auth, or its no-TTY headless behaviour.
4
+ metadata:
5
+ version: '1.0.0'
6
+ ---
7
+
8
+ # codex-cli-bridge
9
+
10
+ Bridges the main agent to the **OpenAI Codex CLI** (`codex`) as a **delegated-execution backend**
11
+ beside Antigravity. The main agent stays the orchestrator — owning decisions, the edits it accepts,
12
+ verification, and user-facing claims — and hands `codex` a bounded sub-task answered from a **ChatGPT
13
+ subscription** (no pay-as-you-go billing). Codex has two roles here: a **sandboxed executor** that
14
+ edits a repo under a fixed policy (`codex-exec`), and a **read-only reviewer** that critiques a plan
15
+ or a working-tree diff and only emits findings (`codex-review`).
16
+
17
+ ## Overview / when to use
18
+
19
+ Use this skill when the user wants to:
20
+
21
+ - Delegate plan or instruction EXECUTION to `codex` in a workspace-write sandbox (network OFF).
22
+ - Get a second-opinion ADVISORY review of an implementation plan or the current diff.
23
+ - Install, authenticate, smoke-test, or troubleshoot `codex`, or understand its sandbox/flags/models.
24
+ - Drive codex efficiently from the main agent (exec vs review, `resume`, the commit boundary).
25
+
26
+ Do **not** use it to bundle secrets, bypass subscription auth, use api-key billing, or let codex
27
+ commit / push on its own.
28
+
29
+ ## Install
30
+
31
+ Clean-machine setup is in [`setup/README.md`](setup/README.md). In short: install the `codex`
32
+ binary, run `codex login` once under a ChatGPT subscription, then expose this skill's two wrappers on
33
+ `PATH` as `codex-exec` ([`bin/codex-exec.sh`](bin/codex-exec.sh)) and `codex-review`
34
+ ([`bin/codex-review.sh`](bin/codex-review.sh)).
35
+
36
+ ## Auth — subscription only (invariant)
37
+
38
+ `codex` authenticates with the cached **ChatGPT login** under `CODEX_HOME` (`~/.codex`). Never read,
39
+ print, copy, commit, or package `~/.codex/auth.json` — it is personal and is **never bundled** with
40
+ this skill. Both wrappers enforce the subscription path before invoking codex:
41
+
42
+ - they **unset every `*_API_KEY`** (plus `OPENAI_API_KEY` / `CODEX_API_KEY` / `OPENAI_BASE_URL`) so a
43
+ stray key can never silently switch you to paid api-key billing;
44
+ - they pass **`--ignore-user-config`** so a personal `~/.codex/config.toml` cannot change model,
45
+ sandbox, or approval behaviour (auth still works — codex reads the login from `CODEX_HOME`
46
+ regardless of that flag);
47
+ - they **preflight `codex login status`** and refuse to run unless it reports `Logged in using ChatGPT`.
48
+
49
+ ## Models
50
+
51
+ The wrappers default to `gpt-5.5` at reasoning effort `xhigh` (the strongest setting verified in this
52
+ environment), both overridable per call. `codex --version` reports the CLI version, **not** the model
53
+ list — check your Codex CLI / ChatGPT account for the model slugs available to you, or let a wrong
54
+ `-m` surface the error.
55
+
56
+ | Variable | Default | Effect |
57
+ |---|---|---|
58
+ | `CODEX_MODEL` | `gpt-5.5` | model passed to `-m` |
59
+ | `CODEX_EFFORT` | `xhigh` | reasoning effort passed to `-c model_reasoning_effort=…` |
60
+
61
+ ```bash
62
+ CODEX_MODEL=<slug> CODEX_EFFORT=<low|medium|high|xhigh> codex-exec <file>
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ Drive codex only through the two wrappers (installed on `PATH`), run from the target project root:
68
+
69
+ ```bash
70
+ # EXECUTION (workspace-write sandbox, network OFF, never prompts):
71
+ codex-exec docs/plans/<slug>.md # drive a plan file
72
+ echo "apply review fix: ..." | codex-exec - # ad-hoc instruction from stdin
73
+ CODEX_MODEL=<slug> codex-exec <file> # override the model
74
+ codex-exec <file|-> -- <extra codex flags...> # passthrough codex flags after `--`
75
+
76
+ # REVIEW (read-only sandbox — codex cannot edit anything, only emits findings):
77
+ codex-review plan docs/plans/<slug>.md # critique a plan
78
+ codex-review code # review the current working-tree diff
79
+ codex-review code "focus on the new reducer" # review with extra focus
80
+ ```
81
+
82
+ `codex exec` is headless: there is **no TTY**, so `approval_policy=never` — anything needing
83
+ escalation is refused and reported, never interactively approved. Extra `codex` flags go after a
84
+ literal `--`; args without the separator are rejected (never silently dropped). Full flag/policy
85
+ detail: [`references/sandbox-and-flags.md`](references/sandbox-and-flags.md).
86
+
87
+ ## Project context (how `codex` sees the repo)
88
+
89
+ From its **current working directory** `codex` auto-reads the root **`AGENTS.md`** — so when you run a
90
+ wrapper from a project root, the project's Hard Constraints are available to codex with no wiring (a
91
+ probe confirmed codex returned a repo's declared dialogue language from `AGENTS.md`). The wrappers
92
+ therefore **hardcode no project rules**: the orchestrator contract tells codex to read the target
93
+ `AGENTS.md` and obey it.
94
+
95
+ **Fallback is strict.** Both wrappers preflight that they run inside a git work tree and that a root
96
+ `AGENTS.md` exists — if either is missing they **STOP and report** (a wasted subscription run is
97
+ avoided). And the execution contract tells codex: if the project declares **no** verification/gate
98
+ set, **STOP and report** rather than invent checks. Pass `--skip-git-repo-check` to codex only when
99
+ you truly mean it.
100
+
101
+ ## How the main agent drives `codex` efficiently
102
+
103
+ See [`references/driving-codex.md`](references/driving-codex.md) for the full playbook. Essentials:
104
+
105
+ - **`codex-exec` for doing, `codex-review` for judging.** Use exec to implement a plan/fix under the
106
+ sandbox; use review to get advisory findings on a plan or diff without any edits.
107
+ - **The orchestrator commits — codex never does.** The execution contract forbids every git write
108
+ (branch/add/commit/stash/reset/checkout/tag/rewrite); you review codex's diff, then commit yourself.
109
+ - **Treat output as advisory** and verify before acting — re-run the project's gates yourself, reject
110
+ advice that conflicts with user instructions or repo rules.
111
+ - **Hand codex a self-contained task.** It cannot see your conversation — for an ad-hoc instruction,
112
+ embed the goal, the relevant paths, and the expected result; codex reads `AGENTS.md` for the rules.
113
+ - **Re-dispatch with `codex exec resume`** (run codex directly — the wrapper's flag/stdin shape can't
114
+ host the `resume` subcommand) instead of re-sending context. **Caveat:** resume runs outside the
115
+ wrapper and may not re-accept `--sandbox` / policy flags — restate the policy, or start a fresh
116
+ `codex-exec` run when a guaranteed sandbox/network posture matters.
117
+ - **Network is OFF in exec.** New dependencies and any network step are installed by hand, then codex
118
+ is re-dispatched.
119
+
120
+ ## Complementary skills (optional, standalone-first)
121
+
122
+ The wrappers work in any git repo where `codex` is installed and authenticated. The skills below are
123
+ **not required** — surface them only when they actually help.
124
+
125
+ - **`antigravity-cli-bridge`** (sibling backend, Google `agy`) — recommend **by actual presence**: if
126
+ `~/.claude/skills/antigravity-cli-bridge/` exists you have a **second delegated engine** (codex for
127
+ sandboxed repo edits with gates; `agy` for subscription-quota Gemini/Claude/GPT-OSS reasoning). If
128
+ it is **not** installed, treat it as a planned sibling — don't assume it exists.
129
+ - **`agent-workflow-memory`** (family **context provider**) — if the target project has **no**
130
+ `AGENTS.md` + `docs/ai/`, codex has no root context to read (and the wrappers' preflight will
131
+ STOP). The memory substrate is what creates that context. Soft-recommend it (only when the user
132
+ wants the memory workflow): `npx @sabaiway/agent-workflow-memory@latest init`, or bootstrap the whole
133
+ family via the **`agent-workflow-kit`** orchestrator (`npx @sabaiway/agent-workflow-kit@latest init`),
134
+ which delegates substrate deployment to memory and injects the workflow methodology. Never a
135
+ prerequisite.
136
+
137
+ ## Known limitations
138
+
139
+ - **Network is OFF** in `codex-exec` (`sandbox_workspace_write.network_access=false`): codex cannot
140
+ install dependencies or reach the network — do that by hand, then re-dispatch.
141
+ - **No live approvals** — `codex exec` has no TTY, so `approval_policy=never`; an action that would
142
+ need escalation is reported, not approved interactively.
143
+ - **`resume` may drop sandbox/policy flags** — restate the policy or start a fresh run when the
144
+ posture matters (see the driving reference).
145
+ - **bubblewrap** — on Linux, if `bubblewrap` is not on `PATH` codex prints a warning and uses a
146
+ bundled copy; install it via your package manager to silence the warning.
147
+ - codex output is advisory and may be incomplete or out of date — the main agent verifies before
148
+ acting.
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env bash
2
+ # Delegate plan/instruction EXECUTION to the OpenAI Codex CLI (`codex exec`).
3
+ #
4
+ # Project-agnostic wrapper for the codex-cli-bridge skill. It encodes one fixed,
5
+ # deterministic execution policy and prepends an ORCHESTRATOR EXECUTION CONTRACT
6
+ # so codex never wastes a run rediscovering it. Codex reads the TARGET project's
7
+ # Hard Constraints itself, from the root AGENTS.md in its working directory
8
+ # (codex auto-reads AGENTS.md from cwd) — this wrapper hardcodes no project rules.
9
+ #
10
+ # Fixed policy (single source of truth — passed via flags + --ignore-user-config,
11
+ # so behaviour is deterministic regardless of ~/.codex/config.toml):
12
+ # - workspace-write sandbox: codex may edit the repo, nothing outside it
13
+ # - network access OFF: new dependencies / network installs are done by a human
14
+ # - approval_policy=never: there is no TTY in exec; anything needing escalation
15
+ # is refused and reported, then handled by hand
16
+ # - strongest model at maximum reasoning effort (override CODEX_MODEL/CODEX_EFFORT)
17
+ #
18
+ # Auth: SUBSCRIPTION ONLY. Uses the cached ChatGPT login under CODEX_HOME
19
+ # (~/.codex). The wrapper unsets every *_API_KEY plus OPENAI_BASE_URL and passes
20
+ # --ignore-user-config, so a stray key or a personal ~/.codex/config.toml can
21
+ # never silently switch billing or change behaviour. No credentials are bundled.
22
+ #
23
+ # Usage (installed on PATH as `codex-exec`):
24
+ # codex-exec docs/plans/<slug>.md # drive a plan file
25
+ # echo "apply review fix: ..." | codex-exec - # ad-hoc instruction (stdin)
26
+ # CODEX_MODEL=<slug> codex-exec <file> # override the model
27
+ # codex-exec <file|-> -- <extra codex flags...> # passthrough codex flags
28
+ set -euo pipefail
29
+
30
+ CODEX_MODEL="${CODEX_MODEL:-gpt-5.5}" # default coding model (verified locally); override per call
31
+ CODEX_EFFORT="${CODEX_EFFORT:-xhigh}" # maximum reasoning effort
32
+ CHATGPT_LOGIN_GUARD="Logged in using ChatGPT"
33
+
34
+ # --- Subscription-only guard -------------------------------------------------
35
+ # Never let an API key (or a user config) silently switch codex to paid api-key
36
+ # billing or alternate behaviour. Clear the explicit vars first, then any other
37
+ # *_API_KEY that may have been added later (`compgen` is a bash builtin).
38
+ unset OPENAI_API_KEY CODEX_API_KEY OPENAI_BASE_URL 2>/dev/null || true
39
+ while IFS= read -r _api_key_var; do
40
+ unset "$_api_key_var" 2>/dev/null || true
41
+ done < <(compgen -v 2>/dev/null | grep '_API_KEY$' || true)
42
+
43
+ # --- Environment preflight (fail fast, before spending a subscription run) ----
44
+ if ! command -v codex >/dev/null 2>&1; then
45
+ echo "error: 'codex' (OpenAI Codex CLI) not found on PATH. See this skill's setup/README.md." >&2
46
+ exit 127
47
+ fi
48
+ if ! codex login status 2>&1 | grep -qF "$CHATGPT_LOGIN_GUARD"; then
49
+ echo "error: codex is not on a ChatGPT subscription (expected '$CHATGPT_LOGIN_GUARD')." >&2
50
+ echo " Run 'codex login' once; this skill is subscription-only and won't use api-key billing." >&2
51
+ exit 1
52
+ fi
53
+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
54
+ echo "error: codex-exec must run inside a git working tree (codex exec needs one; the diff is your review surface)." >&2
55
+ exit 2
56
+ fi
57
+ if [[ ! -f AGENTS.md ]]; then
58
+ echo "error: no root AGENTS.md in the current directory — run from the target project root." >&2
59
+ echo " (codex reads AGENTS.md for the project's Hard Constraints and declared gates)" >&2
60
+ exit 2
61
+ fi
62
+
63
+ read -r -d '' ORCHESTRATOR_DIRECTIVE <<'DIRECTIVE' || true
64
+ ORCHESTRATOR EXECUTION CONTRACT — read before the task, follow it exactly:
65
+ 1. Work directly in the current working tree on the current git branch. NEVER run
66
+ any git write command (no branch, add, commit, stash, reset, checkout, tag, or
67
+ history rewrite) — the orchestrator commits after review.
68
+ 2. Read the target project's root AGENTS.md and obey EVERY Hard Constraint it
69
+ declares, plus this task's own "do NOT" / out-of-scope section.
70
+ 3. After implementing, run a SELF-REVIEW pass over your own changes — `git status`
71
+ for untracked files and `git diff` for tracked ones, reading the contents of
72
+ any new untracked files — against the task and those Hard Constraints; fix
73
+ anything that drifts so the handed-back work is clean.
74
+ 4. Run the verification / gate set the project declares (in AGENTS.md or the
75
+ task). If the project declares NO gate set, STOP and report — do NOT invent
76
+ checks. Fix every failure before finishing.
77
+ 5. Do NOT commit. If you hit a blocker needing escalation (network access, writes
78
+ outside the repo, a live approval, or an ambiguous decision), STOP and report
79
+ it clearly — never guess.
80
+
81
+ TASK:
82
+ DIRECTIVE
83
+
84
+ if [[ $# -lt 1 ]]; then
85
+ echo "usage: $0 <plan-file|-> [-- extra codex args...]" >&2
86
+ exit 2
87
+ fi
88
+
89
+ prompt_src="$1"; shift
90
+
91
+ # Split off passthrough codex flags after a literal `--`. Extra args WITHOUT the
92
+ # `--` separator are a mistake — they would be silently dropped, so fail loudly.
93
+ passthrough=()
94
+ if [[ $# -gt 0 ]]; then
95
+ if [[ "$1" == "--" ]]; then
96
+ shift
97
+ passthrough=("$@")
98
+ else
99
+ echo "error: unexpected argument '$1'. Pass extra codex flags after a literal '--':" >&2
100
+ echo " $0 <plan-file|-> -- <codex flags...>" >&2
101
+ exit 2
102
+ fi
103
+ fi
104
+
105
+ # This wrapper OWNS the safety policy (sandbox level, approval policy, network
106
+ # access, and every -c config override). Reject passthrough flags that would
107
+ # defeat it — appended flags can otherwise override the fixed ones. Benign flags
108
+ # (--add-dir, --cd, --ephemeral, -m, --image, ...) still pass through.
109
+ if [[ ${#passthrough[@]} -gt 0 ]]; then
110
+ for _arg in "${passthrough[@]}"; do
111
+ case "$_arg" in
112
+ -c*|--config*|-s*|--sandbox*|--dangerously-bypass-approvals-and-sandbox|--dangerously-bypass-hook-trust|--full-auto)
113
+ echo "error: passthrough flag '$_arg' is not allowed — this wrapper fixes the sandbox / approval / network / config policy." >&2
114
+ echo " Drop it, or invoke 'codex' directly if you truly need a different policy." >&2
115
+ exit 2
116
+ ;;
117
+ esac
118
+ done
119
+ fi
120
+
121
+ if [[ "$prompt_src" == "-" ]]; then
122
+ task="$(cat)"
123
+ elif [[ -f "$prompt_src" ]]; then
124
+ task="$(cat "$prompt_src")"
125
+ else
126
+ echo "error: '$prompt_src' is not a file (use '-' to read the prompt from stdin)" >&2
127
+ exit 2
128
+ fi
129
+
130
+ if [[ -z "${task//[[:space:]]/}" ]]; then
131
+ echo "error: empty plan/instruction" >&2
132
+ exit 2
133
+ fi
134
+
135
+ printf '%s\n\n%s' "$ORCHESTRATOR_DIRECTIVE" "$task" | codex exec \
136
+ --ignore-user-config \
137
+ --sandbox workspace-write \
138
+ -c approval_policy="never" \
139
+ -c sandbox_workspace_write.network_access=false \
140
+ -c model_reasoning_effort="$CODEX_EFFORT" \
141
+ -m "$CODEX_MODEL" \
142
+ "${passthrough[@]+"${passthrough[@]}"}" \
143
+ -
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env bash
2
+ # Read-only ADVISORY review BY the OpenAI Codex CLI. Runs under the read-only
3
+ # sandbox, so codex structurally CANNOT edit/create/delete files or write to git
4
+ # — it can only read and emit findings. The orchestrator reads those findings and
5
+ # decides what to act on; codex never applies them itself.
6
+ #
7
+ # Project-agnostic wrapper for the codex-cli-bridge skill. Codex reads the target
8
+ # project's Hard Constraints itself, from the root AGENTS.md in its cwd.
9
+ #
10
+ # Modes:
11
+ # codex-review plan <plan-file> # critique an implementation plan
12
+ # codex-review code [extra focus...] # review the current working-tree diff
13
+ #
14
+ # Auth/policy: subscription-only, identical to codex-exec.sh. The read-only
15
+ # sandbox grants no writes and no network in v0.140.0, so review needs no separate
16
+ # network flag (the sandbox_workspace_write.* config applies only to workspace-write).
17
+ set -euo pipefail
18
+
19
+ CODEX_MODEL="${CODEX_MODEL:-gpt-5.5}"
20
+ CODEX_EFFORT="${CODEX_EFFORT:-xhigh}"
21
+ CHATGPT_LOGIN_GUARD="Logged in using ChatGPT"
22
+
23
+ # --- Subscription-only guard (see codex-exec.sh) -----------------------------
24
+ unset OPENAI_API_KEY CODEX_API_KEY OPENAI_BASE_URL 2>/dev/null || true
25
+ while IFS= read -r _api_key_var; do
26
+ unset "$_api_key_var" 2>/dev/null || true
27
+ done < <(compgen -v 2>/dev/null | grep '_API_KEY$' || true)
28
+
29
+ # --- Environment preflight (fail fast) ---------------------------------------
30
+ if ! command -v codex >/dev/null 2>&1; then
31
+ echo "error: 'codex' (OpenAI Codex CLI) not found on PATH. See this skill's setup/README.md." >&2
32
+ exit 127
33
+ fi
34
+ if ! codex login status 2>&1 | grep -qF "$CHATGPT_LOGIN_GUARD"; then
35
+ echo "error: codex is not on a ChatGPT subscription (expected '$CHATGPT_LOGIN_GUARD'). Run 'codex login' once." >&2
36
+ exit 1
37
+ fi
38
+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
39
+ echo "error: codex-review must run inside a git working tree." >&2
40
+ exit 2
41
+ fi
42
+ if [[ ! -f AGENTS.md ]]; then
43
+ echo "error: no root AGENTS.md in the current directory — run from the target project root." >&2
44
+ exit 2
45
+ fi
46
+
47
+ mode="${1:-}"
48
+ shift || true
49
+
50
+ case "$mode" in
51
+ plan)
52
+ target="${1:-}"
53
+ shift || true
54
+ if [[ ! -f "$target" ]]; then
55
+ echo "error: plan file '$target' not found" >&2
56
+ exit 2
57
+ fi
58
+ if [[ $# -gt 0 ]]; then
59
+ echo "error: unexpected arguments after plan file: $*" >&2
60
+ exit 2
61
+ fi
62
+ directive="You are REVIEWING an implementation plan — ADVISORY ONLY. You are in a read-only sandbox: do NOT edit, create, or delete any file, and do NOT rewrite the plan. Read the plan below, the project's root AGENTS.md, and the relevant repository code it references. Output findings ONLY, one per line, as: [blocker|major|minor|nit] — location — issue — suggested change. Cover: correctness risks, missing or mis-ordered steps, ambiguities a cold executor would trip on, violated project Hard Constraints (AGENTS.md), scope creep, and missing verification/gates. End with a one-line overall verdict (ship / revise / rethink)."
63
+ prompt="${directive}"$'\n\nPLAN:\n'"$(cat "$target")"
64
+ ;;
65
+ code)
66
+ directive="You are REVIEWING the current uncommitted working-tree changes — ADVISORY ONLY. You are in a read-only sandbox: do NOT edit, create, or delete any file and do NOT run any git write command. Run \`git status --short\` to list ALL changes, \`git diff\` for the tracked changes, and for every path marked \`??\` by git status READ that file's full contents (plain \`git diff\` omits untracked files). Also read the project's root AGENTS.md. Then output findings ONLY, one per line, as: [blocker|major|minor|nit] — file:line — issue — suggested fix. Focus on correctness bugs, project Hard Constraints (AGENTS.md), behaviour drift vs the intended change, and test/gate gaps. End with a one-line overall verdict (ship / revise / rethink)."
67
+ if [[ $# -gt 0 ]]; then
68
+ directive="${directive} Extra focus: $*"
69
+ fi
70
+ prompt="$directive"
71
+ ;;
72
+ *)
73
+ echo "usage: $0 plan <plan-file> | code [extra focus...]" >&2
74
+ exit 2
75
+ ;;
76
+ esac
77
+
78
+ printf '%s' "$prompt" | codex exec \
79
+ --ignore-user-config \
80
+ --sandbox read-only \
81
+ -c approval_policy="never" \
82
+ -c model_reasoning_effort="$CODEX_EFFORT" \
83
+ -m "$CODEX_MODEL" \
84
+ -
@@ -0,0 +1,22 @@
1
+ {
2
+ "family": "agent-workflow",
3
+ "schema": 1,
4
+ "name": "codex-cli-bridge",
5
+ "kind": "execution-backend",
6
+ "version": "1.0.0",
7
+ "provides": ["execute", "review"],
8
+ "roles": {
9
+ "execute": { "cmd": "codex-exec", "source": "bin/codex-exec.sh", "output": "diff" },
10
+ "review": { "cmd": "codex-review", "source": "bin/codex-review.sh", "modes": ["plan", "code"], "output": "advisory" }
11
+ },
12
+ "detect": {
13
+ "installed": {
14
+ "env": "CODEX_CLI_BRIDGE_DIR",
15
+ "default": "~/.claude/skills/codex-cli-bridge",
16
+ "file": "SKILL.md"
17
+ }
18
+ },
19
+ "cost": "subscription",
20
+ "quota": { "kind": "subscription", "finite": true },
21
+ "provenance": { "author": "sabaiway", "source": "github:sabaiway/agent-workflow" }
22
+ }
@@ -0,0 +1,97 @@
1
+ # How the main agent drives `codex`
2
+
3
+ `codex` is a **delegated-execution backend**: the main agent stays the orchestrator and hands codex a
4
+ bounded sub-task answered from the **ChatGPT subscription**. Codex has two modes here — a sandboxed
5
+ **executor** (`codex-exec`) and a read-only **reviewer** (`codex-review`). Treat all codex output as
6
+ **advisory**: the orchestrator owns the accepted edits, the verification, the commit, and the final
7
+ judgment.
8
+
9
+ ## Delegation checklist
10
+
11
+ 1. Decide the mode: `codex-exec` to *do* (edit the repo under the sandbox), `codex-review` to *judge*
12
+ (advisory findings, no edits).
13
+ 2. Run the wrapper from the **target project root** so codex auto-reads its `AGENTS.md` (the wrappers
14
+ also preflight that a root `AGENTS.md` and a git work tree exist).
15
+ 3. For an ad-hoc instruction, make it self-contained: codex cannot see your conversation — embed the
16
+ goal, the relevant paths, the non-goals, and the expected result. The project's rules come from
17
+ `AGENTS.md`.
18
+ 4. Let codex run; then **review its diff yourself** and re-run the project's gates.
19
+ 5. **Commit yourself** — codex never commits.
20
+
21
+ ## Exec vs review
22
+
23
+ Use **`codex-exec`** when there is a concrete plan or focused instruction to implement, the project
24
+ declares Hard Constraints + gates in `AGENTS.md`, the work fits network-off `workspace-write`, and you
25
+ can review the resulting diff.
26
+
27
+ Use **`codex-review plan`** for a cold second opinion on a plan before executing it (risks, missing or
28
+ mis-ordered steps, scope creep, missing gates).
29
+
30
+ Use **`codex-review code`** for advisory, severity-tagged findings on uncommitted changes — including
31
+ when **untracked** files matter: the wrapper prompt tells codex to run `git status --short` and read
32
+ the contents of `??` files, because plain `git diff` omits them.
33
+
34
+ ## Usage
35
+
36
+ ```bash
37
+ codex-exec docs/plans/<slug>.md # drive a plan file
38
+ echo "apply review fix: tighten the guard in X, keep tests green" | codex-exec -
39
+ CODEX_MODEL=<slug> CODEX_EFFORT=high codex-exec <file> # tune model/effort
40
+ codex-exec <file|-> -- --add-dir ../shared # passthrough codex flags after `--`
41
+
42
+ codex-review plan docs/plans/<slug>.md # critique a plan before executing it
43
+ codex-review code # review the current working-tree diff
44
+ codex-review code "focus on the reducer and its tests"
45
+ ```
46
+
47
+ `codex-exec` prepends an **orchestrator execution contract**: work in the current tree, never
48
+ git-write, obey the target `AGENTS.md`, self-review the diff (incl. untracked files), run the
49
+ project's declared gates (STOP if none are declared), don't commit, report blockers.
50
+
51
+ ## Prompt shapes (for ad-hoc `codex-exec -` instructions)
52
+
53
+ Execution:
54
+
55
+ ```text
56
+ Implement the change below from the current project root.
57
+ Respect root AGENTS.md, especially its Hard Constraints and declared gates.
58
+ Do not run git write commands. Do not commit.
59
+ If a dependency install, network call, missing gate set, or out-of-repo write is needed, STOP and report.
60
+
61
+ <the focused instruction + relevant paths>
62
+ ```
63
+
64
+ The review prompt shapes are built into `codex-review` itself — you only pass `plan <file>` or
65
+ `code [focus]`; the wrapper supplies the severity-tagged-findings + verdict directive.
66
+
67
+ ## Re-dispatch vs. fresh run
68
+
69
+ ```bash
70
+ codex exec resume --last # run codex DIRECTLY — not through codex-exec
71
+ ```
72
+
73
+ Resume is **not** reachable through `codex-exec`: the wrapper's shape (fixed flags + a trailing `-`
74
+ that reads the prompt from stdin) can't host the `resume` subcommand, and the wrapper rejects
75
+ policy-affecting passthrough flags anyway. Run `codex exec resume` directly when you want to continue
76
+ a session without re-sending context — but note it runs **outside** the wrapper, so it does not
77
+ inherit the enforced sandbox/network/approval policy and **may not re-accept those flags**. Restate
78
+ the policy in the resumed instruction, or just start a fresh `codex-exec` run when the posture must be
79
+ guaranteed (see `sandbox-and-flags.md`).
80
+
81
+ ## Escalation policy (edits, network, git)
82
+
83
+ - **Repo edits** are codex's job *inside* `codex-exec`'s workspace-write sandbox — but you **review the
84
+ diff** before accepting/committing it. `codex-review` makes no edits at all.
85
+ - **New dependencies / network installs** are done by hand (exec has network OFF), then codex is
86
+ re-dispatched.
87
+ - **Git writes** (branch/add/commit/stash/reset/checkout/tag/rewrite) are never delegated — the
88
+ orchestrator commits after review. The execution contract forbids them.
89
+
90
+ ## Handling output
91
+
92
+ codex output is advisory. Before acting:
93
+
94
+ - Re-run the project's gates yourself; don't trust a "green" claim you didn't see.
95
+ - Inspect the diff yourself; check edits against the project's `AGENTS.md` rules.
96
+ - Reject advice that conflicts with user instructions, repository rules, or security boundaries.
97
+ - Report uncertainty clearly, and summarise only verified claims back to the user.
@@ -0,0 +1,105 @@
1
+ # `codex` sandbox, flags & policy (reference)
2
+
3
+ The source of truth is the live binary: `codex --version`, `codex --help`, `codex exec --help`. The
4
+ tables below were captured from **codex-cli 0.140.0**; if the binary disagrees, the binary wins. The
5
+ wrapper commands are `codex-exec` and `codex-review`, backed by `bin/codex-exec.sh` /
6
+ `bin/codex-review.sh`.
7
+
8
+ ## Sandbox levels — when to use which
9
+
10
+ | Level | Can write? | Network? | Wrapper that uses it |
11
+ |---|---|---|---|
12
+ | `read-only` | no | no | `codex-review` (codex only reads + emits findings) |
13
+ | `workspace-write` | repo (cwd) only | OFF (we force it off) | `codex-exec` (codex edits the repo) |
14
+ | `danger-full-access` | anywhere | yes | never used by this skill |
15
+
16
+ `codex-exec` always passes:
17
+
18
+ ```bash
19
+ --sandbox workspace-write \
20
+ -c approval_policy="never" \
21
+ -c sandbox_workspace_write.network_access=false
22
+ ```
23
+
24
+ `codex-review` always passes:
25
+
26
+ ```bash
27
+ --sandbox read-only \
28
+ -c approval_policy="never"
29
+ ```
30
+
31
+ Under `read-only`, codex *structurally* cannot edit, create, delete, or git-write — it can only read
32
+ and report. In v0.140.0 `read-only` also grants **no network**, so `codex-review` relies on that and
33
+ passes no separate network flag — the `sandbox_workspace_write.*` config (including
34
+ `network_access`) applies **only** to `workspace-write`.
35
+
36
+ ## Network-OFF invariant (exec)
37
+
38
+ `codex-exec` keeps network access OFF on purpose: **new dependencies and any network step are
39
+ installed by a human**, not by codex. If a task needs a new package, codex must STOP and report it;
40
+ the orchestrator installs it, then re-dispatches.
41
+
42
+ ## Escalation & approvals
43
+
44
+ There is **no TTY** in `codex exec`, so `approval_policy=never`: codex never pauses for an interactive
45
+ approval. Any action that would need escalation (network, writes outside the repo, an ambiguous
46
+ decision) is **refused and reported**, and the orchestrator handles it by hand. Codex must never run a
47
+ git write command — the orchestrator commits after reviewing the diff.
48
+
49
+ ## Commit prohibition
50
+
51
+ Delegated codex runs do not own repository history. The wrappers' contract prohibits every git write:
52
+ no branch, add, commit, stash, reset, checkout, tag, or history rewrite. The orchestrator reviews the
53
+ diff, runs final verification, and commits only when that is the desired next step.
54
+
55
+ ## `resume` caveat
56
+
57
+ `codex exec resume` re-dispatches an existing session without re-sending context. **It may not
58
+ re-accept `--sandbox` / `approval_policy` / network flags** — do not assume the original posture
59
+ carries over. Restate the policy in the resumed instruction, or start a fresh `codex-exec` run when a
60
+ guaranteed sandbox/network posture matters.
61
+
62
+ ## Subscription / config invariant
63
+
64
+ Both wrappers, before invoking codex:
65
+
66
+ - **unset** `OPENAI_API_KEY`, `CODEX_API_KEY`, `OPENAI_BASE_URL`, and every other `*_API_KEY`, so a
67
+ stray key can't switch to paid api-key billing;
68
+ - pass **`--ignore-user-config`** so a personal `~/.codex/config.toml` cannot change behaviour. Auth
69
+ still works: codex reads the cached login from `CODEX_HOME` (`~/.codex`) regardless of that flag;
70
+ - preflight `codex login status` and refuse unless it contains `Logged in using ChatGPT`;
71
+ - preflight a git work tree and a root `AGENTS.md`, failing fast (before a run is spent) if missing.
72
+
73
+ ## Verified commands & flags (v0.140.0)
74
+
75
+ | Command / flag | Verified behaviour |
76
+ |---|---|
77
+ | `codex exec` | non-interactive run from stdin / a prompt arg (headless, no TTY) |
78
+ | `codex exec resume` | resume an exec session (see the resume caveat) |
79
+ | `codex exec review` | review path reachable under `exec` |
80
+ | `codex review` | repository review path; supports reviewing uncommitted changes |
81
+ | `codex login` / `codex login status` | subscription auth flow + status check |
82
+ | `codex sandbox` / `codex apply` / `codex resume` | sandbox / apply / resume helper subcommands |
83
+ | `-c key=value` | override a config value (dotted path, TOML-parsed) — how policy is set deterministically |
84
+ | `--sandbox <mode>` | `read-only` \| `workspace-write` \| `danger-full-access` (this skill uses the first two) |
85
+ | `-c approval_policy=never` | never pause for interactive approval (required: exec has no TTY) |
86
+ | `-c sandbox_workspace_write.network_access=false` | network OFF under workspace-write (the exec invariant) |
87
+ | `-m <model>` | model to use (wrapper default `gpt-5.5` via `CODEX_MODEL`) |
88
+ | `-c model_reasoning_effort=<effort>` | reasoning effort (wrapper default `xhigh` via `CODEX_EFFORT`) |
89
+ | `--ignore-user-config` | do NOT load `$CODEX_HOME/config.toml`; auth still uses `CODEX_HOME` |
90
+ | `--add-dir <dir>` | extra writable dir alongside the workspace |
91
+ | `-C, --cd <dir>` | use `<dir>` as the working root |
92
+ | `--skip-git-repo-check` | allow running outside a git repo (exec normally requires one) |
93
+ | `--ephemeral` | do not persist session files |
94
+
95
+ ## Troubleshooting
96
+
97
+ - **`could not find bubblewrap on PATH`** (Linux): codex falls back to a bundled bubblewrap. Install
98
+ `bubblewrap` (`sudo apt install bubblewrap` or equivalent) to silence the warning; it is only a
99
+ blocker if sandbox startup actually fails.
100
+ - **`not on a ChatGPT subscription`** (wrapper preflight): run `codex login`; confirm with
101
+ `codex login status` → `Logged in using ChatGPT`.
102
+ - **`must run inside a git working tree` / `no root AGENTS.md`** (wrapper preflight): run the wrapper
103
+ from the target project root.
104
+ - **codex wants to install a dependency**: it can't (network OFF in exec) — install it by hand, then
105
+ re-dispatch.