@phren/cli 0.1.31 → 0.1.33

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.
Files changed (73) hide show
  1. package/dist/capabilities/cli.js +2 -2
  2. package/dist/cli/config-access.d.ts +1 -0
  3. package/dist/cli/config-access.js +59 -0
  4. package/dist/cli/config-llm.d.ts +1 -0
  5. package/dist/cli/config-llm.js +60 -0
  6. package/dist/cli/config-policy.d.ts +11 -0
  7. package/dist/cli/config-policy.js +328 -0
  8. package/dist/cli/config-proactivity.d.ts +15 -0
  9. package/dist/cli/config-proactivity.js +129 -0
  10. package/dist/cli/config-shared.d.ts +6 -0
  11. package/dist/cli/config-shared.js +23 -0
  12. package/dist/cli/config-synonyms.d.ts +1 -0
  13. package/dist/cli/config-synonyms.js +60 -0
  14. package/dist/cli/config.d.ts +6 -24
  15. package/dist/cli/config.js +13 -670
  16. package/dist/finding-graph-id.d.ts +15 -0
  17. package/dist/finding-graph-id.js +58 -0
  18. package/dist/generated/memory-ui-graph.browser.js +15 -15
  19. package/dist/governance/activity.d.ts +36 -0
  20. package/dist/governance/activity.js +83 -0
  21. package/dist/governance/rbac.d.ts +17 -0
  22. package/dist/governance/rbac.js +37 -1
  23. package/dist/memory-ui-graph.runtime.js +15 -15
  24. package/dist/phren-paths.d.ts +6 -0
  25. package/dist/phren-paths.js +8 -0
  26. package/dist/shared/governance.d.ts +1 -0
  27. package/dist/shared/governance.js +1 -0
  28. package/dist/shared.d.ts +1 -1
  29. package/dist/shared.js +1 -1
  30. package/dist/tools/config.js +39 -2
  31. package/dist/tools/finding.js +5 -11
  32. package/dist/tools/search.js +28 -1
  33. package/dist/tools/tasks.js +3 -12
  34. package/dist/ui/data.d.ts +2 -0
  35. package/dist/ui/data.js +8 -3
  36. package/dist/ui/graph.js +2 -0
  37. package/dist/ui/page.js +45 -2
  38. package/dist/ui/scripts.d.ts +13 -0
  39. package/dist/ui/scripts.js +229 -2
  40. package/dist/ui/server.js +165 -1
  41. package/dist/ui/styles.d.ts +1 -0
  42. package/dist/ui/styles.js +38 -0
  43. package/package.json +1 -1
  44. package/dist/cli-hooks-prompt.d.ts +0 -18
  45. package/dist/cli-hooks-prompt.js +0 -359
  46. package/dist/cli-hooks-session-handlers.d.ts +0 -3
  47. package/dist/cli-hooks-session-handlers.js +0 -356
  48. package/dist/cli-hooks-stop.d.ts +0 -11
  49. package/dist/cli-hooks-stop.js +0 -584
  50. package/dist/init-bootstrap.d.ts +0 -5
  51. package/dist/init-bootstrap.js +0 -21
  52. package/dist/init-detect.d.ts +0 -8
  53. package/dist/init-detect.js +0 -38
  54. package/dist/init-env.d.ts +0 -6
  55. package/dist/init-env.js +0 -114
  56. package/dist/init-fresh.d.ts +0 -10
  57. package/dist/init-fresh.js +0 -234
  58. package/dist/init-hooks.d.ts +0 -5
  59. package/dist/init-hooks.js +0 -26
  60. package/dist/init-mcp.d.ts +0 -8
  61. package/dist/init-mcp.js +0 -65
  62. package/dist/init-modes.d.ts +0 -4
  63. package/dist/init-modes.js +0 -135
  64. package/dist/init-npm.d.ts +0 -10
  65. package/dist/init-npm.js +0 -37
  66. package/dist/init-project-local.d.ts +0 -2
  67. package/dist/init-project-local.js +0 -99
  68. package/dist/init-semantic.d.ts +0 -4
  69. package/dist/init-semantic.js +0 -48
  70. package/dist/init-types.d.ts +0 -59
  71. package/dist/init-types.js +0 -1
  72. package/dist/init-update.d.ts +0 -10
  73. package/dist/init-update.js +0 -96
@@ -956,6 +956,30 @@ export function renderTasksAndSettingsScript(authToken) {
956
956
  });
957
957
  }
958
958
 
