@iceinvein/agent-skills 0.25.0 → 0.27.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.
Files changed (44) hide show
  1. package/README.md +14 -5
  2. package/dist/cli/index.js +913 -239
  3. package/package.json +2 -1
  4. package/skills/index.json +4 -4
  5. package/skills/magpie/README.md +24 -6
  6. package/skills/magpie/SKILL.md +35 -18
  7. package/skills/magpie/bin/magpie.ts +28 -0
  8. package/skills/magpie/package.json +1 -1
  9. package/skills/magpie/references/critic.md +2 -2
  10. package/skills/magpie/references/peer-review.md +7 -7
  11. package/skills/magpie/references/proof.md +2 -2
  12. package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
  13. package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
  14. package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
  15. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +45 -4
  16. package/skills/magpie/scripts/peer-run.ts +146 -0
  17. package/skills/magpie/scripts/preflight.ts +20 -20
  18. package/skills/magpie/scripts/setup-cmd.ts +7 -1
  19. package/skills/magpie/skill.json +21 -3
  20. package/skills/sluice/SKILL.md +24 -7
  21. package/skills/sluice/evals/README.md +4 -3
  22. package/skills/sluice/evals/deep-run-mirrors-the-task-list/case.yaml +4 -0
  23. package/skills/sluice/evals/deep-run-mirrors-the-task-list/fixture.sh +304 -0
  24. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/every-task-done.md +7 -0
  25. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/sluice-fired.md +5 -0
  26. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-completed.md +7 -0
  27. package/skills/sluice/evals/deep-run-mirrors-the-task-list/graders/task-list-created.md +8 -0
  28. package/skills/sluice/evals/deep-run-mirrors-the-task-list/prompt.md +13 -0
  29. package/skills/sluice/evals/rules.json +9 -0
  30. package/skills/sluice/references/deep-channel.md +52 -25
  31. package/skills/sluice/references/finish.md +2 -2
  32. package/skills/sluice/references/intent.md +1 -1
  33. package/skills/sluice/references/status.md +18 -7
  34. package/skills/sluice/references/test-first.md +12 -0
  35. package/skills/sluice/scripts/board-index.sh +59 -37
  36. package/skills/sluice/scripts/board.sh +72 -40
  37. package/skills/sluice/scripts/host.sh +60 -0
  38. package/skills/sluice/scripts/postinstall.sh +3 -3
  39. package/skills/sluice/scripts/run-stats.sh +41 -3
  40. package/skills/sluice/scripts/session-start.sh +75 -17
  41. package/skills/sluice/scripts/status.sh +9 -5
  42. package/skills/sluice/scripts/stop-guard.sh +101 -37
  43. package/skills/sluice/scripts/transcript.sh +221 -0
  44. package/skills/sluice/skill.json +28 -4
package/dist/cli/index.js CHANGED
@@ -203,7 +203,8 @@ var TOOL_MARKERS = {
203
203
  claude: (cwd) => existsSync(join(cwd, ".claude")),
204
204
  cursor: (cwd) => existsSync(join(cwd, ".cursor")),
205
205
  codex: (cwd) => existsSync(join(cwd, "AGENTS.md")),
206
- gemini: (cwd) => existsSync(join(cwd, ".gemini"))
206
+ gemini: (cwd) => existsSync(join(cwd, ".gemini")),
207
+ antigravity: () => false
207
208
  };
