@uzysjung/agent-harness 26.182.0 → 26.184.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
@@ -150,7 +150,7 @@ import {
150
150
  withoutAppleDouble,
151
151
  wrapHarnessBlock,
152
152
  writeInstallLog
153
- } from "./chunk-OYXKVPAB.js";
153
+ } from "./chunk-7ASVB2BV.js";
154
154
 
155
155
  // node_modules/sisteransi/src/index.js
156
156
  var require_src = __commonJS({
@@ -1229,6 +1229,8 @@ var SHARED_BY_ALL = (self) => [
1229
1229
  ];
1230
1230
  var CLI_OWNERSHIP = {
1231
1231
  claude: [
1232
+ // #953 (ADR-118) — Codex 의 경로 룰 포인터가 `.claude/rules/` 를 가리킬 수 있다. 이 자리를 지우는 `uninstall --cli claude` 는
1233
+ // `AGENTS.md` 재렌더(인라인)와 묶여 있다(`agentsMdRerenderSet`) — 지우는 길을 더하면 그 재렌더도 함께 묶는다
1232
1234
  { path: ".claude/", kind: "recorded", sharedWith: [] },
1233
1235
  { path: HARNESS_ANCHOR_FILE, kind: "anchor", sharedWith: [] },
1234
1236
  { path: "CLAUDE.md", kind: "import-block", sharedWith: [] },
@@ -1954,7 +1956,7 @@ function legacyGitignoreSeed(text, render, previous) {
1954
1956
  // src/installer.ts
1955
1957
  init_esm_shims();
1956
1958
  import { chmodSync as chmodSync3, existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync22, writeFileSync as writeFileSync7 } from "fs";
1957
- import { basename as basename6, join as join30, relative as relative7, resolve, sep as sep8 } from "path";
1959
+ import { basename as basename6, join as join30, relative as relative8, resolve, sep as sep9 } from "path";
1958
1960
 
1959
1961
  // src/agents-md-render.ts
1960
1962
  init_esm_shims();
@@ -2137,7 +2139,7 @@ function installCiScaffold(ctx) {
2137
2139
  // src/cli-transforms.ts
2138
2140
  init_esm_shims();
2139
2141
  import { existsSync as existsSync15, readFileSync as readFileSync14 } from "fs";
2140
- import { join as join19 } from "path";
2142
+ import { join as join19, relative as relative4, sep as sep5 } from "path";
2141
2143
 
2142
2144
  // src/agents-md-transform.ts
2143
2145
  init_esm_shims();
@@ -2319,10 +2321,10 @@ function ruleHeadings(harnessRoot) {
2319
2321
  );
2320
2322
  }
2321
2323
  var PATH_RULE_POINTER_LEAD = "> \uC544\uB798 \uD30C\uC77C\uC744 \uB9CC\uB4E4\uAC70\uB098 \uACE0\uCE58\uAE30 \uC804\uC5D0 \uADF8 \uB8F0\uC744 \uC77D\uACE0 \uB530\uB978\uB2E4 \u2014 \uBCF8\uBB38\uC740 \uC5EC\uAE30 \uC5C6\uB2E4.";
2322
- function pathRulePointerLine(rule) {
2323
- return `> - ${rule.paths.map((p2) => `\`${p2}\``).join(" \xB7 ")} \u2192 \`.agents/rules/${rule.name}.md\``;
2324
+ function pathRulePointerLine(rule, folder) {
2325
+ return `> - ${rule.paths.map((p2) => `\`${p2}\``).join(" \xB7 ")} \u2192 \`${folder}/${rule.name}.md\``;
2324
2326
  }
2325
- var POINTER_TARGET = /^> - .+ → `\.agents\/rules\/([^`/]+)\.md`$/;
2327
+ var POINTER_TARGET = /^> - .+ → `((?:\.agents|\.claude)\/rules\/[^`/]+\.md)`$/;
2326
2328
  function pathRulePointerTargets(text) {
2327
2329
  return text.split("\n").flatMap((l) => POINTER_TARGET.exec(l.replace(/\r$/, ""))?.[1] ?? []);
2328
2330
  }
@@ -2330,10 +2332,15 @@ function renderRulesBlock(rules, pathRulesViaFiles = false) {
2330
2332
  if (rules.length === 0) return "";
2331
2333
  const always = rules.filter((r) => r.paths.length === 0);
2332
2334
  const path = rules.filter((r) => r.paths.length > 0);
2333
- const bodies = (pathRulesViaFiles ? always : [...always, ...path]).map(
2335
+ const bodies = (pathRulesViaFiles !== false ? always : [...always, ...path]).map(
2334
2336
  (r) => r.body.replace(/^#\s+/, "## ")
2335
2337
  );
2336
- const pointers = pathRulesViaFiles && path.length > 0 ? [[PATH_RULE_POINTER_LEAD, ...path.map(pathRulePointerLine)].join("\n")] : [];
2338
+ const pointers = pathRulesViaFiles !== false && path.length > 0 ? [
2339
+ [
2340
+ PATH_RULE_POINTER_LEAD,
2341
+ ...path.map((r) => pathRulePointerLine(r, pathRulesViaFiles))
2342
+ ].join("\n")
2343
+ ] : [];
2337
2344
  return [...bodies, ...pointers].join("\n\n---\n\n");
2338
2345
  }
2339
2346
 
@@ -2659,7 +2666,7 @@ function runAgentsMdTransform(params) {
2659
2666
  ),
2660
2667
  harnessRules: renderRulesBlock(
2661
2668
  portRules(harnessRoot, params.rules),
2662
- params.pathRulesViaFiles && sectionsModel
2669
+ sectionsModel ? params.pathRulesViaFiles : false
2663
2670
  ),
2664
2671
  clis,
2665
2672
  rulesViaInstructions: params.rulesViaInstructions && sectionsModel
@@ -3449,12 +3456,12 @@ function adapterExcluded(harnessRoot, excluded) {
3449
3456
  }
3450
3457
  return out;
3451
3458
  }
3452
- function wroteEveryRule(harnessRoot, projectDir, report, rules) {
3453
- if (report === null) return false;
3454
- const written = new Set(report.harnessRuleFiles);
3455
- return portRules(harnessRoot, rules).every(
3456
- (r) => written.has(join19(projectDir, ".agents", "rules", `${r.name}.md`))
3457
- );
3459
+ function wroteEveryRule(harnessRoot, folder, written, rules) {
3460
+ return portRules(harnessRoot, rules).every((r) => written.has(`${folder}/${r.name}.md`));
3461
+ }
3462
+ function antigravityRuleWrites(projectDir, report) {
3463
+ if (report === null) return null;
3464
+ return new Set(report.harnessRuleFiles.map((f) => relative4(projectDir, f).split(sep5).join("/")));
3458
3465
  }
3459
3466
  function mcpSources(harnessRoot) {
3460
3467
  return {
@@ -3583,8 +3590,9 @@ function runCliTransforms(params) {
3583
3590
  }
3584
3591
  let agentsMd = null;
3585
3592
  if (agentsSet.length > 0) {
3586
- const beyondThisRun = agentsSet.some((c3) => !cli.includes(c3));
3587
- const agentsRules = beyondThisRun && params.cumulativeRules !== void 0 ? params.cumulativeRules : rules;
3593
+ const agentsRules = params.cumulativeRules ?? rules;
3594
+ const agRules = antigravityRuleWrites(projectDir, antigravity);
3595
+ const wroteAllTo = (folder, written) => written !== null && wroteEveryRule(harnessRoot, folder, written, agentsRules);
3588
3596
  agentsMd = runAgentsMdTransform({
3589
3597
  harnessRoot,
3590
3598
  projectDir,
@@ -3594,11 +3602,14 @@ function runCliTransforms(params) {
3594
3602
  // #944 (ADR-116) — 룰 본문 대신 위치 안내는 이번 실행이 OpenCode 의 도달을 **보장했을 때만**(집합이 아니라 쓴 결과로):
3595
3603
  // ① Codex ∉ 집합 ② opencode 변환이 이번에 돌았다 ③ Antigravity 가 이번 룰을 전부 `.agents/rules/` 에 썼다 ④ 그 뒤
3596
3604
  // 디스크의 `opencode.json` 에 룰 원소가 있다. 하나라도 거짓이면 인라인 — OpenCode 가 룰을 0번 받는 실행은 없다
3597
- rulesViaInstructions: !agentsSet.includes("codex") && opencode?.rulesViaInstructions === true && wroteEveryRule(harnessRoot, projectDir, antigravity, agentsRules),
3598
- // #948 (ADR-117) — Codex 의 경로 룰은 Antigravity 가 이번에 쓴 `.agents/rules/<룰>.md` 를 가리키는 목록으로(실 Codex 포인터
3599
- // 15/15): ① Codex ∈ 집합 ② OpenCode ∉ 집합(OpenCode 의 포인터 따르기는 재지 않았다) ③ Antigravity 가 이번 룰을 전부 썼다
3600
- // (④ 절 모델은 변환이 본다). 하나라도 거짓이면 인라인 — 포인터는 이번 실행이 실재를 보장한 파일만 가리킨다
3601
- pathRulesViaFiles: agentsSet.includes("codex") && !agentsSet.includes("opencode") && wroteEveryRule(harnessRoot, projectDir, antigravity, agentsRules),
3605
+ rulesViaInstructions: !agentsSet.includes("codex") && opencode?.rulesViaInstructions === true && wroteAllTo(".agents/rules", agRules),
3606
+ // #948 (ADR-117) · #953 (ADR-118) · #960 (ADR-119) — 인라인 룰을 읽는 CLI(Codex · OpenCode)의 경로 룰은 이번 실행이 쓴 룰
3607
+ // 파일을 가리키는 목록으로(실 Codex 15/15 · `.claude/rules/` 4/4 · 실 OpenCode 6/6): ① Codex 또는 OpenCode ∈ 집합 ③a Antigravity
3608
+ // 가 이번 룰 전부를 `.agents/rules/` 에 썼다 → 그 폴더 ③b 아니면 이번 실행의 하네스 writer(Claude Code 단계 — 이 변환 앞)가 이번
3609
+ // 룰 전부를 `.claude/rules/` 에 남겼다 → 그 폴더(④ 절 모델은 변환이 본다). 대조 목록은 렌더하는 `agentsRules`(누적일 수 있다).
3610
+ // 하나라도 거짓이면 인라인 — 포인터는 이번 실행이 실재를 보장한 파일만 가리킨다. 위 위치 안내(ADR-116)가 서면 렌더가 그쪽을
3611
+ // 쓴다(룰 전부가 이미 파일로 간다 — 이 값은 쓰이지 않는다)
3612
+ pathRulesViaFiles: !agentsSet.includes("codex") && !agentsSet.includes("opencode") ? false : wroteAllTo(".agents/rules", agRules) ? ".agents/rules" : wroteAllTo(".claude/rules", params.harnessWrote ?? null) ? ".claude/rules" : false,
3602
3613
  baseline,
3603
3614
  refreshOnly,
3604
3615
  // ADR-099 R2 — 기록이 이 파일을 읽는 CLI 를 깔린 것으로 말하면 없어도 만든다(26.164.0 이하 Antigravity 단독 설치본은
@@ -3702,7 +3713,7 @@ function holdsHarnessBytes(log, projectDir, path, isTarget = recordedTrackTarget
3702
3713
 
3703
3714
  // src/harness-slot.ts
3704
3715
  init_esm_shims();
3705
- import { isAbsolute, join as join21, posix as posix2, relative as relative4, sep as sep5 } from "path";
3716
+ import { isAbsolute, join as join21, posix as posix2, relative as relative5, sep as sep6 } from "path";
3706
3717
  var ownedOf = (...kinds) => [
3707
3718
  ...new Set(
3708
3719
  Object.values(CLI_OWNERSHIP).flat().filter((o) => kinds.includes(o.kind)).map((o) => o.path)
@@ -3729,9 +3740,9 @@ function realRel(projectDir, norm, follow) {
3729
3740
  return dir === null ? null : join21(dir, posix2.basename(norm));
3730
3741
  })();
3731
3742
  if (target === null) return null;
3732
- const rel = relative4(resolveWriteTarget(projectDir) ?? projectDir, target);
3743
+ const rel = relative5(resolveWriteTarget(projectDir) ?? projectDir, target);
3733
3744
  if (rel === "" || isAbsolute(rel)) return null;
3734
- const slash = rel.split(sep5).join("/");
3745
+ const slash = rel.split(sep6).join("/");
3735
3746
  return slash === ".." || slash.startsWith("../") ? null : slash;
3736
3747
  }
3737
3748
  function inSlotByName(path, slots = HARNESS_FILES) {
@@ -3928,7 +3939,7 @@ import {
3928
3939
  rmSync as rmSync3
3929
3940
  } from "fs";
3930
3941
  import { homedir as homedir2 } from "os";
3931
- import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join24, relative as relative5, sep as sep6 } from "path";
3942
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join24, relative as relative6, sep as sep7 } from "path";
3932
3943
  function outsideSlotNote(o) {
3933
3944
  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})`;
3934
3945
  }
@@ -4483,12 +4494,12 @@ function reclaimCopy(projectDir, slot, home, ctx) {
4483
4494
  return res.removed.length > 0 || res.left.length > 0 ? res : null;
4484
4495
  }
4485
4496
  function inCanonicalSkillRoot(projectDir, real) {
4486
- const rel = relative5(realOrNull(projectDir) ?? projectDir, real).split(sep6).join("/");
4497
+ const rel = relative6(realOrNull(projectDir) ?? projectDir, real).split(sep7).join("/");
4487
4498
  return SKILL_ROOTS.some((r) => rel.startsWith(`${r}/`));
4488
4499
  }
4489
4500
  function inProjectSpelling(projectDir, real) {
4490
- const at2 = relative5(realOrNull(projectDir) ?? projectDir, real);
4491
- return at2 === "" || at2 === ".." || at2.startsWith(`..${sep6}`) || isAbsolute2(at2) ? real : join24(projectDir, at2);
4501
+ const at2 = relative6(realOrNull(projectDir) ?? projectDir, real);
4502
+ return at2 === "" || at2 === ".." || at2.startsWith(`..${sep7}`) || isAbsolute2(at2) ? real : join24(projectDir, at2);
4492
4503
  }
4493
4504
  function realOrNull(abs) {
4494
4505
  try {
@@ -4614,7 +4625,7 @@ function inSkillFolders(projectDir, slot) {
4614
4625
  const roots = SKILL_ROOTS.flatMap((r) => {
4615
4626
  const real = resolveWriteTarget(join24(projectDir, r));
4616
4627
  if (real === null) return [r];
4617
- const rel = relative5(base, real).split(sep6).join("/");
4628
+ const rel = relative6(base, real).split(sep7).join("/");
4618
4629
  return rel === "" || rel === ".." || rel.startsWith("../") || isAbsolute2(rel) ? [r] : [r, rel];
4619
4630
  });
4620
4631
  const places = [...new Set(roots.map((r) => name === "" ? `${r}/` : `${r}/${name}/`))];
@@ -4672,7 +4683,7 @@ function pruneEmptyDirs(dir) {
4672
4683
  }
4673
4684
  }
4674
4685
  function toProjectRel(projectDir, abs) {
4675
- return relative5(projectDir, abs).split(sep6).join("/");
4686
+ return relative6(projectDir, abs).split(sep7).join("/");
4676
4687
  }
4677
4688
  function recordRefreshedFiles(projectDir, log, report, displaced, writeLog) {
4678
4689
  const next = new Map(
@@ -5111,7 +5122,7 @@ import {
5111
5122
  unlinkSync as unlinkSync2,
5112
5123
  writeFileSync as writeFileSync6
5113
5124
  } from "fs";
5114
- import { basename as basename5, dirname as dirname7, join as join29, relative as relative6, sep as sep7 } from "path";
5125
+ import { basename as basename5, dirname as dirname7, join as join29, relative as relative7, sep as sep8 } from "path";
5115
5126
  var LEGACY_ANCHOR_FILE2 = ".claude/CLAUDE.md";
5116
5127
  function buildUpdateSpec(projectDir, tracks, only) {
5117
5128
  const log = readInstallLog(projectDir);
@@ -5225,7 +5236,8 @@ function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
5225
5236
  harnessRoot,
5226
5237
  legacyDroppedKeys(logAtStart),
5227
5238
  harnessMcp,
5228
- report.skillsSkippedLinks.filter((id) => linksToProjectSharedSkill(projectDir, id))
5239
+ report.skillsSkippedLinks.filter((id) => linksToProjectSharedSkill(projectDir, id)),
5240
+ harness.wrote
5229
5241
  ) : {
5230
5242
  externalUpdated: 0,
5231
5243
  externalBackedUp: [],
@@ -5727,7 +5739,7 @@ function updateHarnessFiles(args) {
5727
5739
  function removedRow(projectDir, path, why, judged, backupAbs) {
5728
5740
  const { line, recorded: recorded2 } = judged;
5729
5741
  if (backupAbs === null) return { path, verdict: "remove", recorded: recorded2, line: `${why} \u2014 ${line}` };
5730
- const backup = relative6(projectDir, backupAbs).split(sep7).join("/");
5742
+ const backup = relative7(projectDir, backupAbs).split(sep8).join("/");
5731
5743
  return {
5732
5744
  path,
5733
5745
  verdict: "backup+remove",
@@ -5884,7 +5896,7 @@ function syncHarnessAnchor(projectDir, templatesDir, report, outside, judged, no
5884
5896
  if (!owned) {
5885
5897
  const backup = backupFile(anchor, now);
5886
5898
  report.anchorBackedUp = true;
5887
- const rel = relative6(projectDir, backup).split(sep7).join("/");
5899
+ const rel = relative7(projectDir, backup).split(sep8).join("/");
5888
5900
  const rec = recorded2?.path === HARNESS_ANCHOR_FILE ? { state: "sha", sha256: recorded2.sha256 } : { state: "no-sha" };
5889
5901
  const next = readFileSync21(templateMd, "utf8");
5890
5902
  const { line } = judge({ op: "write", kind: "harness", rec, disk: current, next });
@@ -6058,7 +6070,7 @@ function changedRemoteMcp(writes) {
6058
6070
  const changed = /* @__PURE__ */ new Set([...mcp.added, ...mcp.replaced ?? []]);
6059
6071
  return (mcp.remote ?? []).filter((r) => changed.has(r.name));
6060
6072
  }
6061
- function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, linkedIds) {
6073
+ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, linkedIds, harnessWrote) {
6062
6074
  const log = readInstallLog(projectDir);
6063
6075
  const presentBefore = sharedSkillIdsOnDisk(projectDir);
6064
6076
  const rulesBefore = /* @__PURE__ */ new Set();
@@ -6088,7 +6100,9 @@ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, li
6088
6100
  recordedClis: log === null ? [] : installedClis(log),
6089
6101
  // #761 B-1 — 외부 기록이 아예 없던 옛 판의 산출물은 첫 접촉이 아니라 체크섬 없는 하네스 파일이다(install 과 같은 판정).
6090
6102
  // 앞 단계(하네스 파일 쓰기)가 헬퍼만 든 `externalFiles` 를 적어도 같은 답이다 — 헬퍼는 외부 자리로 세지 않는다(B-2)
6091
- owned: recordedOwner(log)
6103
+ owned: recordedOwner(log),
6104
+ // #953 (ADR-118) — install 과 같은 인자: 이번 실행의 하네스 writer 가 이 변환 앞에서 남긴 경로(`.claude/rules/` 포인터의 근거)
6105
+ harnessWrote
6092
6106
  });
6093
6107
  const linked = refreshLinkedSkillBodies({
6094
6108
  harnessRoot,
@@ -6208,7 +6222,7 @@ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, li
6208
6222
  ],
6209
6223
  anchorRetired: result.anchorRetired,
6210
6224
  retiredCommands: (result.opencode?.retiredCommands ?? []).map(
6211
- (p2) => relative6(projectDir, p2).split(sep7).join("/")
6225
+ (p2) => relative7(projectDir, p2).split(sep8).join("/")
6212
6226
  ),
6213
6227
  anchorDisplaced,
6214
6228
  agentsMd: agentsMdNews(result.agentsMd, agentsMdBefore, priorPaths),
@@ -6330,7 +6344,7 @@ function runInstall(ctx) {
6330
6344
  JSON.parse(readFileSync22(settingsPath, "utf8"));
6331
6345
  } catch {
6332
6346
  throw new Error(
6333
- `${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`
6347
+ `${relative8(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`
6334
6348
  );
6335
6349
  }
6336
6350
  }
@@ -6427,6 +6441,9 @@ function runInstallStages(ctx, args) {
6427
6441
  ...manifestSpec,
6428
6442
  tracks: [.../* @__PURE__ */ new Set([...(previousLog?.spec.tracks ?? []).filter(isTrack), ...spec.tracks])]
6429
6443
  }).filter((r) => !isBaselineExcluded(`.claude/rules/${r}.md`, baselineExcluded)),
6444
+ // #953 (ADR-118) — 위 Claude Code 단계가 이번에 판정해 남긴 경로(같은 writer 의 원장). Codex 의 경로 룰 포인터가 `.claude/rules/`
6445
+ // 를 가리켜도 되는지의 근거다 — claude 를 안 고른 실행은 거기 룰이 없어 인라인이다
6446
+ harnessWrote: new Set(writer.ledger().writes.map((w3) => w3.path)),
6430
6447
  // #568 — Codex · OpenCode 의 MCP 서버는 `.mcp.json` 에 쓴 것과 같은 값이다.
6431
6448
  mcp: harnessMcp,
6432
6449
  previousExternal: previousLog?.externalFiles ?? [],
@@ -6976,7 +6993,7 @@ function recordInterruptedInstall(ctx, error, run) {
6976
6993
  const codexTrust = registeredTrust(journal.codexOptIn, ctx.projectDir);
6977
6994
  const written = writtenSoFar(ledger, cliFiles, rootFiles, stage.rootImportWritten);
6978
6995
  if (codexTrust) written.push(`${codexTrust.configPath} (Codex trust entry for this folder)`);
6979
- const projectRel = (abs) => relative7(ctx.projectDir, abs).split(sep8).join("/");
6996
+ const projectRel = (abs) => relative8(ctx.projectDir, abs).split(sep9).join("/");
6980
6997
  const writtenSet = new Set(written);
6981
6998
  const backups = [...own.backups, ...journal.backups].map((abs) => {
6982
6999
  const original = projectRel(backupOriginal(abs) ?? abs);
@@ -7158,7 +7175,7 @@ function shellArg(s) {
7158
7175
  // src/commands/install-render.ts
7159
7176
  init_esm_shims();
7160
7177
  import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "fs";
7161
- import { basename as basename8, join as join32, relative as relative8 } from "path";
7178
+ import { basename as basename8, dirname as dirname8, join as join32, relative as relative9, sep as sep10 } from "path";
7162
7179
 
7163
7180
  // src/preset-recommend.ts
7164
7181
  init_esm_shims();
@@ -7516,7 +7533,16 @@ function rulesInsideAgentsMd(spec, cost) {
7516
7533
  ...cost,
7517
7534
  rules: outside.reduce((sum, f) => sum + fileTokens(f), 0),
7518
7535
  rulesInline: rendered ? "rendered" : "planned",
7519
- ...outside.length > 0 ? { rulesOutside: outside.length } : {},
7536
+ ...outside.length > 0 ? {
7537
+ rulesOutside: {
7538
+ count: outside.length,
7539
+ dir: [
7540
+ ...new Set(
7541
+ outside.map((f) => relative9(spec.projectDir, dirname8(f)).split(sep10).join("/"))
7542
+ )
7543
+ ].join(" \xB7 ")
7544
+ }
7545
+ } : {},
7520
7546
  contextNote: "whole file, incl. your text"
7521
7547
  });
7522
7548
  }
@@ -7524,7 +7550,7 @@ function pointedRuleFiles(spec) {
7524
7550
  if (!rulesInline(spec)) return [];
7525
7551
  const agents = join32(spec.projectDir, "AGENTS.md");
7526
7552
  if (!existsSync22(agents)) return [];
7527
- return pathRulePointerTargets(readFileSync24(agents, "utf8")).map((name) => join32(spec.projectDir, ".agents", "rules", `${name}.md`)).filter((f) => existsSync22(f));
7553
+ return pathRulePointerTargets(readFileSync24(agents, "utf8")).map((rel) => join32(spec.projectDir, rel)).filter((f) => existsSync22(f));
7528
7554
  }
7529
7555
  function rulesInline(spec) {
7530
7556
  if (!spec.cli.includes("codex") && !spec.cli.includes("opencode")) return false;
@@ -8590,7 +8616,7 @@ function renderInterruptedInstall(err, e2, cwd = process.cwd()) {
8590
8616
  }
8591
8617
  const { path, error } = e2.record;
8592
8618
  err(
8593
- path !== null ? ` Already in place before it stopped \u2014 recorded in ${relative8(cwd, path) || path}:` : " Already in place before it stopped:"
8619
+ path !== null ? ` Already in place before it stopped \u2014 recorded in ${relative9(cwd, path) || path}:` : " Already in place before it stopped:"
8594
8620
  );
8595
8621
  for (const [key, n] of groups) {
8596
8622
  err(` ${key.endsWith("/") ? `${key} (${n} file${n === 1 ? "" : "s"})` : key}`);
@@ -9064,7 +9090,7 @@ import {
9064
9090
  statSync as statSync4,
9065
9091
  writeFileSync as writeFileSync8
9066
9092
  } from "fs";
9067
- import { dirname as dirname8, join as join34, relative as relative9, resolve as resolve4, sep as sep9 } from "path";
9093
+ import { dirname as dirname9, join as join34, relative as relative10, resolve as resolve4, sep as sep11 } from "path";
9068
9094
 
9069
9095
  // src/track-removal.ts
9070
9096
  init_esm_shims();
@@ -10891,9 +10917,7 @@ function uninstallAction(options, deps = {}) {
10891
10917
  }
10892
10918
  const blocked = unwritablePaths({ projectDir, installLog, targetAssets, selectedIds });
10893
10919
  if (blocked.length > 0) {
10894
- err(status.failure(c.red("ERROR: uninstall cannot write here \u2014 nothing was removed:")));
10895
- for (const p2 of blocked) err(c.dim(` \xB7 ${p2 === "." ? "the project folder" : p2}`));
10896
- err(c.dim(" Fix the permissions, then run the same command again."));
10920
+ reportUnwritable(blocked, err);
10897
10921
  exit(1);
10898
10922
  return;
10899
10923
  }
@@ -11009,7 +11033,7 @@ function unwritablePaths(ctx) {
11009
11033
  if (!safeExists(abs)) return;
11010
11034
  const real = safeRealpath(abs);
11011
11035
  if (real !== null && isOutsideProject(projectDir, real)) return;
11012
- need.add(dirname8(path));
11036
+ need.add(dirname9(path));
11013
11037
  };
11014
11038
  for (const a of project)
11015
11039
  if (a.method === "skill") for (const f of a.files ?? []) parentOf(f.path);
@@ -11025,7 +11049,10 @@ function unwritablePaths(ctx) {
11025
11049
  for (const f of installLog.rootFiles ?? []) if (f.change === "displaced") parentOf(f.path);
11026
11050
  if (hasRootImport(projectDir)) need.add("CLAUDE.md");
11027
11051
  }
11028
- return [...need].filter((p2) => {
11052
+ return notWritable(projectDir, [...need]);
11053
+ }
11054
+ function notWritable(projectDir, paths) {
11055
+ return paths.filter((p2) => {
11029
11056
  try {
11030
11057
  accessSync2(join34(projectDir, p2), fsConstants2.W_OK);
11031
11058
  return false;
@@ -11034,6 +11061,11 @@ function unwritablePaths(ctx) {
11034
11061
  }
11035
11062
  });
11036
11063
  }
11064
+ function reportUnwritable(blocked, err) {
11065
+ err(status.failure(c.red("ERROR: uninstall cannot write here \u2014 nothing was removed:")));
11066
+ for (const p2 of blocked) err(c.dim(` \xB7 ${p2 === "." ? "the project folder" : p2}`));
11067
+ err(c.dim(" Fix the permissions, then run the same command again."));
11068
+ }
11037
11069
  function safeExists(abs) {
11038
11070
  try {
11039
11071
  lstatSync8(abs);
@@ -11387,8 +11419,7 @@ function keptForRemainingLines(plan, preview) {
11387
11419
  function displayNames(clis) {
11388
11420
  return clis.map((c3) => CLI_DISPLAY_NAMES[c3]).join(" \xB7 ");
11389
11421
  }
11390
- function agentsMdRerenderSet(target, remaining, log, projectDir) {
11391
- if (target !== null && !isAgentsMdCli(target)) return null;
11422
+ function agentsMdRerenderSet(remaining, log, projectDir) {
11392
11423
  const set = agentsMdClis(remaining);
11393
11424
  if (set.length === 0) return null;
11394
11425
  const recorded2 = (log.externalFiles ?? []).some((f) => f.path === AGENTS_MD2) || (log.portions ?? []).some((p2) => p2.path === AGENTS_MD2);
@@ -11505,6 +11536,14 @@ function runScopedRemoval(ctx, io, plan) {
11505
11536
  ""
11506
11537
  ];
11507
11538
  for (const line of header) io.log(line);
11539
+ if (!preview && plan.rerenderSet !== null) {
11540
+ const blocked = notWritable(projectDir, [AGENTS_MD2]);
11541
+ if (blocked.length > 0) {
11542
+ reportUnwritable(blocked, io.err);
11543
+ io.exit(1);
11544
+ return;
11545
+ }
11546
+ }
11508
11547
  const done = removeHarnessFiles(installLog, projectDir, plan.scope, {
11509
11548
  rm: preview ? () => {
11510
11549
  } : io.rm,
@@ -11576,7 +11615,7 @@ function removeCliAction(ctx, io) {
11576
11615
  ...keptForRemainingLines(plan, preview),
11577
11616
  ...assetsLeftLines(installLog, projectDir, plan.scope)
11578
11617
  ],
11579
- rerenderSet: agentsMdRerenderSet(target, remaining, installLog, projectDir),
11618
+ rerenderSet: agentsMdRerenderSet(remaining, installLog, projectDir),
11580
11619
  settle: (done) => settleCliLog(ctx, target, remaining, done, done.anchor.removed)
11581
11620
  });
11582
11621
  }
@@ -11598,7 +11637,7 @@ function removeTrackAction(ctx, io) {
11598
11637
  remaining: removal.remaining,
11599
11638
  scope: { ...TRACK_SCOPE, has: removal.has },
11600
11639
  leftLines: (preview, done) => preview ? trackNotes(ctx, removal, done, false).map((l) => ` \u25CB ${l}`) : trackNotes(ctx, removal, done, true),
11601
- rerenderSet: agentsMdRerenderSet(null, installedClis(installLog), installLog, projectDir),
11640
+ rerenderSet: agentsMdRerenderSet(installedClis(installLog), installLog, projectDir),
11602
11641
  settle: (done) => settleTrackLog(ctx, target, removal.remaining, done)
11603
11642
  });
11604
11643
  }
@@ -11994,7 +12033,7 @@ function removeHarnessFiles(log, projectDir, scope, io) {
11994
12033
  write: io.write
11995
12034
  });
11996
12035
  if (io.write) {
11997
- for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, p2)));
12036
+ for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname9(join34(projectDir, p2)));
11998
12037
  for (const d2 of scope.skeleton) {
11999
12038
  const abs = join34(projectDir, d2);
12000
12039
  if (outsideProjectTarget(projectDir, abs) !== null) continue;
@@ -12102,7 +12141,7 @@ function removeRecordedFile(path, ctx) {
12102
12141
  if (verdict.verdict !== "remove" && verdict.verdict !== "backup+remove") return;
12103
12142
  let backup = null;
12104
12143
  if (verdict.verdict === "backup+remove") {
12105
- backup = io.write ? relative9(projectDir, backupFile(effective)).split(sep9).join("/") : `${relative9(projectDir, effective).split(sep9).join("/")}.backup-<time>`;
12144
+ backup = io.write ? relative10(projectDir, backupFile(effective)).split(sep11).join("/") : `${relative10(projectDir, effective).split(sep11).join("/")}.backup-<time>`;
12106
12145
  }
12107
12146
  if (io.write) {
12108
12147
  if (effective !== abs) io.rm(abs);
@@ -12515,7 +12554,7 @@ function removeAnchor(log, projectDir, io) {
12515
12554
  ]
12516
12555
  };
12517
12556
  }
12518
- const backup = edited ? relative9(projectDir, backupFile(abs)).split(sep9).join("/") : null;
12557
+ const backup = edited ? relative10(projectDir, backupFile(abs)).split(sep11).join("/") : null;
12519
12558
  io.rm(abs);
12520
12559
  return {
12521
12560
  removed: true,
@@ -12578,7 +12617,7 @@ function removeLegacyAgentsMd(path, abs, effective, strip, ctx) {
12578
12617
  let backup = `${path}.backup-<time>`;
12579
12618
  try {
12580
12619
  if (io.write) {
12581
- backup = relative9(projectDir, backupFile(effective)).split(sep9).join("/");
12620
+ backup = relative10(projectDir, backupFile(effective)).split(sep11).join("/");
12582
12621
  if (strip.remainder !== null) {
12583
12622
  writeFileSync8(effective, neutralizeScaffoldBanner(strip.remainder), "utf8");
12584
12623
  } else {
@@ -12756,7 +12795,7 @@ function removeToolFiles(files, projectDir, rm) {
12756
12795
  try {
12757
12796
  if (hashContent(readFileSync26(abs, "utf8")) !== sha256) {
12758
12797
  const backup = backupFile(abs);
12759
- notes.push(`backed up ${path} \u2192 ${relative9(projectDir, backup)} (changed since install)`);
12798
+ notes.push(`backed up ${path} \u2192 ${relative10(projectDir, backup)} (changed since install)`);
12760
12799
  }
12761
12800
  rm(abs);
12762
12801
  removed.push(path);
@@ -12765,21 +12804,21 @@ function removeToolFiles(files, projectDir, rm) {
12765
12804
  notes.push(`left ${path} \u2014 ${e2 instanceof Error ? e2.message : String(e2)}`);
12766
12805
  }
12767
12806
  }
12768
- for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, path)));
12807
+ for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname9(join34(projectDir, path)));
12769
12808
  return failed > 0 ? { ok: false, message: `${failed} file(s) could not be removed`, notes } : { ok: true, notes };
12770
12809
  }
12771
12810
  function pruneEmptyDirsUpward(projectDir, startDir) {
12772
12811
  let cursor = startDir;
12773
12812
  while (true) {
12774
- const rel = relative9(projectDir, cursor);
12775
- if (rel === "" || rel.startsWith(`..${sep9}`) || rel === "..") return;
12813
+ const rel = relative10(projectDir, cursor);
12814
+ if (rel === "" || rel.startsWith(`..${sep11}`) || rel === "..") return;
12776
12815
  try {
12777
12816
  if (readdirSync7(cursor).length > 0) return;
12778
12817
  rmdirSync3(cursor);
12779
12818
  } catch {
12780
12819
  return;
12781
12820
  }
12782
- cursor = dirname8(cursor);
12821
+ cursor = dirname9(cursor);
12783
12822
  }
12784
12823
  }
12785
12824
  function stripRootImport(projectDir) {