959
+ function postAccess(role, value) {
960
+ var proj = getSettingsProject();
961
+ var csrfUrl = _tsAuthToken ? tsAuthUrl('/api/csrf-token') : '/api/csrf-token';
962
+ fetch(csrfUrl).then(function(r) { return r.json(); }).then(function(csrfData) {
963
+ var payload = {};
964
+ payload[role] = value || '';
965
+ if (proj) payload.project = proj;
966
+ var body = new URLSearchParams(payload);
967
+ if (csrfData.token) body.set('_csrf', csrfData.token);
968
+ var url = _tsAuthToken ? tsAuthUrl('/api/settings/access') : '/api/settings/access';
969
+ return fetch(url, { method: 'POST', body: body, headers: { 'content-type': 'application/x-www-form-urlencoded' } });
970
+ }).then(function(r) { return r.json(); }).then(function(data) {
971
+ if (!data.ok) {
972
+ setSettingsStatus(data.error || 'Failed to update access roles', 'err');
973
+ return;
974
+ }
975
+ _settingsLoaded = false;
976
+ loadSettings();
977
+ setSettingsStatus('Access roles updated', 'ok');
978
+ }).catch(function(err) {
979
+ setSettingsStatus('Failed: ' + String(err), 'err');
980
+ });
981
+ }
982
+
959
983
  function postGlobalWorkflow(field, value, clearField) {
960
984
  var csrfUrl = _tsAuthToken ? tsAuthUrl('/api/csrf-token') : '/api/csrf-token';
961
985
  fetch(csrfUrl).then(function(r) { return r.json(); }).then(function(csrfData) {
@@ -1167,6 +1191,11 @@ export function renderTasksAndSettingsScript(authToken) {
1167
1191
  retRow('Retention days', 'retentionDays', ret.retentionDays, 'Hard cutoff — memories past this age are removed.');
1168
1192
  retRow('Auto-accept threshold', 'autoAcceptThreshold', ret.autoAcceptThreshold, 'Confidence score (0–1) above which memories are auto-accepted.');
1169
1193
  retRow('Min inject confidence', 'minInjectConfidence', ret.minInjectConfidence, 'Minimum confidence score to inject a memory into context.');
1194
+ var decay = ret.decay || {};
1195
+ retRow('Decay @30d', 'decay.d30', decay.d30, 'Confidence multiplier (0–1) applied to memories ~30 days old.');
1196
+ retRow('Decay @60d', 'decay.d60', decay.d60, 'Confidence multiplier (0–1) applied to memories ~60 days old.');
1197
+ retRow('Decay @90d', 'decay.d90', decay.d90, 'Confidence multiplier (0–1) applied to memories ~90 days old.');
1198
+ retRow('Decay @120d', 'decay.d120', decay.d120, 'Confidence multiplier (0–1) applied to memories ~120 days old.');
1170
1199
  retentionEl.innerHTML = retHtml;
1171
1200
  }
1172
1201
 
@@ -1190,8 +1219,14 @@ export function renderTasksAndSettingsScript(authToken) {
1190
1219
  wfHtml += '<div class="settings-control-note">Memories below this confidence score are flagged for review.</div></div>';
1191
1220
  wfHtml += '<div class="settings-control">';
1192
1221
  wfHtml += '<div class="settings-control-header"><span class="settings-control-label">Risky sections</span>' + sourceBadge(riskySectionsOverride);
1193
- wfHtml += '<span class="settings-control-value" style="margin-left:auto">' + esc(Array.isArray(wf.riskySections) ? wf.riskySections.join(', ') : '—') + '</span></div>';
1194
- wfHtml += '<div class="settings-control-note">Sections that trigger approval gates when memories are written.</div></div>';
1222
+ if (isProject && riskySectionsOverride) {
1223
+ wfHtml += '<button data-ts-action="clearProjectOverride" data-field="riskySections" class="settings-chip" style="font-size:11px;margin-left:auto">Clear</button>';
1224
+ }
1225
+ wfHtml += '</div><div style="display:flex;gap:8px;align-items:center;margin-top:8px">' +
1226
+ '<input type="text" id="wf-input-riskySections" value="' + esc(Array.isArray(wf.riskySections) ? wf.riskySections.join(', ') : '') + '" placeholder="Review, Stale, Conflicts" style="flex:1;min-width:0;border:1px solid var(--border);border-radius:var(--radius-sm);padding:4px 8px;font-size:var(--text-sm);background:var(--surface);color:var(--ink)">' +
1227
+ '<button data-ts-action="' + (isProject ? 'setProjectWorkflow' : 'setGlobalWorkflow') + '" data-field="riskySections" class="settings-chip active" style="font-size:11px">Set</button>' +
1228
+ '</div>';
1229
+ wfHtml += '<div class="settings-control-note">Comma-separated sections that trigger approval gates when memories are written (Review, Stale, Conflicts).</div></div>';
1195
1230
  workflowEl.innerHTML = wfHtml;
1196
1231
  }
1197
1232
 
@@ -1219,6 +1254,35 @@ export function renderTasksAndSettingsScript(authToken) {
1219
1254
  indexEl.innerHTML = '<div style="color:var(--muted);font-size:var(--text-sm)">Index policy is global — switch to Global scope to edit it.</div>';
1220
1255
  }
1221
1256
 
1257
+ var accessEl = document.getElementById('settings-access');
1258
+ if (accessEl) {
1259
+ var accFields = (data.view && data.view.fields) ? data.view.fields : {};
1260
+ function accVal(role) {
1261
+ if (isProject) {
1262
+ return (rawOverrides && rawOverrides.access && Array.isArray(rawOverrides.access[role])) ? rawOverrides.access[role].join(', ') : '';
1263
+ }
1264
+ var f = accFields['access.' + role];
1265
+ return (f && Array.isArray(f.value)) ? f.value.join(', ') : '';
1266
+ }
1267
+ var accHtml = '';
1268
+ function accRow(label, role, note) {
1269
+ accHtml += '<div class="settings-control">';
1270
+ accHtml += '<div class="settings-control-header"><span class="settings-control-label">' + esc(label) + '</span></div>';
1271
+ accHtml += '<div class="settings-control-note">' + esc(note) + '</div>';
1272
+ accHtml += '<div style="display:flex;gap:8px;align-items:center;margin-top:8px">' +
1273
+ '<input type="text" id="access-input-' + esc(role) + '" value="' + esc(accVal(role)) + '" placeholder="comma,separated actors" style="flex:1;min-width:0;border:1px solid var(--border);border-radius:var(--radius-sm);padding:4px 8px;font-size:var(--text-sm);background:var(--surface);color:var(--ink)">' +
1274
+ '<button data-ts-action="setAccessRole" data-role="' + esc(role) + '" class="settings-chip active" style="font-size:11px">Set</button>' +
1275
+ '</div></div>';
1276
+ }
1277
+ accRow('Admins', 'admins', 'Full access — all actions, including config changes.');
1278
+ accRow('Contributors', 'contributors', 'Can add, edit, and remove findings and tasks.');
1279
+ accRow('Readers', 'readers', 'Read-only access (search and get).');
1280
+ accHtml += '<div class="settings-control-note">' + (isProject
1281
+ ? 'Editing the per-project access list for this project. Effective roles are the union of global and project lists.'
1282
+ : 'Editing the global access list. Effective roles are the union of global and per-project lists.') + ' All lists empty everywhere = open mode (everyone allowed).</div>';
1283
+ accessEl.innerHTML = accHtml;
1284
+ }
1285
+
1222
1286
  var integrationsEl = document.getElementById('settings-integrations');
1223
1287
  if (integrationsEl && !isProject) {
1224
1288
  var tools = Array.isArray(data.hookTools) ? data.hookTools : [];
@@ -1418,6 +1482,11 @@ export function renderTasksAndSettingsScript(authToken) {
1418
1482
  var nextHidden = actionEl.getAttribute('data-enabled') !== 'true';
1419
1483
  postSettings('/api/settings/index-policy', { includeHidden: String(nextHidden) }, 'Index policy updated.');
1420
1484
  }
1485
+ else if (action === 'setAccessRole') {
1486
+ var role = actionEl.getAttribute('data-role') || '';
1487
+ var inputEl = document.getElementById('access-input-' + role);
1488
+ postAccess(role, inputEl ? inputEl.value : '');
1489
+ }
1421
1490
  });
1422
1491
 
1423
1492
  // Keydown delegation for add-task inputs (Enter key)
@@ -2329,3 +2398,161 @@ export function renderReviewQueueKeyboardScript(_authToken) {
2329
2398
  });
2330
2399
  })();`;
2331
2400
  }
2401
+ /**
2402
+ * Live "Activity" tab: streams memory lookups from /api/lookups/stream (SSE)
2403
+ * and prepends them to #activity-feed in real time, so you can watch phren land
2404
+ * on memories as it searches. Falls back gracefully if EventSource is missing.
2405
+ */
2406
+ export function renderActivityStreamScript(_authToken) {
2407
+ return `(function() {
2408
+ var esc = window._phrenEsc;
2409
+ var authUrl = window._phrenAuthUrl;
2410
+ var MAX_ITEMS = 80;
2411
+ var feed = null, statusEl = null, ledEl = null;
2412
+ var emptyShown = true;
2413
+
2414
+ function el() {
2415
+ feed = document.getElementById('activity-feed');
2416
+ statusEl = document.getElementById('activity-status');
2417
+ ledEl = document.getElementById('activity-led');
2418
+ return !!feed;
2419
+ }
2420
+
2421
+ function relTime(iso) {
2422
+ var t = Date.parse(iso);
2423
+ if (isNaN(t)) return '';
2424
+ var s = Math.max(0, Math.round((Date.now() - t) / 1000));
2425
+ if (s < 5) return 'just now';
2426
+ if (s < 60) return s + 's ago';
2427
+ var m = Math.round(s / 60);
2428
+ if (m < 60) return m + 'm ago';
2429
+ var h = Math.round(m / 60);
2430
+ if (h < 24) return h + 'h ago';
2431
+ return Math.round(h / 24) + 'd ago';
2432
+ }
2433
+
2434
+ function setStatus(text, state) {
2435
+ if (statusEl) statusEl.textContent = text;
2436
+ if (ledEl) ledEl.className = 'activity-led' + (state ? ' activity-led-' + state : '');
2437
+ }
2438
+
2439
+ function renderItem(ev, isNew) {
2440
+ if (!feed) return;
2441
+ if (emptyShown) { feed.innerHTML = ''; emptyShown = false; }
2442
+ var li = document.createElement('li');
2443
+ li.className = 'activity-item' + (isNew ? ' activity-item-new' : '');
2444
+ var loc = esc((ev.project || '?') + '/' + (ev.filename || '?'));
2445
+ var type = esc(ev.type || '');
2446
+ var q = ev.query ? esc(ev.query) : '';
2447
+ var snip = ev.snippet ? esc(ev.snippet) : '';
2448
+ li.innerHTML =
2449
+ '<div class="activity-row">' +
2450
+ '<span class="activity-type activity-type-' + type + '">' + type + '</span>' +
2451
+ '<span class="activity-loc">' + loc + '</span>' +
2452
+ '<span class="activity-time">' + esc(relTime(ev.at)) + '</span>' +
2453
+ '</div>' +
2454
+ (q ? '<div class="activity-query">found via &ldquo;' + q + '&rdquo;</div>' : '') +
2455
+ (snip ? '<div class="activity-snippet">' + snip + '</div>' : '');
2456
+ feed.insertBefore(li, feed.firstChild);
2457
+ while (feed.children.length > MAX_ITEMS) feed.removeChild(feed.lastChild);
2458
+ if (isNew) {
2459
+ setTimeout(function() { li.classList.remove('activity-item-new'); }, 1500);
2460
+ }
2461
+ }
2462
+
2463
+ function loadInitial() {
2464
+ fetch(authUrl('/api/lookups')).then(function(r) { return r.json(); }).then(function(d) {
2465
+ var items = (d && d.lookups) || [];
2466
+ // Leave the feed placeholder and let the SSE connection drive the status
2467
+ // (avoids clobbering 'Live' when the snapshot is empty).
2468
+ if (!items.length) return;
2469
+ // API returns newest-first; render oldest-first so newest ends up on top.
2470
+ for (var i = items.length - 1; i >= 0; i--) renderItem(items[i], false);
2471
+ }).catch(function() { /* stream may still deliver */ });
2472
+ }
2473
+
2474
+ function connect() {
2475
+ if (typeof EventSource === 'undefined') {
2476
+ setStatus('Live updates unsupported — reload to refresh', 'err');
2477
+ return;
2478
+ }
2479
+ var src = new EventSource(authUrl('/api/lookups/stream'));
2480
+ src.onopen = function() { setStatus('Live', 'ok'); };
2481
+ src.onmessage = function(e) {
2482
+ try {
2483
+ var ev = JSON.parse(e.data);
2484
+ renderItem(ev, true);
2485
+ // Broadcast so other surfaces (e.g. the graph walk) can react without
2486
+ // opening a second SSE connection.
2487
+ try { window.dispatchEvent(new CustomEvent('phren:lookup', { detail: ev })); } catch (err2) {}
2488
+ } catch (err) {}
2489
+ setStatus('Live', 'ok');
2490
+ };
2491
+ src.onerror = function() {
2492
+ setStatus('Reconnecting…', 'warn');
2493
+ // EventSource auto-reconnects using the server's retry hint.
2494
+ };
2495
+ }
2496
+
2497
+ function init() {
2498
+ if (!el()) return;
2499
+ setStatus('Connecting…', 'warn');
2500
+ loadInitial();
2501
+ connect();
2502
+ }
2503
+
2504
+ if (document.readyState === 'loading') {
2505
+ document.addEventListener('DOMContentLoaded', init);
2506
+ } else {
2507
+ init();
2508
+ }
2509
+ })();`;
2510
+ }
2511
+ /**
2512
+ * Drives the graph mascot from the live lookup feed: each 'phren:lookup' event
2513
+ * (dispatched by the activity stream) maps to a graph node and sends phren
2514
+ * walking to it, so you can watch phren traverse the knowledge graph in real
2515
+ * time. No-ops gracefully until the graph is mounted (Graph tab opened).
2516
+ */
2517
+ export function renderGraphWalkScript() {
2518
+ return `(function() {
2519
+ function api() { return window.phrenGraph; }
2520
+
2521
+ function nodeIdForLookup(ev) {
2522
+ var g = api();
2523
+ if (!g || typeof g.getNodeDetail !== 'function' || typeof g.getData !== 'function') return null;
2524
+ if (!ev || !ev.project) return null;
2525
+
2526
+ // Precomputed node id (e.g. a specific finding) wins when it resolves.
2527
+ if (ev.nodeId && g.getNodeDetail(ev.nodeId)) return ev.nodeId;
2528
+
2529
+ // Reference lookups: prefer the specific reference node when present.
2530
+ if (ev.type === 'reference' && ev.filename) {
2531
+ var base = String(ev.filename).split('/').pop() || ev.filename;
2532
+ var candidates = [ev.project + ':ref:' + ev.filename, ev.project + ':ref:' + base];
2533
+ for (var i = 0; i < candidates.length; i++) {
2534
+ if (g.getNodeDetail(candidates[i])) return candidates[i];
2535
+ }
2536
+ var stem = base.replace(/\\.md$/, '');
2537
+ var refMatch = (g.getData().nodes || []).find(function(n) {
2538
+ return n.project === ev.project && n.group === 'reference' && String(n.label || '').indexOf(stem) !== -1;
2539
+ });
2540
+ if (refMatch) return refMatch.id;
2541
+ }
2542
+
2543
+ // Project node id is the project name — the reliable, always-present hop.
2544
+ if (g.getNodeDetail(ev.project)) return ev.project;
2545
+
2546
+ // Last resort: any visible node belonging to the project.
2547
+ var any = (g.getData().nodes || []).find(function(n) { return n.project === ev.project; });
2548
+ return any ? any.id : null;
2549
+ }
2550
+
2551
+ window.addEventListener('phren:lookup', function(e) {
2552
+ var g = api();
2553
+ if (!g || typeof g.walkTo !== 'function') return;
2554
+ var id = nodeIdForLookup(e.detail);
2555
+ if (id) { try { g.walkTo(id); } catch (err) {} }
2556
+ });
2557
+ })();`;
2558
+ }
package/dist/ui/server.js CHANGED
@@ -10,10 +10,12 @@ import { getNonPrimaryStores, subscribeStoreProjects, unsubscribeStoreProjects }
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
11
  import { isValidProjectName, errorMessage, queueFilePath, safeProjectPath } from "../utils.js";
12
12
  import { readInstallPreferences, writeInstallPreferences, writeGovernanceInstallPreferences } from "../init/preferences.js";
13
- import { buildGraph, collectProjectsForUI, collectSkillsForUI, getHooksData, isAllowedSkillPath, readSyncSnapshot, recentAccepted, recentUsage, } from "./data.js";
13
+ import { buildGraph, collectProjectsForUI, collectSkillsForUI, getHooksData, isAllowedSkillPath, readSyncSnapshot, recentAccepted, recentLookups, recentUsage, } from "./data.js";
14
+ import { lookupEventsLogFile } from "../shared.js";
14
15
  import { CONSOLIDATION_ENTRY_THRESHOLD } from "../content/validate.js";
15
16
  import { ensureTopicReferenceDoc, getProjectTopicsResponse, listProjectReferenceDocs, pinProjectTopicSuggestion, readReferenceContent, reclassifyLegacyTopicDocs, unpinProjectTopicSuggestion, writeProjectTopics, } from "../project-topics.js";
16
17
  import { getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, getRetentionPolicy, getProjectConfigOverrides, getIndexPolicy, updateIndexPolicy, VALID_TASK_MODES } from "../governance/policy.js";
18
+ import { setAccessRoles, ACCESS_ROLE_KEYS } from "../governance/rbac.js";
17
19
  import { readProjectConfig, updateProjectConfigOverrides } from "../project-config.js";
18
20
  import { buildConfigView } from "../config/resolve.js";
19
21
  import { CONFIG_DOMAINS } from "../config/schema.js";
@@ -372,6 +374,101 @@ function handleGetReviewQueue(res, ctx) {
372
374
  function handleGetReviewActivity(res, ctx) {
373
375
  jsonOk(res, { accepted: recentAccepted(ctx.phrenPath), usage: recentUsage(ctx.phrenPath) });
374
376
  }
377
+ /** Initial snapshot of recent memory lookups (newest first) for the Activity feed. */
378
+ function handleGetLookups(res, ctx) {
379
+ jsonOk(res, { ok: true, lookups: recentLookups(ctx.phrenPath, 40) });
380
+ }
381
+ /**
382
+ * Server-Sent Events stream of memory lookups. The server tails
383
+ * .runtime/lookup-events.jsonl and pushes each newly appended event to the
384
+ * browser, so the Activity tab lights up in real time as phren lands on
385
+ * memories. A short poll loop reads only appended bytes (robust across
386
+ * platforms vs. fs.watch); delivery to the client is push-based via SSE.
387
+ */
388
+ function handleLookupStream(req, res, ctx) {
389
+ res.writeHead(200, {
390
+ "Content-Type": "text/event-stream; charset=utf-8",
391
+ "Cache-Control": "no-cache, no-transform",
392
+ Connection: "keep-alive",
393
+ "X-Accel-Buffering": "no",
394
+ });
395
+ res.write("retry: 3000\n\n");
396
+ const logPath = lookupEventsLogFile(ctx.phrenPath);
397
+ // Start from the current end of the file so we only stream events that happen
398
+ // after the client connects (the initial snapshot comes from /api/lookups).
399
+ let offset = 0;
400
+ try {
401
+ offset = fs.existsSync(logPath) ? fs.statSync(logPath).size : 0;
402
+ }
403
+ catch {
404
+ offset = 0;
405
+ }
406
+ let carry = "";
407
+ const flushNew = () => {
408
+ let size;
409
+ try {
410
+ if (!fs.existsSync(logPath))
411
+ return;
412
+ size = fs.statSync(logPath).size;
413
+ }
414
+ catch {
415
+ return;
416
+ }
417
+ if (size < offset) {
418
+ offset = 0;
419
+ carry = "";
420
+ } // file rotated/truncated
421
+ if (size <= offset)
422
+ return;
423
+ let chunk = "";
424
+ try {
425
+ const fd = fs.openSync(logPath, "r");
426
+ try {
427
+ const buf = Buffer.alloc(size - offset);
428
+ fs.readSync(fd, buf, 0, buf.length, offset);
429
+ chunk = buf.toString("utf8");
430
+ }
431
+ finally {
432
+ fs.closeSync(fd);
433
+ }
434
+ }
435
+ catch {
436
+ return;
437
+ }
438
+ offset = size;
439
+ const lines = (carry + chunk).split("\n");
440
+ carry = lines.pop() ?? "";
441
+ for (const line of lines) {
442
+ const trimmed = line.trim();
443
+ if (!trimmed)
444
+ continue;
445
+ try {
446
+ JSON.parse(trimmed); // validate before forwarding
447
+ res.write(`data: ${trimmed}\n\n`);
448
+ }
449
+ catch {
450
+ // skip malformed lines
451
+ }
452
+ }
453
+ };
454
+ const pollTimer = setInterval(flushNew, 1000);
455
+ const heartbeat = setInterval(() => {
456
+ try {
457
+ res.write(": ping\n\n");
458
+ }
459
+ catch { /* connection gone */ }
460
+ }, 25000);
461
+ const cleanup = () => {
462
+ clearInterval(pollTimer);
463
+ clearInterval(heartbeat);
464
+ try {
465
+ res.end();
466
+ }
467
+ catch { /* already closed */ }
468
+ };
469
+ req.on("close", cleanup);
470
+ req.on("error", cleanup);
471
+ }
375
472
  function handleGetProjectContent(res, url, ctx) {
376
473
  const qs = parseQs(url);
377
474
  const project = String(qs.project || "");
@@ -869,6 +966,30 @@ function handlePostSettingsIndexPolicy(req, res, url, ctx) {
869
966
  jsonOk(res, result.ok ? { ok: true, indexPolicy: result.data } : { ok: false, error: result.error });
870
967
  });
871
968
  }
969
+ function handlePostSettingsAccess(req, res, url, ctx) {
970
+ withPostBody(req, res, url, ctx, (parsed) => {
971
+ const project = String(parsed.project || "").trim();
972
+ if (project && !isValidProjectName(project))
973
+ return jsonErr(res, "Invalid project name", 400);
974
+ const toList = (v) => (Array.isArray(v) ? v : String(v ?? "").split(","))
975
+ .map((s) => String(s).trim())
976
+ .filter(Boolean);
977
+ const patch = {};
978
+ for (const role of ACCESS_ROLE_KEYS) {
979
+ if (Object.prototype.hasOwnProperty.call(parsed, role))
980
+ patch[role] = toList(parsed[role]);
981
+ }
982
+ if (!Object.keys(patch).length)
983
+ return jsonErr(res, "Provide at least one of: admins, contributors, readers");
984
+ try {
985
+ const written = setAccessRoles(ctx.phrenPath, patch, project || undefined);
986
+ jsonOk(res, { ok: true, access: written });
987
+ }
988
+ catch (err) {
989
+ jsonErr(res, errorMessage(err));
990
+ }
991
+ });
992
+ }
872
993
  function handlePostSettingsMcpEnabled(req, res, url, ctx) {
873
994
  withPostBody(req, res, url, ctx, (parsed) => {
874
995
  const enabled = String(parsed.enabled || "").toLowerCase() === "true";
@@ -964,6 +1085,28 @@ function handlePostSettingsProjectOverrides(req, res, url, ctx) {
964
1085
  return jsonErr(res, result.error || "Failed to update retention policy", 500);
965
1086
  return jsonOk(res, { ok: true, retentionPolicy: result.data });
966
1087
  }
1088
+ else if (field.startsWith("decay.")) {
1089
+ const { updateRetentionPolicy } = require("../governance/policy.js");
1090
+ const point = field.slice("decay.".length);
1091
+ let updateData = {};
1092
+ if (!clearField) {
1093
+ const num = parseFloat(value);
1094
+ if (!Number.isFinite(num) || num < 0 || num > 1)
1095
+ throw new Error("Invalid value for " + field + " (must be 0-1)");
1096
+ updateData = { decay: { [point]: num } };
1097
+ }
1098
+ const result = updateRetentionPolicy(ctx.phrenPath, updateData);
1099
+ if (!result.ok)
1100
+ return jsonErr(res, result.error || "Failed to update retention policy", 500);
1101
+ return jsonOk(res, { ok: true, retentionPolicy: result.data });
1102
+ }
1103
+ else if (field === "riskySections") {
1104
+ const sections = (clearField ? [] : value.split(",").map((s) => s.trim()).filter(Boolean));
1105
+ const result = updateWorkflowPolicy(ctx.phrenPath, { riskySections: sections });
1106
+ if (!result.ok)
1107
+ return jsonErr(res, result.error || "Failed to update workflow policy", 500);
1108
+ return jsonOk(res, { ok: true, workflowPolicy: result.data });
1109
+ }
967
1110
  else if (NUMERIC_WORKFLOW_FIELDS.includes(field)) {
968
1111
  const { updateWorkflowPolicy } = require("../governance/policy.js");
969
1112
  let updateData = {};
@@ -1005,6 +1148,14 @@ function handlePostSettingsProjectOverrides(req, res, url, ctx) {
1005
1148
  if (next.retentionPolicy)
1006
1149
  delete next.retentionPolicy[field];
1007
1150
  }
1151
+ else if (field.startsWith("decay.")) {
1152
+ if (next.retentionPolicy?.decay)
1153
+ delete next.retentionPolicy.decay[field.slice("decay.".length)];
1154
+ }
1155
+ else if (field === "riskySections") {
1156
+ if (next.workflowPolicy)
1157
+ delete next.workflowPolicy.riskySections;
1158
+ }
1008
1159
  else if (NUMERIC_WORKFLOW_FIELDS.includes(field)) {
1009
1160
  if (next.workflowPolicy)
1010
1161
  delete next.workflowPolicy[field];
@@ -1022,6 +1173,16 @@ function handlePostSettingsProjectOverrides(req, res, url, ctx) {
1022
1173
  throw new Error(`Invalid numeric value for ${field}`);
1023
1174
  next.retentionPolicy = { ...next.retentionPolicy, [field]: num };
1024
1175
  }
1176
+ else if (field.startsWith("decay.")) {
1177
+ const num = parseFloat(value);
1178
+ if (!Number.isFinite(num) || num < 0 || num > 1)
1179
+ throw new Error(`Invalid value for ${field} (must be 0-1)`);
1180
+ next.retentionPolicy = { ...next.retentionPolicy, decay: { ...next.retentionPolicy?.decay, [field.slice("decay.".length)]: num } };
1181
+ }
1182
+ else if (field === "riskySections") {
1183
+ const sections = value.split(",").map((s) => s.trim()).filter(Boolean);
1184
+ next.workflowPolicy = { ...next.workflowPolicy, riskySections: sections };
1185
+ }
1025
1186
  else if (NUMERIC_WORKFLOW_FIELDS.includes(field)) {
1026
1187
  const num = parseFloat(value);
1027
1188
  if (!Number.isFinite(num) || num < 0 || num > 1)
@@ -1110,6 +1271,8 @@ export function createWebUiHttpServer(phrenPath, renderPage, profile, opts) {
1110
1271
  case "/api/runtime-health": return handleGetRuntimeHealth(res, ctx);
1111
1272
  case "/api/review-queue": return handleGetReviewQueue(res, ctx);
1112
1273
  case "/api/review-activity": return handleGetReviewActivity(res, ctx);
1274
+ case "/api/lookups": return handleGetLookups(res, ctx);
1275
+ case "/api/lookups/stream": return handleLookupStream(req, res, ctx);
1113
1276
  case "/api/project-topics": return handleGetProjectTopics(res, url, ctx);
1114
1277
  case "/api/project-reference-list": return handleGetProjectReferenceList(res, url, ctx);
1115
1278
  case "/api/project-reference-content": return handleGetProjectReferenceContent(res, url, ctx);
@@ -1161,6 +1324,7 @@ export function createWebUiHttpServer(phrenPath, renderPage, profile, opts) {
1161
1324
  case "/api/settings/auto-capture": return handlePostSettingsAutoCapture(req, res, url, ctx);
1162
1325
  case "/api/settings/mcp-enabled": return handlePostSettingsMcpEnabled(req, res, url, ctx);
1163
1326
  case "/api/settings/index-policy": return handlePostSettingsIndexPolicy(req, res, url, ctx);
1327
+ case "/api/settings/access": return handlePostSettingsAccess(req, res, url, ctx);
1164
1328
  case "/api/settings/project-overrides": return handlePostSettingsProjectOverrides(req, res, url, ctx);
1165
1329
  }
1166
1330
  // Prefix-matched write routes
@@ -2,3 +2,4 @@ export declare const PROJECT_REFERENCE_UI_STYLES = "\n .project-reference-shell
2
2
  export declare const SETTINGS_TAB_UI_STYLES = "\n .settings-shell {\n display: flex;\n flex-direction: column;\n gap: 18px;\n }\n .settings-section {\n border: 1px solid var(--border);\n border-radius: var(--radius);\n background: var(--surface);\n box-shadow: var(--shadow);\n overflow: hidden;\n }\n .settings-section-findings { border-top: 3px solid color-mix(in srgb, var(--accent) 60%, var(--border)); }\n .settings-section-behavior { border-top: 3px solid color-mix(in srgb, var(--blue) 45%, var(--border)); }\n .settings-section-integrations { border-top: 3px solid color-mix(in srgb, var(--purple) 45%, var(--border)); }\n .settings-section-header {\n padding: 16px 18px 12px;\n border-bottom: 1px solid var(--border-light);\n background: var(--surface);\n }\n .settings-section-header h3 {\n margin: 0;\n font-size: var(--text-md);\n font-weight: 700;\n letter-spacing: -0.02em;\n color: var(--ink);\n }\n .settings-section-header p {\n margin: 6px 0 0;\n color: var(--muted);\n font-size: var(--text-sm);\n line-height: 1.5;\n }\n .settings-section-body {\n padding: 18px;\n display: flex;\n flex-direction: column;\n gap: 16px;\n }\n .settings-control {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px;\n border: 1px solid var(--border-light);\n border-radius: var(--radius-sm);\n background: var(--surface-raised);\n }\n .settings-control-primary {\n background: color-mix(in srgb, var(--accent) 4%, var(--surface-raised));\n border-color: color-mix(in srgb, var(--accent) 18%, var(--border));\n }\n .settings-control-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n .settings-control-label {\n font-size: var(--text-base);\n font-weight: 600;\n color: var(--ink-secondary);\n }\n .settings-control-note {\n color: var(--muted);\n font-size: var(--text-sm);\n line-height: 1.5;\n }\n .settings-control-value {\n color: var(--ink-secondary);\n font-size: var(--text-base);\n font-weight: 600;\n }\n .settings-chip-row {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n }\n .settings-chip {\n border: 1px solid var(--border);\n background: transparent;\n color: var(--ink-secondary);\n border-radius: 999px;\n padding: 6px 12px;\n cursor: pointer;\n font-size: var(--text-sm);\n font-family: var(--font);\n font-weight: 600;\n transition: background .15s, border-color .15s, color .15s;\n }\n .settings-chip:hover {\n border-color: var(--accent);\n color: var(--ink);\n }\n .settings-chip.active {\n border-color: var(--accent);\n background: var(--accent);\n color: #fff;\n }\n .settings-chip.readonly {\n cursor: default;\n opacity: 0.92;\n }\n .settings-chip.readonly:hover {\n border-color: var(--border);\n color: var(--ink-secondary);\n }\n .settings-chip.active.readonly:hover {\n border-color: var(--accent);\n color: #fff;\n }\n .settings-status-inline {\n min-height: 18px;\n font-size: var(--text-sm);\n color: var(--muted);\n }\n .settings-status-inline.ok { color: var(--success); }\n .settings-status-inline.err { color: var(--danger); }\n .settings-integrations-table {\n width: 100%;\n border-collapse: collapse;\n }\n .settings-integrations-table th,\n .settings-integrations-table td {\n text-align: left;\n padding: 10px 8px;\n border-bottom: 1px solid var(--border-light);\n font-size: var(--text-sm);\n vertical-align: middle;\n }\n .settings-integrations-table th {\n color: var(--muted);\n font-weight: 650;\n letter-spacing: 0.02em;\n text-transform: uppercase;\n font-size: var(--text-xs);\n }\n .settings-integrations-table tr:last-child td { border-bottom: none; }\n .settings-tool {\n display: flex;\n align-items: center;\n gap: 8px;\n font-weight: 600;\n color: var(--ink-secondary);\n text-transform: capitalize;\n }\n .settings-indicator {\n width: 9px;\n height: 9px;\n border-radius: 50%;\n display: inline-block;\n margin-right: 6px;\n }\n .settings-indicator.on { background: var(--success); }\n .settings-indicator.off { background: var(--danger); }\n";
3
3
  export declare const TASK_UI_STYLES = "\n /* \u2500\u2500 Task Manager Styles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-toolbar {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-bottom: 20px;\n flex-wrap: wrap;\n }\n .task-filter-select {\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n padding: 8px 12px;\n background: var(--surface);\n color: var(--ink);\n font-size: var(--text-sm);\n font-family: var(--font);\n cursor: pointer;\n transition: border-color 0.15s;\n }\n .task-filter-select:hover { border-color: var(--accent); }\n .task-filter-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }\n .task-count-label {\n font-size: var(--text-sm);\n color: var(--muted);\n margin-left: auto;\n font-weight: 500;\n }\n\n .task-empty-state {\n padding: 60px 40px;\n text-align: center;\n color: var(--muted);\n }\n\n .task-add-bar {\n display: flex;\n gap: 10px;\n margin-bottom: 20px;\n align-items: center;\n }\n .task-add-input {\n flex: 1;\n padding: 10px 14px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n background: var(--surface);\n color: var(--ink);\n font-size: var(--text-base);\n font-family: var(--font);\n transition: border-color 0.15s, box-shadow 0.15s;\n }\n .task-add-input:focus {\n outline: none;\n border-color: var(--accent);\n box-shadow: 0 0 0 3px var(--accent-dim);\n }\n .task-add-input::placeholder { color: var(--muted); opacity: 0.6; }\n .task-add-btn {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 10px 18px;\n border: none;\n border-radius: var(--radius-sm);\n background: var(--accent);\n color: #fff;\n cursor: pointer;\n font-size: var(--text-sm);\n font-weight: 600;\n font-family: var(--font);\n transition: background 0.15s, transform 0.1s;\n white-space: nowrap;\n }\n .task-add-btn:hover { background: var(--accent-hover); }\n .task-add-btn:active { transform: scale(0.97); }\n\n .task-section-group { margin-bottom: 24px; }\n .task-section-header {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--text-xs);\n font-weight: 700;\n color: var(--muted);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: 8px;\n padding: 0 4px;\n }\n .task-section-count {\n font-weight: 500;\n color: var(--muted);\n font-size: var(--text-xs);\n opacity: 0.7;\n }\n\n .task-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n border: 1px solid var(--border);\n border-radius: var(--radius);\n background: var(--surface);\n overflow: hidden;\n }\n\n .task-row {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n border-bottom: 1px solid var(--border-light);\n transition: background 0.1s;\n cursor: default;\n position: relative;\n }\n .task-row:last-child { border-bottom: none; }\n .task-row:hover { background: var(--surface-raised); }\n .task-row:hover .task-row-actions { opacity: 1; pointer-events: auto; }\n\n .task-row-priority {\n width: 4px;\n height: 24px;\n border-radius: 2px;\n flex-shrink: 0;\n }\n .task-row-priority-high { background: #ef4444; }\n .task-row-priority-medium { background: #f59e0b; }\n .task-row-priority-low { background: #9ca3af; }\n .task-row-priority-none { background: transparent; }\n\n .task-row-content {\n flex: 1;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .task-row-text {\n font-size: var(--text-base);\n color: var(--ink);\n line-height: 1.4;\n word-break: break-word;\n }\n .task-row-done .task-row-text {\n text-decoration: line-through;\n opacity: 0.5;\n }\n .task-row-context {\n font-size: var(--text-xs);\n color: var(--muted);\n font-style: italic;\n margin-top: 2px;\n }\n\n .task-row-meta {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n }\n\n .task-priority-badge {\n display: inline-block;\n padding: 1px 7px;\n border-radius: 999px;\n font-size: 10px;\n font-weight: 600;\n text-transform: capitalize;\n }\n .task-priority-high { background: #ef444418; color: #ef4444; }\n .task-priority-medium { background: #f59e0b18; color: #f59e0b; }\n .task-priority-low { background: #6b728018; color: #6b7280; }\n\n .task-project-badge {\n display: inline-block;\n padding: 2px 8px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-weight: 500;\n background: var(--accent-dim);\n color: var(--accent);\n }\n\n .task-pin-indicator {\n color: var(--accent);\n display: inline-flex;\n align-items: center;\n }\n\n .task-github-badge {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 8px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-weight: 500;\n background: var(--surface-sunken);\n color: var(--ink-secondary);\n text-decoration: none;\n transition: background 0.15s;\n }\n .task-github-badge:hover { background: var(--accent-dim); color: var(--accent); }\n\n .task-row-actions {\n display: flex;\n align-items: center;\n gap: 4px;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s;\n flex-shrink: 0;\n }\n .task-action-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n background: var(--surface);\n color: var(--muted);\n cursor: pointer;\n font-size: 12px;\n font-family: var(--font);\n transition: all 0.15s;\n padding: 0;\n }\n .task-action-btn:hover {\n border-color: var(--accent);\n color: var(--accent);\n background: var(--accent-dim);\n }\n .task-action-btn.task-action-complete:hover {\n border-color: var(--success);\n color: var(--success);\n background: var(--success-dim);\n }\n .task-action-btn.task-action-delete:hover {\n border-color: var(--danger);\n color: var(--danger);\n background: var(--danger-dim);\n }\n\n .task-done-section { margin-top: 24px; }\n .task-done-toggle {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 4px;\n background: none;\n border: none;\n color: var(--muted);\n font-size: var(--text-xs);\n font-weight: 700;\n font-family: var(--font);\n cursor: pointer;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n transition: color 0.15s;\n }\n .task-done-toggle:hover { color: var(--ink-secondary); }\n .task-toggle-arrow {\n font-size: 10px;\n transition: transform 0.2s;\n }\n .task-done-list { padding-top: 4px; }\n\n /* \u2500\u2500 Task Summary Bar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-summary-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: var(--surface-sunken, var(--surface));\n border: 1px solid var(--border);\n border-radius: var(--radius);\n margin-bottom: 16px;\n flex-wrap: wrap;\n font-size: var(--text-sm);\n }\n .task-summary-total {\n font-weight: 600;\n color: var(--ink);\n font-size: var(--text-base);\n }\n .task-summary-pill {\n display: inline-flex;\n align-items: center;\n padding: 2px 8px;\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n }\n .task-summary-high { background: #ef444422; color: #ef4444; }\n .task-summary-medium { background: #f59e0b22; color: #f59e0b; }\n .task-summary-low { background: #6b728022; color: #6b7280; }\n .task-summary-projects {\n display: flex;\n gap: 6px;\n align-items: center;\n }\n .task-summary-project {\n font-size: 11px;\n color: var(--muted);\n padding: 1px 6px;\n border: 1px solid var(--border);\n border-radius: var(--radius-sm);\n }\n\n /* \u2500\u2500 Task Session Badge \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .task-session-badge {\n display: inline-block;\n padding: 1px 6px;\n border-radius: var(--radius-sm);\n font-size: 10px;\n font-family: var(--mono, monospace);\n background: var(--surface-sunken, var(--surface));\n color: var(--muted);\n border: 1px solid var(--border);\n }\n";
4
4
  export declare const REVIEW_UI_STYLES = "\n /* \u2500\u2500 Review Toolbar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n .review-toolbar {\n display: flex;\n align-items: center;\n gap: 10px;\n margin-bottom: 16px;\n flex-wrap: wrap;\n }\n .review-flagged-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: var(--text-sm);\n font-weight: 500;\n color: var(--ink-secondary);\n cursor: pointer;\n user-select: none;\n }\n .review-flagged-toggle input[type=\"checkbox\"] {\n width: 14px;\n height: 14px;\n cursor: pointer;\n accent-color: var(--accent);\n }\n .review-sync-dot {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n flex-shrink: 0;\n }\n .review-sync-indicator {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: var(--success);\n display: inline-block;\n transition: background 0.3s;\n }\n .review-sync-indicator.syncing {\n background: var(--warning);\n animation: ledPulse 1.2s infinite;\n }\n .review-sync-indicator.error {\n background: var(--danger);\n }\n /* \u2500\u2500 Review Card Highlight (keyboard shortcuts) \u2500\u2500\u2500\u2500 */\n .review-card-highlight {\n border: 2px solid var(--blue) !important;\n box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.08), var(--shadow) !important;\n background: color-mix(in srgb, var(--surface) 98%, var(--blue)) !important;\n }\n";
5
+ export declare const LAYOUT_VIEWPORT_STYLES = "\n /* Graph: fill the available viewport height instead of forcing 800px\n (which overflowed laptop-height screens), and frame it as a panel. */\n #graph-canvas {\n height: calc(100vh - 110px);\n min-height: 420px;\n }\n .graph-container {\n position: relative;\n border: 1px solid var(--border);\n border-radius: 10px;\n overflow: hidden;\n }\n\n /* Header nav: shrink and scroll internally on narrow widths so the header\n never pushes the page wider than the viewport. */\n .nav {\n min-width: 0;\n flex: 0 1 auto;\n overflow-x: auto;\n overflow-y: hidden;\n scrollbar-width: none;\n -ms-overflow-style: none;\n }\n .nav::-webkit-scrollbar { display: none; }\n .nav-item { flex: 0 0 auto; white-space: nowrap; }\n\n @media (max-width: 900px) {\n #graph-canvas { height: calc(100vh - 92px); min-height: 360px; }\n .header { gap: 12px; }\n .nav-item { padding: 0 12px; }\n }\n";
package/dist/ui/styles.js CHANGED
@@ -662,3 +662,41 @@ export const REVIEW_UI_STYLES = `
662
662
  background: color-mix(in srgb, var(--surface) 98%, var(--blue)) !important;
