@sabaiway/agent-workflow-kit 1.6.0 → 1.7.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 CHANGED
@@ -4,6 +4,37 @@ Semantically versioned ([semver](https://semver.org)), newest first. The `versio
4
4
  is the current release. `upgrade` mode reads a project's `docs/ai/.workflow-version` and applies
5
5
  every `migrations/<version>-<slug>.md` newer than it, in semver order.
6
6
 
7
+ ## 1.7.0 — Link-only backend auto-setup; bridges bundled in the tarball
8
+
9
+ The optional execution-backend bridges (`codex-cli-bridge` → `codex`, `antigravity-cli-bridge` →
10
+ `agy`) can now be set up from the kit itself, via a new **opt-in, in-agent** mode —
11
+ **`/agent-workflow-kit setup [backend]`** (`tools/setup-backends.mjs`). It owns only the two
12
+ **deterministic, secret-free** steps and **guides** the rest (AD-011):
13
+
14
+ - **Bridges are bundled in the kit's npm tarball** under `bridges/<name>/` — a **byte-identical
15
+ mirror** of the repo-root bridges, pinned by `test/bridges-mirror.test.mjs` (the same drift-guard
16
+ pattern as the methodology mirror). So `setup` places a bridge from local files, with **no network
17
+ fetch**. `init` (npx) bundles them but still **does not place** them — that stays the opt-in
18
+ `setup` job (preserving the honest `init` ≠ deploy claim).
19
+ - **`setup` places/refreshes the bundled bridge skill**, but only into a dir that is **absent /
20
+ empty / proven-managed** (valid manifest, matching `name`+`kind`); a stub/foreign/invalid/
21
+ unsupported manifest, a marker fs-error, a non-empty unknown dir, or a symlinked dir → **STOP**,
22
+ never overwritten. Refresh re-runs on a managed dir so re-running `setup` delivers bundled fixes.
23
+ - **It links the wrappers** (`codex-exec` / `codex-review`; `agy-run`) onto `PATH` (`~/.local/bin`,
24
+ override with `--bindir`) via **managed symlinks** — replacing only a symlink already pointing at
25
+ our source. It **preflights every target first**, so a conflict on one wrapper makes **zero**
26
+ changes; a non-symlink or a foreign symlink → STOP. Wrapper presence is judged **per-bindir**, not
27
+ PATH-wide. `--dry-run` prints the plan and changes nothing.
28
+ - **The binary install + the interactive subscription login stay manual** — `setup` prints the exact
29
+ commands (the detector's axis-aware `guideFor`), never runs a subscription CLI, never commits. On
30
+ **Windows** it reports *unsupported — use WSL* and mutates nothing (the wrappers are POSIX `.sh`).
31
+ - Internal: the symlink-traversal-safe copy/link primitives are now shared in `tools/fs-safe.mjs`
32
+ (the npx installer consumes them and gained an `isDirectRun` guard so importing it runs nothing).
33
+ The per-package publish workflow now gates the kit on its **whole** test suite, not just the
34
+ shipped enforcement scripts.
35
+
36
+ No `docs/ai` structural change → the deployment-lineage head stays **`1.3.0`**; no migration.
37
+
7
38
  ## 1.6.0 — Methodology slot reconciliation; engine becomes the canonical methodology home
8
39
 
9
40
  The workflow methodology now has a **single canonical home** in `agent-workflow-engine`
package/README.md CHANGED
@@ -216,6 +216,7 @@ command is printed).
216
216
  | `/agent-workflow-kit` | new / empty project | recon → **asks visible-or-hidden** + **conversational language** + **agent attribution** (default off) → deploys `AGENTS.md` + `docs/ai/` filled with real recon data → installs enforcement → **asks before committing** |
217
217
  | `/agent-workflow-kit upgrade` | existing deployment | reads `docs/ai/.workflow-version`, shows the changelog diff, preserves your authored memory, applies migrations, re-stamps |
218
218
  | `/agent-workflow-kit backends` | any time | **read-only** check of the optional execution-backends (the `codex` / `agy` bridges): what's set up vs missing and the next step. Never writes, never commits, never runs a subscription CLI (credentials = marker-file presence, not a live login). |
219
+ | `/agent-workflow-kit setup [backend]` | opt-in, any time | **link-only** auto-setup of a bridge: places the bundled bridge skill (only into an absent / empty / managed dir — never overwrites an unmanaged one) + links its wrappers onto `PATH` via managed symlinks (idempotent; refuses to clobber a non-symlink; try `--dry-run` to preview). The binary install + the one-time subscription login stay **manual**: it prints the exact **login** command and points the binary install at each bridge's `setup/README.md`. POSIX wrappers — on Windows use WSL. Never commits, never runs a subscription CLI. |
219
220
 
220
221
  It **never auto-commits** and **never overwrites** an existing `AGENTS.md` without asking.
221
222
 
@@ -248,17 +249,20 @@ agent-workflow-kit — the composition root (installed via npx … init)
248
249
  ├─ delegates ─▶ memory substrate (healthy copy, else bundled fallback)
249
250
  ├─ injects ─▶ workflow methodology (engine = future supplier; stub)
250
251
  ├─ deploys ─▶ AGENTS.md + docs/ai/ + Node scripts + pre-commit hook
251
- └─ detects ─▶ optional backends (codex / agy — not by init)
252
+ ├─ detects ─▶ optional backends (codex / agy, read-only)
253
+ └─ sets up ─▶ a bridge (opt-in) (place skill + link wrappers)
252
254
  ```
253
255
 
254
256
  - **Delegates** substrate deployment to **`@sabaiway/agent-workflow-memory`** when a healthy
255
257
  standalone copy is present, else uses its **bundled fallback** — same `docs/ai/` either way.
256
258
  - **Injects** the bounded workflow methodology into the deployed `AGENTS.md`. Its *future* home is
257
259
  **`agent-workflow-engine`** — today an `available: false` stub, never one of the shipped backends.
258
- - **Detects** the optional `codex` / `agy` **bridges** — agent skills with a manual once-per-machine
259
- setup (not npm, not installed by `init`); `/agent-workflow-kit backends` reports readiness
260
- read-only. A bridge reads the deployed memory only if it wins that tool's context-file priority,
261
- and the bridges call third-party services (so "no telemetry" covers family code, not those).
260
+ - **Detects & (opt-in) sets up** the optional `codex` / `agy` **bridges** — agent skills (not npm, not
261
+ installed by `init`). `/agent-workflow-kit backends` reports readiness **read-only**;
262
+ `/agent-workflow-kit setup` does the **link-only** part (place the bundled bridge skill + link its
263
+ wrappers), while the binary install + the subscription login stay manual. A bridge reads the deployed
264
+ memory only if it wins that tool's context-file priority, and the bridges call third-party services
265
+ (so "no telemetry" covers family code, not those).
262
266
 
263
267
  > Full member-by-member map + the whole-family story: the
264
268
  > **[family front door](https://github.com/sabaiway/agent-workflow#readme)** — this page stays the
@@ -295,7 +299,10 @@ agent-workflow-kit/
295
299
  │ ├── delegation.mjs ← detect substrate · delegate-or-fall-back
296
300
  │ ├── inject-methodology.mjs ← write the methodology slot
297
301
  │ ├── detect-backends.mjs ← read-only backend detector
302
+ │ ├── setup-backends.mjs ← link-only backend setup
303
+ │ ├── fs-safe.mjs ← symlink-safe copy/link
298
304
  │ └── release-scan.mjs ← attribution / release gate
305
+ ├── bridges/ ← bundled bridge skill mirrors (codex / antigravity)
299
306
  ├── launchers/ ← Codex / Devin Desktop / Cursor entries
300
307
  └── migrations/ ← per-version upgrade steps
301
308
  ```
package/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: agent-workflow-kit
3
3
  description: Deploy or upgrade a portable AI-agent memory-and-workflow system in any project. Use when the user wants to bootstrap `docs/ai/` + an entry-point `AGENTS.md` (+ `CLAUDE.md` alias) + cap/archive/index enforcement in a new or existing repo, set up the Memory Map and session protocols, install the docs-rotation pre-commit hook, or run `/agent-workflow-kit` / `/agent-workflow-kit upgrade`. Triggers on phrases like "set up the memory system", "deploy the AI workflow here", "bootstrap docs/ai", "upgrade the workflow".
4
4
  disable-model-invocation: true
5
5
  metadata:
6
- version: '1.6.0'
6
+ version: '1.7.0'
7
7
  ---
8
8
 
9
9
  # agent-workflow-kit
@@ -83,6 +83,7 @@ Pick the mode from the user's invocation. Auto-detect an existing `docs/ai/` to
83
83
  - **`/agent-workflow-kit`** (default) — bootstrap a new or empty project. If `docs/ai/` already exists, stop and ask whether they meant `upgrade`.
84
84
  - **`/agent-workflow-kit upgrade`** — upgrade an existing deployment to the skill's current `version`.
85
85
  - **`/agent-workflow-kit backends`** — read-only environment check: which optional **execution-backends** (the `codex` / `agy` bridges) are set up vs missing. Never writes, never commits, never runs a subscription CLI.
86
+ - **`/agent-workflow-kit setup [backend]`** — the **link-only**, opt-in companion to `backends`: place the bundled bridge skill + link its wrappers onto `PATH`. **In-agent only** — `init` (npx) never places bridges. The binary install + the interactive subscription login stay **manual** (it prints the exact commands); idempotent; refuses to clobber a non-symlink; never commits, never runs a subscription CLI.
86
87
 
87
88
  ### Mode: bootstrap
88
89
 
@@ -145,6 +146,26 @@ Read-only. Answers *"which optional execution-backends are set up vs missing, an
145
146
  - **"credentials present"** means the credential-marker **file** exists — it is **not** a live login check. The detector never runs `codex login status` / `agy` (that would spawn a paid, slow, networked subscription CLI).
146
147
  - The bridges' wrappers are **POSIX `.sh`** scripts. On Windows the detector still works, but the bridges themselves are **not promised to run** — say so rather than implying they will.
147
148
 
149
+ ### Mode: setup
150
+
151
+ The **only writer** among the backend modes, and **opt-in / in-agent only** — it is **never** part of `init`. The npx installer deploys the *kit* and bundles the bridge skills in its tarball, but **does not place** them (that honesty claim is load-bearing — see `decisions.md` AD-009 / AD-011). `setup` owns exactly the two deterministic, secret-free steps and **guides** the rest. It **never commits and never runs a subscription CLI**.
152
+
153
+ Run `node ${CLAUDE_SKILL_DIR}/tools/setup-backends.mjs [<backend>] [--bindir <path>] [--dry-run]`:
154
+
155
+ - `<backend>` — `codex` | `agy` | `antigravity` | `codex-cli-bridge` | `antigravity-cli-bridge`; omit for **all**.
156
+ - `--bindir <path>` — where to link the wrappers (default `~/.local/bin`).
157
+ - `--dry-run` — print the per-backend plan and change **nothing** (run this first).
158
+ - `--help`, `-h` — usage.
159
+
160
+ For each backend it:
161
+ 1. **Places / refreshes the bundled bridge skill** (from the kit's `bridges/<name>/` mirror) into its canonical dir — but only when that dir is **absent / empty / proven-managed** (valid manifest, matching `name`+`kind`). A `stub` / `foreign` / `invalid` / `unsupported` dir, a marker fs-error, or a symlinked dir → **STOP**, never overwritten. Refresh re-runs on a proven-managed dir so re-running `setup` delivers bundled fixes.
162
+ 2. **Links its wrappers** (`codex-exec` / `codex-review`; `agy-run`) onto `--bindir` via **managed symlinks** — replacing only a symlink that already points at our source. A non-symlink or a foreign symlink → **STOP**; it **preflights every target first**, so a conflict on one wrapper makes **zero** changes. If `--bindir` is not on `PATH`, it prints the one-line `export PATH=…` to add — it never edits a shell rc.
163
+ 3. **Guides the manual, secret-bearing steps it will NOT automate** — the binary install (each bridge's `setup/README.md` §1) and the one-time interactive subscription login (`codex login` / `agy`) — printing the exact command for whichever axis is still missing (axis-aware: it can ask for both the CLI and the login at once).
164
+
165
+ **Windows:** the wrappers are POSIX `.sh`; on `win32` it reports *unsupported — use WSL* and mutates nothing.
166
+
167
+ **Exit codes:** `0` = done / already set up / only manual steps remain (guidance is never a failure); **non-zero** = a STOP (a dir/symlink it refuses to clobber), a bad argument, a missing bundle, or a native fs error (the underlying reason is preserved in the message).
168
+
148
169
  ---
149
170
 
150
171
  ## Gotchas
@@ -214,6 +235,6 @@ Deploy these into `AGENTS.md`; remove rows that don't apply to the stack.
214
235
  - [`references/scripts/`](references/scripts/) — the Node enforcement scripts (caps + staleness + index-freshness gate, 3-tier archive, hook installer) and their unit tests.
215
236
  - [`migrations/`](migrations/) — per-version upgrade steps; see `migrations/README.md`.
216
237
  - [`launchers/`](launchers/) — run the bootstrapper from non-Claude agents (`SKILL.md` is a native Codex skill; a Devin Desktop workflow launcher + install script). See `launchers/README.md`.
217
- - [`tools/`](tools/) — the family-wide tooling the kit **owns and ships**: `manifest/{schema.md,validate.mjs}` (the `capability.json` schema + the validator the kit runs as the memory detector, and root CI invokes), `delegation.mjs` (the executable delegate/fallback decision + hand-off plan), `inject-methodology.mjs` + `methodology-slot.md` (the bounded slot reconciliation — ensure-slot / inject-if-empty / cap; the fragment is a byte-identical mirror of the `agent-workflow-engine` canon, pinned by `methodology-mirror.test.mjs`), `detect-backends.mjs` (the read-only **backend detector** behind `/agent-workflow-kit backends`), and `release-scan.mjs` (the attribution-off release gate). See [`tools/manifest/schema.md`](tools/manifest/schema.md).
238
+ - [`tools/`](tools/) — the family-wide tooling the kit **owns and ships**: `manifest/{schema.md,validate.mjs}` (the `capability.json` schema + the validator the kit runs as the memory detector, and root CI invokes), `delegation.mjs` (the executable delegate/fallback decision + hand-off plan), `inject-methodology.mjs` + `methodology-slot.md` (the bounded slot reconciliation — ensure-slot / inject-if-empty / cap; the fragment is a byte-identical mirror of the `agent-workflow-engine` canon, pinned by `methodology-mirror.test.mjs`), `detect-backends.mjs` (the read-only **backend detector** behind `/agent-workflow-kit backends`, plus the axis-aware `guideFor`), `setup-backends.mjs` (the **link-only** backend setup behind `/agent-workflow-kit setup` — place the bundled bridge + link wrappers), `fs-safe.mjs` (the shared symlink-traversal-safe copy/link primitives both `setup-backends` and the npx installer use), and `release-scan.mjs` (the attribution-off release gate). The bundled bridge skill mirrors live under [`bridges/`](bridges/) (byte-identical to the repo-root bridges, pinned by `test/bridges-mirror.test.mjs`). See [`tools/manifest/schema.md`](tools/manifest/schema.md).
218
239
  - [`capability.json`](capability.json) — the kit's own `agent-workflow` family manifest (`kind: composition-root`).
219
240
  - [`CHANGELOG.md`](CHANGELOG.md) — version history of this kernel.
package/bin/install.mjs CHANGED
@@ -18,19 +18,22 @@
18
18
  //
19
19
  // Dependency-free, Node >= 18.
20
20
 
21
- import { readFile, mkdir, readdir, copyFile, lstat, readlink, symlink } from 'node:fs/promises';
21
+ import { readFile, mkdir } from 'node:fs/promises';
22
22
  import { existsSync, lstatSync } from 'node:fs';
23
- import { dirname, join, resolve, relative, sep, isAbsolute } from 'node:path';
24
- import { fileURLToPath } from 'node:url';
23
+ import { dirname, resolve } from 'node:path';
24
+ import { fileURLToPath, pathToFileURL } from 'node:url';
25
25
  import { homedir } from 'node:os';
26
26
  import { spawnSync } from 'node:child_process';
27
+ import { copyTreeRefresh } from '../tools/fs-safe.mjs';
27
28
 
28
29
  const __dirname = dirname(fileURLToPath(import.meta.url));
29
30
  const PKG_ROOT = resolve(__dirname, '..');
30
31
 
31
32
  // The deployable skill = everything except the npm wrapper (package.json, bin/).
32
33
  // capability.json (the family manifest) + tools/ (the family schema + validator the kit runs
33
- // as the memory detector) must land in the installed skill dir too.
34
+ // as the memory detector) must land in the installed skill dir too. bridges/ carries the
35
+ // byte-identical execution-backend skill mirrors (codex/antigravity) so `setup` can place a bridge
36
+ // from the installed kit, with no network fetch (Plan B / AD-011).
34
37
  const PAYLOAD = [
35
38
  'SKILL.md',
36
39
  'README.md',
@@ -40,6 +43,7 @@ const PAYLOAD = [
40
43
  'launchers',
41
44
  'migrations',
42
45
  'tools',
46
+ 'bridges',
43
47
  ];
44
48
 
45
49
  const tildify = (path) => path.replace(homedir(), '~');
@@ -64,42 +68,10 @@ const lstatNoFollow = (path) => {
64
68
  }
65
69
  };
66
70
 
67
- // Symlink-traversal guard: refuse to write *through* any symlink at or above `dest` within
68
- // `root` (root / intermediate dir / leaf, including a dangling one), or to a dest outside `root`.
69
- const assertContainedRealPath = (root, dest) => {
70
- const rel = relative(root, dest);
71
- if (rel.startsWith('..') || isAbsolute(rel)) {
72
- throw new Error(`[agent-workflow-kit] refusing to write outside the target dir: ${dest}`);
73
- }
74
- if (lstatNoFollow(root)?.isSymbolicLink()) {
75
- throw new Error(`[agent-workflow-kit] refusing to install into a symlinked target dir: ${root}`);
76
- }
77
- const walk = (acc, part) => {
78
- const cur = join(acc, part);
79
- if (lstatNoFollow(cur)?.isSymbolicLink()) {
80
- throw new Error(`[agent-workflow-kit] refusing to write through a symlink at ${cur} (would escape ${root}).`);
81
- }
82
- return cur;
83
- };
84
- rel.split(sep).filter(Boolean).reduce(walk, root);
85
- };
86
-
87
- const copyRecursive = async (src, dest, root) => {
88
- assertContainedRealPath(root, dest); // never write through a dest symlink (root/intermediate/leaf)
89
- const stat = await lstat(src);
90
- if (stat.isSymbolicLink()) {
91
- if (existsSync(dest)) return; // additive: never delete/replace an existing entry
92
- const linkTarget = await readlink(src);
93
- await symlink(linkTarget, dest);
94
- } else if (stat.isDirectory()) {
95
- await mkdir(dest, { recursive: true });
96
- const entries = await readdir(src);
97
- await Promise.all(entries.map((entry) => copyRecursive(join(src, entry), join(dest, entry), root)));
98
- } else {
99
- await mkdir(dirname(dest), { recursive: true });
100
- await copyFile(src, dest);
101
- }
102
- };
71
+ // The symlink-traversal guard + the recursive refresh copy now live in tools/fs-safe.mjs (shared,
72
+ // dependency-injectable, unit-tested in isolation). install.mjs consumes copyTreeRefresh, which guards
73
+ // every dest via assertContainedRealPath internally. The local lstatNoFollow above stays for the
74
+ // pre-flight check on the target root itself (a nicer error than letting the copy throw).
103
75
 
104
76
  const parseArgs = (argv) => {
105
77
  const dirFlag = argv.indexOf('--dir');
@@ -150,7 +122,15 @@ const main = async () => {
150
122
 
151
123
  // Critical payload must be present, or the install would silently ship a kit that can't run
152
124
  // its own detector (tools/) or family contract (capability.json). Fail loudly, don't filter away.
153
- const REQUIRED = ['SKILL.md', 'capability.json', 'references', 'tools', 'migrations'];
125
+ const REQUIRED = [
126
+ 'SKILL.md',
127
+ 'capability.json',
128
+ 'references',
129
+ 'tools',
130
+ 'migrations',
131
+ 'bridges/codex-cli-bridge',
132
+ 'bridges/antigravity-cli-bridge',
133
+ ];
154
134
  const missing = REQUIRED.filter((entry) => !existsSync(resolve(PKG_ROOT, entry)));
155
135
  if (missing.length > 0) {
156
136
  console.error(`[agent-workflow-kit] package payload incomplete — missing: ${missing.join(', ')} (corrupt install?)`);
@@ -164,11 +144,9 @@ const main = async () => {
164
144
  process.exit(1);
165
145
  }
166
146
  await mkdir(target, { recursive: true });
167
- await Promise.all(
168
- PAYLOAD.filter((entry) => existsSync(resolve(PKG_ROOT, entry))).map((entry) =>
169
- copyRecursive(resolve(PKG_ROOT, entry), resolve(target, entry), target),
170
- ),
171
- );
147
+ for (const entry of PAYLOAD.filter((e) => existsSync(resolve(PKG_ROOT, e)))) {
148
+ copyTreeRefresh(resolve(PKG_ROOT, entry), resolve(target, entry), target);
149
+ }
172
150
  console.log(`[agent-workflow-kit] ${wasPresent ? 'updated the kit to' : 'installed'} v${version} -> ${tildify(target)}`);
173
151
 
174
152
  // Wire non-Claude agents — best-effort; the launcher only touches tools you have.
@@ -198,7 +176,12 @@ This command only installs/updates the kit itself (in ${tildify(target)}).
198
176
  To update the kit later, re-run: npx @sabaiway/agent-workflow-kit@latest init`);
199
177
  };
200
178
 
201
- main().catch((err) => {
202
- console.error(err);
203
- process.exit(1);
204
- });
179
+ // Run main() only when executed directly (npx / node bin/install.mjs), never on import — so tests
180
+ // can import this module to assert it has no side effects. Same idiom as tools/detect-backends.mjs.
181
+ const isDirectRun = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;
182
+ if (isDirectRun) {
183
+ main().catch((err) => {
184
+ console.error(err);
185
+ process.exit(1);
186
+ });
187
+ }
@@ -5,9 +5,10 @@ import { mkdtemp, rm, mkdir, symlink, readdir } from 'node:fs/promises';
5
5
  import { existsSync } from 'node:fs';
6
6
  import { tmpdir } from 'node:os';
7
7
  import { dirname, join } from 'node:path';
8
- import { fileURLToPath } from 'node:url';
8
+ import { fileURLToPath, pathToFileURL } from 'node:url';
9
9
 
10
10
  const INSTALLER = join(dirname(fileURLToPath(import.meta.url)), 'install.mjs');
11
+ const KIT_ROOT = dirname(dirname(INSTALLER));
11
12
  // --no-launchers so the test never wires Codex/Devin on the host.
12
13
  const runInstaller = (target) =>
13
14
  spawnSync(process.execPath, [INSTALLER, '--dir', target, '--no-launchers'], { encoding: 'utf8' });
@@ -64,3 +65,31 @@ describe('kit installer — payload + symlink-traversal hardening', () => {
64
65
  assert.deepEqual(await readdir(real), []);
65
66
  });
66
67
  });
68
+
69
+ describe('kit installer — module hygiene', () => {
70
+ it('importing install.mjs runs nothing (main() is guarded by isDirectRun)', () => {
71
+ // `node -e` has no argv[1], so isDirectRun is false → importing must not run main()
72
+ // (no FS writes, no exit). A child process keeps the assertion off the test runner's own state.
73
+ const url = JSON.stringify(pathToFileURL(INSTALLER).href);
74
+ const res = spawnSync(
75
+ process.execPath,
76
+ ['--input-type=module', '-e', `import(${url}).then(() => console.log('IMPORT_OK'));`],
77
+ { encoding: 'utf8' },
78
+ );
79
+ assert.equal(res.status, 0, res.stderr);
80
+ assert.match(res.stdout, /IMPORT_OK/);
81
+ assert.doesNotMatch(res.stdout, /installed v|updated the kit/);
82
+ });
83
+ });
84
+
85
+ describe('kit installer — published tarball bundles the bridges', () => {
86
+ it('npm pack ships bridges/<name>/ (the execution-backend skill mirrors)', () => {
87
+ // The real `files` whitelist decides what publishes — assert against `npm pack`, not the source
88
+ // tree, so a dropped `bridges/` entry in package.json fails here (not silently at install time).
89
+ const res = spawnSync('npm', ['pack', '--dry-run', '--json'], { cwd: KIT_ROOT, encoding: 'utf8' });
90
+ assert.equal(res.status, 0, res.stderr || res.error?.message);
91
+ const paths = JSON.parse(res.stdout)[0].files.map((f) => f.path);
92
+ assert.ok(paths.includes('bridges/codex-cli-bridge/SKILL.md'), 'codex bridge SKILL.md not packed');
93
+ assert.ok(paths.includes('bridges/antigravity-cli-bridge/bin/agy.sh'), 'antigravity agy.sh not packed');
94
+ });
95
+ });
@@ -0,0 +1,178 @@
1
+ ---
2
+ name: antigravity-cli-bridge
3
+ description: Delegate work to Google's Antigravity CLI (`agy`) — the successor to Gemini CLI — to reach Gemini, Claude, and GPT-OSS models under a Google AI Pro/Ultra subscription from the terminal. Use when the user wants to run a headless `agy` prompt, hand a focused task or second-opinion review to `agy`, install or authenticate Antigravity CLI, check or economise its quota/models, bridge project context into `agy`, set up a second delegated-execution backend beside Codex, or troubleshoot `agy` flags, models, auth, conversations, or its no-JSON headless behaviour.
4
+ metadata:
5
+ version: '1.0.0'
6
+ ---
7
+
8
+ # antigravity-cli-bridge
9
+
10
+ Bridges the main agent to **Antigravity CLI** (`agy`), Google's successor to Gemini CLI. As of
11
+ 2026-06-18 the old Gemini CLI stopped serving Google AI Pro / Ultra / free tiers; terminal access to
12
+ Google's models moved to `agy`. This is a **delegated-execution backend** beside Codex: the main
13
+ agent stays the orchestrator — owning decisions, edits, verification, and user-facing claims — and
14
+ hands `agy` a bounded, self-contained sub-task answered from the **subscription** quota (no
15
+ pay-as-you-go billing). `agy` reaches Gemini, Claude, and GPT-OSS through one subscription, so it
16
+ serves as both a cheap probe engine (Flash) and a strong second opinion (Pro / Claude Thinking).
17
+
18
+ ## Overview / when to use
19
+
20
+ Use this skill when the user wants to:
21
+
22
+ - Delegate a focused prompt to `agy` in headless mode.
23
+ - Use Gemini, Claude, or GPT-OSS access available through a Google AI Pro/Ultra subscription.
24
+ - Ask a second model to review a plan, summarise project context, or critique a diff supplied in the
25
+ prompt.
26
+ - Install, authenticate, smoke-test, or troubleshoot `agy`, or understand its models/flags/quota.
27
+
28
+ Do **not** use it to bundle secrets, bypass subscription auth, or hand uncontrolled repository
29
+ mutations to `agy`.
30
+
31
+ ## Install
32
+
33
+ Clean-machine setup is in [`setup/README.md`](setup/README.md). In short: the binary is **`agy`**
34
+ (not `antigravity`), installs to `~/.local/bin/agy`, and must be on `PATH`; expose this skill's
35
+ wrapper [`bin/agy.sh`](bin/agy.sh) on `PATH` as `agy-run`.
36
+
37
+ ## Auth — subscription only (invariant)
38
+
39
+ `agy` authenticates with a cached **OAuth token** from a **Google AI Pro/Ultra** sign-in:
40
+
41
+ ```text
42
+ ~/.gemini/antigravity-cli/antigravity-oauth-token
43
+ ```
44
+
45
+ Never read, print, copy, commit, or package that token — it is personal and is **never bundled** with
46
+ this skill. The wrapper [`bin/agy.sh`](bin/agy.sh) **unsets every `*_API_KEY`** (`ANTIGRAVITY_API_KEY`,
47
+ `GEMINI_API_KEY`, `GOOGLE_API_KEY`, `GOOGLE_GENAI_API_KEY`) before invoking `agy`, so a stray key can
48
+ never silently switch you to pay-as-you-go billing.
49
+
50
+ **Caveat:** the subscription has a finite quota. Prefer the cheapest model that fits the task, and
51
+ keep probes short (see *How the main agent drives agy*).
52
+
53
+ ## Models
54
+
55
+ Pass the **exact display string** to `--model` (or set `AGY_MODEL`). The wrapper defaults to
56
+ `Gemini 3.1 Pro (High)`. Run `agy models` for the live list — if it differs from this table, the live
57
+ list wins.
58
+
59
+ | Model string | Use it for |
60
+ |---|---|
61
+ | `Gemini 3.5 Flash (Low)` | cheapest; reachability checks, smoke tests, simple transforms |
62
+ | `Gemini 3.5 Flash (Medium)` | cheap probes, context-reachability checks, quick summaries |
63
+ | `Gemini 3.5 Flash (High)` | fast drafting / review when a little more effort helps |
64
+ | `Gemini 3.1 Pro (Low)` | cheaper Pro pass for medium reasoning |
65
+ | `Gemini 3.1 Pro (High)` | wrapper default; hard reasoning, plan critique, architecture review |
66
+ | `Claude Sonnet 4.6 (Thinking)` | a Claude second opinion through the same subscription |
67
+ | `Claude Opus 4.6 (Thinking)` | strongest Claude reasoning available via `agy` |
68
+ | `GPT-OSS 120B (Medium)` | an open-weights cross-check / diversity pass |
69
+
70
+ ## Usage
71
+
72
+ Drive `agy` only through the wrapper [`bin/agy.sh`](bin/agy.sh) (installed on `PATH` as `agy-run`):
73
+
74
+ ```bash
75
+ agy-run "your prompt" # prompt as an argument
76
+ echo "your prompt" | agy-run - # prompt from stdin
77
+ agy-run @path/to/prompt.md # prompt from a file
78
+ AGY_MODEL="Claude Opus 4.6 (Thinking)" agy-run "..." # pick a model
79
+ AGY_TIMEOUT=10m agy-run "..." # agy's soft --print-timeout
80
+ AGY_HARD_TIMEOUT=8m agy-run "..." # hard wall-clock cap via timeout(1)
81
+ agy-run "..." -- --add-dir . --dangerously-skip-permissions # passthrough agy flags
82
+ ```
83
+
84
+ `agy` is **headless-only** here (`-p`/`--print`) and there is **no JSON output mode** in v1.0.10 — you
85
+ get plain text. If you need structure, ask for Markdown with explicit headings and validate it
86
+ yourself. Wrapper inputs: first argument is the prompt (`text`, `-` for stdin, or `@file`);
87
+ `AGY_MODEL` (default `Gemini 3.1 Pro (High)`); `AGY_TIMEOUT` → `--print-timeout` (default `5m`);
88
+ `AGY_HARD_TIMEOUT` → hard `timeout(1)` wall-clock cap (default = `AGY_TIMEOUT`); extra `agy` flags
89
+ after `--`. Full detail: [`references/models-and-flags.md`](references/models-and-flags.md).
90
+
91
+ ## Project context (how `agy` sees the repo)
92
+
93
+ From its **current working directory** `agy` reads one root context file by priority, plus
94
+ per-workspace skills:
95
+
96
+ ```text
97
+ .antigravity.md > GEMINI.md > AGENTS.md
98
+ .agents/skills/
99
+ ```
100
+
101
+ So when you run `agy-run` from a project root, `agy` loads the **highest-priority context file that
102
+ exists** — in most repos that is `AGENTS.md`, so its Hard Constraints are available — plus the
103
+ project's `.agents/skills/`, with no wiring needed. **A `.antigravity.md` or `GEMINI.md`, if present,
104
+ shadows `AGENTS.md`** (only the winning file is read), so put cross-cutting rules in whichever file
105
+ wins, or include them in the prompt. Probe results in a real repo confirmed `agy` read the root
106
+ `AGENTS.md` (returning the dialogue language + a Hard Constraint) and cited
107
+ `.agents/skills/<skill>/SKILL.md` by path.
108
+
109
+ **Honest scope:** these probes prove *reachability* — `agy` surfaces the cwd context file and
110
+ per-workspace skills by directory scan. In testing it also **named a project-specific skill without
111
+ being pointed at any file** (auto-discovery), but that is `agy`'s own mechanism, not a guaranteed
112
+ Claude-style description-dispatch engine; don't promise more than the probe shows in a given repo.
113
+ Re-runnable from a project root (use a cheap model):
114
+
115
+ ```bash
116
+ AGY_MODEL="Gemini 3.5 Flash (Low)" agy-run \
117
+ "Read the cwd context file and state the dialogue language plus one Hard Constraint, in two lines."
118
+ AGY_MODEL="Gemini 3.5 Flash (Low)" agy-run \
119
+ "Without me pointing you at any file, name a project-specific skill under .agents/skills/ here and cite its path."
120
+ ```
121
+
122
+ ## How the main agent drives `agy` efficiently
123
+
124
+ See [`references/driving-agy.md`](references/driving-agy.md) for the full playbook (delegation
125
+ checklist, prompt templates, output handling). Essentials:
126
+
127
+ - **Pick the cheapest model that fits.** Flash (Low/Medium) for reachability/probes; Pro (High) for
128
+ reasoning; `Claude Sonnet 4.6 (Thinking)`, `Claude Opus 4.6 (Thinking)`, or `GPT-OSS 120B (Medium)`
129
+ for a different engine's opinion (exact strings — see the Models table) — all on the same
130
+ subscription. Quota is finite, so don't reach for Pro by reflex.
131
+ - **Hand `agy` a self-contained prompt.** It cannot see your conversation — embed the goal,
132
+ constraints, relevant excerpts, and the expected output shape; nothing more.
133
+ - **Continue a thread** with `-- --continue` (most recent) or `-- --conversation <id>` (by id) instead
134
+ of re-sending context.
135
+ - **Treat output as advisory** and verify before acting — check claims against local files, re-run
136
+ tests/linters yourself, reject advice that conflicts with user instructions or repo rules.
137
+ - **Escalations are done by hand, not by `agy`.** The wrapper passes no `--add-dir`, no
138
+ `--dangerously-skip-permissions`, and no `--sandbox` — but that is a **policy boundary you state in
139
+ the prompt, not an enforced sandbox**. Keep repo edits, new dependencies/network installs, and git
140
+ writes (branch/add/commit/stash/reset/rewrite) with the orchestrator, and tell `agy` in the prompt
141
+ to return findings only. Add `-- --sandbox` when delegating anything that could trigger
142
+ terminal/tool work; opt into `-- --add-dir . --dangerously-skip-permissions` only for a flow that
143
+ genuinely needs writes, then review the diff afterwards.
144
+
145
+ ## Complementary skills (optional, standalone-first)
146
+
147
+ `agy-run` works in any directory where `agy` is installed and authenticated. The two skills below are
148
+ **not required** to use `agy` — surface them only when they actually help.
149
+
150
+ - **`agent-workflow-memory`** (family **context provider**) — if the current project has **no**
151
+ `AGENTS.md` + `docs/ai/`, `agy` has no per-workspace context to read. The memory substrate creates
152
+ it. Soft-recommend it (only when the user wants the memory workflow):
153
+ `npx @sabaiway/agent-workflow-memory init`, then `/agent-workflow-memory` in the project — or
154
+ bootstrap the whole family via the **`agent-workflow-kit`** orchestrator
155
+ (`npx @sabaiway/agent-workflow-kit init`), which delegates substrate deployment to memory. Never a
156
+ prerequisite for using `agy`.
157
+ - **`codex-cli-bridge`** (sibling backend, OpenAI Codex) — recommend **by actual presence**: if
158
+ `~/.claude/skills/codex-cli-bridge/` exists you have a **second delegated engine** (Codex for
159
+ sandboxed repo edits with gates; `agy` for subscription-quota Gemini/Claude reasoning). If it is
160
+ **not** installed, treat it as a **planned sibling** — don't assume it exists.
161
+
162
+ ## Known limitations
163
+
164
+ - Subdirectory `CLAUDE.md` files are **not** auto-loaded by `agy` (only the cwd context file +
165
+ `.agents/skills/`). Put cross-cutting rules in the root context file, or include local rules in the
166
+ prompt when they matter.
167
+ - **No JSON output** and **no `agy inspect`** in v1.0.10 — parse text; there is no machine-readable
168
+ introspection.
169
+ - Model names must match the `agy models` display strings **exactly**.
170
+ - **Quota is finite.** Heavy use of Pro/Claude models can exhaust the subscription; prefer Flash for
171
+ cheap work.
172
+ - **A run can't hang forever.** The wrapper caps `agy` with `timeout(1)` (`AGY_HARD_TIMEOUT`,
173
+ default = `AGY_TIMEOUT`) because `agy`'s own `--print-timeout` is **not** a reliable wall-clock
174
+ kill (a run was seen surviving 32 min past a 10m `--print-timeout`). A heavy `--add-dir` agentic
175
+ prompt on the slowest model (`Gemini 3.1 Pro (High)`) can run unbounded — prefer a faster model or
176
+ a **self-contained prompt** (no `--add-dir`); an "exceeded the hard cap" error is the guard firing.
177
+ - `agy` output is plain text and may be incomplete or out of date — treat it as advisory until the
178
+ main agent verifies it.
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env bash
2
+ # Universal, neutral wrapper around Google's Antigravity CLI (`agy`).
3
+ #
4
+ # Antigravity CLI is the successor to Gemini CLI: as of 2026-06-18 the old
5
+ # Gemini CLI stopped serving Google AI Pro / Ultra / free tiers, and access to
6
+ # Google's models from the terminal moved to `agy`. This wrapper is the single
7
+ # entry point so callers never have to remember the flag spelling.
8
+ #
9
+ # Auth: SUBSCRIPTION ONLY. We use the cached OAuth token at
10
+ # ~/.gemini/antigravity-cli/antigravity-oauth-token (Google AI Pro) and the
11
+ # quota that comes with it. To make that guarantee hard, the wrapper unsets any
12
+ # API-key env var so a stray key can never silently switch us to paid
13
+ # pay-as-you-go billing.
14
+ #
15
+ # This is a THIN, FLOW-AGNOSTIC wrapper on purpose: it just runs one headless
16
+ # prompt and prints the text response. It does NOT encode any orchestration
17
+ # policy (no plan contract, no auto-approve, no workspace edits) — that is left
18
+ # to whatever flow we design later, which can opt in via passthrough flags.
19
+ #
20
+ # Models (pass the exact display string from `agy models`, or set AGY_MODEL):
21
+ # Gemini 3.5 Flash (Low|Medium|High), Gemini 3.1 Pro (Low|High),
22
+ # Claude Sonnet 4.6 (Thinking), Claude Opus 4.6 (Thinking), GPT-OSS 120B (Medium)
23
+ #
24
+ # Usage (installed on PATH as `agy-run`):
25
+ # agy-run "your prompt" # prompt as an argument
26
+ # echo "your prompt" | agy-run - # prompt from stdin
27
+ # agy-run @path/to/prompt.md # prompt from a file
28
+ # AGY_MODEL="Claude Opus 4.6 (Thinking)" agy-run "..." # pick a model
29
+ # AGY_TIMEOUT=10m agy-run "..." # override print timeout (agy's soft bound)
30
+ # AGY_HARD_TIMEOUT=8m agy-run "..." # override the hard wall-clock cap (timeout(1))
31
+ # agy-run "..." -- --add-dir . --dangerously-skip-permissions
32
+ # # passthrough agy flags (future flows)
33
+ set -euo pipefail
34
+
35
+ # 1. Make `agy` findable even when ~/.bashrc was not sourced.
36
+ export PATH="$HOME/.local/bin:$PATH"
37
+
38
+ # 2. Force the subscription path: never let an API key hijack billing. Unset EVERY *_API_KEY for the
39
+ # agy subprocess — the explicit Google/Antigravity ones first, then any other *_API_KEY that may
40
+ # have been added later (`compgen` is a bash builtin; the shebang guarantees bash).
41
+ unset ANTIGRAVITY_API_KEY GEMINI_API_KEY GOOGLE_API_KEY GOOGLE_GENAI_API_KEY 2>/dev/null || true
42
+ while IFS= read -r _api_key_var; do
43
+ unset "$_api_key_var" 2>/dev/null || true
44
+ done < <(compgen -v 2>/dev/null | grep '_API_KEY$' || true)
45
+
46
+ if ! command -v agy >/dev/null 2>&1; then
47
+ echo "error: 'agy' (Antigravity CLI) not found on PATH. Install it and run 'agy' once to sign in." >&2
48
+ exit 127
49
+ fi
50
+
51
+ # `-` (empty) => skip --model and let agy use settings.json; default to Pro.
52
+ AGY_MODEL="${AGY_MODEL-Gemini 3.1 Pro (High)}"
53
+ AGY_TIMEOUT="${AGY_TIMEOUT:-5m}"
54
+ # Hard wall-clock cap (defaults to AGY_TIMEOUT). agy's own --print-timeout is NOT a reliable
55
+ # wall-clock kill — a run was observed surviving 32 min past a 10m --print-timeout — so we also wrap
56
+ # agy in timeout(1). A heavy `--add-dir` agentic prompt on the slowest model can otherwise run
57
+ # unbounded, and once a caller backgrounds it nothing kills it. Raise only for a known-healthy run.
58
+ AGY_HARD_TIMEOUT="${AGY_HARD_TIMEOUT:-$AGY_TIMEOUT}"
59
+
60
+ if [[ $# -lt 1 ]]; then
61
+ echo "usage: $0 <prompt | - | @file> [-- extra agy flags...]" >&2
62
+ exit 2
63
+ fi
64
+
65
+ prompt_src="$1"; shift
66
+
67
+ # Split off any passthrough flags after a literal `--`. Extra args WITHOUT the `--` separator are a
68
+ # mistake — they would be silently dropped, so fail loudly instead (no silent failures).
69
+ passthrough=()
70
+ if [[ $# -gt 0 ]]; then
71
+ if [[ "$1" == "--" ]]; then
72
+ shift
73
+ passthrough=("$@")
74
+ else
75
+ echo "error: unexpected argument '$1'. Pass extra agy flags after a literal '--':" >&2
76
+ echo " $0 <prompt | - | @file> -- <agy flags...>" >&2
77
+ exit 2
78
+ fi
79
+ fi
80
+
81
+ if [[ "$prompt_src" == "-" ]]; then
82
+ prompt="$(cat)"
83
+ elif [[ "${prompt_src:0:1}" == "@" ]]; then
84
+ file="${prompt_src:1}"
85
+ if [[ ! -f "$file" ]]; then
86
+ echo "error: prompt file '$file' not found" >&2
87
+ exit 2
88
+ fi
89
+ prompt="$(cat "$file")"
90
+ else
91
+ prompt="$prompt_src"
92
+ fi
93
+
94
+ if [[ -z "${prompt// }" ]]; then
95
+ echo "error: empty prompt" >&2
96
+ exit 2
97
+ fi
98
+
99
+ model_flag=()
100
+ if [[ -n "$AGY_MODEL" ]]; then
101
+ model_flag=(--model "$AGY_MODEL")
102
+ fi
103
+
104
+ agy_cmd=(agy "${model_flag[@]}" --print-timeout "$AGY_TIMEOUT" "${passthrough[@]}" -p "$prompt")
105
+
106
+ # Hard wall-clock cap via timeout(1) (GNU `timeout` on Linux, `gtimeout` from coreutils on macOS).
107
+ # This is the real guard — a backgrounded, hung agy survives its own --print-timeout otherwise.
108
+ timeout_bin=""
109
+ if command -v timeout >/dev/null 2>&1; then
110
+ timeout_bin="timeout"
111
+ elif command -v gtimeout >/dev/null 2>&1; then
112
+ timeout_bin="gtimeout"
113
+ fi
114
+
115
+ if [[ -z "$timeout_bin" ]]; then
116
+ echo "warning: no 'timeout'/'gtimeout' on PATH — running agy WITHOUT a hard wall-clock cap" >&2
117
+ echo " (install coreutils to enable AGY_HARD_TIMEOUT=$AGY_HARD_TIMEOUT)." >&2
118
+ exec "${agy_cmd[@]}"
119
+ fi
120
+
121
+ # --kill-after: if agy ignores the initial TERM, SIGKILL it 10s later. Capture rc (don't `exec`) so
122
+ # we can turn a timeout into an explicit, actionable error instead of a silent non-zero.
123
+ set +e
124
+ "$timeout_bin" --kill-after=10s "$AGY_HARD_TIMEOUT" "${agy_cmd[@]}"
125
+ rc=$?
126
+ set -e
127
+ if [[ $rc -eq 124 || $rc -eq 137 ]]; then
128
+ echo "error: agy exceeded the hard cap AGY_HARD_TIMEOUT=$AGY_HARD_TIMEOUT and was terminated." >&2
129
+ echo " This usually means a heavy '--add-dir' agentic run, or the slowest model looping." >&2
130
+ echo " Retry with a faster model (e.g. AGY_MODEL='Gemini 3.5 Flash (High)') or a" >&2
131
+ echo " self-contained prompt without --add-dir. Raise AGY_HARD_TIMEOUT only if the run is healthy." >&2
132
+ fi
133
+ exit $rc