@sabaiway/agent-workflow-kit 1.23.0 → 1.25.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.
- package/CHANGELOG.md +53 -0
- package/README.md +1 -1
- package/SKILL.md +44 -17
- package/bridges/antigravity-cli-bridge/SKILL.md +1 -1
- package/bridges/antigravity-cli-bridge/bin/agy-review.sh +35 -0
- package/bridges/antigravity-cli-bridge/bin/agy-review.test.mjs +186 -0
- package/bridges/antigravity-cli-bridge/bin/agy.sh +23 -0
- package/bridges/antigravity-cli-bridge/bin/agy.test.mjs +58 -2
- package/bridges/antigravity-cli-bridge/capability.json +25 -2
- package/bridges/codex-cli-bridge/SKILL.md +2 -2
- package/bridges/codex-cli-bridge/bin/codex-exec.sh +34 -0
- package/bridges/codex-cli-bridge/bin/codex-exec.test.mjs +160 -1
- package/bridges/codex-cli-bridge/bin/codex-review.sh +28 -0
- package/bridges/codex-cli-bridge/bin/codex-review.test.mjs +127 -0
- package/bridges/codex-cli-bridge/capability.json +36 -3
- package/bridges/codex-cli-bridge/references/driving-codex.md +1 -1
- package/capability.json +1 -1
- package/package.json +1 -1
- package/tools/commands.mjs +1 -1
- package/tools/detect-backends.mjs +59 -0
- package/tools/manifest/schema.md +15 -0
- package/tools/procedures.mjs +37 -6
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: codex-cli-bridge
|
|
3
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
4
|
metadata:
|
|
5
|
-
version: '2.
|
|
5
|
+
version: '2.1.0'
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# codex-cli-bridge
|
|
@@ -77,7 +77,7 @@ Drive codex only through the two wrappers (installed on `PATH`), run from the ta
|
|
|
77
77
|
# EXECUTION (workspace-write sandbox, network OFF, never prompts):
|
|
78
78
|
codex-exec docs/plans/<slug>.md # drive a plan file
|
|
79
79
|
echo "apply review fix: ..." | codex-exec - # ad-hoc instruction from stdin
|
|
80
|
-
codex-exec <file|-> -- <
|
|
80
|
+
codex-exec <file|-> -- <extra codex flags...> # GUARDED passthrough after `--` (policy/model/capture flags rejected; some relaxed only under CODEX_PROBE=1)
|
|
81
81
|
|
|
82
82
|
# RESUME (iterate on the SAME session without re-sending context):
|
|
83
83
|
codex-exec --resume-last docs/plans/<slug>.md # continue the last session (id from the sidecar)
|
|
@@ -40,6 +40,40 @@
|
|
|
40
40
|
# CODEX_PROBE=1 CODEX_MODEL=<slug> codex-exec <file> # throwaway probe (relaxes the guard)
|
|
41
41
|
set -euo pipefail
|
|
42
42
|
|
|
43
|
+
# --- --help / -h (pre-preflight: no codex, no login, no git tree needed) -------
|
|
44
|
+
# Keyed ONLY on the FIRST argument — never a scan of all args, else a passthrough
|
|
45
|
+
# payload like `codex-exec f - -- --help` would be intercepted.
|
|
46
|
+
# The contract below is drift-guarded against capability.json roles.execute.contract.
|
|
47
|
+
case "${1:-}" in
|
|
48
|
+
--help|-h)
|
|
49
|
+
cat <<'HELP'
|
|
50
|
+
codex-exec — delegate plan/instruction EXECUTION to the OpenAI Codex CLI (subscription-only; workspace-write sandbox, network OFF, git writes blocked — the orchestrator commits).
|
|
51
|
+
|
|
52
|
+
Usage:
|
|
53
|
+
codex-exec <plan-file|->
|
|
54
|
+
codex-exec <plan-file|-> -- <extra codex flags...>
|
|
55
|
+
|
|
56
|
+
Grounding:
|
|
57
|
+
automatic — the root AGENTS.md (Hard Constraints) is auto-merged into codex's
|
|
58
|
+
context and the wrapper prepends the orchestrator execution contract; no
|
|
59
|
+
grounding flags
|
|
60
|
+
|
|
61
|
+
Round-2 / resume:
|
|
62
|
+
codex-exec --resume-last <plan-file|->
|
|
63
|
+
codex-exec --resume <session-id> <plan-file|->
|
|
64
|
+
(resume continues the recorded session without re-sending context; takes no '--' passthrough)
|
|
65
|
+
|
|
66
|
+
Guarded passthrough after '--':
|
|
67
|
+
blocked always: -c* --config* -s* --sandbox* --dangerously-bypass-approvals-and-sandbox --dangerously-bypass-hook-trust --full-auto --oss --local-provider* -p* --profile* -m* --model* -o* --output-last-message* --json* --color* --output-schema* --ephemeral*
|
|
68
|
+
relaxed only under CODEX_PROBE=1: --add-dir* -C* --cd* --skip-git-repo-check --ignore-rules --enable* --disable*
|
|
69
|
+
|
|
70
|
+
Environment: CODEX_HARD_TIMEOUT (seconds, default 3600), CODEX_PROBE=1 (throwaway probe only).
|
|
71
|
+
Requires at run time: the codex CLI on PATH, a ChatGPT-subscription login, a git work tree with a root AGENTS.md (--help needs none of these).
|
|
72
|
+
HELP
|
|
73
|
+
exit 0
|
|
74
|
+
;;
|
|
75
|
+
esac
|
|
76
|
+
|
|
43
77
|
DEFAULT_CODEX_MODEL="gpt-5.5" # frontier coding model (verified locally) — pinned
|
|
44
78
|
DEFAULT_CODEX_EFFORT="xhigh" # maximum reasoning effort — pinned
|
|
45
79
|
CODEX_MODEL="${CODEX_MODEL:-$DEFAULT_CODEX_MODEL}"
|
|
@@ -149,7 +149,8 @@ describe('codex-exec.sh — quality-first model/effort guard (1.1)', () => {
|
|
|
149
149
|
// capture flags: rejected ALWAYS, even under CODEX_PROBE=1.
|
|
150
150
|
const ALWAYS_BLOCKED = [
|
|
151
151
|
['-s', 'read-only'], ['--sandbox', 'danger-full-access'], ['-c', 'k=v'], ['--config', 'k=v'],
|
|
152
|
-
['--full-auto'], ['--dangerously-bypass-approvals-and-sandbox'], ['--
|
|
152
|
+
['--full-auto'], ['--dangerously-bypass-approvals-and-sandbox'], ['--dangerously-bypass-hook-trust'],
|
|
153
|
+
['--oss'], ['--local-provider', 'x'],
|
|
153
154
|
['-p', 'prof'], ['--profile', 'prof'], ['-m', 'gpt-5.5'], ['--model', 'gpt-5.5'],
|
|
154
155
|
['-o', '/x'], ['--output-last-message', '/x'], ['--json'], ['--color', 'always'],
|
|
155
156
|
['--output-schema', '/x'], ['--ephemeral'],
|
|
@@ -591,3 +592,161 @@ describe('codex-exec.sh — session id absent', () => {
|
|
|
591
592
|
assert.match(r.stdout, /FAKE_FINAL_MESSAGE/, 'the run still succeeds');
|
|
592
593
|
});
|
|
593
594
|
});
|
|
595
|
+
|
|
596
|
+
// ── driving contract: --help ⟷ manifest ⟷ real arg-parsing (drift-guarded) ─────
|
|
597
|
+
// The manifest roles.execute.contract is the single machine-readable source of the
|
|
598
|
+
// driving contract; these suites pin (a) --help renders it verbatim (set-EQUALITY,
|
|
599
|
+
// both directions, incl. the TIERED guarded-passthrough sets), (b) the wrapper's
|
|
600
|
+
// REAL parser arms equal the declared sets (source-level reverse guard — the
|
|
601
|
+
// git-shim heredoc's own `case` arms are NOT CLI modes and must be skipped).
|
|
602
|
+
// Helpers are inline — each bridge test file stays standalone (mirror byte-equality).
|
|
603
|
+
|
|
604
|
+
const MANIFEST = JSON.parse(readFileSync(join(HERE, '..', 'capability.json'), 'utf8'));
|
|
605
|
+
const EXEC_CONTRACT = MANIFEST.roles.execute.contract;
|
|
606
|
+
const norm = (s) => s.replace(/\s+/g, ' ').trim();
|
|
607
|
+
const setEq = (got, want, msg) => assert.deepEqual([...got].sort(), [...want].sort(), msg);
|
|
608
|
+
const leadingFlag = (descriptor) => {
|
|
609
|
+
const m = norm(descriptor).match(/(^|\s)(--[a-z-]+)/);
|
|
610
|
+
assert.ok(m, `descriptor "${descriptor}" carries no --flag token`);
|
|
611
|
+
return m[2];
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// Run `--help`/-h with PATH stripped of codex/agy/git, from a non-git cwd with no
|
|
615
|
+
// AGENTS.md — proving the short-circuit fires BEFORE every preflight.
|
|
616
|
+
const runHelp = (arg) => {
|
|
617
|
+
const root = mkdtempSync(join(tmpdir(), 'codex-exec-help-'));
|
|
618
|
+
const nongit = join(root, 'nongit');
|
|
619
|
+
mkdirSync(nongit, { recursive: true });
|
|
620
|
+
const path = makePathWithout(root, ['codex', 'agy', 'git']);
|
|
621
|
+
const r = spawnSync('bash', [WRAPPER, arg], {
|
|
622
|
+
cwd: nongit, encoding: 'utf8', timeout: 15000, env: { HOME: root, PATH: path },
|
|
623
|
+
});
|
|
624
|
+
rmSync(root, { recursive: true, force: true });
|
|
625
|
+
return r;
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
// The lines of a labelled --help section (header line → the next blank line).
|
|
629
|
+
const helpSection = (text, header) => {
|
|
630
|
+
const lines = text.split('\n');
|
|
631
|
+
const i = lines.findIndex((l) => l.trim() === header);
|
|
632
|
+
assert.notEqual(i, -1, `--help must carry a "${header}" section`);
|
|
633
|
+
const out = [];
|
|
634
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
635
|
+
if (lines[j].trim() === '') break;
|
|
636
|
+
out.push(lines[j].trim());
|
|
637
|
+
}
|
|
638
|
+
return out;
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// Source-level parser-arm extractor — the reverse drift guard. Scans ONLY `case`
|
|
642
|
+
// statements whose SUBJECT is a CLI-argument variable (allowlisted), skipping
|
|
643
|
+
// heredoc bodies (codex-exec's git-shim heredoc carries its own `case "$verb"`
|
|
644
|
+
// git-verb arms that are NOT CLI modes). Returns Map(subject → [raw arm label, …]).
|
|
645
|
+
const ARG_SUBJECTS = new Set(['"$mode"', '"${1:-}"', '"$1"', '"$_arg"']);
|
|
646
|
+
const extractArgCaseArms = (source) => {
|
|
647
|
+
const arms = new Map();
|
|
648
|
+
const stack = [];
|
|
649
|
+
let heredoc = null;
|
|
650
|
+
for (const raw of source.split('\n')) {
|
|
651
|
+
if (heredoc) {
|
|
652
|
+
if (raw.trim() === heredoc) heredoc = null;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (raw.trimStart().startsWith('#')) continue; // a comment line may carry a stray ')'
|
|
656
|
+
const hd = raw.match(/<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);
|
|
657
|
+
if (hd) { heredoc = hd[1]; continue; }
|
|
658
|
+
const cs = raw.match(/^\s*case\s+(\S+)\s+in\b/);
|
|
659
|
+
if (cs) { stack.push(cs[1]); continue; }
|
|
660
|
+
if (/^\s*esac\b/.test(raw)) { stack.pop(); continue; }
|
|
661
|
+
if (stack.length && ARG_SUBJECTS.has(stack[stack.length - 1])) {
|
|
662
|
+
const arm = raw.match(/^\s*([^)(\s][^)(]*)\)/);
|
|
663
|
+
if (arm) {
|
|
664
|
+
const subject = stack[stack.length - 1];
|
|
665
|
+
if (!arms.has(subject)) arms.set(subject, []);
|
|
666
|
+
arms.get(subject).push(arm[1].trim());
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return arms;
|
|
671
|
+
};
|
|
672
|
+
const splitArms = (labels) => (labels ?? []).flatMap((l) => l.split('|'));
|
|
673
|
+
|
|
674
|
+
describe('codex-exec.sh — --help contract (manifest-pinned)', () => {
|
|
675
|
+
it('--help and -h exit 0 pre-preflight (no codex, no git, no AGENTS.md)', () => {
|
|
676
|
+
for (const arg of ['--help', '-h']) {
|
|
677
|
+
const r = runHelp(arg);
|
|
678
|
+
assert.equal(r.status, 0, `${arg}: ${r.stderr}`);
|
|
679
|
+
assert.match(r.stdout, /Usage:/, `${arg} prints the contract to stdout`);
|
|
680
|
+
assert.equal(r.stderr, '', `${arg} prints nothing to stderr`);
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
it('Usage set-EQUALS the manifest invocation descriptors (both directions)', () => {
|
|
685
|
+
const help = runHelp('--help').stdout;
|
|
686
|
+
const got = helpSection(help, 'Usage:').filter((l) => l.startsWith('codex-exec')).map(norm);
|
|
687
|
+
assert.ok(EXEC_CONTRACT.invocations.length > 0, 'manifest invocations must be non-empty');
|
|
688
|
+
setEq(got, EXEC_CONTRACT.invocations.map(norm), 'help Usage ⟷ manifest invocations');
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
it('Grounding renders the manifest grounding note verbatim', () => {
|
|
692
|
+
const help = runHelp('--help').stdout;
|
|
693
|
+
assert.equal(norm(helpSection(help, 'Grounding:').join(' ')), norm(EXEC_CONTRACT.grounding));
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
it('Round-2 / resume set-EQUALS the manifest continue descriptors', () => {
|
|
697
|
+
const help = runHelp('--help').stdout;
|
|
698
|
+
const got = helpSection(help, 'Round-2 / resume:').filter((l) => l.startsWith('codex-exec')).map(norm);
|
|
699
|
+
assert.ok(EXEC_CONTRACT.continue.length > 0, 'manifest continue must be non-empty');
|
|
700
|
+
setEq(got, EXEC_CONTRACT.continue.map(norm), 'help continue ⟷ manifest continue');
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
it('the guarded-passthrough TIERS set-EQUAL the manifest tiers (never a flat set)', () => {
|
|
704
|
+
const help = runHelp('--help').stdout;
|
|
705
|
+
const section = helpSection(help, "Guarded passthrough after '--':");
|
|
706
|
+
const tier = (prefix) => {
|
|
707
|
+
const line = section.find((l) => l.startsWith(prefix));
|
|
708
|
+
assert.ok(line, `passthrough section must carry a "${prefix}" line`);
|
|
709
|
+
return line.slice(prefix.length).trim().split(/\s+/);
|
|
710
|
+
};
|
|
711
|
+
assert.ok(EXEC_CONTRACT.passthrough.blocked.length > 0, 'manifest blocked tier must be non-empty');
|
|
712
|
+
assert.ok(EXEC_CONTRACT.passthrough.probeRelaxed.length > 0, 'manifest probe tier must be non-empty');
|
|
713
|
+
setEq(tier('blocked always:'), EXEC_CONTRACT.passthrough.blocked, 'help tier-1 ⟷ manifest blocked');
|
|
714
|
+
setEq(tier('relaxed only under CODEX_PROBE=1:'), EXEC_CONTRACT.passthrough.probeRelaxed, 'help tier-2 ⟷ manifest probeRelaxed');
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
it('--help after the -- separator is passthrough payload, never intercepted', () => {
|
|
718
|
+
const sb = makeSandbox();
|
|
719
|
+
const r = run(sb, { args: ['-', '--', '--help'], input: 'go' });
|
|
720
|
+
rmSync(sb.root, { recursive: true, force: true });
|
|
721
|
+
assert.equal(r.status, 0, r.stderr);
|
|
722
|
+
assert.doesNotMatch(r.stdout, /Usage:/, 'help is keyed on the FIRST argument only');
|
|
723
|
+
assert.match(r.argv, /(^|\n)--help(\n|$)/, 'the payload --help reaches codex argv');
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
describe('codex-exec.sh — source-level reverse guard (parser arms ⟷ manifest)', () => {
|
|
728
|
+
const arms = extractArgCaseArms(readFileSync(WRAPPER, 'utf8'));
|
|
729
|
+
|
|
730
|
+
it('the first-arg entrypoints are exactly --help/-h + the manifest resume flags', () => {
|
|
731
|
+
const declared = EXEC_CONTRACT.continue.map(leadingFlag);
|
|
732
|
+
assert.ok(declared.length > 0, 'manifest resume set must be non-empty');
|
|
733
|
+
setEq(new Set(splitArms(arms.get('"${1:-}"'))), new Set(['--help', '-h', ...declared]));
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
it('the real passthrough tier arms equal the manifest tiers (git-shim heredoc excluded)', () => {
|
|
737
|
+
const tierArms = arms.get('"$_arg"') ?? [];
|
|
738
|
+
assert.equal(tierArms.length, 2, 'exactly two passthrough tiers: always-blocked, probe-relaxed');
|
|
739
|
+
setEq(tierArms[0].split('|'), EXEC_CONTRACT.passthrough.blocked, 'tier-1 arm ⟷ manifest blocked');
|
|
740
|
+
setEq(tierArms[1].split('|'), EXEC_CONTRACT.passthrough.probeRelaxed, 'tier-2 arm ⟷ manifest probeRelaxed');
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it('the in-test tier samples cover every manifest tier pattern (behavioural forward guard)', () => {
|
|
744
|
+
// ALWAYS_BLOCKED / PROBE_RELAXABLE drive the real behaviour suite above; pin them
|
|
745
|
+
// to the manifest so a tier edit cannot leave the behavioural samples stale.
|
|
746
|
+
const sample = (patterns) => patterns.map((p) => p.replace(/\*$/, ''));
|
|
747
|
+
const covered = (flags, patterns) =>
|
|
748
|
+
sample(patterns).every((p) => flags.some(([f]) => f === p || f.startsWith(p)));
|
|
749
|
+
assert.ok(covered(ALWAYS_BLOCKED, EXEC_CONTRACT.passthrough.blocked), 'every blocked pattern has a behavioural sample');
|
|
750
|
+
assert.ok(covered(PROBE_RELAXABLE, EXEC_CONTRACT.passthrough.probeRelaxed), 'every probe pattern has a behavioural sample');
|
|
751
|
+
});
|
|
752
|
+
});
|
|
@@ -31,6 +31,34 @@
|
|
|
31
31
|
# on disk remain readable under read-only — read-scoping is a prompt concern).
|
|
32
32
|
set -euo pipefail
|
|
33
33
|
|
|
34
|
+
# --- --help / -h (pre-preflight: no codex, no login, no git tree needed) -------
|
|
35
|
+
# Keyed ONLY on the FIRST argument — never a scan of all args (uniform rule across
|
|
36
|
+
# the four wrappers, so an open wrapper's passthrough payload is never intercepted).
|
|
37
|
+
# The contract below is drift-guarded against capability.json roles.review.contract.
|
|
38
|
+
case "${1:-}" in
|
|
39
|
+
--help|-h)
|
|
40
|
+
cat <<'HELP'
|
|
41
|
+
codex-review — read-only ADVISORY review by the OpenAI Codex CLI (subscription-only; frontier model at max effort).
|
|
42
|
+
|
|
43
|
+
Usage:
|
|
44
|
+
codex-review plan <plan-file>
|
|
45
|
+
codex-review code [extra focus...]
|
|
46
|
+
|
|
47
|
+
Grounding:
|
|
48
|
+
automatic — the wrapper precomputes the full working-tree change set (repo map,
|
|
49
|
+
status, diffs, untracked contents) and codex auto-merges the root AGENTS.md;
|
|
50
|
+
no grounding flags
|
|
51
|
+
|
|
52
|
+
Round-2 / resume:
|
|
53
|
+
(none — one-shot; a follow-up review is a fresh run)
|
|
54
|
+
|
|
55
|
+
Environment: CODEX_REVIEW_SCHEMA=1 (structured JSON findings), CODEX_HARD_TIMEOUT (seconds, default 1800), CODEX_PROBE=1 (throwaway probe only).
|
|
56
|
+
Requires at run time: the codex CLI on PATH, a ChatGPT-subscription login, a git work tree with a root AGENTS.md (--help needs none of these).
|
|
57
|
+
HELP
|
|
58
|
+
exit 0
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
|
|
34
62
|
DEFAULT_CODEX_MODEL="gpt-5.5"
|
|
35
63
|
DEFAULT_CODEX_EFFORT="xhigh"
|
|
36
64
|
CODEX_MODEL="${CODEX_MODEL:-$DEFAULT_CODEX_MODEL}"
|
|
@@ -540,3 +540,130 @@ describe('codex-review.sh — assemble & output edge cases', () => {
|
|
|
540
540
|
assert.match(r.stdout, /FAKE_FINAL_MESSAGE/);
|
|
541
541
|
});
|
|
542
542
|
});
|
|
543
|
+
|
|
544
|
+
// ── driving contract: --help ⟷ manifest ⟷ real arg-parsing (drift-guarded) ─────
|
|
545
|
+
// The manifest roles.review.contract is the single machine-readable source of the
|
|
546
|
+
// driving contract; these suites pin (a) --help renders it verbatim (set-EQUALITY,
|
|
547
|
+
// both directions), (b) the wrapper's REAL parser arms equal the declared sets
|
|
548
|
+
// (source-level reverse guard), (c) each declared mode is really accepted.
|
|
549
|
+
// Helpers are inline — each bridge test file stays standalone (mirror byte-equality).
|
|
550
|
+
|
|
551
|
+
const MANIFEST = JSON.parse(readFileSync(join(HERE, '..', 'capability.json'), 'utf8'));
|
|
552
|
+
const REVIEW_CONTRACT = MANIFEST.roles.review.contract;
|
|
553
|
+
const norm = (s) => s.replace(/\s+/g, ' ').trim();
|
|
554
|
+
const setEq = (got, want, msg) => assert.deepEqual([...got].sort(), [...want].sort(), msg);
|
|
555
|
+
|
|
556
|
+
// Run `--help`/-h with PATH stripped of codex/agy/git, from a non-git cwd with no
|
|
557
|
+
// AGENTS.md — proving the short-circuit fires BEFORE every preflight.
|
|
558
|
+
const runHelp = (arg) => {
|
|
559
|
+
const root = mkdtempSync(join(tmpdir(), 'codex-review-help-'));
|
|
560
|
+
const nongit = join(root, 'nongit');
|
|
561
|
+
mkdirSync(nongit, { recursive: true });
|
|
562
|
+
const path = makePathWithout(root, ['codex', 'agy', 'git']);
|
|
563
|
+
const r = spawnSync('bash', [WRAPPER, arg], {
|
|
564
|
+
cwd: nongit, encoding: 'utf8', timeout: 15000, env: { HOME: root, PATH: path },
|
|
565
|
+
});
|
|
566
|
+
rmSync(root, { recursive: true, force: true });
|
|
567
|
+
return r;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
// The lines of a labelled --help section (header line → the next blank line).
|
|
571
|
+
const helpSection = (text, header) => {
|
|
572
|
+
const lines = text.split('\n');
|
|
573
|
+
const i = lines.findIndex((l) => l.trim() === header);
|
|
574
|
+
assert.notEqual(i, -1, `--help must carry a "${header}" section`);
|
|
575
|
+
const out = [];
|
|
576
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
577
|
+
if (lines[j].trim() === '') break;
|
|
578
|
+
out.push(lines[j].trim());
|
|
579
|
+
}
|
|
580
|
+
return out;
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
// Source-level parser-arm extractor — the reverse drift guard. Scans ONLY `case`
|
|
584
|
+
// statements whose SUBJECT is a CLI-argument variable (allowlisted), skipping
|
|
585
|
+
// heredoc bodies (a heredoc may carry non-CLI `case` arms — e.g. codex-exec's
|
|
586
|
+
// git-shim). Returns Map(subject → [raw arm label, …]) in source order.
|
|
587
|
+
const ARG_SUBJECTS = new Set(['"$mode"', '"${1:-}"', '"$1"', '"$_arg"']);
|
|
588
|
+
const extractArgCaseArms = (source) => {
|
|
589
|
+
const arms = new Map();
|
|
590
|
+
const stack = [];
|
|
591
|
+
let heredoc = null;
|
|
592
|
+
for (const raw of source.split('\n')) {
|
|
593
|
+
if (heredoc) {
|
|
594
|
+
if (raw.trim() === heredoc) heredoc = null;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
if (raw.trimStart().startsWith('#')) continue; // a comment line may carry a stray ')'
|
|
598
|
+
const hd = raw.match(/<<-?\s*['"]?([A-Za-z_][A-Za-z0-9_]*)['"]?/);
|
|
599
|
+
if (hd) { heredoc = hd[1]; continue; }
|
|
600
|
+
const cs = raw.match(/^\s*case\s+(\S+)\s+in\b/);
|
|
601
|
+
if (cs) { stack.push(cs[1]); continue; }
|
|
602
|
+
if (/^\s*esac\b/.test(raw)) { stack.pop(); continue; }
|
|
603
|
+
if (stack.length && ARG_SUBJECTS.has(stack[stack.length - 1])) {
|
|
604
|
+
const arm = raw.match(/^\s*([^)(\s][^)(]*)\)/);
|
|
605
|
+
if (arm) {
|
|
606
|
+
const subject = stack[stack.length - 1];
|
|
607
|
+
if (!arms.has(subject)) arms.set(subject, []);
|
|
608
|
+
arms.get(subject).push(arm[1].trim());
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return arms;
|
|
613
|
+
};
|
|
614
|
+
const splitArms = (labels) => (labels ?? []).flatMap((l) => l.split('|'));
|
|
615
|
+
|
|
616
|
+
describe('codex-review.sh — --help contract (manifest-pinned)', () => {
|
|
617
|
+
it('--help and -h exit 0 pre-preflight (no codex, no git, no AGENTS.md)', () => {
|
|
618
|
+
for (const arg of ['--help', '-h']) {
|
|
619
|
+
const r = runHelp(arg);
|
|
620
|
+
assert.equal(r.status, 0, `${arg}: ${r.stderr}`);
|
|
621
|
+
assert.match(r.stdout, /Usage:/, `${arg} prints the contract to stdout`);
|
|
622
|
+
assert.equal(r.stderr, '', `${arg} prints nothing to stderr`);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
it('Usage set-EQUALS the manifest invocation descriptors (both directions)', () => {
|
|
627
|
+
const help = runHelp('--help').stdout;
|
|
628
|
+
const got = helpSection(help, 'Usage:').filter((l) => l.startsWith('codex-review')).map(norm);
|
|
629
|
+
assert.ok(REVIEW_CONTRACT.invocations.length > 0, 'manifest invocations must be non-empty');
|
|
630
|
+
setEq(got, REVIEW_CONTRACT.invocations.map(norm), 'help Usage ⟷ manifest invocations');
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
it('Grounding renders the manifest grounding note verbatim', () => {
|
|
634
|
+
const help = runHelp('--help').stdout;
|
|
635
|
+
assert.equal(norm(helpSection(help, 'Grounding:').join(' ')), norm(REVIEW_CONTRACT.grounding));
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
it('Round-2 / resume set-EQUALS the manifest continue descriptors (empty — one-shot)', () => {
|
|
639
|
+
const help = runHelp('--help').stdout;
|
|
640
|
+
const got = helpSection(help, 'Round-2 / resume:').filter((l) => l.startsWith('codex-review')).map(norm);
|
|
641
|
+
setEq(got, (REVIEW_CONTRACT.continue ?? []).map(norm), 'help continue ⟷ manifest continue');
|
|
642
|
+
assert.deepEqual(REVIEW_CONTRACT.continue, [], 'codex-review is one-shot — no continue descriptor');
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
describe('codex-review.sh — source-level reverse guard (parser arms ⟷ manifest)', () => {
|
|
647
|
+
const arms = extractArgCaseArms(readFileSync(WRAPPER, 'utf8'));
|
|
648
|
+
|
|
649
|
+
it('the real mode arms equal the manifest modes (adding a mode without the manifest fails here)', () => {
|
|
650
|
+
const modes = splitArms(arms.get('"$mode"')).filter((a) => a !== '*');
|
|
651
|
+
assert.ok(MANIFEST.roles.review.modes.length > 0, 'manifest modes must be non-empty');
|
|
652
|
+
setEq(new Set(modes), MANIFEST.roles.review.modes, 'parser mode arms ⟷ manifest modes');
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
it('the first-arg entrypoints are exactly --help/-h (no undeclared resume/flag entrypoint)', () => {
|
|
656
|
+
setEq(new Set(splitArms(arms.get('"${1:-}"'))), ['--help', '-h']);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
it('every manifest mode is really accepted (forward guard)', () => {
|
|
660
|
+
const drive = { plan: ['plan', 'plan.md'], code: ['code'] };
|
|
661
|
+
for (const mode of MANIFEST.roles.review.modes) {
|
|
662
|
+
assert.ok(drive[mode], `no test drive for manifest mode "${mode}" — add one`);
|
|
663
|
+
const sb = makeSandbox();
|
|
664
|
+
const r = run(sb, { args: drive[mode] });
|
|
665
|
+
rmSync(sb.root, { recursive: true, force: true });
|
|
666
|
+
assert.equal(r.status, 0, `mode ${mode}: ${r.stderr}`);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
});
|
|
@@ -3,11 +3,44 @@
|
|
|
3
3
|
"schema": 1,
|
|
4
4
|
"name": "codex-cli-bridge",
|
|
5
5
|
"kind": "execution-backend",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.1.0",
|
|
7
7
|
"provides": ["execute", "review"],
|
|
8
8
|
"roles": {
|
|
9
|
-
"execute": {
|
|
10
|
-
|
|
9
|
+
"execute": {
|
|
10
|
+
"cmd": "codex-exec",
|
|
11
|
+
"source": "bin/codex-exec.sh",
|
|
12
|
+
"output": "diff",
|
|
13
|
+
"contract": {
|
|
14
|
+
"invocations": [
|
|
15
|
+
"codex-exec <plan-file|->",
|
|
16
|
+
"codex-exec <plan-file|-> -- <extra codex flags...>"
|
|
17
|
+
],
|
|
18
|
+
"grounding": "automatic — the root AGENTS.md (Hard Constraints) is auto-merged into codex's context and the wrapper prepends the orchestrator execution contract; no grounding flags",
|
|
19
|
+
"continue": [
|
|
20
|
+
"codex-exec --resume-last <plan-file|->",
|
|
21
|
+
"codex-exec --resume <session-id> <plan-file|->"
|
|
22
|
+
],
|
|
23
|
+
"passthrough": {
|
|
24
|
+
"policy": "guarded",
|
|
25
|
+
"blocked": ["-c*", "--config*", "-s*", "--sandbox*", "--dangerously-bypass-approvals-and-sandbox", "--dangerously-bypass-hook-trust", "--full-auto", "--oss", "--local-provider*", "-p*", "--profile*", "-m*", "--model*", "-o*", "--output-last-message*", "--json*", "--color*", "--output-schema*", "--ephemeral*"],
|
|
26
|
+
"probeRelaxed": ["--add-dir*", "-C*", "--cd*", "--skip-git-repo-check", "--ignore-rules", "--enable*", "--disable*"]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"review": {
|
|
31
|
+
"cmd": "codex-review",
|
|
32
|
+
"source": "bin/codex-review.sh",
|
|
33
|
+
"modes": ["plan", "code"],
|
|
34
|
+
"output": "advisory",
|
|
35
|
+
"contract": {
|
|
36
|
+
"invocations": [
|
|
37
|
+
"codex-review plan <plan-file>",
|
|
38
|
+
"codex-review code [extra focus...]"
|
|
39
|
+
],
|
|
40
|
+
"grounding": "automatic — the wrapper precomputes the full working-tree change set (repo map, status, diffs, untracked contents) and codex auto-merges the root AGENTS.md; no grounding flags",
|
|
41
|
+
"continue": []
|
|
42
|
+
}
|
|
43
|
+
}
|
|
11
44
|
},
|
|
12
45
|
"detect": {
|
|
13
46
|
"installed": {
|
|
@@ -50,7 +50,7 @@ object (raw-text fallback on failure).
|
|
|
50
50
|
```bash
|
|
51
51
|
codex-exec docs/plans/<slug>.md # drive a plan file
|
|
52
52
|
echo "apply review fix: tighten the guard in X, keep tests green" | codex-exec -
|
|
53
|
-
codex-exec <file|-> -- <
|
|
53
|
+
codex-exec <file|-> -- <extra codex flags> # GUARDED passthrough AFTER `--` (policy/model/capture flags rejected; some relaxed only under CODEX_PROBE=1)
|
|
54
54
|
|
|
55
55
|
codex-exec --resume-last docs/plans/<slug>.md # continue the last session, no re-send
|
|
56
56
|
echo "now do step 2" | codex-exec --resume <id> -
|
package/capability.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sabaiway/agent-workflow-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"description": "Portable, cross-agent memory & workflow for AI coding agents — Claude Code, Codex, Cursor, Devin Desktop. One command deploys an AGENTS.md entry point + docs/ai context with cap/archive/index enforcement into any repo.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-agents",
|
package/tools/commands.mjs
CHANGED
|
@@ -113,7 +113,7 @@ const CATALOG = [
|
|
|
113
113
|
invocation: invocationOf('procedures'),
|
|
114
114
|
group: 'Orchestrate',
|
|
115
115
|
kind: READ_ONLY,
|
|
116
|
-
oneLine: 'Show a named activity’s steps
|
|
116
|
+
oneLine: 'Show a named activity’s steps, the recipe per stage, and each dispatched backend’s exact driving contract (invocation + grounding + round-2 delta).',
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
key: 'set-recipe',
|
|
@@ -60,6 +60,36 @@ const RAW_BACKENDS = [
|
|
|
60
60
|
name: 'codex-cli-bridge',
|
|
61
61
|
installed: { env: 'CODEX_CLI_BRIDGE_DIR', default: '~/.claude/skills/codex-cli-bridge', file: 'SKILL.md' },
|
|
62
62
|
roleCmds: { execute: 'codex-exec', review: 'codex-review' },
|
|
63
|
+
// The per-role DRIVING CONTRACT (exact invocation descriptors + grounding + round-2 continue),
|
|
64
|
+
// mirroring the bridge manifest roles[role].contract byte-for-byte — drift-guarded like roleCmds.
|
|
65
|
+
// Scope = dispatchable recipe roles ONLY (review, execute): the probe role is never dispatched by
|
|
66
|
+
// an activity slot, so it carries NO contract here (wrapperContractFor(_, 'probe') → null).
|
|
67
|
+
roleContracts: {
|
|
68
|
+
execute: {
|
|
69
|
+
invocations: [
|
|
70
|
+
'codex-exec <plan-file|->',
|
|
71
|
+
'codex-exec <plan-file|-> -- <extra codex flags...>',
|
|
72
|
+
],
|
|
73
|
+
grounding: "automatic — the root AGENTS.md (Hard Constraints) is auto-merged into codex's context and the wrapper prepends the orchestrator execution contract; no grounding flags",
|
|
74
|
+
continue: [
|
|
75
|
+
'codex-exec --resume-last <plan-file|->',
|
|
76
|
+
'codex-exec --resume <session-id> <plan-file|->',
|
|
77
|
+
],
|
|
78
|
+
passthrough: {
|
|
79
|
+
policy: 'guarded',
|
|
80
|
+
blocked: ['-c*', '--config*', '-s*', '--sandbox*', '--dangerously-bypass-approvals-and-sandbox', '--dangerously-bypass-hook-trust', '--full-auto', '--oss', '--local-provider*', '-p*', '--profile*', '-m*', '--model*', '-o*', '--output-last-message*', '--json*', '--color*', '--output-schema*', '--ephemeral*'],
|
|
81
|
+
probeRelaxed: ['--add-dir*', '-C*', '--cd*', '--skip-git-repo-check', '--ignore-rules', '--enable*', '--disable*'],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
review: {
|
|
85
|
+
invocations: [
|
|
86
|
+
'codex-review plan <plan-file>',
|
|
87
|
+
'codex-review code [extra focus...]',
|
|
88
|
+
],
|
|
89
|
+
grounding: 'automatic — the wrapper precomputes the full working-tree change set (repo map, status, diffs, untracked contents) and codex auto-merges the root AGENTS.md; no grounding flags',
|
|
90
|
+
continue: [],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
63
93
|
bin: 'codex',
|
|
64
94
|
credential: { env: 'CODEX_HOME', default: '~/.codex', file: 'auth.json' },
|
|
65
95
|
setupUrl: 'https://github.com/sabaiway/agent-workflow/blob/main/codex-cli-bridge/setup/README.md',
|
|
@@ -72,6 +102,26 @@ const RAW_BACKENDS = [
|
|
|
72
102
|
name: 'antigravity-cli-bridge',
|
|
73
103
|
installed: { env: 'ANTIGRAVITY_CLI_BRIDGE_DIR', default: '~/.claude/skills/antigravity-cli-bridge', file: 'SKILL.md' },
|
|
74
104
|
roleCmds: { review: 'agy-review', probe: 'agy-run' },
|
|
105
|
+
// Mirror of the manifest roles.review.contract (see the codex entry note). probe: NO contract.
|
|
106
|
+
roleContracts: {
|
|
107
|
+
review: {
|
|
108
|
+
invocations: [
|
|
109
|
+
'agy-review code [--facts @f] [--decided @f] [--focus "…"] [extra focus…]',
|
|
110
|
+
'agy-review plan <plan-file> [--facts @f] [--decided @f] [--focus "…"]',
|
|
111
|
+
'agy-review diff <diff-file> [--facts @f] [--decided @f] [--focus "…"]',
|
|
112
|
+
],
|
|
113
|
+
grounding: 'grounded review — agy reads NOTHING by default, an ungrounded review GUESSES: --facts @f = the verified facts to review AGAINST; --decided @f = decisions already made, do NOT re-raise (anti-circling)',
|
|
114
|
+
flags: [
|
|
115
|
+
'--facts @f — verified facts the review runs AGAINST (omit ⇒ loud ungrounded-review warning)',
|
|
116
|
+
'--decided @f — already-decided / already-addressed list; do NOT re-raise (anti-circling; the round-2 payload)',
|
|
117
|
+
'--focus "…" — extra focus (repeatable; code mode also takes trailing focus words)',
|
|
118
|
+
],
|
|
119
|
+
continue: [
|
|
120
|
+
'agy-review --continue [--decided @f] [--focus "…"]',
|
|
121
|
+
'agy-review --conversation <id> [--decided @f] [--focus "…"]',
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
75
125
|
bin: 'agy',
|
|
76
126
|
credential: { env: null, default: '~/.gemini/antigravity-cli', file: 'antigravity-oauth-token' },
|
|
77
127
|
setupUrl: 'https://github.com/sabaiway/agent-workflow/blob/main/antigravity-cli-bridge/setup/README.md',
|
|
@@ -91,6 +141,15 @@ export const KNOWN_BACKENDS = RAW_BACKENDS.map((entry) => ({ ...entry, wrapperCm
|
|
|
91
141
|
export const wrapperCmdFor = (backendName, role) =>
|
|
92
142
|
KNOWN_BACKENDS.find((b) => b.name === backendName)?.roleCmds?.[role] ?? null;
|
|
93
143
|
|
|
144
|
+
// Resolve a dispatched (backend, role) to its structured DRIVING CONTRACT — the registry mirror of
|
|
145
|
+
// the bridge manifest roles[role].contract: exact invocation descriptor(s), the grounding note, the
|
|
146
|
+
// closed flag set (when the wrapper's grammar is closed), the round-2/continue descriptor(s), and
|
|
147
|
+
// the guarded passthrough tiers (codex-exec). The point-of-use advisor (procedures.mjs) renders this
|
|
148
|
+
// VERBATIM so a driving agent never re-derives the contract from wrapper source. `null` when the
|
|
149
|
+
// pair is unknown or the role carries no contract (probe — never dispatched by an activity slot).
|
|
150
|
+
export const wrapperContractFor = (backendName, role) =>
|
|
151
|
+
KNOWN_BACKENDS.find((b) => b.name === backendName)?.roleContracts?.[role] ?? null;
|
|
152
|
+
|
|
94
153
|
// ── pure helpers ─────────────────────────────────────────────────────────────
|
|
95
154
|
|
|
96
155
|
// Expand a leading "~" / "~/x" against home; absolute and relative paths pass through untouched.
|
package/tools/manifest/schema.md
CHANGED
|
@@ -38,6 +38,21 @@ Each `roles.<role>` is an object:
|
|
|
38
38
|
- `template` (string, optional) — an in-skill prompt/template path (e.g.
|
|
39
39
|
`references/review-prompt.md`); repo-relative, **must exist**.
|
|
40
40
|
- `modes`, `output` (optional) — e.g. `["plan","code"]`, `"advisory"`.
|
|
41
|
+
- `contract` (object, optional; execution-backend bridges) — the machine-readable **driving
|
|
42
|
+
contract** for a dispatchable recipe role (`review` / `execute`; the `probe` role carries none).
|
|
43
|
+
Rides as a validator-tolerated extra field (format-checked by the bridge/kit drift-guard tests,
|
|
44
|
+
not by `validate.mjs`), and is the single source the point-of-use advisor
|
|
45
|
+
(`/agent-workflow-kit procedures`) and each wrapper's `--help` render verbatim:
|
|
46
|
+
- `invocations` (string[], non-empty) — exact copy-pasteable invocation descriptors, one per
|
|
47
|
+
mode/variant, incl. operand placeholders (`<plan-file>`, `[extra focus...]`).
|
|
48
|
+
- `grounding` (string) — the grounding note (e.g. agy's `--facts @f` / `--decided @f` levers, or
|
|
49
|
+
"automatic — …" when the wrapper grounds itself).
|
|
50
|
+
- `flags` (string[], optional) — the closed per-mode flag descriptor set (closed-grammar
|
|
51
|
+
wrappers only).
|
|
52
|
+
- `continue` (string[]) — round-2 / resume invocation descriptors; `[]` when one-shot.
|
|
53
|
+
- `passthrough` (object, optional) — the guarded `--` passthrough tiers:
|
|
54
|
+
`{ policy: "guarded", blocked: string[], probeRelaxed: string[] }`, matching the wrapper's
|
|
55
|
+
real case-arm patterns (pinned by the source-level reverse-guard test).
|
|
41
56
|
|
|
42
57
|
## Path-field rules (Windows-safe, traversal-safe)
|
|
43
58
|
|