663
663
  }
664
664
  `;
665
+ /*
666
+ * Viewport refinements — appended LAST in the page <style> so these win the
667
+ * cascade over the base WEB_UI_STYLES. Keeps the layout fitting the viewport
668
+ * across desktop, laptop, and narrow widths without horizontal page scroll.
669
+ */
670
+ export const LAYOUT_VIEWPORT_STYLES = `
671
+ /* Graph: fill the available viewport height instead of forcing 800px
672
+ (which overflowed laptop-height screens), and frame it as a panel. */
673
+ #graph-canvas {
674
+ height: calc(100vh - 110px);
675
+ min-height: 420px;
676
+ }
677
+ .graph-container {
678
+ position: relative;
679
+ border: 1px solid var(--border);
680
+ border-radius: 10px;
681
+ overflow: hidden;
682
+ }
683
+
684
+ /* Header nav: shrink and scroll internally on narrow widths so the header
685
+ never pushes the page wider than the viewport. */
686
+ .nav {
687
+ min-width: 0;
688
+ flex: 0 1 auto;
689
+ overflow-x: auto;
690
+ overflow-y: hidden;
691
+ scrollbar-width: none;
692
+ -ms-overflow-style: none;
693
+ }
694
+ .nav::-webkit-scrollbar { display: none; }
695
+ .nav-item { flex: 0 0 auto; white-space: nowrap; }
696
+
697
+ @media (max-width: 900px) {
698
+ #graph-canvas { height: calc(100vh - 92px); min-height: 360px; }
699
+ .header { gap: 12px; }
700
+ .nav-item { padding: 0 12px; }
701
+ }
702
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phren/cli",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "Knowledge layer for AI agents — CLI, MCP server, and data layer",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,18 +0,0 @@
1
- export declare function handleHookContext(): Promise<void>;
2
- export declare function handleHookTool(): Promise<void>;
3
- interface LearningCandidate {
4
- text: string;
5
- confidence: number;
6
- explicit?: boolean;
7
- }
8
- export declare function filterToolFindingsForProactivity(candidates: Array<{
9
- text: string;
10
- confidence: number;
11
- explicit?: boolean;
12
- }>, level?: "high" | "medium" | "low"): Array<{
13
- text: string;
14
- confidence: number;
15
- explicit?: boolean;
16
- }>;
17
- export declare function extractToolFindings(toolName: string, input: Record<string, unknown>, responseStr: string, toolResponse?: unknown): LearningCandidate[];
18
- export {};