208
209
  async function detectTools(cwd) {
209
210
  const detected = [];
@@ -216,9 +217,20 @@ async function detectTools(cwd) {
216
217
  }
217
218
 
218
219
  // src/cli/types.ts
219
- var TOOL_NAMES = ["claude", "cursor", "codex", "gemini"];
220
+ var TOOL_NAMES = ["claude", "cursor", "codex", "gemini", "antigravity"];
220
221
  var SKILL_TYPES = ["prompt", "code", "hybrid"];
221
222
  var ACTIVATION_MODES = ["session", "global"];
223
+ var HOST_HOOK_KEYS = ["sessionStart", "stop", "statusline"];
224
+ function resolveInstallConfig(config, isGlobal) {
225
+ if (!isGlobal || config.global === undefined)
226
+ return config;
227
+ const { global, ...resolved } = config;
228
+ if (global.prompt !== undefined)
229
+ resolved.prompt = global.prompt;
230
+ if (global.bundleRoot !== undefined)
231
+ resolved.bundleRoot = global.bundleRoot;
232
+ return resolved;
233
+ }
222
234
  function validateManifest(data) {
223
235
  if (typeof data !== "object" || data === null) {
224
236
  return { ok: false, error: "Manifest must be an object" };
@@ -242,14 +254,36 @@ function validateManifest(data) {
242
254
  if (!Array.isArray(d.tools) || d.tools.length === 0) {
243
255
  return { ok: false, error: "Missing or empty 'tools' array" };
244
256
  }
257
+ const tools = [];
245
258
  for (const tool of d.tools) {
246
- if (!TOOL_NAMES.includes(tool)) {
247
- return { ok: false, error: `Invalid tool '${tool}': must be one of ${TOOL_NAMES.join(", ")}` };
259
+ if (TOOL_NAMES.includes(tool)) {
260
+ tools.push(tool);
261
+ } else {
262
+ console.warn(`Ignoring unsupported tool '${tool}' in 'tools'`);
248
263
  }
249
264
  }
265
+ if (tools.length === 0) {
266
+ return { ok: false, error: `No supported tools in 'tools': must include one of ${TOOL_NAMES.join(", ")}` };
267
+ }
250
268
  if (typeof d.install !== "object" || d.install === null) {
251
269
  return { ok: false, error: "Missing 'install' configuration" };
252
270
  }
271
+ for (const [tool, block] of Object.entries(d.install)) {
272
+ if (typeof block !== "object" || block === null)
273
+ continue;
274
+ const global = block.global;
275
+ if (global === undefined)
276
+ continue;
277
+ if (typeof global !== "object" || global === null || Array.isArray(global)) {
278
+ return { ok: false, error: `'install.${tool}.global' must be an object` };
279
+ }
280
+ for (const field of ["prompt", "bundleRoot"]) {
281
+ const value = global[field];
282
+ if (value !== undefined && typeof value !== "string") {
283
+ return { ok: false, error: `'install.${tool}.global.${field}' must be a string` };
284
+ }
285
+ }
286
+ }
253
287
  if (d.bundle !== undefined) {
254
288
  if (typeof d.bundle !== "object" || d.bundle === null) {
255
289
  return { ok: false, error: "'bundle' must be an object" };
@@ -274,6 +308,7 @@ function validateManifest(data) {
274
308
  }
275
309
  }
276
310
  }
311
+ let hostHooks;
277
312
  if (d.activation !== undefined) {
278
313
  if (typeof d.activation !== "object" || d.activation === null) {
279
314
  return { ok: false, error: "'activation' must be an object" };
@@ -305,6 +340,16 @@ function validateManifest(data) {
305
340
  if (a.claudeStatuslineScript !== undefined && typeof a.claudeStatuslineScript !== "string") {
306
341
  return { ok: false, error: "'activation.claudeStatuslineScript' must be a string" };
307
342
  }
343
+ if (a.claudeEnv !== undefined) {
344
+ if (typeof a.claudeEnv !== "object" || a.claudeEnv === null || Array.isArray(a.claudeEnv)) {
345
+ return { ok: false, error: "'activation.claudeEnv' must be an object" };
346
+ }
347
+ for (const [key, value] of Object.entries(a.claudeEnv)) {
348
+ if (typeof value !== "string") {
349
+ return { ok: false, error: `'activation.claudeEnv.${key}' must be a string` };
350
+ }
351
+ }
352
+ }
308
353
  const claudeBundleRoot = d.install.claude?.bundleRoot;
309
354
  if (claudeBundleRoot === undefined) {
310
355
  for (const field of ["claudeHookScript", "claudeStopScript", "claudeStatuslineScript"]) {
@@ -316,8 +361,31 @@ function validateManifest(data) {
316
361
  }
317
362
  }
318
363
  }
364
+ if (a.hooks !== undefined) {
365
+ if (typeof a.hooks !== "object" || a.hooks === null || Array.isArray(a.hooks)) {
366
+ return { ok: false, error: "'activation.hooks' must be an object" };
367
+ }
368
+ hostHooks = {};
369
+ for (const [key, value] of Object.entries(a.hooks)) {
370
+ if (!HOST_HOOK_KEYS.includes(key)) {
371
+ console.warn(`Ignoring unknown key 'activation.hooks.${key}'`);
372
+ continue;
373
+ }
374
+ if (typeof value !== "string") {
375
+ return { ok: false, error: `'activation.hooks.${key}' must be a string` };
376
+ }
377
+ hostHooks[key] = value;
378
+ }
379
+ const hostHasBundleRoot = Object.entries(d.install).some(([tool, config]) => tool !== "claude" && config?.bundleRoot !== undefined);
380
+ if (!hostHasBundleRoot) {
381
+ return { ok: false, error: "'activation.hooks' is resolved against a tool's 'bundleRoot', and none is set" };
382
+ }
383
+ }
319
384
  }
320
- return { ok: true, manifest: d };
385
+ const manifest = { ...d, tools };
386
+ if (hostHooks !== undefined)
387
+ manifest.activation = { ...manifest.activation, hooks: hostHooks };
388
+ return { ok: true, manifest };
321
389
  }
322
390
 
323
391
  // src/cli/github.ts
@@ -423,9 +491,16 @@ function resolveBundlePaths(entries, bundle) {
423
491
  return [...result].sort();
424
492
  }
425
493
 
494
+ // src/cli/commands/install.ts
495
+ import { join as join9 } from "node:path";
496
+
426
497
  // src/cli/adapters/claude.ts
427
- import { chmodSync, existsSync as existsSync2, mkdirSync, rmSync, rmdirSync, statSync, unlinkSync } from "node:fs";
498
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2 } from "node:fs";
428
499
  import { homedir } from "node:os";
500
+ import { dirname as dirname2, join as join3 } from "node:path";
501
+
502
+ // src/cli/adapters/bundle.ts
503
+ import { chmodSync, existsSync as existsSync2, mkdirSync, rmSync, rmdirSync, statSync, unlinkSync } from "node:fs";
429
504
  import { dirname, join as join2 } from "node:path";
430
505
  function shouldBeExecutable(relPath, content) {
431
506
  if (relPath.endsWith(".sh"))
@@ -446,6 +521,50 @@ function runScript(scriptPath, cwd) {
446
521
  });
447
522
  return { ok: result.exitCode === 0, code: result.exitCode ?? 1 };
448
523
  }
524
+ async function writeBundle(cwd, bundleRoot, files, skip) {
525
+ const written = [];
526
+ for (const [relPath, content] of files) {
527
+ if (skip.has(relPath))
528
+ continue;
529
+ const targetRel = join2(bundleRoot, relPath);
530
+ const targetPath = join2(cwd, targetRel);
531
+ mkdirSync(dirname(targetPath), { recursive: true });
532
+ await Bun.write(targetPath, content);
533
+ if (shouldBeExecutable(relPath, content)) {
534
+ chmodSync(targetPath, 493);
535
+ }
536
+ written.push(targetRel);
537
+ }
538
+ return written;
539
+ }
540
+ function removeInstalledFiles(cwd, files, stops, keep) {
541
+ for (const file of files) {
542
+ if (keep.has(file))
543
+ continue;
544
+ const fullPath = join2(cwd, file);
545
+ if (!existsSync2(fullPath))
546
+ continue;
547
+ try {
548
+ const stat = statSync(fullPath);
549
+ if (stat.isDirectory()) {
550
+ rmSync(fullPath, { recursive: true, force: true });
551
+ } else {
552
+ unlinkSync(fullPath);
553
+ }
554
+ } catch {}
555
+ let dir = dirname(fullPath);
556
+ while (!stops.includes(dir) && dir.startsWith(`${cwd}/`)) {
557
+ try {
558
+ rmdirSync(dir);
559
+ } catch {
560
+ break;
561
+ }
562
+ dir = dirname(dir);
563
+ }
564
+ }
565
+ }
566
+
567
+ // src/cli/adapters/claude.ts
449
568
  function shq(s) {
450
569
  return "'" + s.replace(/'/g, "'\\''") + "'";
451
570
  }
@@ -458,13 +577,13 @@ function matchesSkillDirective(hook, skillName, directive) {
458
577
  }
459
578
  function commandRunsScript(command, scriptPath, settingsPath) {
460
579
  const home = homedir();
461
- const config = dirname(settingsPath);
580
+ const config = dirname2(settingsPath);
462
581
  const expanded = command.replaceAll("${CLAUDE_CONFIG_DIR:-$HOME/.claude}", config).replaceAll("${CLAUDE_CONFIG_DIR:-${HOME}/.claude}", config).replaceAll("${CLAUDE_CONFIG_DIR}", config).replaceAll("$CLAUDE_CONFIG_DIR", config).replaceAll("${HOME}", home).replaceAll("$HOME", home).replaceAll("~/", `${home}/`);
463
582
  return expanded.includes(scriptPath);
464
583
  }
465
584
  async function wireSessionStartHook(settingsPath, skillName, directive, scriptPath) {
466
585
  let settings = {};
467
- if (existsSync2(settingsPath)) {
586
+ if (existsSync3(settingsPath)) {
468
587
  settings = await Bun.file(settingsPath).json();
469
588
  }
470
589
  if (!settings.hooks)
@@ -514,7 +633,7 @@ async function wireSessionStartHook(settingsPath, skillName, directive, scriptPa
514
633
  console.warn(`${skillName}: a hand-edited SessionStart hook already carries its directive, so it was left as is and ${scriptPath} was not wired; add it to that entry yourself if you want it.`);
515
634
  }
516
635
  if (changed) {
517
- mkdirSync(dirname(settingsPath), { recursive: true });
636
+ mkdirSync2(dirname2(settingsPath), { recursive: true });
518
637
  await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
519
638
  `);
520
639
  }
@@ -523,12 +642,12 @@ async function wireSessionStartHook(settingsPath, skillName, directive, scriptPa
523
642
  settings.hooks.SessionStart.push({
524
643
  hooks: [{ type: "command", command, skill: skillName }]
525
644
  });
526
- mkdirSync(dirname(settingsPath), { recursive: true });
645
+ mkdirSync2(dirname2(settingsPath), { recursive: true });
527
646
  await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
528
647
  `);
529
648
  }
530
649
  async function unwireSessionStartHook(settingsPath, skillName, directive) {
531
- if (!existsSync2(settingsPath))
650
+ if (!existsSync3(settingsPath))
532
651
  return;
533
652
  const settings = await Bun.file(settingsPath).json();
534
653
  const sessionStart = settings.hooks?.SessionStart;
@@ -552,7 +671,7 @@ async function unwireSessionStartHook(settingsPath, skillName, directive) {
552
671
  }
553
672
  async function wireStopHook(settingsPath, skillName, scriptPath) {
554
673
  let settings = {};
555
- if (existsSync2(settingsPath)) {
674
+ if (existsSync3(settingsPath)) {
556
675
  settings = await Bun.file(settingsPath).json();
557
676
  }
558
677
  if (!settings.hooks)
@@ -572,12 +691,12 @@ async function wireStopHook(settingsPath, skillName, scriptPath) {
572
691
  if (!found) {
573
692
  settings.hooks.Stop.push({ hooks: [{ type: "command", command, skill: skillName }] });
574
693
  }
575
- mkdirSync(dirname(settingsPath), { recursive: true });
694
+ mkdirSync2(dirname2(settingsPath), { recursive: true });
576
695
  await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
577
696
  `);
578
697
  }
579
698
  async function unwireStopHook(settingsPath, skillName) {
580
- if (!existsSync2(settingsPath))
699
+ if (!existsSync3(settingsPath))
581
700
  return;
582
701
  const settings = await Bun.file(settingsPath).json();
583
702
  const stop = settings.hooks?.Stop;
@@ -610,7 +729,7 @@ function ownsStatusLine(command, skillName, scriptPath) {
610
729
  }
611
730
  async function wireStatusLine(settingsPath, skillName, scriptPath) {
612
731
  let settings = {};
613
- if (existsSync2(settingsPath)) {
732
+ if (existsSync3(settingsPath)) {
614
733
  settings = await Bun.file(settingsPath).json();
615
734
  }
616
735
  const existing = settings.statusLine;
@@ -622,12 +741,68 @@ async function wireStatusLine(settingsPath, skillName, scriptPath) {
622
741
  if (existing?.type === "command" && existing?.command === command)
623
742
  return;
624
743
  settings.statusLine = { type: "command", command };
625
- mkdirSync(dirname(settingsPath), { recursive: true });
744
+ mkdirSync2(dirname2(settingsPath), { recursive: true });
745
+ await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
746
+ `);
747
+ }
748
+ async function holdsStatusLine(settingsPath, skillName) {
749
+ if (!existsSync3(settingsPath))
750
+ return false;
751
+ const settings = await Bun.file(settingsPath).json();
752
+ return ownsStatusLine(settings.statusLine?.command, skillName);
753
+ }
754
+ async function wireEnv(settingsPath, env) {
755
+ let settings = {};
756
+ if (existsSync3(settingsPath)) {
757
+ settings = await Bun.file(settingsPath).json();
758
+ }
759
+ const added = {};
760
+ for (const [key, value] of Object.entries(env)) {
761
+ if (settings.env !== undefined && key in settings.env)
762
+ continue;
763
+ settings.env = { ...settings.env, [key]: value };
764
+ added[key] = value;
765
+ }
766
+ if (Object.keys(added).length === 0)
767
+ return added;
768
+ mkdirSync2(dirname2(settingsPath), { recursive: true });
769
+ await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
770
+ `);
771
+ return added;
772
+ }
773
+ async function heldEnv(settingsPath, recorded) {
774
+ if (!existsSync3(settingsPath))
775
+ return {};
776
+ const settings = await Bun.file(settingsPath).json();
777
+ const held = {};
778
+ for (const [key, value] of Object.entries(recorded)) {
779
+ if (settings.env?.[key] === value)
780
+ held[key] = value;
781
+ }
782
+ return held;
783
+ }
784
+ async function unwireEnv(settingsPath, added) {
785
+ if (!existsSync3(settingsPath))
786
+ return;
787
+ const settings = await Bun.file(settingsPath).json();
788
+ if (settings.env === undefined)
789
+ return;
790
+ let changed = false;
791
+ for (const [key, value] of Object.entries(added)) {
792
+ if (settings.env[key] !== value)
793
+ continue;
794
+ delete settings.env[key];
795
+ changed = true;
796
+ }
797
+ if (!changed)
798
+ return;
799
+ if (Object.keys(settings.env).length === 0)
800
+ delete settings.env;
626
801
  await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
627
802
  `);
628
803
  }
629
804
  async function unwireStatusLine(settingsPath, skillName, scriptPath) {
630
- if (!existsSync2(settingsPath))
805
+ if (!existsSync3(settingsPath))
631
806
  return;
632
807
  const settings = await Bun.file(settingsPath).json();
633
808
  if (settings.statusLine === undefined || settings.statusLine === null)
@@ -640,48 +815,37 @@ async function unwireStatusLine(settingsPath, skillName, scriptPath) {
640
815
  }
641
816
  var claudeAdapter = {
642
817
  name: "claude",
643
- async install(cwd, manifest, files, activation) {
818
+ async install(cwd, manifest, files, activation, _isGlobal, options) {
644
819
  const installed = [];
645
820
  const config = manifest.install.claude;
646
821
  if (!config)
647
822
  return installed;
648
823
  if (config.prompt && files.has(manifest.files?.prompt ?? "")) {
649
- const targetPath = join2(cwd, config.prompt);
650
- mkdirSync(dirname(targetPath), { recursive: true });
824
+ const targetPath = join3(cwd, config.prompt);
825
+ mkdirSync2(dirname2(targetPath), { recursive: true });
651
826
  await Bun.write(targetPath, files.get(manifest.files.prompt));
652
827
  installed.push(config.prompt);
653
828
  }
654
829
  if (config.supporting) {
655
830
  for (const [sourceFile, targetRel] of Object.entries(config.supporting)) {
656
831
  if (files.has(sourceFile)) {
657
- const targetPath = join2(cwd, targetRel);
658
- mkdirSync(dirname(targetPath), { recursive: true });
832
+ const targetPath = join3(cwd, targetRel);
833
+ mkdirSync2(dirname2(targetPath), { recursive: true });
659
834
  await Bun.write(targetPath, files.get(sourceFile));
660
835
  installed.push(targetRel);
661
836
  }
662
837
  }
663
838
  }
664
839
  if (config.bundleRoot && manifest.bundle) {
665
- const promptPath = manifest.files?.prompt;
666
- for (const [relPath, content] of files) {
667
- if (relPath === promptPath)
668
- continue;
669
- if (config.supporting && Object.hasOwn(config.supporting, relPath))
670
- continue;
671
- const targetRel = join2(config.bundleRoot, relPath);
672
- const targetPath = join2(cwd, targetRel);
673
- mkdirSync(dirname(targetPath), { recursive: true });
674
- await Bun.write(targetPath, content);
675
- if (shouldBeExecutable(relPath, content)) {
676
- chmodSync(targetPath, 493);
677
- }
678
- installed.push(targetRel);
679
- }
840
+ const skip = new Set(Object.keys(config.supporting ?? {}));
841
+ if (manifest.files?.prompt)
842
+ skip.add(manifest.files.prompt);
843
+ installed.push(...await writeBundle(cwd, config.bundleRoot, files, skip));
680
844
  }
681
845
  if (config.mcpServers) {
682
- const settingsPath = join2(cwd, ".claude/settings.json");
846
+ const settingsPath = join3(cwd, ".claude/settings.json");
683
847
  let settings = {};
684
- if (existsSync2(settingsPath)) {
848
+ if (existsSync3(settingsPath)) {
685
849
  settings = await Bun.file(settingsPath).json();
686
850
  }
687
851
  if (!settings.mcpServers)
@@ -694,31 +858,34 @@ var claudeAdapter = {
694
858
  installed.push(".claude/settings.json");
695
859
  }
696
860
  if (activation === "global" && manifest.activation?.claudeHookDirective) {
697
- const settingsPath = join2(cwd, ".claude/settings.json");
861
+ const settingsPath = join3(cwd, ".claude/settings.json");
698
862
  const script = manifest.activation.claudeHookScript;
699
- const scriptPath = script && config.bundleRoot ? join2(cwd, config.bundleRoot, script) : undefined;
863
+ const scriptPath = script && config.bundleRoot ? join3(cwd, config.bundleRoot, script) : undefined;
700
864
  await wireSessionStartHook(settingsPath, manifest.name, manifest.activation.claudeHookDirective, scriptPath);
701
865
  if (!installed.includes(".claude/settings.json")) {
702
866
  installed.push(".claude/settings.json");
703
867
  }
704
868
  }
705
869
  if (activation === "global" && manifest.activation?.claudeStopScript && config.bundleRoot) {
706
- const settingsPath = join2(cwd, ".claude/settings.json");
707
- await wireStopHook(settingsPath, manifest.name, join2(cwd, config.bundleRoot, manifest.activation.claudeStopScript));
870
+ const settingsPath = join3(cwd, ".claude/settings.json");
871
+ await wireStopHook(settingsPath, manifest.name, join3(cwd, config.bundleRoot, manifest.activation.claudeStopScript));
708
872
  if (!installed.includes(".claude/settings.json")) {
709
873
  installed.push(".claude/settings.json");
710
874
  }
711
875
  }
712
- if (activation === "global" && manifest.activation?.claudeStatuslineScript && config.bundleRoot) {
713
- const settingsPath = join2(cwd, ".claude/settings.json");
714
- await wireStatusLine(settingsPath, manifest.name, join2(cwd, config.bundleRoot, manifest.activation.claudeStatuslineScript));
876
+ if (activation === "global" && options?.statusline && manifest.activation?.claudeStatuslineScript && config.bundleRoot) {
877
+ const settingsPath = join3(cwd, ".claude/settings.json");
878
+ await wireStatusLine(settingsPath, manifest.name, join3(cwd, config.bundleRoot, manifest.activation.claudeStatuslineScript));
715
879
  if (!installed.includes(".claude/settings.json")) {
716
880
  installed.push(".claude/settings.json");
717
881
  }
718
882
  }
883
+ if (options?.statusline === false && manifest.activation?.claudeStatuslineScript && config.bundleRoot) {
884
+ await unwireStatusLine(join3(cwd, ".claude/settings.json"), manifest.name, join3(cwd, config.bundleRoot, manifest.activation.claudeStatuslineScript));
885
+ }
719
886
  if (config.postinstall && config.bundleRoot) {
720
- const scriptPath = join2(cwd, config.bundleRoot, config.postinstall);
721
- const result = runScript(scriptPath, join2(cwd, config.bundleRoot));
887
+ const scriptPath = join3(cwd, config.bundleRoot, config.postinstall);
888
+ const result = runScript(scriptPath, join3(cwd, config.bundleRoot));
722
889
  if (!result.ok) {
723
890
  console.error(`postinstall script '${config.postinstall}' exited with code ${result.code}`);
724
891
  }
@@ -730,42 +897,19 @@ var claudeAdapter = {
730
897
  if (!config)
731
898
  return;
732
899
  if (config.postremove && config.bundleRoot) {
733
- const scriptPath = join2(cwd, config.bundleRoot, config.postremove);
734
- const result = runScript(scriptPath, join2(cwd, config.bundleRoot));
900
+ const scriptPath = join3(cwd, config.bundleRoot, config.postremove);
901
+ const result = runScript(scriptPath, join3(cwd, config.bundleRoot));
735
902
  if (!result.ok) {
736
903
  console.error(`postremove script '${config.postremove}' exited with code ${result.code}`);
737
904
  }
738
905
  }
739
- for (const file of installedFiles) {
740
- if (file === ".claude/settings.json")
741
- continue;
742
- const fullPath = join2(cwd, file);
743
- if (existsSync2(fullPath)) {
744
- try {
745
- const stat = statSync(fullPath);
746
- if (stat.isDirectory()) {
747
- rmSync(fullPath, { recursive: true, force: true });
748
- } else {
749
- unlinkSync(fullPath);
750
- }
751
- } catch {}
752
- const stops = [join2(cwd, ".claude"), cwd];
753
- if (config.bundleRoot)
754
- stops.push(join2(cwd, config.bundleRoot, ".."));
755
- let dir = dirname(fullPath);
756
- while (!stops.includes(dir) && dir.startsWith(`${cwd}/`)) {
757
- try {
758
- rmdirSync(dir);
759
- } catch {
760
- break;
761
- }
762
- dir = dirname(dir);
763
- }
764
- }
765
- }
906
+ const stops = [join3(cwd, ".claude"), cwd];
907
+ if (config.bundleRoot)
908
+ stops.push(join3(cwd, config.bundleRoot, ".."));
909
+ removeInstalledFiles(cwd, installedFiles, stops, new Set([".claude/settings.json"]));
766
910
  if (config.mcpServers) {
767
- const settingsPath = join2(cwd, ".claude/settings.json");
768
- if (existsSync2(settingsPath)) {
911
+ const settingsPath = join3(cwd, ".claude/settings.json");
912
+ if (existsSync3(settingsPath)) {
769
913
  const settings = await Bun.file(settingsPath).json();
770
914
  if (settings.mcpServers) {
771
915
  for (const name of Object.keys(config.mcpServers)) {
@@ -777,21 +921,21 @@ var claudeAdapter = {
777
921
  }
778
922
  }
779
923
  if (manifest.activation?.claudeHookDirective) {
780
- const settingsPath = join2(cwd, ".claude/settings.json");
924
+ const settingsPath = join3(cwd, ".claude/settings.json");
781
925
  await unwireSessionStartHook(settingsPath, manifest.name, manifest.activation.claudeHookDirective);
782
926
  }
783
927
  if (manifest.activation?.claudeStopScript) {
784
- await unwireStopHook(join2(cwd, ".claude/settings.json"), manifest.name);
928
+ await unwireStopHook(join3(cwd, ".claude/settings.json"), manifest.name);
785
929
  }
786
930
  if (manifest.activation?.claudeStatuslineScript && config.bundleRoot) {
787
- await unwireStatusLine(join2(cwd, ".claude/settings.json"), manifest.name, join2(cwd, config.bundleRoot, manifest.activation.claudeStatuslineScript));
931
+ await unwireStatusLine(join3(cwd, ".claude/settings.json"), manifest.name, join3(cwd, config.bundleRoot, manifest.activation.claudeStatuslineScript));
788
932
  }
789
933
  }
790
934
  };
791
935
 
792
936
  // src/cli/adapters/cursor.ts
793
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, unlinkSync as unlinkSync2, rmdirSync as rmdirSync2 } from "node:fs";
794
- import { dirname as dirname2, join as join3 } from "node:path";
937
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2, rmdirSync as rmdirSync2 } from "node:fs";
938
+ import { dirname as dirname3, join as join4 } from "node:path";
795
939
  var cursorAdapter = {
796
940
  name: "cursor",
797
941
  async install(cwd, manifest, files, _activation) {
@@ -800,25 +944,25 @@ var cursorAdapter = {
800
944
  if (!config)
801
945
  return installed;
802
946
  if (config.prompt && files.has(manifest.files?.prompt ?? "")) {
803
- const targetPath = join3(cwd, config.prompt);
804
- mkdirSync2(dirname2(targetPath), { recursive: true });
947
+ const targetPath = join4(cwd, config.prompt);
948
+ mkdirSync3(dirname3(targetPath), { recursive: true });
805
949
  await Bun.write(targetPath, files.get(manifest.files.prompt));
806
950
  installed.push(config.prompt);
807
951
  }
808
952
  if (config.supporting) {
809
953
  for (const [sourceFile, targetRel] of Object.entries(config.supporting)) {
810
954
  if (files.has(sourceFile)) {
811
- const targetPath = join3(cwd, targetRel);
812
- mkdirSync2(dirname2(targetPath), { recursive: true });
955
+ const targetPath = join4(cwd, targetRel);
956
+ mkdirSync3(dirname3(targetPath), { recursive: true });
813
957
  await Bun.write(targetPath, files.get(sourceFile));
814
958
  installed.push(targetRel);
815
959
  }
816
960
  }
817
961
  }
818
962
  if (config.mcpServers) {
819
- const mcpPath = join3(cwd, ".cursor/mcp.json");
963
+ const mcpPath = join4(cwd, ".cursor/mcp.json");
820
964
  let mcpConfig = {};
821
- if (existsSync3(mcpPath)) {
965
+ if (existsSync4(mcpPath)) {
822
966
  mcpConfig = await Bun.file(mcpPath).json();
823
967
  }
824
968
  if (!mcpConfig.mcpServers)
@@ -839,17 +983,17 @@ var cursorAdapter = {
839
983
  for (const file of installedFiles) {
840
984
  if (file === ".cursor/mcp.json")
841
985
  continue;
842
- const fullPath = join3(cwd, file);
843
- if (existsSync3(fullPath)) {
986
+ const fullPath = join4(cwd, file);
987
+ if (existsSync4(fullPath)) {
844
988
  unlinkSync2(fullPath);
845
989
  try {
846
- rmdirSync2(dirname2(fullPath));
990
+ rmdirSync2(dirname3(fullPath));
847
991
  } catch {}
848
992
  }
849
993
  }
850
994
  if (config.mcpServers) {
851
- const mcpPath = join3(cwd, ".cursor/mcp.json");
852
- if (existsSync3(mcpPath)) {
995
+ const mcpPath = join4(cwd, ".cursor/mcp.json");
996
+ if (existsSync4(mcpPath)) {
853
997
  const mcpConfig = await Bun.file(mcpPath).json();
854
998
  if (mcpConfig.mcpServers) {
855
999
  for (const name of Object.keys(config.mcpServers)) {
@@ -864,11 +1008,106 @@ var cursorAdapter = {
864
1008
  };
865
1009
 
866
1010
  // src/cli/adapters/codex.ts
867
- import { existsSync as existsSync4 } from "node:fs";
868
- import { join as join4 } from "node:path";
1011
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4 } from "node:fs";
1012
+ import { dirname as dirname4, join as join5 } from "node:path";
1013
+ function shq2(s) {
1014
+ return "'" + s.replace(/'/g, "'\\''") + "'";
1015
+ }
1016
+ function isOurs(hook, bundleDir) {
1017
+ return (hook.command ?? "").includes(shq2(`${bundleDir}/`).slice(0, -1));
1018
+ }
1019
+ function codexHooksPath(cwd, isGlobal) {
1020
+ const codexHome = process.env.CODEX_HOME;
1021
+ return isGlobal && codexHome ? join5(codexHome, "hooks.json") : join5(cwd, ".codex/hooks.json");
1022
+ }
1023
+ function codexHooksPathsToUnwire(cwd, isGlobal) {
1024
+ const projectPath = join5(cwd, ".codex/hooks.json");
1025
+ const path = codexHooksPath(cwd, isGlobal);
1026
+ return path === projectPath ? [path] : [path, projectPath];
1027
+ }
1028
+ async function wireCodexHooks(hooksPath, bundleDir, directive, hooks) {
1029
+ const file = existsSync5(hooksPath) ? await Bun.file(hooksPath).json() : {};
1030
+ if (!file.hooks)
1031
+ file.hooks = {};
1032
+ const commands = {};
1033
+ if (hooks.sessionStart) {
1034
+ const script = shq2(join5(bundleDir, hooks.sessionStart));
1035
+ const run = `if [ -f ${script} ]; then bash ${script} --host codex; fi`;
1036
+ commands.SessionStart = directive === undefined ? run : `echo ${shq2(directive)}; ${run}`;
1037
+ }
1038
+ if (hooks.stop) {
1039
+ const script = shq2(join5(bundleDir, hooks.stop));
1040
+ commands.Stop = `if [ -f ${script} ]; then bash ${script} --host codex; fi`;
1041
+ }
1042
+ const events = new Set([...Object.keys(file.hooks), ...Object.keys(commands)]);
1043
+ for (const event of events) {
1044
+ const command = commands[event];
1045
+ const ourHook = { type: "command", command, timeout: 10 };
1046
+ let placed = false;
1047
+ const kept = [];
1048
+ for (const group of file.hooks[event] ?? []) {
1049
+ const groupHooks = group.hooks ?? [];
1050
+ if (!groupHooks.some((h) => isOurs(h, bundleDir))) {
1051
+ kept.push(group);
1052
+ continue;
1053
+ }
1054
+ const next = [];
1055
+ for (const hook of groupHooks) {
1056
+ if (!isOurs(hook, bundleDir))
1057
+ next.push(hook);
1058
+ else if (command !== undefined && !placed) {
1059
+ next.push(ourHook);
1060
+ placed = true;
1061
+ }
1062
+ }
1063
+ if (next.length > 0)
1064
+ kept.push({ ...group, hooks: next });
1065
+ }
1066
+ if (command !== undefined && !placed)
1067
+ kept.push({ hooks: [ourHook] });
1068
+ if (kept.length > 0)
1069
+ file.hooks[event] = kept;
1070
+ else if ((file.hooks[event] ?? []).length > 0)
1071
+ delete file.hooks[event];
1072
+ }
1073
+ mkdirSync4(dirname4(hooksPath), { recursive: true });
1074
+ await Bun.write(hooksPath, JSON.stringify(file, null, 2) + `
1075
+ `);
1076
+ }
1077
+ async function unwireCodexHooks(hooksPath, bundleDir) {
1078
+ if (!existsSync5(hooksPath))
1079
+ return;
1080
+ const file = await Bun.file(hooksPath).json();
1081
+ if (!file.hooks)
1082
+ return;
1083
+ let changed = false;
1084
+ for (const [event, groups] of Object.entries(file.hooks)) {
1085
+ const kept = [];
1086
+ for (const group of groups) {
1087
+ const hooks = (group.hooks ?? []).filter((h) => !isOurs(h, bundleDir));
1088
+ if (hooks.length === (group.hooks ?? []).length) {
1089
+ kept.push(group);
1090
+ continue;
1091
+ }
1092
+ changed = true;
1093
+ if (hooks.length > 0)
1094
+ kept.push({ ...group, hooks });
1095
+ }
1096
+ if (kept.length === 0)
1097
+ delete file.hooks[event];
1098
+ else
1099
+ file.hooks[event] = kept;
1100
+ }
1101
+ if (!changed)
1102
+ return;
1103
+ if (Object.keys(file.hooks).length === 0)
1104
+ delete file.hooks;
1105
+ await Bun.write(hooksPath, JSON.stringify(file, null, 2) + `
1106
+ `);
1107
+ }
869
1108
  var codexAdapter = {
870
1109
  name: "codex",
871
- async install(cwd, manifest, files, _activation) {
1110
+ async install(cwd, manifest, files, activation, isGlobal) {
872
1111
  const installed = [];
873
1112
  const config = manifest.install.codex;
874
1113
  if (!config)
@@ -878,9 +1117,9 @@ var codexAdapter = {
878
1117
  return installed;
879
1118
  }
880
1119
  if (config.append && config.prompt && files.has(manifest.files?.prompt ?? "")) {
881
- const agentsPath = join4(cwd, config.prompt);
1120
+ const agentsPath = join5(cwd, config.prompt);
882
1121
  let existing = "";
883
- if (existsSync4(agentsPath)) {
1122
+ if (existsSync5(agentsPath)) {
884
1123
  existing = await Bun.file(agentsPath).text();
885
1124
  }
886
1125
  const content = files.get(manifest.files.prompt);
@@ -895,15 +1134,36 @@ var codexAdapter = {
895
1134
  await Bun.write(agentsPath, existing + section);
896
1135
  installed.push("AGENTS.md");
897
1136
  }
1137
+ if (!config.append && config.prompt && files.has(manifest.files?.prompt ?? "")) {
1138
+ const targetPath = join5(cwd, config.prompt);
1139
+ mkdirSync4(dirname4(targetPath), { recursive: true });
1140
+ await Bun.write(targetPath, files.get(manifest.files.prompt));
1141
+ installed.push(config.prompt);
1142
+ if (config.bundleRoot && manifest.bundle) {
1143
+ const skip = new Set([manifest.files.prompt]);
1144
+ installed.push(...await writeBundle(cwd, config.bundleRoot, files, skip));
1145
+ }
1146
+ if (config.postinstall && config.bundleRoot) {
1147
+ const scriptPath = join5(cwd, config.bundleRoot, config.postinstall);
1148
+ const result = runScript(scriptPath, join5(cwd, config.bundleRoot));
1149
+ if (!result.ok) {
1150
+ console.error(`postinstall script '${config.postinstall}' exited with code ${result.code}`);
1151
+ }
1152
+ }
1153
+ if (activation === "global" && manifest.activation?.hooks && config.bundleRoot) {
1154
+ await wireCodexHooks(codexHooksPath(cwd, isGlobal), join5(cwd, config.bundleRoot), manifest.activation.claudeHookDirective, manifest.activation.hooks);
1155
+ console.log("Codex runs these hooks only after you trust them: open /hooks in Codex.");
1156
+ }
1157
+ }
898
1158
  return installed;
899
1159
  },
900
- async remove(cwd, manifest, _installedFiles) {
1160
+ async remove(cwd, manifest, installedFiles, isGlobal) {
901
1161
  const config = manifest.install.codex;
902
1162
  if (!config)
903
1163
  return;
904
1164
  if (config.append && config.prompt) {
905
- const agentsPath = join4(cwd, config.prompt);
906
- if (existsSync4(agentsPath)) {
1165
+ const agentsPath = join5(cwd, config.prompt);
1166
+ if (existsSync5(agentsPath)) {
907
1167
  const content = await Bun.file(agentsPath).text();
908
1168
  const startMarker = `<!-- agent-skills:start:${manifest.name} -->`;
909
1169
  const endMarker = `<!-- agent-skills:end:${manifest.name} -->`;
@@ -916,12 +1176,32 @@ var codexAdapter = {
916
1176
  }
917
1177
  }
918
1178
  }
1179
+ if (!config.append && config.prompt) {
1180
+ if (config.bundleRoot) {
1181
+ for (const hooksPath of codexHooksPathsToUnwire(cwd, isGlobal)) {
1182
+ await unwireCodexHooks(hooksPath, join5(cwd, config.bundleRoot));
1183
+ }
1184
+ }
1185
+ if (config.postremove && config.bundleRoot) {
1186
+ const scriptPath = join5(cwd, config.bundleRoot, config.postremove);
1187
+ const result = runScript(scriptPath, join5(cwd, config.bundleRoot));
1188
+ if (!result.ok) {
1189
+ console.error(`postremove script '${config.postremove}' exited with code ${result.code}`);
1190
+ }
1191
+ }
1192
+ const stops = [cwd];
1193
+ if (config.bundleRoot)
1194
+ stops.push(join5(cwd, config.bundleRoot, ".."));
1195
+ else
1196
+ stops.push(join5(cwd, dirname4(config.prompt), ".."));
1197
+ removeInstalledFiles(cwd, installedFiles, stops, new Set);
1198
+ }
919
1199
  }
920
1200
  };
921
1201
 
922
1202
  // src/cli/adapters/gemini.ts
923
- import { existsSync as existsSync5, mkdirSync as mkdirSync3, unlinkSync as unlinkSync3, rmdirSync as rmdirSync3 } from "node:fs";
924
- import { dirname as dirname3, join as join5 } from "node:path";
1203
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, unlinkSync as unlinkSync3, rmdirSync as rmdirSync3 } from "node:fs";
1204
+ import { dirname as dirname5, join as join6 } from "node:path";
925
1205
  var geminiAdapter = {
926
1206
  name: "gemini",
927
1207
  async install(cwd, manifest, files, _activation) {
@@ -930,25 +1210,25 @@ var geminiAdapter = {
930
1210
  if (!config)
931
1211
  return installed;
932
1212
  if (config.prompt && files.has(manifest.files?.prompt ?? "")) {
933
- const targetPath = join5(cwd, config.prompt);
934
- mkdirSync3(dirname3(targetPath), { recursive: true });
1213
+ const targetPath = join6(cwd, config.prompt);
1214
+ mkdirSync5(dirname5(targetPath), { recursive: true });
935
1215
  await Bun.write(targetPath, files.get(manifest.files.prompt));
936
1216
  installed.push(config.prompt);
937
1217
  }
938
1218
  if (config.supporting) {
939
1219
  for (const [sourceFile, targetRel] of Object.entries(config.supporting)) {
940
1220
  if (files.has(sourceFile)) {
941
- const targetPath = join5(cwd, targetRel);
942
- mkdirSync3(dirname3(targetPath), { recursive: true });
1221
+ const targetPath = join6(cwd, targetRel);
1222
+ mkdirSync5(dirname5(targetPath), { recursive: true });
943
1223
  await Bun.write(targetPath, files.get(sourceFile));
944
1224
  installed.push(targetRel);
945
1225
  }
946
1226
  }
947
1227
  }
948
1228
  if (config.mcpServers) {
949
- const settingsPath = join5(cwd, ".gemini/settings.json");
1229
+ const settingsPath = join6(cwd, ".gemini/settings.json");
950
1230
  let settings = {};
951
- if (existsSync5(settingsPath)) {
1231
+ if (existsSync6(settingsPath)) {
952
1232
  settings = await Bun.file(settingsPath).json();
953
1233
  }
954
1234
  if (!settings.mcpServers)
@@ -969,17 +1249,17 @@ var geminiAdapter = {
969
1249
  for (const file of installedFiles) {
970
1250
  if (file === ".gemini/settings.json")
971
1251
  continue;
972
- const fullPath = join5(cwd, file);
973
- if (existsSync5(fullPath)) {
1252
+ const fullPath = join6(cwd, file);
1253
+ if (existsSync6(fullPath)) {
974
1254
  unlinkSync3(fullPath);
975
1255
  try {
976
- rmdirSync3(dirname3(fullPath));
1256
+ rmdirSync3(dirname5(fullPath));
977
1257
  } catch {}
978
1258
  }
979
1259
  }
980
1260
  if (config.mcpServers) {
981
- const settingsPath = join5(cwd, ".gemini/settings.json");
982
- if (existsSync5(settingsPath)) {
1261
+ const settingsPath = join6(cwd, ".gemini/settings.json");
1262
+ if (existsSync6(settingsPath)) {
983
1263
  const settings = await Bun.file(settingsPath).json();
984
1264
  if (settings.mcpServers) {
985
1265
  for (const name of Object.keys(config.mcpServers)) {
@@ -993,36 +1273,224 @@ var geminiAdapter = {
993
1273
  }
994
1274
  };
995
1275
 
1276
+ // src/cli/adapters/antigravity.ts
1277
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6 } from "node:fs";
1278
+ import { dirname as dirname6, join as join7 } from "node:path";
1279
+ function shq3(s) {
1280
+ return "'" + s.replace(/'/g, "'\\''") + "'";
1281
+ }
1282
+ async function wireAntigravityHooks(hooksPath, groupName, bundleDir, directive, hooks) {
1283
+ let file = {};
1284
+ if (existsSync7(hooksPath)) {
1285
+ file = await Bun.file(hooksPath).json();
1286
+ }
1287
+ const group = {};
1288
+ if (hooks.sessionStart) {
1289
+ const script = shq3(join7(bundleDir, hooks.sessionStart));
1290
+ let args = "--host antigravity";
1291
+ if (directive !== undefined)
1292
+ args += ` --directive ${shq3(directive)}`;
1293
+ const command = `if [ -f ${script} ]; then bash ${script} ${args}; fi`;
1294
+ group.SessionStart = [{ type: "command", command, timeout: 10 }];
1295
+ }
1296
+ if (hooks.stop) {
1297
+ const script = shq3(join7(bundleDir, hooks.stop));
1298
+ const command = `if [ -f ${script} ]; then bash ${script} --host antigravity; fi`;
1299
+ group.Stop = [{ type: "command", command, timeout: 10 }];
1300
+ }
1301
+ if (Object.keys(group).length === 0) {
1302
+ if (!(groupName in file))
1303
+ return;
1304
+ delete file[groupName];
1305
+ } else {
1306
+ file[groupName] = group;
1307
+ }
1308
+ mkdirSync6(dirname6(hooksPath), { recursive: true });
1309
+ await Bun.write(hooksPath, JSON.stringify(file, null, 2) + `
1310
+ `);
1311
+ }
1312
+ async function unwireAntigravityHooks(hooksPath, groupName) {
1313
+ if (!existsSync7(hooksPath))
1314
+ return;
1315
+ const file = await Bun.file(hooksPath).json();
1316
+ if (!(groupName in file))
1317
+ return;
1318
+ delete file[groupName];
1319
+ await Bun.write(hooksPath, JSON.stringify(file, null, 2) + `
1320
+ `);
1321
+ }
1322
+ async function wireAntigravityStatusLine(settingsPath, command) {
1323
+ let settings = {};
1324
+ if (existsSync7(settingsPath)) {
1325
+ settings = await Bun.file(settingsPath).json();
1326
+ }
1327
+ if (settings.statusLine !== undefined && settings.statusLine !== null)
1328
+ return false;
1329
+ settings.statusLine = { type: "command", command };
1330
+ mkdirSync6(dirname6(settingsPath), { recursive: true });
1331
+ await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
1332
+ `);
1333
+ return true;
1334
+ }
1335
+ async function holdsAntigravityStatusLine(settingsPath, bundleDir) {
1336
+ if (!existsSync7(settingsPath))
1337
+ return false;
1338
+ const settings = await Bun.file(settingsPath).json();
1339
+ const statusLine = settings.statusLine;
1340
+ const command = typeof statusLine === "object" && statusLine !== null && "command" in statusLine ? statusLine.command : undefined;
1341
+ return typeof command === "string" && command.includes(`${bundleDir}/`);
1342
+ }
1343
+ async function unwireAntigravityStatusLine(settingsPath, bundleDir) {
1344
+ if (!await holdsAntigravityStatusLine(settingsPath, bundleDir))
1345
+ return;
1346
+ const settings = await Bun.file(settingsPath).json();
1347
+ delete settings.statusLine;
1348
+ await Bun.write(settingsPath, JSON.stringify(settings, null, 2) + `
1349
+ `);
1350
+ }
1351
+ function isGlobalInstall(bundleRoot) {
1352
+ return bundleRoot.startsWith(".gemini/");
1353
+ }
1354
+ function hooksPathFor(cwd, bundleRoot) {
1355
+ return isGlobalInstall(bundleRoot) ? join7(cwd, ".gemini/config/hooks.json") : join7(cwd, ".agents/hooks.json");
1356
+ }
1357
+ var SETTINGS_PATH = ".gemini/antigravity-cli/settings.json";
1358
+ var antigravityAdapter = {
1359
+ name: "antigravity",
1360
+ async install(cwd, manifest, files, activation, _isGlobal, options) {
1361
+ const installed = [];
1362
+ const config = manifest.install.antigravity;
1363
+ if (!config)
1364
+ return installed;
1365
+ if (config.mcpServers) {
1366
+ throw new Error(`Antigravity install of '${manifest.name}' does not support mcpServers`);
1367
+ }
1368
+ if (config.append) {
1369
+ throw new Error(`Antigravity install of '${manifest.name}' does not support append`);
1370
+ }
1371
+ if (config.prompt && files.has(manifest.files?.prompt ?? "")) {
1372
+ const targetPath = join7(cwd, config.prompt);
1373
+ mkdirSync6(dirname6(targetPath), { recursive: true });
1374
+ await Bun.write(targetPath, files.get(manifest.files.prompt));
1375
+ installed.push(config.prompt);
1376
+ }
1377
+ if (config.bundleRoot && manifest.bundle) {
1378
+ const skip = new Set([manifest.files?.prompt ?? ""]);
1379
+ installed.push(...await writeBundle(cwd, config.bundleRoot, files, skip));
1380
+ }
1381
+ if (config.postinstall && config.bundleRoot) {
1382
+ const scriptPath = join7(cwd, config.bundleRoot, config.postinstall);
1383
+ const result = runScript(scriptPath, join7(cwd, config.bundleRoot));
1384
+ if (!result.ok) {
1385
+ console.error(`postinstall script '${config.postinstall}' exited with code ${result.code}`);
1386
+ }
1387
+ }
1388
+ const hooks = manifest.activation?.hooks;
1389
+ if (activation === "global" && hooks && config.bundleRoot) {
1390
+ const bundleDir = join7(cwd, config.bundleRoot);
1391
+ await wireAntigravityHooks(hooksPathFor(cwd, config.bundleRoot), manifest.name, bundleDir, manifest.activation?.claudeHookDirective, hooks);
1392
+ if (options?.statusline && hooks.statusline && isGlobalInstall(config.bundleRoot)) {
1393
+ const script = shq3(join7(bundleDir, hooks.statusline));
1394
+ const command = `if [ -f ${script} ]; then bash ${script}; fi`;
1395
+ await wireAntigravityStatusLine(join7(cwd, SETTINGS_PATH), command);
1396
+ }
1397
+ }
1398
+ if (options?.statusline === false && config.bundleRoot && isGlobalInstall(config.bundleRoot)) {
1399
+ await unwireAntigravityStatusLine(join7(cwd, SETTINGS_PATH), join7(cwd, config.bundleRoot));
1400
+ }
1401
+ return installed;
1402
+ },
1403
+ async remove(cwd, manifest, installedFiles) {
1404
+ const config = manifest.install.antigravity;
1405
+ if (!config)
1406
+ return;
1407
+ if (config.postremove && config.bundleRoot) {
1408
+ const scriptPath = join7(cwd, config.bundleRoot, config.postremove);
1409
+ const result = runScript(scriptPath, join7(cwd, config.bundleRoot));
1410
+ if (!result.ok) {
1411
+ console.error(`postremove script '${config.postremove}' exited with code ${result.code}`);
1412
+ }
1413
+ }
1414
+ if (config.bundleRoot) {
1415
+ const bundleDir = join7(cwd, config.bundleRoot);
1416
+ await unwireAntigravityHooks(hooksPathFor(cwd, config.bundleRoot), manifest.name);
1417
+ if (isGlobalInstall(config.bundleRoot)) {
1418
+ await unwireAntigravityStatusLine(join7(cwd, SETTINGS_PATH), bundleDir);
1419
+ }
1420
+ }
1421
+ const stops = [cwd];
1422
+ if (config.bundleRoot)
1423
+ stops.push(join7(cwd, config.bundleRoot, ".."));
1424
+ else if (config.prompt)
1425
+ stops.push(join7(cwd, dirname6(config.prompt), ".."));
1426
+ removeInstalledFiles(cwd, installedFiles, stops, new Set);
1427
+ }
1428
+ };
1429
+
996
1430
  // src/cli/adapters/index.ts
997
1431
  var adapters = {
998
1432
  claude: claudeAdapter,
999
1433
  cursor: cursorAdapter,
1000
1434
  codex: codexAdapter,
1001
- gemini: geminiAdapter
1435
+ gemini: geminiAdapter,
1436
+ antigravity: antigravityAdapter
1002
1437
  };
1003
1438
  function getAdapter(tool) {
1004
1439
  return adapters[tool];
1005
1440
  }
1006
1441
 
1007
1442
  // src/cli/lockfile.ts
1008
- import { join as join6 } from "node:path";
1443
+ import { join as join8 } from "node:path";
1009
1444
  var LOCKFILE_NAME = ".agent-skills.lock";
1445
+ function fromPreChangeEntry(entry) {
1446
+ const record = {
1447
+ version: entry.version,
1448
+ files: entry.files,
1449
+ ...entry.activation !== undefined ? { activation: entry.activation } : {}
1450
+ };
1451
+ const tools = {};
1452
+ for (const tool of entry.tools)
1453
+ tools[tool] = record;
1454
+ return { installedAt: entry.installedAt, tools };
1455
+ }
1456
+ function compareVersions(a, b) {
1457
+ const left = a.split(".").map(Number);
1458
+ const right = b.split(".").map(Number);
1459
+ for (let i = 0;i < Math.max(left.length, right.length); i++) {
1460
+ const diff = (left[i] ?? 0) - (right[i] ?? 0);
1461
+ if (diff !== 0)
1462
+ return diff;
1463
+ }
1464
+ return 0;
1465
+ }
1466
+ function lowestInstalledVersion(entry) {
1467
+ const versions = Object.values(entry.tools).map((record) => record.version);
1468
+ return versions.reduce((lowest, version) => compareVersions(version, lowest) < 0 ? version : lowest);
1469
+ }
1010
1470
  async function readLockfile(cwd) {
1011
- const path = join6(cwd, LOCKFILE_NAME);
1471
+ const path = join8(cwd, LOCKFILE_NAME);
1012
1472
  const file = Bun.file(path);
1013
1473
  if (!await file.exists()) {
1014
1474
  return { skills: {} };
1015
1475
  }
1016
- return file.json();
1476
+ const lockfile = await file.json();
1477
+ for (const [name, entry] of Object.entries(lockfile.skills)) {
1478
+ if (Array.isArray(entry.tools)) {
1479
+ lockfile.skills[name] = fromPreChangeEntry(entry);
1480
+ }
1481
+ }
1482
+ return lockfile;
1017
1483
  }
1018
1484
  async function writeLockfile(cwd, lockfile) {
1019
- const path = join6(cwd, LOCKFILE_NAME);
1485
+ const path = join8(cwd, LOCKFILE_NAME);
1020
1486
  await Bun.write(path, JSON.stringify(lockfile, null, 2) + `
1021
1487
  `);
1022
1488
  }
1023
- async function addSkillToLockfile(cwd, skillName, entry) {
1489
+ async function addSkillToLockfile(cwd, skillName, tool, record) {
1024
1490
  const lockfile = await readLockfile(cwd);
1025
- lockfile.skills[skillName] = entry;
1491
+ const tools = lockfile.skills[skillName]?.tools ?? {};
1492
+ tools[tool] = record;
1493
+ lockfile.skills[skillName] = { installedAt: new Date().toISOString(), tools };
1026
1494
  await writeLockfile(cwd, lockfile);
1027
1495
  }
1028
1496
  async function removeSkillFromLockfile(cwd, skillName) {
@@ -1032,7 +1500,7 @@ async function removeSkillFromLockfile(cwd, skillName) {
1032
1500
  }
1033
1501
 
1034
1502
  // src/cli/commands/install.ts
1035
- async function installSkill(cwd, manifest, files, targetTools, activation) {
1503
+ async function installSkill(cwd, manifest, files, targetTools, activation, isGlobal, options = {}) {
1036
1504
  const compatibleTools = targetTools.filter((t) => manifest.tools.includes(t));
1037
1505
  const skipped = targetTools.filter((t) => !manifest.tools.includes(t));
1038
1506
  if (compatibleTools.length === 0) {
@@ -1042,26 +1510,35 @@ async function installSkill(cwd, manifest, files, targetTools, activation) {
1042
1510
  };
1043
1511
  }
1044
1512
  const installed = {};
1045
- const allFiles = [];
1513
+ const previous = (await readLockfile(cwd)).skills[manifest.name]?.tools ?? {};
1046
1514
  for (const tool of compatibleTools) {
1047
1515
  const adapter = getAdapter(tool);
1048
- const toolFiles = await adapter.install(cwd, manifest, files, activation);
1516
+ const statusline = options.statusline ?? previous[tool]?.statusline === true;
1517
+ const config = manifest.install[tool];
1518
+ const resolved = config ? { ...manifest, install: { ...manifest.install, [tool]: resolveInstallConfig(config, isGlobal) } } : manifest;
1519
+ const toolFiles = await adapter.install(cwd, resolved, files, activation, isGlobal, { ...options, statusline });
1049
1520
  installed[tool] = toolFiles;
1050
- allFiles.push(...toolFiles);
1051
- }
1052
- await addSkillToLockfile(cwd, manifest.name, {
1053
- version: manifest.version,
1054
- tools: compatibleTools,
1055
- installedAt: new Date().toISOString(),
1056
- files: allFiles,
1057
- ...activation !== undefined ? { activation } : {}
1058
- });
1521
+ const claudeEnv = manifest.activation?.claudeEnv;
1522
+ const settingsPath = join9(cwd, ".claude/settings.json");
1523
+ const previousEnv = previous[tool]?.env;
1524
+ const envAdded = {
1525
+ ...previousEnv ? await heldEnv(settingsPath, previousEnv) : {},
1526
+ ...tool === "claude" && activation === "global" && claudeEnv ? await wireEnv(settingsPath, claudeEnv) : {}
1527
+ };
1528
+ await addSkillToLockfile(cwd, manifest.name, tool, {
1529
+ version: manifest.version,
1530
+ files: toolFiles,
1531
+ ...activation !== undefined ? { activation } : {},
1532
+ ...statusline ? { statusline: true } : {},
1533
+ ...Object.keys(envAdded).length > 0 ? { env: envAdded } : {}
1534
+ });
1535
+ }
1059
1536
  return { ok: true, installed, skipped };
1060
1537
  }
1061
1538
 
1062
1539
  // src/cli/commands/remove.ts
1063
- import { existsSync as existsSync6, statSync as statSync2, unlinkSync as unlinkSync4, rmSync as rmSync2 } from "node:fs";
1064
- import { basename, join as join7 } from "node:path";
1540
+ import { existsSync as existsSync8, statSync as statSync2, unlinkSync as unlinkSync4, rmSync as rmSync2 } from "node:fs";
1541
+ import { basename, dirname as dirname7, join as join10 } from "node:path";
1065
1542
 
1066
1543
  // src/cli/github.ts
1067
1544
  var REPO2 = "iceinvein/agent-skills";
@@ -1171,7 +1648,11 @@ var SHARED_CONFIG_FILES = new Set([
1171
1648
  ".claude/settings.json",
1172
1649
  ".claude/settings.local.json",
1173
1650
  ".cursor/mcp.json",
1174
- ".gemini/settings.json"
1651
+ ".gemini/settings.json",
1652
+ ".codex/hooks.json",
1653
+ ".agents/hooks.json",
1654
+ ".gemini/config/hooks.json",
1655
+ "AGENTS.md"
1175
1656
  ]);
1176
1657
  function isSharedConfigFile(relPath) {
1177
1658
  if (SHARED_CONFIG_FILES.has(relPath))
@@ -1189,20 +1670,85 @@ function removeFileOrDir(fullPath) {
1189
1670
  unlinkSync4(fullPath);
1190
1671
  }
1191
1672
  }
1192
- async function removeSkill(cwd, skillName) {
1673
+ async function cutAgentsSection(agentsPath, skillName) {
1674
+ if (!existsSync8(agentsPath))
1675
+ return;
1676
+ const content = await Bun.file(agentsPath).text();
1677
+ const startMarker = `<!-- agent-skills:start:${skillName} -->`;
1678
+ const endMarker = `<!-- agent-skills:end:${skillName} -->`;
1679
+ const startIdx = content.indexOf(startMarker);
1680
+ const endIdx = content.indexOf(endMarker);
1681
+ if (startIdx === -1 || endIdx === -1)
1682
+ return;
1683
+ const before = content.slice(0, startIdx).replace(/\n$/, "");
1684
+ const after = content.slice(endIdx + endMarker.length).replace(/^\n/, "");
1685
+ await Bun.write(agentsPath, before + after);
1686
+ }
1687
+ async function removeWithoutManifest(cwd, skillName, tools, reason, isGlobal) {
1688
+ const removed = [];
1689
+ const warnings = [];
1690
+ const skillDirs = (record) => record.files.filter((f) => f.endsWith("SKILL.md")).map((f) => join10(cwd, dirname7(f)));
1691
+ if (tools.codex) {
1692
+ for (const bundleDir of skillDirs(tools.codex)) {
1693
+ for (const hooksPath of codexHooksPathsToUnwire(cwd, isGlobal)) {
1694
+ await unwireCodexHooks(hooksPath, bundleDir);
1695
+ }
1696
+ }
1697
+ }
1698
+ if (tools.antigravity) {
1699
+ await unwireAntigravityHooks(join10(cwd, ".gemini/config/hooks.json"), skillName);
1700
+ await unwireAntigravityHooks(join10(cwd, ".agents/hooks.json"), skillName);
1701
+ for (const bundleDir of skillDirs(tools.antigravity)) {
1702
+ await unwireAntigravityStatusLine(join10(cwd, ".gemini/antigravity-cli/settings.json"), bundleDir);
1703
+ }
1704
+ }
1705
+ const files = [...new Set(Object.values(tools).flatMap((record) => record.files))];
1706
+ for (const file of files) {
1707
+ if (file === "AGENTS.md") {
1708
+ await cutAgentsSection(join10(cwd, file), skillName);
1709
+ continue;
1710
+ }
1711
+ if (isSharedConfigFile(file)) {
1712
+ const fullPath = join10(cwd, file);
1713
+ if (existsSync8(fullPath)) {
1714
+ await unwireSessionStartHook(fullPath, skillName);
1715
+ await unwireStatusLine(fullPath, skillName);
1716
+ }
1717
+ warnings.push(`${reason}. Left '${file}' in place, removing '${skillName}'s SessionStart hook and status line from it; any MCP server entries it owns were not touched.`);
1718
+ continue;
1719
+ }
1720
+ const fullPath = join10(cwd, file);
1721
+ if (!existsSync8(fullPath))
1722
+ continue;
1723
+ removeFileOrDir(fullPath);
1724
+ removed.push(file);
1725
+ }
1726
+ return { removed, warnings };
1727
+ }
1728
+ async function removeSkill(cwd, skillName, isGlobal, manifest) {
1193
1729
  const lockfile = await readLockfile(cwd);
1194
1730
  const entry = lockfile.skills[skillName];
1195
1731
  if (!entry) {
1196
1732
  return { ok: false, error: `Skill '${skillName}' is not installed` };
1197
1733
  }
1198
- const manifestResult = await fetchSkillManifest2(skillName);
1734
+ const records = Object.entries(entry.tools);
1735
+ const allFiles = [...new Set(records.flatMap(([, record]) => record.files))];
1736
+ const envAdded = entry.tools.claude?.env;
1737
+ if (envAdded)
1738
+ await unwireEnv(join10(cwd, ".claude/settings.json"), envAdded);
1739
+ const manifestResult = manifest ? { ok: true, manifest } : await fetchSkillManifest2(skillName);
1199
1740
  if (manifestResult.ok) {
1200
- for (const tool of entry.tools) {
1741
+ const dropped = {};
1742
+ for (const [tool, record] of records) {
1201
1743
  const adapter = getAdapter(tool);
1202
- const toolFiles = entry.files.filter((f) => {
1203
- const config = manifestResult.manifest.install[tool];
1204
- if (!config)
1205
- return false;
1744
+ const manifest = manifestResult.manifest;
1745
+ const rawConfig = manifest.install[tool];
1746
+ if (!rawConfig) {
1747
+ dropped[tool] = record;
1748
+ continue;
1749
+ }
1750
+ const config = resolveInstallConfig(rawConfig, isGlobal);
1751
+ const toolFiles = record.files.filter((f) => {
1206
1752
  if (config.prompt && f === config.prompt)
1207
1753
  return true;
1208
1754
  if (config.supporting && Object.values(config.supporting).includes(f))
@@ -1213,29 +1759,17 @@ async function removeSkill(cwd, skillName) {
1213
1759
  return true;
1214
1760
  return false;
1215
1761
  });
1216
- await adapter.remove(cwd, manifestResult.manifest, toolFiles);
1762
+ const resolved = { ...manifest, install: { ...manifest.install, [tool]: config } };
1763
+ await adapter.remove(cwd, resolved, toolFiles, isGlobal);
1217
1764
  }
1218
- await removeSkillFromLockfile(cwd, skillName);
1219
- return { ok: true, removed: entry.files };
1220
- }
1221
- const removed = [];
1222
- const warnings = [];
1223
- for (const file of entry.files) {
1224
- if (isSharedConfigFile(file)) {
1225
- const fullPath = join7(cwd, file);
1226
- if (existsSync6(fullPath)) {
1227
- await unwireSessionStartHook(fullPath, skillName);
1228
- await unwireStatusLine(fullPath, skillName);
1229
- }
1230
- warnings.push(`Manifest unavailable (${manifestResult.error}). Left '${file}' in place, removing '${skillName}'s SessionStart hook and status line from it; any MCP server entries it owns were not touched.`);
1231
- continue;
1765
+ let warnings = [];
1766
+ if (Object.keys(dropped).length > 0) {
1767
+ ({ warnings } = await removeWithoutManifest(cwd, skillName, dropped, `The manifest no longer lists ${Object.keys(dropped).join(", ")}`, isGlobal));
1232
1768
  }
1233
- const fullPath = join7(cwd, file);
1234
- if (!existsSync6(fullPath))
1235
- continue;
1236
- removeFileOrDir(fullPath);
1237
- removed.push(file);
1769
+ await removeSkillFromLockfile(cwd, skillName);
1770
+ return { ok: true, removed: allFiles, ...warnings.length > 0 ? { warnings } : {} };
1238
1771
  }
1772
+ const { removed, warnings } = await removeWithoutManifest(cwd, skillName, entry.tools, `Manifest unavailable (${manifestResult.error})`, isGlobal);
1239
1773
  await removeSkillFromLockfile(cwd, skillName);
1240
1774
  return { ok: true, removed, ...warnings.length > 0 ? { warnings } : {} };
1241
1775
  }
@@ -1258,14 +1792,22 @@ async function infoSkill(skillName) {
1258
1792
  return fetchSkillManifest2(skillName);
1259
1793
  }
1260
1794
 
1795
+ // src/cli/commands/update.ts
1796
+ import { homedir as homedir2 } from "node:os";
1797
+ import { join as join13 } from "node:path";
1798
+
1261
1799
  // src/cli/commands/remove.ts
1262
- import { existsSync as existsSync7, statSync as statSync3, unlinkSync as unlinkSync5, rmSync as rmSync3 } from "node:fs";
1263
- import { basename as basename2, join as join8 } from "node:path";
1800
+ import { existsSync as existsSync9, statSync as statSync3, unlinkSync as unlinkSync5, rmSync as rmSync3 } from "node:fs";
1801
+ import { basename as basename2, dirname as dirname8, join as join11 } from "node:path";
1264
1802
  var SHARED_CONFIG_FILES2 = new Set([
1265
1803
  ".claude/settings.json",
1266
1804
  ".claude/settings.local.json",
1267
1805
  ".cursor/mcp.json",
1268
- ".gemini/settings.json"
1806
+ ".gemini/settings.json",
1807
+ ".codex/hooks.json",
1808
+ ".agents/hooks.json",
1809
+ ".gemini/config/hooks.json",
1810
+ "AGENTS.md"
1269
1811
  ]);
1270
1812
  function isSharedConfigFile2(relPath) {
1271
1813
  if (SHARED_CONFIG_FILES2.has(relPath))
@@ -1283,20 +1825,85 @@ function removeFileOrDir2(fullPath) {
1283
1825
  unlinkSync5(fullPath);
1284
1826
  }
1285
1827
  }
1286
- async function removeSkill2(cwd, skillName) {
1828
+ async function cutAgentsSection2(agentsPath, skillName) {
1829
+ if (!existsSync9(agentsPath))
1830
+ return;
1831
+ const content = await Bun.file(agentsPath).text();
1832
+ const startMarker = `<!-- agent-skills:start:${skillName} -->`;
1833
+ const endMarker = `<!-- agent-skills:end:${skillName} -->`;
1834
+ const startIdx = content.indexOf(startMarker);
1835
+ const endIdx = content.indexOf(endMarker);
1836
+ if (startIdx === -1 || endIdx === -1)
1837
+ return;
1838
+ const before = content.slice(0, startIdx).replace(/\n$/, "");
1839
+ const after = content.slice(endIdx + endMarker.length).replace(/^\n/, "");
1840
+ await Bun.write(agentsPath, before + after);
1841
+ }
1842
+ async function removeWithoutManifest2(cwd, skillName, tools, reason, isGlobal) {
1843
+ const removed = [];
1844
+ const warnings = [];
1845
+ const skillDirs = (record) => record.files.filter((f) => f.endsWith("SKILL.md")).map((f) => join11(cwd, dirname8(f)));
1846
+ if (tools.codex) {
1847
+ for (const bundleDir of skillDirs(tools.codex)) {
1848
+ for (const hooksPath of codexHooksPathsToUnwire(cwd, isGlobal)) {
1849
+ await unwireCodexHooks(hooksPath, bundleDir);
1850
+ }
1851
+ }
1852
+ }
1853
+ if (tools.antigravity) {
1854
+ await unwireAntigravityHooks(join11(cwd, ".gemini/config/hooks.json"), skillName);
1855
+ await unwireAntigravityHooks(join11(cwd, ".agents/hooks.json"), skillName);
1856
+ for (const bundleDir of skillDirs(tools.antigravity)) {
1857
+ await unwireAntigravityStatusLine(join11(cwd, ".gemini/antigravity-cli/settings.json"), bundleDir);
1858
+ }
1859
+ }
1860
+ const files = [...new Set(Object.values(tools).flatMap((record) => record.files))];
1861
+ for (const file of files) {
1862
+ if (file === "AGENTS.md") {
1863
+ await cutAgentsSection2(join11(cwd, file), skillName);
1864
+ continue;
1865
+ }
1866
+ if (isSharedConfigFile2(file)) {
1867
+ const fullPath = join11(cwd, file);
1868
+ if (existsSync9(fullPath)) {
1869
+ await unwireSessionStartHook(fullPath, skillName);
1870
+ await unwireStatusLine(fullPath, skillName);
1871
+ }
1872
+ warnings.push(`${reason}. Left '${file}' in place, removing '${skillName}'s SessionStart hook and status line from it; any MCP server entries it owns were not touched.`);
1873
+ continue;
1874
+ }
1875
+ const fullPath = join11(cwd, file);
1876
+ if (!existsSync9(fullPath))
1877
+ continue;
1878
+ removeFileOrDir2(fullPath);
1879
+ removed.push(file);
1880
+ }
1881
+ return { removed, warnings };
1882
+ }
1883
+ async function removeSkill2(cwd, skillName, isGlobal, manifest) {
1287
1884
  const lockfile = await readLockfile(cwd);
1288
1885
  const entry = lockfile.skills[skillName];
1289
1886
  if (!entry) {
1290
1887
  return { ok: false, error: `Skill '${skillName}' is not installed` };
1291
1888
  }
1292
- const manifestResult = await fetchSkillManifest2(skillName);
1889
+ const records = Object.entries(entry.tools);
1890
+ const allFiles = [...new Set(records.flatMap(([, record]) => record.files))];
1891
+ const envAdded = entry.tools.claude?.env;
1892
+ if (envAdded)
1893
+ await unwireEnv(join11(cwd, ".claude/settings.json"), envAdded);
1894
+ const manifestResult = manifest ? { ok: true, manifest } : await fetchSkillManifest2(skillName);
1293
1895
  if (manifestResult.ok) {
1294
- for (const tool of entry.tools) {
1896
+ const dropped = {};
1897
+ for (const [tool, record] of records) {
1295
1898
  const adapter = getAdapter(tool);
1296
- const toolFiles = entry.files.filter((f) => {
1297
- const config = manifestResult.manifest.install[tool];
1298
- if (!config)
1299
- return false;
1899
+ const manifest = manifestResult.manifest;
1900
+ const rawConfig = manifest.install[tool];
1901
+ if (!rawConfig) {
1902
+ dropped[tool] = record;
1903
+ continue;
1904
+ }
1905
+ const config = resolveInstallConfig(rawConfig, isGlobal);
1906
+ const toolFiles = record.files.filter((f) => {
1300
1907
  if (config.prompt && f === config.prompt)
1301
1908
  return true;
1302
1909
  if (config.supporting && Object.values(config.supporting).includes(f))
@@ -1307,35 +1914,24 @@ async function removeSkill2(cwd, skillName) {
1307
1914
  return true;
1308
1915
  return false;
1309
1916
  });
1310
- await adapter.remove(cwd, manifestResult.manifest, toolFiles);
1917
+ const resolved = { ...manifest, install: { ...manifest.install, [tool]: config } };
1918
+ await adapter.remove(cwd, resolved, toolFiles, isGlobal);
1311
1919
  }
1312
- await removeSkillFromLockfile(cwd, skillName);
1313
- return { ok: true, removed: entry.files };
1314
- }
1315
- const removed = [];
1316
- const warnings = [];
1317
- for (const file of entry.files) {
1318
- if (isSharedConfigFile2(file)) {
1319
- const fullPath = join8(cwd, file);
1320
- if (existsSync7(fullPath)) {
1321
- await unwireSessionStartHook(fullPath, skillName);
1322
- await unwireStatusLine(fullPath, skillName);
1323
- }
1324
- warnings.push(`Manifest unavailable (${manifestResult.error}). Left '${file}' in place, removing '${skillName}'s SessionStart hook and status line from it; any MCP server entries it owns were not touched.`);
1325
- continue;
1920
+ let warnings = [];
1921
+ if (Object.keys(dropped).length > 0) {
1922
+ ({ warnings } = await removeWithoutManifest2(cwd, skillName, dropped, `The manifest no longer lists ${Object.keys(dropped).join(", ")}`, isGlobal));
1326
1923
  }
1327
- const fullPath = join8(cwd, file);
1328
- if (!existsSync7(fullPath))
1329
- continue;
1330
- removeFileOrDir2(fullPath);
1331
- removed.push(file);
1924
+ await removeSkillFromLockfile(cwd, skillName);
1925
+ return { ok: true, removed: allFiles, ...warnings.length > 0 ? { warnings } : {} };
1332
1926
  }
1927
+ const { removed, warnings } = await removeWithoutManifest2(cwd, skillName, entry.tools, `Manifest unavailable (${manifestResult.error})`, isGlobal);
1333
1928
  await removeSkillFromLockfile(cwd, skillName);
1334
1929
  return { ok: true, removed, ...warnings.length > 0 ? { warnings } : {} };
1335
1930
  }
1336
1931
 
1337
1932
  // src/cli/commands/install.ts
1338
- async function installSkill2(cwd, manifest, files, targetTools, activation) {
1933
+ import { join as join12 } from "node:path";
1934
+ async function installSkill2(cwd, manifest, files, targetTools, activation, isGlobal, options = {}) {
1339
1935
  const compatibleTools = targetTools.filter((t) => manifest.tools.includes(t));
1340
1936
  const skipped = targetTools.filter((t) => !manifest.tools.includes(t));
1341
1937
  if (compatibleTools.length === 0) {
@@ -1345,33 +1941,54 @@ async function installSkill2(cwd, manifest, files, targetTools, activation) {
1345
1941
  };
1346
1942
  }
1347
1943
  const installed = {};
1348
- const allFiles = [];
1944
+ const previous = (await readLockfile(cwd)).skills[manifest.name]?.tools ?? {};
1349
1945
  for (const tool of compatibleTools) {
1350
1946
  const adapter = getAdapter(tool);
1351
- const toolFiles = await adapter.install(cwd, manifest, files, activation);
1947
+ const statusline = options.statusline ?? previous[tool]?.statusline === true;
1948
+ const config = manifest.install[tool];
1949
+ const resolved = config ? { ...manifest, install: { ...manifest.install, [tool]: resolveInstallConfig(config, isGlobal) } } : manifest;
1950
+ const toolFiles = await adapter.install(cwd, resolved, files, activation, isGlobal, { ...options, statusline });
1352
1951
  installed[tool] = toolFiles;
1353
- allFiles.push(...toolFiles);
1354
- }
1355
- await addSkillToLockfile(cwd, manifest.name, {
1356
- version: manifest.version,
1357
- tools: compatibleTools,
1358
- installedAt: new Date().toISOString(),
1359
- files: allFiles,
1360
- ...activation !== undefined ? { activation } : {}
1361
- });
1952
+ const claudeEnv = manifest.activation?.claudeEnv;
1953
+ const settingsPath = join12(cwd, ".claude/settings.json");
1954
+ const previousEnv = previous[tool]?.env;
1955
+ const envAdded = {
1956
+ ...previousEnv ? await heldEnv(settingsPath, previousEnv) : {},
1957
+ ...tool === "claude" && activation === "global" && claudeEnv ? await wireEnv(settingsPath, claudeEnv) : {}
1958
+ };
1959
+ await addSkillToLockfile(cwd, manifest.name, tool, {
1960
+ version: manifest.version,
1961
+ files: toolFiles,
1962
+ ...activation !== undefined ? { activation } : {},
1963
+ ...statusline ? { statusline: true } : {},
1964
+ ...Object.keys(envAdded).length > 0 ? { env: envAdded } : {}
1965
+ });
1966
+ }
1362
1967
  return { ok: true, installed, skipped };
1363
1968
  }
1364
1969
 
1365
1970
  // src/cli/commands/update.ts
1971
+ async function holdsOwnStatusLine(cwd, tool, manifest, isGlobal) {
1972
+ if (tool === "claude")
1973
+ return holdsStatusLine(join13(cwd, ".claude/settings.json"), manifest.name);
1974
+ if (tool === "antigravity") {
1975
+ const config = manifest.install.antigravity;
1976
+ const bundleRoot = config ? resolveInstallConfig(config, isGlobal).bundleRoot : undefined;
1977
+ if (bundleRoot === undefined)
1978
+ return false;
1979
+ return holdsAntigravityStatusLine(join13(cwd, ".gemini/antigravity-cli/settings.json"), join13(cwd, bundleRoot));
1980
+ }
1981
+ return false;
1982
+ }
1366
1983
  async function updateSkill(cwd, skillName) {
1367
1984
  const lockfile = await readLockfile(cwd);
1368
1985
  const entry = lockfile.skills[skillName];
1369
1986
  if (!entry) {
1370
1987
  return { ok: false, error: `Skill '${skillName}' is not installed` };
1371
1988
  }
1372
- const oldVersion = entry.version;
1373
- const tools = entry.tools;
1374
- const activation = entry.activation;
1989
+ const records = Object.entries(entry.tools);
1990
+ const oldVersion = lowestInstalledVersion(entry);
1991
+ const isGlobal = cwd === homedir2();
1375
1992
  const manifestResult = await fetchSkillManifest2(skillName);
1376
1993
  if (!manifestResult.ok) {
1377
1994
  return { ok: false, error: manifestResult.error };
@@ -1380,12 +1997,29 @@ async function updateSkill(cwd, skillName) {
1380
1997
  if ("error" in filesResult) {
1381
1998
  return { ok: false, error: filesResult.error };
1382
1999
  }
1383
- await removeSkill2(cwd, skillName);
1384
- const installResult = await installSkill2(cwd, manifestResult.manifest, filesResult, tools, activation);
1385
- if (!installResult.ok) {
1386
- return { ok: false, error: installResult.error };
2000
+ const manifest = manifestResult.manifest;
2001
+ const kept = records.filter(([tool]) => manifest.tools.includes(tool));
2002
+ const skipped = records.filter(([tool]) => !manifest.tools.includes(tool)).map(([tool]) => tool);
2003
+ const statusline = new Map;
2004
+ for (const [tool, record] of kept) {
2005
+ statusline.set(tool, record.statusline === true || await holdsOwnStatusLine(cwd, tool, manifest, isGlobal));
2006
+ }
2007
+ const removeResult = await removeSkill2(cwd, skillName, isGlobal, manifest);
2008
+ if (!removeResult.ok) {
2009
+ return { ok: false, error: removeResult.error };
2010
+ }
2011
+ const failures = [];
2012
+ for (const [tool, record] of kept) {
2013
+ const installResult = await installSkill2(cwd, manifest, filesResult, [tool], record.activation, isGlobal, {
2014
+ statusline: statusline.get(tool)
2015
+ });
2016
+ if (!installResult.ok)
2017
+ failures.push(installResult.error);
2018
+ }
2019
+ if (failures.length > 0) {
2020
+ return { ok: false, error: failures.join("; ") };
1387
2021
  }
1388
- return { ok: true, from: oldVersion, to: manifestResult.manifest.version };
2022
+ return { ok: true, from: oldVersion, to: manifest.version, skipped, warnings: removeResult.warnings ?? [] };
1389
2023
  }
1390
2024
  async function updateAllSkills(cwd) {
1391
2025
  const lockfile = await readLockfile(cwd);
@@ -1401,7 +2035,7 @@ async function updateAllSkills(cwd) {
1401
2035
  }
1402
2036
 
1403
2037
  // src/cli/commands/bump.ts
1404
- import { join as join9 } from "node:path";
2038
+ import { join as join14 } from "node:path";
1405
2039
 
1406
2040
  // src/cli/semver.ts
1407
2041
  function bumpVersion(current, level) {
@@ -1422,7 +2056,7 @@ function bumpVersion(current, level) {
1422
2056
 
1423
2057
  // src/cli/commands/bump.ts
1424
2058
  async function bumpSkill(repoRoot, skillName, level) {
1425
- const manifestPath = join9(repoRoot, "skills", skillName, "skill.json");
2059
+ const manifestPath = join14(repoRoot, "skills", skillName, "skill.json");
1426
2060
  const file = Bun.file(manifestPath);
1427
2061
  if (!await file.exists()) {
1428
2062
  return { ok: false, error: `Skill '${skillName}' not found at skills/${skillName}/skill.json` };
@@ -1493,7 +2127,7 @@ async function bumpAllChanged(repoRoot, level, dryRun) {
1493
2127
  if (skillVersionChanged(repoRoot, skillName, tag))
1494
2128
  continue;
1495
2129
  if (dryRun) {
1496
- const manifestPath = join9(repoRoot, "skills", skillName, "skill.json");
2130
+ const manifestPath = join14(repoRoot, "skills", skillName, "skill.json");
1497
2131
  const file = Bun.file(manifestPath);
1498
2132
  if (!await file.exists())
1499
2133
  continue;
@@ -1531,8 +2165,9 @@ async function checkForUpdates(cwd) {
1531
2165
  const result = await fetchSkillManifest2(name);
1532
2166
  if (!result.ok)
1533
2167
  return null;
1534
- const installed = lockfile.skills[name].version;
1535
- if (result.manifest.version !== installed) {
2168
+ const records = Object.values(lockfile.skills[name].tools);
2169
+ const installed = lowestInstalledVersion(lockfile.skills[name]);
2170
+ if (records.some((record) => record.version !== result.manifest.version)) {
1536
2171
  return { name, installed, latest: result.manifest.version };
1537
2172
  }
1538
2173
  return null;
@@ -1549,19 +2184,36 @@ async function checkForUpdates(cwd) {
1549
2184
  }
1550
2185
 
1551
2186
  // src/cli/lockfile.ts
1552
- import { join as join10 } from "node:path";
2187
+ import { join as join15 } from "node:path";
1553
2188
  var LOCKFILE_NAME2 = ".agent-skills.lock";
2189
+ function fromPreChangeEntry2(entry) {
2190
+ const record = {
2191
+ version: entry.version,
2192
+ files: entry.files,
2193
+ ...entry.activation !== undefined ? { activation: entry.activation } : {}
2194
+ };
2195
+ const tools = {};
2196
+ for (const tool of entry.tools)
2197
+ tools[tool] = record;
2198
+ return { installedAt: entry.installedAt, tools };
2199
+ }
1554
2200
  async function readLockfile2(cwd) {
1555
- const path = join10(cwd, LOCKFILE_NAME2);
2201
+ const path = join15(cwd, LOCKFILE_NAME2);
1556
2202
  const file = Bun.file(path);
1557
2203
  if (!await file.exists()) {
1558
2204
  return { skills: {} };
1559
2205
  }
1560
- return file.json();
2206
+ const lockfile = await file.json();
2207
+ for (const [name, entry] of Object.entries(lockfile.skills)) {
2208
+ if (Array.isArray(entry.tools)) {
2209
+ lockfile.skills[name] = fromPreChangeEntry2(entry);
2210
+ }
2211
+ }
2212
+ return lockfile;
1561
2213
  }
1562
2214
 
1563
2215
  // src/cli/types.ts
1564
- var TOOL_NAMES2 = ["claude", "cursor", "codex", "gemini"];
2216
+ var TOOL_NAMES2 = ["claude", "cursor", "codex", "gemini", "antigravity"];
1565
2217
 
1566
2218
  // node_modules/@inquirer/core/dist/lib/key.js
1567
2219
  var isUpKey = (key, keybindings = []) => key.name === "up" || keybindings.includes("vim") && key.name === "k" || keybindings.includes("emacs") && key.ctrl && key.name === "p";
@@ -3373,7 +4025,8 @@ var TOOL_LABELS = {
3373
4025
  claude: "Claude Code",
3374
4026
  cursor: "Cursor",
3375
4027
  codex: "Codex",
3376
- gemini: "Gemini CLI"
4028
+ gemini: "Gemini CLI",
4029
+ antigravity: "Antigravity"
3377
4030
  };
3378
4031
  function formatChoice(skill) {
3379
4032
  const tag = TYPE_TAGS[skill.type] ?? "[other] ";
@@ -3431,11 +4084,11 @@ async function pickActivation(skillName, modes) {
3431
4084
  }
3432
4085
 
3433
4086
  // src/cli/index.ts
3434
- import { mkdirSync as mkdirSync4 } from "fs";
3435
- import { join as join11 } from "path";
3436
- import { homedir as homedir2 } from "os";
4087
+ import { mkdirSync as mkdirSync7 } from "fs";
4088
+ import { join as join16 } from "path";
4089
+ import { homedir as homedir3 } from "os";
3437
4090
  async function otherScopeSkillCount(currentDir) {
3438
- const home = homedir2();
4091
+ const home = homedir3();
3439
4092
  const otherDir = currentDir === home ? process.cwd() : home;
3440
4093
  if (otherDir === currentDir)
3441
4094
  return { scope: "global", count: 0 };
@@ -3447,11 +4100,11 @@ async function otherScopeSkillCount(currentDir) {
3447
4100
  }
3448
4101
  function resolveInstallDir(flags) {
3449
4102
  if (flags.global !== undefined || flags.g !== undefined) {
3450
- return homedir2();
4103
+ return homedir3();
3451
4104
  }
3452
4105
  return process.cwd();
3453
4106
  }
3454
- var BOOLEAN_FLAGS = new Set(["global", "g", "all", "dry-run"]);
4107
+ var BOOLEAN_FLAGS = new Set(["global", "g", "all", "dry-run", "statusline", "no-statusline"]);
3455
4108
  function parseArgs(argv) {
3456
4109
  if (argv.length === 0)
3457
4110
  return { command: "help", args: [], flags: {} };
@@ -3481,7 +4134,7 @@ function printHelp() {
3481
4134
  @iceinvein/agent-skills \u2014 Install agent skills into AI coding tools
3482
4135
 
3483
4136
  Usage:
3484
- agent-skills install <skill> [<skill> ...] [--tool <tool>] [--activation <mode>] [-g] Install one or more skills
4137
+ agent-skills install <skill> [<skill> ...] [--tool <tool>] [--activation <mode>] [--statusline | --no-statusline] [-g] Install one or more skills
3485
4138
  agent-skills install [--tool <tool>] [-g] No args: opens interactive picker
3486
4139
  agent-skills browse [--tool <tool>] [-g] Alias for 'install' with picker
3487
4140
  agent-skills remove <skill> [-g] Remove a skill
@@ -3497,6 +4150,8 @@ Flags:
3497
4150
  -g, --global Install to home directory (available in all projects)
3498
4151
  --dry-run With bump --all: check without writing (exit 1 if unbumped)
3499
4152
  --activation <mode> Set activation mode for skills that support it (session or global)
4153
+ --statusline With a global activation: put the skill's status line in an empty statusLine slot
4154
+ --no-statusline Give back a statusLine slot the skill holds; later installs and updates leave it empty
3500
4155
  `);
3501
4156
  }
3502
4157
  function printInstalled(result, skipped) {
@@ -3513,7 +4168,8 @@ function printInstalled(result, skipped) {
3513
4168
  var TOOL_DIRS = {
3514
4169
  claude: ".claude",
3515
4170
  cursor: ".cursor",
3516
- gemini: ".gemini"
4171
+ gemini: ".gemini",
4172
+ antigravity: ".agents"
3517
4173
  };
3518
4174
  async function resolveTargetTools(installDir, isGlobal, flags) {
3519
4175
  if (flags.tool) {
@@ -3529,14 +4185,14 @@ async function resolveTargetTools(installDir, isGlobal, flags) {
3529
4185
  return detected;
3530
4186
  }
3531
4187
  if (!process.stdin.isTTY) {
3532
- console.error("Error: no tools detected and no TTY for prompting. Pass --tool <claude|cursor|codex|gemini>.");
4188
+ console.error("Error: no tools detected and no TTY for prompting. Pass --tool <claude|cursor|codex|gemini|antigravity>.");
3533
4189
  return null;
3534
4190
  }
3535
4191
  const picked = await pickTools(isGlobal ? "Which tools do you use?" : "No tools detected in this directory. Which tools do you use?");
3536
4192
  for (const tool of picked) {
3537
4193
  const dir = TOOL_DIRS[tool];
3538
4194
  if (dir)
3539
- mkdirSync4(join11(installDir, dir), { recursive: true });
4195
+ mkdirSync7(join16(installDir, dir), { recursive: true });
3540
4196
  }
3541
4197
  return picked;
3542
4198
  }
@@ -3568,7 +4224,9 @@ async function installOne(skillName, installDir, isGlobal, targetTools, flags) {
3568
4224
  activation = manifest.activation.default;
3569
4225
  }
3570
4226
  }
3571
- const result = await installSkill(installDir, manifest, filesResult, targetTools, activation);
4227
+ const result = await installSkill(installDir, manifest, filesResult, targetTools, activation, isGlobal, {
4228
+ statusline: flags.statusline !== undefined ? true : flags["no-statusline"] !== undefined ? false : undefined
4229
+ });
3572
4230
  if (!result.ok) {
3573
4231
  console.error(`Error: ${result.error}`);
3574
4232
  return false;
@@ -3583,8 +4241,12 @@ async function main() {
3583
4241
  switch (command) {
3584
4242
  case "install":
3585
4243
  case "browse": {
4244
+ if (flags.statusline !== undefined && flags["no-statusline"] !== undefined) {
4245
+ console.error("Error: --statusline and --no-statusline cannot be given together");
4246
+ process.exit(1);
4247
+ }
3586
4248
  const installDir = resolveInstallDir(flags);
3587
- const isGlobal = installDir === homedir2();
4249
+ const isGlobal = installDir === homedir3();
3588
4250
  let names = args;
3589
4251
  if (names.length === 0 || command === "browse") {
3590
4252
  if (!process.stdin.isTTY) {
@@ -3635,7 +4297,7 @@ Installing ${names.length} skills...
3635
4297
  process.exit(1);
3636
4298
  }
3637
4299
  const removeDir = resolveInstallDir(flags);
3638
- const result = await removeSkill(removeDir, skillName);
4300
+ const result = await removeSkill(removeDir, skillName, removeDir === homedir3());
3639
4301
  if (!result.ok) {
3640
4302
  console.error(`Error: ${result.error}`);
3641
4303
  process.exit(1);
@@ -3665,6 +4327,13 @@ Installing ${names.length} skills...
3665
4327
  } else {
3666
4328
  console.log(` \u2713 ${r.name} v${r.from} \u2192 v${r.to}`);
3667
4329
  }
4330
+ if (r.ok && r.skipped.length > 0) {
4331
+ console.log(` \u2298 removed from ${r.skipped.join(", ")}, which v${r.to} no longer supports`);
4332
+ }
4333
+ if (r.ok) {
4334
+ for (const warning of r.warnings)
4335
+ console.warn(` \u26A0 ${warning}`);
4336
+ }
3668
4337
  }
3669
4338
  }
3670
4339
  const other = await otherScopeSkillCount(updateDir);
@@ -3692,6 +4361,11 @@ Note: ${other.count} ${noun} installed in the ${other.scope} scope. Run \`${comm
3692
4361
  } else {
3693
4362
  console.log(`\u2713 Updated '${skillName}' from v${result.from} to v${result.to}`);
3694
4363
  }
4364
+ if (result.skipped.length > 0) {
4365
+ console.log(`\u2298 Removed from ${result.skipped.join(", ")}, which v${result.to} no longer supports`);
4366
+ }
4367
+ for (const warning of result.warnings)
4368
+ console.warn(`\u26A0 ${warning}`);
3695
4369
  break;
3696
4370
  }
3697
4371
  case "list": {
@@ -3785,7 +4459,7 @@ ${m.name} v${m.version}`);
3785
4459
  break;
3786
4460
  }
3787
4461
  if (command !== "update") {
3788
- const checkDir = flags.global !== undefined || flags.g !== undefined ? homedir2() : process.cwd();
4462
+ const checkDir = flags.global !== undefined || flags.g !== undefined ? homedir3() : process.cwd();
3789
4463
  const outdated = await checkForUpdates(checkDir);
3790
4464
  if (outdated.length > 0) {
3791
4465
  const list = outdated.map((s) => `${s.name} (v${s.installed} \u2192 v${s.latest})`).join(", ");