claude-everything-workflow 0.2.10 → 0.2.11

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.
@@ -7,6 +7,7 @@ const path = require("node:path");
7
7
  const crypto = require("node:crypto");
8
8
  const { spawnSync } = require("node:child_process");
9
9
  const { installRules, finalizeBackups, BACKUP_ROOT_NAME } = require("../install-rules");
10
+ const { installAntigravity, parseFrontmatter, mapTools } = require("../install-antigravity");
10
11
 
11
12
  const sourceRoot = path.resolve(__dirname, "../..");
12
13
  const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "cew-rules-"));
@@ -177,13 +178,63 @@ function checkCodexImplementationRuleUpgrades() {
177
178
  assert.equal(read(stock), read(source), "a known older distribution still upgrades");
178
179
  }
179
180
 
181
+ function checkAntigravityImplementationRuleUpgrades() {
182
+ const fixture = path.join(tempRoot, "ag-rule-source");
183
+ const filename = "02-implementation.md";
184
+ const source = path.join(fixture, "rules", filename);
185
+ const old = [
186
+ "# Implementation",
187
+ "Scope: fix bugs.",
188
+ "",
189
+ "# Checks",
190
+ "Run unit tests.",
191
+ "",
192
+ ].join("\n");
193
+ const hash = crypto.createHash("sha256").update(old).digest("hex");
194
+ fs.mkdirSync(path.join(fixture, "rules/common"), { recursive: true });
195
+ fs.mkdirSync(path.join(fixture, "scripts"));
196
+ fs.writeFileSync(source, old);
197
+ fs.writeFileSync(path.join(fixture, "rules/common/testing.md"), "Run checks.\n");
198
+ fs.writeFileSync(path.join(fixture, "scripts/legacy-common-rule-hashes.json"),
199
+ JSON.stringify({ files: { [filename]: [hash] } }));
200
+
201
+ const installRoot = path.join(tempRoot, "ag-rule-install");
202
+ const active = path.join(installRoot, "references/rules", filename);
203
+ const base = path.join(installRoot, ".cew-rule-state/02-implementation.base.md");
204
+ const incoming = path.join(installRoot, ".cew-rule-state/02-implementation.incoming.md");
205
+ const run = () => installRules({ sourceRoot: fixture, installRoot, host: "antigravity", log: () => {} });
206
+
207
+ run();
208
+ assert.equal(fs.existsSync(path.join(installRoot, "rules", filename)), false,
209
+ "Antigravity must keep detailed rules out of auto-loaded rules/");
210
+ assert.equal(read(active), old);
211
+ assert.equal(read(path.join(installRoot, "references/rules/common/testing.md")), "Run checks.\n");
212
+
213
+ const personal = old.replace("fix bugs.", "fix bugs. Leave unrelated work alone.").replace(/\n/g, "\r\n");
214
+ fs.writeFileSync(active, personal);
215
+ const updated = old.replace("unit tests", "unit and integration tests");
216
+ fs.writeFileSync(source, updated);
217
+ run();
218
+ const merged = personal.replace("unit tests", "unit and integration tests");
219
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "Antigravity merges independent upstream edits");
220
+
221
+ fs.writeFileSync(source, updated.replace("Scope: fix bugs.", "Scope: add features."));
222
+ run();
223
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "overlapping edits keep personal rule intact");
224
+ assert.equal(read(base), updated);
225
+ assert.equal(read(incoming), read(source));
226
+ }
227
+
180
228
  function checkInstallerCliOptions() {
181
229
  const profile = path.join(tempRoot, "invalid-cli-profile");
182
230
  for (const [options, message] of [
183
231
  [["--unknown-option"], /Unknown option: --unknown-option/],
184
232
  [["--claude-only", "--codex-only"], /cannot be used together/],
185
233
  [["--codex-only", "--claude-only"], /cannot be used together/],
234
+ [["--claude-only", "--antigravity-only"], /cannot be used together/],
235
+ [["--codex-only", "--antigravity-only"], /cannot be used together/],
186
236
  [["--claude-only", "--codex-only", "--help"], /cannot be used together/],
237
+ [["--antigravity-only", "--claude-only", "--help"], /cannot be used together/],
187
238
  ]) {
188
239
  const result = spawnSync(process.execPath, [
189
240
  path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install", ...options,
@@ -195,7 +246,7 @@ function checkInstallerCliOptions() {
195
246
  assert.notEqual(result.status, 0, "invalid CLI options must fail before installation");
196
247
  assert.match(result.stderr, message);
197
248
  }
198
- for (const host of [".claude", ".codex"]) {
249
+ for (const host of [".claude", ".codex", ".gemini"]) {
199
250
  assert.equal(fs.existsSync(path.join(profile, host)), false);
200
251
  }
201
252
  for (const help of ["--help", "-h"]) {
@@ -208,7 +259,7 @@ function checkInstallerCliOptions() {
208
259
  assert.ifError(result.error);
209
260
  assert.equal(result.status, 0, "install help must succeed without installing");
210
261
  assert.match(result.stdout, /Usage:/);
211
- for (const host of [".claude", ".codex"]) {
262
+ for (const host of [".claude", ".codex", ".gemini"]) {
212
263
  assert.equal(fs.existsSync(path.join(profile, host)), false);
213
264
  }
214
265
  }
@@ -222,6 +273,8 @@ function checkBashHelpOptions() {
222
273
  ["--help", "--claude-only", "--codex-only"],
223
274
  ["--claude-only", "--help", "--codex-only"],
224
275
  ["--claude-only", "--codex-only", "--help"],
276
+ ["--help", "--antigravity-only", "--codex-only"],
277
+ ["--claude-only", "--antigravity-only", "--help"],
225
278
  ["--help", "--unknown-option"],
226
279
  ["--unknown-option", "--help"],
227
280
  ];
@@ -238,14 +291,18 @@ function checkBashHelpOptions() {
238
291
  assert.notEqual(result.status, 0, `Bash must reject invalid options even with help: ${options.join(" ")}`);
239
292
  assert.match(result.stderr, /Unknown option|cannot be used together/);
240
293
  }
241
- for (const host of [".claude", ".codex"]) {
294
+ for (const host of [".claude", ".codex", ".gemini"]) {
242
295
  assert.equal(fs.existsSync(path.join(profile, host)), false);
243
296
  }
244
297
  }
245
298
  }
246
299
 
247
300
  function checkInstallerLinkedRoots() {
248
- for (const host of [".claude", ".codex"]) {
301
+ for (const [host, flag] of [
302
+ [".claude", "--claude-only"],
303
+ [".codex", "--codex-only"],
304
+ [".gemini", "--antigravity-only"],
305
+ ]) {
249
306
  const profile = path.join(tempRoot, "linked-profile" + host);
250
307
  const outside = path.join(tempRoot, "linked-outside" + host);
251
308
  fs.mkdirSync(profile);
@@ -253,8 +310,7 @@ function checkInstallerLinkedRoots() {
253
310
  fs.writeFileSync(path.join(outside, "AGENTS.md"), "Keep external user content\n");
254
311
  fs.symlinkSync(outside, path.join(profile, host), process.platform === "win32" ? "junction" : "dir");
255
312
  const result = spawnSync(process.execPath, [
256
- path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install",
257
- host === ".claude" ? "--claude-only" : "--codex-only",
313
+ path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install", flag,
258
314
  ], {
259
315
  cwd: sourceRoot,
260
316
  env: {
@@ -313,9 +369,11 @@ function checkInstallerEntrypoint() {
313
369
  assert.notEqual(invalid.status, 0, "direct installer must reject unknown options before writing");
314
370
  assert.equal(fs.existsSync(path.join(profile, ".claude")), false);
315
371
  assert.equal(fs.existsSync(path.join(profile, ".codex")), false);
372
+ assert.equal(fs.existsSync(path.join(profile, ".gemini")), false);
316
373
  for (const only of [
317
374
  windows ? ["-ClaudeOnly", "-CodexOnly"] : ["--claude-only", "--codex-only"],
318
375
  windows ? ["-CodexOnly", "-ClaudeOnly"] : ["--codex-only", "--claude-only"],
376
+ windows ? ["-ClaudeOnly", "-AntigravityOnly"] : ["--claude-only", "--antigravity-only"],
319
377
  ]) {
320
378
  const conflict = spawnSync(executable, [...args, ...only], {
321
379
  cwd: sourceRoot, env, encoding: "utf8", timeout: 60000, maxBuffer: 8 * 1024 * 1024,
@@ -323,7 +381,7 @@ function checkInstallerEntrypoint() {
323
381
  assert.ifError(conflict.error);
324
382
  assert.notEqual(conflict.status, 0, "direct installer must reject conflicting host options");
325
383
  assert.match(conflict.stderr, /cannot be used together/);
326
- for (const host of [".claude", ".codex"]) {
384
+ for (const host of [".claude", ".codex", ".gemini"]) {
327
385
  assert.equal(fs.existsSync(path.join(profile, host)), false);
328
386
  }
329
387
  }
@@ -333,10 +391,12 @@ function checkInstallerEntrypoint() {
333
391
  });
334
392
  assert.ifError(result.error);
335
393
  assert.equal(result.status, 0, result.stdout + result.stderr);
394
+ return result;
336
395
  };
337
396
  run([windows ? "-DryRun" : "--dry-run"]);
338
397
  assert.equal(fs.existsSync(path.join(profile, ".claude")), false);
339
398
  assert.equal(fs.existsSync(path.join(profile, ".codex")), false);
399
+ assert.equal(fs.existsSync(path.join(profile, ".gemini")), false);
340
400
  // Seed an older installation to exercise retirement and policy replacement through the real CLI.
341
401
  for (const host of [".claude", ".codex"]) {
342
402
  const skills = path.join(profile, host, "skills");
@@ -405,6 +465,26 @@ function checkInstallerEntrypoint() {
405
465
  const codexRule = path.join(profile, ".codex/rules/02-implementation.md");
406
466
  const customizedRule = read(codexRule) + "\nKeep unrelated work separate.\n";
407
467
  fs.writeFileSync(codexRule, customizedRule);
468
+ assert.equal(fs.existsSync(path.join(profile, ".gemini")), false,
469
+ "default install must not create ~/.gemini when it does not already exist");
470
+
471
+ // Default install must skip symlinked ~/.gemini without failing Claude/Codex updates.
472
+ const linkedGeminiOutside = path.join(tempRoot, "installer-linked-gemini");
473
+ fs.mkdirSync(linkedGeminiOutside);
474
+ fs.writeFileSync(path.join(linkedGeminiOutside, "sentinel.txt"), "keep\n");
475
+ fs.symlinkSync(
476
+ linkedGeminiOutside,
477
+ path.join(profile, ".gemini"),
478
+ windows ? "junction" : "dir",
479
+ );
480
+ const skippedLinked = run();
481
+ assert.match(skippedLinked.stdout, /Skipping Antigravity plugin sync/);
482
+ assert.deepEqual(fs.readdirSync(linkedGeminiOutside), ["sentinel.txt"]);
483
+ assert.equal(read(codexRule), customizedRule, "the host installer must preserve the active Codex rule");
484
+
485
+ // Once a regular ~/.gemini directory exists, default install syncs Antigravity automatically.
486
+ fs.unlinkSync(path.join(profile, ".gemini"));
487
+ fs.mkdirSync(path.join(profile, ".gemini"));
408
488
  run();
409
489
  assert.equal(read(codexRule), customizedRule, "the host installer must preserve the active Codex rule");
410
490
  assert.equal(read(path.join(backups, earlier, "AGENTS.md")), "My original instructions\n");
@@ -430,6 +510,7 @@ function checkInstallerEntrypoint() {
430
510
  }
431
511
  assert.equal(fs.existsSync(path.join(profile, host, "skills/wayfinder/agents")), false);
432
512
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/install-rules.js")), false);
513
+ assert.equal(fs.existsSync(path.join(profile, host, "scripts/install-antigravity.js")), false);
433
514
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/eval-scenarios.js")), false,
434
515
  "安装不应保留仅供包内评测的场景脚本");
435
516
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/scenario-checks.test.js")), false,
@@ -441,6 +522,204 @@ function checkInstallerEntrypoint() {
441
522
  assert.match(read(path.join(profile, host, "skills/handoff/agents/openai.yaml")),
442
523
  /allow_implicit_invocation: true/);
443
524
  }
525
+
526
+ const agRoot = path.join(profile, ".gemini/config/plugins/claude-everything-workflow");
527
+ const pkg = JSON.parse(read(path.join(sourceRoot, "package.json")));
528
+ const manifest = JSON.parse(read(path.join(agRoot, "plugin.json")));
529
+ assert.equal(manifest.name, pkg.name);
530
+ assert.equal(manifest.version, pkg.version);
531
+ assert.deepEqual(fs.readdirSync(path.join(agRoot, "rules")), ["AGENTS.md"]);
532
+ assert.match(read(path.join(agRoot, "rules/AGENTS.md")), /plugins\/claude-everything-workflow\/references\/rules\//);
533
+ assert.equal(read(path.join(agRoot, "references/rules/common/testing.md")),
534
+ read(path.join(sourceRoot, "rules/common/testing.md")));
535
+ assert.equal(fs.existsSync(path.join(agRoot, "skills/README.md")), false);
536
+ const agSkills = fs.readdirSync(path.join(agRoot, "skills"), { withFileTypes: true })
537
+ .filter((entry) => entry.isDirectory());
538
+ assert.equal(agSkills.length, 22);
539
+ for (const dir of agSkills) {
540
+ const skillMd = read(path.join(agRoot, "skills", dir.name, "SKILL.md"));
541
+ assert.match(skillMd, new RegExp(`^---\\nname: ${dir.name}\\ndescription: .+`, "m"));
542
+ }
543
+ assert.doesNotMatch(read(path.join(agRoot, "skills/pr/SKILL.md")), /\$ARGUMENTS/);
544
+ assert.doesNotMatch(read(path.join(agRoot, "skills/learn/SKILL.md")), /\$ARGUMENTS/);
545
+ const agAgents = fs.readdirSync(path.join(agRoot, "agents")).sort();
546
+ assert.equal(agAgents.length, 5);
547
+ for (const agentFile of agAgents) {
548
+ const body = read(path.join(agRoot, "agents", agentFile));
549
+ assert.match(body, /^subagent: true$/m);
550
+ assert.match(body, /^mainAgent: false$/m);
551
+ assert.match(body, /^tools: \[/m);
552
+ assert.doesNotMatch(body, /^model:/m);
553
+ }
554
+ assert.match(read(path.join(agRoot, "agents/e2e-runner.md")),
555
+ /~\/\.gemini\/config\/plugins\/claude-everything-workflow\/skills\/feature-acceptance\/references\/e2e-testing\.md/);
556
+ assert.match(read(path.join(agRoot, "agents/security-reviewer.md")),
557
+ /~\/\.gemini\/config\/plugins\/claude-everything-workflow\/references\/agents\/security-reviewer\.md/);
558
+ assert.equal(fs.existsSync(path.join(agRoot, "scripts/learning/projects.js")), true);
559
+ assert.equal(fs.existsSync(path.join(agRoot, "harness/manifest.json")), true);
560
+ assert.equal(fs.existsSync(path.join(agRoot, "scripts/install-antigravity.js")), false);
561
+ }
562
+
563
+ function checkAntigravityOnlyInstaller() {
564
+ const profile = path.join(tempRoot, "antigravity-only-profile");
565
+ const agRoot = path.join(profile, ".gemini/config/plugins/claude-everything-workflow");
566
+ const legacyAgents = path.join(profile, ".gemini/AGENTS.md");
567
+ fs.mkdirSync(path.join(agRoot, "skills/research"), { recursive: true });
568
+ fs.writeFileSync(path.join(agRoot, "skills/research/SKILL.md"), "Old distributed content\n");
569
+ fs.writeFileSync(path.join(agRoot, "skills/research/personal-notes.md"), "Keep my notes\n");
570
+ fs.writeFileSync(legacyAgents, "Keep legacy user file\n");
571
+
572
+ const runCli = (extra = []) => {
573
+ const result = spawnSync(process.execPath, [
574
+ path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install", "--antigravity-only", ...extra,
575
+ ], {
576
+ cwd: sourceRoot,
577
+ env: { ...process.env, USERPROFILE: profile, HOME: profile },
578
+ encoding: "utf8",
579
+ timeout: 60000,
580
+ maxBuffer: 8 * 1024 * 1024,
581
+ });
582
+ assert.ifError(result.error);
583
+ assert.equal(result.status, 0, result.stdout + result.stderr);
584
+ return result;
585
+ };
586
+
587
+ runCli(["--dry-run"]);
588
+ assert.equal(fs.existsSync(path.join(agRoot, "plugin.json")), false);
589
+
590
+ const first = runCli();
591
+ assert.equal(fs.existsSync(path.join(profile, ".claude")), false);
592
+ assert.equal(fs.existsSync(path.join(profile, ".codex")), false);
593
+ assert.equal(read(legacyAgents), "Keep legacy user file\n", "legacy ~/.gemini/AGENTS.md must not be removed");
594
+ assert.match(first.stdout, /\.gemini[\\/]AGENTS\.md/);
595
+ assert.equal(fs.existsSync(path.join(agRoot, "skills/research/SKILL.md")), false);
596
+ assert.equal(read(path.join(agRoot, "skills/research/personal-notes.md")), "Keep my notes\n");
597
+
598
+ const agImpl = path.join(agRoot, "references/rules/02-implementation.md");
599
+ const customized = read(agImpl) + "\nKeep Antigravity personal rule.\n";
600
+ fs.writeFileSync(agImpl, customized);
601
+ fs.writeFileSync(path.join(agRoot, "plugin.json"), '{"name":"old"}\n');
602
+ runCli();
603
+ assert.equal(read(agImpl), customized, "reinstall must preserve Antigravity personal 02-implementation.md");
604
+ const backupsDir = path.join(agRoot, BACKUP_ROOT_NAME);
605
+ const snapshots = fs.readdirSync(backupsDir);
606
+ assert.equal(snapshots.length, 1);
607
+ assert.equal(read(path.join(backupsDir, snapshots[0], "plugin.json")), '{"name":"old"}\n');
608
+ }
609
+
610
+ function checkAntigravityEdgeCases() {
611
+ // 1. Pre-write rule target validation must refuse symlinked references/rules before writing any file.
612
+ const precheckHome = path.join(tempRoot, "ag-precheck-home");
613
+ const outsideRules = path.join(tempRoot, "ag-outside-rules");
614
+ const precheckPlugin = path.join(precheckHome, ".gemini/config/plugins/claude-everything-workflow");
615
+ fs.mkdirSync(outsideRules, { recursive: true });
616
+ fs.mkdirSync(path.join(precheckPlugin, "references"), { recursive: true });
617
+ fs.symlinkSync(
618
+ outsideRules,
619
+ path.join(precheckPlugin, "references/rules"),
620
+ process.platform === "win32" ? "junction" : "dir",
621
+ );
622
+ assert.throws(
623
+ () => installAntigravity({ sourceRoot, homeDir: precheckHome, log: () => {} }),
624
+ /symlink/i,
625
+ );
626
+ assert.equal(fs.existsSync(path.join(precheckPlugin, "plugin.json")), false,
627
+ "symlinked references/rules must fail before any partial plugin write");
628
+ assert.deepEqual(fs.readdirSync(outsideRules), []);
629
+
630
+ // 2. Read-only source files (0o444) install with owner-writable permissions so upgrades succeed.
631
+ {
632
+ const roHome = path.join(tempRoot, "ag-ro-home");
633
+ const roSource = path.join(tempRoot, "ag-ro-source");
634
+ fs.cpSync(sourceRoot, roSource, {
635
+ recursive: true,
636
+ filter: (src) => !src.includes(`${path.sep}node_modules`) && !src.includes(`${path.sep}.git`),
637
+ });
638
+ const roRef = path.join(roSource, "references/git-worktrees.md");
639
+ const roRule = path.join(roSource, "rules/01-base.md");
640
+ fs.chmodSync(roRef, 0o444);
641
+ fs.chmodSync(roRule, 0o444);
642
+ try {
643
+ const installedRoot = installAntigravity({ sourceRoot: roSource, homeDir: roHome, log: () => {} });
644
+ const installedRef = path.join(installedRoot, "references/git-worktrees.md");
645
+ const installedRule = path.join(installedRoot, "references/rules/01-base.md");
646
+ assert.ok((fs.statSync(installedRef).mode & 0o200) !== 0, "installed file must keep owner write bit");
647
+ assert.ok(fs.statSync(installedRule).mode & 0o200, "installed rule must be owner-writable");
648
+ // Older installers could leave this target read-only.
649
+ fs.chmodSync(installedRule, 0o400);
650
+ fs.chmodSync(roRef, 0o644);
651
+ fs.writeFileSync(roRef, "# Updated worktrees\n");
652
+ const originalRule = read(roRule);
653
+ fs.chmodSync(roRule, 0o644);
654
+ fs.writeFileSync(roRule, "# Updated rule\n");
655
+ fs.chmodSync(roRule, 0o444);
656
+ installAntigravity({ sourceRoot: roSource, homeDir: roHome, backupId: "upgrade", log: () => {} });
657
+ assert.equal(read(installedRef), "# Updated worktrees\n");
658
+ assert.equal(read(installedRule), "# Updated rule\n");
659
+ assert.ok(fs.statSync(installedRule).mode & 0o200, "upgraded rule must be owner-writable");
660
+ const backup = path.join(installedRoot, BACKUP_ROOT_NAME, "upgrade", "references/rules/01-base.md");
661
+ assert.equal(read(backup), originalRule);
662
+ // Reuse the same snapshot ID, as happens for two updates within the same second.
663
+ fs.writeFileSync(installedRule, "Previous local rule\n");
664
+ installAntigravity({ sourceRoot: roSource, homeDir: roHome, backupId: "upgrade", log: () => {} });
665
+ assert.equal(read(backup), "Previous local rule\n");
666
+ assert.equal(read(installedRule), "# Updated rule\n");
667
+ } finally {
668
+ fs.chmodSync(roRef, 0o644);
669
+ fs.chmodSync(roRule, 0o644);
670
+ }
671
+ }
672
+
673
+ // 3. Symlinked $HOME is allowed when .gemini chain itself is clean.
674
+ const realHome = path.join(tempRoot, "ag-real-home");
675
+ const linkedHome = path.join(tempRoot, "ag-linked-home");
676
+ fs.mkdirSync(realHome);
677
+ fs.symlinkSync(realHome, linkedHome, process.platform === "win32" ? "junction" : "dir");
678
+ const linkedPlugin = installAntigravity({ sourceRoot, homeDir: linkedHome, log: () => {} });
679
+ assert.equal(fs.existsSync(path.join(linkedPlugin, "plugin.json")), true);
680
+
681
+ // 4. Zero-indent YAML lists parse cleanly; invalid/unmapped explicit tools throw instead of fail-open.
682
+ const parsedList = parseFrontmatter("---\nname: demo\ntools:\n- Read\n- Grep\n---\n\nBody\n");
683
+ assert.deepEqual(parsedList.data.tools, ["Read", "Grep"]);
684
+ assert.deepEqual(mapTools(["Read", "Grep"], "demo.md"), ["read_file"]);
685
+ assert.throws(() => mapTools(["UnknownTool"], "demo.md"), /no supported Antigravity tools/);
686
+ assert.throws(() => mapTools([], "demo.md"), /no supported Antigravity tools/);
687
+ assert.throws(() => mapTools("Read", "demo.md"), /invalid tools/);
688
+
689
+ // 5. Reject "." as --backup-id in both CLI entrypoints.
690
+ for (const script of ["scripts/install-rules.js", "scripts/install-antigravity.js"]) {
691
+ const args = script.endsWith("install-rules.js")
692
+ ? [path.join(sourceRoot, script), "codex", path.join(tempRoot, "unused"), "--backup-id", "."]
693
+ : [path.join(sourceRoot, script), path.join(tempRoot, "unused"), "--backup-id", "."];
694
+ const res = spawnSync(process.execPath, args, { cwd: sourceRoot, encoding: "utf8" });
695
+ assert.notEqual(res.status, 0);
696
+ assert.match(res.stderr, /Invalid --backup-id/);
697
+ }
698
+
699
+ // 6. Bash --antigravity-only works without rsync on PATH.
700
+ if (process.platform !== "win32") {
701
+ const noRsyncProfile = path.join(tempRoot, "ag-no-rsync-profile");
702
+ const noRsyncBin = path.join(tempRoot, "ag-no-rsync-bin");
703
+ fs.mkdirSync(noRsyncBin, { recursive: true });
704
+ fs.symlinkSync(process.execPath, path.join(noRsyncBin, "node"));
705
+ for (const tool of ["dirname", "date"]) {
706
+ const located = spawnSync("which", [tool], { encoding: "utf8" }).stdout.trim();
707
+ if (located) fs.symlinkSync(located, path.join(noRsyncBin, tool));
708
+ }
709
+ const executable = process.env.CEW_TEST_BASH || "bash";
710
+ const res = spawnSync(executable, ["scripts/install.sh", "--antigravity-only"], {
711
+ cwd: sourceRoot,
712
+ env: { ...process.env, HOME: noRsyncProfile, PATH: `${noRsyncBin}:/bin` },
713
+ encoding: "utf8",
714
+ timeout: 60000,
715
+ });
716
+ assert.ifError(res.error);
717
+ assert.equal(res.status, 0, res.stdout + res.stderr);
718
+ assert.equal(
719
+ fs.existsSync(path.join(noRsyncProfile, ".gemini/config/plugins/claude-everything-workflow/plugin.json")),
720
+ true,
721
+ );
722
+ }
444
723
  }
445
724
 
446
725
  try {
@@ -489,11 +768,14 @@ try {
489
768
  checkLegacyMigration();
490
769
  checkPromotedImplementationRule();
491
770
  checkCodexImplementationRuleUpgrades();
771
+ checkAntigravityImplementationRuleUpgrades();
492
772
  checkInstallerCliOptions();
493
773
  checkBashHelpOptions();
494
774
  checkInstallerLinkedRoots();
495
775
  checkInstallerMergeFailure();
496
776
  checkInstallerEntrypoint();
777
+ checkAntigravityOnlyInstaller();
778
+ checkAntigravityEdgeCases();
497
779
  console.log("Rule installation tests passed (migration, backups, custom rules, symlink safety, both hosts, installer dry-run and execution).");
498
780
  } finally {
499
781
  // Only remove the exact private directory returned by mkdtemp; never a caller-supplied path.
@@ -16,6 +16,7 @@ const PACKAGE_ONLY_PATHS = [
16
16
  "scripts/install.sh",
17
17
  "scripts/install.ps1",
18
18
  "scripts/install-rules.js",
19
+ "scripts/install-antigravity.js",
19
20
  "scripts/legacy-common-rule-hashes.json",
20
21
  "scripts/eval-scenarios.js",
21
22
  "scripts/verify-harness.js",
@@ -189,6 +190,15 @@ function checkInstallerSurface(ps, sh) {
189
190
  fail(`installers must route ${host} rules through the host adapter`);
190
191
  }
191
192
  }
193
+ const antigravityInstaller = exists("scripts/install-antigravity.js")
194
+ ? read("scripts/install-antigravity.js")
195
+ : "";
196
+ if (!antigravityInstaller.includes('host: "antigravity"')) {
197
+ fail('scripts/install-antigravity.js must route rules through host: "antigravity"');
198
+ }
199
+ if (antigravityInstaller.includes("settings.json")) {
200
+ fail("scripts/install-antigravity.js should not install Claude Code settings.json");
201
+ }
192
202
  if (sh.includes('copy_dir rules "$dest"') || /\$dirs\s*=\s*@\([^)]*"rules"/s.test(ps)) {
193
203
  fail("installers must not copy cold common rules into the shared automatic rules directory");
194
204
  }
@@ -226,9 +236,11 @@ function checkInstallRuntimePolicy() {
226
236
  requireTokens("scripts/install.ps1", [
227
237
  "Copy-ClaudeSettings",
228
238
  "Install-CodexWorkflow",
239
+ "Install-AntigravityWorkflow",
229
240
  "Copy-ConfigFile -Source (Join-Path $RootDir \"AGENTS.md\")",
230
241
  "Remove-PackageOnlyPaths",
231
242
  "scripts\\install.ps1",
243
+ "scripts\\install-antigravity.js",
232
244
  "scripts\\verify-harness.js",
233
245
  "scripts\\verify",
234
246
  "scripts\\verify\\scenario-checks.js",
@@ -237,14 +249,25 @@ function checkInstallRuntimePolicy() {
237
249
  requireTokens("scripts/install.sh", [
238
250
  "copy_claude_settings",
239
251
  "install_codex()",
252
+ "install_antigravity()",
240
253
  "copy_file \"$ROOT_DIR/AGENTS.md\" \"$dest/AGENTS.md\"",
241
254
  "remove_package_only_paths",
242
255
  "scripts/install.sh",
256
+ "scripts/install-antigravity.js",
243
257
  "scripts/verify-harness.js",
244
258
  "scripts/verify",
245
259
  "scripts/verify/scenario-checks.js",
246
260
  "scripts/verify/scenario-checks.test.js",
247
261
  ]);
262
+ requireTokens("scripts/install-antigravity.js", [
263
+ "installRules",
264
+ "finalizeBackups",
265
+ "cleanup-retired-skills.js",
266
+ ]);
267
+ requireTokens("bin/claude-everything-workflow.js", [
268
+ "--antigravity-only",
269
+ "-AntigravityOnly",
270
+ ]);
248
271
 
249
272
  const ps = read("scripts/install.ps1");
250
273
  const sh = read("scripts/install.sh");
@@ -44,12 +44,16 @@ function checkEvalCli() {
44
44
  const fs = require("node:fs");
45
45
  fs.writeFileSync(process.env.PROMPT_FILE, process.argv.at(-1));
46
46
  const output = process.argv.indexOf("--output-last-message");
47
- if (output >= 0) fs.writeFileSync(process.argv[output + 1], process.env.FINAL);
48
- process.stdout.write(process.env.STDOUT);
49
- process.stderr.write(process.env.STDERR);
50
- process.exitCode = Number(process.env.HOST_STATUS);
47
+ const samples = JSON.parse(fs.readFileSync(process.env.SAMPLES_FILE, "utf8"));
48
+ const { final, hostStatus = 0, diagnostics = "" } = samples.shift();
49
+ fs.writeFileSync(process.env.SAMPLES_FILE, JSON.stringify(samples));
50
+ if (output >= 0) fs.writeFileSync(process.argv[output + 1], final);
51
+ process.stdout.write(output >= 0 ? process.env.DECOY : final);
52
+ process.stderr.write(diagnostics);
53
+ process.exitCode = hostStatus;
51
54
  `;
52
55
  const promptFile = path.join(bin, "prompt.txt");
56
+ const samplesFile = path.join(bin, "samples.json");
53
57
  try {
54
58
  for (const host of ["claude", "codex"]) {
55
59
  fs.writeFileSync(path.join(bin, host), stub, { mode: 0o755 });
@@ -57,18 +61,32 @@ process.exitCode = Number(process.env.HOST_STATUS);
57
61
  const target = "skills/implement/SKILL.md";
58
62
  const correct = JSON.stringify({ target });
59
63
  const excluded = JSON.stringify({ target: "NONE", reason: `Do not choose ${target}` });
60
- const run = (host, id, final, expectedStatus, diagnostics = "", hostStatus = 0) => {
61
- const result = spawnSync(process.execPath, ["scripts/eval-scenarios.js", "--host", host, "--id", id], {
64
+ const runSamples = (host, id, samples, verdict) => {
65
+ fs.writeFileSync(samplesFile, JSON.stringify(samples));
66
+ const args = ["scripts/eval-scenarios.js", "--host", host, "--id", id];
67
+ if (samples.length > 1) args.push("--repeat", String(samples.length));
68
+ const result = spawnSync(process.execPath, args, {
62
69
  cwd: root, encoding: "utf8",
63
- env: { ...process.env, PATH: bin + path.delimiter + process.env.PATH, FINAL: final, PROMPT_FILE: promptFile,
64
- STDOUT: host === "codex" ? correct : final, STDERR: diagnostics, HOST_STATUS: String(hostStatus) },
70
+ env: { ...process.env, PATH: bin + path.delimiter + process.env.PATH,
71
+ SAMPLES_FILE: samplesFile, PROMPT_FILE: promptFile, DECOY: correct },
65
72
  });
66
73
  assert.ifError(result.error);
67
- assert.equal(result.status, expectedStatus, `${host} ${id}: ${result.stdout} ${result.stderr}`);
68
- assert.match(result.stdout, expectedStatus === 0 ? /^PASS /m : /^FAIL /m);
74
+ assert.equal(result.status, verdict === "PASS" ? 0 : 1, `${host} ${id}: ${result.stdout} ${result.stderr}`);
75
+ assert.ok(result.stdout.startsWith(`${verdict} ${id} `), result.stdout);
76
+ assert.deepEqual(JSON.parse(fs.readFileSync(samplesFile, "utf8")), []);
77
+ return result.stdout;
69
78
  };
79
+ const run = (host, id, final, expectedStatus, diagnostics = "", hostStatus = 0) =>
80
+ runSamples(host, id, [{ final, diagnostics, hostStatus }], expectedStatus === 0 ? "PASS" : "FAIL");
70
81
  for (const host of ["claude", "codex"]) {
71
82
  run(host, "direct-small-change", excluded, 1, correct);
83
+ run(host, "direct-small-change", `Rejected example: ${correct}. Final choice: NONE.`, 1);
84
+ const fence = "`".repeat(3);
85
+ run(host, "direct-small-change", [fence + "json", correct, fence].join("\r\n"), 0);
86
+ run(host, "direct-small-change", [fence, correct, fence].join("\n"), 0);
87
+ run(host, "direct-small-change", [fence + "json", correct].join("\n"), 1);
88
+ run(host, "direct-small-change", [correct, fence].join("\n"), 1);
89
+ run(host, "direct-small-change", [correct, correct].join("\n"), 1);
72
90
  run(host, "direct-small-change", "NONE. Do not choose implement.", 1);
73
91
  run(host, "direct-small-change", "{}", 1, correct);
74
92
  run(host, "direct-small-change", correct, 0);
@@ -78,6 +96,17 @@ process.exitCode = Number(process.env.HOST_STATUS);
78
96
  const router = JSON.stringify({ target: "skills/using-superpowers/SKILL.md" });
79
97
  run(host, "direct-small-change", router, 1);
80
98
  run(host, "workflow-advice", router, 0);
99
+ const right = { final: correct };
100
+ const wrong = { final: router };
101
+ const repeat = (samples, verdict) => runSamples(host, "direct-small-change", samples, verdict);
102
+ repeat([right, right], "PASS");
103
+ repeat([wrong, wrong], "FAIL");
104
+ repeat([right, wrong], "UNSTABLE");
105
+ assert.match(repeat([right, { final: "", hostStatus: 1 }], "FAIL"), /host-error/);
106
+ assert.match(repeat([right, { final: "{}" }], "FAIL"), /invalid-answer/);
107
+ const incomplete = repeat([right, wrong, { final: "invalid" }, { final: correct, hostStatus: 1 }], "FAIL");
108
+ assert.match(incomplete, /invalid-answer/);
109
+ assert.match(incomplete, /host-error/);
81
110
  run(host, "direct-small-change", correct, 1, "", 1);
82
111
  run(host, "non-eng-translate", JSON.stringify({ target: "NONE" }), 0);
83
112
  const debug = JSON.stringify({ target: "skills/systematic-debugging/SKILL.md" });
package/skills/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  ## Engineering / 开发实践
30
30
 
31
- - `code-review`:简单、明确、低风险且可验证的任务可自审;复杂或证据不足时使用一个独立子智能体,高风险使用 Standards/Spec 双轴;必要的独立审查不可用时阻塞。
31
+ - `code-review`:基于固定基点和已确认范围启动独立只读子智能体审查,高风险升级为 Standards/Spec 双轴隔离审查;不提供自我审查,代理不可用时阻塞。
32
32
  - `test-driven-development`:行为变化的 Red Test Gate。
33
33
  - `systematic-debugging`:区分普通明确失败与疑难故障;预期 TDD RED 留在实现循环。
34
34
  - `resolving-merge-conflicts`:按双方原始意图逐 hunk 解决 merge/rebase 冲突。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: code-review
3
- description: Review a fixed diff and confirmed scope; use self-review for verifiable low-risk work and independent review as risk grows.
3
+ description: Review a fixed diff and confirmed scope with an independent read-only subagent, escalating to dual-axis review as risk grows.
4
4
  ---
5
5
 
6
6
  # Code Review
@@ -31,37 +31,31 @@ evidence is `BLOCKED`, not `PASS`.
31
31
 
32
32
  ## Select review depth
33
33
 
34
- `--mode auto` is the default. Select by risk and verification evidence, not file count, model generation
35
- or confidence. State the selected mode and reason briefly.
34
+ `--mode auto` is the default. Always delegate review to a fresh independent read-only subagent (`independent` or `dual`), selected by risk and verification evidence, not file count, model generation or confidence. State the selected mode and reason briefly.
36
35
 
37
36
  | Mode | Trigger | Execution |
38
37
  | --- | --- | --- |
39
- | self | Clear requirements, local and reversible low-risk changes, with direct checks or relevant tests covering the result; no unresolved risk or repeated unexpected failures | The implementing agent checks the diff against requirements and relevant rules, then provides verification evidence; no review subagent |
40
- | independent | Cross-module behavior, complex dependencies, hidden constraints, insufficient verification, repeated unexpected failures, or an explicit request for independent review | One fresh read-only subagent checks Standards and Spec against the same package |
41
- | dual | High-risk changes such as authorization, persistent data, destructive operations or public contracts, or an explicit request for two isolated axes | Spawn two parallel subagents: separate Standards and Spec reviewers |
38
+ | independent | Standard changes with clear scope and verification evidence, or an explicit request for single-subagent review | One fresh read-only subagent checks Standards and Spec against the same frozen package |
39
+ | dual | High-risk changes such as authorization, persistent data, destructive operations or public contracts, insufficient verification, repeated unexpected failures, or an explicit request for two isolated axes | Spawn two parallel subagents: separate Standards and Spec reviewers |
42
40
 
43
- `--mode self|independent|dual` may request a mode, but cannot weaken the review required by the scope or
44
- project. Self-review requires every self condition above; otherwise use independent, or dual for high
45
- risk. Reassess if the scope grows or verification exposes a gap. Review never replaces required tests.
41
+ `--mode auto|independent|dual` may request a mode, but cannot weaken the review required by the scope or
42
+ project. Reassess if the scope grows or verification exposes a gap. Review never replaces required tests.
46
43
 
47
- For self-review, keep the result concise and use relevant existing checks or direct inspection; do not
48
- load the independent-review prompts, invent low-value tests, or write a long checklist just for ceremony.
49
- The implementing agent cannot serve as its own independent reviewer.
44
+ The implementing agent must never review its own diff (no self-review mode is offered).
45
+ Load `references/standards-reviewer-prompt.md` and `references/spec-reviewer-prompt.md` only for the
46
+ reviewer(s) that need them (`independent` receives both; `dual` passes each prompt only to its respective
47
+ subagent). Repository standards override smell heuristics. Each independent context receives only the
48
+ frozen package, relevant rules, confirmed scope and verification evidence. Reviewers are read-only and
49
+ must not influence each other.
50
50
 
51
- For independent or dual review, load `references/standards-reviewer-prompt.md` and
52
- `references/spec-reviewer-prompt.md` only for the reviewer that needs them. Repository standards override
53
- smell heuristics. Each independent context receives only the frozen package, relevant rules, confirmed
54
- scope and verification evidence. Reviewers are read-only and must not influence each other.
55
-
56
- When independent or dual review is selected, lack of agent capacity is never a reason to downgrade to
57
- self. If parallelism is unavailable, run dual axes sequentially in fresh isolated contexts. If no
58
- independent context is available, return `BLOCKED`, mark review `NOT RUN`, and do not claim completion.
51
+ Lack of agent capacity is never a reason to fall back to self-review. If parallelism is unavailable during
52
+ `dual` review, run dual axes sequentially in fresh isolated contexts. If no independent context is
53
+ available, return `BLOCKED`, mark review `NOT RUN`, and do not claim completion.
59
54
 
60
55
  ## Report and follow-up
61
56
 
62
57
  Report mode, base and scope source, then separate `Standards` and `Spec` findings with evidence and severity.
63
58
  Do not merge or rerank findings across axes. Include checks not run and remaining risks.
64
- For self-review with no findings, a short conclusion and verification evidence are sufficient.
65
59
 
66
60
  Fix Critical/Important findings before completion. Recheck affected axes against the same base and updated
67
61
  package; rerun both when scope, shared behavior or review assumptions change. Reuse checks whose relevant
@@ -38,8 +38,8 @@ disable-model-invocation: true
38
38
  已确认失败原因正确的预期 TDD RED 继续 GREEN,不触发调试。其他失败按
39
39
  `systematic-debugging` 的分级入口处理,不跳过真实失败。
40
40
  2. 用 pre-delivery base 冻结包含 task-owned committed、staged、unstaged、untracked 的完整审查包,
41
- 范围合同作为 Spec source,按 `skills/code-review/SKILL.md` 选择相称的 review 模式。
42
- 满足该 Skill 的低风险与验证条件时可自审;需要独立审查却无法启动时不得降级。
41
+ 范围合同作为 Spec source,按 `skills/code-review/SKILL.md` 启动独立只读子代理(`independent` 或 `dual`)完成审查;
42
+ 实施者不得自我审查,独立审查不可用时返回 `BLOCKED`,不得降级。
43
43
  修复 Critical/Important findings 后复核受影响的验收与审查项,不把部分完成报告为交付完成。
44
44
  3. 逐条核对验收,按 `rules/common/testing.md` 运行 fresh commands。已在当前阶段运行且仍对应
45
45
  最终改动的证据可以复用;新改动、失败或未决风险才触发重跑。记录实际结果、未运行项和剩余风险。