claude-everything-workflow 0.2.9 → 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-"));
@@ -104,13 +105,136 @@ function checkPromotedImplementationRule() {
104
105
  assert.equal(fs.existsSync(cold), false);
105
106
  }
106
107
 
108
+ function checkCodexImplementationRuleUpgrades() {
109
+ const fixture = path.join(tempRoot, "codex-release");
110
+ const target = path.join(tempRoot, "codex-existing");
111
+ const filename = "02-implementation.md";
112
+ const source = path.join(fixture, "rules", filename);
113
+ const active = path.join(target, "rules", filename);
114
+ const old = "Original release\n";
115
+ const initial = "# Implementation\nScope: fix bugs.\n\n# Checks\nRun unit tests.\n";
116
+ const personal = initial.replace("fix bugs.", "fix bugs. Leave unrelated work alone.").replace(/\n/g, "\r\n");
117
+ const updated = initial.replace("unit tests", "unit and integration tests");
118
+ const base = path.join(target, ".cew-rule-state", "02-implementation.base.md");
119
+ const incoming = path.join(target, ".cew-rule-state", "02-implementation.incoming.md");
120
+ const run = (dryRun = false) => installRules({
121
+ sourceRoot: fixture, installRoot: target, host: "codex", dryRun, log: () => {},
122
+ });
123
+ fs.mkdirSync(path.dirname(active), { recursive: true });
124
+ fs.mkdirSync(path.join(fixture, "rules/common"), { recursive: true });
125
+ fs.mkdirSync(path.join(fixture, "scripts"));
126
+ const oldHash = crypto.createHash("sha256").update(old).digest("hex");
127
+ fs.writeFileSync(path.join(fixture, "scripts/legacy-common-rule-hashes.json"),
128
+ JSON.stringify({ files: { [filename]: [oldHash] } }));
129
+ fs.writeFileSync(source, initial);
130
+ fs.writeFileSync(active, personal);
131
+ run(true);
132
+ assert.deepEqual(fs.readdirSync(target), ["rules"], "dry-run leaves no installation state");
133
+ run();
134
+ run();
135
+ assert.equal(fs.readFileSync(active, "utf8"), personal, "customizations must stay in the active Codex rule");
136
+
137
+ fs.writeFileSync(source, updated);
138
+ run(true);
139
+ assert.equal(read(base), initial, "preview must not consume the upstream delta");
140
+ assert.equal(fs.readFileSync(active, "utf8"), personal);
141
+ run();
142
+ const merged = personal.replace("unit tests", "unit and integration tests");
143
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "apply independent upstream edits and preserve CRLF");
144
+ run();
145
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "a retry does not duplicate edits");
146
+
147
+ fs.writeFileSync(source, updated.replace("Scope: fix bugs.", "Scope: add features."));
148
+ run();
149
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "overlapping edits leave the personal rule intact");
150
+ assert.equal(read(base), updated, "keep the last applied base for a retry");
151
+ assert.equal(read(incoming), read(source), "offer the conflicting distribution outside active rules");
152
+ run();
153
+ assert.equal(fs.readFileSync(active, "utf8"), merged);
154
+
155
+ // Apply a later non-conflicting release even if Git was unavailable on the first attempt.
156
+ const later = updated.replace("Run unit and integration tests.", "Run the release checks.");
157
+ fs.writeFileSync(source, later);
158
+ const originalPath = process.env.PATH;
159
+ try {
160
+ process.env.PATH = path.join(tempRoot, "no-git");
161
+ run();
162
+ } finally {
163
+ process.env.PATH = originalPath;
164
+ }
165
+ assert.equal(fs.readFileSync(active, "utf8"), merged, "missing Git preserves the usable rule");
166
+ assert.equal(read(base), updated);
167
+ assert.equal(read(incoming), later);
168
+ run();
169
+ assert.equal(read(active), later.replace("fix bugs.", "fix bugs. Leave unrelated work alone."));
170
+ assert.equal(read(base), later);
171
+ assert.equal(fs.existsSync(incoming), false);
172
+
173
+ const stockRoot = path.join(tempRoot, "codex-stock");
174
+ const stock = path.join(stockRoot, "rules", filename);
175
+ fs.mkdirSync(path.dirname(stock), { recursive: true });
176
+ fs.writeFileSync(stock, old.replace(/\n/g, "\r\n"));
177
+ installRules({ sourceRoot: fixture, installRoot: stockRoot, host: "codex", log: () => {} });
178
+ assert.equal(read(stock), read(source), "a known older distribution still upgrades");
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
+
107
228
  function checkInstallerCliOptions() {
108
229
  const profile = path.join(tempRoot, "invalid-cli-profile");
109
230
  for (const [options, message] of [
110
231
  [["--unknown-option"], /Unknown option: --unknown-option/],
111
232
  [["--claude-only", "--codex-only"], /cannot be used together/],
112
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/],
113
236
  [["--claude-only", "--codex-only", "--help"], /cannot be used together/],
237
+ [["--antigravity-only", "--claude-only", "--help"], /cannot be used together/],
114
238
  ]) {
115
239
  const result = spawnSync(process.execPath, [
116
240
  path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install", ...options,
@@ -122,7 +246,7 @@ function checkInstallerCliOptions() {
122
246
  assert.notEqual(result.status, 0, "invalid CLI options must fail before installation");
123
247
  assert.match(result.stderr, message);
124
248
  }
125
- for (const host of [".claude", ".codex"]) {
249
+ for (const host of [".claude", ".codex", ".gemini"]) {
126
250
  assert.equal(fs.existsSync(path.join(profile, host)), false);
127
251
  }
128
252
  for (const help of ["--help", "-h"]) {
@@ -135,7 +259,7 @@ function checkInstallerCliOptions() {
135
259
  assert.ifError(result.error);
136
260
  assert.equal(result.status, 0, "install help must succeed without installing");
137
261
  assert.match(result.stdout, /Usage:/);
138
- for (const host of [".claude", ".codex"]) {
262
+ for (const host of [".claude", ".codex", ".gemini"]) {
139
263
  assert.equal(fs.existsSync(path.join(profile, host)), false);
140
264
  }
141
265
  }
@@ -149,6 +273,8 @@ function checkBashHelpOptions() {
149
273
  ["--help", "--claude-only", "--codex-only"],
150
274
  ["--claude-only", "--help", "--codex-only"],
151
275
  ["--claude-only", "--codex-only", "--help"],
276
+ ["--help", "--antigravity-only", "--codex-only"],
277
+ ["--claude-only", "--antigravity-only", "--help"],
152
278
  ["--help", "--unknown-option"],
153
279
  ["--unknown-option", "--help"],
154
280
  ];
@@ -165,14 +291,18 @@ function checkBashHelpOptions() {
165
291
  assert.notEqual(result.status, 0, `Bash must reject invalid options even with help: ${options.join(" ")}`);
166
292
  assert.match(result.stderr, /Unknown option|cannot be used together/);
167
293
  }
168
- for (const host of [".claude", ".codex"]) {
294
+ for (const host of [".claude", ".codex", ".gemini"]) {
169
295
  assert.equal(fs.existsSync(path.join(profile, host)), false);
170
296
  }
171
297
  }
172
298
  }
173
299
 
174
300
  function checkInstallerLinkedRoots() {
175
- 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
+ ]) {
176
306
  const profile = path.join(tempRoot, "linked-profile" + host);
177
307
  const outside = path.join(tempRoot, "linked-outside" + host);
178
308
  fs.mkdirSync(profile);
@@ -180,8 +310,7 @@ function checkInstallerLinkedRoots() {
180
310
  fs.writeFileSync(path.join(outside, "AGENTS.md"), "Keep external user content\n");
181
311
  fs.symlinkSync(outside, path.join(profile, host), process.platform === "win32" ? "junction" : "dir");
182
312
  const result = spawnSync(process.execPath, [
183
- path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install",
184
- host === ".claude" ? "--claude-only" : "--codex-only",
313
+ path.join(sourceRoot, "bin/claude-everything-workflow.js"), "install", flag,
185
314
  ], {
186
315
  cwd: sourceRoot,
187
316
  env: {
@@ -240,9 +369,11 @@ function checkInstallerEntrypoint() {
240
369
  assert.notEqual(invalid.status, 0, "direct installer must reject unknown options before writing");
241
370
  assert.equal(fs.existsSync(path.join(profile, ".claude")), false);
242
371
  assert.equal(fs.existsSync(path.join(profile, ".codex")), false);
372
+ assert.equal(fs.existsSync(path.join(profile, ".gemini")), false);
243
373
  for (const only of [
244
374
  windows ? ["-ClaudeOnly", "-CodexOnly"] : ["--claude-only", "--codex-only"],
245
375
  windows ? ["-CodexOnly", "-ClaudeOnly"] : ["--codex-only", "--claude-only"],
376
+ windows ? ["-ClaudeOnly", "-AntigravityOnly"] : ["--claude-only", "--antigravity-only"],
246
377
  ]) {
247
378
  const conflict = spawnSync(executable, [...args, ...only], {
248
379
  cwd: sourceRoot, env, encoding: "utf8", timeout: 60000, maxBuffer: 8 * 1024 * 1024,
@@ -250,7 +381,7 @@ function checkInstallerEntrypoint() {
250
381
  assert.ifError(conflict.error);
251
382
  assert.notEqual(conflict.status, 0, "direct installer must reject conflicting host options");
252
383
  assert.match(conflict.stderr, /cannot be used together/);
253
- for (const host of [".claude", ".codex"]) {
384
+ for (const host of [".claude", ".codex", ".gemini"]) {
254
385
  assert.equal(fs.existsSync(path.join(profile, host)), false);
255
386
  }
256
387
  }
@@ -260,10 +391,12 @@ function checkInstallerEntrypoint() {
260
391
  });
261
392
  assert.ifError(result.error);
262
393
  assert.equal(result.status, 0, result.stdout + result.stderr);
394
+ return result;
263
395
  };
264
396
  run([windows ? "-DryRun" : "--dry-run"]);
265
397
  assert.equal(fs.existsSync(path.join(profile, ".claude")), false);
266
398
  assert.equal(fs.existsSync(path.join(profile, ".codex")), false);
399
+ assert.equal(fs.existsSync(path.join(profile, ".gemini")), false);
267
400
  // Seed an older installation to exercise retirement and policy replacement through the real CLI.
268
401
  for (const host of [".claude", ".codex"]) {
269
402
  const skills = path.join(profile, host, "skills");
@@ -329,7 +462,31 @@ function checkInstallerEntrypoint() {
329
462
  assert.deepEqual(installedSettings.hooks.SessionStart, [unrelatedHook]);
330
463
  assert.equal(installedSettings.hooks.PostToolUse.flatMap(({ hooks }) => hooks)
331
464
  .filter(({ command }) => command?.includes("hooks/check-console-log.js")).length, 1);
465
+ const codexRule = path.join(profile, ".codex/rules/02-implementation.md");
466
+ const customizedRule = read(codexRule) + "\nKeep unrelated work separate.\n";
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"));
332
488
  run();
489
+ assert.equal(read(codexRule), customizedRule, "the host installer must preserve the active Codex rule");
333
490
  assert.equal(read(path.join(backups, earlier, "AGENTS.md")), "My original instructions\n");
334
491
  assert.deepEqual(JSON.parse(read(settingsPath).replace(/^\uFEFF/, "")), installedSettings,
335
492
  "reinstallation must preserve user hooks and add each managed hook only once");
@@ -353,6 +510,7 @@ function checkInstallerEntrypoint() {
353
510
  }
354
511
  assert.equal(fs.existsSync(path.join(profile, host, "skills/wayfinder/agents")), false);
355
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);
356
514
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/eval-scenarios.js")), false,
357
515
  "安装不应保留仅供包内评测的场景脚本");
358
516
  assert.equal(fs.existsSync(path.join(profile, host, "scripts/verify/scenario-checks.test.js")), false,
@@ -364,6 +522,204 @@ function checkInstallerEntrypoint() {
364
522
  assert.match(read(path.join(profile, host, "skills/handoff/agents/openai.yaml")),
365
523
  /allow_implicit_invocation: true/);
366
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
+ }
367
723
  }
368
724
 
369
725
  try {
@@ -411,11 +767,15 @@ try {
411
767
  assert.throws(() => install("invalid", "unknown"), /host/i);
412
768
  checkLegacyMigration();
413
769
  checkPromotedImplementationRule();
770
+ checkCodexImplementationRuleUpgrades();
771
+ checkAntigravityImplementationRuleUpgrades();
414
772
  checkInstallerCliOptions();
415
773
  checkBashHelpOptions();
416
774
  checkInstallerLinkedRoots();
417
775
  checkInstallerMergeFailure();
418
776
  checkInstallerEntrypoint();
777
+ checkAntigravityOnlyInstaller();
778
+ checkAntigravityEdgeCases();
419
779
  console.log("Rule installation tests passed (migration, backups, custom rules, symlink safety, both hosts, installer dry-run and execution).");
420
780
  } finally {
421
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");
@@ -42,12 +42,18 @@ function checkEvalCli() {
42
42
  const bin = fs.mkdtempSync(path.join(os.tmpdir(), "cew-eval-test-"));
43
43
  const stub = `#!/usr/bin/env node
44
44
  const fs = require("node:fs");
45
+ fs.writeFileSync(process.env.PROMPT_FILE, process.argv.at(-1));
45
46
  const output = process.argv.indexOf("--output-last-message");
46
- if (output >= 0) fs.writeFileSync(process.argv[output + 1], process.env.FINAL);
47
- process.stdout.write(process.env.STDOUT);
48
- process.stderr.write(process.env.STDERR);
49
- 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;
50
54
  `;
55
+ const promptFile = path.join(bin, "prompt.txt");
56
+ const samplesFile = path.join(bin, "samples.json");
51
57
  try {
52
58
  for (const host of ["claude", "codex"]) {
53
59
  fs.writeFileSync(path.join(bin, host), stub, { mode: 0o755 });
@@ -55,23 +61,59 @@ process.exitCode = Number(process.env.HOST_STATUS);
55
61
  const target = "skills/implement/SKILL.md";
56
62
  const correct = JSON.stringify({ target });
57
63
  const excluded = JSON.stringify({ target: "NONE", reason: `Do not choose ${target}` });
58
- const run = (host, id, final, expectedStatus, diagnostics = "", hostStatus = 0) => {
59
- 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, {
60
69
  cwd: root, encoding: "utf8",
61
- env: { ...process.env, PATH: bin + path.delimiter + process.env.PATH, FINAL: final,
62
- 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 },
63
72
  });
64
73
  assert.ifError(result.error);
65
- assert.equal(result.status, expectedStatus, `${host} ${id}: ${result.stdout} ${result.stderr}`);
66
- 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;
67
78
  };
79
+ const run = (host, id, final, expectedStatus, diagnostics = "", hostStatus = 0) =>
80
+ runSamples(host, id, [{ final, diagnostics, hostStatus }], expectedStatus === 0 ? "PASS" : "FAIL");
68
81
  for (const host of ["claude", "codex"]) {
69
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);
70
90
  run(host, "direct-small-change", "NONE. Do not choose implement.", 1);
71
91
  run(host, "direct-small-change", "{}", 1, correct);
72
92
  run(host, "direct-small-change", correct, 0);
93
+ const prompt = fs.readFileSync(promptFile, "utf8");
94
+ assert.ok(!prompt.includes("第一个 Skill 或规则"), "the host question must not ask for the first routing hop");
95
+ assert.ok(!prompt.includes(target), "keep the expected answer out of the host prompt");
96
+ const router = JSON.stringify({ target: "skills/using-superpowers/SKILL.md" });
97
+ run(host, "direct-small-change", router, 1);
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/);
73
110
  run(host, "direct-small-change", correct, 1, "", 1);
74
111
  run(host, "non-eng-translate", JSON.stringify({ target: "NONE" }), 0);
112
+ const debug = JSON.stringify({ target: "skills/systematic-debugging/SKILL.md" });
113
+ const acceptance = JSON.stringify({ target: "skills/feature-acceptance/SKILL.md" });
114
+ run(host, "e2e-flaky-fix", debug, 0);
115
+ run(host, "e2e-flaky-fix", acceptance, 1);
116
+ run(host, "e2e-playwright-tests", acceptance, 0);
75
117
  }
76
118
  } finally {
77
119
  fs.rmSync(bin, { recursive: true, force: true });
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 冲突。