@phren/cli 0.1.36 → 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.
@@ -1 +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";
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/* Edge drag handle to widen/narrow the docked dossier (symmetric with the\n contents pane). The popover itself is pointer-transparent, so the handle\n re-enables pointer events for itself. */\n#graph-node-popover.phren-docked .phren-dossier-resize {\n position: absolute;\n right: -4px;\n top: 0;\n bottom: 0;\n width: 9px;\n cursor: ew-resize;\n z-index: 20;\n pointer-events: auto;\n touch-action: none;\n}\n#graph-node-popover.phren-docked .phren-dossier-resize::after {\n content: \"\";\n position: absolute;\n right: 3px;\n top: 50%;\n transform: translateY(-50%);\n width: 3px;\n height: 38px;\n border-radius: 999px;\n background: rgba(103, 232, 249, 0.28);\n opacity: 0;\n transition: opacity 0.15s ease;\n}\n#graph-node-popover.phren-docked .phren-dossier-resize:hover::after,\n#graph-node-popover.phren-docked .phren-dossier-resize.dragging::after {\n opacity: 1;\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";
@@ -67,6 +67,37 @@ body:has(#tab-graph.active) .header-brand { color: #dbe6ff; }
67
67
  pointer-events: none;
68
68
  z-index: 12;
69
69
  }
70
+ /* Edge drag handle to widen/narrow the docked dossier (symmetric with the
71
+ contents pane). The popover itself is pointer-transparent, so the handle
72
+ re-enables pointer events for itself. */
73
+ #graph-node-popover.phren-docked .phren-dossier-resize {
74
+ position: absolute;
75
+ right: -4px;
76
+ top: 0;
77
+ bottom: 0;
78
+ width: 9px;
79
+ cursor: ew-resize;
80
+ z-index: 20;
81
+ pointer-events: auto;
82
+ touch-action: none;
83
+ }
84
+ #graph-node-popover.phren-docked .phren-dossier-resize::after {
85
+ content: "";
86
+ position: absolute;
87
+ right: 3px;
88
+ top: 50%;
89
+ transform: translateY(-50%);
90
+ width: 3px;
91
+ height: 38px;
92
+ border-radius: 999px;
93
+ background: rgba(103, 232, 249, 0.28);
94
+ opacity: 0;
95
+ transition: opacity 0.15s ease;
96
+ }
97
+ #graph-node-popover.phren-docked .phren-dossier-resize:hover::after,
98
+ #graph-node-popover.phren-docked .phren-dossier-resize.dragging::after {
99
+ opacity: 1;
100
+ }
70
101
  /* GraphRAG-style stats row + relationships in the inspector */
71
102
  .phren-dossier-stats {
72
103
  display: grid;
@@ -1854,6 +1854,28 @@ export function renderGraphHostScript() {
1854
1854
  }, 2600);
1855
1855
  }
1856
1856
 
