@uzysjung/agent-harness 26.180.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
@@ -31,6 +31,7 @@ import {
31
31
  RETIRED_HOOK_WIRING_REFS,
32
32
  RETIRED_PATHS,
33
33
  RETIRED_SKILL_IDS,
34
+ RULES_BLOCK,
34
35
  SCAFFOLD_BANNER_LINES,
35
36
  SHARED_FILES,
36
37
  SKILLS_BLOCK,
@@ -72,6 +73,7 @@ import {
72
73
  excludedKeys,
73
74
  experimentalOptInCandidates,
74
75
  extractFrontmatter,
76
+ fileTokens,
75
77
  filterApplicableAssets,
76
78
  findStaleHookRefs,
77
79
  formatResidentCostLine,
@@ -94,6 +96,7 @@ import {
94
96
  isOutsideProject,
95
97
  isTrack,
96
98
  isUnfilledScaffold,
99
+ jsonKeys,
97
100
  jsonSha,
98
101
  keyId,
99
102
  legacyDroppedKeys,
@@ -147,7 +150,7 @@ import {
147
150
  withoutAppleDouble,
148
151
  wrapHarnessBlock,
149
152
  writeInstallLog
150
- } from "./chunk-NDE7UYUS.js";
153
+ } from "./chunk-OYXKVPAB.js";
151
154
 
152
155
  // node_modules/sisteransi/src/index.js
153
156
  var require_src = __commonJS({
@@ -1969,9 +1972,16 @@ function renameSlashes(text) {
1969
1972
  return text.replaceAll("/uzys:", "/uzys-");
1970
1973
  }
1971
1974
  var RULES_NOTE = [
1972
- "> \uD558\uB124\uC2A4\uAC00 \uC124\uCE58\uD55C \uB8F0\uC774 \uC5EC\uAE30 \uBCF8\uBB38\uC73C\uB85C \uB4E4\uC5B4\uC628\uB2E4. \uC774 \uD504\uB85C\uC81D\uD2B8\uC5D0\uC11C\uB9CC \uC9C0\uD0AC \uADDC\uCE59\uC744 \uC138\uC6B0\uBA74 \uC774 \uBB38\uC11C\uC5D0",
1973
- "> \uC774\uC5B4 \uC4F0\uAC70\uB098, \uD558\uC704 \uB514\uB809\uD130\uB9AC\uC5D0 `AGENTS.md` \uB97C \uB450\uBA74 \uADF8 \uBC94\uC704\uC5D0\uC11C \uB354 \uAD6C\uCCB4\uC801\uC778 \uADDC\uCE59\uC774 \uB41C\uB2E4."
1975
+ "> \uD558\uB124\uC2A4\uAC00 \uC124\uCE58\uD55C \uB8F0\uC774 \uC5EC\uAE30 \uBCF8\uBB38\uC73C\uB85C \uB4E4\uC5B4\uC628\uB2E4. \uC774 \uD504\uB85C\uC81D\uD2B8\uC5D0\uC11C\uB9CC \uC9C0\uD0AC \uADDC\uCE59\uC744 \uC138\uC6B0\uBA74 \uC774 \uC808 **\uC704\uC5D0** `## ` \uC808\uB85C",
1976
+ "> \uC4F0\uAC70\uB098, \uD558\uC704 \uB514\uB809\uD130\uB9AC\uC5D0 `AGENTS.md` \uB97C \uB450\uBA74 \uADF8 \uBC94\uC704\uC5D0\uC11C \uB354 \uAD6C\uCCB4\uC801\uC778 \uADDC\uCE59\uC774 \uB41C\uB2E4."
1974
1977
  ].join("\n");
1978
+ var RULES_POINTER = [
1979
+ "> \uD558\uB124\uC2A4 \uB8F0\uC740 `.agents/rules/` \uC5D0 \uC788\uB2E4. Antigravity \uB294 \uADF8 \uD3F4\uB354\uB97C \uC9C1\uC811, OpenCode \uB294 `opencode.json` \uC758",
1980
+ "> `instructions` \uB85C \uC77D\uB294\uB2E4. \uC774 \uD504\uB85C\uC81D\uD2B8\uB9CC\uC758 \uADDC\uCE59\uC740 \uC774 \uC808 **\uC704\uC5D0** `## ` \uC808\uB85C \uC4F4\uB2E4."
1981
+ ].join("\n");
1982
+ function hasRulesPointer(text) {
1983
+ return text.includes(RULES_POINTER);
1984
+ }
1975
1985
  var CODEX_SIZE_NOTE = [
1976
1986
  ">",
1977
1987
  "> Codex \uB294 **\uD569\uCE5C \uD06C\uAE30**\uAC00 `project_doc_max_bytes`(\uAE30\uBCF8 32 KiB)\uC5D0 \uB2FF\uC73C\uBA74 **\uAC70\uAE30\uC11C \uC77D\uAE30\uB97C \uBA48\uCD98\uB2E4** \u2014 \uB4A4\uC5D0 \uC624\uB294",
@@ -2016,12 +2026,18 @@ function pruneTemplate(template, empty) {
2016
2026
  function renderAgentsMd(params) {
2017
2027
  const clis = agentsMdClis(params.clis);
2018
2028
  if (clis.length === 0) throw new Error("renderAgentsMd: empty CLI set");
2019
- const inlineRules = clis.includes("codex") || clis.includes("opencode");
2029
+ const pointer = params.rulesViaInstructions === true && !clis.includes("codex");
2030
+ const inlineRules = !pointer && (clis.includes("codex") || clis.includes("opencode"));
2020
2031
  const leads = clis.flatMap((c3) => PROTECTED_LEAD[c3] ?? []);
2021
2032
  const values = {
2022
- "{HARNESS_RULES_NOTE}": inlineRules ? clis.includes("codex") ? `${RULES_NOTE}
2023
- ${CODEX_SIZE_NOTE}` : RULES_NOTE : "",
2024
- "{HARNESS_RULES}": inlineRules ? params.harnessRules : "",
2033
+ "{HARNESS_RULES}": pointer ? wrapHarnessBlock(RULES_BLOCK, RULES_POINTER) : inlineRules ? wrapHarnessBlock(
2034
+ RULES_BLOCK,
2035
+ [
2036
+ clis.includes("codex") ? `${RULES_NOTE}
2037
+ ${CODEX_SIZE_NOTE}` : RULES_NOTE,
2038
+ params.harnessRules.trimEnd()
2039
+ ].filter((part) => part !== "").join("\n\n")
2040
+ ) : "",
2025
2041
  "{SESSION_START}": clis.includes("codex") ? CODEX_SESSION_START : "",
2026
2042
  "{PROTECTED_FILES_LEAD}": leads.length === 0 ? "" : `${leads.join("\n")} \uADF8 \uC704\uC5D0:`
2027
2043
  };
@@ -2302,9 +2318,23 @@ function ruleHeadings(harnessRoot) {
2302
2318
  block.split("\n").filter((l) => /^## /.test(l)).map((l) => l.trim())
2303
2319
  );
2304
2320
  }
2305
- 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) {
2306
2330
  if (rules.length === 0) return "";
2307
- return rules.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");
2308
2338
  }
2309
2339
 
2310
2340
  // src/shared-write.ts
@@ -2449,12 +2479,28 @@ function agentsMdModel(disk, recordedByHarness, recordedBlock = false) {
2449
2479
  if (legacy) return "sections";
2450
2480
  return "block";
2451
2481
  }
2452
- function writeAgentsMd(params) {
2453
- const abs = join10(params.projectDir, AGENTS_MD);
2482
+ function agentsMdState(projectDir, baseline, record) {
2483
+ const abs = join10(projectDir, AGENTS_MD);
2454
2484
  const disk = existsSync9(abs) ? readFileSync6(abs, "utf8") : null;
2455
- const recordedBlock = (params.record.portions ?? []).some((p2) => p2.path === AGENTS_MD);
2485
+ const recordedBlock = (record.portions ?? []).some((p2) => p2.path === AGENTS_MD);
2486
+ return {
2487
+ abs,
2488
+ disk,
2489
+ recordedBlock,
2490
+ model: agentsMdModel(disk, baseline.has(AGENTS_MD), recordedBlock)
2491
+ };
2492
+ }
2493
+ function agentsMdModelFor(projectDir, baseline, record) {
2494
+ return agentsMdState(projectDir, baseline, record).model;
2495
+ }
2496
+ function writeAgentsMd(params) {
2497
+ const { abs, disk, recordedBlock, model } = agentsMdState(
2498
+ params.projectDir,
2499
+ params.baseline,
2500
+ params.record
2501
+ );
2456
2502
  const recordedByHarness = params.baseline.has(AGENTS_MD);
2457
- if (agentsMdModel(disk, recordedByHarness, recordedBlock) === "sections") {
2503
+ if (model === "sections") {
2458
2504
  const legacyUnrecorded = disk !== null && !recordedByHarness && isLegacyHarnessAgentsMd(disk);
2459
2505
  const merged = mergeAgentsMdDetailed({
2460
2506
  rendered: params.rendered,
@@ -2601,6 +2647,7 @@ function runAgentsMdTransform(params) {
2601
2647
  const seed = fromRoot ?? legacy;
2602
2648
  const seededFrom = fromRoot !== null ? "CLAUDE.md" : legacy !== null ? LEGACY_ANTIGRAVITY_ANCHOR : null;
2603
2649
  ensureDir(projectDir);
2650
+ const sectionsModel = agentsMdModelFor(projectDir, baseline, shared2) === "sections";
2604
2651
  const rendered = renderAgentsMd({
2605
2652
  template,
2606
2653
  claudeMd,
@@ -2610,8 +2657,12 @@ function runAgentsMdTransform(params) {
2610
2657
  seed ?? renderFillScaffold("agents-md"),
2611
2658
  skillIds
2612
2659
  ),
2613
- harnessRules: renderRulesBlock(portRules(harnessRoot, params.rules)),
2614
- clis
2660
+ harnessRules: renderRulesBlock(
2661
+ portRules(harnessRoot, params.rules),
2662
+ params.pathRulesViaFiles && sectionsModel
2663
+ ),
2664
+ clis,
2665
+ rulesViaInstructions: params.rulesViaInstructions && sectionsModel
2615
2666
  });
2616
2667
  const agentsMd = writeAgentsMd({
2617
2668
  projectDir,
@@ -3226,6 +3277,16 @@ function renderOpencodeMcp(mcp) {
3226
3277
  Object.entries(mcp.mcpServers).map(([name, cfg]) => [`mcp.${name}`, toOpencode(cfg)])
3227
3278
  );
3228
3279
  }
3280
+ var RULES_INSTRUCTION = ".agents/rules/*.md";
3281
+ var RULES_INSTRUCTION_KEY = `instructions[=${RULES_INSTRUCTION}]`;
3282
+ function renderOpencodePortion(mcp, rulesInstruction) {
3283
+ const out = new Map(renderOpencodeMcp(mcp));
3284
+ if (rulesInstruction) out.set(RULES_INSTRUCTION_KEY, RULES_INSTRUCTION);
3285
+ return out;
3286
+ }
3287
+ function hasRulesInstruction(text) {
3288
+ return jsonKeys.read(text, [RULES_INSTRUCTION_KEY])?.has(RULES_INSTRUCTION_KEY) === true;
3289
+ }
3229
3290
  function renderOpencodeJson(params) {
3230
3291
  const config = parseTemplate(params.template);
3231
3292
  if (params.mcp) {
@@ -3272,7 +3333,7 @@ function runOpencodeTransform(params) {
3272
3333
  });
3273
3334
  ensureDir(projectDir);
3274
3335
  const opencodeJsonPath = join18(projectDir, OPENCODE_JSON);
3275
- const render = renderOpencodeMcp(mcp);
3336
+ const render = renderOpencodePortion(mcp, params.rulesInstruction === true);
3276
3337
  const opencodeJson = writeShared({
3277
3338
  projectDir,
3278
3339
  path: OPENCODE_JSON,
@@ -3316,6 +3377,7 @@ function runOpencodeTransform(params) {
3316
3377
  return {
3317
3378
  opencodeJsonPath,
3318
3379
  opencodeJson,
3380
+ rulesViaInstructions: rulesInstructionOnDisk(opencodeJsonPath),
3319
3381
  skillFiles,
3320
3382
  retiredCommands,
3321
3383
  forgetCommands,
@@ -3323,6 +3385,13 @@ function runOpencodeTransform(params) {
3323
3385
  };
3324
3386
  }
3325
3387
  var OPENCODE_JSON = "opencode.json";
3388
+ function rulesInstructionOnDisk(path) {
3389
+ try {
3390
+ return existsSync14(path) && hasRulesInstruction(readFileSync13(path, "utf8"));
3391
+ } catch {
3392
+ return false;
3393
+ }
3394
+ }
3326
3395
  function readRequired3(path) {
3327
3396
  if (!existsSync14(path)) {
3328
3397
  throw new Error(`OpenCode transform: required source missing: ${path}`);
@@ -3380,6 +3449,13 @@ function adapterExcluded(harnessRoot, excluded) {
3380
3449
  }
3381
3450
  return out;
3382
3451
  }
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
+ );
3458
+ }
3383
3459
  function mcpSources(harnessRoot) {
3384
3460
  return {
3385
3461
  templateMcpPath: join19(harnessRoot, "templates/mcp.json"),
@@ -3467,6 +3543,7 @@ function runCliTransforms(params) {
3467
3543
  }
3468
3544
  journal?.done("codex");
3469
3545
  }
3546
+ const agentsSet = agentsMdClis([...cli, ...recordedClis2]);
3470
3547
  let opencode = null;
3471
3548
  if (cli.includes("opencode")) {
3472
3549
  opencode = runOpencodeTransform({
@@ -3477,6 +3554,12 @@ function runCliTransforms(params) {
3477
3554
  baseline,
3478
3555
  refreshOnly,
3479
3556
  shared: shared2,
3557
+ // #944 (ADR-116) — Antigravity 가 집합(이번 선택 ∪ 기록)에 있고 Codex 가 `AGENTS.md` 를 읽지 않고 그 파일이 절 모델일 때
3558
+ // 원소를 둔다. Antigravity 를 안 고른 부분 실행도 원소를 걷지 않는다(F2 — 그 실행의 `AGENTS.md` 는 D2 ③ 으로 인라인이라 두 번
3559
+ // 읽고, 다음 update 가 포인터로 모은다). 첫 접촉 블록(`block`)은 늘 인라인이라(R2-B1) 원소를 두면 OpenCode 가 늘 두 번 읽는다 —
3560
+ // 모델은 `writeAgentsMd` 와 같은 판정이고 그 파일은 앞의 변환이 쓰지 않는다. 쓰기 주체는 이 변환 하나다 — `AGENTS.md` 쪽은
3561
+ // 결과(`rulesViaInstructions`)만 읽는다
3562
+ rulesInstruction: agentsSet.includes("antigravity") && !agentsSet.includes("codex") && agentsMdModelFor(projectDir, baseline, shared2) === "sections",
3480
3563
  ...writerParams
3481
3564
  });
3482
3565
  absorb(opencode);
@@ -3498,16 +3581,24 @@ function runCliTransforms(params) {
3498
3581
  absorb(antigravity);
3499
3582
  journal?.done("antigravity");
3500
3583
  }
3501
- const agentsSet = agentsMdClis([...cli, ...recordedClis2]);
3502
3584
  let agentsMd = null;
3503
3585
  if (agentsSet.length > 0) {
3504
3586
  const beyondThisRun = agentsSet.some((c3) => !cli.includes(c3));
3587
+ const agentsRules = beyondThisRun && params.cumulativeRules !== void 0 ? params.cumulativeRules : rules;
3505
3588
  agentsMd = runAgentsMdTransform({
3506
3589
  harnessRoot,
3507
3590
  projectDir,
3508
3591
  clis: agentsSet,
3509
3592
  selectedInternalSkills,
3510
- rules: beyondThisRun && params.cumulativeRules !== void 0 ? params.cumulativeRules : rules,
3593
+ rules: agentsRules,
3594
+ // #944 (ADR-116) — 룰 본문 대신 위치 안내는 이번 실행이 OpenCode 의 도달을 **보장했을 때만**(집합이 아니라 쓴 결과로):
3595
+ // ① Codex ∉ 집합 ② opencode 변환이 이번에 돌았다 ③ Antigravity 가 이번 룰을 전부 `.agents/rules/` 에 썼다 ④ 그 뒤
3596
+ // 디스크의 `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),
3511
3602
  baseline,
3512
3603
  refreshOnly,
3513
3604
  // ADR-099 R2 — 기록이 이 파일을 읽는 CLI 를 깔린 것으로 말하면 없어도 만든다(26.164.0 이하 Antigravity 단독 설치본은
@@ -4796,7 +4887,10 @@ function renderedKeyIds(harnessRoot, input, clis) {
4796
4887
  add(".codex/config.toml", TABLES_REGION);
4797
4888
  }
4798
4889
  if (clis.includes("opencode")) {
4799
- for (const key of renderOpencodeMcp(mcp).keys()) add("opencode.json", key);
4890
+ const rulesInstruction = clis.includes("antigravity") && !clis.includes("codex");
4891
+ for (const key of renderOpencodePortion(mcp, rulesInstruction).keys()) {
4892
+ add("opencode.json", key);
4893
+ }
4800
4894
  }
4801
4895
  if (clis.some(isAgentsMdCli)) add("AGENTS.md", AGENTS_BLOCK_NAME);
4802
4896
  return out;
@@ -7054,10 +7148,17 @@ function listHookFiles(hookDir) {
7054
7148
  return readdirSync5(hookDir, { withFileTypes: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".sh")).map((e2) => resolve(hookDir, e2.name));
7055
7149
  }
7056
7150
 
7151
+ // src/shell-arg.ts
7152
+ init_esm_shims();
7153
+ var SHELL_SPECIAL = /[\s*?[\]{}()$`'"\\;&|<>!]/;
7154
+ function shellArg(s) {
7155
+ return SHELL_SPECIAL.test(s) ? `'${s.replaceAll("'", `'\\''`)}'` : s;
7156
+ }
7157
+
7057
7158
  // src/commands/install-render.ts
7058
7159
  init_esm_shims();
7059
7160
  import { existsSync as existsSync22, readdirSync as readdirSync6, readFileSync as readFileSync24 } from "fs";
7060
- import { join as join32, relative as relative8 } from "path";
7161
+ import { basename as basename8, join as join32, relative as relative8 } from "path";
7061
7162
 
7062
7163
  // src/preset-recommend.ts
7063
7164
  init_esm_shims();
@@ -7376,7 +7477,17 @@ function residentEntriesOnDisk(spec) {
7376
7477
  file: join32(abs, e2.name)
7377
7478
  })) : [];
7378
7479
  };
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");
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");
7380
7491
  const slot = hasClaude ? join32(".claude", "skills") : join32(".agents", "skills");
7381
7492
  const skills = planned.filter((e2) => e2.target.startsWith(".claude/skills/")).map((e2) => ({
7382
7493
  ...e2,
@@ -7398,17 +7509,27 @@ function contextFilesOnDisk(spec) {
7398
7509
  return files.map((f) => join32(spec.projectDir, f));
7399
7510
  }
7400
7511
  function rulesInsideAgentsMd(spec, cost) {
7401
- if (anchorSurface(spec.cli).scaffold !== "agents-md" || !rulesInline(spec.cli)) return cost;
7512
+ if (anchorSurface(spec.cli).scaffold !== "agents-md" || !rulesInline(spec)) return cost;
7402
7513
  const rendered = spec.updateOnly === void 0 || spec.updateOnly.includes("external");
7514
+ const outside = pointedRuleFiles(spec);
7403
7515
  return makeResidentCost({
7404
7516
  ...cost,
7405
- rules: 0,
7517
+ rules: outside.reduce((sum, f) => sum + fileTokens(f), 0),
7406
7518
  rulesInline: rendered ? "rendered" : "planned",
7519
+ ...outside.length > 0 ? { rulesOutside: outside.length } : {},
7407
7520
  contextNote: "whole file, incl. your text"
7408
7521
  });
7409
7522
  }
7410
- function rulesInline(cli) {
7411
- return cli.includes("codex") || cli.includes("opencode");
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
+ }
7529
+ function rulesInline(spec) {
7530
+ if (!spec.cli.includes("codex") && !spec.cli.includes("opencode")) return false;
7531
+ const agents = join32(spec.projectDir, "AGENTS.md");
7532
+ return !(existsSync22(agents) && hasRulesPointer(readFileSync24(agents, "utf8")));
7412
7533
  }
7413
7534
  function renderCliArtifacts(log, spec, report) {
7414
7535
  const agentsReport = report.agentsMd ?? null;
@@ -7587,8 +7708,14 @@ function sharedLeftRow(f) {
7587
7708
  return assetRow("skip", f.path, `${parts.join(" \xB7 ")}${legacy}`);
7588
7709
  }
7589
7710
  function opencodeMcpPart(r) {
7590
- const names = harnessKeysInFile(r).map((k2) => /^mcp\.(.+)$/.exec(k2)?.[1]).filter((n) => n !== void 0 && !n.endsWith("{}"));
7591
- return names.length > 0 ? `harness mcp: ${names.join(" \xB7 ")}` : "no harness part in the file";
7711
+ const keys = harnessKeysInFile(r);
7712
+ const names = keys.map((k2) => /^mcp\.(.+)$/.exec(k2)?.[1]).filter((n) => n !== void 0 && !n.endsWith("{}"));
7713
+ const instructions = keys.flatMap((k2) => /^instructions\[=(.*)\]$/.exec(k2)?.[1] ?? []);
7714
+ const parts = [
7715
+ ...names.length > 0 ? [`harness mcp: ${names.join(" \xB7 ")}`] : [],
7716
+ ...instructions.length > 0 ? [`harness instructions: ${instructions.join(" \xB7 ")}`] : []
7717
+ ];
7718
+ return parts.length > 0 ? parts.join(" \xB7 ") : "no harness part in the file";
7592
7719
  }
7593
7720
  function configRegionsPart(r) {
7594
7721
  const order = (k2) => k2 === "top" ? 0 : 1;
@@ -7795,7 +7922,7 @@ function renderPhase1Rows(log, baseline, verbose = false) {
7795
7922
  assetRow(
7796
7923
  "skip",
7797
7924
  "to keep it out",
7798
- `deleting is undone by the next update \u2014 re-run \`agent-harness install\` with your usual flags plus ${withoutArgs.map((a) => `--without ${a}`).join(" ")}, then delete it again (${KEPT_OUT_SCOPE})`
7925
+ `deleting is undone by the next update \u2014 re-run \`agent-harness install\` with your usual flags plus ${withoutArgs.map((a) => `--without ${shellArg(a)}`).join(" ")}, then delete it again (${KEPT_OUT_SCOPE})`
7799
7926
  )
7800
7927
  );
7801
7928
  }
@@ -8326,7 +8453,7 @@ var GITIGNORE_RECORD_DIR_NOTE = "now ignores only the harness's runtime files \u
8326
8453
  function excludedKeyParts(f) {
8327
8454
  const parts = [];
8328
8455
  if (f.removedOut.length > 0) {
8329
- const asked = f.removedOut.map((id) => `--without ${id}`).join(" ");
8456
+ const asked = f.removedOut.map((id) => `--without ${shellArg(id)}`).join(" ");
8330
8457
  parts.push(`removed the harness part: ${f.removedOut.join(", ")} (you asked: ${asked})`);
8331
8458
  }
8332
8459
  if (f.removedEdited.length > 0) {
@@ -8359,18 +8486,18 @@ function catalogRemovedRows(items) {
8359
8486
  const only = next ? assetCliSupport(next).map((cli) => CLI_DISPLAY_NAMES[cli]).join(" \xB7 ") : "\uB2E4\uB978 CLI";
8360
8487
  parts.push(`${e2.replacedBy} \uB294 ${only} \uC804\uC6A9\uC774\uB77C \uC774 \uC124\uCE58\uBCF8\uC758 CLI \uC5D0\uB294 \uAE54\uB9AC\uC9C0 \uC54A\uB294\uB2E4`);
8361
8488
  } else {
8362
- parts.push(`\uC0C8 \uAC83\uC740 agent-harness install --with ${e2.replacedBy}`);
8489
+ parts.push(`\uC0C8 \uAC83\uC740 agent-harness install --with ${shellArg(e2.replacedBy)}`);
8363
8490
  }
8364
- parts.push(`\uC61B \uAC83\uC744 \uCE58\uC6B0\uB824\uBA74 agent-harness uninstall --only ${e2.id}`);
8491
+ parts.push(`\uC61B \uAC83\uC744 \uCE58\uC6B0\uB824\uBA74 agent-harness uninstall --only ${shellArg(e2.id)}`);
8365
8492
  } else {
8366
- parts.push(`\uCE58\uC6B0\uB824\uBA74 agent-harness uninstall --only ${e2.id}`);
8493
+ parts.push(`\uCE58\uC6B0\uB824\uBA74 agent-harness uninstall --only ${shellArg(e2.id)}`);
8367
8494
  }
8368
8495
  return assetRow("skip", e2.id, parts.join(" \xB7 "));
8369
8496
  });
8370
8497
  }
8371
8498
  function excludedStillThereRows(items) {
8372
8499
  return items.map(
8373
- (e2) => e2.catalog ? ` ${c.yellow(symbol.skip)} ${e2.id} \u2014 excluded, so the harness no longer updates it (still installed). To manage it again: run install (without --without ${e2.id}; add --with ${e2.id} if it is opt-in) \xB7 remove it: agent-harness uninstall --only ${e2.id}` : ` ${c.yellow(symbol.skip)} ${e2.id} \u2014 excluded (still on disk \u2014 an earlier install put it there; the harness does not delete it. Remove the file yourself, or run uninstall) \xB7 to manage it again: run install without --without ${e2.id}`
8500
+ (e2) => e2.catalog ? ` ${c.yellow(symbol.skip)} ${e2.id} \u2014 excluded, so the harness no longer updates it (still installed). To manage it again: run install (without --without ${shellArg(e2.id)}; add --with ${shellArg(e2.id)} if it is opt-in) \xB7 remove it: agent-harness uninstall --only ${shellArg(e2.id)}` : ` ${c.yellow(symbol.skip)} ${e2.id} \u2014 excluded (still on disk \u2014 an earlier install put it there; the harness does not delete it. Remove the file yourself, or run uninstall) \xB7 to manage it again: run install without --without ${shellArg(e2.id)}`
8374
8501
  );
8375
8502
  }
8376
8503
  function installedByExternalPhase(id) {
@@ -8378,7 +8505,7 @@ function installedByExternalPhase(id) {
8378
8505
  }
8379
8506
  function releasedRows(items, notInstalled = /* @__PURE__ */ new Map()) {
8380
8507
  return items.map(
8381
- (r) => notInstalled.has(r.id) ? ` ${c.yellow(symbol.skip)} ${r.id} \u2014 selected again, but ${notInstalled.get(r.id)}: this install did not pass --without ${r.id}` : r.again ? ` ${c.green("\u21BA")} ${r.id} \u2014 dropped earlier, installed again: this install did not pass --without ${r.id}` : ` ${c.green("\u21BA")} ${r.id} \u2014 no longer excluded: ${r.tail} (this install did not pass --without ${r.id})`
8508
+ (r) => notInstalled.has(r.id) ? ` ${c.yellow(symbol.skip)} ${r.id} \u2014 selected again, but ${notInstalled.get(r.id)}: this install did not pass --without ${shellArg(r.id)}` : r.again ? ` ${c.green("\u21BA")} ${r.id} \u2014 dropped earlier, installed again: this install did not pass --without ${shellArg(r.id)}` : ` ${c.green("\u21BA")} ${r.id} \u2014 no longer excluded: ${r.tail} (this install did not pass --without ${shellArg(r.id)})`
8382
8509
  );
8383
8510
  }
8384
8511
  function legacyReleasedCatalogRows(ids) {
@@ -8388,7 +8515,7 @@ function legacyReleasedCatalogRows(ids) {
8388
8515
  }
8389
8516
  var KEPT_OUT_SCOPE = "kept out by update; a later install without that flag brings it back";
8390
8517
  function restoredKeysPart(ids) {
8391
- const drop = ids.map((id) => `--without ${id}`).join(" ");
8518
+ const drop = ids.map((id) => `--without ${shellArg(id)}`).join(" ");
8392
8519
  return `was missing \u2014 restored: ${ids.join(", ")} ${c.dim(`(drop it: install \u2026 ${drop} \u2014 ${KEPT_OUT_SCOPE})`)}`;
8393
8520
  }
8394
8521
  function unrestoredPart(names) {
@@ -8396,7 +8523,7 @@ function unrestoredPart(names) {
8396
8523
  }
8397
8524
  function restoredFilePart(f) {
8398
8525
  const how = f.how === void 0 ? "" : ` \u2014 ${f.how}`;
8399
- const drop = f.ids !== void 0 && f.ids.length > 0 ? ` ${c.dim(`(drop it: install \u2026 ${f.ids.map((id) => `--without ${id}`).join(" ")} \u2014 ${KEPT_OUT_SCOPE})`)}` : f.clis.length === 0 ? "" : ` ${c.dim(`(drop this CLI for good: ${f.clis.map((cli) => `agent-harness uninstall --cli ${cli}`).join(" and ")})`)}`;
8526
+ const drop = f.ids !== void 0 && f.ids.length > 0 ? ` ${c.dim(`(drop it: install \u2026 ${f.ids.map((id) => `--without ${shellArg(id)}`).join(" ")} \u2014 ${KEPT_OUT_SCOPE})`)}` : f.clis.length === 0 ? "" : ` ${c.dim(`(drop this CLI for good: ${f.clis.map((cli) => `agent-harness uninstall --cli ${cli}`).join(" and ")})`)}`;
8400
8527
  return `was missing \u2014 restored${how}${drop}`;
8401
8528
  }
8402
8529
  function legacyRestoredRow(ids) {
@@ -8728,7 +8855,7 @@ function unknownKeyWarning(id, flag, keys) {
8728
8855
  const prefix = id.slice(0, id.indexOf(":") + 1);
8729
8856
  const same = [...keys].filter((k2) => k2.startsWith(prefix)).sort();
8730
8857
  const shown = same.length > 0 ? same : [...keys].sort();
8731
- return shown.length > 0 ? `[WARN] Unknown key id '${id}' (${flag}). Skipping. Key ids this install writes: ${shown.join(", ")}` : `[WARN] Unknown key id '${id}' (${flag}). Skipping. This install writes no harness part with that name`;
8858
+ return shown.length > 0 ? `[WARN] Unknown key id '${id}' (${flag}). Skipping. Key ids this install writes: ${shown.map(shellArg).join(", ")}` : `[WARN] Unknown key id '${id}' (${flag}). Skipping. This install writes no harness part with that name`;
8732
8859
  }
8733
8860
  function conflictingIds(options) {
8734
8861
  const without = new Set(normalizeRepeatable(options.without));
@@ -8860,7 +8987,7 @@ function formatSelectionRows(log, projectDir) {
8860
8987
  rows.push(` ${day} migration (26.162\u201326.163 record): ${parts.join(" \xB7 ")}`);
8861
8988
  continue;
8862
8989
  }
8863
- if (ev.without?.length) parts.push(`--without ${ev.without.join(", ")}`);
8990
+ if (ev.without?.length) parts.push(`--without ${ev.without.map(shellArg).join(", ")}`);
8864
8991
  if (ev.with?.length) parts.push(`re-added ${ev.with.join(", ")}`);
8865
8992
  const tags = [ev.via === "wizard" ? "wizard" : "", ev.interrupted ? "interrupted" : ""].filter(Boolean).join(", ");
8866
8993
  rows.push(` ${day} install ${parts.join(" \xB7 ")}${tags ? ` (${tags})` : ""}`);
@@ -11285,6 +11412,11 @@ function rerenderAgentsMd(ctx, set, log) {
11285
11412
  projectDir,
11286
11413
  clis: agentsMdClis(set),
11287
11414
  ...recordedRenderInputs(projectDir, log, log.spec.tracks.filter(isTrack)),
11415
+ // #944 (ADR-116) — 이 경로는 `opencode.json` 을 쓰지 않아 OpenCode 의 도달을 보장하지 못한다 — 늘 인라인. 다음 update 가
11416
+ // 조건이 맞으면 위치 안내로 되돌린다(ADR-103 결정 2 의 "다음 update 와 같은 바이트" 는 이 경우에 깨진다 — ADR-116)
11417
+ rulesViaInstructions: false,
11418
+ // #948 (ADR-117) — 같은 이유로 `.agents/rules/` 를 이번에 쓰지 않는다 — 경로 룰도 인라인
11419
+ pathRulesViaFiles: false,
11288
11420
  baseline: new Map((log.externalFiles ?? []).map((f) => [f.path, f.sha256])),
11289
11421
  refreshOnly: true,
11290
11422
  installedByRecord: true,