@riconext/hermes-repo 1.2.0 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a8aff7f: 记录 flush 执行过程到 debug 日志,并在写入 MEMORY.md 前校验知识文件链接是否真实存在。
8
+
9
+ ## 1.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - be5381b: 修复 ESM 打包产物中 `flush` 触发动态 require 导致 `Dynamic require of "fs" is not supported` 的问题。
14
+
3
15
  ## 1.2.0
4
16
 
5
17
  ### Minor Changes
package/dist/cli.js CHANGED
@@ -1,10 +1,4 @@
1
1
  #!/usr/bin/env node
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
2
 
9
3
  // src/cli.ts
10
4
  import { Command } from "commander";
@@ -1541,8 +1535,15 @@ function isSkippedEntry(raw) {
1541
1535
  }
1542
1536
 
1543
1537
  // src/consolidate/writeKnowledge.ts
1544
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
1538
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "fs";
1545
1539
  import { dirname as dirname4 } from "path";
1540
+ var KNOWLEDGE_LINK_PREFIXES = [
1541
+ "rules/",
1542
+ "domains/",
1543
+ "workflows/",
1544
+ "decisions/",
1545
+ "incidents/"
1546
+ ];
1546
1547
  function writeKnowledgeFiles(repoRoot, files) {
1547
1548
  const result = {
1548
1549
  created: [],
@@ -1576,7 +1577,7 @@ function writeKnowledgeFiles(repoRoot, files) {
1576
1577
  function writeMemoryMd(repoRoot, memoryMd) {
1577
1578
  const memoryPathAbs = memoryPath(repoRoot, "MEMORY.md");
1578
1579
  if (existsSync7(memoryPathAbs)) {
1579
- const existing = __require("fs").readFileSync(memoryPathAbs, "utf8");
1580
+ const existing = readFileSync10(memoryPathAbs, "utf8");
1580
1581
  const preserved = extractUserEditedSections(existing);
1581
1582
  if (preserved.length > 0) {
1582
1583
  memoryMd = injectUserSections(memoryMd, preserved);
@@ -1586,6 +1587,38 @@ function writeMemoryMd(repoRoot, memoryMd) {
1586
1587
  writeFileSync5(memoryPathAbs, `${memoryMd}
1587
1588
  `, "utf8");
1588
1589
  }
1590
+ function assertMemoryKnowledgeLinksExist(repoRoot, memoryMd) {
1591
+ const missing = findMissingKnowledgeLinks(repoRoot, memoryMd);
1592
+ if (missing.length > 0) {
1593
+ throw new Error(
1594
+ `MEMORY.md \u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u77E5\u8BC6\u6587\u4EF6: ${missing.join(", ")}`
1595
+ );
1596
+ }
1597
+ }
1598
+ function findMissingKnowledgeLinks(repoRoot, memoryMd) {
1599
+ const links = extractKnowledgeLinks(memoryMd);
1600
+ return links.filter((link) => !existsSync7(memoryPath(repoRoot, link)));
1601
+ }
1602
+ function extractKnowledgeLinks(memoryMd) {
1603
+ const links = /* @__PURE__ */ new Set();
1604
+ const markdownLink = /\[[^\]]+\]\(([^)]+)\)/g;
1605
+ let match;
1606
+ while ((match = markdownLink.exec(memoryMd)) !== null) {
1607
+ const normalized = normalizeKnowledgeLink(match[1]);
1608
+ if (normalized) {
1609
+ links.add(normalized);
1610
+ }
1611
+ }
1612
+ return [...links];
1613
+ }
1614
+ function normalizeKnowledgeLink(rawLink) {
1615
+ const withoutAnchor = rawLink.split("#")[0].trim();
1616
+ const withoutDotSlash = withoutAnchor.startsWith("./") ? withoutAnchor.slice(2) : withoutAnchor;
1617
+ if (withoutDotSlash.includes("://") || withoutDotSlash.startsWith("/") || withoutDotSlash.includes("..") || !withoutDotSlash.endsWith(".md")) {
1618
+ return null;
1619
+ }
1620
+ return KNOWLEDGE_LINK_PREFIXES.some((prefix) => withoutDotSlash.startsWith(prefix)) ? withoutDotSlash : null;
1621
+ }
1589
1622
  function serializeKnowledgeFile(frontmatter, body) {
1590
1623
  const lines = ["---"];
1591
1624
  const fieldOrder = ["title", "domain", "type", "status", "confidence", "lastReviewed"];
@@ -1672,10 +1705,17 @@ function archiveDoneSessions(repoRoot, sessions, autoArchiveDays = 30) {
1672
1705
  // src/consolidate/runConsolidate.ts
1673
1706
  async function runConsolidate(opts) {
1674
1707
  const { repoRoot, config, force, dryRun, debug } = opts;
1708
+ debugLog(
1709
+ debug === true,
1710
+ "consolidate",
1711
+ `start: force=${force === true}, dryRun=${dryRun === true}`
1712
+ );
1675
1713
  writeConsolidateLock(repoRoot);
1714
+ debugLog(debug === true, "consolidate", "lock acquired");
1676
1715
  try {
1677
1716
  const llmConfig = config.llm;
1678
1717
  if (!llmConfig.enabled) {
1718
+ debugLog(debug === true, "consolidate", "skip: llm not enabled");
1679
1719
  return {
1680
1720
  ran: false,
1681
1721
  reason: "llm-not-enabled",
@@ -1694,6 +1734,7 @@ async function runConsolidate(opts) {
1694
1734
  `\u626B\u63CF\u5230 ${allSessions.length} \u4E2A session\uFF0C\u5176\u4E2D ${pendingSessions.length} \u4E2A\u5F85\u5904\u7406`
1695
1735
  );
1696
1736
  if (pendingSessions.length === 0 && !force) {
1737
+ debugLog(debug === true, "consolidate", "skip: no pending sessions");
1697
1738
  return {
1698
1739
  ran: false,
1699
1740
  reason: "no-pending-sessions",
@@ -1705,6 +1746,11 @@ async function runConsolidate(opts) {
1705
1746
  };
1706
1747
  }
1707
1748
  if (dryRun) {
1749
+ debugLog(
1750
+ debug === true,
1751
+ "consolidate",
1752
+ `dry-run: would process ${pendingSessions.length} session(s)`
1753
+ );
1708
1754
  return {
1709
1755
  ran: true,
1710
1756
  reason: "dry-run",
@@ -1716,7 +1762,11 @@ async function runConsolidate(opts) {
1716
1762
  };
1717
1763
  }
1718
1764
  const llmInput = buildLlmConsolidateInput(repoRoot, pendingSessions);
1719
- debugLog(debug === true, "consolidate", `LLM \u8F93\u5165: ${llmInput.pendingSessions.length} sessions, ${llmInput.existingKnowledge.length} existing knowledge`);
1765
+ debugLog(
1766
+ debug === true,
1767
+ "consolidate",
1768
+ `LLM \u8F93\u5165: ${llmInput.pendingSessions.length} sessions, ${llmInput.existingKnowledge.length} existing knowledge`
1769
+ );
1720
1770
  let llmResult;
1721
1771
  try {
1722
1772
  llmResult = await callLlmConsolidate(llmInput, llmConfig);
@@ -1729,8 +1779,33 @@ async function runConsolidate(opts) {
1729
1779
  "consolidate",
1730
1780
  `LLM \u8FD4\u56DE: ${llmResult.knowledgeFiles.length} knowledge files, ${llmResult.skippedSessions.length} skipped`
1731
1781
  );
1782
+ debugLog(debug === true, "consolidate", "writing knowledge files");
1732
1783
  const writeResult = writeKnowledgeFiles(repoRoot, llmResult.knowledgeFiles);
1784
+ if (writeResult.failed.length > 0) {
1785
+ debugLog(
1786
+ debug === true,
1787
+ "consolidate",
1788
+ `write failed: ${writeResult.failed.join(", ")}`
1789
+ );
1790
+ throw new Error(
1791
+ `\u77E5\u8BC6\u6587\u4EF6\u5199\u5165\u5931\u8D25: ${writeResult.failed.join(", ")}`
1792
+ );
1793
+ }
1794
+ debugLog(
1795
+ debug === true,
1796
+ "consolidate",
1797
+ `knowledge files written: created=${writeResult.created.length}, updated=${writeResult.updated.length}`
1798
+ );
1799
+ debugLog(debug === true, "consolidate", "validating MEMORY.md links");
1800
+ assertMemoryKnowledgeLinksExist(repoRoot, llmResult.memoryMd);
1801
+ debugLog(debug === true, "consolidate", "MEMORY.md links ok");
1802
+ debugLog(debug === true, "consolidate", "writing MEMORY.md");
1733
1803
  writeMemoryMd(repoRoot, llmResult.memoryMd);
1804
+ debugLog(
1805
+ debug === true,
1806
+ "consolidate",
1807
+ `marking sessions done: ${pendingSessions.length} processed, ${llmResult.skippedSessions.length} skipped`
1808
+ );
1734
1809
  const processedSessionIds = /* @__PURE__ */ new Set();
1735
1810
  for (const s of pendingSessions) {
1736
1811
  markSessionConsolidated(repoRoot, s.sessionId);
@@ -1742,6 +1817,7 @@ async function runConsolidate(opts) {
1742
1817
  }
1743
1818
  const prevState = readConsolidateState(repoRoot);
1744
1819
  const newDomains = extractDomainsFromResults(llmResult.knowledgeFiles);
1820
+ debugLog(debug === true, "consolidate", "updating consolidate state");
1745
1821
  writeConsolidateState(repoRoot, {
1746
1822
  version: 2,
1747
1823
  lastConsolidatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1765,6 +1841,12 @@ async function runConsolidate(opts) {
1765
1841
  allSessions,
1766
1842
  config.consolidate.autoArchiveDays
1767
1843
  );
1844
+ debugLog(debug === true, "consolidate", `archived sessions: ${archived}`);
1845
+ debugLog(
1846
+ debug === true,
1847
+ "consolidate",
1848
+ `done: sessions=${pendingSessions.length}, created=${writeResult.created.length}, updated=${writeResult.updated.length}, skipped=${llmResult.skippedSessions.length}, archived=${archived}`
1849
+ );
1768
1850
  return {
1769
1851
  ran: true,
1770
1852
  sessionsProcessed: pendingSessions.length,
@@ -1775,6 +1857,7 @@ async function runConsolidate(opts) {
1775
1857
  };
1776
1858
  } finally {
1777
1859
  releaseConsolidateLock(repoRoot);
1860
+ debugLog(debug === true, "consolidate", "lock released");
1778
1861
  }
1779
1862
  }
1780
1863
  function extractDomainsFromResults(files) {
@@ -1976,7 +2059,7 @@ async function commitCapture(opts) {
1976
2059
  }
1977
2060
 
1978
2061
  // src/capture/claude-code/resolveSession.ts
1979
- import { existsSync as existsSync9, readdirSync as readdirSync4, readFileSync as readFileSync11, statSync } from "fs";
2062
+ import { existsSync as existsSync9, readdirSync as readdirSync4, readFileSync as readFileSync12, statSync } from "fs";
1980
2063
  import { homedir } from "os";
1981
2064
  import { basename as basename2, join as join12, resolve as resolve3 } from "path";
1982
2065
  function encodeClaudeProjectDir(absPath) {
@@ -2427,12 +2510,25 @@ function runCaptureCommand(opts) {
2427
2510
 
2428
2511
  // src/commands/flush.ts
2429
2512
  async function runFlushCommandCli(opts) {
2513
+ const ctx = loadRepoContext(opts.cwd);
2514
+ const debug = ctx?.config.debug === true;
2515
+ configureDebugLogging(ctx?.repoRoot ?? null, debug);
2516
+ debugLog(
2517
+ debug,
2518
+ "flush",
2519
+ `start: force=${opts.force === true}, dryRun=${opts.dryRun === true}`
2520
+ );
2430
2521
  try {
2431
2522
  const result = await runFlushCommand({
2432
2523
  cwd: opts.cwd,
2433
2524
  force: opts.force,
2434
2525
  dryRun: opts.dryRun
2435
2526
  });
2527
+ debugLog(
2528
+ debug,
2529
+ "flush",
2530
+ `result: ran=${result.ran}, reason=${result.reason ?? "ok"}, sessions=${result.sessionsProcessed}, created=${result.knowledgeCreated}, updated=${result.knowledgeUpdated}, skipped=${result.skippedCount}, archived=${result.archived}`
2531
+ );
2436
2532
  if (result.ran) {
2437
2533
  if (result.reason === "dry-run") {
2438
2534
  console.error(
@@ -2472,6 +2568,11 @@ async function runFlushCommandCli(opts) {
2472
2568
  }
2473
2569
  hookExit(0, opts.strict);
2474
2570
  } catch (err) {
2571
+ debugLog(
2572
+ debug,
2573
+ "flush",
2574
+ `error: ${err instanceof Error ? err.message : String(err)}`
2575
+ );
2475
2576
  console.error(
2476
2577
  `hermes-repo flush: ${err instanceof Error ? err.message : String(err)}`
2477
2578
  );
@@ -2480,7 +2581,7 @@ async function runFlushCommandCli(opts) {
2480
2581
  }
2481
2582
 
2482
2583
  // src/inject/runInject.ts
2483
- import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync12 } from "fs";
2584
+ import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync13 } from "fs";
2484
2585
  import { join as join15 } from "path";
2485
2586
 
2486
2587
  // src/inject/constants.ts
@@ -2543,7 +2644,7 @@ function readMemoryMd(repoRoot) {
2543
2644
  const path = memoryPathOnDisk(repoRoot);
2544
2645
  if (!existsSync12(path)) return null;
2545
2646
  try {
2546
- const content = readFileSync12(path, "utf8");
2647
+ const content = readFileSync13(path, "utf8");
2547
2648
  return content.trim() || null;
2548
2649
  } catch {
2549
2650
  return null;
@@ -2562,7 +2663,7 @@ function readAllRules(repoRoot) {
2562
2663
  for (const file of files) {
2563
2664
  try {
2564
2665
  const filePath = join15(rulesDir, file);
2565
- const content = readFileSync12(filePath, "utf8").trim();
2666
+ const content = readFileSync13(filePath, "utf8").trim();
2566
2667
  if (!content) continue;
2567
2668
  parts.push(`### ${file}`, "", content, "");
2568
2669
  } catch {
@@ -2592,23 +2693,23 @@ import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "fs";
2592
2693
  import { join as join19 } from "path";
2593
2694
 
2594
2695
  // src/init/mergeClaudeSettings.ts
2595
- import { existsSync as existsSync14, readFileSync as readFileSync15 } from "fs";
2696
+ import { existsSync as existsSync14, readFileSync as readFileSync16 } from "fs";
2596
2697
  import { join as join18 } from "path";
2597
2698
 
2598
2699
  // src/init/templateDir.ts
2599
- import { existsSync as existsSync13, readFileSync as readFileSync14 } from "fs";
2700
+ import { existsSync as existsSync13, readFileSync as readFileSync15 } from "fs";
2600
2701
  import { dirname as dirname7, join as join17 } from "path";
2601
2702
  import { fileURLToPath as fileURLToPath4 } from "url";
2602
2703
 
2603
2704
  // src/index.ts
2604
- import { readFileSync as readFileSync13 } from "fs";
2705
+ import { readFileSync as readFileSync14 } from "fs";
2605
2706
  import { dirname as dirname6, join as join16 } from "path";
2606
2707
  import { fileURLToPath as fileURLToPath3 } from "url";
2607
2708
  var PACKAGE_NAME = "@riconext/hermes-repo";
2608
2709
  var __dirname = dirname6(fileURLToPath3(import.meta.url));
2609
2710
  function readPkgVersion() {
2610
2711
  const pkgPath = join16(__dirname, "..", "package.json");
2611
- const pkg = JSON.parse(readFileSync13(pkgPath, "utf8"));
2712
+ const pkg = JSON.parse(readFileSync14(pkgPath, "utf8"));
2612
2713
  return pkg.version;
2613
2714
  }
2614
2715
 
@@ -2631,7 +2732,7 @@ function resolveTemplatePath(name) {
2631
2732
  return join17(templateDir, name);
2632
2733
  }
2633
2734
  function readTemplate(name) {
2634
- return readFileSync14(resolveTemplatePath(name), "utf8");
2735
+ return readFileSync15(resolveTemplatePath(name), "utf8");
2635
2736
  }
2636
2737
  function renderTemplate(name) {
2637
2738
  const raw = readTemplate(name);
@@ -2650,7 +2751,7 @@ function mergeClaudeLocalSettings(repoRoot) {
2650
2751
  let existing = {};
2651
2752
  if (existed) {
2652
2753
  try {
2653
- existing = JSON.parse(readFileSync15(settingsPath, "utf8"));
2754
+ existing = JSON.parse(readFileSync16(settingsPath, "utf8"));
2654
2755
  } catch {
2655
2756
  existing = {};
2656
2757
  }
@@ -2690,7 +2791,7 @@ import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync7 } from "fs";
2690
2791
  import { join as join21 } from "path";
2691
2792
 
2692
2793
  // src/init/mergeCodexConfig.ts
2693
- import { existsSync as existsSync15, readFileSync as readFileSync16 } from "fs";
2794
+ import { existsSync as existsSync15, readFileSync as readFileSync17 } from "fs";
2694
2795
  import { join as join20 } from "path";
2695
2796
  var CODEX_CONFIG_REL = ".codex/config.toml";
2696
2797
  var CODEX_HERMES_START_MARKER = "# >>> hermes-repo codex (do not edit this block manually)";
@@ -2737,7 +2838,7 @@ function mergeCodexConfig(repoRoot) {
2737
2838
  action: "created"
2738
2839
  };
2739
2840
  }
2740
- const existing = readFileSync16(configPath, "utf8");
2841
+ const existing = readFileSync17(configPath, "utf8");
2741
2842
  const hasBlock = existing.includes(CODEX_HERMES_START_MARKER) && existing.includes(CODEX_HERMES_END_MARKER);
2742
2843
  return {
2743
2844
  content: spliceHermesBlock(existing, block),
@@ -2764,7 +2865,7 @@ import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync8 } from "fs";
2764
2865
  import { join as join23 } from "path";
2765
2866
 
2766
2867
  // src/init/mergeCodebuddySettings.ts
2767
- import { existsSync as existsSync16, readFileSync as readFileSync17 } from "fs";
2868
+ import { existsSync as existsSync16, readFileSync as readFileSync18 } from "fs";
2768
2869
  import { join as join22 } from "path";
2769
2870
  var CODEBUDDY_SETTINGS_LOCAL_REL = ".codebuddy/settings.local.json";
2770
2871
  function codebuddySettingsLocalPath(repoRoot) {
@@ -2779,7 +2880,7 @@ function mergeCodebuddyLocalSettings(repoRoot) {
2779
2880
  let existing = {};
2780
2881
  if (existed) {
2781
2882
  try {
2782
- existing = JSON.parse(readFileSync17(settingsPath, "utf8"));
2883
+ existing = JSON.parse(readFileSync18(settingsPath, "utf8"));
2783
2884
  } catch {
2784
2885
  existing = {};
2785
2886
  }
@@ -2819,7 +2920,7 @@ import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "fs";
2819
2920
  import { join as join25 } from "path";
2820
2921
 
2821
2922
  // src/init/mergeCursorHooks.ts
2822
- import { existsSync as existsSync17, readFileSync as readFileSync18 } from "fs";
2923
+ import { existsSync as existsSync17, readFileSync as readFileSync19 } from "fs";
2823
2924
  import { join as join24 } from "path";
2824
2925
  var CURSOR_HOOKS_REL = ".cursor/hooks.json";
2825
2926
  function cursorHooksPath(repoRoot) {
@@ -2832,7 +2933,7 @@ function mergeCursorHooks(repoRoot) {
2832
2933
  let existing = {};
2833
2934
  if (existed) {
2834
2935
  try {
2835
- existing = JSON.parse(readFileSync18(hooksPath, "utf8"));
2936
+ existing = JSON.parse(readFileSync19(hooksPath, "utf8"));
2836
2937
  } catch {
2837
2938
  existing = {};
2838
2939
  }
@@ -2939,14 +3040,14 @@ function ensureMemoryTree(repoRoot) {
2939
3040
  }
2940
3041
 
2941
3042
  // src/init/mergeAssistants.ts
2942
- import { existsSync as existsSync18, readFileSync as readFileSync19 } from "fs";
3043
+ import { existsSync as existsSync18, readFileSync as readFileSync20 } from "fs";
2943
3044
  function readExistingAssistants(repoRoot) {
2944
3045
  const configPath = memoryPath(repoRoot, "config.json");
2945
3046
  if (!existsSync18(configPath)) {
2946
3047
  return [];
2947
3048
  }
2948
3049
  try {
2949
- const config = JSON.parse(readFileSync19(configPath, "utf8"));
3050
+ const config = JSON.parse(readFileSync20(configPath, "utf8"));
2950
3051
  if (!Array.isArray(config.assistants)) {
2951
3052
  return [];
2952
3053
  }
@@ -2961,14 +3062,14 @@ function mergeAssistants(repoRoot, selected) {
2961
3062
  }
2962
3063
 
2963
3064
  // src/init/mergeGitignore.ts
2964
- import { existsSync as existsSync19, readFileSync as readFileSync20, writeFileSync as writeFileSync11 } from "fs";
3065
+ import { existsSync as existsSync19, readFileSync as readFileSync21, writeFileSync as writeFileSync11 } from "fs";
2965
3066
  import { join as join27 } from "path";
2966
3067
  var START_MARKER = "# >>> hermes-repo memory (do not edit this block manually)";
2967
3068
  var END_MARKER = "# <<< hermes-repo memory";
2968
3069
  function mergeHermesGitignore(repoRoot) {
2969
3070
  const block = readTemplate("gitignore-block.txt").trimEnd() + "\n";
2970
3071
  const gitignorePath = join27(repoRoot, ".gitignore");
2971
- const contentBefore = existsSync19(gitignorePath) ? readFileSync20(gitignorePath, "utf8") : "";
3072
+ const contentBefore = existsSync19(gitignorePath) ? readFileSync21(gitignorePath, "utf8") : "";
2972
3073
  const warnBroadMemoryIgnore = contentBefore.length > 0 && !contentBefore.includes(START_MARKER) && /(^|\n)\.memory\/\s*$/m.test(contentBefore);
2973
3074
  if (!existsSync19(gitignorePath)) {
2974
3075
  writeFileSync11(gitignorePath, `${block}
@@ -3002,7 +3103,7 @@ function mergeHermesGitignore(repoRoot) {
3002
3103
  import { copyFileSync, mkdirSync as mkdirSync12, writeFileSync as writeFileSync14 } from "fs";
3003
3104
 
3004
3105
  // src/init/mergeConfig.ts
3005
- import { existsSync as existsSync20, readFileSync as readFileSync21 } from "fs";
3106
+ import { existsSync as existsSync20, readFileSync as readFileSync22 } from "fs";
3006
3107
  var DEFAULT_LLM = {
3007
3108
  enabled: false,
3008
3109
  provider: "openai",
@@ -3028,7 +3129,7 @@ function mergeConfigForInit(repoRoot, assistants) {
3028
3129
  let existing = {};
3029
3130
  if (existed) {
3030
3131
  try {
3031
- existing = JSON.parse(readFileSync21(configPath, "utf8"));
3132
+ existing = JSON.parse(readFileSync22(configPath, "utf8"));
3032
3133
  } catch {
3033
3134
  existing = {};
3034
3135
  }
@@ -3064,7 +3165,7 @@ function mergeConfigForInit(repoRoot, assistants) {
3064
3165
  }
3065
3166
 
3066
3167
  // src/init/mergeAgentsMd.ts
3067
- import { existsSync as existsSync21, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "fs";
3168
+ import { existsSync as existsSync21, readFileSync as readFileSync23, writeFileSync as writeFileSync12 } from "fs";
3068
3169
  import { join as join28 } from "path";
3069
3170
  var HERMES_AGENTS_START_MARKER = "<!-- >>> hermes-repo agents (do not edit this block manually) -->";
3070
3171
  var HERMES_AGENTS_END_MARKER = "<!-- <<< hermes-repo agents -->";
@@ -3127,7 +3228,7 @@ function mergeAgentsMd(repoRoot, force) {
3127
3228
  writeFileSync12(agentsPath, buildNewAgentsMd(), "utf8");
3128
3229
  return "created";
3129
3230
  }
3130
- const content = readFileSync22(agentsPath, "utf8");
3231
+ const content = readFileSync23(agentsPath, "utf8");
3131
3232
  if (agentsMdHasHermesBlock(content)) {
3132
3233
  if (!force) {
3133
3234
  return "skipped";
@@ -3235,7 +3336,7 @@ function writeScaffoldFiles(repoRoot, opts, report) {
3235
3336
 
3236
3337
  // src/init/prompts.ts
3237
3338
  import { checkbox, confirm, input } from "@inquirer/prompts";
3238
- import { existsSync as existsSync23, readFileSync as readFileSync23 } from "fs";
3339
+ import { existsSync as existsSync23, readFileSync as readFileSync24 } from "fs";
3239
3340
  import { resolve as resolve6 } from "path";
3240
3341
  function isInitialized(targetDir) {
3241
3342
  const configPath = memoryPath(targetDir, "config.json");
@@ -3243,7 +3344,7 @@ function isInitialized(targetDir) {
3243
3344
  return false;
3244
3345
  }
3245
3346
  try {
3246
- const config = JSON.parse(readFileSync23(configPath, "utf8"));
3347
+ const config = JSON.parse(readFileSync24(configPath, "utf8"));
3247
3348
  return typeof config.version === "number" && config.version >= 1;
3248
3349
  } catch {
3249
3350
  return false;