@uzysjung/agent-harness 26.176.0 → 26.178.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -77,6 +77,7 @@ import {
77
77
  formatResidentCostLine,
78
78
  hasUiTrack,
79
79
  hashContent,
80
+ importsAgentsMd,
80
81
  init_esm_shims,
81
82
  installLogPath,
82
83
  installedClis,
@@ -133,6 +134,7 @@ import {
133
134
  selectedMcpServers,
134
135
  sharedPathOfKeyId,
135
136
  shouldInstallAsset,
137
+ skillFolderOf,
136
138
  skillNames,
137
139
  stripAgentsMd,
138
140
  stripHarnessImport,
@@ -145,7 +147,7 @@ import {
145
147
  withoutAppleDouble,
146
148
  wrapHarnessBlock,
147
149
  writeInstallLog
148
- } from "./chunk-HB6UJWC6.js";
150
+ } from "./chunk-543MIQR5.js";
149
151
 
150
152
  // node_modules/sisteransi/src/index.js
151
153
  var require_src = __commonJS({
@@ -1948,13 +1950,8 @@ function legacyGitignoreSeed(text, render, previous) {
1948
1950
 
1949
1951
  // src/installer.ts
1950
1952
  init_esm_shims();
1951
- import { chmodSync as chmodSync3, existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync21, writeFileSync as writeFileSync7 } from "fs";
1952
- import { basename as basename6, join as join29, relative as relative7, resolve, sep as sep8 } from "path";
1953
-
1954
- // src/anchor-seed.ts
1955
- init_esm_shims();
1956
- import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
1957
- import { join as join6 } from "path";
1953
+ import { chmodSync as chmodSync3, existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync22, writeFileSync as writeFileSync7 } from "fs";
1954
+ import { basename as basename6, join as join30, relative as relative7, resolve, sep as sep8 } from "path";
1958
1955
 
1959
1956
  // src/agents-md-render.ts
1960
1957
  init_esm_shims();
@@ -2037,6 +2034,9 @@ ${CODEX_SIZE_NOTE}` : RULES_NOTE : "",
2037
2034
  }
2038
2035
 
2039
2036
  // src/anchor-seed.ts
2037
+ init_esm_shims();
2038
+ import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
2039
+ import { join as join6 } from "path";
2040
2040
  function readIfExists(path) {
2041
2041
  if (!existsSync5(path)) return null;
2042
2042
  try {
@@ -2770,6 +2770,11 @@ function renderBundledSkill(source) {
2770
2770
  ${portBody(body)}
2771
2771
  `;
2772
2772
  }
2773
+ function renderBundledSkillFile(rel, raw) {
2774
+ if (rel === "SKILL.md") return renderBundledSkill(raw);
2775
+ return rel.endsWith(".md") || rel.endsWith(".sh") ? `${portBody(raw)}
2776
+ ` : raw;
2777
+ }
2773
2778
  function portBody(body) {
2774
2779
  return renameSlashes(body).replace(/CLAUDE_PROJECT_DIR/g, "CODEX_PROJECT_DIR").trimEnd();
2775
2780
  }
@@ -2784,7 +2789,7 @@ function writeBundledSkillDirs(params) {
2784
2789
  }
2785
2790
  const targetDir = join13(projectDir, ".agents", "skills", id);
2786
2791
  const targetSkill = join13(targetDir, "SKILL.md");
2787
- if (!writer.write(targetSkill, renderBundledSkill(readFileSync9(srcSkill, "utf8")))) {
2792
+ if (!writer.write(targetSkill, renderBundledSkillFile("SKILL.md", readFileSync9(srcSkill, "utf8")))) {
2788
2793
  continue;
2789
2794
  }
2790
2795
  written.push(targetSkill);
@@ -2793,8 +2798,7 @@ function writeBundledSkillDirs(params) {
2793
2798
  if (rel.split("/").some((segment) => segment.startsWith("."))) continue;
2794
2799
  const segments = rel.split("/");
2795
2800
  const raw = readFileSync9(join13(srcDir, ...segments), "utf8");
2796
- const ported = rel.endsWith(".md") || rel.endsWith(".sh") ? `${portBody(raw)}
2797
- ` : raw;
2801
+ const ported = renderBundledSkillFile(rel, raw);
2798
2802
  const target = join13(targetDir, ...segments);
2799
2803
  if (!writer.write(target, ported, { createInRefresh: true })) continue;
2800
2804
  if (rel.endsWith(".sh")) chmodSync(target, 493);
@@ -2812,6 +2816,10 @@ trigger: glob
2812
2816
  globs: "${rule.paths.join(", ")}"
2813
2817
  ---
2814
2818
 
2819
+ `;
2820
+ }
2821
+ function renderAntigravityRule(rule) {
2822
+ return `${antigravityFrontmatter(rule)}${rule.body}
2815
2823
  `;
2816
2824
  }
2817
2825
  function runAntigravityTransform(params) {
@@ -2838,8 +2846,7 @@ function runAntigravityTransform(params) {
2838
2846
  const harnessRuleFiles = [];
2839
2847
  for (const rule of portRules(harnessRoot, rules)) {
2840
2848
  const target = join14(projectDir, ".agents", "rules", `${rule.name}.md`);
2841
- const content = `${antigravityFrontmatter(rule)}${rule.body}
2842
- `;
2849
+ const content = renderAntigravityRule(rule);
2843
2850
  if (!writer.write(target, content, { createInRefresh: antigravityInstalled })) {
2844
2851
  continue;
2845
2852
  }
@@ -3090,6 +3097,9 @@ function quoteIfNeeded(name) {
3090
3097
  // src/codex/transform.ts
3091
3098
  var HOOK_NAMES = ["session-start"];
3092
3099
  var ENV_VAR_RENAME = /CLAUDE_PROJECT_DIR/g;
3100
+ function renderCodexHook(source) {
3101
+ return source.replace(ENV_VAR_RENAME, "CODEX_PROJECT_DIR");
3102
+ }
3093
3103
  function runCodexTransform(params) {
3094
3104
  const {
3095
3105
  harnessRoot,
@@ -3131,7 +3141,7 @@ function runCodexTransform(params) {
3131
3141
  if (!existsSync13(src)) {
3132
3142
  continue;
3133
3143
  }
3134
- const ported = readFileSync12(src, "utf8").replace(ENV_VAR_RENAME, "CODEX_PROJECT_DIR");
3144
+ const ported = renderCodexHook(readFileSync12(src, "utf8"));
3135
3145
  const target = join17(hookDir, `${hook}.sh`);
3136
3146
  if (!writer.write(target, ported)) continue;
3137
3147
  chmodSync2(target, 493);
@@ -3550,12 +3560,58 @@ function runCliTransforms(params) {
3550
3560
 
3551
3561
  // src/displaced.ts
3552
3562
  init_esm_shims();
3553
- import { lstatSync as lstatSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync15, renameSync } from "fs";
3554
- import { basename as basename3, dirname as dirname5, join as join21, posix as posix2 } from "path";
3563
+ import { lstatSync as lstatSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync16, renameSync } from "fs";
3564
+ import { basename as basename3, dirname as dirname5, join as join22, posix as posix3 } from "path";
3565
+
3566
+ // src/harness-bytes.ts
3567
+ init_esm_shims();
3568
+ import { lstatSync as lstatSync3, readFileSync as readFileSync15 } from "fs";
3569
+ import { join as join20, posix } from "path";
3570
+ var CLAUDE_DIR3 = ".claude/";
3571
+ function harnessBytesAt(log, path, isTarget = recordedTrackTargets(log)) {
3572
+ const norm = posix.normalize(path);
3573
+ const root = resolveBundleRoot();
3574
+ const text = (rel) => readFileSync15(join20(root, "templates", rel), "utf8");
3575
+ try {
3576
+ const rule = /^\.agents\/rules\/([^/]+)\.md$/.exec(norm)?.[1];
3577
+ if (rule !== void 0) {
3578
+ const [ported] = isTarget(`${CLAUDE_DIR3}rules/${rule}.md`) ? portRules(root, [rule]) : [];
3579
+ return ported === void 0 ? null : Buffer.from(renderAntigravityRule(ported));
3580
+ }
3581
+ const hook = /^\.codex\/hooks\/([^/]+)$/.exec(norm)?.[1];
3582
+ if (hook !== void 0) {
3583
+ return isTarget(`${CLAUDE_DIR3}hooks/${hook}`) ? Buffer.from(renderCodexHook(text(`hooks/${hook}`))) : null;
3584
+ }
3585
+ const skill = /^\.agents\/skills\/([^/]+\/.+)$/.exec(norm)?.[1];
3586
+ if (skill !== void 0) {
3587
+ return isTarget(`${CLAUDE_DIR3}skills/${skill}`) ? Buffer.from(
3588
+ renderBundledSkillFile(skill.slice(skill.indexOf("/") + 1), text(`skills/${skill}`))
3589
+ ) : null;
3590
+ }
3591
+ if (norm.startsWith(CLAUDE_DIR3) && isTarget(norm)) {
3592
+ return readFileSync15(join20(root, "templates", norm.slice(CLAUDE_DIR3.length)));
3593
+ }
3594
+ } catch {
3595
+ }
3596
+ return null;
3597
+ }
3598
+ function holdsHarnessBytes(log, projectDir, path, isTarget = recordedTrackTargets(log)) {
3599
+ const slot = join20(projectDir, path);
3600
+ try {
3601
+ if (!lstatSync3(slot).isFile()) return false;
3602
+ const disk = readFileSync15(slot);
3603
+ const bundle = harnessBytesAt(log, path, isTarget);
3604
+ if (bundle !== null && disk.equals(bundle)) return true;
3605
+ const rec = recorded(log, path, { isTarget });
3606
+ return rec.state === "sha" && rec.sha256 === hashContent(disk.toString("utf8"));
3607
+ } catch {
3608
+ return false;
3609
+ }
3610
+ }
3555
3611
 
3556
3612
  // src/harness-slot.ts
3557
3613
  init_esm_shims();
3558
- import { isAbsolute, join as join20, posix, relative as relative4, sep as sep5 } from "path";
3614
+ import { isAbsolute, join as join21, posix as posix2, relative as relative4, sep as sep5 } from "path";
3559
3615
  var ownedOf = (...kinds) => [
3560
3616
  ...new Set(
3561
3617
  Object.values(CLI_OWNERSHIP).flat().filter((o) => kinds.includes(o.kind)).map((o) => o.path)
@@ -3577,9 +3633,9 @@ function within(rel, slots) {
3577
3633
  return slots.places.some((p2) => p2.endsWith("/") ? rel.startsWith(p2) : rel === p2);
3578
3634
  }
3579
3635
  function realRel(projectDir, norm, follow) {
3580
- const target = follow ? resolveWriteTarget(join20(projectDir, norm)) : (() => {
3581
- const dir = resolveWriteTarget(join20(projectDir, posix.dirname(norm)));
3582
- return dir === null ? null : join20(dir, posix.basename(norm));
3636
+ const target = follow ? resolveWriteTarget(join21(projectDir, norm)) : (() => {
3637
+ const dir = resolveWriteTarget(join21(projectDir, posix2.dirname(norm)));
3638
+ return dir === null ? null : join21(dir, posix2.basename(norm));
3583
3639
  })();
3584
3640
  if (target === null) return null;
3585
3641
  const rel = relative4(resolveWriteTarget(projectDir) ?? projectDir, target);
@@ -3587,29 +3643,65 @@ function realRel(projectDir, norm, follow) {
3587
3643
  const slash = rel.split(sep5).join("/");
3588
3644
  return slash === ".." || slash.startsWith("../") ? null : slash;
3589
3645
  }
3646
+ function inSlotByName(path, slots = HARNESS_FILES) {
3647
+ return within(posix2.normalize(path), slots);
3648
+ }
3590
3649
  function inHarnessSlot(projectDir, path, slots = HARNESS_FILES, opts = {}) {
3591
- const norm = posix.normalize(path);
3650
+ const norm = posix2.normalize(path);
3592
3651
  if (!within(norm, slots)) return false;
3593
3652
  const real = realRel(projectDir, norm, opts.follow === true);
3594
3653
  return real !== null && within(real, slots);
3595
3654
  }
3596
3655
 
3656
+ // src/screen-text.ts
3657
+ init_esm_shims();
3658
+ function screenText(text) {
3659
+ return text.replace(/[^\p{L}\p{N}\p{M}._\-/~+@:,=%]/gu, (ch, at2) => {
3660
+ if (ch === " " && at2 > 0 && at2 < text.length - 1 && text[at2 - 1] !== " " && text[at2 + 1] !== " ") {
3661
+ return ch;
3662
+ }
3663
+ return asCode(ch);
3664
+ });
3665
+ }
3666
+ function oneLine(text) {
3667
+ return text.replace(/[\p{Cc}\u2028\u2029]/gu, asCode);
3668
+ }
3669
+ function asCode(ch) {
3670
+ const cp = ch.codePointAt(0);
3671
+ return cp > 65535 ? `\\u{${cp.toString(16)}}` : `\\u${cp.toString(16).padStart(4, "0")}`;
3672
+ }
3673
+
3597
3674
  // src/displaced.ts
3598
3675
  function exists(abs) {
3599
3676
  try {
3600
- lstatSync3(abs);
3677
+ lstatSync4(abs);
3601
3678
  return true;
3602
3679
  } catch {
3603
3680
  return false;
3604
3681
  }
3605
3682
  }
3606
3683
  function outsideBackup(projectDir, backup) {
3607
- const abs = join21(projectDir, backup);
3684
+ const abs = join22(projectDir, backup);
3608
3685
  const hit = outsideProjectTarget(projectDir, dirname5(abs));
3609
- return hit === null ? null : join21(hit.target, basename3(abs));
3686
+ return hit === null ? null : join22(hit.target, basename3(abs));
3610
3687
  }
3611
3688
  function isBackupOf(path, backup) {
3612
- return backupOriginal(posix2.normalize(backup)) === posix2.normalize(path);
3689
+ return backupOriginal(posix3.normalize(backup)) === posix3.normalize(path);
3690
+ }
3691
+ function replacesOnlyHarnessCopy(log, projectDir, path, isTarget) {
3692
+ if (harnessBytesAt(log, path, isTarget) === null) return false;
3693
+ return !exists(join22(projectDir, path)) || holdsHarnessBytes(log, projectDir, path, isTarget);
3694
+ }
3695
+ function handBackOf(log, projectDir, f, isTarget) {
3696
+ const backup = f.notes[0];
3697
+ if (backup === void 0 || !inSlotByName(f.path)) return null;
3698
+ if (outsideBackup(projectDir, backup) !== null || !isBackupOf(f.path, backup)) return null;
3699
+ if (!exists(join22(projectDir, backup)) || isLegacyDisplaced(log, projectDir, f)) return null;
3700
+ return {
3701
+ from: posix3.normalize(backup),
3702
+ to: posix3.normalize(f.path),
3703
+ safe: replacesOnlyHarnessCopy(log, projectDir, f.path, isTarget)
3704
+ };
3613
3705
  }
3614
3706
  function isLegacyDisplaced(log, projectDir, f) {
3615
3707
  if (f.change !== "displaced") return false;
@@ -3617,7 +3709,7 @@ function isLegacyDisplaced(log, projectDir, f) {
3617
3709
  if (outsideBackup(projectDir, at2) !== null) return false;
3618
3710
  let original;
3619
3711
  try {
3620
- original = readFileSync15(join21(projectDir, at2), "utf8");
3712
+ original = readFileSync16(join22(projectDir, at2), "utf8");
3621
3713
  } catch {
3622
3714
  return false;
3623
3715
  }
@@ -3625,17 +3717,21 @@ function isLegacyDisplaced(log, projectDir, f) {
3625
3717
  }
3626
3718
  function restoreDisplaced(log, projectDir, opts) {
3627
3719
  const out = [];
3720
+ let bundleTargets;
3628
3721
  for (const f of log.rootFiles ?? []) {
3629
3722
  if (f.change !== "displaced" || !opts.has(f.path)) continue;
3630
- const slot = join21(projectDir, f.path);
3723
+ const slot = join22(projectDir, f.path);
3631
3724
  if (outsideProjectTarget(projectDir, slot) !== null) continue;
3632
3725
  if (!inHarnessSlot(projectDir, f.path)) {
3726
+ bundleTargets ??= recordedTrackTargets(log);
3727
+ const handBack = handBackOf(log, projectDir, f, bundleTargets);
3633
3728
  out.push({
3634
3729
  path: f.path,
3635
3730
  backup: f.notes[0] ?? null,
3636
3731
  verdict: "advise",
3637
3732
  line: "not put back \u2014 the install record says this tool moved a file of yours aside here, but this is (or leads) outside the places this tool installs to; left it as is",
3638
- forget: true
3733
+ forget: true,
3734
+ ...handBack === null ? {} : { handBack }
3639
3735
  });
3640
3736
  continue;
3641
3737
  }
@@ -3646,7 +3742,7 @@ function restoreDisplaced(log, projectDir, opts) {
3646
3742
  path: f.path,
3647
3743
  backup,
3648
3744
  verdict: "advise",
3649
- line: `not put back \u2014 the install record points its backup outside this project (${away}); left that file where it is`,
3745
+ line: `not put back \u2014 the install record points its backup outside this project (${screenText(away)}); left that file where it is`,
3650
3746
  forget: true
3651
3747
  });
3652
3748
  continue;
@@ -3656,19 +3752,19 @@ function restoreDisplaced(log, projectDir, opts) {
3656
3752
  path: f.path,
3657
3753
  backup,
3658
3754
  verdict: "advise",
3659
- line: `not put back \u2014 the install record names ${JSON.stringify(backup)} as the backup, which is not a backup this tool made for this file; left that file where it is`,
3755
+ line: `not put back \u2014 the install record names "${screenText(backup)}" as the backup, which is not a backup this tool made for this file; left that file where it is`,
3660
3756
  forget: true
3661
3757
  });
3662
3758
  continue;
3663
3759
  }
3664
3760
  const d2 = judgeDisplaced({
3665
3761
  backup,
3666
- backupExists: backup !== null && exists(join21(projectDir, backup)),
3762
+ backupExists: backup !== null && exists(join22(projectDir, backup)),
3667
3763
  slotEmpty: !exists(slot) || !opts.write && opts.willBeGone?.has(f.path) === true
3668
3764
  });
3669
3765
  if (opts.write && d2.verdict === "restore" && backup !== null) {
3670
3766
  mkdirSync5(dirname5(slot), { recursive: true });
3671
- renameSync(join21(projectDir, backup), slot);
3767
+ renameSync(join22(projectDir, backup), slot);
3672
3768
  }
3673
3769
  out.push({
3674
3770
  path: f.path,
@@ -3688,7 +3784,7 @@ function withoutRestored(rootFiles, outcomes) {
3688
3784
  // src/excluded-still-there.ts
3689
3785
  init_esm_shims();
3690
3786
  import { existsSync as existsSync16 } from "fs";
3691
- import { join as join22 } from "path";
3787
+ import { join as join23 } from "path";
3692
3788
  function excludedStillThere(projectDir, excluded, baselineOnDisk, previousLog) {
3693
3789
  const out = [];
3694
3790
  const add = (id, catalog) => {
@@ -3701,7 +3797,7 @@ function excludedStillThere(projectDir, excluded, baselineOnDisk, previousLog) {
3701
3797
  for (const id of excluded) {
3702
3798
  if (INTERNAL_BUNDLED_SKILL_IDS.includes(id)) {
3703
3799
  const there = [".claude/skills", ".agents/skills"].some(
3704
- (d2) => existsSync16(join22(projectDir, d2, id))
3800
+ (d2) => existsSync16(join23(projectDir, d2, id))
3705
3801
  );
3706
3802
  if (there) add(id, false);
3707
3803
  } else {
@@ -3714,10 +3810,13 @@ function excludedStillThere(projectDir, excluded, baselineOnDisk, previousLog) {
3714
3810
  }
3715
3811
  function assetStillThere(projectDir, asset) {
3716
3812
  if (asset.method !== "skill" || asset.scope === "global") return true;
3717
- if (asset.files !== void 0)
3718
- return asset.files.some((f) => existsSync16(join22(projectDir, f.path)));
3813
+ if (asset.files?.some((f) => existsSync16(join23(projectDir, f.path)))) return true;
3814
+ if (asset.files !== void 0 && asset.filesPartial !== true) return false;
3719
3815
  const dir = asset.detail.skill ?? asset.id;
3720
- return [".claude/skills", ".agents/skills"].some((d2) => existsSync16(join22(projectDir, d2, dir)));
3816
+ const listed = new Set((asset.files ?? []).map((f) => f.path.split("/").slice(0, 3).join("/")));
3817
+ return [".claude/skills", ".agents/skills"].some(
3818
+ (d2) => !listed.has(`${d2}/${dir}`) && existsSync16(join23(projectDir, d2, dir))
3819
+ );
3721
3820
  }
3722
3821
 
3723
3822
  // src/external-installer.ts
@@ -3727,10 +3826,10 @@ import {
3727
3826
  accessSync,
3728
3827
  existsSync as existsSync17,
3729
3828
  constants as fsConstants,
3730
- lstatSync as lstatSync4,
3829
+ lstatSync as lstatSync5,
3731
3830
  mkdirSync as mkdirSync6,
3732
3831
  readdirSync as readdirSync3,
3733
- readFileSync as readFileSync16,
3832
+ readFileSync as readFileSync17,
3734
3833
  readlinkSync,
3735
3834
  realpathSync as realpathSync3,
3736
3835
  renameSync as renameSync2,
@@ -3738,7 +3837,10 @@ import {
3738
3837
  rmSync as rmSync3
3739
3838
  } from "fs";
3740
3839
  import { homedir as homedir2 } from "os";
3741
- import { basename as basename4, dirname as dirname6, join as join23, relative as relative5, sep as sep6 } from "path";
3840
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join24, relative as relative5, sep as sep6 } from "path";
3841
+ function outsideSlotNote(o) {
3842
+ return o.slot !== void 0 ? `${o.slot}/ left as is (links outside the skill folders: ${o.target})` : `${o.root}/ left as is (links outside the project: ${o.target})`;
3843
+ }
3742
3844
  var SKILL_ROOTS = [".claude/skills", ".agents/skills"];
3743
3845
  function skillRootOf(cli) {
3744
3846
  return cli === "claude" ? ".claude/skills" : ".agents/skills";
@@ -3746,11 +3848,11 @@ function skillRootOf(cli) {
3746
3848
  function snapshotSkillRoots(projectDir) {
3747
3849
  const out = /* @__PURE__ */ new Map();
3748
3850
  for (const root of SKILL_ROOTS) {
3749
- if (outsideProjectTarget(projectDir, join23(projectDir, root)) !== null) continue;
3750
- for (const rel of listFilesRecursive(join23(projectDir, root))) {
3851
+ if (outsideProjectTarget(projectDir, join24(projectDir, root)) !== null) continue;
3852
+ for (const rel of listFilesRecursive(join24(projectDir, root))) {
3751
3853
  const path = `${root}/${rel}`;
3752
3854
  try {
3753
- out.set(path, hashContent(readFileSync16(join23(projectDir, path), "utf8")));
3855
+ out.set(path, hashContent(readFileSync17(join24(projectDir, path), "utf8")));
3754
3856
  } catch {
3755
3857
  }
3756
3858
  }
@@ -3768,8 +3870,8 @@ function homeSkillDirs(roots) {
3768
3870
  }
3769
3871
  for (const name of names) {
3770
3872
  try {
3771
- const st2 = lstatSync4(join23(root, name), { bigint: true });
3772
- if (st2.isDirectory()) out.set(join23(root, name), `${st2.ino}:${st2.ctimeNs}`);
3873
+ const st2 = lstatSync5(join24(root, name), { bigint: true });
3874
+ if (st2.isDirectory()) out.set(join24(root, name), `${st2.ino}:${st2.ctimeNs}`);
3773
3875
  } catch {
3774
3876
  }
3775
3877
  }
@@ -3782,9 +3884,9 @@ function writtenSkillNames(before, after) {
3782
3884
  }
3783
3885
  function lockedSkillNames(source) {
3784
3886
  const xdg = process.env.XDG_STATE_HOME;
3785
- const path = xdg ? join23(xdg, "skills", ".skill-lock.json") : join23(homedir2(), ".agents", ".skill-lock.json");
3887
+ const path = xdg ? join24(xdg, "skills", ".skill-lock.json") : join24(homedir2(), ".agents", ".skill-lock.json");
3786
3888
  try {
3787
- const lock = JSON.parse(readFileSync16(path, "utf8"));
3889
+ const lock = JSON.parse(readFileSync17(path, "utf8"));
3788
3890
  if (typeof lock.version !== "number" || lock.version < 3) return null;
3789
3891
  if (typeof lock.skills !== "object" || lock.skills === null) return null;
3790
3892
  const out = /* @__PURE__ */ new Set();
@@ -3884,18 +3986,30 @@ function installOne(asset, ctx) {
3884
3986
  const written = writtenSkillNames(before2, homeSkillDirs(roots));
3885
3987
  return { ...result2, skills: written.filter((n) => locked.has(n)) };
3886
3988
  }
3887
- const outside = SKILL_ROOTS.flatMap((root) => {
3888
- const hit = outsideProjectTarget(cwd, join23(cwd, root));
3889
- return hit === null ? [] : [{ root, target: hit.target }];
3890
- });
3989
+ const outside = SKILL_ROOTS.flatMap(
3990
+ (root) => {
3991
+ const hit = outsideProjectTarget(cwd, join24(cwd, root));
3992
+ if (hit !== null) return [{ root, target: hit.target }];
3993
+ const slot = method.skill === void 0 ? root : `${root}/${method.skill}`;
3994
+ if (inSkillFolders(cwd, slot)) return [];
3995
+ return [{ root, target: resolveWriteTarget(join24(cwd, slot)) ?? slot, slot }];
3996
+ }
3997
+ );
3891
3998
  const outRoots = new Set(outside.map((o) => o.root));
3892
3999
  const cli = ctx.cli.filter((c3) => !outRoots.has(skillRootOf(c3)));
3893
4000
  if (outside.length > 0 && cli.length === 0) {
3894
- const where = outside.map((o) => `${o.root} \u2192 ${o.target}`).join(", ");
4001
+ const away = outside.filter((o) => o.slot === void 0);
4002
+ const where = away.map((o) => `${o.root} \u2192 ${o.target}`).join(", ");
4003
+ const reasons = [
4004
+ ...away.length > 0 ? [`the skill folder links outside the project (${where})`] : [],
4005
+ ...outside.flatMap(
4006
+ (o) => o.slot === void 0 ? [] : [`${o.slot} links outside the skill folders (${o.target})`]
4007
+ )
4008
+ ];
3895
4009
  return {
3896
4010
  asset,
3897
4011
  ok: false,
3898
- message: `not installed \u2014 the skill folder links outside the project (${where}); left as is`,
4012
+ message: `not installed \u2014 ${reasons.join("; ")}; left as is`,
3899
4013
  outside
3900
4014
  };
3901
4015
  }
@@ -3974,6 +4088,7 @@ function refreshExternalSkills(projectDir, deps = {}) {
3974
4088
  const slotCtx = { log, scope: "project" };
3975
4089
  const settle = holdSkillSlots(projectDir, {
3976
4090
  recorded: log.assets.filter((a) => targetIds.has(a.id)),
4091
+ assets: targets,
3977
4092
  slots: skillSlotsFor(inProject, clis, slotCtx),
3978
4093
  unlisted: unlistedSkillSlots(inProject, clis, slotCtx),
3979
4094
  log,
@@ -4028,6 +4143,9 @@ function refreshExternalSkills(projectDir, deps = {}) {
4028
4143
  );
4029
4144
  const late = reclaimNewlyNamed(projectDir, log, next);
4030
4145
  const reclaimedAll = [...reclaimed, ...late];
4146
+ const leftAsIs = report.attempted.flatMap(
4147
+ (r) => r.ok && r.outside !== void 0 && r.outside.length > 0 ? [{ id: r.asset.id, outside: r.outside }] : []
4148
+ );
4031
4149
  return {
4032
4150
  attempted: report.attempted.length,
4033
4151
  refreshed: report.succeeded,
@@ -4035,6 +4153,7 @@ function refreshExternalSkills(projectDir, deps = {}) {
4035
4153
  notInCatalog,
4036
4154
  unknown: false,
4037
4155
  ...reclaimedAll.length > 0 ? { reclaimed: reclaimedAll } : {},
4156
+ ...leftAsIs.length > 0 ? { leftAsIs } : {},
4038
4157
  judged: [...reclaimedAll.flatMap((r) => r.judged), ...judged]
4039
4158
  };
4040
4159
  }
@@ -4042,15 +4161,16 @@ function holdSkillSlots(projectDir, hold) {
4042
4161
  const now = /* @__PURE__ */ new Date();
4043
4162
  const asides = /* @__PURE__ */ new Map();
4044
4163
  const moved = [];
4164
+ const kept = slotFilesToKeep(projectDir, hold);
4045
4165
  try {
4046
- for (const f of slotFilesToKeep(projectDir, hold)) {
4166
+ for (const f of kept.files) {
4047
4167
  const root = dirname6(f.slot);
4048
4168
  let dir = asides.get(root);
4049
4169
  if (dir === void 0) {
4050
- dir = claimBackupDir(join23(projectDir, root), now);
4170
+ dir = claimBackupDir(join24(projectDir, root), now);
4051
4171
  asides.set(root, dir);
4052
4172
  }
4053
- const aside = join23(dir, f.rel.slice(root.length + 1));
4173
+ const aside = join24(dir, f.rel.slice(root.length + 1));
4054
4174
  mkdirSync6(dirname6(aside), { recursive: true });
4055
4175
  renameSync2(f.abs, aside);
4056
4176
  moved.push({ ...f, aside });
@@ -4073,19 +4193,32 @@ function holdSkillSlots(projectDir, hold) {
4073
4193
  displaced: [],
4074
4194
  judged: []
4075
4195
  };
4196
+ const ok = (report?.attempted ?? []).filter((r) => r.ok);
4076
4197
  const rewritten = new Set(
4077
- (report?.attempted ?? []).flatMap(
4078
- (r) => r.ok ? (r.files?.created ?? []).map((x) => skillFolderOf(x.path)) : []
4079
- )
4198
+ [
4199
+ ...ok.flatMap((r) => (r.files?.created ?? []).map((x) => skillFolderOf(x.path))),
4200
+ ...skillSlotsFor(
4201
+ ok.map((r) => r.asset),
4202
+ hold.clis,
4203
+ { log: hold.log, scope: hold.scope }
4204
+ )
4205
+ ].flatMap((p2) => realOrNull(join24(projectDir, p2)) ?? [])
4080
4206
  );
4081
4207
  const back = /* @__PURE__ */ new Set();
4082
4208
  const failed = [];
4083
4209
  for (const f of moved) {
4084
4210
  const restore = failedSlots === null || failedSlots.some((s) => f.rel === s || f.rel.startsWith(`${s}/`));
4085
4211
  try {
4086
- const r = settleAside(projectDir, f, restore, rewritten.has(skillFolderOf(f.rel)));
4212
+ const literal = realFileOrNull(f.abs) === f.real;
4213
+ const at2 = literal ? f : { ...f, abs: inProjectSpelling(projectDir, f.real) };
4214
+ const r = settleAside(
4215
+ projectDir,
4216
+ at2,
4217
+ restore,
4218
+ f.folder !== null && rewritten.has(f.folder) && inCanonicalSkillRoot(projectDir, f.real)
4219
+ );
4087
4220
  if (r === "back") {
4088
- back.add(f.rel);
4221
+ if (literal) back.add(f.rel);
4089
4222
  continue;
4090
4223
  }
4091
4224
  out.backups.push(r.backup);
@@ -4111,9 +4244,30 @@ function holdSkillSlots(projectDir, hold) {
4111
4244
  `could not put back ${failed.length} file(s) moved aside before the skill tool ran \u2014 they stay in ${at2}: ${failed.join(", ")}`
4112
4245
  );
4113
4246
  }
4114
- return { ...out, report: report === null ? null : withoutCreated(report, back) };
4247
+ const settled = report === null ? null : settledReport(report, back, coveredBy(report, kept, hold));
4248
+ return { ...out, report: settled };
4115
4249
  };
4116
4250
  }
4251
+ function coveredBy(report, kept, hold) {
4252
+ const unlisted = new Set(hold.unlisted ?? []);
4253
+ const out = /* @__PURE__ */ new Map();
4254
+ if (unlisted.size === 0) return out;
4255
+ for (const r of report.attempted) {
4256
+ if (!r.ok || r.files === void 0) continue;
4257
+ const own = new Set(
4258
+ skillSlotsFor([r.asset], hold.clis, { log: hold.log, scope: hold.scope }).filter(
4259
+ (s) => unlisted.has(s)
4260
+ )
4261
+ );
4262
+ const folders = /* @__PURE__ */ new Set();
4263
+ for (const f of r.files.created) {
4264
+ const folder = skillFolderOf(f.path);
4265
+ if (own.has(kept.ownerOf(f.path)) && !kept.left.has(folder)) folders.add(folder);
4266
+ }
4267
+ if (folders.size > 0) out.set(r, folders);
4268
+ }
4269
+ return out;
4270
+ }
4117
4271
  function skillSlotsFor(assets, clis, ctx) {
4118
4272
  if (resolveScope(ctx.scope) === "global") return [];
4119
4273
  const roots = clis.length === 0 ? [...SKILL_ROOTS] : [...new Set(clis.map(skillRootOf))];
@@ -4126,11 +4280,15 @@ function skillSlotsFor(assets, clis, ctx) {
4126
4280
  return [...out];
4127
4281
  }
4128
4282
  function unlistedSkillSlots(assets, clis, ctx) {
4129
- const unlisted = assets.filter((a) => {
4283
+ const out = assets.flatMap((a) => {
4130
4284
  const prior = ctx.log?.assets.find((r) => r.id === a.id);
4131
- return prior !== void 0 && prior.files === void 0;
4285
+ if (prior === void 0) return [];
4286
+ if (prior.files === void 0) return skillSlotsFor([a], clis, ctx);
4287
+ if (prior.filesPartial !== true) return [];
4288
+ const listed = new Set(prior.files.map((f) => skillFolderOf(f.path)));
4289
+ return skillSlotsFor([a], clis, ctx).filter((s) => !listed.has(s));
4132
4290
  });
4133
- return skillSlotsFor(unlisted, clis, ctx);
4291
+ return [...new Set(out)];
4134
4292
  }
4135
4293
  function reclaimGlobalSkillCopies(projectDir, log, opts) {
4136
4294
  const clis = installedClis(log);
@@ -4150,13 +4308,13 @@ function reclaimGlobalSkillCopies(projectDir, log, opts) {
4150
4308
  for (const name of names) {
4151
4309
  for (const root of roots) {
4152
4310
  const slot = `${root}/${name}`;
4153
- const real = realOrNull(join23(projectDir, slot));
4311
+ const real = realOrNull(join24(projectDir, slot));
4154
4312
  if (real !== null) {
4155
4313
  if (seen.has(real)) continue;
4156
4314
  seen.add(real);
4157
4315
  }
4158
4316
  const ctx = { log, others, write: opts.write, rm, id: a.id };
4159
- const r = reclaimCopy(projectDir, slot, join23(globalSkillRoot(root), name), ctx);
4317
+ const r = reclaimCopy(projectDir, slot, join24(globalSkillRoot(root), name), ctx);
4160
4318
  if (r !== null) out.push(r);
4161
4319
  }
4162
4320
  }
@@ -4165,17 +4323,17 @@ function reclaimGlobalSkillCopies(projectDir, log, opts) {
4165
4323
  }
4166
4324
  function globalSkillRoot(root) {
4167
4325
  if (root === ".claude/skills") {
4168
- return join23(process.env.CLAUDE_CONFIG_DIR?.trim() || join23(homedir2(), ".claude"), "skills");
4326
+ return join24(process.env.CLAUDE_CONFIG_DIR?.trim() || join24(homedir2(), ".claude"), "skills");
4169
4327
  }
4170
- return join23(homedir2(), ".agents/skills");
4328
+ return join24(homedir2(), ".agents/skills");
4171
4329
  }
4172
4330
  function isSkillName(name) {
4173
4331
  return typeof name === "string" && name !== "" && name !== "." && name !== ".." && !/[\\/]/.test(name);
4174
4332
  }
4175
4333
  function reclaimCopy(projectDir, slot, home, ctx) {
4176
- const abs = join23(projectDir, slot);
4334
+ const abs = join24(projectDir, slot);
4177
4335
  try {
4178
- if (lstatSync4(abs, { throwIfNoEntry: false })?.isDirectory() !== true) return null;
4336
+ if (lstatSync5(abs, { throwIfNoEntry: false })?.isDirectory() !== true) return null;
4179
4337
  if (outsideProjectTarget(projectDir, abs) !== null) return null;
4180
4338
  if (existsSync17(home) && realpathSync3(abs) === realpathSync3(home)) return null;
4181
4339
  } catch {
@@ -4206,15 +4364,15 @@ function reclaimCopy(projectDir, slot, home, ctx) {
4206
4364
  res.left.push({ path, why: "a link \u2014 not part of the copy the tool put here" });
4207
4365
  continue;
4208
4366
  }
4209
- const file = join23(abs, rel);
4367
+ const file = join24(abs, rel);
4210
4368
  try {
4211
- const mine = readFileSync16(file);
4212
- const same = homeExists && readOrNull(join23(home, rel))?.equals(mine) === true;
4369
+ const mine = readFileSync17(file);
4370
+ const same = homeExists && readOrNull(join24(home, rel))?.equals(mine) === true;
4213
4371
  const backupAbs = !same && ctx.write ? backupFile(file, now) : void 0;
4214
4372
  if (ctx.write) ctx.rm(file);
4215
4373
  res.removed.push(path);
4216
4374
  if (same) continue;
4217
- const line = homeExists ? `not the same as the global copy (${join23(home, rel)}) \u2014 saved as <file>.backup-<time>, removed from live` : `no global copy at ${home} to compare \u2014 saved as <file>.backup-<time>, removed from live`;
4375
+ const line = homeExists ? `not the same as the global copy (${join24(home, rel)}) \u2014 saved as <file>.backup-<time>, removed from live` : `no global copy at ${home} to compare \u2014 saved as <file>.backup-<time>, removed from live`;
4218
4376
  const judged = {
4219
4377
  path,
4220
4378
  verdict: "backup+remove",
@@ -4233,6 +4391,14 @@ function reclaimCopy(projectDir, slot, home, ctx) {
4233
4391
  if (ctx.write && res.removed.length > 0) pruneEmptyDirs(abs);
4234
4392
  return res.removed.length > 0 || res.left.length > 0 ? res : null;
4235
4393
  }
4394
+ function inCanonicalSkillRoot(projectDir, real) {
4395
+ const rel = relative5(realOrNull(projectDir) ?? projectDir, real).split(sep6).join("/");
4396
+ return SKILL_ROOTS.some((r) => rel.startsWith(`${r}/`));
4397
+ }
4398
+ function inProjectSpelling(projectDir, real) {
4399
+ const at2 = relative5(realOrNull(projectDir) ?? projectDir, real);
4400
+ return at2 === "" || at2 === ".." || at2.startsWith(`..${sep6}`) || isAbsolute2(at2) ? real : join24(projectDir, at2);
4401
+ }
4236
4402
  function realOrNull(abs) {
4237
4403
  try {
4238
4404
  return realpathSync3(abs);
@@ -4242,11 +4408,11 @@ function realOrNull(abs) {
4242
4408
  }
4243
4409
  function realFileOrNull(abs) {
4244
4410
  const dir = realOrNull(dirname6(abs));
4245
- return dir === null ? null : join23(dir, basename4(abs));
4411
+ return dir === null ? null : join24(dir, basename4(abs));
4246
4412
  }
4247
4413
  function readOrNull(abs) {
4248
4414
  try {
4249
- return readFileSync16(abs);
4415
+ return readFileSync17(abs);
4250
4416
  } catch {
4251
4417
  return null;
4252
4418
  }
@@ -4259,7 +4425,7 @@ function slotFilesToKeep(projectDir, hold) {
4259
4425
  const sha = new Map(mine.map((f) => [f.path, f.sha256]));
4260
4426
  const realSha = new Map(
4261
4427
  mine.flatMap((f) => {
4262
- const real = realFileOrNull(join23(projectDir, f.path));
4428
+ const real = realFileOrNull(join24(projectDir, f.path));
4263
4429
  return real === null ? [] : [[real, f.sha256]];
4264
4430
  })
4265
4431
  );
@@ -4268,42 +4434,61 @@ function slotFilesToKeep(projectDir, hold) {
4268
4434
  (hold.log?.assets ?? []).filter((a) => !targetIds.has(a.id)).flatMap((a) => (a.files ?? []).map((f) => f.path))
4269
4435
  );
4270
4436
  const slots = /* @__PURE__ */ new Set([
4271
- ...mine.map((f) => f.path.split("/")).filter((parts) => parts.length > 3).map((parts) => parts.slice(0, 3).join("/")),
4437
+ ...hold.recorded.flatMap(
4438
+ (a) => recordedSlots(
4439
+ projectDir,
4440
+ a,
4441
+ hold.assets.find((c3) => c3.id === a.id)
4442
+ )
4443
+ ),
4272
4444
  ...hold.slots
4273
4445
  ]);
4274
4446
  const unlisted = new Set(hold.unlisted ?? []);
4275
- const unlistedAt = (path) => {
4447
+ const ownerOf = (path) => {
4276
4448
  let owner = "";
4277
4449
  for (const s of slots) if (path.startsWith(`${s}/`) && s.length > owner.length) owner = s;
4278
- return unlisted.has(owner);
4450
+ return owner;
4279
4451
  };
4452
+ const unlistedAt = (path) => unlisted.has(ownerOf(path));
4280
4453
  const out = /* @__PURE__ */ new Map();
4454
+ const left = /* @__PURE__ */ new Set();
4281
4455
  const realProject = realpathSync3(projectDir);
4282
4456
  for (const slot of slots) {
4283
- if (outsideProjectTarget(projectDir, join23(projectDir, slot)) !== null) continue;
4284
- for (const { rel, link } of listEntriesRecursive(join23(projectDir, slot))) {
4457
+ if (outsideProjectTarget(projectDir, join24(projectDir, slot)) !== null) continue;
4458
+ if (!inSkillFolders(projectDir, slot)) continue;
4459
+ for (const { rel, link } of listEntriesRecursive(join24(projectDir, slot))) {
4285
4460
  const path = `${slot}/${rel}`;
4286
- if (link && SKILL_ROOTS.includes(dirname6(path))) continue;
4287
- const abs = join23(projectDir, path);
4288
- const real = join23(realpathSync3(dirname6(abs)), basename4(abs));
4461
+ if (link && SKILL_ROOTS.includes(dirname6(path))) {
4462
+ left.add(skillFolderOf(path));
4463
+ continue;
4464
+ }
4465
+ const abs = join24(projectDir, path);
4466
+ const real = join24(realpathSync3(dirname6(abs)), basename4(abs));
4289
4467
  const prev = out.get(real);
4290
- if (prev !== void 0 && (prev.rel === path || real !== join23(realProject, path))) continue;
4468
+ if (prev !== void 0 && (prev.rel === path || real !== join24(realProject, path))) continue;
4291
4469
  const recordedSha = sha.get(path) ?? realSha.get(real);
4292
- if (recordedSha === void 0 && (others.has(path) || recorded(hold.log, path).state !== "none"))
4470
+ if (recordedSha === void 0 && (others.has(path) || recorded(hold.log, path).state !== "none")) {
4471
+ left.add(skillFolderOf(path));
4293
4472
  continue;
4473
+ }
4294
4474
  try {
4295
4475
  if (!link) {
4296
- if (recordedSha !== void 0 && hashContent(readFileSync16(abs, "utf8")) === recordedSha)
4476
+ if (recordedSha !== void 0 && hashContent(readFileSync17(abs, "utf8")) === recordedSha) {
4477
+ left.add(skillFolderOf(path));
4297
4478
  continue;
4479
+ }
4298
4480
  accessSync(abs, fsConstants.R_OK);
4299
4481
  }
4300
4482
  } catch {
4483
+ left.add(skillFolderOf(path));
4301
4484
  continue;
4302
4485
  }
4303
4486
  const listed = recordedSha !== void 0;
4304
4487
  out.set(real, {
4305
4488
  abs,
4489
+ real,
4306
4490
  rel: path,
4491
+ folder: realOrNull(join24(projectDir, skillFolderOf(path))),
4307
4492
  slot,
4308
4493
  recorded: listed,
4309
4494
  unlisted: !listed && unlistedAt(path) && backupOriginal(path) === null,
@@ -4311,20 +4496,51 @@ function slotFilesToKeep(projectDir, hold) {
4311
4496
  });
4312
4497
  }
4313
4498
  }
4314
- return [...out.values()];
4499
+ return { files: [...out.values()], left, ownerOf };
4500
+ }
4501
+ function recordedSlots(projectDir, asset, catalog) {
4502
+ if (catalog?.method.kind !== "skill") return [];
4503
+ const named = catalog.method.skill;
4504
+ if (asset.detail.skill !== named || named !== void 0 && !isSkillName(named)) return [];
4505
+ const out = /* @__PURE__ */ new Set();
4506
+ for (const f of asset.files ?? []) {
4507
+ const parts = f.path.split("/");
4508
+ if (parts.length <= 3) continue;
4509
+ const root = `${parts[0]}/${parts[1]}`;
4510
+ const name = parts[2];
4511
+ if (!SKILL_ROOTS.includes(root) || !isSkillName(name)) continue;
4512
+ if (named !== void 0 && name !== named) continue;
4513
+ const slot = `${root}/${name}`;
4514
+ if (!inSkillFolders(projectDir, slot)) continue;
4515
+ out.add(slot);
4516
+ }
4517
+ return [...out];
4518
+ }
4519
+ function inSkillFolders(projectDir, slot) {
4520
+ if (resolveWriteTarget(join24(projectDir, slot)) === null) return true;
4521
+ const name = slot.split("/").slice(2).join("/");
4522
+ const base = resolveWriteTarget(projectDir) ?? projectDir;
4523
+ const roots = SKILL_ROOTS.flatMap((r) => {
4524
+ const real = resolveWriteTarget(join24(projectDir, r));
4525
+ if (real === null) return [r];
4526
+ const rel = relative5(base, real).split(sep6).join("/");
4527
+ return rel === "" || rel === ".." || rel.startsWith("../") || isAbsolute2(rel) ? [r] : [r, rel];
4528
+ });
4529
+ const places = [...new Set(roots.map((r) => name === "" ? `${r}/` : `${r}/${name}/`))];
4530
+ return inHarnessSlot(projectDir, `${slot}/_`, { places });
4315
4531
  }
4316
4532
  function settleAside(projectDir, f, restore, folderRewritten) {
4317
4533
  let now = null;
4318
4534
  let vacant = false;
4319
4535
  try {
4320
- if (f.link) lstatSync4(f.abs);
4321
- else now = readFileSync16(f.abs);
4536
+ if (f.link) lstatSync5(f.abs);
4537
+ else now = readFileSync17(f.abs);
4322
4538
  } catch (e2) {
4323
4539
  const code = e2.code;
4324
4540
  if (code !== "ENOENT" && code !== "ENOTDIR") throw e2;
4325
4541
  vacant = true;
4326
4542
  }
4327
- const keep = vacant ? f.unlisted ? !folderRewritten : f.link || !f.recorded : f.link ? lstatSync4(f.abs).isSymbolicLink() && readlinkSync(f.abs) === readlinkSync(f.aside) : now?.equals(readFileSync16(f.aside)) === true;
4543
+ const keep = vacant ? !folderRewritten || f.link || !f.recorded && !f.unlisted : f.link ? lstatSync5(f.abs).isSymbolicLink() && readlinkSync(f.abs) === readlinkSync(f.aside) : now?.equals(readFileSync17(f.aside)) === true;
4328
4544
  if (restore || keep) {
4329
4545
  mkdirSync6(dirname6(f.abs), { recursive: true });
4330
4546
  renameSync2(f.aside, f.abs);
@@ -4339,25 +4555,27 @@ function settleAside(projectDir, f, restore, folderRewritten) {
4339
4555
  displaced: { path: f.rel, change: "displaced", notes: [toProjectRel(projectDir, backup)] }
4340
4556
  };
4341
4557
  }
4342
- function skillFolderOf(path) {
4343
- return path.split("/").slice(0, 3).join("/");
4344
- }
4345
- function withoutCreated(report, paths) {
4346
- if (paths.size === 0) return report;
4558
+ function settledReport(report, paths, covered) {
4559
+ if (paths.size === 0 && covered.size === 0) return report;
4347
4560
  return {
4348
4561
  ...report,
4349
- attempted: report.attempted.map(
4350
- (r) => r.files === void 0 ? r : {
4562
+ attempted: report.attempted.map((r) => {
4563
+ if (r.files === void 0) return r;
4564
+ const folders = covered.get(r);
4565
+ const created = r.files.created.filter(
4566
+ (x) => !paths.has(x.path) || folders?.has(skillFolderOf(x.path)) === true
4567
+ );
4568
+ return {
4351
4569
  ...r,
4352
- files: { ...r.files, created: r.files.created.filter((x) => !paths.has(x.path)) }
4353
- }
4354
- )
4570
+ files: { ...r.files, created, ...folders ? { covered: [...folders].sort() } : {} }
4571
+ };
4572
+ })
4355
4573
  };
4356
4574
  }
4357
4575
  function pruneEmptyDirs(dir) {
4358
4576
  try {
4359
4577
  for (const e2 of readdirSync3(dir, { withFileTypes: true }))
4360
- if (e2.isDirectory()) pruneEmptyDirs(join23(dir, e2.name));
4578
+ if (e2.isDirectory()) pruneEmptyDirs(join24(dir, e2.name));
4361
4579
  rmdirSync(dir);
4362
4580
  } catch {
4363
4581
  }
@@ -4367,7 +4585,7 @@ function toProjectRel(projectDir, abs) {
4367
4585
  }
4368
4586
  function recordRefreshedFiles(projectDir, log, report, displaced, writeLog) {
4369
4587
  const next = new Map(
4370
- buildAssetEntries(report, log.scope, log.assets).filter((e2) => e2.files !== void 0).map((e2) => [e2.id, e2.files])
4588
+ buildAssetEntries(report, log.scope, log.assets).filter((e2) => e2.files !== void 0).map((e2) => [e2.id, e2])
4371
4589
  );
4372
4590
  const named = new Map(
4373
4591
  report.attempted.flatMap(
@@ -4376,13 +4594,19 @@ function recordRefreshedFiles(projectDir, log, report, displaced, writeLog) {
4376
4594
  );
4377
4595
  let changed = displaced.length > 0;
4378
4596
  const assets = log.assets.map((a) => {
4379
- const files = next.get(a.id);
4597
+ const entry = next.get(a.id);
4598
+ const files = entry?.files;
4599
+ const partial = entry?.filesPartial === true ? { filesPartial: true } : {};
4600
+ const sameFiles = files === void 0 || JSON.stringify(files) === JSON.stringify(a.files) && entry?.filesPartial === a.filesPartial;
4380
4601
  const { skills } = skillNames(a, a.scope, named.get(a.id));
4381
- const sameFiles = files === void 0 || JSON.stringify(files) === JSON.stringify(a.files);
4382
4602
  const sameSkills = skills === void 0 || JSON.stringify(skills) === JSON.stringify(a.skills);
4383
4603
  if (sameFiles && sameSkills) return a;
4384
4604
  changed = true;
4385
- return { ...a, ...sameFiles ? {} : { files }, ...skills !== void 0 ? { skills } : {} };
4605
+ return {
4606
+ ...a,
4607
+ ...sameFiles ? {} : { files, ...partial },
4608
+ ...skills !== void 0 ? { skills } : {}
4609
+ };
4386
4610
  });
4387
4611
  if (!changed) return log;
4388
4612
  const written = {
@@ -4490,9 +4714,9 @@ function detectVersion(method, spawn, scope, projectDir) {
4490
4714
  case "plugin":
4491
4715
  return detectPluginVersion(method.pluginId, scope, projectDir);
4492
4716
  case "npm": {
4493
- const pkgJson = scope === "global" ? detectGlobalNpmPackageJsonPath(method.pkg, spawn) : join23(projectDir, "node_modules", method.pkg, "package.json");
4717
+ const pkgJson = scope === "global" ? detectGlobalNpmPackageJsonPath(method.pkg, spawn) : join24(projectDir, "node_modules", method.pkg, "package.json");
4494
4718
  if (!pkgJson || !existsSync17(pkgJson)) return void 0;
4495
- const parsed = JSON.parse(readFileSync16(pkgJson, "utf8"));
4719
+ const parsed = JSON.parse(readFileSync17(pkgJson, "utf8"));
4496
4720
  return parsed.version;
4497
4721
  }
4498
4722
  default:
@@ -4504,9 +4728,9 @@ function detectVersion(method, spawn, scope, projectDir) {
4504
4728
  }
4505
4729
  function detectPluginVersion(pluginId, scope, projectDir) {
4506
4730
  const claudeScope = scope === "global" ? "user" : "project";
4507
- const path = join23(homedir2(), ".claude/plugins/installed_plugins.json");
4731
+ const path = join24(homedir2(), ".claude/plugins/installed_plugins.json");
4508
4732
  if (!existsSync17(path)) return void 0;
4509
- const data = JSON.parse(readFileSync16(path, "utf8"));
4733
+ const data = JSON.parse(readFileSync17(path, "utf8"));
4510
4734
  const entries = data.plugins?.[pluginId] ?? [];
4511
4735
  const matches = entries.filter(
4512
4736
  (e2) => claudeScope === "user" ? e2.scope === "user" : e2.scope === "project" && e2.projectPath === projectDir
@@ -4519,7 +4743,7 @@ function detectPluginVersion(pluginId, scope, projectDir) {
4519
4743
  }
4520
4744
  function detectGlobalNpmPackageJsonPath(pkg, spawn) {
4521
4745
  const npmRoot = getNpmGlobalRoot(spawn);
4522
- return npmRoot ? join23(npmRoot, pkg, "package.json") : void 0;
4746
+ return npmRoot ? join24(npmRoot, pkg, "package.json") : void 0;
4523
4747
  }
4524
4748
  var npmGlobalRootCache;
4525
4749
  function getNpmGlobalRoot(spawn) {
@@ -4538,8 +4762,8 @@ function getNpmGlobalRoot(spawn) {
4538
4762
 
4539
4763
  // src/key-ids.ts
4540
4764
  init_esm_shims();
4541
- import { readFileSync as readFileSync17 } from "fs";
4542
- import { join as join24 } from "path";
4765
+ import { readFileSync as readFileSync18 } from "fs";
4766
+ import { join as join25 } from "path";
4543
4767
  function renderedKeyIds(harnessRoot, input, clis) {
4544
4768
  const out = /* @__PURE__ */ new Set();
4545
4769
  const add = (path, key) => {
@@ -4562,7 +4786,7 @@ function renderedKeyIds(harnessRoot, input, clis) {
4562
4786
  for (const name of Object.keys(mcp.mcpServers)) add(".mcp.json", `mcpServers.${name}`);
4563
4787
  for (const key of gitignoreRender().keys()) add(".gitignore", key);
4564
4788
  if (clis.includes("claude")) {
4565
- const template = readFileSync17(join24(harnessRoot, "templates/settings.json"), "utf8");
4789
+ const template = readFileSync18(join25(harnessRoot, "templates/settings.json"), "utf8");
4566
4790
  for (const key of renderSettingsPortion(template, () => true).keys()) {
4567
4791
  add(".claude/settings.json", key);
4568
4792
  }
@@ -4603,7 +4827,7 @@ function withoutAccepts(harnessRoot, spec, previous) {
4603
4827
 
4604
4828
  // src/linked-skill-bodies.ts
4605
4829
  init_esm_shims();
4606
- import { join as join25 } from "path";
4830
+ import { join as join26 } from "path";
4607
4831
  function refreshLinkedSkillBodies(params) {
4608
4832
  const { harnessRoot, projectDir, ids, baseline, journal } = params;
4609
4833
  const bodyKey = (id) => `.agents/skills/${id}/SKILL.md`;
@@ -4614,7 +4838,7 @@ function refreshLinkedSkillBodies(params) {
4614
4838
  );
4615
4839
  const result = writer.result();
4616
4840
  return {
4617
- updated: ours.filter((id) => written.has(join25(projectDir, bodyKey(id)))),
4841
+ updated: ours.filter((id) => written.has(join26(projectDir, bodyKey(id)))),
4618
4842
  notOurs: ids.filter((id) => !baseline.has(bodyKey(id))),
4619
4843
  files: result.files,
4620
4844
  backupPaths: result.backupPaths,
@@ -4628,8 +4852,8 @@ function refreshLinkedSkillBodies(params) {
4628
4852
 
4629
4853
  // src/out-of-track.ts
4630
4854
  init_esm_shims();
4631
- import { lstatSync as lstatSync5, readFileSync as readFileSync18, rmSync as rmSync4 } from "fs";
4632
- import { join as join26 } from "path";
4855
+ import { lstatSync as lstatSync6, readFileSync as readFileSync19, rmSync as rmSync4 } from "fs";
4856
+ import { join as join27 } from "path";
4633
4857
  var AGENTS_RULE = /^\.agents\/rules\/([^/]+)\.md$/;
4634
4858
  var ANCHOR_RULE = "uzys-harness";
4635
4859
  function reclaimOutOfTrack(args) {
@@ -4649,17 +4873,17 @@ function reclaimOutOfTrack(args) {
4649
4873
  const name = AGENTS_RULE.exec(f.path)?.[1];
4650
4874
  if (name === void 0 || name === ANCHOR_RULE || rendered.has(name)) continue;
4651
4875
  if (isBaselineExcluded(`.claude/rules/${name}.md`, args.excluded)) continue;
4652
- const abs = join26(projectDir, f.path);
4876
+ const abs = join27(projectDir, f.path);
4653
4877
  if (args.outside.skip(abs)) continue;
4654
4878
  if (!inHarnessSlot(projectDir, f.path)) continue;
4655
- const stat = lstatSync5(abs, { throwIfNoEntry: false });
4879
+ const stat = lstatSync6(abs, { throwIfNoEntry: false });
4656
4880
  if (stat !== void 0 && !stat.isFile()) continue;
4657
4881
  if (stat !== void 0 && claudeCopy.has(`rules/${name}.md`)) {
4658
4882
  out.kept.push(f.path);
4659
4883
  out.bringBack[f.path] = tracksBringing(name);
4660
4884
  continue;
4661
4885
  }
4662
- const disk = stat === void 0 ? null : readFileSync18(abs, "utf8");
4886
+ const disk = stat === void 0 ? null : readFileSync19(abs, "utf8");
4663
4887
  const verdict = judge({
4664
4888
  op: "remove",
4665
4889
  kind: "harness",
@@ -4691,15 +4915,15 @@ function tracksBringing(rule) {
4691
4915
 
4692
4916
  // src/state.ts
4693
4917
  init_esm_shims();
4694
- import { existsSync as existsSync18, readFileSync as readFileSync19 } from "fs";
4695
- import { join as join27 } from "path";
4918
+ import { existsSync as existsSync18, readFileSync as readFileSync20 } from "fs";
4919
+ import { join as join28 } from "path";
4696
4920
  var META_FILE = ".claude/.installed-tracks";
4697
4921
  var LEGACY_ANCHOR_FILE = ".claude/CLAUDE.md";
4698
4922
  var TRACE_RULES = ["htmx", "nextjs", "data-analysis", "pyside6", "cli-development"].map(
4699
4923
  (r) => `.claude/rules/${r}.md`
4700
4924
  );
4701
4925
  function detectInstallState(projectDir) {
4702
- const hasClaudeDir = existsSync18(join27(projectDir, ".claude"));
4926
+ const hasClaudeDir = existsSync18(join28(projectDir, ".claude"));
4703
4927
  const read = readInstallLogStatus(projectDir);
4704
4928
  if (read.status === "ok") {
4705
4929
  return {
@@ -4719,10 +4943,10 @@ function tracksFromLog(tracks) {
4719
4943
  return [...new Set(tracks.filter(isTrack))].sort();
4720
4944
  }
4721
4945
  function collectTraces(projectDir) {
4722
- const at2 = (rel) => join27(projectDir, rel);
4946
+ const at2 = (rel) => join28(projectDir, rel);
4723
4947
  const text = (rel) => {
4724
4948
  try {
4725
- return readFileSync19(at2(rel), "utf8");
4949
+ return readFileSync20(at2(rel), "utf8");
4726
4950
  } catch {
4727
4951
  return null;
4728
4952
  }
@@ -4786,14 +5010,14 @@ init_esm_shims();
4786
5010
  import {
4787
5011
  copyFileSync,
4788
5012
  existsSync as existsSync19,
4789
- lstatSync as lstatSync6,
5013
+ lstatSync as lstatSync7,
4790
5014
  readdirSync as readdirSync4,
4791
- readFileSync as readFileSync20,
5015
+ readFileSync as readFileSync21,
4792
5016
  rmdirSync as rmdirSync2,
4793
5017
  unlinkSync as unlinkSync2,
4794
5018
  writeFileSync as writeFileSync6
4795
5019
  } from "fs";
4796
- import { basename as basename5, dirname as dirname7, join as join28, relative as relative6, sep as sep7 } from "path";
5020
+ import { basename as basename5, dirname as dirname7, join as join29, relative as relative6, sep as sep7 } from "path";
4797
5021
  var LEGACY_ANCHOR_FILE2 = ".claude/CLAUDE.md";
4798
5022
  function buildUpdateSpec(projectDir, tracks, only) {
4799
5023
  const log = readInstallLog(projectDir);
@@ -4815,7 +5039,7 @@ function parseUpdateOnly(raw) {
4815
5039
  return { ok: true, groups: [...new Set(raw)] };
4816
5040
  }
4817
5041
  function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
4818
- const claudeDir = join28(projectDir, ".claude");
5042
+ const claudeDir = join29(projectDir, ".claude");
4819
5043
  const startedAt = Date.now();
4820
5044
  const backupsAtStart = new Set(
4821
5045
  collectRunBackups(projectDir, Number.NEGATIVE_INFINITY).map((b2) => b2.backup)
@@ -4886,7 +5110,7 @@ function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
4886
5110
  harnessMcp,
4887
5111
  harnessWrote: harness.wrote
4888
5112
  });
4889
- const settingsPath = join28(claudeDir, "settings.json");
5113
+ const settingsPath = join29(claudeDir, "settings.json");
4890
5114
  if (claudeManaged && wants("hooks") && existsSync19(settingsPath) && !outside.skip(settingsPath)) {
4891
5115
  report.retiredHookRefsRemoved = removeRetiredHookRefs(
4892
5116
  settingsPath,
@@ -5000,6 +5224,7 @@ function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
5000
5224
  const skillRefresh = wants("external") ? (deps.refreshSkills ?? refreshExternalSkills)(projectDir) : { attempted: 0, refreshed: 0, failed: [], notInCatalog: [], unknown: false };
5001
5225
  report.externalSkillsRefreshed = skillRefresh.refreshed;
5002
5226
  report.externalSkillsFailed = skillRefresh.failed;
5227
+ if (skillRefresh.leftAsIs !== void 0) report.externalSkillsLeftAsIs = skillRefresh.leftAsIs;
5003
5228
  const removedOnRecord = wants("external") ? catalogRemovedOnRecord(logAtStart) : [];
5004
5229
  if (removedOnRecord.length > 0) report.catalogRemoved = removedOnRecord;
5005
5230
  const saidAsRemoved = new Set(removedOnRecord.map((e2) => e2.id));
@@ -5033,7 +5258,7 @@ function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
5033
5258
  judged.filter((j4) => j4.recorded === "no-sha" && j4.backup !== void 0).map((j4) => j4.path)
5034
5259
  );
5035
5260
  report.backups = collectRunBackups(projectDir, startedAt, backupsAtStart).map(
5036
- (b2) => existsSync19(join28(projectDir, b2.path)) ? b2 : { ...b2, removed: true }
5261
+ (b2) => existsSync19(join29(projectDir, b2.path)) ? b2 : { ...b2, removed: true }
5037
5262
  );
5038
5263
  const noChecksum = report.backups.map((b2) => b2.path).filter((p2) => unmeasured.has(p2));
5039
5264
  if (noChecksum.length > 0) report.noChecksum = noChecksum;
@@ -5116,7 +5341,7 @@ function reclaimOutOfTrackRecorded(projectDir, outside) {
5116
5341
  function deadMcpLeft(projectDir) {
5117
5342
  let servers;
5118
5343
  try {
5119
- servers = JSON.parse(readFileSync20(join28(projectDir, ".mcp.json"), "utf8")).mcpServers;
5344
+ servers = JSON.parse(readFileSync21(join29(projectDir, ".mcp.json"), "utf8")).mcpServers;
5120
5345
  } catch {
5121
5346
  return [];
5122
5347
  }
@@ -5131,7 +5356,7 @@ function retiredFeaturesPart(projectDir, f) {
5131
5356
  }
5132
5357
  function legacyHookOnDisk(projectDir, rel) {
5133
5358
  try {
5134
- return hasLegacyHarnessHook(readFileSync20(join28(projectDir, rel), "utf8"));
5359
+ return hasLegacyHarnessHook(readFileSync21(join29(projectDir, rel), "utf8"));
5135
5360
  } catch {
5136
5361
  return false;
5137
5362
  }
@@ -5157,13 +5382,13 @@ function writeUpdateSharedFiles(args) {
5157
5382
  excluded: adapterExcluded(harnessRoot, excluded)
5158
5383
  });
5159
5384
  const tracks = installedTracks(projectDir);
5160
- const settingsSource = join28(templatesDir, "settings.json");
5385
+ const settingsSource = join29(templatesDir, "settings.json");
5161
5386
  if (args.claudeManaged && wants("hooks") && existsSync19(settingsSource)) {
5162
5387
  const spec = buildAssetSpec({ tracks, options: DEFAULT_OPTIONS });
5163
5388
  const manifest = buildManifest(spec);
5164
5389
  writeSettingsShared(
5165
5390
  writer,
5166
- readFileSync20(settingsSource, "utf8"),
5391
+ readFileSync21(settingsSource, "utf8"),
5167
5392
  projectDir,
5168
5393
  log,
5169
5394
  (script) => {
@@ -5232,8 +5457,8 @@ function catalogRemovedOnRecord(log) {
5232
5457
  }
5233
5458
  function staleSkillDirs(projectDir, claudeDir, clis) {
5234
5459
  const stale = (id) => RENAMED_SKILL_IDS[id] !== void 0 || RETIRED_SKILL_IDS.includes(id);
5235
- const dirs = [join28(claudeDir, "skills")];
5236
- if (clis.some((cli) => cli !== "claude")) dirs.push(join28(projectDir, ".agents", "skills"));
5460
+ const dirs = [join29(claudeDir, "skills")];
5461
+ if (clis.some((cli) => cli !== "claude")) dirs.push(join29(projectDir, ".agents", "skills"));
5237
5462
  const ids = /* @__PURE__ */ new Set();
5238
5463
  for (const dir of dirs) {
5239
5464
  if (!existsSync19(dir)) continue;
@@ -5244,13 +5469,13 @@ function staleSkillDirs(projectDir, claudeDir, clis) {
5244
5469
  return [...ids];
5245
5470
  }
5246
5471
  function staleAgentFiles(claudeDir) {
5247
- const dir = join28(claudeDir, "agents");
5472
+ const dir = join29(claudeDir, "agents");
5248
5473
  if (!existsSync19(dir)) return [];
5249
5474
  return readdirSync4(dir, { withFileTypes: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".md")).map((e2) => basename5(e2.name, ".md")).filter((id) => RETIRED_AGENT_IDS.includes(id));
5250
5475
  }
5251
5476
  function demotedAgentFiles(claudeDir, tracks) {
5252
5477
  if (tracks.length === 0) return [];
5253
- const dir = join28(claudeDir, "agents");
5478
+ const dir = join29(claudeDir, "agents");
5254
5479
  if (!existsSync19(dir)) return [];
5255
5480
  const demoted = TRACK_AGENTS.filter(([, pattern]) => !anyTrack(tracks, pattern)).map(
5256
5481
  ([id]) => id
@@ -5266,19 +5491,19 @@ function updateHarnessTargets(projectDir, templatesDir, log, wants, report, fore
5266
5491
  if (!wants(e2.target.startsWith(".claude/hooks/") ? "hooks" : "rules")) continue;
5267
5492
  if (e2.target.startsWith(".claude/") && !claude) continue;
5268
5493
  if (isBaselineExcluded(e2.target, excluded)) continue;
5269
- const source = join28(templatesDir, e2.source);
5494
+ const source = join29(templatesDir, e2.source);
5270
5495
  if (!existsSync19(source)) continue;
5271
5496
  const policy = POLICY_DIRS.find((d2) => e2.target.startsWith(`.claude/${d2.dir}/`));
5272
5497
  files.push({
5273
5498
  path: e2.target,
5274
5499
  source,
5275
5500
  unit: e2.target,
5276
- unitExisted: existsSync19(join28(projectDir, e2.target)),
5501
+ unitExisted: existsSync19(join29(projectDir, e2.target)),
5277
5502
  label: policy === void 0 ? e2.target : `.claude/${policy.dir}`
5278
5503
  });
5279
5504
  }
5280
5505
  const refreshedSkills = [];
5281
- const skillsSource = join28(templatesDir, "skills");
5506
+ const skillsSource = join29(templatesDir, "skills");
5282
5507
  if (!claude || !(wants("skills") || wants("new-skills")) || !existsSync19(skillsSource)) {
5283
5508
  return { files, refreshedSkills };
5284
5509
  }
@@ -5288,20 +5513,20 @@ function updateHarnessTargets(projectDir, templatesDir, log, wants, report, fore
5288
5513
  for (const d2 of readdirSync4(skillsSource, { withFileTypes: true })) {
5289
5514
  if (!d2.isDirectory()) continue;
5290
5515
  const unit = `.claude/skills/${d2.name}`;
5291
- if (occupiedByNonDirectory(join28(projectDir, unit))) {
5516
+ if (occupiedByNonDirectory(join29(projectDir, unit))) {
5292
5517
  report.skillsSkippedLinks.push(d2.name);
5293
5518
  continue;
5294
5519
  }
5295
5520
  if (!ids.has(d2.name) || excludedSkill(d2.name)) continue;
5296
- const existed = existsSync19(join28(projectDir, unit));
5521
+ const existed = existsSync19(join29(projectDir, unit));
5297
5522
  if (existed ? !wants("skills") : !wants("new-skills") || !creatable.has(d2.name)) continue;
5298
- for (const rel of listFilesRecursive(join28(skillsSource, d2.name))) {
5523
+ for (const rel of listFilesRecursive(join29(skillsSource, d2.name))) {
5299
5524
  const foreign = foreignOwnedTarget(projectDir, `${unit}/${rel}`);
5300
5525
  if (foreign !== null) {
5301
5526
  if (!foreignOwned.includes(foreign)) foreignOwned.push(foreign);
5302
5527
  continue;
5303
5528
  }
5304
- const source = join28(skillsSource, d2.name, rel);
5529
+ const source = join29(skillsSource, d2.name, rel);
5305
5530
  files.push({
5306
5531
  path: `${unit}/${rel}`,
5307
5532
  source,
@@ -5339,8 +5564,8 @@ function updateHarnessFiles(args) {
5339
5564
  report.updated[label] = 0;
5340
5565
  const ctx = { prefix: dir, outside, recordOf, projectDir, judged };
5341
5566
  report.pruned[label] = pruneOrphans(
5342
- join28(projectDir, label),
5343
- join28(templatesDir, dir),
5567
+ join29(projectDir, label),
5568
+ join29(templatesDir, dir),
5344
5569
  ext,
5345
5570
  ctx,
5346
5571
  now
@@ -5424,19 +5649,19 @@ function pruneSkillExtras(projectDir, templatesDir, ids, outside, recordOf, now,
5424
5649
  const backedUp = [];
5425
5650
  const failed = [];
5426
5651
  for (const id of ids) {
5427
- const targetSkill = join28(projectDir, ".claude/skills", id);
5428
- const bundled = new Set(listFilesRecursive(join28(templatesDir, "skills", id)));
5652
+ const targetSkill = join29(projectDir, ".claude/skills", id);
5653
+ const bundled = new Set(listFilesRecursive(join29(templatesDir, "skills", id)));
5429
5654
  for (const rel of listFilesRecursive(targetSkill)) {
5430
5655
  if (bundled.has(rel) || basename5(rel).includes(".backup-")) continue;
5431
5656
  if (foreignOwnedTarget(projectDir, `.claude/skills/${id}/${rel}`) !== null) continue;
5432
- const targetFile = join28(targetSkill, rel);
5657
+ const targetFile = join29(targetSkill, rel);
5433
5658
  if (outside.skip(targetFile)) continue;
5434
5659
  const path = `.claude/skills/${id}/${rel}`;
5435
5660
  const rec = recordOf(path);
5436
5661
  let line;
5437
5662
  let backupAbs = null;
5438
5663
  try {
5439
- const disk = rec.state === "sha" ? readFileSync20(targetFile, "utf8") : "";
5664
+ const disk = rec.state === "sha" ? readFileSync21(targetFile, "utf8") : "";
5440
5665
  line = rec.state === "none" ? NOT_RECORDED_REMOVED : judge({ op: "remove", kind: "harness", rec, disk, next: null }).line;
5441
5666
  if (rec.state !== "sha" || hashContent(disk) !== rec.sha256) {
5442
5667
  backupAbs = backupFile(targetFile, now);
@@ -5504,20 +5729,20 @@ function collectRunBackups(projectDir, startedAt, exclude) {
5504
5729
  const consider = (rel) => {
5505
5730
  if (!BACKUP_SUFFIX.test(rel)) return;
5506
5731
  if (exclude?.has(rel)) return;
5507
- const abs = join28(projectDir, rel);
5508
- if (lstatSync6(abs).mtimeMs < startedAt - 1e3) return;
5732
+ const abs = join29(projectDir, rel);
5733
+ if (lstatSync7(abs).mtimeMs < startedAt - 1e3) return;
5509
5734
  out.push({ path: rel.replace(BACKUP_SUFFIX, ""), backup: rel });
5510
5735
  };
5511
5736
  for (const e2 of withoutAppleDouble(readdirSync4(projectDir, { withFileTypes: true })))
5512
5737
  if (e2.isFile()) consider(e2.name);
5513
5738
  for (const dir of BACKUP_SCAN_DIRS) {
5514
- for (const { rel } of listEntriesRecursive(join28(projectDir, dir))) consider(`${dir}/${rel}`);
5739
+ for (const { rel } of listEntriesRecursive(join29(projectDir, dir))) consider(`${dir}/${rel}`);
5515
5740
  }
5516
5741
  return out.sort((a, b2) => a.path.localeCompare(b2.path));
5517
5742
  }
5518
5743
  function writeBackupList(projectDir, backups, noChecksum = /* @__PURE__ */ new Set()) {
5519
- const dir = join28(projectDir, ".uzys-agent-harness");
5520
- const file = join28(dir, "update-backups.json");
5744
+ const dir = join29(projectDir, ".uzys-agent-harness");
5745
+ const file = join29(dir, "update-backups.json");
5521
5746
  try {
5522
5747
  if (backups.length === 0) {
5523
5748
  if (existsSync19(file)) unlinkSync2(file);
@@ -5549,17 +5774,17 @@ function trackOnlyFileAssets(tracks) {
5549
5774
  );
5550
5775
  }
5551
5776
  function syncHarnessAnchor(projectDir, templatesDir, report, outside, judged, now = /* @__PURE__ */ new Date()) {
5552
- if (existsSync19(join28(projectDir, LEGACY_ANCHOR_FILE2))) {
5777
+ if (existsSync19(join29(projectDir, LEGACY_ANCHOR_FILE2))) {
5553
5778
  report.legacyAnchor = LEGACY_ANCHOR_FILE2;
5554
5779
  }
5555
- const templateMd = join28(templatesDir, "CLAUDE.md");
5780
+ const templateMd = join29(templatesDir, "CLAUDE.md");
5556
5781
  if (!existsSync19(templateMd)) return;
5557
- const anchor = join28(projectDir, HARNESS_ANCHOR_FILE);
5782
+ const anchor = join29(projectDir, HARNESS_ANCHOR_FILE);
5558
5783
  if (outside.skip(anchor)) return;
5559
5784
  const existed = existsSync19(anchor);
5560
5785
  if (existed) {
5561
- const current = readFileSync20(anchor, "utf8");
5562
- if (current !== readFileSync20(templateMd, "utf8")) {
5786
+ const current = readFileSync21(anchor, "utf8");
5787
+ if (current !== readFileSync21(templateMd, "utf8")) {
5563
5788
  const recorded2 = readInstallLog(projectDir)?.templates.rootClaudeMd;
5564
5789
  const owned = recorded2?.path === HARNESS_ANCHOR_FILE && hashContent(current) === recorded2.sha256;
5565
5790
  if (!owned) {
@@ -5567,7 +5792,7 @@ function syncHarnessAnchor(projectDir, templatesDir, report, outside, judged, no
5567
5792
  report.anchorBackedUp = true;
5568
5793
  const rel = relative6(projectDir, backup).split(sep7).join("/");
5569
5794
  const rec = recorded2?.path === HARNESS_ANCHOR_FILE ? { state: "sha", sha256: recorded2.sha256 } : { state: "no-sha" };
5570
- const next = readFileSync20(templateMd, "utf8");
5795
+ const next = readFileSync21(templateMd, "utf8");
5571
5796
  const { line } = judge({ op: "write", kind: "harness", rec, disk: current, next });
5572
5797
  judged.push({
5573
5798
  path: HARNESS_ANCHOR_FILE,
@@ -5592,15 +5817,15 @@ function syncHarnessAnchor(projectDir, templatesDir, report, outside, judged, no
5592
5817
  recordAnchorBaseline(projectDir, anchor);
5593
5818
  }
5594
5819
  function upsertRootImport(projectDir, outside) {
5595
- const target = join28(projectDir, "CLAUDE.md");
5820
+ const target = join29(projectDir, "CLAUDE.md");
5596
5821
  if (outside.skip(target)) return false;
5597
- const existing = existsSync19(target) ? readFileSync20(target, "utf8") : null;
5822
+ const existing = existsSync19(target) ? readFileSync21(target, "utf8") : null;
5598
5823
  const next = upsertHarnessImport(existing, {
5599
5824
  projectName: basename5(projectDir),
5600
5825
  // ADR-085 — update 는 선택 목록을 인자로 받지 않는다. 앞 단계(하네스 파일 쓰기)가 지나간 디스크로 판정한다:
5601
5826
  // `.claude/skills/<id>` 가 있으면 그 스킬은 이 설치가 고른 것이다.
5602
5827
  continuousSkills: CONTINUOUS_SKILLS.map((s) => s.id).filter(
5603
- (id) => existsSync19(join28(projectDir, ".claude/skills", id))
5828
+ (id) => existsSync19(join29(projectDir, ".claude/skills", id))
5604
5829
  )
5605
5830
  });
5606
5831
  if (next === existing) return false;
@@ -5621,7 +5846,7 @@ function recordAnchorBaseline(projectDir, anchor) {
5621
5846
  ...log.templates,
5622
5847
  rootClaudeMd: {
5623
5848
  path: HARNESS_ANCHOR_FILE,
5624
- sha256: hashContent(readFileSync20(anchor, "utf8"))
5849
+ sha256: hashContent(readFileSync21(anchor, "utf8"))
5625
5850
  }
5626
5851
  }
5627
5852
  };
@@ -5635,7 +5860,7 @@ function excludedBaselineOnDisk(projectDir, log) {
5635
5860
  if (excluded.size === 0) return [];
5636
5861
  const spec = buildAssetSpec({ tracks: installedTracks(projectDir), options: DEFAULT_OPTIONS });
5637
5862
  return buildManifest(spec).filter(
5638
- (e2) => e2.applies(spec) && isBaselineExcluded(e2.target, excluded) && existsSync19(join28(projectDir, e2.target))
5863
+ (e2) => e2.applies(spec) && isBaselineExcluded(e2.target, excluded) && existsSync19(join29(projectDir, e2.target))
5639
5864
  ).map((e2) => e2.target);
5640
5865
  }
5641
5866
  function excludedSkillOf(log) {
@@ -5663,7 +5888,7 @@ function recordedRenderInputs(projectDir, log, tracks = installedTracks(projectD
5663
5888
  function recordedBundledSkills(projectDir, log) {
5664
5889
  if (log === null) {
5665
5890
  return INTERNAL_BUNDLED_SKILL_IDS.filter(
5666
- (id) => existsSync19(join28(projectDir, ".claude/skills", id)) || existsSync19(join28(projectDir, ".agents/skills", id))
5891
+ (id) => existsSync19(join29(projectDir, ".claude/skills", id)) || existsSync19(join29(projectDir, ".agents/skills", id))
5667
5892
  );
5668
5893
  }
5669
5894
  const ids = recordedSkillIds(projectDir, log);
@@ -5714,9 +5939,9 @@ var SHARED_SKILLS_DIR = ".agents/skills";
5714
5939
  var SHARED_SKILL_FILE = /^\.agents\/skills\/([^/]+)\//;
5715
5940
  var SHARED_SKILL_MD = /^\.agents\/skills\/([^/]+)\/SKILL\.md$/;
5716
5941
  function sharedSkillIdsOnDisk(projectDir) {
5717
- const root = join28(projectDir, SHARED_SKILLS_DIR);
5942
+ const root = join29(projectDir, SHARED_SKILLS_DIR);
5718
5943
  if (!existsSync19(root)) return /* @__PURE__ */ new Set();
5719
- return new Set(readdirSync4(root).filter((id) => existsSync19(join28(root, id, "SKILL.md"))));
5944
+ return new Set(readdirSync4(root).filter((id) => existsSync19(join29(root, id, "SKILL.md"))));
5720
5945
  }
5721
5946
  var CREATED_SHARED_HOW = {
5722
5947
  "opencode.json": "created from template (harness part + template defaults)",
@@ -5743,14 +5968,14 @@ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, li
5743
5968
  const log = readInstallLog(projectDir);
5744
5969
  const presentBefore = sharedSkillIdsOnDisk(projectDir);
5745
5970
  const rulesBefore = /* @__PURE__ */ new Set();
5746
- const rulesDir = join28(projectDir, ".agents", "rules");
5971
+ const rulesDir = join29(projectDir, ".agents", "rules");
5747
5972
  if (existsSync19(rulesDir)) {
5748
5973
  try {
5749
5974
  for (const f of readdirSync4(rulesDir)) rulesBefore.add(f);
5750
5975
  } catch {
5751
5976
  }
5752
5977
  }
5753
- const agentsMdBefore = existsSync19(join28(projectDir, "AGENTS.md"));
5978
+ const agentsMdBefore = existsSync19(join29(projectDir, "AGENTS.md"));
5754
5979
  const result = runCliTransforms({
5755
5980
  harnessRoot,
5756
5981
  projectDir,
@@ -5927,12 +6152,12 @@ function pruneOrphans(target, source, ext, ctx, now) {
5927
6152
  if (!existsSync19(target) || !existsSync19(source)) return [];
5928
6153
  const removed = [];
5929
6154
  for (const file of readdirSync4(target)) {
5930
- if (!file.endsWith(ext) || existsSync19(join28(source, file))) continue;
5931
- const targetFile = join28(target, file);
6155
+ if (!file.endsWith(ext) || existsSync19(join29(source, file))) continue;
6156
+ const targetFile = join29(target, file);
5932
6157
  const path = `.claude/${ctx.prefix}/${file}`;
5933
6158
  const rec = ctx.recordOf(path);
5934
6159
  try {
5935
- const disk = readFileSync20(targetFile, "utf8");
6160
+ const disk = readFileSync21(targetFile, "utf8");
5936
6161
  const { verdict, line } = judge({ op: "remove", kind: "harness", rec, disk, next: null });
5937
6162
  if (verdict === "leave" || ctx.outside.skip(targetFile)) continue;
5938
6163
  if (!inHarnessSlot(ctx.projectDir, path, HARNESS_FILES, { follow: true })) continue;
@@ -5954,7 +6179,7 @@ function pruneOrphans(target, source, ext, ctx, now) {
5954
6179
  return removed;
5955
6180
  }
5956
6181
  function retireMcpAllowlist(projectDir, now = /* @__PURE__ */ new Date()) {
5957
- const target = join28(projectDir, ".mcp-allowlist");
6182
+ const target = join29(projectDir, ".mcp-allowlist");
5958
6183
  if (!existsSync19(target)) return null;
5959
6184
  try {
5960
6185
  const backup = backupFile(target, now);
@@ -5976,11 +6201,11 @@ function recordClaudeCommand(log, tracks) {
5976
6201
  function runInstall(ctx) {
5977
6202
  const { harnessRoot, projectDir } = ctx;
5978
6203
  const mode = ctx.mode ?? "fresh";
5979
- const templatesDir = join29(harnessRoot, "templates");
6204
+ const templatesDir = join30(harnessRoot, "templates");
5980
6205
  if (!existsSync20(templatesDir)) {
5981
6206
  throw new Error(`Templates dir not found: ${templatesDir}`);
5982
6207
  }
5983
- const claudeDir = join29(projectDir, ".claude");
6208
+ const claudeDir = join30(projectDir, ".claude");
5984
6209
  const previousLog = readInstallLog(projectDir);
5985
6210
  const legacyAnchor = mode === "update" ? null : legacyAnchorTrace(projectDir, ctx.spec);
5986
6211
  if (mode === "update" && previousLog === null) {
@@ -6005,10 +6230,10 @@ function runInstall(ctx) {
6005
6230
  const manifestSpec = buildManifestSpec(spec);
6006
6231
  const baselineExcluded = new Set(spec.baselineExclude ?? []);
6007
6232
  if (spec.cli.includes("claude")) {
6008
- const settingsPath = join29(projectDir, ".claude", "settings.json");
6233
+ const settingsPath = join30(projectDir, ".claude", "settings.json");
6009
6234
  if (existsSync20(settingsPath)) {
6010
6235
  try {
6011
- JSON.parse(readFileSync21(settingsPath, "utf8"));
6236
+ JSON.parse(readFileSync22(settingsPath, "utf8"));
6012
6237
  } catch {
6013
6238
  throw new Error(
6014
6239
  `${relative7(process.cwd(), settingsPath)} is not valid JSON \u2014 left untouched, so no hooks were wired. Fix or delete that file, then run the install again`
@@ -6194,6 +6419,7 @@ function runInstallStages(ctx, args) {
6194
6419
  legacyRestored: legacyRestored(previousLog, ledger.shared, cliSharedFiles),
6195
6420
  pendingKeyExcludes: pendingKeyExcludes(projectDir, spec.keyExclude ?? [], ledger.portionPaths),
6196
6421
  ...legacyAnchor ? { legacyAnchor } : {},
6422
+ ...agentsMdImportField(projectDir, [...spec.cli, ...installedClis(previousLog)]),
6197
6423
  releasedThisRun: releasedThisRun({
6198
6424
  projectDir,
6199
6425
  spec,
@@ -6255,6 +6481,20 @@ function runInstallStages(ctx, args) {
6255
6481
  external
6256
6482
  };
6257
6483
  }
6484
+ function agentsMdImportField(projectDir, clis) {
6485
+ if (!clis.includes("claude") || !clis.some(isAgentsMdCli)) return {};
6486
+ const read = (name) => {
6487
+ try {
6488
+ return readFileSync22(join30(projectDir, name), "utf8");
6489
+ } catch {
6490
+ return null;
6491
+ }
6492
+ };
6493
+ const root = read("CLAUDE.md");
6494
+ const agents = read("AGENTS.md");
6495
+ if (root === null || agents === null || !importsAgentsMd(root)) return {};
6496
+ return { agentsMdImport: { bytes: Buffer.byteLength(agents, "utf8") } };
6497
+ }
6258
6498
  function legacyAnchorTrace(projectDir, spec) {
6259
6499
  if (!spec.cli.includes("claude")) return null;
6260
6500
  const { state, traces } = detectInstallState(projectDir);
@@ -6290,7 +6530,11 @@ function runUpdateInstall(ctx, templatesDir) {
6290
6530
  gitignoreEnvAdded: false,
6291
6531
  gitignoreNpxSkillsAdded: []
6292
6532
  },
6293
- rootClaudeMd: null
6533
+ rootClaudeMd: null,
6534
+ ...agentsMdImportField(ctx.projectDir, [
6535
+ ...ctx.spec.cli,
6536
+ ...installedClis(readInstallLog(ctx.projectDir))
6537
+ ])
6294
6538
  };
6295
6539
  ctx.onProgress?.({ type: "baseline-complete", baseline });
6296
6540
  return { ...baseline, external: null };
@@ -6305,7 +6549,7 @@ function releasedThisRun(args) {
6305
6549
  }
6306
6550
  if (id.startsWith(BASELINE_PREFIX)) {
6307
6551
  const again2 = manifest.some(
6308
- (e2) => e2.applies(manifestSpec) && classifyBaselineTarget(e2.target)?.id === id && existsSync20(join29(projectDir, e2.target))
6552
+ (e2) => e2.applies(manifestSpec) && classifyBaselineTarget(e2.target)?.id === id && existsSync20(join30(projectDir, e2.target))
6309
6553
  );
6310
6554
  return { id, again: again2, tail: "the harness manages it again" };
6311
6555
  }
@@ -6314,7 +6558,7 @@ function releasedThisRun(args) {
6314
6558
  options: spec.options,
6315
6559
  ...spec.userOverride ? { userOverride: spec.userOverride } : {}
6316
6560
  });
6317
- const recorded2 = (previousLog?.assets.some((a) => a.id === id) ?? false) || [".claude/skills", ".agents/skills"].some((d2) => existsSync20(join29(projectDir, d2, id)));
6561
+ const recorded2 = (previousLog?.assets.some((a) => a.id === id) ?? false) || [".claude/skills", ".agents/skills"].some((d2) => existsSync20(join30(projectDir, d2, id)));
6318
6562
  return {
6319
6563
  id,
6320
6564
  again,
@@ -6326,10 +6570,10 @@ function pendingKeyExcludes(projectDir, keyExclude, touched) {
6326
6570
  const done = new Set(touched);
6327
6571
  return keyExclude.flatMap((id) => {
6328
6572
  const path = sharedPathOfKeyId(id);
6329
- if (path === null || done.has(path) || !existsSync20(join29(projectDir, path))) return [];
6573
+ if (path === null || done.has(path) || !existsSync20(join30(projectDir, path))) return [];
6330
6574
  const name = adapterFor(path);
6331
6575
  const keys = [...excludedKeys(path, [id])];
6332
- const present = name === null ? null : ADAPTERS[name].read(readFileSync21(join29(projectDir, path), "utf8"), keys, projectDir);
6576
+ const present = name === null ? null : ADAPTERS[name].read(readFileSync22(join30(projectDir, path), "utf8"), keys, projectDir);
6333
6577
  return present !== null && present.size === 0 ? [] : [{ id, path }];
6334
6578
  });
6335
6579
  }
@@ -6373,7 +6617,7 @@ function installCliNeutralAssets(manifestSpec, templatesDir, baselineExcluded, w
6373
6617
  continue;
6374
6618
  }
6375
6619
  if (!isCliNeutralTarget(entry.target)) continue;
6376
- const source = join29(templatesDir, entry.source);
6620
+ const source = join30(templatesDir, entry.source);
6377
6621
  if (!existsSync20(source)) {
6378
6622
  result.skipped += 1;
6379
6623
  continue;
@@ -6394,13 +6638,13 @@ function installClaudeBaseline(manifestSpec, projectDir, templatesDir, baselineE
6394
6638
  if (!entry.applies(manifestSpec)) {
6395
6639
  continue;
6396
6640
  }
6397
- const target = join29(projectDir, entry.target);
6641
+ const target = join30(projectDir, entry.target);
6398
6642
  if (isBaselineExcluded(entry.target, baselineExcluded)) {
6399
6643
  result.excluded.push(entry.target);
6400
6644
  if (existsSync20(target)) result.excludedOnDisk.push(entry.target);
6401
6645
  continue;
6402
6646
  }
6403
- const source = join29(templatesDir, entry.source);
6647
+ const source = join30(templatesDir, entry.source);
6404
6648
  if (!existsSync20(source)) {
6405
6649
  result.skipped += 1;
6406
6650
  continue;
@@ -6431,18 +6675,18 @@ function installClaudeBaseline(manifestSpec, projectDir, templatesDir, baselineE
6431
6675
  if (!result.foreignOwned.includes(slot)) result.foreignOwned.push(slot);
6432
6676
  continue;
6433
6677
  }
6434
- if (writer.skipOutside(join29(projectDir, entry.target, rel))) {
6678
+ if (writer.skipOutside(join30(projectDir, entry.target, rel))) {
6435
6679
  leftOutside += 1;
6436
6680
  continue;
6437
6681
  }
6438
- writer.harness(`${entry.target}/${rel}`, { source: join29(source, rel) });
6682
+ writer.harness(`${entry.target}/${rel}`, { source: join30(source, rel) });
6439
6683
  }
6440
6684
  if (leftOutside > 0) continue;
6441
6685
  result.dirsCopied += 1;
6442
6686
  }
6443
6687
  accumulateCategory(result.categories, entry);
6444
6688
  }
6445
- const hookDir = join29(projectDir, ".claude/hooks");
6689
+ const hookDir = join30(projectDir, ".claude/hooks");
6446
6690
  if (existsSync20(hookDir)) {
6447
6691
  chmodHooksSync(hookDir, projectDir);
6448
6692
  }
@@ -6464,8 +6708,8 @@ function installClaudeBaseline(manifestSpec, projectDir, templatesDir, baselineE
6464
6708
  });
6465
6709
  result.keptHookRefs.push(
6466
6710
  ...findStaleHookRefs(
6467
- join29(projectDir, ".claude", "settings.json"),
6468
- join29(projectDir, ".claude")
6711
+ join30(projectDir, ".claude", "settings.json"),
6712
+ join30(projectDir, ".claude")
6469
6713
  )
6470
6714
  );
6471
6715
  }
@@ -6474,7 +6718,7 @@ function installClaudeBaseline(manifestSpec, projectDir, templatesDir, baselineE
6474
6718
  // ADR-085 · update(`upsertRootImport`)와 같은 판정 — 실제로 깔린 스킬만 안내한다. 밖 링크라 쓰지 않은
6475
6719
  // 스킬(ADR-098)을 "installed" 라 적으면 다음 update 가 그 절을 걷어 내 두 동작이 서로 반대로 쓴다.
6476
6720
  (manifestSpec.selectedInternalSkills ?? []).filter(
6477
- (id) => existsSync20(join29(projectDir, ".claude", "skills", id))
6721
+ (id) => existsSync20(join30(projectDir, ".claude", "skills", id))
6478
6722
  ),
6479
6723
  harnessRoot,
6480
6724
  writer
@@ -6490,7 +6734,7 @@ function installClaudeBaseline(manifestSpec, projectDir, templatesDir, baselineE
6490
6734
  function writeSettingsPortion(writer, source, projectDir, previousLog, hookInstalled) {
6491
6735
  return writeSettingsShared(
6492
6736
  writer,
6493
- readFileSync21(source, "utf8"),
6737
+ readFileSync22(source, "utf8"),
6494
6738
  projectDir,
6495
6739
  previousLog,
6496
6740
  hookInstalled
@@ -6543,6 +6787,7 @@ function runExternalPhase(ctx, previousLog) {
6543
6787
  const slotCtx = { log: previousLog, scope: spec.scope };
6544
6788
  const settle = holdSkillSlots(projectDir, {
6545
6789
  recorded: (previousLog?.assets ?? []).filter((a) => a.method === "skill" && skillIds.has(a.id)),
6790
+ assets: skills,
6546
6791
  slots: skillSlotsFor(skills, spec.cli, slotCtx),
6547
6792
  // #902 — 옛 판이 파일 목록 없이 깐 자산의 자리 — 그 안 파일은 되살리지 않고 백업만 남긴다
6548
6793
  unlisted: unlistedSkillSlots(skills, spec.cli, slotCtx),
@@ -6564,7 +6809,7 @@ function runExternalPhase(ctx, previousLog) {
6564
6809
  throw e2;
6565
6810
  }
6566
6811
  const { report: external, backups, displaced } = settle(ran);
6567
- const displacedBackups = new Set(displaced.map((f) => join29(projectDir, f.notes[0] ?? "")));
6812
+ const displacedBackups = new Set(displaced.map((f) => join30(projectDir, f.notes[0] ?? "")));
6568
6813
  const editBackups = backups.filter((b2) => !displacedBackups.has(b2));
6569
6814
  ctx.onProgress?.({
6570
6815
  type: "external-complete",
@@ -6777,9 +7022,9 @@ function accumulateCategory(cats, entry) {
6777
7022
  }
6778
7023
  }
6779
7024
  function writeRootClaudeMd(projectDir, continuousSkills, harnessRoot, writer) {
6780
- const target = join29(projectDir, "CLAUDE.md");
7025
+ const target = join30(projectDir, "CLAUDE.md");
6781
7026
  if (writer.skipOutside(target)) return null;
6782
- const existing = existsSync20(target) ? readFileSync21(target, "utf-8") : null;
7027
+ const existing = existsSync20(target) ? readFileSync22(target, "utf-8") : null;
6783
7028
  const seeded = existing === null ? seedRootClaudeProjectContext(projectDir, harnessRoot) : null;
6784
7029
  const content = upsertHarnessImport(existing, {
6785
7030
  projectName: basename6(projectDir),
@@ -6811,8 +7056,8 @@ function listHookFiles(hookDir) {
6811
7056
 
6812
7057
  // src/commands/install-render.ts
6813
7058
  init_esm_shims();
6814
- import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync23 } from "fs";
6815
- import { join as join31, relative as relative8 } from "path";
7059
+ import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "fs";
7060
+ import { join as join32, relative as relative8 } from "path";
6816
7061
 
6817
7062
  // src/preset-recommend.ts
6818
7063
  init_esm_shims();
@@ -6867,10 +7112,10 @@ function groupAssetsByCategory(assetIds) {
6867
7112
 
6868
7113
  // src/resident-entries.ts
6869
7114
  init_esm_shims();
6870
- import { existsSync as existsSync21, readFileSync as readFileSync22 } from "fs";
6871
- import { basename as basename7, join as join30 } from "path";
7115
+ import { existsSync as existsSync21, readFileSync as readFileSync23 } from "fs";
7116
+ import { basename as basename7, join as join31 } from "path";
6872
7117
  function residentEntries(spec) {
6873
- const skillThere = (id) => INTERNAL_BUNDLED_SKILL_IDS.includes(id) && [".claude/skills", ".agents/skills"].some((d2) => existsSync21(join30(spec.projectDir, d2, id)));
7118
+ const skillThere = (id) => INTERNAL_BUNDLED_SKILL_IDS.includes(id) && [".claude/skills", ".agents/skills"].some((d2) => existsSync21(join31(spec.projectDir, d2, id)));
6874
7119
  const forceExclude = (spec.userOverride?.forceExclude ?? []).filter((id) => !skillThere(id));
6875
7120
  const assetSpec = buildManifestSpec(
6876
7121
  spec.userOverride ? { ...spec, userOverride: { ...spec.userOverride, forceExclude } } : spec
@@ -6896,7 +7141,7 @@ function residentEntries(spec) {
6896
7141
  function residentCostFor(spec, entries = residentEntries(spec), contextFiles) {
6897
7142
  if (contextFiles !== void 0) return residentCost(entries, void 0, spec.cli, contextFiles);
6898
7143
  const cost = residentCost(entries, void 0, spec.cli, plannedClaudeContext(spec));
6899
- if (anchorSurface(spec.cli).scaffold === "agents-md" && existsSync21(join30(spec.projectDir, "AGENTS.md"))) {
7144
+ if (anchorSurface(spec.cli).scaffold === "agents-md" && existsSync21(join31(spec.projectDir, "AGENTS.md"))) {
6900
7145
  return makeResidentCost({
6901
7146
  ...cost,
6902
7147
  contextNote: "planned, not counting text already in AGENTS.md"
@@ -6907,8 +7152,8 @@ function residentCostFor(spec, entries = residentEntries(spec), contextFiles) {
6907
7152
  function plannedClaudeContext(spec) {
6908
7153
  if (!spec.cli.includes("claude")) return void 0;
6909
7154
  const root = resolveBundleRoot();
6910
- const rootClaude = join30(spec.projectDir, "CLAUDE.md");
6911
- const existing = existsSync21(rootClaude) ? readFileSync22(rootClaude, "utf-8") : null;
7155
+ const rootClaude = join31(spec.projectDir, "CLAUDE.md");
7156
+ const existing = existsSync21(rootClaude) ? readFileSync23(rootClaude, "utf-8") : null;
6912
7157
  const seeded = existing === null ? seedRootClaudeProjectContext(spec.projectDir, root) : null;
6913
7158
  if (existing === null && seeded === null) return void 0;
6914
7159
  const manifestSpec = buildManifestSpec(spec);
@@ -6917,14 +7162,14 @@ function plannedClaudeContext(spec) {
6917
7162
  continuousSkills: manifestSpec.selectedInternalSkills ?? [],
6918
7163
  ...seeded === null ? {} : { projectContext: seeded }
6919
7164
  });
6920
- return [join30(root, "templates", "CLAUDE.md"), { text }];
7165
+ return [join31(root, "templates", "CLAUDE.md"), { text }];
6921
7166
  }
6922
7167
  function onDiskTargets(spec, assetSpec) {
6923
7168
  const out = /* @__PURE__ */ new Set();
6924
7169
  for (const e2 of buildManifest(assetSpec)) {
6925
7170
  if (!e2.applies(assetSpec)) continue;
6926
7171
  const t = classifyBaselineTarget(e2.target);
6927
- if (t !== null && existsSync21(join30(spec.projectDir, e2.target))) out.add(t.id);
7172
+ if (t !== null && existsSync21(join31(spec.projectDir, e2.target))) out.add(t.id);
6928
7173
  }
6929
7174
  return out;
6930
7175
  }
@@ -6932,6 +7177,16 @@ function onDiskTargets(spec, assetSpec) {
6932
7177
  // src/commands/install-render.ts
6933
7178
  var CLI_SUMMARY_LABELS = CLI_DISPLAY_NAMES;
6934
7179
  var LEGACY_ANCHOR_NOTE = `legacy anchor \xB7 no longer updated \u2014 content now in ${HARNESS_ANCHOR_FILE}; delete it when you no longer need it`;
7180
+ function agentsMdImportRow(hit, labelWidth) {
7181
+ if (hit === void 0) return null;
7182
+ const kb = Math.round(hit.bytes / 1024);
7183
+ return assetRow(
7184
+ "skip",
7185
+ "CLAUDE.md (root)",
7186
+ `imports @AGENTS.md \u2014 Claude Code reads the harness principles \xB7 rules twice \u2014 AGENTS.md (${kb} KB) carries them again, and it already gets them via ${HARNESS_ANCHOR_FILE} and .claude/rules/. Left as is \u2014 drop the import unless you need AGENTS.md's own sections`,
7187
+ labelWidth
7188
+ );
7189
+ }
6935
7190
  function renderInstallHeader(log, spec, mode) {
6936
7191
  const headerLabel = mode === "update" ? "uzys-agent-harness \xB7 update" : mode === "add" ? "uzys-agent-harness \xB7 add" : mode === "reinstall" ? "uzys-agent-harness \xB7 reinstall" : "uzys-agent-harness \xB7 install";
6937
7192
  log("");
@@ -7053,7 +7308,7 @@ function createInstallRenderer(log, spec, verbose) {
7053
7308
  },
7054
7309
  onAssetResult: (result) => {
7055
7310
  const base = result.ok ? formatAssetMeta(result.asset, result.version) : result.message ?? "failed";
7056
- const outsideNote = result.ok && result.outside?.length ? ` \xB7 ${result.outside.map((o) => `${o.root}/ left as is (links outside the project: ${o.target})`).join(" \xB7 ")}` : "";
7311
+ const outsideNote = result.ok && result.outside?.length ? ` \xB7 ${result.outside.map(outsideSlotNote).join(" \xB7 ")}` : "";
7057
7312
  const meta = `${base}${outsideNote}`;
7058
7313
  log(` ${assetRow(result.ok ? "success" : "skip", result.asset.id, meta)}`);
7059
7314
  }
@@ -7111,23 +7366,23 @@ function residentEntriesOnDisk(spec) {
7111
7366
  const hasClaude = spec.cli.includes("claude");
7112
7367
  const surface = anchorSurface(spec.cli).scaffold;
7113
7368
  const mdFiles = (dir, kind, skip) => {
7114
- const abs = join31(spec.projectDir, dir);
7369
+ const abs = join32(spec.projectDir, dir);
7115
7370
  return existsSync22(abs) ? readdirSync6(abs, { withFileTypes: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".md") && e2.name !== skip).map((e2) => ({
7116
7371
  source: `${kind}/${e2.name}`,
7117
7372
  // `target` 은 `residentCost` 의 분류 키다 — 실제 자리는 `file` 이 말한다.
7118
7373
  target: `.claude/${kind}/${e2.name}`,
7119
7374
  // 배포판이 아니라 **이 프로젝트의 파일**을 잰다 — 사용자가 고친 본문도,
7120
7375
  // 배포판에 더는 없는 파일도 실제로 상주하는 것은 이쪽이다.
7121
- file: join31(abs, e2.name)
7376
+ file: join32(abs, e2.name)
7122
7377
  })) : [];
7123
7378
  };
7124
- const rules = surface === "claude" ? mdFiles(join31(".claude", "rules"), "rules") : rulesInline(spec.cli) ? planned.filter((e2) => e2.target.startsWith(".claude/rules/")) : mdFiles(join31(".agents", "rules"), "rules", "uzys-harness.md");
7125
- const slot = hasClaude ? join31(".claude", "skills") : join31(".agents", "skills");
7379
+ const rules = surface === "claude" ? mdFiles(join32(".claude", "rules"), "rules") : rulesInline(spec.cli) ? planned.filter((e2) => e2.target.startsWith(".claude/rules/")) : mdFiles(join32(".agents", "rules"), "rules", "uzys-harness.md");
7380
+ const slot = hasClaude ? join32(".claude", "skills") : join32(".agents", "skills");
7126
7381
  const skills = planned.filter((e2) => e2.target.startsWith(".claude/skills/")).map((e2) => ({
7127
7382
  ...e2,
7128
- file: join31(spec.projectDir, slot, e2.target.slice(".claude/skills/".length))
7383
+ file: join32(spec.projectDir, slot, e2.target.slice(".claude/skills/".length))
7129
7384
  })).filter((e2) => existsSync22(e2.file));
7130
- const agents = hasClaude ? mdFiles(join31(".claude", "agents"), "agents") : [];
7385
+ const agents = hasClaude ? mdFiles(join32(".claude", "agents"), "agents") : [];
7131
7386
  return [
7132
7387
  ...planned.filter(
7133
7388
  (e2) => !e2.target.startsWith(".claude/rules/") && !e2.target.startsWith(".claude/agents/") && !e2.target.startsWith(".claude/skills/")
@@ -7139,8 +7394,8 @@ function residentEntriesOnDisk(spec) {
7139
7394
  }
7140
7395
  function contextFilesOnDisk(spec) {
7141
7396
  const surface = anchorSurface(spec.cli).scaffold;
7142
- const files = surface === "claude" ? [HARNESS_ANCHOR_FILE, "CLAUDE.md", join31(".claude", "CLAUDE.md")] : ["AGENTS.md"];
7143
- return files.map((f) => join31(spec.projectDir, f));
7397
+ const files = surface === "claude" ? [HARNESS_ANCHOR_FILE, "CLAUDE.md", join32(".claude", "CLAUDE.md")] : ["AGENTS.md"];
7398
+ return files.map((f) => join32(spec.projectDir, f));
7144
7399
  }
7145
7400
  function rulesInsideAgentsMd(spec, cost) {
7146
7401
  if (anchorSurface(spec.cli).scaffold !== "agents-md" || !rulesInline(spec.cli)) return cost;
@@ -7407,7 +7662,7 @@ function renderFinalSummary(log, spec, report, fromWizard) {
7407
7662
  const alreadyTrustedGlobally = (() => {
7408
7663
  try {
7409
7664
  if (!existsSync22(configPath)) return false;
7410
- return hasTrustEntry(readFileSync23(configPath, "utf8"), spec.projectDir);
7665
+ return hasTrustEntry(readFileSync24(configPath, "utf8"), spec.projectDir);
7411
7666
  } catch {
7412
7667
  return false;
7413
7668
  }
@@ -7432,7 +7687,7 @@ function renderFinalSummary(log, spec, report, fromWizard) {
7432
7687
  const remote = (report.shared ?? []).find((f) => f.path === ".mcp.json")?.remote ?? [];
7433
7688
  for (const line of remoteMcpNextLines(remote, spec.cli)) log(`${" ".repeat(16)} ${line}`);
7434
7689
  const scaffoldFiles = scaffoldFilesForCli(spec.cli).filter(
7435
- (f) => f === "CLAUDE.md" && report.rootClaudeMd?.created === true || hasFillPrompt(join31(spec.projectDir, f))
7690
+ (f) => f === "CLAUDE.md" && report.rootClaudeMd?.created === true || hasFillPrompt(join32(spec.projectDir, f))
7436
7691
  );
7437
7692
  if (scaffoldFiles.length > 0) {
7438
7693
  const auditInstalled = buildManifestSpec(spec).selectedInternalSkills?.includes("audit-harness-fit");
@@ -7448,7 +7703,7 @@ function renderFinalSummary(log, spec, report, fromWizard) {
7448
7703
  }
7449
7704
  function hasFillPrompt(path) {
7450
7705
  try {
7451
- return readFileSync23(path, "utf8").includes("<!-- FILL:");
7706
+ return readFileSync24(path, "utf8").includes("<!-- FILL:");
7452
7707
  } catch {
7453
7708
  return false;
7454
7709
  }
@@ -7618,6 +7873,8 @@ function renderPhase1Rows(log, baseline, verbose = false) {
7618
7873
  if (baseline.updateMode.legacyAnchor) {
7619
7874
  log(assetRow("skip", baseline.updateMode.legacyAnchor, LEGACY_ANCHOR_NOTE));
7620
7875
  }
7876
+ const agentsImport2 = agentsMdImportRow(baseline.agentsMdImport);
7877
+ if (agentsImport2 !== null) log(agentsImport2);
7621
7878
  linkedSkillRows(
7622
7879
  log,
7623
7880
  baseline.updateMode.skillsLinked ?? [],
@@ -7749,6 +8006,7 @@ function renderPhase1Rows(log, baseline, verbose = false) {
7749
8006
  )
7750
8007
  );
7751
8008
  }
8009
+ for (const row of leftAsIsRows(baseline.updateMode.externalSkillsLeftAsIs ?? [])) log(row);
7752
8010
  if (baseline.updateMode.externalSkillsFailed.length > 0) {
7753
8011
  const failed = baseline.updateMode.externalSkillsFailed;
7754
8012
  const head = failed[0];
@@ -7893,6 +8151,8 @@ function renderPhase1Rows(log, baseline, verbose = false) {
7893
8151
  if (baseline.legacyAnchor) {
7894
8152
  log(assetRow("skip", baseline.legacyAnchor, LEGACY_ANCHOR_NOTE, TEMPLATES_COL));
7895
8153
  }
8154
+ const agentsImport = agentsMdImportRow(baseline.agentsMdImport, TEMPLATES_COL);
8155
+ if (agentsImport !== null) log(agentsImport);
7896
8156
  if (baseline.ciScaffold) {
7897
8157
  for (const f of baseline.ciScaffold.written) {
7898
8158
  log(assetRow("success", f, "CI scaffold (fill-in template)", TEMPLATES_COL));
@@ -8082,6 +8342,11 @@ function excludedKeyParts(f) {
8082
8342
  }
8083
8343
  return parts;
8084
8344
  }
8345
+ function leftAsIsRows(items) {
8346
+ return items.map(
8347
+ ({ id, outside }) => assetRow("skip", "external skills", `${id}: ${outside.map(outsideSlotNote).join(" \xB7 ")}`)
8348
+ );
8349
+ }
8085
8350
  function catalogRemovedRows(items) {
8086
8351
  return items.map((e2) => {
8087
8352
  const parts = [
@@ -8521,8 +8786,8 @@ function registerInstallCommand(cli) {
8521
8786
 
8522
8787
  // src/commands/list.ts
8523
8788
  init_esm_shims();
8524
- import { existsSync as existsSync23, readFileSync as readFileSync24 } from "fs";
8525
- import { join as join32, resolve as resolve3 } from "path";
8789
+ import { existsSync as existsSync23, readFileSync as readFileSync25 } from "fs";
8790
+ import { join as join33, resolve as resolve3 } from "path";
8526
8791
  function listAction(options = {}, deps = {}) {
8527
8792
  const log = deps.log ?? console.log;
8528
8793
  const err = deps.err ?? console.error;
@@ -8626,8 +8891,8 @@ function formatHarnessFileRows(log, projectDir) {
8626
8891
  const rows = [` ${c.dim(tops.length > 0 ? tops.join(" ") : "(none recorded)")}`];
8627
8892
  const rootMd = log.templates.rootClaudeMd;
8628
8893
  if (rootMd) {
8629
- const path = join32(projectDir, rootMd.path);
8630
- const modified = existsSync23(path) && hashContent(readFileSync24(path, "utf8")) !== rootMd.sha256;
8894
+ const path = join33(projectDir, rootMd.path);
8895
+ const modified = existsSync23(path) && hashContent(readFileSync25(path, "utf8")) !== rootMd.sha256;
8631
8896
  rows.push(
8632
8897
  modified ? ` ${c.dim(rootMd.path)} ${c.yellow("(\uC218\uC815\uB428 \u2014 uninstall \uC2DC \uBCF4\uC874)")}` : ` ${c.dim(rootMd.path)}`
8633
8898
  );
@@ -8641,7 +8906,7 @@ var ROOT_FILE_CHANGE = {
8641
8906
  displaced: "\uBE44\uCF1C \uB460"
8642
8907
  };
8643
8908
  function formatRootFileRows(rootFiles, projectDir) {
8644
- const present = rootFiles.filter((f) => existsSync23(join32(projectDir, f.path)));
8909
+ const present = rootFiles.filter((f) => existsSync23(join33(projectDir, f.path)));
8645
8910
  const width = Math.max(0, ...present.map((f) => f.path.length));
8646
8911
  return present.map(
8647
8912
  (f) => ` ${c.dim(padDisplay(f.path, width))} ${c.dim(ROOT_FILE_CHANGE[f.change])} ${c.dim(f.notes.join(" / "))}`
@@ -8662,9 +8927,9 @@ import {
8662
8927
  accessSync as accessSync2,
8663
8928
  existsSync as existsSync24,
8664
8929
  constants as fsConstants2,
8665
- lstatSync as lstatSync7,
8930
+ lstatSync as lstatSync8,
8666
8931
  readdirSync as readdirSync7,
8667
- readFileSync as readFileSync25,
8932
+ readFileSync as readFileSync26,
8668
8933
  readlinkSync as readlinkSync2,
8669
8934
  realpathSync as realpathSync4,
8670
8935
  rmdirSync as rmdirSync3,
@@ -8672,7 +8937,7 @@ import {
8672
8937
  statSync as statSync4,
8673
8938
  writeFileSync as writeFileSync8
8674
8939
  } from "fs";
8675
- import { dirname as dirname8, join as join33, relative as relative9, resolve as resolve4, sep as sep9 } from "path";
8940
+ import { dirname as dirname8, join as join34, relative as relative9, resolve as resolve4, sep as sep9 } from "path";
8676
8941
 
8677
8942
  // src/track-removal.ts
8678
8943
  init_esm_shims();
@@ -10119,7 +10384,7 @@ function hintFor(asset) {
10119
10384
  case "plugin":
10120
10385
  return "claude plugin uninstall --scope project";
10121
10386
  case "skill":
10122
- return asset.files === void 0 ? 'files not on record (older install) \u2014 nothing removed; only "Remove everything" clears it' : `removes the ${asset.files.length} file(s) on record`;
10387
+ return asset.files === void 0 ? 'files not on record (older install) \u2014 nothing removed; only "Remove everything" clears it' : asset.filesPartial === true ? `removes the ${asset.files.length} file(s) on record; files in other folders are not on record (older install) \u2014 left` : `removes the ${asset.files.length} file(s) on record`;
10123
10388
  case "npm":
10124
10389
  return "npm uninstall --save-dev";
10125
10390
  case "npx-run":
@@ -10381,10 +10646,10 @@ Proceed?`, initialValue: false });
10381
10646
  // src/commands/uninstall.ts
10382
10647
  var CODEX_CONFIG = ".codex/config.toml";
10383
10648
  function keptOutsideLinkLine(o, log) {
10384
- const head = ` ${c.yellow("\u2298")} ${o.link} \u2014 left as is: the link points outside the project (${o.link} \u2192 ${o.linkTarget}). Nothing behind it is removed`;
10649
+ const head = ` ${c.yellow("\u2298")} ${screenText(o.link)} \u2014 left as is: the link points outside the project (${screenText(o.link)} \u2192 ${screenText(o.linkTarget)}). Nothing behind it is removed`;
10385
10650
  const files = recordedUnder(log, o.link);
10386
10651
  if (files.length === 0) return `${head}; clean up harness files there by hand if intended.`;
10387
- const shown = files.slice(0, KEPT_LINK_FILES_SHOWN).join(" \xB7 ");
10652
+ const shown = files.slice(0, KEPT_LINK_FILES_SHOWN).map(screenText).join(" \xB7 ");
10388
10653
  const more = files.length > KEPT_LINK_FILES_SHOWN ? ` +${files.length - KEPT_LINK_FILES_SHOWN} more` : "";
10389
10654
  return `${head}; harness files there on record: ${shown}${more} \u2014 clean them up by hand if intended.`;
10390
10655
  }
@@ -10535,6 +10800,7 @@ function uninstallAction(options, deps = {}) {
10535
10800
  if (d2.verdict === "restore") journal.push(`put back ${d2.path}`);
10536
10801
  }
10537
10802
  for (const line of displacedLines(onlyDisplaced, false)) log(line);
10803
+ for (const line of byHandLines([], onlyDisplaced, projectDir, installLog)) log(line);
10538
10804
  } else {
10539
10805
  const done = removeHarnessFiles(installLog, projectDir, FULL_SCOPE, {
10540
10806
  rm: rmJ,
@@ -10611,7 +10877,7 @@ function unwritablePaths(ctx) {
10611
10877
  const project = ctx.targetAssets.filter((a) => a.scope === "project");
10612
10878
  if (project.some((a) => a.method === "npm")) need.add(".");
10613
10879
  const parentOf = (path) => {
10614
- const abs = join33(projectDir, path);
10880
+ const abs = join34(projectDir, path);
10615
10881
  if (!safeExists(abs)) return;
10616
10882
  const real = safeRealpath(abs);
10617
10883
  if (real !== null && isOutsideProject(projectDir, real)) return;
@@ -10623,7 +10889,7 @@ function unwritablePaths(ctx) {
10623
10889
  const recordedShared = new Set((installLog.portions ?? []).map((p2) => p2.path));
10624
10890
  const made = new Set((installLog.externalFiles ?? []).map((f) => f.path));
10625
10891
  for (const p2 of UNINSTALL_SHARED) {
10626
- if (recordedShared.has(p2) && existsSync24(join33(projectDir, p2))) need.add(p2);
10892
+ if (recordedShared.has(p2) && existsSync24(join34(projectDir, p2))) need.add(p2);
10627
10893
  if (made.has(p2)) parentOf(p2);
10628
10894
  }
10629
10895
  for (const p2 of harnessCandidates(installLog)) parentOf(p2);
@@ -10633,7 +10899,7 @@ function unwritablePaths(ctx) {
10633
10899
  }
10634
10900
  return [...need].filter((p2) => {
10635
10901
  try {
10636
- accessSync2(join33(projectDir, p2), fsConstants2.W_OK);
10902
+ accessSync2(join34(projectDir, p2), fsConstants2.W_OK);
10637
10903
  return false;
10638
10904
  } catch (e2) {
10639
10905
  return e2.code !== "ENOENT";
@@ -10642,7 +10908,7 @@ function unwritablePaths(ctx) {
10642
10908
  }
10643
10909
  function safeExists(abs) {
10644
10910
  try {
10645
- lstatSync7(abs);
10911
+ lstatSync8(abs);
10646
10912
  return true;
10647
10913
  } catch {
10648
10914
  return false;
@@ -10700,7 +10966,8 @@ function executeReverse(plan, log, logSurvives, journal) {
10700
10966
  failedIds.push(step.assetId);
10701
10967
  failed++;
10702
10968
  }
10703
- for (const note of result.notes ?? []) log(c.dim(` \u21B3 ${note}`));
10969
+ for (const note of [...result.notes ?? [], ...step.hints ?? []])
10970
+ log(c.dim(` \u21B3 ${note}`));
10704
10971
  }
10705
10972
  for (const line of noReverseLines(plan, logSurvives || failed > 0)) log(line);
10706
10973
  return { succeeded, failed, removedIds, failedIds };
@@ -10736,15 +11003,15 @@ function settleLog(ctx, io) {
10736
11003
  return true;
10737
11004
  }
10738
11005
  } else {
10739
- const recordDir = join33(projectDir, INSTALL_LOG_DIR);
11006
+ const recordDir = join34(projectDir, INSTALL_LOG_DIR);
10740
11007
  if (outsideLinkAt(projectDir, INSTALL_LOG_DIR) !== null) io.rm(recordDir);
10741
11008
  else {
10742
- for (const rel of RECORD_FILES) io.rm(join33(projectDir, rel));
11009
+ for (const rel of RECORD_FILES) io.rm(join34(projectDir, rel));
10743
11010
  pruneEmptyDirsUpward(projectDir, recordDir);
10744
11011
  }
10745
11012
  if (outsideLinkAt(projectDir, LEGACY_INSTALL_LOG_DIR) === null) {
10746
11013
  io.rm(legacyInstallLogPath(projectDir));
10747
- pruneEmptyDirsUpward(projectDir, join33(projectDir, LEGACY_INSTALL_LOG_DIR));
11014
+ pruneEmptyDirsUpward(projectDir, join34(projectDir, LEGACY_INSTALL_LOG_DIR));
10748
11015
  }
10749
11016
  io.log(` ${status.success("install log removed")}`);
10750
11017
  }
@@ -10760,7 +11027,7 @@ function afterFullRemoval(next, done) {
10760
11027
  if (back.size === 0) return next;
10761
11028
  const out = { ...next, rootFiles: withoutRestored(next.rootFiles, done.displaced) };
10762
11029
  const stays = (prefix) => (f) => !back.has(`${prefix}${f.path}`);
10763
- if (out.policyFiles !== void 0) out.policyFiles = out.policyFiles.filter(stays(CLAUDE_DIR3));
11030
+ if (out.policyFiles !== void 0) out.policyFiles = out.policyFiles.filter(stays(CLAUDE_DIR4));
10764
11031
  if (out.skillFiles !== void 0) out.skillFiles = out.skillFiles.filter(stays(SKILLS_DIR3));
10765
11032
  if (out.externalFiles !== void 0) out.externalFiles = out.externalFiles.filter(stays(""));
10766
11033
  const anchor = out.templates.rootClaudeMd;
@@ -10784,7 +11051,12 @@ function dryRunLines(plan, installLog, projectDir, assetsOnly, rootFiles, harnes
10784
11051
  if (plan.reverseSteps.length === 0 && copies.length === 0) {
10785
11052
  lines.push(c.dim(" (no project-scope assets to reverse)"));
10786
11053
  }
10787
- lines.push(...plan.reverseSteps.map((s) => ` \u25CB ${s.label}`));
11054
+ lines.push(
11055
+ ...plan.reverseSteps.flatMap((s) => [
11056
+ ` \u25CB ${s.label}`,
11057
+ ...(s.hints ?? []).map((hint) => c.dim(` \u21B3 ${hint}`))
11058
+ ])
11059
+ );
10788
11060
  lines.push(...globalCopyLines(copies, true));
10789
11061
  lines.push(
10790
11062
  assetsOnly ? ` \u25CB install log updated (${installLog.assets.length - plannedAssets(plan, installLog).length} asset(s) remain)` : " \u25CB remove install record (.uzys-agent-harness/ \u2014 \uC124\uCE58 \uAE30\uB85D\xB7\uCC28\uB2E8 \uB85C\uADF8\xB7update \uBC31\uC5C5 \uBAA9\uB85D)"
@@ -10808,7 +11080,10 @@ function dryRunLines(plan, installLog, projectDir, assetsOnly, rootFiles, harnes
10808
11080
  willBeGone: new Set(plannedAssetFiles(plan, installLog)),
10809
11081
  write: false
10810
11082
  });
10811
- lines.push(...displacedLines(preview, true));
11083
+ lines.push(
11084
+ ...displacedLines(preview, true),
11085
+ ...byHandLines([], preview, projectDir, installLog)
11086
+ );
10812
11087
  }
10813
11088
  lines.push(...advisoryLines(plan, projectDir, rootFiles, globalTrust), "");
10814
11089
  return lines;
@@ -10848,7 +11123,7 @@ function backupArtifactAdvisoryLines(projectDir) {
10848
11123
  }
10849
11124
  }
10850
11125
  for (const dir of BACKUP_SCAN_DIRS) {
10851
- const abs = join33(projectDir, dir);
11126
+ const abs = join34(projectDir, dir);
10852
11127
  if (!existsSync24(abs) || outsideLinkAt(projectDir, dir) !== null) continue;
10853
11128
  for (const rel of listFilesRecursive(abs)) {
10854
11129
  if (BACKUP_SUFFIX.test(rel)) found.push(`${dir}/${rel}`);
@@ -10859,16 +11134,16 @@ function backupArtifactAdvisoryLines(projectDir) {
10859
11134
  c.yellow(
10860
11135
  `[BACKUPS] \uD558\uB124\uC2A4\uAC00 \uB0A8\uAE34 \uBC31\uC5C5 ${found.length}\uAC74 (\uC790\uB3D9\uC73C\uB85C \uC9C0\uC6B0\uC9C0 \uC54A\uB294\uB2E4 \u2014 \uB0B4\uC6A9 \uD655\uC778 \uD6C4 \uC0AD\uC81C):`
10861
11136
  ),
10862
- ...found.sort().map((f) => c.dim(` ${f}`))
11137
+ ...found.sort().map((f) => c.dim(` ${screenText(f)}`))
10863
11138
  ];
10864
11139
  }
10865
11140
  function rootFileAdvisoryLines(rootFiles, projectDir) {
10866
11141
  const header = "[ROOT] `.claude/` \uBC16\uC5D0 \uB0A8\uB294 \uAC83 (\uC790\uB3D9\uC73C\uB85C \uC9C0\uC6B0\uC9C0 \uC54A\uB294\uB2E4):";
10867
- const present = rootFiles.filter((f) => existsSync24(join33(projectDir, f.path)));
11142
+ const present = rootFiles.filter((f) => existsSync24(join34(projectDir, f.path)));
10868
11143
  if (present.length === 0) return [];
10869
11144
  const outside = /* @__PURE__ */ new Map();
10870
11145
  const inside = present.filter((f) => {
10871
- const o = outsideProjectTarget(projectDir, join33(projectDir, f.path));
11146
+ const o = outsideProjectTarget(projectDir, join34(projectDir, f.path));
10872
11147
  if (o === null) return true;
10873
11148
  const group = outside.get(o.link) ?? { link: o, files: [] };
10874
11149
  group.files.push(f.path);
@@ -10880,13 +11155,13 @@ function rootFileAdvisoryLines(rootFiles, projectDir) {
10880
11155
  c.yellow(header),
10881
11156
  ...[...outside.values()].map(
10882
11157
  ({ link: o, files }) => c.dim(
10883
- ` \xB7 ${o.link} \u2014 left as is: the link points outside the project (${o.link} \u2192 ${o.linkTarget}); harness files there: ${files.join(" \xB7 ")} (other projects linked to it may use them)`
11158
+ ` \xB7 ${screenText(o.link)} \u2014 left as is: the link points outside the project (${screenText(o.link)} \u2192 ${screenText(o.linkTarget)}); harness files there: ${files.map(screenText).join(" \xB7 ")} (other projects linked to it may use them)`
10884
11159
  )
10885
11160
  ),
10886
11161
  ...inside.flatMap((f) => [
10887
- c.dim(` \xB7 ${f.path} \u2014 ${rootFileMeaning(f, projectDir)}`),
11162
+ c.dim(` \xB7 ${screenText(f.path)} \u2014 ${rootFileMeaning(f, projectDir)}`),
10888
11163
  // displaced 의 notes 는 백업 경로 하나 — 위 줄이 이미 댔다
10889
- ...f.change !== "displaced" && f.notes.length > 0 ? [c.dim(` ${f.notes.join(" / ")}`)] : []
11164
+ ...f.change !== "displaced" && f.notes.length > 0 ? [c.dim(` ${f.notes.map(oneLine).join(" / ")}`)] : []
10890
11165
  ])
10891
11166
  ];
10892
11167
  }
@@ -10907,7 +11182,7 @@ function rootFileMeaning(f, projectDir) {
10907
11182
  case "displaced": {
10908
11183
  const backup = f.notes[0];
10909
11184
  if (backup === void 0) return "\uD558\uB124\uC2A4 \uD310\uACFC \uAC19\uC740 \uC124\uCE58\uC790 \uD30C\uC77C\uC774 \uC788\uB358 \uC790\uB9AC (\uADF8\uB300\uB85C \uB450\uC5C8\uB2E4)";
10910
- return existsSync24(join33(projectDir, backup)) ? `\uD558\uB124\uC2A4\uAC00 \uC4F4 \uC790\uB9AC \u2014 \uC6D0\uB798 \uC788\uB358 \uC124\uCE58\uC790 \uD30C\uC77C\uC740 ${backup} \uC5D0 \uC788\uB2E4` : `\uD558\uB124\uC2A4\uAC00 \uC4F4 \uC790\uB9AC \u2014 \uC6D0\uB798 \uC788\uB358 \uC124\uCE58\uC790 \uD30C\uC77C\uC758 \uBC31\uC5C5(${backup})\uC774 \uB354\uB294 \uC5C6\uB2E4`;
11185
+ return existsSync24(join34(projectDir, backup)) ? `\uD558\uB124\uC2A4\uAC00 \uC4F4 \uC790\uB9AC \u2014 \uC6D0\uB798 \uC788\uB358 \uC124\uCE58\uC790 \uD30C\uC77C\uC740 ${screenText(backup)} \uC5D0 \uC788\uB2E4` : `\uD558\uB124\uC2A4\uAC00 \uC4F4 \uC790\uB9AC \u2014 \uC6D0\uB798 \uC788\uB358 \uC124\uCE58\uC790 \uD30C\uC77C\uC758 \uBC31\uC5C5(${screenText(backup)})\uC774 \uB354\uB294 \uC5C6\uB2E4`;
10911
11186
  }
10912
11187
  }
10913
11188
  }
@@ -10989,15 +11264,15 @@ function agentsMdRerenderSet(target, remaining, log, projectDir) {
10989
11264
  const set = agentsMdClis(remaining);
10990
11265
  if (set.length === 0) return null;
10991
11266
  const recorded2 = (log.externalFiles ?? []).some((f) => f.path === AGENTS_MD2) || (log.portions ?? []).some((p2) => p2.path === AGENTS_MD2);
10992
- if (!existsSync24(join33(projectDir, AGENTS_MD2))) return null;
10993
- if (!recorded2 && !isLegacyHarnessAgentsMd(readTextOrEmpty(join33(projectDir, AGENTS_MD2)))) {
11267
+ if (!existsSync24(join34(projectDir, AGENTS_MD2))) return null;
11268
+ if (!recorded2 && !isLegacyHarnessAgentsMd(readTextOrEmpty(join34(projectDir, AGENTS_MD2)))) {
10994
11269
  return null;
10995
11270
  }
10996
11271
  return set;
10997
11272
  }
10998
11273
  function readTextOrEmpty(abs) {
10999
11274
  try {
11000
- return readFileSync25(abs, "utf8");
11275
+ return readFileSync26(abs, "utf8");
11001
11276
  } catch {
11002
11277
  return "";
11003
11278
  }
@@ -11067,7 +11342,7 @@ function settleCliLog(ctx, target, remaining, done, anchorRemoved) {
11067
11342
  function forgetRemoved(next, done) {
11068
11343
  const out = { ...next };
11069
11344
  const kept = (prefix) => (f) => !done.forgotten.has(`${prefix}${f.path}`);
11070
- if (out.policyFiles !== void 0) out.policyFiles = out.policyFiles.filter(kept(CLAUDE_DIR3));
11345
+ if (out.policyFiles !== void 0) out.policyFiles = out.policyFiles.filter(kept(CLAUDE_DIR4));
11071
11346
  if (out.skillFiles !== void 0) out.skillFiles = out.skillFiles.filter(kept(SKILLS_DIR3));
11072
11347
  const survivors = (out.externalFiles ?? []).filter(kept(""));
11073
11348
  if (survivors.length > 0) out.externalFiles = survivors;
@@ -11121,9 +11396,9 @@ function runScopedRemoval(ctx, io, plan) {
11121
11396
  }
11122
11397
  for (const line of lines) io.log(line);
11123
11398
  const settled = plan.settle(done);
11124
- const agentsBefore = readTextOrEmpty(join33(projectDir, AGENTS_MD2));
11399
+ const agentsBefore = readTextOrEmpty(join34(projectDir, AGENTS_MD2));
11125
11400
  const rerender = plan.rerenderSet === null ? null : rerenderAgentsMd(ctx, plan.rerenderSet, settled);
11126
- const rewrote = rerender !== null && readTextOrEmpty(join33(projectDir, AGENTS_MD2)) !== agentsBefore;
11401
+ const rewrote = rerender !== null && readTextOrEmpty(join34(projectDir, AGENTS_MD2)) !== agentsBefore;
11127
11402
  if (rewrote) for (const line of rerenderLines(rerender)) io.log(line);
11128
11403
  const next = rerender === null ? settled : withRerender(settled, rerender);
11129
11404
  try {
@@ -11196,7 +11471,7 @@ function removeTrackAction(ctx, io) {
11196
11471
  }
11197
11472
  var TRACK_SCOPE = { shared: [], skeleton: [], folders: [], importBlock: false, anchor: false };
11198
11473
  function trackNotes(ctx, r, d2, write) {
11199
- const md = join33(ctx.projectDir, "CLAUDE.md");
11474
+ const md = join34(ctx.projectDir, "CLAUDE.md");
11200
11475
  const block = rootBlockNext(ctx, new Set(d2.removed));
11201
11476
  if (write && block !== null) {
11202
11477
  backupIfLossyUtf8(md);
@@ -11224,11 +11499,11 @@ function previewTrackRemoval(ctx, target) {
11224
11499
  }
11225
11500
  function rootBlockNext({ installLog, projectDir }, gone) {
11226
11501
  const anchor = installLog.templates?.rootClaudeMd?.path;
11227
- const md = join33(projectDir, "CLAUDE.md");
11502
+ const md = join34(projectDir, "CLAUDE.md");
11228
11503
  const text = safeExists(md) && outsideProjectTarget(projectDir, md) === null ? readTextOrEmpty(md) : "";
11229
- if (anchor === void 0 || !safeExists(join33(projectDir, anchor))) return null;
11504
+ if (anchor === void 0 || !safeExists(join34(projectDir, anchor))) return null;
11230
11505
  if (stripHarnessImport(text) === null) return null;
11231
- const stays = (id) => listFilesRecursive(join33(projectDir, SKILLS_DIR3, id)).some(
11506
+ const stays = (id) => listFilesRecursive(join34(projectDir, SKILLS_DIR3, id)).some(
11232
11507
  (f) => !gone.has(`${SKILLS_DIR3}${id}/${f}`)
11233
11508
  );
11234
11509
  const continuousSkills = CONTINUOUS_SKILLS.map((s) => s.id).filter(stays);
@@ -11239,8 +11514,8 @@ function settleTrackLog(ctx, target, remaining, done) {
11239
11514
  const { installLog, projectDir } = ctx;
11240
11515
  const tracks = installLog.spec.tracks.filter((t) => t !== target);
11241
11516
  const next = forgetRemoved({ ...installLog, spec: { ...installLog.spec, tracks } }, done);
11242
- const abs = join33(projectDir, INSTALLED_TRACKS);
11243
- const key = INSTALLED_TRACKS.slice(CLAUDE_DIR3.length);
11517
+ const abs = join34(projectDir, INSTALLED_TRACKS);
11518
+ const key = INSTALLED_TRACKS.slice(CLAUDE_DIR4.length);
11244
11519
  const prior = installLog.policyFiles?.find((f) => f.path === key)?.sha256 ?? hashContent(installedTracksText(installLog.spec.tracks.filter(isTrack)));
11245
11520
  const edited = safeExists(abs) && hashContent(readTextOrEmpty(abs)) !== prior;
11246
11521
  if (!installedClis(installLog).includes("claude")) return next;
@@ -11266,7 +11541,7 @@ var SKILLS_LOCK = "skills-lock.json";
11266
11541
  function withSkillsLock(rootFiles, assets, projectDir) {
11267
11542
  const out = [...rootFiles];
11268
11543
  const skills = assets.some((a) => a.method === "skill" && a.scope === "project");
11269
- if (skills && !out.some((f) => f.path === SKILLS_LOCK) && existsSync24(join33(projectDir, SKILLS_LOCK))) {
11544
+ if (skills && !out.some((f) => f.path === SKILLS_LOCK) && existsSync24(join34(projectDir, SKILLS_LOCK))) {
11270
11545
  out.push({ path: SKILLS_LOCK, change: "advisory", notes: [] });
11271
11546
  }
11272
11547
  return out;
@@ -11277,7 +11552,7 @@ function remnantFor(path, log, harnessRoot, projectDir, wiringGone = []) {
11277
11552
  const gone = (k2) => wiringGone.includes(`hooks/${k2.split("#")[1] ?? ""}`);
11278
11553
  return (disk) => {
11279
11554
  try {
11280
- const template = readFileSync25(join33(harnessRoot, "templates", "settings.json"), "utf8");
11555
+ const template = readFileSync26(join34(harnessRoot, "templates", "settings.json"), "utf8");
11281
11556
  const render = renderSettingsPortion(template, () => true);
11282
11557
  return [...legacySettingsSeed(disk, render, projectDir, { edited: true }).keys()].filter(
11283
11558
  (k2) => !k2.endsWith("{}") && !gone(k2)
@@ -11415,12 +11690,27 @@ function noReverseHints(asset, ctx) {
11415
11690
  return [".claude/ \uBC16\uC5D0 \uB9CC\uB4E0 \uD30C\uC77C(\uC608: _bmad/ \xB7 _openspec/)\uC740 \uC9C1\uC811 \uD655\uC778 \uD6C4 \uC9C0\uC6B4\uB2E4 \u2014 \uAE30\uB85D\uC5D0 \uC5C6\uB2E4"];
11416
11691
  }
11417
11692
  if (asset.method !== "skill") return [];
11418
- const name = asset.detail.skill;
11419
- const left = name === void 0 ? [] : [".claude/skills", ".agents/skills"].map((root) => `${root}/${name}/`).filter((p2) => existsSync24(join33(ctx.projectDir, p2)));
11693
+ const left = unlistedFoldersLeft(asset, ctx.projectDir);
11420
11694
  return [
11421
11695
  left.length > 0 ? `files it put down are not on record (installed by an older version) \u2014 left: ${left.join(" \xB7 ")} (delete by hand if the harness installed it)` : "files it put down are not on record (installed by an older version) \u2014 nothing removed"
11422
11696
  ];
11423
11697
  }
11698
+ function unlistedFoldersLeft(asset, projectDir) {
11699
+ const name = asset.detail.skill;
11700
+ if (!isSkillName(name) || !isPlainPath(name)) return [];
11701
+ const listed = new Set((asset.files ?? []).map((f) => f.path.split("/").slice(0, 3).join("/")));
11702
+ return [".claude/skills", ".agents/skills"].filter((root) => !listed.has(`${root}/${name}`)).map((root) => `${root}/${name}/`).filter((p2) => existsSync24(join34(projectDir, p2)));
11703
+ }
11704
+ function partialHints(asset, projectDir) {
11705
+ const left = unlistedFoldersLeft(asset, projectDir);
11706
+ if (left.length > 0) {
11707
+ return [
11708
+ `other files it put down are not on record (installed by an older version) \u2014 left: ${left.join(" \xB7 ")} (delete by hand if the harness installed it)`
11709
+ ];
11710
+ }
11711
+ const name = asset.detail.skill;
11712
+ return name === void 0 || !isSkillName(name) || !isPlainPath(name) ? ["other files it put down are not on record (installed by an older version) \u2014 left as is"] : [];
11713
+ }
11424
11714
  function buildProjectReverseStep(asset, ctx) {
11425
11715
  const { spawn } = ctx;
11426
11716
  switch (asset.method) {
@@ -11444,10 +11734,12 @@ ${r.stdout || ""}`;
11444
11734
  case "skill": {
11445
11735
  const files = asset.files;
11446
11736
  if (files === void 0) return null;
11737
+ const hints = asset.filesPartial === true ? partialHints(asset, ctx.projectDir) : [];
11447
11738
  return {
11448
11739
  assetId: asset.id,
11449
11740
  label: `remove ${asset.id} \u2014 ${files.length} file(s) on record`,
11450
- execute: () => removeToolFiles(files, ctx.projectDir, ctx.rm)
11741
+ execute: () => removeToolFiles(files, ctx.projectDir, ctx.rm),
11742
+ ...hints.length > 0 ? { hints } : {}
11451
11743
  };
11452
11744
  }
11453
11745
  case "npm": {
@@ -11498,7 +11790,7 @@ function buildGlobalAdvisoryCmd(asset) {
11498
11790
  return "(no standard reverse \u2014 manual)";
11499
11791
  }
11500
11792
  }
11501
- var CLAUDE_DIR3 = ".claude/";
11793
+ var CLAUDE_DIR4 = ".claude/";
11502
11794
  var LEGACY_LOG = `${LEGACY_INSTALL_LOG_DIR}/${INSTALL_LOG_FILENAME}`;
11503
11795
  var SKILLS_DIR3 = ".claude/skills/";
11504
11796
  var CLI_FOLDERS2 = [".claude", ".codex", ".opencode"];
@@ -11543,7 +11835,7 @@ function removeHarnessFiles(log, projectDir, scope, io) {
11543
11835
  }
11544
11836
  const judged = new Set(candidates);
11545
11837
  for (const path of legacyFileCandidates()) {
11546
- if (judged.has(path) || !scope.has(path) || !safeExists(join33(projectDir, path))) continue;
11838
+ if (judged.has(path) || !scope.has(path) || !safeExists(join34(projectDir, path))) continue;
11547
11839
  if (recorded(log, path, { isTarget }).state !== "none") continue;
11548
11840
  removeRecordedFile(path, { log, projectDir, io, out, isTarget, pruneFrom });
11549
11841
  }
@@ -11569,9 +11861,9 @@ function removeHarnessFiles(log, projectDir, scope, io) {
11569
11861
  write: io.write
11570
11862
  });
11571
11863
  if (io.write) {
11572
- for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname8(join33(projectDir, p2)));
11864
+ for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, p2)));
11573
11865
  for (const d2 of scope.skeleton) {
11574
- const abs = join33(projectDir, d2);
11866
+ const abs = join34(projectDir, d2);
11575
11867
  if (outsideProjectTarget(projectDir, abs) !== null) continue;
11576
11868
  pruneEmptyDirsUpward(projectDir, abs);
11577
11869
  }
@@ -11580,7 +11872,7 @@ function removeHarnessFiles(log, projectDir, scope, io) {
11580
11872
  }
11581
11873
  function harnessCandidates(log) {
11582
11874
  const paths = [
11583
- ...(log.policyFiles ?? []).map((f) => `${CLAUDE_DIR3}${f.path}`),
11875
+ ...(log.policyFiles ?? []).map((f) => `${CLAUDE_DIR4}${f.path}`),
11584
11876
  ...(log.skillFiles ?? []).map((f) => `${SKILLS_DIR3}${f.path}`),
11585
11877
  ...(log.externalFiles ?? []).map((f) => f.path),
11586
11878
  // 헬퍼 — writer 기록은 `externalFiles` 에 sha 로 적지만 옛 기록(≤v26.161.0)엔 항목이 없다. `recorded()` 가 가른다
@@ -11607,17 +11899,17 @@ function helperSources() {
11607
11899
  function templateNext(harnessRoot, log, path) {
11608
11900
  if (path === INSTALLED_TRACKS) return installedTracksText(log.spec.tracks.filter(isTrack));
11609
11901
  const helper = helperSources().get(path);
11610
- if (helper === void 0 && !path.startsWith(CLAUDE_DIR3)) return null;
11902
+ if (helper === void 0 && !path.startsWith(CLAUDE_DIR4)) return null;
11611
11903
  try {
11612
- const source = helper ?? path.slice(CLAUDE_DIR3.length);
11613
- return readFileSync25(join33(harnessRoot, "templates", source), "utf8");
11904
+ const source = helper ?? path.slice(CLAUDE_DIR4.length);
11905
+ return readFileSync26(join34(harnessRoot, "templates", source), "utf8");
11614
11906
  } catch {
11615
11907
  return null;
11616
11908
  }
11617
11909
  }
11618
11910
  function removeRecordedFile(path, ctx) {
11619
11911
  const { log, projectDir, io, out } = ctx;
11620
- const abs = join33(projectDir, path);
11912
+ const abs = join34(projectDir, path);
11621
11913
  let foreign;
11622
11914
  try {
11623
11915
  foreign = foreignOwnedTarget(projectDir, path);
@@ -11641,7 +11933,7 @@ function removeRecordedFile(path, ctx) {
11641
11933
  }
11642
11934
  let st2;
11643
11935
  try {
11644
- st2 = lstatSync7(abs, { throwIfNoEntry: false });
11936
+ st2 = lstatSync8(abs, { throwIfNoEntry: false });
11645
11937
  } catch {
11646
11938
  out.unjudged.push(path);
11647
11939
  return;
@@ -11659,7 +11951,7 @@ function removeRecordedFile(path, ctx) {
11659
11951
  return;
11660
11952
  }
11661
11953
  if (st2.isSymbolicLink()) effective = real;
11662
- disk = readFileSync25(effective, "utf8");
11954
+ disk = readFileSync26(effective, "utf8");
11663
11955
  } catch {
11664
11956
  out.unjudged.push(path);
11665
11957
  return;
@@ -11706,11 +11998,11 @@ function mayReclaimLegacy(log, projectDir, path) {
11706
11998
  function removeLegacyHookWiring(log, projectDir, scope, io, removed) {
11707
11999
  if (!scope.has(SETTINGS_TARGET) || !installedClis(log).includes("claude")) return [];
11708
12000
  if ((log.portions ?? []).some((p2) => p2.path === SETTINGS_TARGET)) return [];
11709
- const abs = join33(projectDir, SETTINGS_TARGET);
12001
+ const abs = join34(projectDir, SETTINGS_TARGET);
11710
12002
  if (!safeExists(abs) || outsideProjectTarget(projectDir, abs) !== null) return [];
11711
- const claudeDir = join33(projectDir, ".claude");
12003
+ const claudeDir = join34(projectDir, ".claude");
11712
12004
  const gone = LEGACY_HOOK_REFS.filter(
11713
- (r) => !RETIRED_HOOK_WIRING_REFS.includes(r) && (removed.includes(`${CLAUDE_DIR3}${r}`) || !safeExists(join33(claudeDir, r)))
12005
+ (r) => !RETIRED_HOOK_WIRING_REFS.includes(r) && (removed.includes(`${CLAUDE_DIR4}${r}`) || !safeExists(join34(claudeDir, r)))
11714
12006
  );
11715
12007
  return removeRetiredHookRefs(abs, claudeDir, gone, { evenIfScriptExists: true, write: io.write });
11716
12008
  }
@@ -11731,7 +12023,7 @@ function stripSharedFiles(log, projectDir, paths, io, out, pruneFrom) {
11731
12023
  };
11732
12024
  for (const path of paths) {
11733
12025
  if (!relevant(path)) continue;
11734
- const abs = join33(projectDir, path);
12026
+ const abs = join34(projectDir, path);
11735
12027
  if (safeExists(abs)) {
11736
12028
  const o = outsideProjectTarget(projectDir, abs);
11737
12029
  if (o !== null) {
@@ -11742,7 +12034,7 @@ function stripSharedFiles(log, projectDir, paths, io, out, pruneFrom) {
11742
12034
  if (path === SETTINGS_TARGET && safeExists(abs)) {
11743
12035
  out.retiredWiring = removeRetiredHookRefs(
11744
12036
  abs,
11745
- join33(projectDir, ".claude"),
12037
+ join34(projectDir, ".claude"),
11746
12038
  RETIRED_HOOK_WIRING_REFS,
11747
12039
  { evenIfScriptExists: true, write: io.write }
11748
12040
  );
@@ -11770,7 +12062,7 @@ function stripSharedFiles(log, projectDir, paths, io, out, pruneFrom) {
11770
12062
  }
11771
12063
  }
11772
12064
  function removeHarnessMadeShared(path, sha, projectDir, io, out, pruneFrom) {
11773
- const abs = join33(projectDir, path);
12065
+ const abs = join34(projectDir, path);
11774
12066
  if (!existsSync24(abs)) {
11775
12067
  out.forgotten.add(path);
11776
12068
  return true;
@@ -11783,8 +12075,8 @@ function removeHarnessMadeShared(path, sha, projectDir, io, out, pruneFrom) {
11783
12075
  out.unjudged.push(path);
11784
12076
  return true;
11785
12077
  }
11786
- if (lstatSync7(abs).isSymbolicLink()) effective = real;
11787
- current = readFileSync25(effective, "utf8");
12078
+ if (lstatSync8(abs).isSymbolicLink()) effective = real;
12079
+ current = readFileSync26(effective, "utf8");
11788
12080
  } catch {
11789
12081
  out.unjudged.push(path);
11790
12082
  return true;
@@ -11852,14 +12144,16 @@ function displacedLines(displaced, preview) {
11852
12144
  const restore = displaced.filter((d2) => d2.verdict === "restore");
11853
12145
  if (preview && restore.length > 0) {
11854
12146
  lines.push(
11855
- ` \u25CB put back ${restore.length} file(s) of yours (displaced): ${restore.map((d2) => d2.path).join(" \xB7 ")}`
12147
+ ` \u25CB put back ${restore.length} file(s) of yours (displaced): ${restore.map((d2) => screenText(d2.path)).join(" \xB7 ")}`
11856
12148
  );
11857
12149
  }
11858
12150
  for (const d2 of displaced) {
11859
12151
  if (d2.verdict === "restore" && !preview) {
11860
- lines.push(` ${status.success(`put back ${d2.path} (from ${d2.backup})`)}`);
12152
+ lines.push(
12153
+ ` ${status.success(`put back ${screenText(d2.path)} (from ${screenText(String(d2.backup))})`)}`
12154
+ );
11861
12155
  } else if (d2.verdict === "advise") {
11862
- lines.push(` ${c.yellow("\u2298")} ${d2.path} \u2014 ${d2.line}`);
12156
+ lines.push(` ${c.yellow("\u2298")} ${screenText(d2.path)} \u2014 ${d2.line}`);
11863
12157
  }
11864
12158
  }
11865
12159
  return lines;
@@ -11961,13 +12255,14 @@ function harnessRemovalLines(r, log, projectDir, scope, preview, alsoGone = [])
11961
12255
  }
11962
12256
  lines.push(...sharedStripLines(r.shared, preview));
11963
12257
  lines.push(...leftFolderLines(r, log, projectDir, scope, preview, alsoGone));
12258
+ lines.push(...byHandLines(r.offSlot, r.displaced, projectDir, log));
11964
12259
  return lines;
11965
12260
  }
11966
12261
  function outsideLines(outside, log) {
11967
12262
  const byLink = /* @__PURE__ */ new Map();
11968
12263
  for (const o of outside) if (!byLink.has(o.link)) byLink.set(o.link, o);
11969
12264
  return [...byLink.values()].map(
11970
- (o) => o.link === o.path ? ` ${c.yellow("\u2298")} ${o.path} kept \u2014 link target is outside the project (${o.target}). Not touched; remove manually if intended.` : keptOutsideLinkLine(o, log)
12265
+ (o) => o.link === o.path ? ` ${c.yellow("\u2298")} ${screenText(o.path)} kept \u2014 link target is outside the project (${screenText(o.target)}). Not touched; remove manually if intended.` : keptOutsideLinkLine(o, log)
11971
12266
  );
11972
12267
  }
11973
12268
  function leftFolderLines(r, log, projectDir, scope, preview, alsoGone) {
@@ -12009,19 +12304,19 @@ function yoursUnder(projectDir, dir) {
12009
12304
  }
12010
12305
  for (const e2 of entries) {
12011
12306
  const name = `${prefix}${e2.name}`;
12012
- if (e2.isDirectory()) walk(join33(abs2, e2.name), `${name}/`);
12307
+ if (e2.isDirectory()) walk(join34(abs2, e2.name), `${name}/`);
12013
12308
  else if (BACKUP_SUFFIX.test(e2.name)) continue;
12014
12309
  else if (e2.isSymbolicLink()) {
12015
12310
  let target = "?";
12016
12311
  try {
12017
- target = readlinkSync2(join33(abs2, e2.name));
12312
+ target = readlinkSync2(join34(abs2, e2.name));
12018
12313
  } catch {
12019
12314
  }
12020
12315
  out.push({ name, shown: `${name} (your link \u2192 ${target})` });
12021
12316
  } else out.push({ name, shown: name });
12022
12317
  }
12023
12318
  };
12024
- const abs = join33(projectDir, dir);
12319
+ const abs = join34(projectDir, dir);
12025
12320
  try {
12026
12321
  if (!statSync4(abs).isDirectory()) return [];
12027
12322
  } catch {
@@ -12033,7 +12328,7 @@ function yoursUnder(projectDir, dir) {
12033
12328
  function assetsLeftLines(log, projectDir, scope) {
12034
12329
  const lines = [];
12035
12330
  for (const a of log.assets) {
12036
- const here = (a.files ?? []).map((f) => f.path).filter((p2) => scope.has(p2) && safeExists(join33(projectDir, p2)));
12331
+ const here = (a.files ?? []).map((f) => f.path).filter((p2) => scope.has(p2) && safeExists(join34(projectDir, p2)));
12037
12332
  if (here.length === 0) continue;
12038
12333
  const slots = [...new Set(here.map((p2) => p2.split("/").slice(0, 3).join("/")))].sort();
12039
12334
  lines.push(
@@ -12045,7 +12340,7 @@ function assetsLeftLines(log, projectDir, scope) {
12045
12340
  function removeAnchor(log, projectDir, io) {
12046
12341
  const rootMd = log.templates?.rootClaudeMd;
12047
12342
  if (!rootMd) return { removed: false, lines: [] };
12048
- const abs = join33(projectDir, rootMd.path);
12343
+ const abs = join34(projectDir, rootMd.path);
12049
12344
  if (!existsSync24(abs)) return { removed: false, lines: [] };
12050
12345
  const outside = outsideProjectTarget(projectDir, abs);
12051
12346
  if (outside !== null) return { removed: false, lines: outsideLines([outside], log) };
@@ -12054,7 +12349,7 @@ function removeAnchor(log, projectDir, io) {
12054
12349
  }
12055
12350
  let disk;
12056
12351
  try {
12057
- disk = readFileSync25(abs, "utf8");
12352
+ disk = readFileSync26(abs, "utf8");
12058
12353
  } catch {
12059
12354
  return {
12060
12355
  removed: false,
@@ -12099,7 +12394,7 @@ function removeAnchor(log, projectDir, io) {
12099
12394
  var AGENTS_MD2 = "AGENTS.md";
12100
12395
  function readAgentsMdTemplate(harnessRoot) {
12101
12396
  try {
12102
- return readFileSync25(join33(harnessRoot, AGENTS_MD_TEMPLATE), "utf8");
12397
+ return readFileSync26(join34(harnessRoot, AGENTS_MD_TEMPLATE), "utf8");
12103
12398
  } catch {
12104
12399
  return null;
12105
12400
  }
@@ -12125,14 +12420,14 @@ function agentsMdRemainder(current, harnessRoot) {
12125
12420
  return { ok: true, remainder: strip.remainder, strip };
12126
12421
  }
12127
12422
  function removeUnrecordedLegacyAgentsMd(path, projectDir, io, out, pruneFrom) {
12128
- const abs = join33(projectDir, path);
12423
+ const abs = join34(projectDir, path);
12129
12424
  let effective = abs;
12130
12425
  let current;
12131
12426
  try {
12132
12427
  const real = realpathSync4(abs);
12133
12428
  if (!statSync4(real).isFile()) return false;
12134
- if (lstatSync7(abs).isSymbolicLink()) effective = real;
12135
- current = readFileSync25(effective, "utf8");
12429
+ if (lstatSync8(abs).isSymbolicLink()) effective = real;
12430
+ current = readFileSync26(effective, "utf8");
12136
12431
  } catch {
12137
12432
  return false;
12138
12433
  }
@@ -12190,33 +12485,95 @@ function globalCopyLines(copies, preview) {
12190
12485
  });
12191
12486
  }
12192
12487
  var ASSET_SLOTS = skillFolders(SKILL_ROOTS);
12193
- function offSlotLines(paths, projectDir) {
12194
- const lines = [];
12488
+ function offSlotGroups(paths, projectDir) {
12489
+ const literal = [];
12195
12490
  const byLink = /* @__PURE__ */ new Map();
12196
12491
  for (const path of paths) {
12197
12492
  const link = linkOnPath(projectDir, path);
12198
12493
  if (link === null) {
12199
- lines.push(offSlotLine(path, "lists it"));
12494
+ literal.push(path);
12200
12495
  continue;
12201
12496
  }
12202
- const g = byLink.get(link.link) ?? { target: link.target, n: 0 };
12203
- g.n += 1;
12497
+ const g = byLink.get(link.link) ?? { target: link.target, files: [] };
12498
+ g.files.push(path);
12204
12499
  byLink.set(link.link, g);
12205
12500
  }
12206
- for (const [link, g] of byLink) {
12501
+ return { literal, byLink };
12502
+ }
12503
+ function offSlotLines(paths, projectDir) {
12504
+ const { literal, byLink } = offSlotGroups(paths, projectDir);
12505
+ return [
12506
+ ...literal.map((path) => offSlotLine(path, "lists it")),
12507
+ ...[...byLink].map(
12508
+ ([link, g]) => ` ${c.yellow("\u2298")} ${screenText(link)} \u2014 your link (\u2192 ${screenText(g.target)}) leads outside the places this tool installs to; left ${g.files.length} file(s) on the install record under it. Not touched \u2014 remove by hand if intended.`
12509
+ )
12510
+ ];
12511
+ }
12512
+ function byHandLines(offSlot, displaced, projectDir, log) {
12513
+ let hidden = 0;
12514
+ let bundleTargets;
12515
+ const stands = (path, confirmed) => {
12516
+ if (isPlainPath(path) && confirmed()) return true;
12517
+ hidden += 1;
12518
+ return false;
12519
+ };
12520
+ const back = displaced.flatMap((d2) => d2.handBack === void 0 ? [] : [d2.handBack]);
12521
+ const movable = back.filter((b2) => stands(b2.from, () => true) && stands(b2.to, () => b2.safe));
12522
+ const links = [...offSlotGroups(offSlot, projectDir).byLink].flatMap(([link, g]) => {
12523
+ const shown = g.files.filter((f) => f !== link).filter(
12524
+ (f) => stands(f, () => {
12525
+ bundleTargets ??= recordedTrackTargets(log);
12526
+ return isPlainPath(link) && holdsHarnessBytes(log, projectDir, f, bundleTargets);
12527
+ })
12528
+ ).sort();
12529
+ return shown.length > 0 ? [{ link, files: shown }] : [];
12530
+ });
12531
+ if (movable.length === 0 && links.length === 0 && hidden === 0) return [];
12532
+ const yours = new Set(movable.map((b2) => b2.to));
12533
+ const lines = [
12534
+ ` ${c.yellow("\u2298")} left for you to finish by hand (nothing here was touched \u2014 run from the project folder):`
12535
+ ];
12536
+ if (movable.length > 0) {
12537
+ lines.push(
12538
+ c.dim(
12539
+ " your files this tool moved aside \u2014 put each back (only an empty place or a harness copy is overwritten):"
12540
+ )
12541
+ );
12542
+ for (const b2 of movable) lines.push(c.dim(` mv -i ${b2.from} ${b2.to}`));
12543
+ }
12544
+ for (const g of links) {
12207
12545
  lines.push(
12208
- ` ${c.yellow("\u2298")} ${link} \u2014 your link (\u2192 ${g.target}) leads outside the places this tool installs to; left ${g.n} file(s) on the install record under it. Not touched \u2014 remove by hand if intended.`
12546
+ c.dim(
12547
+ ` listed on the install record under your link ${g.link} \u2014 check, then remove if intended:`
12548
+ )
12549
+ );
12550
+ for (const file of g.files) {
12551
+ lines.push(
12552
+ c.dim(
12553
+ yours.has(file) ? ` ${file} (your own file goes back here \u2014 do not delete)` : ` ${file}`
12554
+ )
12555
+ );
12556
+ }
12557
+ }
12558
+ if (hidden > 0) {
12559
+ lines.push(
12560
+ c.dim(
12561
+ ` not shown \u2014 ${hidden} entr${hidden === 1 ? "y" : "ies"} on the install record that this tool cannot confirm it wrote or cannot safely put back (a name it never writes, or contents that differ from what it installed): inspect the record, and look for *.backup-* files`
12562
+ )
12209
12563
  );
12210
12564
  }
12211
12565
  return lines;
12212
12566
  }
12567
+ function isPlainPath(path) {
12568
+ return path.split("/").every((seg) => /^[A-Za-z0-9._][A-Za-z0-9._-]*$/.test(seg) && seg !== "." && seg !== "..");
12569
+ }
12213
12570
  function linkOnPath(projectDir, path) {
12214
12571
  const parts = path.split("/");
12215
12572
  for (let i = 1; i <= parts.length; i++) {
12216
12573
  const rel = parts.slice(0, i).join("/");
12217
12574
  try {
12218
- if (lstatSync7(join33(projectDir, rel), { throwIfNoEntry: false })?.isSymbolicLink() === true) {
12219
- return { link: rel, target: readlinkSync2(join33(projectDir, rel)) };
12575
+ if (lstatSync8(join34(projectDir, rel), { throwIfNoEntry: false })?.isSymbolicLink() === true) {
12576
+ return { link: rel, target: readlinkSync2(join34(projectDir, rel)) };
12220
12577
  }
12221
12578
  } catch {
12222
12579
  return null;
@@ -12225,16 +12582,16 @@ function linkOnPath(projectDir, path) {
12225
12582
  return null;
12226
12583
  }
12227
12584
  function offSlotLine(path, what) {
12228
- return ` ${c.yellow("\u2298")} ${path} left \u2014 the install record ${what}, but it is (or leads) outside the places this tool installs to. Not touched.`;
12585
+ return ` ${c.yellow("\u2298")} ${screenText(path)} left \u2014 the install record ${what}, but it is (or leads) outside the places this tool installs to. Not touched.`;
12229
12586
  }
12230
12587
  function removeToolFiles(files, projectDir, rm) {
12231
12588
  const notes = [];
12232
12589
  const removed = [];
12233
12590
  let failed = 0;
12234
- const pairs = new Set(files.filter((f) => isAppleDoublePath(join33(projectDir, f.path))));
12591
+ const pairs = new Set(files.filter((f) => isAppleDoublePath(join34(projectDir, f.path))));
12235
12592
  for (const file of files) {
12236
12593
  const { path, sha256 } = file;
12237
- const abs = join33(projectDir, path);
12594
+ const abs = join34(projectDir, path);
12238
12595
  if (pairs.has(file)) {
12239
12596
  try {
12240
12597
  rm(abs);
@@ -12244,7 +12601,7 @@ function removeToolFiles(files, projectDir, rm) {
12244
12601
  }
12245
12602
  let isLink;
12246
12603
  try {
12247
- isLink = lstatSync7(abs).isSymbolicLink();
12604
+ isLink = lstatSync8(abs).isSymbolicLink();
12248
12605
  } catch {
12249
12606
  continue;
12250
12607
  }
@@ -12264,7 +12621,7 @@ function removeToolFiles(files, projectDir, rm) {
12264
12621
  continue;
12265
12622
  }
12266
12623
  try {
12267
- if (hashContent(readFileSync25(abs, "utf8")) !== sha256) {
12624
+ if (hashContent(readFileSync26(abs, "utf8")) !== sha256) {
12268
12625
  const backup = backupFile(abs);
12269
12626
  notes.push(`backed up ${path} \u2192 ${relative9(projectDir, backup)} (changed since install)`);
12270
12627
  }
@@ -12275,7 +12632,7 @@ function removeToolFiles(files, projectDir, rm) {
12275
12632
  notes.push(`left ${path} \u2014 ${e2 instanceof Error ? e2.message : String(e2)}`);
12276
12633
  }
12277
12634
  }
12278
- for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname8(join33(projectDir, path)));
12635
+ for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, path)));
12279
12636
  return failed > 0 ? { ok: false, message: `${failed} file(s) could not be removed`, notes } : { ok: true, notes };
12280
12637
  }
12281
12638
  function pruneEmptyDirsUpward(projectDir, startDir) {
@@ -12299,8 +12656,8 @@ function stripRootImport(projectDir) {
12299
12656
  if (withoutImport === null) return false;
12300
12657
  const stripped = neutralizeScaffoldBanner(withoutImport);
12301
12658
  try {
12302
- backupIfLossyUtf8(join33(projectDir, "CLAUDE.md"));
12303
- writeFileSync8(join33(projectDir, "CLAUDE.md"), stripped, "utf8");
12659
+ backupIfLossyUtf8(join34(projectDir, "CLAUDE.md"));
12660
+ writeFileSync8(join34(projectDir, "CLAUDE.md"), stripped, "utf8");
12304
12661
  return true;
12305
12662
  } catch {
12306
12663
  return false;
@@ -12322,13 +12679,13 @@ function importOutsideLine(o, anchorGone) {
12322
12679
  return ` ${c.yellow("\u2298")} CLAUDE.md kept \u2014 link target is outside the project (${o.target}). Not touched \u2014 its harness @import block (${HARNESS_IMPORT_LINE}) is left in it${pointing} \u2014 delete that block by hand.`;
12323
12680
  }
12324
12681
  function rootClaudeMdOutside(projectDir) {
12325
- return outsideProjectTarget(projectDir, join33(projectDir, "CLAUDE.md"));
12682
+ return outsideProjectTarget(projectDir, join34(projectDir, "CLAUDE.md"));
12326
12683
  }
12327
12684
  function readRootClaudeMd(projectDir) {
12328
- const path = join33(projectDir, "CLAUDE.md");
12685
+ const path = join34(projectDir, "CLAUDE.md");
12329
12686
  if (!existsSync24(path)) return null;
12330
12687
  try {
12331
- return readFileSync25(path, "utf8");
12688
+ return readFileSync26(path, "utf8");
12332
12689
  } catch {
12333
12690
  return null;
12334
12691
  }