@riconext/hermes-repo 1.2.3 → 1.2.4

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 089eb55: 兼容 LLM 返回 path 和 YAML frontmatter 的知识文件格式,避免有效知识文件在 flush 时被过滤丢弃。
8
+
3
9
  ## 1.2.3
4
10
 
5
11
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -1349,7 +1349,11 @@ var CONSOLIDATE_SYSTEM_PROMPT = `\u4F60\u662F\u4E00\u4E2A\u9879\u76EE\u77E5\u8BC
1349
1349
  ## \u8F93\u51FA\u8981\u6C42
1350
1350
  - \u8F93\u51FA\u4E25\u683C JSON \u683C\u5F0F
1351
1351
  - knowledgeFiles \u6570\u7EC4\u5305\u542B\u6240\u6709\u9700\u8981\u521B\u5EFA/\u66F4\u65B0\u7684\u6587\u4EF6
1352
- - \u6BCF\u9879\u5FC5\u987B\u5305\u542B\u5B8C\u6574\u7684 frontmatter \u548C body markdown
1352
+ - \u6BCF\u9879\u5FC5\u987B\u5305\u542B targetPath\u3001action\u3001frontmatter\u3001body
1353
+ - targetPath \u662F\u76F8\u5BF9 .memory/ \u7684\u8DEF\u5F84\uFF0C\u4F8B\u5982 "domains/canvas/canvas-interaction.md"
1354
+ - \u4E0D\u8981\u4F7F\u7528 path\u3001filePath\u3001filename \u7B49\u5B57\u6BB5\u4EE3\u66FF targetPath
1355
+ - frontmatter \u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF0C\u4E0D\u8981\u8F93\u51FA YAML \u5B57\u7B26\u4E32
1356
+ - body \u662F\u4E0D\u5305\u542B frontmatter \u7684 markdown \u6B63\u6587
1353
1357
  - memoryMd \u662F\u5B8C\u6574 MEMORY.md \u5185\u5BB9
1354
1358
  - \u65E0\u4EF7\u503C\u7684 session \u5728 skippedSessions \u4E2D\u8BF4\u660E\u539F\u56E0\uFF08\u800C\u975E\u751F\u6210\u7A7A\u5185\u5BB9\uFF09`;
1355
1359
  function scanExistingKnowledge(repoRoot) {
@@ -1568,16 +1572,51 @@ function validateAndNormalizeLlmResult(raw) {
1568
1572
  function normalizeKnowledgeFile(raw) {
1569
1573
  if (!raw || typeof raw !== "object") return null;
1570
1574
  const obj = raw;
1571
- if (typeof obj.targetPath !== "string" || !["create", "update"].includes(obj.action) || typeof obj.body !== "string") {
1575
+ const targetPath = typeof obj.targetPath === "string" ? obj.targetPath : typeof obj.path === "string" ? obj.path : null;
1576
+ if (!targetPath || !["create", "update"].includes(obj.action) || typeof obj.body !== "string") {
1572
1577
  return null;
1573
1578
  }
1574
1579
  return {
1575
- targetPath: obj.targetPath,
1580
+ targetPath,
1576
1581
  action: obj.action,
1577
- frontmatter: typeof obj.frontmatter === "object" && obj.frontmatter !== null ? obj.frontmatter : {},
1582
+ frontmatter: normalizeFrontmatter(obj.frontmatter),
1578
1583
  body: obj.body
1579
1584
  };
1580
1585
  }
1586
+ function normalizeFrontmatter(raw) {
1587
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
1588
+ return raw;
1589
+ }
1590
+ if (typeof raw !== "string") {
1591
+ return {};
1592
+ }
1593
+ const text = raw.trim();
1594
+ const yaml = text.startsWith("---") ? text.replace(/^---\r?\n?/, "").replace(/\r?\n?---$/, "") : text;
1595
+ const frontmatter = {};
1596
+ for (const line of yaml.split(/\r?\n/)) {
1597
+ const trimmed = line.trim();
1598
+ if (!trimmed || trimmed.startsWith("#")) {
1599
+ continue;
1600
+ }
1601
+ const separator = trimmed.indexOf(":");
1602
+ if (separator <= 0) {
1603
+ continue;
1604
+ }
1605
+ const key = trimmed.slice(0, separator).trim();
1606
+ const value = trimmed.slice(separator + 1).trim();
1607
+ frontmatter[key] = parseFrontmatterValue(value);
1608
+ }
1609
+ return frontmatter;
1610
+ }
1611
+ function parseFrontmatterValue(value) {
1612
+ const unquoted = value.replace(/^["']|["']$/g, "");
1613
+ if (unquoted.startsWith("[") && unquoted.endsWith("]")) {
1614
+ return unquoted.slice(1, -1).split(",").map((item) => item.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
1615
+ }
1616
+ if (unquoted === "true") return true;
1617
+ if (unquoted === "false") return false;
1618
+ return unquoted;
1619
+ }
1581
1620
  function isSkippedEntry(raw) {
1582
1621
  if (!raw || typeof raw !== "object") return false;
1583
1622
  const obj = raw;