1857
+ function graphUndoToast(message, onUndo) {
1858
+ var container = document.getElementById('toast-container');
1859
+ if (!container) return;
1860
+ var toast = document.createElement('div');
1861
+ toast.className = 'toast';
1862
+ toast.style.display = 'flex';
1863
+ toast.style.alignItems = 'center';
1864
+ toast.style.gap = '10px';
1865
+ var msg = document.createElement('span');
1866
+ msg.textContent = message;
1867
+ var btn = document.createElement('button');
1868
+ btn.type = 'button';
1869
+ btn.textContent = 'Undo';
1870
+ btn.style.cssText = 'cursor:pointer;border:1px solid var(--accent,#67e8f9);background:transparent;color:var(--accent,#67e8f9);border-radius:6px;padding:2px 10px;font:inherit;font-size:12px';
1871
+ var remove = function() { if (toast.parentNode) toast.parentNode.removeChild(toast); };
1872
+ btn.addEventListener('click', function() { remove(); onUndo(); });
1873
+ toast.appendChild(msg);
1874
+ toast.appendChild(btn);
1875
+ container.appendChild(toast);
1876
+ setTimeout(remove, 8000);
1877
+ }
1878
+
1857
1879
  function fetchCsrfToken() {
1858
1880
  return fetch(authUrl('/api/csrf-token')).then(function(r) { return r.json(); }).then(function(data) {
1859
1881
  return data && data.ok ? (data.token || null) : null;
@@ -1892,6 +1914,33 @@ export function renderGraphHostScript() {
1892
1914
  // The dossier docks to the right edge of the graph viewport — a stable
1893
1915
  // reading pane instead of a cursor-chasing popover. Signature kept for
1894
1916
  // callers; the x/y hint is no longer needed.
1917
+ function ensureDossierResize(popover) {
1918
+ if (!popover || popover.querySelector('.phren-dossier-resize')) return;
1919
+ var handle = document.createElement('div');
1920
+ handle.className = 'phren-dossier-resize';
1921
+ handle.setAttribute('aria-hidden', 'true');
1922
+ handle.addEventListener('pointerdown', function(ev) {
1923
+ ev.preventDefault();
1924
+ ev.stopPropagation();
1925
+ handle.classList.add('dragging');
1926
+ try { handle.setPointerCapture(ev.pointerId); } catch (_) { /* ignore */ }
1927
+ function move(e) {
1928
+ var rect = popover.getBoundingClientRect();
1929
+ var w = Math.max(280, Math.min(680, e.clientX - rect.left));
1930
+ popover.style.width = w + 'px';
1931
+ popover.style.maxWidth = 'none';
1932
+ }
1933
+ function up() {
1934
+ handle.classList.remove('dragging');
1935
+ window.removeEventListener('pointermove', move);
1936
+ window.removeEventListener('pointerup', up);
1937
+ }
1938
+ window.addEventListener('pointermove', move);
1939
+ window.addEventListener('pointerup', up);
1940
+ });
1941
+ popover.appendChild(handle);
1942
+ }
1943
+
1895
1944
  function positionPopover(x, y) {
1896
1945
  var popover = document.getElementById('graph-node-popover');
1897
1946
  if (!popover) return;
@@ -1900,6 +1949,7 @@ export function renderGraphHostScript() {
1900
1949
  popover.style.top = '';
1901
1950
  popover.style.visibility = 'visible';
1902
1951
  popover.style.display = 'block';
1952
+ ensureDossierResize(popover);
1903
1953
  }
1904
1954
 
1905
1955
  function currentPopoverPoint() {
@@ -2053,12 +2103,16 @@ export function renderGraphHostScript() {
2053
2103
  // Server totals beat visible-adjacency counts (filters can hide nodes)
2054
2104
  var findingTotal = typeof node.findingCount === 'number' && node.findingCount > counts.finding ? node.findingCount : counts.finding;
2055
2105
  var taskTotal = typeof node.taskCount === 'number' && node.taskCount > counts.task ? node.taskCount : counts.task;
2056
- body += '<div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px">';
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>';
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>';
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>';
2061
- body += '</div>';
2106
+ // Compact stat line — the detailed findings/tasks browser lives in the
2107
+ // contents pane on the right, so the bulky card grid was redundant.
2108
+ var stat = function(n, label) {
2109
+ return '<span style="display:inline-flex;align-items:baseline;gap:5px"><b style="font-size:var(--text-md);font-weight:700;color:var(--ink)">' + n + '</b><span style="font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em">' + label + '</span></span>';
2110
+ };
2111
+ body += '<div style="display:flex;flex-wrap:wrap;gap:16px;padding:10px 0">'
2112
+ + stat(findingTotal, 'findings') + stat(taskTotal, 'tasks')
2113
+ + stat(counts.entity, 'fragments') + stat(counts.reference, 'refs')
2114
+ + '</div>';
2115
+ body += '<div class="text-muted" style="font-size:var(--text-sm)">Browse and prune this project\\'s findings and tasks in the contents pane →</div>';
2062
2116
  } else if (node.kind === 'finding') {
2063
2117
  // GraphRAG-style stats row: links / project / helpful
2064
2118
  var conn = node.connections || {};
@@ -2243,34 +2297,131 @@ export function renderGraphHostScript() {
2243
2297
  });
2244
2298
  }
2245
2299
 
2246
- function deleteCurrentNode() {
2247
- if (!currentNode) return;
2248
- if (!confirm('Delete this ' + (currentNode.kind || 'node') + '?')) return;
2249
- if (currentNode.kind === 'finding') {
2250
- graphRequest('/api/findings/' + encodeURIComponent(currentNode.projectName), 'DELETE', {
2251
- text: currentNode.tooltipLabel || currentNode.fullLabel || '',
2252
- score_key: currentNode.scoreKey || ''
2253
- }).then(function(result) {
2254
- if (!result || !result.ok) throw new Error(result && result.error ? result.error : 'Delete failed');
2255
- graphToast('Finding deleted', 'ok');
2256
- return reloadGraph(null);
2257
- }).catch(function(err) {
2258
- graphToast('Delete failed: ' + err.message, 'err');
2300
+ // Fire the delete API for one node (no confirm, no reload) — reused by single
2301
+ // and batch delete so a bulk prune reloads the graph just once at the end.
2302
+ function deleteNodeRequest(node) {
2303
+ if (!node) return Promise.resolve({ ok: false, error: 'no node' });
2304
+ if (node.kind === 'finding') {
2305
+ return graphRequest('/api/findings/' + encodeURIComponent(node.projectName), 'DELETE', {
2306
+ text: node.tooltipLabel || node.fullLabel || '',
2307
+ score_key: node.scoreKey || ''
2259
2308
  });
2260
- return;
2261
2309
  }
2262
- if (currentNode.kind === 'task') {
2263
- graphRequest('/api/tasks/remove', 'POST', {
2264
- project: currentNode.projectName,
2265
- item: currentNode.stableId || currentNode.id || currentNode.tooltipLabel || currentNode.fullLabel || currentNode.displayLabel || ''
2266
- }).then(function(result) {
2267
- if (!result || !result.ok) throw new Error(result && result.error ? result.error : 'Delete failed');
2268
- graphToast('Task removed', 'ok');
2310
+ if (node.kind === 'task') {
2311
+ return graphRequest('/api/tasks/remove', 'POST', {
2312
+ project: node.projectName,
2313
+ item: node.stableId || node.id || node.tooltipLabel || node.fullLabel || node.displayLabel || ''
2314
+ });
2315
+ }
2316
+ return Promise.resolve({ ok: false, error: 'unsupported' });
2317
+ }
2318
+
2319
+ function deleteNode(node) {
2320
+ if (!node) return;
2321
+ if (!confirm('Delete this ' + (node.kind || 'node') + '?')) return;
2322
+ deleteNodeRequest(node).then(function(result) {
2323
+ if (!result || !result.ok) throw new Error(result && result.error ? result.error : 'Delete failed');
2324
+ graphToast(node.kind === 'task' ? 'Task removed' : 'Finding deleted', 'ok');
2325
+ return reloadGraph(null);
2326
+ }).catch(function(err) {
2327
+ graphToast('Delete failed: ' + err.message, 'err');
2328
+ });
2329
+ }
2330
+
2331
+ function reAddNodes(items) {
2332
+ return Promise.all(items.map(function(it) {
2333
+ if (it.kind === 'finding') {
2334
+ return graphRequest('/api/findings/' + encodeURIComponent(it.projectName), 'POST', { text: it.text }).catch(function() { return { ok: false }; });
2335
+ }
2336
+ if (it.kind === 'task') {
2337
+ return graphRequest('/api/tasks/add', 'POST', { project: it.projectName, item: it.item }).catch(function() { return { ok: false }; });
2338
+ }
2339
+ return Promise.resolve({ ok: false });
2340
+ })).then(function() {
2341
+ graphToast('Restored ' + items.length + ' items', 'ok');
2342
+ return reloadGraph(null);
2343
+ });
2344
+ }
2345
+
2346
+ function deleteNodes(nodes) {
2347
+ if (!nodes || !nodes.length) return;
2348
+ if (nodes.length === 1) { deleteNode(nodes[0]); return; }
2349
+ if (!confirm('Delete ' + nodes.length + ' items?')) return;
2350
+ var undoItems = nodes.map(function(n) {
2351
+ return {
2352
+ kind: n.kind, projectName: n.projectName,
2353
+ text: n.tooltipLabel || n.fullLabel || '',
2354
+ item: n.stableId || n.id || n.tooltipLabel || n.fullLabel || n.displayLabel || ''
2355
+ };
2356
+ });
2357
+ Promise.all(nodes.map(function(n) {
2358
+ return deleteNodeRequest(n).catch(function() { return { ok: false }; });
2359
+ })).then(function(results) {
2360
+ var ok = results.filter(function(r) { return r && r.ok; }).length;
2361
+ return reloadGraph(null).then(function() {
2362
+ graphUndoToast('Deleted ' + ok + ' item' + (ok === 1 ? '' : 's'), function() { reAddNodes(undoItems); });
2363
+ });
2364
+ });
2365
+ }
2366
+
2367
+ // Merge two same-project findings into one: remove the originals, then add
2368
+ // their joined text as a single finding. Offers an Undo that restores the
2369
+ // originals and removes the merged bullet.
2370
+ function mergeNodes(nodes) {
2371
+ if (!nodes || nodes.length !== 2) return;
2372
+ var proj = nodes[0].projectName;
2373
+ var t1 = nodes[0].tooltipLabel || nodes[0].fullLabel || '';
2374
+ var t2 = nodes[1].tooltipLabel || nodes[1].fullLabel || '';
2375
+ if (!t1 || !t2) return;
2376
+ if (!confirm('Merge these 2 findings into one?')) return;
2377
+ var merged = t1 + '\\n' + t2;
2378
+ Promise.all(nodes.map(function(n) {
2379
+ return deleteNodeRequest(n).catch(function() { return { ok: false }; });
2380
+ })).then(function() {
2381
+ return graphRequest('/api/findings/' + encodeURIComponent(proj), 'POST', { text: merged });
2382
+ }).then(function(r) {
2383
+ if (!r || !r.ok) throw new Error(r && r.error ? r.error : 'add failed');
2384
+ return reloadGraph(null).then(function() {
2385
+ graphUndoToast('Merged 2 findings', function() { undoMerge(proj, merged, t1, t2); });
2386
+ });
2387
+ }).catch(function(err) {
2388
+ graphToast('Merge failed: ' + err.message, 'err');
2389
+ return reloadGraph(null);
2390
+ });
2391
+ }
2392
+
2393
+ // Reverse a merge: remove the combined bullet, restore the two originals.
2394
+ function undoMerge(proj, merged, t1, t2) {
2395
+ graphRequest('/api/findings/' + encodeURIComponent(proj), 'DELETE', { text: merged, score_key: '' })
2396
+ .then(function() { return graphRequest('/api/findings/' + encodeURIComponent(proj), 'POST', { text: t1 }); })
2397
+ .then(function() { return graphRequest('/api/findings/' + encodeURIComponent(proj), 'POST', { text: t2 }); })
2398
+ .then(function() {
2399
+ graphToast('Merge undone', 'ok');
2269
2400
  return reloadGraph(null);
2270
2401
  }).catch(function(err) {
2271
- graphToast('Delete failed: ' + err.message, 'err');
2402
+ graphToast('Undo failed: ' + err.message, 'err');
2403
+ return reloadGraph(null);
2272
2404
  });
2273
- }
2405
+ }
2406
+
2407
+ function deleteCurrentNode() {
2408
+ deleteNode(currentNode);
2409
+ }
2410
+
2411
+ // Open the dossier in edit mode for a finding/task chosen in the contents pane.
2412
+ function editNodeFromPane(node) {
2413
+ if (!node || (node.kind !== 'finding' && node.kind !== 'task')) return;
2414
+ var api = graphApi();
2415
+ if (api && api.selectNode) api.selectNode(node.id);
2416
+ setTimeout(function() {
2417
+ if (currentNode && currentNode.id === node.id) {
2418
+ editMode = currentNode.kind === 'task' ? 'task' : 'finding';
2419
+ var point = currentPopoverPoint();
2420
+ renderPopover(currentNode, point.x, point.y);
2421
+ var editor = document.getElementById('graph-node-editor');
2422
+ if (editor) editor.focus();
2423
+ }
2424
+ }, 220);
2274
2425
  }
2275
2426
 
2276
2427
  function completeCurrentTask() {
@@ -2388,6 +2539,14 @@ export function renderGraphHostScript() {
2388
2539
  if (popover) popover.style.display = 'none';
2389
2540
  });
2390
2541
  }
2542
+ if (typeof api.onItemAction === 'function') {
2543
+ api.onItemAction(function(payload, action) {
2544
+ if (action === 'delete') deleteNode(payload);
2545
+ else if (action === 'delete-batch') deleteNodes(payload);
2546
+ else if (action === 'edit') editNodeFromPane(payload);
2547
+ else if (action === 'merge') mergeNodes(payload);
2548
+ });
2549
+ }
2391
2550
  return true;
2392
2551
  }
2393
2552
 
@@ -2395,6 +2554,9 @@ export function renderGraphHostScript() {
2395
2554
  var popover = document.getElementById('graph-node-popover-card');
2396
2555
  if (!currentNode || !popover) return;
2397
2556
  if (popover.contains(event.target)) return;
2557
+ // Renderer-owned HUD overlays are legitimate UI, not a click-away dismiss.
2558
+ var t = event.target;
2559
+ if (t && t.closest && t.closest('.phren-project-panel, .phren-project-nav, .phren-pp-reopen, #graph-filter, .graph-controls, .phren-hud-legend, .phren-hud-stats')) return;
2398
2560
  hidePopover();
2399
2561
  }
2400
2562
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {