@phren/cli 0.1.35 → 0.1.37

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.
@@ -29,7 +29,7 @@ export const webUiManifest = {
29
29
  "search.history": { implemented: false, reason: "No search history in web UI" },
30
30
  // Graph
31
31
  "graph.read": { implemented: true, handler: "memory-ui-server.ts:/api/graph" },
32
- "graph.visualize": { implemented: true, handler: "memory-ui-graph-app.ts:graph tab (Sigma.js v3 + ForceAtlas2)" },
32
+ "graph.visualize": { implemented: true, handler: "memory-ui-graph-app.ts:graph tab (GraphRAG-style store>project>finding cages, Three.js / 3d-force-graph, CSS2D labels)" },
33
33
  "graph.link_findings": { implemented: false, reason: "No link findings action in web UI" },
34
34
  // Config
35
35
  "config.get": { implemented: true, handler: "memory-ui-server.ts:/api/settings (read)" },
@@ -58,6 +58,20 @@ function collectFindingBulletLines(lines) {
58
58
  }
59
59
  return bulletLines;
60
60
  }
61
+ /** Bullet content with metadata comments removed — what the user actually sees. */
62
+ function bulletContentKey(line) {
63
+ return line.replace(/<!--.*?-->/g, " ").replace(/\s+/g, " ").trim();
64
+ }
65
+ /**
66
+ * Multiple matches are only truly ambiguous when their CONTENT differs. When a
67
+ * store carries literal duplicate bullets (same text, same tag), acting on the
68
+ * first occurrence is what the caller means — refusing made duplicate findings
69
+ * uneditable/undeletable from every host UI.
70
+ */
71
+ function resolveDuplicateMatches(matches) {
72
+ const first = bulletContentKey(matches[0].line);
73
+ return matches.every(({ line }) => bulletContentKey(line) === first) ? matches[0] : null;
74
+ }
61
75
  function findMatchingFindingBullet(bulletLines, needle, match) {
62
76
  const fidNeedle = needle.replace(/^fid:/, "");
63
77
  const fidMatch = /^[a-z0-9]{8}$/.test(fidNeedle)
@@ -70,11 +84,17 @@ function findMatchingFindingBullet(bulletLines, needle, match) {
70
84
  if (exactMatches.length === 1)
71
85
  return { kind: "found", idx: exactMatches[0].i };
72
86
  if (exactMatches.length > 1) {
87
+ const dup = resolveDuplicateMatches(exactMatches);
88
+ if (dup)
89
+ return { kind: "found", idx: dup.i };
73
90
  return { kind: "ambiguous", error: `"${match}" is ambiguous (${exactMatches.length} exact matches). Use a more specific phrase.` };
74
91
  }
75
92
  if (partialMatches.length === 1)
76
93
  return { kind: "found", idx: partialMatches[0].i };
77
94
  if (partialMatches.length > 1) {
95
+ const dup = resolveDuplicateMatches(partialMatches);
96
+ if (dup)
97
+ return { kind: "found", idx: dup.i };
78
98
  return { kind: "ambiguous", error: `"${match}" is ambiguous (${partialMatches.length} partial matches). Use a more specific phrase.` };
79
99
  }
80
100
  return { kind: "not_found" };
@@ -399,7 +419,12 @@ export function editFinding(phrenPath, project, oldText, newText) {
399
419
  const existing = lines[idx];
400
420
  const metaMatch = existing.match(/(<!--.*?-->)/g);
401
421
  const metaSuffix = metaMatch ? " " + metaMatch.join(" ") : "";
402
- lines[idx] = `- ${newTextTrimmed}${metaSuffix}`;
422
+ // Preserve the bullet's [tag] prefix: host UIs display (and send back)
423
+ // tag-stripped text, and losing the tag silently demoted the finding to
424
+ // untagged. Keep the old tag unless the new text supplies its own.
425
+ const existingTag = existing.match(/^-\s*(\[[a-z][a-z0-9_-]*\])\s/)?.[1];
426
+ const tagPrefix = existingTag && !/^\[[a-z][a-z0-9_-]*\]/.test(newTextTrimmed) ? `${existingTag} ` : "";
427
+ lines[idx] = `- ${tagPrefix}${newTextTrimmed}${metaSuffix}`;
403
428
  const normalized = lines.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd() + "\n";
404
429
  const tmp = findingsPath + ".tmp." + process.pid;
405
430
  fs.writeFileSync(tmp, normalized);