@uzysjung/agent-harness 26.181.0 → 26.182.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-OYXKVPAB.js";
153
154
 
154
155
  // node_modules/sisteransi/src/index.js
155
156
  var require_src = __commonJS({
@@ -2317,13 +2318,23 @@ function ruleHeadings(harnessRoot) {
2317
2318
  block.split("\n").filter((l) => /^## /.test(l)).map((l) => l.trim())
2318
2319
  );
2319
2320
  }
2320
- function renderRulesBlock(rules) {
2321
+ 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
+ }
2325
+ var POINTER_TARGET = /^> - .+ → `\.agents\/rules\/([^`/]+)\.md`$/;
2326
+ function pathRulePointerTargets(text) {
2327
+ return text.split("\n").flatMap((l) => POINTER_TARGET.exec(l.replace(/\r$/, ""))?.[1] ?? []);
2328
+ }
2329
+ function renderRulesBlock(rules, pathRulesViaFiles = false) {
2321
2330
  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");
2331
+ const always = rules.filter((r) => r.paths.length === 0);
2332
+ const path = rules.filter((r) => r.paths.length > 0);
2333
+ const bodies = (pathRulesViaFiles ? always : [...always, ...path]).map(
2334
+ (r) => r.body.replace(/^#\s+/, "## ")
2335
+ );
2336
+ const pointers = pathRulesViaFiles && path.length > 0 ? [[PATH_RULE_POINTER_LEAD, ...path.map(pathRulePointerLine)].join("\n")] : [];
2337
+ return [...bodies, ...pointers].join("\n\n---\n\n");
2327
2338
  }
2328
2339
 
2329
2340
  // src/shared-write.ts
@@ -2636,6 +2647,7 @@ function runAgentsMdTransform(params) {
2636
2647
  const seed = fromRoot ?? legacy;
2637
2648
  const seededFrom = fromRoot !== null ? "CLAUDE.md" : legacy !== null ? LEGACY_ANTIGRAVITY_ANCHOR : null;
2638
2649
  ensureDir(projectDir);
2650
+ const sectionsModel = agentsMdModelFor(projectDir, baseline, shared2) === "sections";
2639
2651
  const rendered = renderAgentsMd({
2640
2652
  template,
2641
2653
  claudeMd,
@@ -2645,11 +2657,12 @@ function runAgentsMdTransform(params) {
2645
2657
  seed ?? renderFillScaffold("agents-md"),
2646
2658
  skillIds
2647
2659
  ),
2648
- harnessRules: renderRulesBlock(portRules(harnessRoot, params.rules)),
2660
+ harnessRules: renderRulesBlock(
2661
+ portRules(harnessRoot, params.rules),
2662
+ params.pathRulesViaFiles && sectionsModel
2663
+ ),
2649
2664
  clis,
2650
- // #944 R2-B1 — 위치 안내는 절 모델에만. 첫 접촉 블록은 늘 인라인이다 — 설치자가 블록을 고치면 굳어서, 굳은 위치 안내는 CLI
2651
- // 집합이 바뀐 뒤(Antigravity 가 빠지거나 Codex 가 들어오면) 가리킬 룰이 없다
2652
- rulesViaInstructions: params.rulesViaInstructions && agentsMdModelFor(projectDir, baseline, shared2) === "sections"
2665
+ rulesViaInstructions: params.rulesViaInstructions && sectionsModel
2653
2666
  });
2654
2667
  const agentsMd = writeAgentsMd({
2655
2668
  projectDir,
@@ -3582,6 +3595,10 @@ function runCliTransforms(params) {
3582
3595
  // ① Codex ∉ 집합 ② opencode 변환이 이번에 돌았다 ③ Antigravity 가 이번 룰을 전부 `.agents/rules/` 에 썼다 ④ 그 뒤
3583
3596
  // 디스크의 `opencode.json` 에 룰 원소가 있다. 하나라도 거짓이면 인라인 — OpenCode 가 룰을 0번 받는 실행은 없다
3584
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),
3585
3602
  baseline,
3586
3603
  refreshOnly,
3587
3604
  // ADR-099 R2 — 기록이 이 파일을 읽는 CLI 를 깔린 것으로 말하면 없어도 만든다(26.164.0 이하 Antigravity 단독 설치본은
@@ -7141,7 +7158,7 @@ function shellArg(s) {
7141
7158
  // src/commands/install-render.ts
7142
7159
  init_esm_shims();
7143
7160
  import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "fs";
7144
- import { join as join32, relative as relative8 } from "path";
7161
+ import { basename as basename8, join as join32, relative as relative8 } from "path";
7145
7162
 
7146
7163
  // src/preset-recommend.ts
7147
7164
  init_esm_shims();
@@ -7460,7 +7477,17 @@ function residentEntriesOnDisk(spec) {
7460
7477
  file: join32(abs, e2.name)
7461
7478
  })) : [];
7462
7479
  };
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");
7480
+ const pointed = pointedRuleFiles(spec);
7481
+ const rules = surface === "claude" ? mdFiles(join32(".claude", "rules"), "rules") : rulesInline(spec) ? [
7482
+ ...planned.filter(
7483
+ (e2) => e2.target.startsWith(".claude/rules/") && !pointed.some((f) => f.endsWith(`/${e2.target.slice(".claude/rules/".length)}`))
7484
+ ),
7485
+ ...pointed.map((f) => ({
7486
+ source: `rules/${basename8(f)}`,
7487
+ target: `.claude/rules/${basename8(f)}`,
7488
+ file: f
7489
+ }))
7490
+ ] : mdFiles(join32(".agents", "rules"), "rules", "uzys-harness.md");
7464
7491
  const slot = hasClaude ? join32(".claude", "skills") : join32(".agents", "skills");
7465
7492
  const skills = planned.filter((e2) => e2.target.startsWith(".claude/skills/")).map((e2) => ({
7466
7493
  ...e2,
@@ -7484,13 +7511,21 @@ function contextFilesOnDisk(spec) {
7484
7511
  function rulesInsideAgentsMd(spec, cost) {
7485
7512
  if (anchorSurface(spec.cli).scaffold !== "agents-md" || !rulesInline(spec)) return cost;
7486
7513
  const rendered = spec.updateOnly === void 0 || spec.updateOnly.includes("external");
7514
+ const outside = pointedRuleFiles(spec);
7487
7515
  return makeResidentCost({
7488
7516
  ...cost,
7489
- rules: 0,
7517
+ rules: outside.reduce((sum, f) => sum + fileTokens(f), 0),
7490
7518
  rulesInline: rendered ? "rendered" : "planned",
7519
+ ...outside.length > 0 ? { rulesOutside: outside.length } : {},
7491
7520
  contextNote: "whole file, incl. your text"
7492
7521
  });
7493
7522
  }
7523
+ function pointedRuleFiles(spec) {
7524
+ if (!rulesInline(spec)) return [];
7525
+ const agents = join32(spec.projectDir, "AGENTS.md");
7526
+ if (!existsSync22(agents)) return [];
7527
+ return pathRulePointerTargets(readFileSync24(agents, "utf8")).map((name) => join32(spec.projectDir, ".agents", "rules", `${name}.md`)).filter((f) => existsSync22(f));
7528
+ }
7494
7529
  function rulesInline(spec) {
7495
7530
  if (!spec.cli.includes("codex") && !spec.cli.includes("opencode")) return false;
7496
7531
  const agents = join32(spec.projectDir, "AGENTS.md");
@@ -11380,6 +11415,8 @@ function rerenderAgentsMd(ctx, set, log) {
11380
11415
  // #944 (ADR-116) — 이 경로는 `opencode.json` 을 쓰지 않아 OpenCode 의 도달을 보장하지 못한다 — 늘 인라인. 다음 update 가
11381
11416
  // 조건이 맞으면 위치 안내로 되돌린다(ADR-103 결정 2 의 "다음 update 와 같은 바이트" 는 이 경우에 깨진다 — ADR-116)
11382
11417
  rulesViaInstructions: false,
11418
+ // #948 (ADR-117) — 같은 이유로 `.agents/rules/` 를 이번에 쓰지 않는다 — 경로 룰도 인라인
11419
+ pathRulesViaFiles: false,
11383
11420
  baseline: new Map((log.externalFiles ?? []).map((f) => [f.path, f.sha256])),
11384
11421
  refreshOnly: true,
11385
11422
  installedByRecord: true,