@uzysjung/agent-harness 26.181.0 → 26.183.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
@@ -73,6 +73,7 @@ import {
73
73
  excludedKeys,
74
74
  experimentalOptInCandidates,
75
75
  extractFrontmatter,
76
+ fileTokens,
76
77
  filterApplicableAssets,
77
78
  findStaleHookRefs,
78
79
  formatResidentCostLine,
@@ -149,7 +150,7 @@ import {
149
150
  withoutAppleDouble,
150
151
  wrapHarnessBlock,
151
152
  writeInstallLog
152
- } from "./chunk-MIHX6XYD.js";
153
+ } from "./chunk-LVDKJMNG.js";
153
154
 
154
155
  // node_modules/sisteransi/src/index.js
155
156
  var require_src = __commonJS({
@@ -1228,6 +1229,8 @@ var SHARED_BY_ALL = (self) => [
1228
1229
  ];
1229
1230
  var CLI_OWNERSHIP = {
1230
1231
  claude: [
1232
+ // #953 (ADR-118) — Codex 의 경로 룰 포인터가 `.claude/rules/` 를 가리킬 수 있다. 이 자리를 지우는 `uninstall --cli claude` 는
1233
+ // `AGENTS.md` 재렌더(인라인)와 묶여 있다(`agentsMdRerenderSet`) — 지우는 길을 더하면 그 재렌더도 함께 묶는다
1231
1234
  { path: ".claude/", kind: "recorded", sharedWith: [] },
1232
1235
  { path: HARNESS_ANCHOR_FILE, kind: "anchor", sharedWith: [] },
1233
1236
  { path: "CLAUDE.md", kind: "import-block", sharedWith: [] },
@@ -1953,7 +1956,7 @@ function legacyGitignoreSeed(text, render, previous) {
1953
1956
  // src/installer.ts
1954
1957
  init_esm_shims();
1955
1958
  import { chmodSync as chmodSync3, existsSync as existsSync20, readdirSync as readdirSync5, readFileSync as readFileSync22, writeFileSync as writeFileSync7 } from "fs";
1956
- 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";
1957
1960
 
1958
1961
  // src/agents-md-render.ts
1959
1962
  init_esm_shims();
@@ -2136,7 +2139,7 @@ function installCiScaffold(ctx) {
2136
2139
  // src/cli-transforms.ts
2137
2140
  init_esm_shims();
2138
2141
  import { existsSync as existsSync15, readFileSync as readFileSync14 } from "fs";
2139
- import { join as join19 } from "path";
2142
+ import { join as join19, relative as relative4, sep as sep5 } from "path";
2140
2143
 
2141
2144
  // src/agents-md-transform.ts
2142
2145
  init_esm_shims();
@@ -2317,13 +2320,28 @@ function ruleHeadings(harnessRoot) {
2317
2320
  block.split("\n").filter((l) => /^## /.test(l)).map((l) => l.trim())
2318
2321
  );
2319
2322
  }
2320
- function renderRulesBlock(rules) {
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.";
2324
+ function pathRulePointerLine(rule, folder) {
2325
+ return `> - ${rule.paths.map((p2) => `\`${p2}\``).join(" \xB7 ")} \u2192 \`${folder}/${rule.name}.md\``;
2326
+ }
2327
+ var POINTER_TARGET = /^> - .+ → `((?:\.agents|\.claude)\/rules\/[^`/]+\.md)`$/;
2328
+ function pathRulePointerTargets(text) {
2329
+ return text.split("\n").flatMap((l) => POINTER_TARGET.exec(l.replace(/\r$/, ""))?.[1] ?? []);
2330
+ }
2331
+ function renderRulesBlock(rules, pathRulesViaFiles = false) {
2321
2332
  if (rules.length === 0) return "";
2322
- const ordered = [
2323
- ...rules.filter((r) => r.paths.length === 0),
2324
- ...rules.filter((r) => r.paths.length > 0)
2325
- ];
2326
- return ordered.map((r) => r.body.replace(/^#\s+/, "## ")).join("\n\n---\n\n");
2333
+ const always = rules.filter((r) => r.paths.length === 0);
2334
+ const path = rules.filter((r) => r.paths.length > 0);
2335
+ const bodies = (pathRulesViaFiles !== false ? always : [...always, ...path]).map(
2336
+ (r) => r.body.replace(/^#\s+/, "## ")
2337
+ );
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
+ ] : [];
2344
+ return [...bodies, ...pointers].join("\n\n---\n\n");
2327
2345
  }
2328
2346
 
2329
2347
  // src/shared-write.ts
@@ -2636,6 +2654,7 @@ function runAgentsMdTransform(params) {
2636
2654
  const seed = fromRoot ?? legacy;
2637
2655
  const seededFrom = fromRoot !== null ? "CLAUDE.md" : legacy !== null ? LEGACY_ANTIGRAVITY_ANCHOR : null;
2638
2656
  ensureDir(projectDir);
2657
+ const sectionsModel = agentsMdModelFor(projectDir, baseline, shared2) === "sections";
2639
2658
  const rendered = renderAgentsMd({
2640
2659
  template,
2641
2660
  claudeMd,
@@ -2645,11 +2664,12 @@ function runAgentsMdTransform(params) {
2645
2664
  seed ?? renderFillScaffold("agents-md"),
2646
2665
  skillIds
2647
2666
  ),
2648
- harnessRules: renderRulesBlock(portRules(harnessRoot, params.rules)),
2667
+ harnessRules: renderRulesBlock(
2668
+ portRules(harnessRoot, params.rules),
2669
+ sectionsModel ? params.pathRulesViaFiles : false
2670
+ ),
2649
2671
  clis,
2650
- // #944 R2-B1 — 위치 안내는 절 모델에만. 첫 접촉 블록은 늘 인라인이다 — 설치자가 블록을 고치면 굳어서, 굳은 위치 안내는 CLI
2651
- // 집합이 바뀐 뒤(Antigravity 가 빠지거나 Codex 가 들어오면) 가리킬 룰이 없다
2652
- rulesViaInstructions: params.rulesViaInstructions && agentsMdModelFor(projectDir, baseline, shared2) === "sections"
2672
+ rulesViaInstructions: params.rulesViaInstructions && sectionsModel
2653
2673
  });
2654
2674
  const agentsMd = writeAgentsMd({
2655
2675
  projectDir,
@@ -3436,12 +3456,12 @@ function adapterExcluded(harnessRoot, excluded) {
3436
3456
  }
3437
3457
  return out;
3438
3458
  }
3439
- function wroteEveryRule(harnessRoot, projectDir, report, rules) {
3440
- if (report === null) return false;
3441
- const written = new Set(report.harnessRuleFiles);
3442
- return portRules(harnessRoot, rules).every(
3443
- (r) => written.has(join19(projectDir, ".agents", "rules", `${r.name}.md`))
3444
- );
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("/")));
3445
3465
  }
3446
3466
  function mcpSources(harnessRoot) {
3447
3467
  return {
@@ -3570,8 +3590,9 @@ function runCliTransforms(params) {
3570
3590
  }
3571
3591
  let agentsMd = null;
3572
3592
  if (agentsSet.length > 0) {
3573
- const beyondThisRun = agentsSet.some((c3) => !cli.includes(c3));
3574
- 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);
3575
3596
  agentsMd = runAgentsMdTransform({
3576
3597
  harnessRoot,
3577
3598
  projectDir,
@@ -3581,7 +3602,13 @@ function runCliTransforms(params) {
3581
3602
  // #944 (ADR-116) — 룰 본문 대신 위치 안내는 이번 실행이 OpenCode 의 도달을 **보장했을 때만**(집합이 아니라 쓴 결과로):
3582
3603
  // ① Codex ∉ 집합 ② opencode 변환이 이번에 돌았다 ③ Antigravity 가 이번 룰을 전부 `.agents/rules/` 에 썼다 ④ 그 뒤
3583
3604
  // 디스크의 `opencode.json` 에 룰 원소가 있다. 하나라도 거짓이면 인라인 — OpenCode 가 룰을 0번 받는 실행은 없다
3584
- rulesViaInstructions: !agentsSet.includes("codex") && opencode?.rulesViaInstructions === true && wroteEveryRule(harnessRoot, projectDir, antigravity, agentsRules),
3605
+ rulesViaInstructions: !agentsSet.includes("codex") && opencode?.rulesViaInstructions === true && wroteAllTo(".agents/rules", agRules),
3606
+ // #948 (ADR-117) · #953 (ADR-118) — Codex 의 경로 룰은 이번 실행이 쓴 룰 파일을 가리키는 목록으로(실 Codex 포인터 15/15 ·
3607
+ // `.claude/rules/` 4/4): ① Codex ∈ 집합 ② OpenCode ∉ 집합(OpenCode 의 포인터 따르기는 재지 않았다) ③a Antigravity 가 이번 룰
3608
+ // 전부를 `.agents/rules/` 에 썼다 → 그 폴더 ③b 아니면 이번 실행의 하네스 writer(Claude Code 단계 — 이 변환 앞)가 이번 룰 전부를
3609
+ // `.claude/rules/` 에 남겼다 → 그 폴더(④ 절 모델은 변환이 본다). 대조 목록은 렌더하는 `agentsRules`(누적일 수 있다). 하나라도
3610
+ // 거짓이면 인라인 — 포인터는 이번 실행이 실재를 보장한 파일만 가리킨다
3611
+ pathRulesViaFiles: !agentsSet.includes("codex") || agentsSet.includes("opencode") ? false : wroteAllTo(".agents/rules", agRules) ? ".agents/rules" : wroteAllTo(".claude/rules", params.harnessWrote ?? null) ? ".claude/rules" : false,
3585
3612
  baseline,
3586
3613
  refreshOnly,
3587
3614
  // ADR-099 R2 — 기록이 이 파일을 읽는 CLI 를 깔린 것으로 말하면 없어도 만든다(26.164.0 이하 Antigravity 단독 설치본은
@@ -3685,7 +3712,7 @@ function holdsHarnessBytes(log, projectDir, path, isTarget = recordedTrackTarget
3685
3712
 
3686
3713
  // src/harness-slot.ts
3687
3714
  init_esm_shims();
3688
- import { isAbsolute, join as join21, posix as posix2, relative as relative4, sep as sep5 } from "path";
3715
+ import { isAbsolute, join as join21, posix as posix2, relative as relative5, sep as sep6 } from "path";
3689
3716
  var ownedOf = (...kinds) => [
3690
3717
  ...new Set(
3691
3718
  Object.values(CLI_OWNERSHIP).flat().filter((o) => kinds.includes(o.kind)).map((o) => o.path)
@@ -3712,9 +3739,9 @@ function realRel(projectDir, norm, follow) {
3712
3739
  return dir === null ? null : join21(dir, posix2.basename(norm));
3713
3740
  })();
3714
3741
  if (target === null) return null;
3715
- const rel = relative4(resolveWriteTarget(projectDir) ?? projectDir, target);
3742
+ const rel = relative5(resolveWriteTarget(projectDir) ?? projectDir, target);
3716
3743
  if (rel === "" || isAbsolute(rel)) return null;
3717
- const slash = rel.split(sep5).join("/");
3744
+ const slash = rel.split(sep6).join("/");
3718
3745
  return slash === ".." || slash.startsWith("../") ? null : slash;
3719
3746
  }
3720
3747
  function inSlotByName(path, slots = HARNESS_FILES) {
@@ -3911,7 +3938,7 @@ import {
3911
3938
  rmSync as rmSync3
3912
3939
  } from "fs";
3913
3940
  import { homedir as homedir2 } from "os";
3914
- import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join24, relative as relative5, sep as sep6 } from "path";
3941
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join24, relative as relative6, sep as sep7 } from "path";
3915
3942
  function outsideSlotNote(o) {
3916
3943
  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})`;
3917
3944
  }
@@ -4466,12 +4493,12 @@ function reclaimCopy(projectDir, slot, home, ctx) {
4466
4493
  return res.removed.length > 0 || res.left.length > 0 ? res : null;
4467
4494
  }
4468
4495
  function inCanonicalSkillRoot(projectDir, real) {
4469
- const rel = relative5(realOrNull(projectDir) ?? projectDir, real).split(sep6).join("/");
4496
+ const rel = relative6(realOrNull(projectDir) ?? projectDir, real).split(sep7).join("/");
4470
4497
  return SKILL_ROOTS.some((r) => rel.startsWith(`${r}/`));
4471
4498
  }
4472
4499
  function inProjectSpelling(projectDir, real) {
4473
- const at2 = relative5(realOrNull(projectDir) ?? projectDir, real);
4474
- return at2 === "" || at2 === ".." || at2.startsWith(`..${sep6}`) || isAbsolute2(at2) ? real : join24(projectDir, at2);
4500
+ const at2 = relative6(realOrNull(projectDir) ?? projectDir, real);
4501
+ return at2 === "" || at2 === ".." || at2.startsWith(`..${sep7}`) || isAbsolute2(at2) ? real : join24(projectDir, at2);
4475
4502
  }
4476
4503
  function realOrNull(abs) {
4477
4504
  try {
@@ -4597,7 +4624,7 @@ function inSkillFolders(projectDir, slot) {
4597
4624
  const roots = SKILL_ROOTS.flatMap((r) => {
4598
4625
  const real = resolveWriteTarget(join24(projectDir, r));
4599
4626
  if (real === null) return [r];
4600
- const rel = relative5(base, real).split(sep6).join("/");
4627
+ const rel = relative6(base, real).split(sep7).join("/");
4601
4628
  return rel === "" || rel === ".." || rel.startsWith("../") || isAbsolute2(rel) ? [r] : [r, rel];
4602
4629
  });
4603
4630
  const places = [...new Set(roots.map((r) => name === "" ? `${r}/` : `${r}/${name}/`))];
@@ -4655,7 +4682,7 @@ function pruneEmptyDirs(dir) {
4655
4682
  }
4656
4683
  }
4657
4684
  function toProjectRel(projectDir, abs) {
4658
- return relative5(projectDir, abs).split(sep6).join("/");
4685
+ return relative6(projectDir, abs).split(sep7).join("/");
4659
4686
  }
4660
4687
  function recordRefreshedFiles(projectDir, log, report, displaced, writeLog) {
4661
4688
  const next = new Map(
@@ -5094,7 +5121,7 @@ import {
5094
5121
  unlinkSync as unlinkSync2,
5095
5122
  writeFileSync as writeFileSync6
5096
5123
  } from "fs";
5097
- import { basename as basename5, dirname as dirname7, join as join29, relative as relative6, sep as sep7 } from "path";
5124
+ import { basename as basename5, dirname as dirname7, join as join29, relative as relative7, sep as sep8 } from "path";
5098
5125
  var LEGACY_ANCHOR_FILE2 = ".claude/CLAUDE.md";
5099
5126
  function buildUpdateSpec(projectDir, tracks, only) {
5100
5127
  const log = readInstallLog(projectDir);
@@ -5208,7 +5235,8 @@ function runUpdateMode(projectDir, templatesDir, harnessRoot, deps = {}, only) {
5208
5235
  harnessRoot,
5209
5236
  legacyDroppedKeys(logAtStart),
5210
5237
  harnessMcp,
5211
- report.skillsSkippedLinks.filter((id) => linksToProjectSharedSkill(projectDir, id))
5238
+ report.skillsSkippedLinks.filter((id) => linksToProjectSharedSkill(projectDir, id)),
5239
+ harness.wrote
5212
5240
  ) : {
5213
5241
  externalUpdated: 0,
5214
5242
  externalBackedUp: [],
@@ -5710,7 +5738,7 @@ function updateHarnessFiles(args) {
5710
5738
  function removedRow(projectDir, path, why, judged, backupAbs) {
5711
5739
  const { line, recorded: recorded2 } = judged;
5712
5740
  if (backupAbs === null) return { path, verdict: "remove", recorded: recorded2, line: `${why} \u2014 ${line}` };
5713
- const backup = relative6(projectDir, backupAbs).split(sep7).join("/");
5741
+ const backup = relative7(projectDir, backupAbs).split(sep8).join("/");
5714
5742
  return {
5715
5743
  path,
5716
5744
  verdict: "backup+remove",
@@ -5867,7 +5895,7 @@ function syncHarnessAnchor(projectDir, templatesDir, report, outside, judged, no
5867
5895
  if (!owned) {
5868
5896
  const backup = backupFile(anchor, now);
5869
5897
  report.anchorBackedUp = true;
5870
- const rel = relative6(projectDir, backup).split(sep7).join("/");
5898
+ const rel = relative7(projectDir, backup).split(sep8).join("/");
5871
5899
  const rec = recorded2?.path === HARNESS_ANCHOR_FILE ? { state: "sha", sha256: recorded2.sha256 } : { state: "no-sha" };
5872
5900
  const next = readFileSync21(templateMd, "utf8");
5873
5901
  const { line } = judge({ op: "write", kind: "harness", rec, disk: current, next });
@@ -6041,7 +6069,7 @@ function changedRemoteMcp(writes) {
6041
6069
  const changed = /* @__PURE__ */ new Set([...mcp.added, ...mcp.replaced ?? []]);
6042
6070
  return (mcp.remote ?? []).filter((r) => changed.has(r.name));
6043
6071
  }
6044
- function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, linkedIds) {
6072
+ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, linkedIds, harnessWrote) {
6045
6073
  const log = readInstallLog(projectDir);
6046
6074
  const presentBefore = sharedSkillIdsOnDisk(projectDir);
6047
6075
  const rulesBefore = /* @__PURE__ */ new Set();
@@ -6071,7 +6099,9 @@ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, li
6071
6099
  recordedClis: log === null ? [] : installedClis(log),
6072
6100
  // #761 B-1 — 외부 기록이 아예 없던 옛 판의 산출물은 첫 접촉이 아니라 체크섬 없는 하네스 파일이다(install 과 같은 판정).
6073
6101
  // 앞 단계(하네스 파일 쓰기)가 헬퍼만 든 `externalFiles` 를 적어도 같은 답이다 — 헬퍼는 외부 자리로 세지 않는다(B-2)
6074
- owned: recordedOwner(log)
6102
+ owned: recordedOwner(log),
6103
+ // #953 (ADR-118) — install 과 같은 인자: 이번 실행의 하네스 writer 가 이 변환 앞에서 남긴 경로(`.claude/rules/` 포인터의 근거)
6104
+ harnessWrote
6075
6105
  });
6076
6106
  const linked = refreshLinkedSkillBodies({
6077
6107
  harnessRoot,
@@ -6191,7 +6221,7 @@ function refreshExternalCli(projectDir, harnessRoot, droppedKeys, harnessMcp, li
6191
6221
  ],
6192
6222
  anchorRetired: result.anchorRetired,
6193
6223
  retiredCommands: (result.opencode?.retiredCommands ?? []).map(
6194
- (p2) => relative6(projectDir, p2).split(sep7).join("/")
6224
+ (p2) => relative7(projectDir, p2).split(sep8).join("/")
6195
6225
  ),
6196
6226
  anchorDisplaced,
6197
6227
  agentsMd: agentsMdNews(result.agentsMd, agentsMdBefore, priorPaths),
@@ -6313,7 +6343,7 @@ function runInstall(ctx) {
6313
6343
  JSON.parse(readFileSync22(settingsPath, "utf8"));
6314
6344
  } catch {
6315
6345
  throw new Error(
6316
- `${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`
6346
+ `${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`
6317
6347
  );
6318
6348
  }
6319
6349
  }
@@ -6410,6 +6440,9 @@ function runInstallStages(ctx, args) {
6410
6440
  ...manifestSpec,
6411
6441
  tracks: [.../* @__PURE__ */ new Set([...(previousLog?.spec.tracks ?? []).filter(isTrack), ...spec.tracks])]
6412
6442
  }).filter((r) => !isBaselineExcluded(`.claude/rules/${r}.md`, baselineExcluded)),
6443
+ // #953 (ADR-118) — 위 Claude Code 단계가 이번에 판정해 남긴 경로(같은 writer 의 원장). Codex 의 경로 룰 포인터가 `.claude/rules/`
6444
+ // 를 가리켜도 되는지의 근거다 — claude 를 안 고른 실행은 거기 룰이 없어 인라인이다
6445
+ harnessWrote: new Set(writer.ledger().writes.map((w3) => w3.path)),
6413
6446
  // #568 — Codex · OpenCode 의 MCP 서버는 `.mcp.json` 에 쓴 것과 같은 값이다.
6414
6447
  mcp: harnessMcp,
6415
6448
  previousExternal: previousLog?.externalFiles ?? [],
@@ -6959,7 +6992,7 @@ function recordInterruptedInstall(ctx, error, run) {
6959
6992
  const codexTrust = registeredTrust(journal.codexOptIn, ctx.projectDir);
6960
6993
  const written = writtenSoFar(ledger, cliFiles, rootFiles, stage.rootImportWritten);
6961
6994
  if (codexTrust) written.push(`${codexTrust.configPath} (Codex trust entry for this folder)`);
6962
- const projectRel = (abs) => relative7(ctx.projectDir, abs).split(sep8).join("/");
6995
+ const projectRel = (abs) => relative8(ctx.projectDir, abs).split(sep9).join("/");
6963
6996
  const writtenSet = new Set(written);
6964
6997
  const backups = [...own.backups, ...journal.backups].map((abs) => {
6965
6998
  const original = projectRel(backupOriginal(abs) ?? abs);
@@ -7141,7 +7174,7 @@ function shellArg(s) {
7141
7174
  // src/commands/install-render.ts
7142
7175
  init_esm_shims();
7143
7176
  import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "fs";
7144
- import { join as join32, relative as relative8 } from "path";
7177
+ import { basename as basename8, dirname as dirname8, join as join32, relative as relative9, sep as sep10 } from "path";
7145
7178
 
7146
7179
  // src/preset-recommend.ts
7147
7180
  init_esm_shims();
@@ -7460,7 +7493,17 @@ function residentEntriesOnDisk(spec) {
7460
7493
  file: join32(abs, e2.name)
7461
7494
  })) : [];
7462
7495
  };
7463
- const rules = surface === "claude" ? mdFiles(join32(".claude", "rules"), "rules") : rulesInline(spec) ? planned.filter((e2) => e2.target.startsWith(".claude/rules/")) : mdFiles(join32(".agents", "rules"), "rules", "uzys-harness.md");
7496
+ const pointed = pointedRuleFiles(spec);
7497
+ const rules = surface === "claude" ? mdFiles(join32(".claude", "rules"), "rules") : rulesInline(spec) ? [
7498
+ ...planned.filter(
7499
+ (e2) => e2.target.startsWith(".claude/rules/") && !pointed.some((f) => f.endsWith(`/${e2.target.slice(".claude/rules/".length)}`))
7500
+ ),
7501
+ ...pointed.map((f) => ({
7502
+ source: `rules/${basename8(f)}`,
7503
+ target: `.claude/rules/${basename8(f)}`,
7504
+ file: f
7505
+ }))
7506
+ ] : mdFiles(join32(".agents", "rules"), "rules", "uzys-harness.md");
7464
7507
  const slot = hasClaude ? join32(".claude", "skills") : join32(".agents", "skills");
7465
7508
  const skills = planned.filter((e2) => e2.target.startsWith(".claude/skills/")).map((e2) => ({
7466
7509
  ...e2,
@@ -7484,13 +7527,30 @@ function contextFilesOnDisk(spec) {
7484
7527
  function rulesInsideAgentsMd(spec, cost) {
7485
7528
  if (anchorSurface(spec.cli).scaffold !== "agents-md" || !rulesInline(spec)) return cost;
7486
7529
  const rendered = spec.updateOnly === void 0 || spec.updateOnly.includes("external");
7530
+ const outside = pointedRuleFiles(spec);
7487
7531
  return makeResidentCost({
7488
7532
  ...cost,
7489
- rules: 0,
7533
+ rules: outside.reduce((sum, f) => sum + fileTokens(f), 0),
7490
7534
  rulesInline: rendered ? "rendered" : "planned",
7535
+ ...outside.length > 0 ? {
7536
+ rulesOutside: {
7537
+ count: outside.length,
7538
+ dir: [
7539
+ ...new Set(
7540
+ outside.map((f) => relative9(spec.projectDir, dirname8(f)).split(sep10).join("/"))
7541
+ )
7542
+ ].join(" \xB7 ")
7543
+ }
7544
+ } : {},
7491
7545
  contextNote: "whole file, incl. your text"
7492
7546
  });
7493
7547
  }
7548
+ function pointedRuleFiles(spec) {
7549
+ if (!rulesInline(spec)) return [];
7550
+ const agents = join32(spec.projectDir, "AGENTS.md");
7551
+ if (!existsSync22(agents)) return [];
7552
+ return pathRulePointerTargets(readFileSync24(agents, "utf8")).map((rel) => join32(spec.projectDir, rel)).filter((f) => existsSync22(f));
7553
+ }
7494
7554
  function rulesInline(spec) {
7495
7555
  if (!spec.cli.includes("codex") && !spec.cli.includes("opencode")) return false;
7496
7556
  const agents = join32(spec.projectDir, "AGENTS.md");
@@ -8555,7 +8615,7 @@ function renderInterruptedInstall(err, e2, cwd = process.cwd()) {
8555
8615
  }
8556
8616
  const { path, error } = e2.record;
8557
8617
  err(
8558
- path !== null ? ` Already in place before it stopped \u2014 recorded in ${relative8(cwd, path) || path}:` : " Already in place before it stopped:"
8618
+ path !== null ? ` Already in place before it stopped \u2014 recorded in ${relative9(cwd, path) || path}:` : " Already in place before it stopped:"
8559
8619
  );
8560
8620
  for (const [key, n] of groups) {
8561
8621
  err(` ${key.endsWith("/") ? `${key} (${n} file${n === 1 ? "" : "s"})` : key}`);
@@ -9029,7 +9089,7 @@ import {
9029
9089
  statSync as statSync4,
9030
9090
  writeFileSync as writeFileSync8
9031
9091
  } from "fs";
9032
- import { dirname as dirname8, join as join34, relative as relative9, resolve as resolve4, sep as sep9 } from "path";
9092
+ import { dirname as dirname9, join as join34, relative as relative10, resolve as resolve4, sep as sep11 } from "path";
9033
9093
 
9034
9094
  // src/track-removal.ts
9035
9095
  init_esm_shims();
@@ -10856,9 +10916,7 @@ function uninstallAction(options, deps = {}) {
10856
10916
  }
10857
10917
  const blocked = unwritablePaths({ projectDir, installLog, targetAssets, selectedIds });
10858
10918
  if (blocked.length > 0) {
10859
- err(status.failure(c.red("ERROR: uninstall cannot write here \u2014 nothing was removed:")));
10860
- for (const p2 of blocked) err(c.dim(` \xB7 ${p2 === "." ? "the project folder" : p2}`));
10861
- err(c.dim(" Fix the permissions, then run the same command again."));
10919
+ reportUnwritable(blocked, err);
10862
10920
  exit(1);
10863
10921
  return;
10864
10922
  }
@@ -10974,7 +11032,7 @@ function unwritablePaths(ctx) {
10974
11032
  if (!safeExists(abs)) return;
10975
11033
  const real = safeRealpath(abs);
10976
11034
  if (real !== null && isOutsideProject(projectDir, real)) return;
10977
- need.add(dirname8(path));
11035
+ need.add(dirname9(path));
10978
11036
  };
10979
11037
  for (const a of project)
10980
11038
  if (a.method === "skill") for (const f of a.files ?? []) parentOf(f.path);
@@ -10990,7 +11048,10 @@ function unwritablePaths(ctx) {
10990
11048
  for (const f of installLog.rootFiles ?? []) if (f.change === "displaced") parentOf(f.path);
10991
11049
  if (hasRootImport(projectDir)) need.add("CLAUDE.md");
10992
11050
  }
10993
- return [...need].filter((p2) => {
11051
+ return notWritable(projectDir, [...need]);
11052
+ }
11053
+ function notWritable(projectDir, paths) {
11054
+ return paths.filter((p2) => {
10994
11055
  try {
10995
11056
  accessSync2(join34(projectDir, p2), fsConstants2.W_OK);
10996
11057
  return false;
@@ -10999,6 +11060,11 @@ function unwritablePaths(ctx) {
10999
11060
  }
11000
11061
  });
11001
11062
  }
11063
+ function reportUnwritable(blocked, err) {
11064
+ err(status.failure(c.red("ERROR: uninstall cannot write here \u2014 nothing was removed:")));
11065
+ for (const p2 of blocked) err(c.dim(` \xB7 ${p2 === "." ? "the project folder" : p2}`));
11066
+ err(c.dim(" Fix the permissions, then run the same command again."));
11067
+ }
11002
11068
  function safeExists(abs) {
11003
11069
  try {
11004
11070
  lstatSync8(abs);
@@ -11352,8 +11418,7 @@ function keptForRemainingLines(plan, preview) {
11352
11418
  function displayNames(clis) {
11353
11419
  return clis.map((c3) => CLI_DISPLAY_NAMES[c3]).join(" \xB7 ");
11354
11420
  }
11355
- function agentsMdRerenderSet(target, remaining, log, projectDir) {
11356
- if (target !== null && !isAgentsMdCli(target)) return null;
11421
+ function agentsMdRerenderSet(remaining, log, projectDir) {
11357
11422
  const set = agentsMdClis(remaining);
11358
11423
  if (set.length === 0) return null;
11359
11424
  const recorded2 = (log.externalFiles ?? []).some((f) => f.path === AGENTS_MD2) || (log.portions ?? []).some((p2) => p2.path === AGENTS_MD2);
@@ -11380,6 +11445,8 @@ function rerenderAgentsMd(ctx, set, log) {
11380
11445
  // #944 (ADR-116) — 이 경로는 `opencode.json` 을 쓰지 않아 OpenCode 의 도달을 보장하지 못한다 — 늘 인라인. 다음 update 가
11381
11446
  // 조건이 맞으면 위치 안내로 되돌린다(ADR-103 결정 2 의 "다음 update 와 같은 바이트" 는 이 경우에 깨진다 — ADR-116)
11382
11447
  rulesViaInstructions: false,
11448
+ // #948 (ADR-117) — 같은 이유로 `.agents/rules/` 를 이번에 쓰지 않는다 — 경로 룰도 인라인
11449
+ pathRulesViaFiles: false,
11383
11450
  baseline: new Map((log.externalFiles ?? []).map((f) => [f.path, f.sha256])),
11384
11451
  refreshOnly: true,
11385
11452
  installedByRecord: true,
@@ -11468,6 +11535,14 @@ function runScopedRemoval(ctx, io, plan) {
11468
11535
  ""
11469
11536
  ];
11470
11537
  for (const line of header) io.log(line);
11538
+ if (!preview && plan.rerenderSet !== null) {
11539
+ const blocked = notWritable(projectDir, [AGENTS_MD2]);
11540
+ if (blocked.length > 0) {
11541
+ reportUnwritable(blocked, io.err);
11542
+ io.exit(1);
11543
+ return;
11544
+ }
11545
+ }
11471
11546
  const done = removeHarnessFiles(installLog, projectDir, plan.scope, {
11472
11547
  rm: preview ? () => {
11473
11548
  } : io.rm,
@@ -11539,7 +11614,7 @@ function removeCliAction(ctx, io) {
11539
11614
  ...keptForRemainingLines(plan, preview),
11540
11615
  ...assetsLeftLines(installLog, projectDir, plan.scope)
11541
11616
  ],
11542
- rerenderSet: agentsMdRerenderSet(target, remaining, installLog, projectDir),
11617
+ rerenderSet: agentsMdRerenderSet(remaining, installLog, projectDir),
11543
11618
  settle: (done) => settleCliLog(ctx, target, remaining, done, done.anchor.removed)
11544
11619
  });
11545
11620
  }
@@ -11561,7 +11636,7 @@ function removeTrackAction(ctx, io) {
11561
11636
  remaining: removal.remaining,
11562
11637
  scope: { ...TRACK_SCOPE, has: removal.has },
11563
11638
  leftLines: (preview, done) => preview ? trackNotes(ctx, removal, done, false).map((l) => ` \u25CB ${l}`) : trackNotes(ctx, removal, done, true),
11564
- rerenderSet: agentsMdRerenderSet(null, installedClis(installLog), installLog, projectDir),
11639
+ rerenderSet: agentsMdRerenderSet(installedClis(installLog), installLog, projectDir),
11565
11640
  settle: (done) => settleTrackLog(ctx, target, removal.remaining, done)
11566
11641
  });
11567
11642
  }
@@ -11957,7 +12032,7 @@ function removeHarnessFiles(log, projectDir, scope, io) {
11957
12032
  write: io.write
11958
12033
  });
11959
12034
  if (io.write) {
11960
- for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, p2)));
12035
+ for (const p2 of pruneFrom) pruneEmptyDirsUpward(projectDir, dirname9(join34(projectDir, p2)));
11961
12036
  for (const d2 of scope.skeleton) {
11962
12037
  const abs = join34(projectDir, d2);
11963
12038
  if (outsideProjectTarget(projectDir, abs) !== null) continue;
@@ -12065,7 +12140,7 @@ function removeRecordedFile(path, ctx) {
12065
12140
  if (verdict.verdict !== "remove" && verdict.verdict !== "backup+remove") return;
12066
12141
  let backup = null;
12067
12142
  if (verdict.verdict === "backup+remove") {
12068
- backup = io.write ? relative9(projectDir, backupFile(effective)).split(sep9).join("/") : `${relative9(projectDir, effective).split(sep9).join("/")}.backup-<time>`;
12143
+ backup = io.write ? relative10(projectDir, backupFile(effective)).split(sep11).join("/") : `${relative10(projectDir, effective).split(sep11).join("/")}.backup-<time>`;
12069
12144
  }
12070
12145
  if (io.write) {
12071
12146
  if (effective !== abs) io.rm(abs);
@@ -12478,7 +12553,7 @@ function removeAnchor(log, projectDir, io) {
12478
12553
  ]
12479
12554
  };
12480
12555
  }
12481
- const backup = edited ? relative9(projectDir, backupFile(abs)).split(sep9).join("/") : null;
12556
+ const backup = edited ? relative10(projectDir, backupFile(abs)).split(sep11).join("/") : null;
12482
12557
  io.rm(abs);
12483
12558
  return {
12484
12559
  removed: true,
@@ -12541,7 +12616,7 @@ function removeLegacyAgentsMd(path, abs, effective, strip, ctx) {
12541
12616
  let backup = `${path}.backup-<time>`;
12542
12617
  try {
12543
12618
  if (io.write) {
12544
- backup = relative9(projectDir, backupFile(effective)).split(sep9).join("/");
12619
+ backup = relative10(projectDir, backupFile(effective)).split(sep11).join("/");
12545
12620
  if (strip.remainder !== null) {
12546
12621
  writeFileSync8(effective, neutralizeScaffoldBanner(strip.remainder), "utf8");
12547
12622
  } else {
@@ -12719,7 +12794,7 @@ function removeToolFiles(files, projectDir, rm) {
12719
12794
  try {
12720
12795
  if (hashContent(readFileSync26(abs, "utf8")) !== sha256) {
12721
12796
  const backup = backupFile(abs);
12722
- notes.push(`backed up ${path} \u2192 ${relative9(projectDir, backup)} (changed since install)`);
12797
+ notes.push(`backed up ${path} \u2192 ${relative10(projectDir, backup)} (changed since install)`);
12723
12798
  }
12724
12799
  rm(abs);
12725
12800
  removed.push(path);
@@ -12728,21 +12803,21 @@ function removeToolFiles(files, projectDir, rm) {
12728
12803
  notes.push(`left ${path} \u2014 ${e2 instanceof Error ? e2.message : String(e2)}`);
12729
12804
  }
12730
12805
  }
12731
- for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname8(join34(projectDir, path)));
12806
+ for (const path of removed) pruneEmptyDirsUpward(projectDir, dirname9(join34(projectDir, path)));
12732
12807
  return failed > 0 ? { ok: false, message: `${failed} file(s) could not be removed`, notes } : { ok: true, notes };
12733
12808
  }
12734
12809
  function pruneEmptyDirsUpward(projectDir, startDir) {
12735
12810
  let cursor = startDir;
12736
12811
  while (true) {
12737
- const rel = relative9(projectDir, cursor);
12738
- if (rel === "" || rel.startsWith(`..${sep9}`) || rel === "..") return;
12812
+ const rel = relative10(projectDir, cursor);
12813
+ if (rel === "" || rel.startsWith(`..${sep11}`) || rel === "..") return;
12739
12814
  try {
12740
12815
  if (readdirSync7(cursor).length > 0) return;
12741
12816
  rmdirSync3(cursor);
12742
12817
  } catch {
12743
12818
  return;
12744
12819
  }
12745
- cursor = dirname8(cursor);
12820
+ cursor = dirname9(cursor);
12746
12821
  }
12747
12822
  }
12748
12823
  function stripRootImport(projectDir) {