@phren/cli 0.1.35 → 0.1.36
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/capabilities/web-ui.js +1 -1
- package/dist/data/access.js +26 -1
- package/dist/generated/memory-ui-graph.browser.js +5688 -294
- package/dist/hooks.d.ts +9 -0
- package/dist/hooks.js +17 -1
- package/dist/init/init-configure.js +13 -0
- package/dist/link/doctor.js +14 -1
- package/dist/memory-ui-graph.runtime.js +5688 -294
- package/dist/ui/data.d.ts +5 -0
- package/dist/ui/data.js +46 -7
- package/dist/ui/graph-chrome.d.ts +1 -0
- package/dist/ui/graph-chrome.js +163 -0
- package/dist/ui/graph.js +1 -1
- package/dist/ui/page.js +3 -0
- package/dist/ui/scripts.js +126 -19
- package/dist/ui/server.js +34 -2
- package/package.json +3 -4
package/dist/ui/data.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ interface GraphNode {
|
|
|
24
24
|
scoreKeys?: string[];
|
|
25
25
|
topicSlug?: string;
|
|
26
26
|
topicLabel?: string;
|
|
27
|
+
/** Findings only: the `## YYYY-MM-DD` heading the entry sits under. */
|
|
28
|
+
date?: string;
|
|
29
|
+
/** Project nodes only: real per-project totals for tooltips/labels. */
|
|
30
|
+
findingCount?: number;
|
|
31
|
+
taskCount?: number;
|
|
27
32
|
}
|
|
28
33
|
interface GraphDocRef {
|
|
29
34
|
doc: string;
|
package/dist/ui/data.js
CHANGED
|
@@ -185,6 +185,19 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
185
185
|
const topicMetaMap = new Map();
|
|
186
186
|
// Track which project nodes have already been pushed (same name may appear in multiple stores)
|
|
187
187
|
const addedProjectNodeIds = new Set();
|
|
188
|
+
// Project nodes by name so per-project finding/task totals can be stamped after the scans
|
|
189
|
+
const projectNodeByName = new Map();
|
|
190
|
+
// Finding ids are content hashes, so duplicate-text bullets collide — every
|
|
191
|
+
// id-keyed map downstream (renderer, selection, removal) then conflates the
|
|
192
|
+
// twins. Salt repeat occurrences deterministically (file order); the FIRST
|
|
193
|
+
// occurrence keeps the canonical id so findingNodeIdForLine / lookup-event
|
|
194
|
+
// targeting stays in lockstep.
|
|
195
|
+
const usedFindingIds = new Map();
|
|
196
|
+
const uniqueFindingId = (id) => {
|
|
197
|
+
const seen = usedFindingIds.get(id) || 0;
|
|
198
|
+
usedFindingIds.set(id, seen + 1);
|
|
199
|
+
return seen === 0 ? id : `${id}-${seen + 1}`;
|
|
200
|
+
};
|
|
188
201
|
for (const { storePath, project } of storeProjects) {
|
|
189
202
|
// Load dynamic topics for this project
|
|
190
203
|
const { topics: projectTopics } = readProjectTopics(storePath, project);
|
|
@@ -198,7 +211,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
198
211
|
if (!fs.existsSync(findingsPath)) {
|
|
199
212
|
if (!addedProjectNodeIds.has(project)) {
|
|
200
213
|
addedProjectNodeIds.add(project);
|
|
201
|
-
|
|
214
|
+
const projectNode = {
|
|
202
215
|
id: project,
|
|
203
216
|
label: project,
|
|
204
217
|
fullLabel: project,
|
|
@@ -207,13 +220,17 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
207
220
|
project,
|
|
208
221
|
store: storeName,
|
|
209
222
|
tagged: false,
|
|
210
|
-
|
|
223
|
+
findingCount: 0,
|
|
224
|
+
taskCount: 0,
|
|
225
|
+
};
|
|
226
|
+
nodes.push(projectNode);
|
|
227
|
+
projectNodeByName.set(project, projectNode);
|
|
211
228
|
}
|
|
212
229
|
continue;
|
|
213
230
|
}
|
|
214
231
|
if (!addedProjectNodeIds.has(project)) {
|
|
215
232
|
addedProjectNodeIds.add(project);
|
|
216
|
-
|
|
233
|
+
const projectNode = {
|
|
217
234
|
id: project,
|
|
218
235
|
label: project,
|
|
219
236
|
fullLabel: project,
|
|
@@ -222,7 +239,11 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
222
239
|
project,
|
|
223
240
|
store: storeName,
|
|
224
241
|
tagged: false,
|
|
225
|
-
|
|
242
|
+
findingCount: 0,
|
|
243
|
+
taskCount: 0,
|
|
244
|
+
};
|
|
245
|
+
nodes.push(projectNode);
|
|
246
|
+
projectNodeByName.set(project, projectNode);
|
|
226
247
|
}
|
|
227
248
|
const content = fs.readFileSync(findingsPath, "utf8");
|
|
228
249
|
const lines = content.split("\n");
|
|
@@ -235,8 +256,15 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
235
256
|
// Support heading-based findings: ## topic / ### title / paragraph
|
|
236
257
|
let currentHeadingTag;
|
|
237
258
|
let _currentHeadingTitle;
|
|
259
|
+
// FINDINGS.md groups entries under `## YYYY-MM-DD` date headings
|
|
260
|
+
let currentDate;
|
|
238
261
|
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
239
262
|
const line = lines[lineIdx];
|
|
263
|
+
const dateMatch = line.match(/^##\s+(\d{4}-\d{2}-\d{2})\s*$/);
|
|
264
|
+
if (dateMatch) {
|
|
265
|
+
currentDate = dateMatch[1];
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
240
268
|
// Track heading context for heading-based findings
|
|
241
269
|
const h2Match = line.match(/^##\s+([a-z_-]+)\s*$/i);
|
|
242
270
|
if (h2Match) {
|
|
@@ -264,7 +292,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
264
292
|
continue;
|
|
265
293
|
const topic = classifyTopicForText(`[${currentHeadingTag}] ${text}`, projectTopics);
|
|
266
294
|
const scoreKey = entryScoreKey(project, FINDINGS_FILENAME, `[${currentHeadingTag}] ${text}`);
|
|
267
|
-
const nodeId = findingStableId(scoreKey);
|
|
295
|
+
const nodeId = uniqueFindingId(findingStableId(scoreKey));
|
|
268
296
|
taggedCount++;
|
|
269
297
|
nodes.push({
|
|
270
298
|
id: nodeId,
|
|
@@ -280,6 +308,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
280
308
|
refDocs: [{ doc: `${project}/FINDINGS.md`, project, scoreKey }],
|
|
281
309
|
topicSlug: topic.slug,
|
|
282
310
|
topicLabel: topic.label,
|
|
311
|
+
date: currentDate,
|
|
283
312
|
});
|
|
284
313
|
links.push({ source: project, target: nodeId });
|
|
285
314
|
for (const other of exactProjectMentions(text, projectSet, project)) {
|
|
@@ -299,7 +328,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
299
328
|
// Classify the finding using the project's topic system
|
|
300
329
|
const topic = classifyTopicForText(`[${tag}] ${text}`, projectTopics);
|
|
301
330
|
const scoreKey = entryScoreKey(project, FINDINGS_FILENAME, `[${tag}] ${text}`);
|
|
302
|
-
const nodeId = findingStableId(scoreKey);
|
|
331
|
+
const nodeId = uniqueFindingId(findingStableId(scoreKey));
|
|
303
332
|
taggedCount++;
|
|
304
333
|
nodes.push({
|
|
305
334
|
id: nodeId,
|
|
@@ -315,6 +344,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
315
344
|
refDocs: [{ doc: `${project}/FINDINGS.md`, project, scoreKey }],
|
|
316
345
|
topicSlug: topic.slug,
|
|
317
346
|
topicLabel: topic.label,
|
|
347
|
+
date: currentDate,
|
|
318
348
|
});
|
|
319
349
|
links.push({ source: project, target: nodeId });
|
|
320
350
|
for (const other of exactProjectMentions(text, projectSet, project)) {
|
|
@@ -334,7 +364,7 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
334
364
|
// Classify using dynamic topics
|
|
335
365
|
const topic = classifyTopicForText(text, projectTopics);
|
|
336
366
|
const scoreKey = entryScoreKey(project, FINDINGS_FILENAME, text);
|
|
337
|
-
const nodeId = findingStableId(scoreKey);
|
|
367
|
+
const nodeId = uniqueFindingId(findingStableId(scoreKey));
|
|
338
368
|
untaggedAdded++;
|
|
339
369
|
nodes.push({
|
|
340
370
|
id: nodeId,
|
|
@@ -350,9 +380,14 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
350
380
|
refDocs: [{ doc: `${project}/FINDINGS.md`, project, scoreKey }],
|
|
351
381
|
topicSlug: topic.slug,
|
|
352
382
|
topicLabel: topic.label,
|
|
383
|
+
date: currentDate,
|
|
353
384
|
});
|
|
354
385
|
links.push({ source: project, target: nodeId });
|
|
355
386
|
}
|
|
387
|
+
const projectNode = projectNodeByName.get(project);
|
|
388
|
+
if (projectNode) {
|
|
389
|
+
projectNode.findingCount = (projectNode.findingCount || 0) + taggedCount + untaggedAdded;
|
|
390
|
+
}
|
|
356
391
|
}
|
|
357
392
|
// ── Tasks ──────────────────────────────────────────────────────────
|
|
358
393
|
try {
|
|
@@ -391,6 +426,10 @@ export async function buildGraph(phrenPath, profile, focusProject, existingDb) {
|
|
|
391
426
|
taskCount++;
|
|
392
427
|
}
|
|
393
428
|
}
|
|
429
|
+
const projectNode = projectNodeByName.get(project);
|
|
430
|
+
if (projectNode) {
|
|
431
|
+
projectNode.taskCount = (projectNode.taskCount || 0) + taskCount;
|
|
432
|
+
}
|
|
394
433
|
}
|
|
395
434
|
}
|
|
396
435
|
catch {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GRAPH_HUD_STYLES = "\n/* \u2500\u2500 Full-bleed graph tab \u2014 total dark immersion (header included) \u2500\u2500 */\nbody:has(#tab-graph.active) { background: #04050b; }\nbody:has(#tab-graph.active) .main { max-width: none; padding: 0; }\nbody:has(#tab-graph.active) .header {\n background: rgba(5, 6, 13, 0.92);\n border-bottom: 1px solid rgba(103, 232, 249, 0.12);\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n}\nbody:has(#tab-graph.active) .header .nav-item { color: #7f8db8; }\nbody:has(#tab-graph.active) .header .nav-item.active { color: #67e8f9; }\nbody:has(#tab-graph.active) .header .brand-name,\nbody:has(#tab-graph.active) .header-brand { color: #dbe6ff; }\n#tab-graph .graph-container {\n background: #04050b;\n border: none;\n border-radius: 0;\n position: relative;\n overflow: hidden;\n}\n#tab-graph #graph-canvas {\n height: calc(100vh - 64px);\n min-height: 520px;\n}\n\n/* \u2500\u2500 Overlay chrome \u2014 compact HUD clustered top-right (GraphRAG) \u2500\u2500\u2500\u2500 */\n#tab-graph .graph-filters {\n background: transparent;\n border: none;\n box-shadow: none;\n padding: 0;\n left: auto;\n right: 60px;\n width: min(560px, 60%);\n z-index: 10;\n}\n#tab-graph .graph-controls { z-index: 10; }\n#tab-graph .graph-controls button {\n width: 34px;\n height: 34px;\n border-radius: 8px;\n border: 1px solid rgba(103, 232, 249, 0.2);\n background: rgba(8, 10, 22, 0.85);\n color: #9fb2e8;\n font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n cursor: pointer;\n transition: border-color 0.15s ease, color 0.15s ease;\n}\n#tab-graph .graph-controls button:hover {\n border-color: rgba(103, 232, 249, 0.55);\n color: #e6f6ff;\n}\n\n/* \u2500\u2500 Docked dossier \u2014 left side, compact (GraphRAG inspector) \u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n#graph-node-popover.phren-docked {\n left: 16px !important;\n right: auto !important;\n top: 68px !important;\n bottom: 16px;\n width: 340px;\n max-width: min(360px, calc(100% - 32px));\n pointer-events: none;\n z-index: 12;\n}\n/* GraphRAG-style stats row + relationships in the inspector */\n.phren-dossier-stats {\n display: grid;\n grid-template-columns: repeat(3, 1fr);\n border: 1px solid rgba(103, 232, 249, 0.16);\n border-radius: 8px;\n overflow: hidden;\n margin: 12px 0 4px;\n}\n.phren-dossier-stats > div {\n padding: 8px 10px;\n border-right: 1px solid rgba(103, 232, 249, 0.12);\n}\n.phren-dossier-stats > div:last-child { border-right: 0; }\n.phren-dossier-stats .k {\n font: 700 8.5px/1.4 ui-monospace, Menlo, monospace;\n letter-spacing: 0.12em; color: #6b76a0; text-transform: uppercase;\n}\n.phren-dossier-stats .v {\n font: 700 14px/1.2 ui-monospace, Menlo, monospace; color: #67e8f9; margin-top: 3px;\n}\n.phren-rel-row {\n display: flex; align-items: baseline; justify-content: space-between; gap: 10px;\n padding: 7px 0; border-bottom: 1px solid rgba(120, 150, 220, 0.08); cursor: pointer;\n}\n.phren-rel-row:last-child { border-bottom: 0; }\n.phren-rel-row .n { font-size: 12px; color: #d6e2ff; overflow: hidden; text-overflow: ellipsis; }\n.phren-rel-row .n small { display: block; color: #6b76a0; font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.phren-rel-row .w { font: 600 11px/1.4 ui-monospace, Menlo, monospace; color: #67e8f9; font-variant-numeric: tabular-nums; }\n.phren-rel-row:hover .n { color: #eaf2ff; }\n#graph-node-popover.phren-docked #graph-node-popover-card {\n --surface: #0a0d1e;\n --surface-raised: rgba(22, 27, 52, 0.9);\n --surface-sunken: rgba(5, 6, 15, 0.92);\n --ink: #dbe4ff;\n --muted: #8b96c9;\n --border: rgba(103, 232, 249, 0.2);\n --accent: #67e8f9;\n --accent-dim: rgba(103, 232, 249, 0.12);\n height: 100%;\n overflow: auto;\n pointer-events: auto;\n background: rgba(8, 10, 22, 0.92);\n border: 1px solid rgba(103, 232, 249, 0.22);\n box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(103, 232, 249, 0.05);\n border-radius: 12px;\n color: #dbe4ff;\n backdrop-filter: blur(14px);\n -webkit-backdrop-filter: blur(14px);\n}\n#graph-node-popover.phren-docked .phren-dossier-kind {\n font: 700 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n color: #67e8f9;\n letter-spacing: 0.16em;\n text-transform: uppercase;\n}\n#graph-node-popover.phren-docked #graph-node-popover-card { padding: 14px 15px; }\n#graph-node-popover.phren-docked .phren-dossier-text {\n white-space: pre-wrap;\n line-height: 1.6;\n font-size: 13px;\n color: #dde6fb;\n}\n.phren-dossier-section {\n font: 700 9.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n color: #67e8f9;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n margin-top: 4px;\n}\n.phren-dossier-nav {\n display: inline-flex;\n align-items: center;\n gap: 10px;\n font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n color: #8b96c9;\n}\n.phren-dossier-nav button {\n width: 28px;\n height: 28px;\n border-radius: 6px;\n border: 1px solid rgba(103, 232, 249, 0.2);\n background: rgba(12, 15, 30, 0.9);\n color: #9fb2e8;\n font-size: 14px;\n line-height: 1;\n cursor: pointer;\n transition: border-color 0.15s ease, color 0.15s ease;\n}\n.phren-dossier-nav button:hover {\n border-color: rgba(103, 232, 249, 0.55);\n color: #e6f6ff;\n}\n";
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// Holographic chrome for the Graph tab. Appended LAST in the page <style>
|
|
2
|
+
// block so it wins the cascade over the base styles. The graph canvas is
|
|
3
|
+
// immersive-dark in BOTH app themes (the 3D scene is always a dark void —
|
|
4
|
+
// a light chrome ring around it read as unfinished).
|
|
5
|
+
export const GRAPH_HUD_STYLES = `
|
|
6
|
+
/* ── Full-bleed graph tab — total dark immersion (header included) ── */
|
|
7
|
+
body:has(#tab-graph.active) { background: #04050b; }
|
|
8
|
+
body:has(#tab-graph.active) .main { max-width: none; padding: 0; }
|
|
9
|
+
body:has(#tab-graph.active) .header {
|
|
10
|
+
background: rgba(5, 6, 13, 0.92);
|
|
11
|
+
border-bottom: 1px solid rgba(103, 232, 249, 0.12);
|
|
12
|
+
backdrop-filter: blur(10px);
|
|
13
|
+
-webkit-backdrop-filter: blur(10px);
|
|
14
|
+
}
|
|
15
|
+
body:has(#tab-graph.active) .header .nav-item { color: #7f8db8; }
|
|
16
|
+
body:has(#tab-graph.active) .header .nav-item.active { color: #67e8f9; }
|
|
17
|
+
body:has(#tab-graph.active) .header .brand-name,
|
|
18
|
+
body:has(#tab-graph.active) .header-brand { color: #dbe6ff; }
|
|
19
|
+
#tab-graph .graph-container {
|
|
20
|
+
background: #04050b;
|
|
21
|
+
border: none;
|
|
22
|
+
border-radius: 0;
|
|
23
|
+
position: relative;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
#tab-graph #graph-canvas {
|
|
27
|
+
height: calc(100vh - 64px);
|
|
28
|
+
min-height: 520px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* ── Overlay chrome — compact HUD clustered top-right (GraphRAG) ──── */
|
|
32
|
+
#tab-graph .graph-filters {
|
|
33
|
+
background: transparent;
|
|
34
|
+
border: none;
|
|
35
|
+
box-shadow: none;
|
|
36
|
+
padding: 0;
|
|
37
|
+
left: auto;
|
|
38
|
+
right: 60px;
|
|
39
|
+
width: min(560px, 60%);
|
|
40
|
+
z-index: 10;
|
|
41
|
+
}
|
|
42
|
+
#tab-graph .graph-controls { z-index: 10; }
|
|
43
|
+
#tab-graph .graph-controls button {
|
|
44
|
+
width: 34px;
|
|
45
|
+
height: 34px;
|
|
46
|
+
border-radius: 8px;
|
|
47
|
+
border: 1px solid rgba(103, 232, 249, 0.2);
|
|
48
|
+
background: rgba(8, 10, 22, 0.85);
|
|
49
|
+
color: #9fb2e8;
|
|
50
|
+
font: 700 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
transition: border-color 0.15s ease, color 0.15s ease;
|
|
53
|
+
}
|
|
54
|
+
#tab-graph .graph-controls button:hover {
|
|
55
|
+
border-color: rgba(103, 232, 249, 0.55);
|
|
56
|
+
color: #e6f6ff;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* ── Docked dossier — left side, compact (GraphRAG inspector) ─────── */
|
|
60
|
+
#graph-node-popover.phren-docked {
|
|
61
|
+
left: 16px !important;
|
|
62
|
+
right: auto !important;
|
|
63
|
+
top: 68px !important;
|
|
64
|
+
bottom: 16px;
|
|
65
|
+
width: 340px;
|
|
66
|
+
max-width: min(360px, calc(100% - 32px));
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
z-index: 12;
|
|
69
|
+
}
|
|
70
|
+
/* GraphRAG-style stats row + relationships in the inspector */
|
|
71
|
+
.phren-dossier-stats {
|
|
72
|
+
display: grid;
|
|
73
|
+
grid-template-columns: repeat(3, 1fr);
|
|
74
|
+
border: 1px solid rgba(103, 232, 249, 0.16);
|
|
75
|
+
border-radius: 8px;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
margin: 12px 0 4px;
|
|
78
|
+
}
|
|
79
|
+
.phren-dossier-stats > div {
|
|
80
|
+
padding: 8px 10px;
|
|
81
|
+
border-right: 1px solid rgba(103, 232, 249, 0.12);
|
|
82
|
+
}
|
|
83
|
+
.phren-dossier-stats > div:last-child { border-right: 0; }
|
|
84
|
+
.phren-dossier-stats .k {
|
|
85
|
+
font: 700 8.5px/1.4 ui-monospace, Menlo, monospace;
|
|
86
|
+
letter-spacing: 0.12em; color: #6b76a0; text-transform: uppercase;
|
|
87
|
+
}
|
|
88
|
+
.phren-dossier-stats .v {
|
|
89
|
+
font: 700 14px/1.2 ui-monospace, Menlo, monospace; color: #67e8f9; margin-top: 3px;
|
|
90
|
+
}
|
|
91
|
+
.phren-rel-row {
|
|
92
|
+
display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
|
|
93
|
+
padding: 7px 0; border-bottom: 1px solid rgba(120, 150, 220, 0.08); cursor: pointer;
|
|
94
|
+
}
|
|
95
|
+
.phren-rel-row:last-child { border-bottom: 0; }
|
|
96
|
+
.phren-rel-row .n { font-size: 12px; color: #d6e2ff; overflow: hidden; text-overflow: ellipsis; }
|
|
97
|
+
.phren-rel-row .n small { display: block; color: #6b76a0; font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
98
|
+
.phren-rel-row .w { font: 600 11px/1.4 ui-monospace, Menlo, monospace; color: #67e8f9; font-variant-numeric: tabular-nums; }
|
|
99
|
+
.phren-rel-row:hover .n { color: #eaf2ff; }
|
|
100
|
+
#graph-node-popover.phren-docked #graph-node-popover-card {
|
|
101
|
+
--surface: #0a0d1e;
|
|
102
|
+
--surface-raised: rgba(22, 27, 52, 0.9);
|
|
103
|
+
--surface-sunken: rgba(5, 6, 15, 0.92);
|
|
104
|
+
--ink: #dbe4ff;
|
|
105
|
+
--muted: #8b96c9;
|
|
106
|
+
--border: rgba(103, 232, 249, 0.2);
|
|
107
|
+
--accent: #67e8f9;
|
|
108
|
+
--accent-dim: rgba(103, 232, 249, 0.12);
|
|
109
|
+
height: 100%;
|
|
110
|
+
overflow: auto;
|
|
111
|
+
pointer-events: auto;
|
|
112
|
+
background: rgba(8, 10, 22, 0.92);
|
|
113
|
+
border: 1px solid rgba(103, 232, 249, 0.22);
|
|
114
|
+
box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6), 0 0 30px rgba(103, 232, 249, 0.05);
|
|
115
|
+
border-radius: 12px;
|
|
116
|
+
color: #dbe4ff;
|
|
117
|
+
backdrop-filter: blur(14px);
|
|
118
|
+
-webkit-backdrop-filter: blur(14px);
|
|
119
|
+
}
|
|
120
|
+
#graph-node-popover.phren-docked .phren-dossier-kind {
|
|
121
|
+
font: 700 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
122
|
+
color: #67e8f9;
|
|
123
|
+
letter-spacing: 0.16em;
|
|
124
|
+
text-transform: uppercase;
|
|
125
|
+
}
|
|
126
|
+
#graph-node-popover.phren-docked #graph-node-popover-card { padding: 14px 15px; }
|
|
127
|
+
#graph-node-popover.phren-docked .phren-dossier-text {
|
|
128
|
+
white-space: pre-wrap;
|
|
129
|
+
line-height: 1.6;
|
|
130
|
+
font-size: 13px;
|
|
131
|
+
color: #dde6fb;
|
|
132
|
+
}
|
|
133
|
+
.phren-dossier-section {
|
|
134
|
+
font: 700 9.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
135
|
+
color: #67e8f9;
|
|
136
|
+
letter-spacing: 0.14em;
|
|
137
|
+
text-transform: uppercase;
|
|
138
|
+
margin-top: 4px;
|
|
139
|
+
}
|
|
140
|
+
.phren-dossier-nav {
|
|
141
|
+
display: inline-flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 10px;
|
|
144
|
+
font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
145
|
+
color: #8b96c9;
|
|
146
|
+
}
|
|
147
|
+
.phren-dossier-nav button {
|
|
148
|
+
width: 28px;
|
|
149
|
+
height: 28px;
|
|
150
|
+
border-radius: 6px;
|
|
151
|
+
border: 1px solid rgba(103, 232, 249, 0.2);
|
|
152
|
+
background: rgba(12, 15, 30, 0.9);
|
|
153
|
+
color: #9fb2e8;
|
|
154
|
+
font-size: 14px;
|
|
155
|
+
line-height: 1;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
transition: border-color 0.15s ease, color 0.15s ease;
|
|
158
|
+
}
|
|
159
|
+
.phren-dossier-nav button:hover {
|
|
160
|
+
border-color: rgba(103, 232, 249, 0.55);
|
|
161
|
+
color: #e6f6ff;
|
|
162
|
+
}
|
|
163
|
+
`;
|
package/dist/ui/graph.js
CHANGED
|
@@ -26,7 +26,7 @@ export function renderGraphScript() {
|
|
|
26
26
|
}
|
|
27
27
|
return `
|
|
28
28
|
(function() {
|
|
29
|
-
console.error('[phrenGraph] Bundled
|
|
29
|
+
console.error('[phrenGraph] Bundled graph renderer asset not found. Run "npm run build" in the phren repo root.');
|
|
30
30
|
window.phrenGraph = window.phrenGraph || {
|
|
31
31
|
__renderer: 'missing',
|
|
32
32
|
mount: function() {},
|
package/dist/ui/page.js
CHANGED
|
@@ -2,6 +2,7 @@ import { WEB_UI_STYLES, renderWebUiScript } from "./assets.js";
|
|
|
2
2
|
import { renderGraphScript } from "./graph.js";
|
|
3
3
|
import { LAYOUT_VIEWPORT_STYLES, PROJECT_REFERENCE_UI_STYLES, REVIEW_UI_STYLES, SETTINGS_TAB_UI_STYLES, TASK_UI_STYLES } from "./styles.js";
|
|
4
4
|
import { PHREN_DEEP_VOID_STYLES } from "./deep-void.js";
|
|
5
|
+
import { GRAPH_HUD_STYLES } from "./graph-chrome.js";
|
|
5
6
|
import { renderSharedWebUiHelpers, renderSkillUiEnhancementScript, renderProfileSwitcherScript, renderProjectReferenceEnhancementScript, renderTasksAndSettingsScript, renderReviewQueueKeyboardScript, renderSearchScript, renderEventWiringScript, renderGraphHostScript, renderActivityStreamScript, renderGraphWalkScript, } from "./scripts.js";
|
|
6
7
|
function h(s) {
|
|
7
8
|
return s
|
|
@@ -20,6 +21,7 @@ export function renderWebUiPage(_phrenPath, authToken, nonce) {
|
|
|
20
21
|
<link rel="preconnect" href="https://fonts.bunny.net" />
|
|
21
22
|
<link href="https://fonts.bunny.net/css?family=inter:400,500,600,700|space-grotesk:400,500,600,700|jetbrains-mono:400,500,700&display=swap" rel="stylesheet" />
|
|
22
23
|
<title>phren</title>
|
|
24
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='15' fill='%2312122a'/%3E%3Ccircle cx='16' cy='16' r='8' fill='%237c6bf5'/%3E%3Ccircle cx='13' cy='13' r='3' fill='%23a99cfa'/%3E%3C/svg%3E" />
|
|
23
25
|
<style>
|
|
24
26
|
${WEB_UI_STYLES}
|
|
25
27
|
${PROJECT_REFERENCE_UI_STYLES}
|
|
@@ -28,6 +30,7 @@ ${TASK_UI_STYLES}
|
|
|
28
30
|
${REVIEW_UI_STYLES}
|
|
29
31
|
${PHREN_DEEP_VOID_STYLES}
|
|
30
32
|
${LAYOUT_VIEWPORT_STYLES}
|
|
33
|
+
${GRAPH_HUD_STYLES}
|
|
31
34
|
</style>
|
|
32
35
|
</head>
|
|
33
36
|
<body>
|
package/dist/ui/scripts.js
CHANGED
|
@@ -1889,22 +1889,17 @@ export function renderGraphHostScript() {
|
|
|
1889
1889
|
if (typeof window.graphClearSelection === 'function') window.graphClearSelection();
|
|
1890
1890
|
}
|
|
1891
1891
|
|
|
1892
|
+
// The dossier docks to the right edge of the graph viewport — a stable
|
|
1893
|
+
// reading pane instead of a cursor-chasing popover. Signature kept for
|
|
1894
|
+
// callers; the x/y hint is no longer needed.
|
|
1892
1895
|
function positionPopover(x, y) {
|
|
1893
1896
|
var popover = document.getElementById('graph-node-popover');
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
+
if (!popover) return;
|
|
1898
|
+
popover.classList.add('phren-docked');
|
|
1899
|
+
popover.style.left = '';
|
|
1900
|
+
popover.style.top = '';
|
|
1901
|
+
popover.style.visibility = 'visible';
|
|
1897
1902
|
popover.style.display = 'block';
|
|
1898
|
-
popover.style.visibility = 'hidden';
|
|
1899
|
-
requestAnimationFrame(function() {
|
|
1900
|
-
var containerRect = container.getBoundingClientRect();
|
|
1901
|
-
var cardRect = card.getBoundingClientRect();
|
|
1902
|
-
var left = Math.min(Math.max(12, x + 18), Math.max(12, containerRect.width - cardRect.width - 12));
|
|
1903
|
-
var top = Math.min(Math.max(12, y + 18), Math.max(12, containerRect.height - cardRect.height - 12));
|
|
1904
|
-
popover.style.left = left + 'px';
|
|
1905
|
-
popover.style.top = top + 'px';
|
|
1906
|
-
popover.style.visibility = 'visible';
|
|
1907
|
-
});
|
|
1908
1903
|
}
|
|
1909
1904
|
|
|
1910
1905
|
function currentPopoverPoint() {
|
|
@@ -1955,6 +1950,68 @@ export function renderGraphHostScript() {
|
|
|
1955
1950
|
return node.kind || 'Node';
|
|
1956
1951
|
}
|
|
1957
1952
|
|
|
1953
|
+
function findingSiblings(node) {
|
|
1954
|
+
var data = graphData();
|
|
1955
|
+
return (data.nodes || []).filter(function(candidate) {
|
|
1956
|
+
return candidate.kind === 'finding' && candidate.projectName === node.projectName;
|
|
1957
|
+
}).sort(function(a, b) { return a.id < b.id ? -1 : a.id > b.id ? 1 : 0; });
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
function findingNav(node) {
|
|
1961
|
+
var list = findingSiblings(node);
|
|
1962
|
+
var index = -1;
|
|
1963
|
+
for (var i = 0; i < list.length; i++) {
|
|
1964
|
+
if (list[i].id === node.id) { index = i; break; }
|
|
1965
|
+
}
|
|
1966
|
+
return { list: list, index: index, total: list.length };
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
function relatedFindings(node) {
|
|
1970
|
+
return findingSiblings(node).filter(function(candidate) {
|
|
1971
|
+
return candidate.id !== node.id && candidate.topicSlug && candidate.topicSlug === node.topicSlug;
|
|
1972
|
+
}).slice(0, 4);
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
// Neighbors of the node from the live graph links, scored so the panel can
|
|
1976
|
+
// list "strongest relationships" like GraphRAG. Entities/findings first.
|
|
1977
|
+
function strongestRelationships(node) {
|
|
1978
|
+
var map = nodeMap();
|
|
1979
|
+
var ids = neighborIds(node.id);
|
|
1980
|
+
var out = [];
|
|
1981
|
+
for (var i = 0; i < ids.length; i++) {
|
|
1982
|
+
var nb = map[ids[i]];
|
|
1983
|
+
if (!nb || nb.kind === 'project') continue;
|
|
1984
|
+
var w = 0.6;
|
|
1985
|
+
if (nb.kind === 'entity') w = 0.7 + Math.min(0.28, (nb.refCount || 0) * 0.03);
|
|
1986
|
+
else if (nb.kind === 'finding') w = typeof nb.qualityScore === 'number' ? 0.55 + nb.qualityScore * 0.4 : 0.6;
|
|
1987
|
+
var name = nb.displayLabel || nb.label || nb.id;
|
|
1988
|
+
var sub = nb.kind === 'entity' ? ((nb.refCount || 0) + ' references') : (nb.tooltipLabel || nb.fullLabel || '');
|
|
1989
|
+
if (sub === name) sub = '';
|
|
1990
|
+
out.push({ id: nb.id, name: name, sub: sub, w: w });
|
|
1991
|
+
}
|
|
1992
|
+
// same-topic siblings that aren't already linked, as softer relationships.
|
|
1993
|
+
// Dedupe by display TEXT too — stores can hold near-duplicate findings and
|
|
1994
|
+
// two identical rows read as a rendering bug.
|
|
1995
|
+
var seen = {}; var seenName = {};
|
|
1996
|
+
out.forEach(function(r) { seen[r.id] = true; seenName[r.name.toLowerCase()] = true; });
|
|
1997
|
+
relatedFindings(node).forEach(function(rel) {
|
|
1998
|
+
if (seen[rel.id]) return;
|
|
1999
|
+
var relName = rel.displayLabel || rel.label || rel.id;
|
|
2000
|
+
if (seenName[relName.toLowerCase()]) return;
|
|
2001
|
+
seenName[relName.toLowerCase()] = true;
|
|
2002
|
+
var relSub = 'same topic' + (rel.projectName && rel.projectName !== node.projectName ? ' · ' + rel.projectName : '');
|
|
2003
|
+
out.push({ id: rel.id, name: relName, sub: relSub, w: 0.5 });
|
|
2004
|
+
});
|
|
2005
|
+
out.sort(function(a, b) { return b.w - a.w; });
|
|
2006
|
+
return out.slice(0, 6);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
function gotoChip(label, nodeId, accent) {
|
|
2010
|
+
var border = accent ? 'var(--accent)' : 'var(--border)';
|
|
2011
|
+
var bg = accent ? 'var(--accent-dim)' : 'var(--surface-raised)';
|
|
2012
|
+
return '<span data-graph-goto="' + esc(nodeId) + '" role="button" tabindex="0" style="display:inline-flex;align-items:center;gap:6px;padding:4px 9px;border-radius:999px;border:1px solid ' + border + ';background:' + bg + ';font-size:11px;color:var(--ink);cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">' + esc(label) + '</span>';
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1958
2015
|
function chip(text, accent) {
|
|
1959
2016
|
var border = accent ? 'var(--accent)' : 'var(--border)';
|
|
1960
2017
|
var bg = accent ? 'var(--accent-dim)' : 'var(--surface-raised)';
|
|
@@ -1984,22 +2041,51 @@ export function renderGraphHostScript() {
|
|
|
1984
2041
|
if (node.kind === 'task' && node.section) meta.push(node.section);
|
|
1985
2042
|
if (node.kind === 'task' && node.priority) meta.push('Priority ' + node.priority);
|
|
1986
2043
|
if (node.kind === 'finding' && node.topicLabel) meta.push(node.topicLabel);
|
|
2044
|
+
if (node.kind === 'finding' && node.date) meta.push(node.date);
|
|
1987
2045
|
|
|
1988
|
-
var header = '<div style="display:flex;flex-direction:column;gap:8px;padding-right:44px"><div style="font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)">' + esc(kindLabel(node)) + '</div><div style="font-size:var(--text-lg);font-weight:600;line-height:1.2">' + esc(title) + '</div><div style="display:flex;flex-wrap:wrap;gap:8px">' + meta.filter(Boolean).map(function(item, index) { return chip(item, index === 0); }).join('') + scoreLine(node) + '</div></div>';
|
|
2046
|
+
var header = '<div style="display:flex;flex-direction:column;gap:8px;padding-right:44px"><div class="phren-dossier-kind" style="font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)">' + esc(kindLabel(node)) + '</div><div style="font-size:var(--text-lg);font-weight:600;line-height:1.2">' + esc(title) + '</div><div style="display:flex;flex-wrap:wrap;gap:8px">' + meta.filter(Boolean).map(function(item, index) { return chip(item, index === 0); }).join('') + scoreLine(node) + '</div></div>';
|
|
1989
2047
|
|
|
1990
2048
|
var body = '';
|
|
1991
2049
|
var actions = [];
|
|
1992
2050
|
|
|
1993
2051
|
if (node.kind === 'project') {
|
|
1994
2052
|
var counts = projectCounts(node);
|
|
2053
|
+
// Server totals beat visible-adjacency counts (filters can hide nodes)
|
|
2054
|
+
var findingTotal = typeof node.findingCount === 'number' && node.findingCount > counts.finding ? node.findingCount : counts.finding;
|
|
2055
|
+
var taskTotal = typeof node.taskCount === 'number' && node.taskCount > counts.task ? node.taskCount : counts.task;
|
|
1995
2056
|
body += '<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px">';
|
|
1996
|
-
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">Findings</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' +
|
|
1997
|
-
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">Tasks</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' +
|
|
2057
|
+
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">Findings</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' + findingTotal + '</div></div>';
|
|
2058
|
+
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">Tasks</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' + taskTotal + '</div></div>';
|
|
1998
2059
|
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">Fragments</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' + counts.entity + '</div></div>';
|
|
1999
2060
|
body += '<div class="card" style="padding:12px"><div style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">References</div><div style="font-size:var(--text-lg);font-weight:600;margin-top:4px">' + counts.reference + '</div></div>';
|
|
2000
2061
|
body += '</div>';
|
|
2001
2062
|
} else if (node.kind === 'finding') {
|
|
2002
|
-
|
|
2063
|
+
// GraphRAG-style stats row: links / project / helpful
|
|
2064
|
+
var conn = node.connections || {};
|
|
2065
|
+
var helpful = node.score && typeof node.score.helpful === 'number' ? node.score.helpful : 0;
|
|
2066
|
+
body += '<div class="phren-dossier-stats">'
|
|
2067
|
+
+ '<div><div class="k">Links</div><div class="v">' + (conn.total || 0) + '</div></div>'
|
|
2068
|
+
+ '<div><div class="k">Project</div><div class="v" style="font-size:11px;letter-spacing:.04em;text-transform:none">' + esc(node.projectName || '—') + '</div></div>'
|
|
2069
|
+
+ '<div><div class="k">Helpful</div><div class="v">' + helpful + '</div></div>'
|
|
2070
|
+
+ '</div>';
|
|
2071
|
+
body += '<div class="phren-dossier-section">◈ Description</div>';
|
|
2072
|
+
body += '<div id="graph-node-text" class="phren-dossier-text">' + esc(node.tooltipLabel || node.fullLabel || title) + '</div>';
|
|
2073
|
+
// Strongest relationships — related same-topic findings + entity neighbors
|
|
2074
|
+
var rels = strongestRelationships(node);
|
|
2075
|
+
if (rels.length) {
|
|
2076
|
+
body += '<div class="phren-dossier-section">⟿ Strongest relationships · ' + rels.length + '</div>';
|
|
2077
|
+
body += '<div style="margin-top:8px">' + rels.map(function(r) {
|
|
2078
|
+
return '<div class="phren-rel-row" data-graph-goto="' + esc(r.id) + '"><div class="n">' + esc(r.name) + (r.sub ? '<small>' + esc(r.sub) + '</small>' : '') + '</div><div class="w">' + r.w.toFixed(2) + '</div></div>';
|
|
2079
|
+
}).join('') + '</div>';
|
|
2080
|
+
}
|
|
2081
|
+
if (node.projectName) {
|
|
2082
|
+
body += '<div class="phren-dossier-section">Community</div>';
|
|
2083
|
+
body += '<div style="display:flex;flex-wrap:wrap;gap:8px;margin-top:6px">' + gotoChip(node.projectName, node.projectName, true) + '</div>';
|
|
2084
|
+
}
|
|
2085
|
+
var nav = findingNav(node);
|
|
2086
|
+
if (nav.total > 1 && nav.index !== -1) {
|
|
2087
|
+
actions.push('<span class="phren-dossier-nav"><button type="button" data-graph-action="prev-finding" title="Previous finding in project">‹</button><span>' + (nav.index + 1) + ' of ' + nav.total + '</span><button type="button" data-graph-action="next-finding" title="Next finding in project">›</button></span>');
|
|
2088
|
+
}
|
|
2003
2089
|
actions.push('<button type="button" class="btn btn-sm" data-graph-action="edit">Edit</button>');
|
|
2004
2090
|
actions.push('<button type="button" class="btn btn-sm" data-graph-action="delete" style="border-color:var(--danger);color:var(--danger)">Delete</button>');
|
|
2005
2091
|
} else if (node.kind === 'task') {
|
|
@@ -2111,7 +2197,8 @@ export function renderGraphHostScript() {
|
|
|
2111
2197
|
}
|
|
2112
2198
|
graphRequest('/api/findings/' + encodeURIComponent(currentNode.projectName), 'PUT', {
|
|
2113
2199
|
old_text: currentNode.tooltipLabel || currentNode.fullLabel || '',
|
|
2114
|
-
new_text: nextText
|
|
2200
|
+
new_text: nextText,
|
|
2201
|
+
score_key: currentNode.scoreKey || ''
|
|
2115
2202
|
}).then(function(result) {
|
|
2116
2203
|
if (!result || !result.ok) throw new Error(result && result.error ? result.error : 'Save failed');
|
|
2117
2204
|
graphToast('Finding updated', 'ok');
|
|
@@ -2161,7 +2248,8 @@ export function renderGraphHostScript() {
|
|
|
2161
2248
|
if (!confirm('Delete this ' + (currentNode.kind || 'node') + '?')) return;
|
|
2162
2249
|
if (currentNode.kind === 'finding') {
|
|
2163
2250
|
graphRequest('/api/findings/' + encodeURIComponent(currentNode.projectName), 'DELETE', {
|
|
2164
|
-
text: currentNode.tooltipLabel || currentNode.fullLabel || ''
|
|
2251
|
+
text: currentNode.tooltipLabel || currentNode.fullLabel || '',
|
|
2252
|
+
score_key: currentNode.scoreKey || ''
|
|
2165
2253
|
}).then(function(result) {
|
|
2166
2254
|
if (!result || !result.ok) throw new Error(result && result.error ? result.error : 'Delete failed');
|
|
2167
2255
|
graphToast('Finding deleted', 'ok');
|
|
@@ -2232,9 +2320,28 @@ export function renderGraphHostScript() {
|
|
|
2232
2320
|
});
|
|
2233
2321
|
});
|
|
2234
2322
|
|
|
2323
|
+
// Related-node chips — fly to the referenced node
|
|
2324
|
+
document.querySelectorAll('[data-graph-goto]').forEach(function(chipEl) {
|
|
2325
|
+
chipEl.addEventListener('click', function() {
|
|
2326
|
+
var target = chipEl.getAttribute('data-graph-goto') || '';
|
|
2327
|
+
var api = graphApi();
|
|
2328
|
+
if (target && api && api.focusNode) api.focusNode(target);
|
|
2329
|
+
});
|
|
2330
|
+
});
|
|
2331
|
+
|
|
2235
2332
|
document.querySelectorAll('[data-graph-action]').forEach(function(button) {
|
|
2236
2333
|
button.addEventListener('click', function() {
|
|
2237
2334
|
var action = button.getAttribute('data-graph-action');
|
|
2335
|
+
if (action === 'prev-finding' || action === 'next-finding') {
|
|
2336
|
+
if (!currentNode) return;
|
|
2337
|
+
var nav = findingNav(currentNode);
|
|
2338
|
+
if (nav.total < 2 || nav.index === -1) return;
|
|
2339
|
+
var step = action === 'next-finding' ? 1 : -1;
|
|
2340
|
+
var nextIndex = (nav.index + step + nav.total) % nav.total;
|
|
2341
|
+
var api = graphApi();
|
|
2342
|
+
if (api && api.focusNode) api.focusNode(nav.list[nextIndex].id);
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2238
2345
|
if (action === 'edit') {
|
|
2239
2346
|
editMode = currentNode && (currentNode.kind === 'finding' || currentNode.kind === 'task') ? currentNode.kind : null;
|
|
2240
2347
|
var point = currentPopoverPoint();
|
package/dist/ui/server.js
CHANGED
|
@@ -8,6 +8,7 @@ import { spawn, execFileSync } from "child_process";
|
|
|
8
8
|
import { computePhrenLiveStateToken, getProjectDirs, } from "../shared.js";
|
|
9
9
|
import { getNonPrimaryStores, subscribeStoreProjects, unsubscribeStoreProjects } from "../store-registry.js";
|
|
10
10
|
import { editFinding, readReviewQueue, removeFinding, readFindings, addFinding as addFindingStore, readTasksAcrossProjects, addTask as addTaskStore, completeTask as completeTaskStore, removeTask as removeTaskStore, updateTask as updateTaskStore, TASKS_FILENAME, FINDINGS_FILENAME, } from "../data/access.js";
|
|
11
|
+
import { entryScoreKey } from "../governance/scores.js";
|
|
11
12
|
import { isValidProjectName, errorMessage, queueFilePath, safeProjectPath } from "../utils.js";
|
|
12
13
|
import { readInstallPreferences, writeInstallPreferences, writeGovernanceInstallPreferences } from "../init/preferences.js";
|
|
13
14
|
import { buildGraph, collectProjectsForUI, collectSkillsForUI, getHooksData, isAllowedSkillPath, readSyncSnapshot, recentAccepted, recentLookups, recentUsage, } from "./data.js";
|
|
@@ -1201,6 +1202,33 @@ function handlePostSettingsProjectOverrides(req, res, url, ctx) {
|
|
|
1201
1202
|
}
|
|
1202
1203
|
});
|
|
1203
1204
|
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Resolve a graph node's score_key back to the exact FINDINGS.md bullet text
|
|
1207
|
+
* (including its [tag] prefix). Score keys are minted per-bullet by the graph
|
|
1208
|
+
* builder, so this pins the precise entry even when display texts are
|
|
1209
|
+
* ambiguous (e.g. two findings differing only by tag). Returns null when the
|
|
1210
|
+
* key doesn't resolve — callers fall back to text matching.
|
|
1211
|
+
*/
|
|
1212
|
+
function findBulletTextByScoreKey(phrenPath, project, scoreKey) {
|
|
1213
|
+
try {
|
|
1214
|
+
const file = path.join(phrenPath, project, FINDINGS_FILENAME);
|
|
1215
|
+
if (!fs.existsSync(file))
|
|
1216
|
+
return null;
|
|
1217
|
+
for (const line of fs.readFileSync(file, "utf8").split("\n")) {
|
|
1218
|
+
const tag = line.match(/^-\s+\[([a-z_-]+)\]\s+(.+?)(?:\s*<!--.*-->)?$/);
|
|
1219
|
+
const plain = tag ? null : line.match(/^-\s+(.+?)(?:\s*<!--.*-->)?$/);
|
|
1220
|
+
const entry = tag ? `[${tag[1]}] ${tag[2].trim()}` : plain ? plain[1].trim() : null;
|
|
1221
|
+
if (!entry)
|
|
1222
|
+
continue;
|
|
1223
|
+
if (entryScoreKey(project, FINDINGS_FILENAME, entry) === scoreKey)
|
|
1224
|
+
return entry;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
catch {
|
|
1228
|
+
// unreadable file — fall back to text matching
|
|
1229
|
+
}
|
|
1230
|
+
return null;
|
|
1231
|
+
}
|
|
1204
1232
|
function handleFindingsWrite(req, res, url, pathname, ctx) {
|
|
1205
1233
|
const project = decodeURIComponent(pathname.slice("/api/findings/".length));
|
|
1206
1234
|
if (!project || !isValidProjectName(project))
|
|
@@ -1220,7 +1248,9 @@ function handleFindingsWrite(req, res, url, pathname, ctx) {
|
|
|
1220
1248
|
const newText = String(parsed.new_text || "");
|
|
1221
1249
|
if (!oldText || !newText)
|
|
1222
1250
|
return jsonErr(res, "old_text and new_text are required");
|
|
1223
|
-
const
|
|
1251
|
+
const scoreKey = String(parsed.score_key || "");
|
|
1252
|
+
const resolved = scoreKey ? findBulletTextByScoreKey(ctx.phrenPath, project, scoreKey) : null;
|
|
1253
|
+
const result = editFinding(ctx.phrenPath, project, resolved || oldText, newText);
|
|
1224
1254
|
jsonOk(res, { ok: result.ok, error: result.ok ? undefined : result.error });
|
|
1225
1255
|
});
|
|
1226
1256
|
}
|
|
@@ -1230,7 +1260,9 @@ function handleFindingsWrite(req, res, url, pathname, ctx) {
|
|
|
1230
1260
|
const text = String(parsed.text || "");
|
|
1231
1261
|
if (!text)
|
|
1232
1262
|
return jsonErr(res, "text is required");
|
|
1233
|
-
const
|
|
1263
|
+
const scoreKey = String(parsed.score_key || "");
|
|
1264
|
+
const resolved = scoreKey ? findBulletTextByScoreKey(ctx.phrenPath, project, scoreKey) : null;
|
|
1265
|
+
const result = removeFinding(ctx.phrenPath, project, resolved || text);
|
|
1234
1266
|
jsonOk(res, { ok: result.ok, error: result.ok ? undefined : result.error });
|
|
1235
1267
|
});
|
|
1236
1268
|
}
|