@phren/cli 0.1.42 → 0.1.45

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 (97) hide show
  1. package/dist/capabilities/cli.js +1 -1
  2. package/dist/capabilities/mcp.js +1 -1
  3. package/dist/capabilities/vscode.js +3 -3
  4. package/dist/capabilities/web-ui.js +29 -29
  5. package/dist/cli/actions.d.ts +1 -1
  6. package/dist/cli/actions.js +7 -2
  7. package/dist/cli/config-proactivity.d.ts +6 -6
  8. package/dist/cli/hooks-output.js +15 -6
  9. package/dist/cli/hooks.d.ts +1 -1
  10. package/dist/cli/hooks.js +16 -5
  11. package/dist/cli/session-stop.d.ts +1 -1
  12. package/dist/cli/session-tool-hook.d.ts +1 -1
  13. package/dist/cli-registry.js +1 -1
  14. package/dist/data/access.js +2 -1
  15. package/dist/generated/memory-ui-graph.browser.js +481 -318
  16. package/dist/governance/locks.js +6 -0
  17. package/dist/governance/scores.d.ts +9 -1
  18. package/dist/governance/scores.js +12 -1
  19. package/dist/graph-core/index.d.ts +2 -0
  20. package/dist/graph-core/index.js +2 -0
  21. package/dist/graph-core/model.d.ts +84 -0
  22. package/dist/graph-core/model.js +355 -0
  23. package/dist/graph-core/types.d.ts +110 -0
  24. package/dist/graph-core/types.js +43 -0
  25. package/dist/index.js +4 -1
  26. package/dist/init/init-uninstall.d.ts +1 -0
  27. package/dist/init/init-uninstall.js +13 -3
  28. package/dist/init/setup.js +11 -4
  29. package/dist/link/context.js +2 -1
  30. package/dist/link/link.js +3 -2
  31. package/dist/link/skills.js +2 -1
  32. package/dist/memory-ui-graph.runtime.js +481 -318
  33. package/dist/phren-core.d.ts +16 -0
  34. package/dist/phren-core.js +21 -0
  35. package/dist/phren-paths.js +8 -4
  36. package/dist/profile-store.d.ts +2 -0
  37. package/dist/profile-store.js +16 -19
  38. package/dist/project-config.js +2 -1
  39. package/dist/shared/fragment-graph.js +7 -2
  40. package/dist/shared/index.js +1 -1
  41. package/dist/shared/retrieval.d.ts +38 -0
  42. package/dist/shared/retrieval.js +62 -4
  43. package/dist/shell/entry.d.ts +10 -2
  44. package/dist/shell/entry.js +128 -97
  45. package/dist/shell/graph/canvas.d.ts +64 -0
  46. package/dist/shell/graph/canvas.js +256 -0
  47. package/dist/shell/graph/controller.d.ts +164 -0
  48. package/dist/shell/graph/controller.js +645 -0
  49. package/dist/shell/graph/glyphs.d.ts +12 -0
  50. package/dist/shell/graph/glyphs.js +31 -0
  51. package/dist/shell/graph/graph-view.d.ts +12 -0
  52. package/dist/shell/graph/graph-view.js +408 -0
  53. package/dist/shell/graph/layout.d.ts +68 -0
  54. package/dist/shell/graph/layout.js +267 -0
  55. package/dist/shell/input.d.ts +4 -1
  56. package/dist/shell/input.js +28 -5
  57. package/dist/shell/intro.d.ts +37 -0
  58. package/dist/shell/intro.js +82 -0
  59. package/dist/shell/keys.d.ts +36 -0
  60. package/dist/shell/keys.js +107 -0
  61. package/dist/shell/logo-fx.d.ts +35 -0
  62. package/dist/shell/logo-fx.js +128 -0
  63. package/dist/shell/render.d.ts +34 -1
  64. package/dist/shell/render.js +220 -66
  65. package/dist/shell/shell.d.ts +13 -1
  66. package/dist/shell/shell.js +61 -10
  67. package/dist/shell/startup.d.ts +37 -0
  68. package/dist/shell/startup.js +105 -0
  69. package/dist/shell/state-store.d.ts +1 -1
  70. package/dist/shell/state-store.js +1 -1
  71. package/dist/shell/types.js +1 -0
  72. package/dist/shell/view.d.ts +3 -0
  73. package/dist/shell/view.js +26 -4
  74. package/dist/store-registry.d.ts +13 -0
  75. package/dist/store-registry.js +109 -37
  76. package/dist/test-global-setup.d.ts +1 -0
  77. package/dist/test-global-setup.js +22 -0
  78. package/dist/tool-registry.js +1 -0
  79. package/dist/tools/memory.js +12 -5
  80. package/dist/tools/ops.js +1 -1
  81. package/dist/ui/data.d.ts +15 -7
  82. package/dist/ui/data.js +102 -3
  83. package/dist/utils-fts.js +2 -1
  84. package/dist/utils-helpers.d.ts +1 -0
  85. package/dist/utils-helpers.js +6 -0
  86. package/dist/utils.d.ts +1 -1
  87. package/dist/utils.js +1 -1
  88. package/package.json +38 -7
  89. package/starter/global/skills/phren-consolidate/SKILL.md +152 -0
  90. package/starter/global/skills/phren-discover/SKILL.md +175 -0
  91. package/starter/global/skills/phren-init/SKILL.md +216 -0
  92. package/starter/global/skills/phren-profiles/SKILL.md +121 -0
  93. package/starter/global/skills/phren-sync/SKILL.md +261 -0
  94. package/dist/init-uninstall.d.ts +0 -3
  95. package/dist/init-uninstall.js +0 -514
  96. package/dist/init-walkthrough.d.ts +0 -55
  97. package/dist/init-walkthrough.js +0 -524
@@ -1,6 +1,6 @@
1
1
  export const cliManifest = {
2
2
  surface: "cli",
3
- version: "0.1.17",
3
+ version: "0.1.42",
4
4
  actions: {
5
5
  // Finding management
6
6
  "finding.add": { implemented: true, handler: "cli-actions.ts:handleAddFinding" },
@@ -1,6 +1,6 @@
1
1
  export const mcpManifest = {
2
2
  surface: "mcp",
3
- version: "0.1.17",
3
+ version: "0.1.42",
4
4
  actions: {
5
5
  // Finding management
6
6
  "finding.add": { implemented: true, handler: "index.ts:add_finding" },
@@ -1,6 +1,6 @@
1
1
  export const vscodeManifest = {
2
2
  surface: "vscode",
3
- version: "0.1.17",
3
+ version: "0.1.42",
4
4
  actions: {
5
5
  // Finding management
6
6
  "finding.add": { implemented: true, handler: "extension.ts:phren.addFinding" },
@@ -24,8 +24,8 @@ export const vscodeManifest = {
24
24
  "hook.errors": { implemented: false, reason: "Hook errors not exposed in VS Code" },
25
25
  // Search
26
26
  "search.fts": { implemented: true, handler: "searchQuickPick.ts:showSearchQuickPick" },
27
- "search.fragment": { implemented: true, handler: "phrenClient.ts:searchFragments" },
28
- "search.related_docs": { implemented: true, handler: "phrenClient.ts:getRelatedDocs" },
27
+ "search.fragment": { implemented: false, reason: "search_fragments is never called from the extension (no client method exists)" },
28
+ "search.related_docs": { implemented: false, reason: "get_related_docs is never called from the extension (no client method exists)" },
29
29
  "search.history": { implemented: true, handler: "searchQuickPick.ts:searchHistory (in-memory)" },
30
30
  // Graph
31
31
  "graph.read": { implemented: true, handler: "graphWebview.ts:showGraphWebview" },
@@ -1,58 +1,58 @@
1
1
  export const webUiManifest = {
2
2
  surface: "web-ui",
3
- version: "0.1.17",
3
+ version: "0.1.42",
4
4
  actions: {
5
5
  // Finding management
6
- "finding.add": { implemented: false, reason: "Web UI is read-only for findings (review queue only)" },
7
- "finding.remove": { implemented: false, reason: "Web UI is read-only for findings" },
8
- "finding.list": { implemented: true, handler: "memory-ui-server.ts:/api/project-content" },
6
+ "finding.add": { implemented: true, handler: "ui/server.ts:POST /api/findings/<project>" },
7
+ "finding.remove": { implemented: true, handler: "ui/server.ts:DELETE /api/findings/<project>" },
8
+ "finding.list": { implemented: true, handler: "ui/server.ts:/api/findings/<project> + /api/project-content" },
9
9
  "finding.filter_by_date": { implemented: false, reason: "No date filter in web UI API" },
10
- "finding.pin": { implemented: false, reason: "No pin action in web UI" },
10
+ "finding.pin": { implemented: false, reason: "Pinning to truths.md is CLI/MCP-only" },
11
11
  // Task management
12
- "task.add": { implemented: false, reason: "No task creation in web UI" },
13
- "task.complete": { implemented: false, reason: "No task completion in web UI" },
14
- "task.remove": { implemented: false, reason: "No task deletion in web UI" },
15
- "task.update": { implemented: false, reason: "No task update in web UI" },
16
- "task.list": { implemented: true, handler: "memory-ui-server.ts:/api/tasks" },
17
- "task.pin": { implemented: false, reason: "No task pinning in web UI" },
18
- "task.github_link": { implemented: false, reason: "No GitHub link in web UI" },
12
+ "task.add": { implemented: true, handler: "ui/server.ts:POST /api/tasks/add" },
13
+ "task.complete": { implemented: true, handler: "ui/server.ts:POST /api/tasks/complete" },
14
+ "task.remove": { implemented: true, handler: "ui/server.ts:POST /api/tasks/remove" },
15
+ "task.update": { implemented: true, handler: "ui/server.ts:POST /api/tasks/update" },
16
+ "task.list": { implemented: true, handler: "ui/server.ts:/api/tasks" },
17
+ "task.pin": { implemented: false, reason: "No task pinning in web UI (pinned flag is displayed read-only)" },
18
+ "task.github_link": { implemented: false, reason: "Issue links display in the task list; creating them is MCP/VS Code-only" },
19
19
  // Hook management
20
- "hook.list": { implemented: true, handler: "memory-ui-server.ts:/api/hooks" },
21
- "hook.toggle": { implemented: true, handler: "memory-ui-server.ts:/api/hook-toggle" },
20
+ "hook.list": { implemented: true, handler: "ui/server.ts:/api/hooks" },
21
+ "hook.toggle": { implemented: true, handler: "ui/server.ts:POST /api/hook-toggle" },
22
22
  "hook.toggle_per_project": { implemented: false, reason: "Per-project hook toggle not exposed in web UI" },
23
23
  "hook.custom_crud": { implemented: false, reason: "Custom hooks CRUD not exposed in web UI" },
24
24
  "hook.errors": { implemented: false, reason: "Hook errors not exposed in web UI" },
25
25
  // Search
26
- "search.fts": { implemented: true, handler: "memory-ui-server.ts:/api/search" },
26
+ "search.fts": { implemented: true, handler: "ui/server.ts:/api/search" },
27
27
  "search.fragment": { implemented: false, reason: "No fragment search in web UI" },
28
28
  "search.related_docs": { implemented: false, reason: "No related docs in web UI" },
29
29
  "search.history": { implemented: false, reason: "No search history in web UI" },
30
30
  // Graph
31
- "graph.read": { implemented: true, handler: "memory-ui-server.ts:/api/graph" },
32
- "graph.visualize": { implemented: true, handler: "memory-ui-graph-app.ts:graph tab (GraphRAG-style store>project>finding cages, Three.js / 3d-force-graph, CSS2D labels)" },
31
+ "graph.read": { implemented: true, handler: "ui/server.ts:/api/graph" },
32
+ "graph.visualize": { implemented: true, handler: "ui/graph.ts:graph tab (browser/graph bundle — store>project>finding cages, Three.js / 3d-force-graph, CSS2D labels)" },
33
33
  "graph.link_findings": { implemented: false, reason: "No link findings action in web UI" },
34
34
  // Config
35
- "config.get": { implemented: true, handler: "memory-ui-server.ts:/api/settings (read)" },
36
- "config.set": { implemented: true, handler: "memory-ui-server.ts:/api/settings (workflow policy, task mode)" },
35
+ "config.get": { implemented: true, handler: "ui/server.ts:/api/settings + /api/config" },
36
+ "config.set": { implemented: true, handler: "ui/server.ts:POST /api/settings/* (workflow policy, task mode, proactivity, finding sensitivity, index policy, auto-capture, mcp-enabled, project overrides, RBAC via /api/settings/access)" },
37
37
  // Health / Sync / Session
38
- "health.check": { implemented: true, handler: "memory-ui-server.ts:/api/runtime-health" },
38
+ "health.check": { implemented: true, handler: "ui/server.ts:/api/runtime-health" },
39
39
  "health.doctor_fix": { implemented: false, reason: "Doctor --fix is CLI-only" },
40
- "health.sync": { implemented: true, handler: "memory-ui-server.ts:/api/sync" },
40
+ "health.sync": { implemented: true, handler: "ui/server.ts:POST /api/sync" },
41
41
  "session.start": { implemented: false, reason: "Session lifecycle is not web UI driven" },
42
42
  "session.end": { implemented: false, reason: "Session lifecycle is not web UI driven" },
43
43
  // Skill management
44
- "skill.list": { implemented: true, handler: "memory-ui-server.ts:/api/skills" },
45
- "skill.read": { implemented: true, handler: "memory-ui-server.ts:/api/skill-content" },
46
- "skill.enable": { implemented: true, handler: "memory-ui-server.ts:/api/skill-toggle" },
47
- "skill.write": { implemented: true, handler: "memory-ui-server.ts:/api/skill-save" },
44
+ "skill.list": { implemented: true, handler: "ui/server.ts:/api/skills" },
45
+ "skill.read": { implemented: true, handler: "ui/server.ts:/api/skill-content" },
46
+ "skill.enable": { implemented: true, handler: "ui/server.ts:POST /api/skill-toggle" },
47
+ "skill.write": { implemented: true, handler: "ui/server.ts:POST /api/skill-save" },
48
48
  // Project management
49
- "project.list": { implemented: true, handler: "memory-ui-server.ts:/api/projects" },
49
+ "project.list": { implemented: true, handler: "ui/server.ts:/api/projects" },
50
50
  "project.manage": { implemented: false, reason: "No archive/unarchive in web UI" },
51
- "project.summary": { implemented: true, handler: "memory-ui-server.ts:/api/project-content" },
51
+ "project.summary": { implemented: true, handler: "ui/server.ts:/api/project-content" },
52
52
  "export.project": { implemented: false, reason: "Export/import not exposed in web UI" },
53
53
  "import.project": { implemented: false, reason: "Export/import not exposed in web UI" },
54
54
  // Profile / Machine
55
- "profile.switch": { implemented: false, reason: "No profile switching in web UI" },
56
- "profile.list": { implemented: false, reason: "No profile listing in web UI" },
55
+ "profile.switch": { implemented: true, handler: "ui/server.ts:POST /api/profile" },
56
+ "profile.list": { implemented: true, handler: "ui/server.ts:/api/profiles" },
57
57
  },
58
58
  };
@@ -9,7 +9,7 @@ export declare function handleDoctor(args: string[]): Promise<void>;
9
9
  export declare function handleStatus(): Promise<void>;
10
10
  export declare function handleQualityFeedback(args: string[]): Promise<void>;
11
11
  export declare function handleMemoryUi(args: string[]): Promise<void>;
12
- export declare function handleShell(_args: string[], profile: string): Promise<void>;
12
+ export declare function handleShell(args: string[], profile: string): Promise<void>;
13
13
  export declare function handleUpdate(args: string[]): Promise<void>;
14
14
  export declare function handleReview(args: string[]): Promise<void>;
15
15
  export declare function handleConsolidationStatus(args: string[]): Promise<void>;
@@ -303,8 +303,13 @@ export async function handleMemoryUi(args) {
303
303
  allowPortFallback: !portRequested,
304
304
  });
305
305
  }
306
- export async function handleShell(_args, profile) {
307
- await startShell(getPhrenPath(), profile);
306
+ export async function handleShell(args, profile) {
307
+ const phrenPath = getPhrenPath();
308
+ const { parseShellArgs, resolveShellStartup } = await import("../shell/startup.js");
309
+ const { startup, warnings } = resolveShellStartup(parseShellArgs(args), { phrenPath, profile });
310
+ if (warnings.length)
311
+ startup.notice = warnings.join(" ");
312
+ await startShell(phrenPath, profile, startup);
308
313
  }
309
314
  export async function handleUpdate(args) {
310
315
  const result = await runPhrenUpdate({ refreshStarter: args.includes("--refresh-starter") });
@@ -1,14 +1,14 @@
1
1
  export declare function buildProactivitySnapshot(phrenPath: string): {
2
2
  path: string;
3
3
  configured: {
4
- proactivity: "high" | "medium" | "low" | null;
5
- proactivityFindings: "high" | "medium" | "low" | null;
6
- proactivityTask: "high" | "medium" | "low" | null;
4
+ proactivity: "high" | "low" | "medium" | null;
5
+ proactivityFindings: "high" | "low" | "medium" | null;
6
+ proactivityTask: "high" | "low" | "medium" | null;
7
7
  };
8
8
  effective: {
9
- proactivity: "high" | "medium" | "low";
10
- proactivityFindings: "high" | "medium" | "low";
11
- proactivityTask: "high" | "medium" | "low";
9
+ proactivity: "high" | "low" | "medium";
10
+ proactivityFindings: "high" | "low" | "medium";
11
+ proactivityTask: "high" | "low" | "medium";
12
12
  };
13
13
  };
14
14
  export declare function handleConfigProactivity(subcommand: "proactivity" | "proactivity.findings" | "proactivity.tasks", args: string[]): void;
@@ -3,7 +3,7 @@ import { getDocSourceKey, } from "../shared/index.js";
3
3
  import { logImpact, extractFindingIdsFromSnippet, } from "../finding/impact.js";
4
4
  import { isFeatureEnabled, errorMessage } from "../utils.js";
5
5
  import { annotateStale } from "./hooks-citations.js";
6
- import { approximateTokens, fileRelevanceBoost, branchMatchBoost } from "../shared/retrieval.js";
6
+ import { approximateTokens, fileRelevanceBoost, branchMatchBoost, SNIPPET_OVERHEAD_TOKENS } from "../shared/retrieval.js";
7
7
  import { logger } from "../logger.js";
8
8
  // ── Progressive disclosure helpers ────────────────────────────────────────────
9
9
  function buildOneLiner(snippet) {
@@ -17,10 +17,13 @@ function buildOneLiner(snippet) {
17
17
  }
18
18
  function buildCompactIndex(selected, phrenPathLocal) {
19
19
  const lines = [];
20
- for (const { doc, snippet } of selected) {
20
+ for (const { doc, snippet, key } of selected) {
21
21
  const id = `mem:${getDocSourceKey(doc, phrenPathLocal)}`;
22
22
  const summary = buildOneLiner(snippet);
23
- lines.push(`[${id}] ${doc.type}: ${summary}`);
23
+ // The fb: key rides here too. memory_feedback's description promises it
24
+ // appears in injected headers without qualification, and this path renders
25
+ // instead of the full one whenever progressive disclosure is enabled.
26
+ lines.push(`[${id}] fb:${key} ${doc.type}: ${summary}`);
24
27
  }
25
28
  return lines;
26
29
  }
@@ -78,14 +81,15 @@ export function buildHookOutput(selected, usedTokens, intent, gitCtx, detectedPr
78
81
  let totalTokens = 36; // base overhead
79
82
  const keep = ordered.map(() => true);
80
83
  for (let i = 0; i < ordered.length; i++) {
81
- totalTokens += approximateTokens(ordered[i].snippet) + 14;
84
+ // 24 ≈ header line ([source key] (type) fb:key) + blank separator.
85
+ totalTokens += approximateTokens(ordered[i].snippet) + SNIPPET_OVERHEAD_TOKENS;
82
86
  }
83
87
  // Trim from the middle (indices 1..N-2) if over budget
84
88
  if (totalTokens > tokenBudget) {
85
89
  for (let i = ordered.length - 2; i >= 1; i--) {
86
90
  if (totalTokens <= tokenBudget)
87
91
  break;
88
- totalTokens -= approximateTokens(ordered[i].snippet) + 14;
92
+ totalTokens -= approximateTokens(ordered[i].snippet) + SNIPPET_OVERHEAD_TOKENS;
89
93
  keep[i] = false;
90
94
  }
91
95
  ordered = ordered.filter((_, i) => keep[i]);
@@ -109,7 +113,12 @@ export function buildHookOutput(selected, usedTokens, intent, gitCtx, detectedPr
109
113
  catch (err) {
110
114
  logger.debug("hooks-output", `injectContext recordRetrievalOrdered: ${errorMessage(err)}`);
111
115
  }
112
- parts.push(`[${getDocSourceKey(doc, phrenPathLocal)}] (${doc.type})`);
116
+ // `fb:` is the memory_feedback handle. The tool scores entryScoreKey
117
+ // (project/filename:digest) — NOT the mem: source key and NOT an fid —
118
+ // and this header was the only place the injection pipeline had the
119
+ // key in hand; before it was printed here, the feedback loop was
120
+ // built, wired into ranking, and unreachable.
121
+ parts.push(`[${getDocSourceKey(doc, phrenPathLocal)}] (${doc.type}) fb:${key}`);
113
122
  parts.push(annotateStale(snippet));
114
123
  parts.push("");
115
124
  }
@@ -1,6 +1,6 @@
1
1
  export { parseCitations, validateCitation, annotateStale, clearCitationValidCache, type ParsedCitation, } from "./hooks-citations.js";
2
2
  export { getProjectGlobBoost, clearProjectGlobCache, } from "./hooks-globs.js";
3
- export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, selectSnippets, type SelectedSnippet, } from "../shared/retrieval.js";
3
+ export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, type SelectedSnippet, } from "../shared/retrieval.js";
4
4
  export { buildHookOutput, } from "./hooks-output.js";
5
5
  export { handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, trackSessionMetrics, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, resolveSubprocessArgs, } from "./hooks-session.js";
6
6
  export interface HookPromptInput {
package/dist/cli/hooks.js CHANGED
@@ -9,7 +9,7 @@ import { mergeConfig, } from "../shared/governance.js";
9
9
  import { loadIndexForHook, detectProject, } from "../shared/index.js";
10
10
  import { isProjectHookEnabled } from "../project-config.js";
11
11
  import { checkConsolidationNeeded, } from "../shared/content.js";
12
- import { buildRobustFtsQuery, extractKeywordEntries, isFeatureEnabled, clampInt, errorMessage, } from "../utils.js";
12
+ import { buildRobustFtsQuery, extractKeywordEntries, isFeatureEnabled, clampInt, clampFloat, errorMessage, } from "../utils.js";
13
13
  import { getHooksEnabledPreference } from "../init/init.js";
14
14
  import { logger } from "../logger.js";
15
15
  import { isToolHookEnabled, runPrePromptHooks } from "../hooks.js";
@@ -25,16 +25,16 @@ export { parseCitations, validateCitation, annotateStale, clearCitationValidCach
25
25
  // Globs
26
26
  export { getProjectGlobBoost, clearProjectGlobCache, } from "./hooks-globs.js";
27
27
  // Retrieval
28
- export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, selectSnippets, } from "../shared/retrieval.js";
28
+ export { detectTaskIntent, filterTaskByPriority, searchDocuments, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, } from "../shared/retrieval.js";
29
29
  // Output
30
30
  export { buildHookOutput, } from "./hooks-output.js";
31
31
  // Session
32
32
  export { handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, trackSessionMetrics, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, resolveSubprocessArgs, } from "./hooks-session.js";
33
33
  // ── Imports for the orchestrator ─────────────────────────────────────────────
34
- import { searchDocumentsAsync, applyTrustFilter, rankResults, selectSnippets, detectTaskIntent, } from "../shared/retrieval.js";
34
+ import { searchDocumentsAsync, applyTrustFilter, rankResults, applyRelevanceFloor, DEFAULT_MIN_QUERY_RELEVANCE, selectSnippets, detectTaskIntent, } from "../shared/retrieval.js";
35
35
  import { buildHookOutput } from "./hooks-output.js";
36
36
  import { getGitContext, trackSessionMetrics, } from "./hooks-session.js";
37
- import { approximateTokens } from "../shared/retrieval.js";
37
+ import { approximateTokens, SNIPPET_OVERHEAD_TOKENS } from "../shared/retrieval.js";
38
38
  import { resolveRuntimeProfile } from "../runtime-profile.js";
39
39
  import { handleTaskPromptLifecycle } from "../task/lifecycle.js";
40
40
  // Auto-learn from prompts was removed — it learned conversational noise ("bro", "idk", typos)
@@ -172,6 +172,17 @@ export async function handleHookPrompt() {
172
172
  const tRank0 = Date.now();
173
173
  rows = rankResults(rows, intent, gitCtx, detectedProject, getPhrenPath(), db, cwd, keywords);
174
174
  stage.rankMs = Date.now() - tRank0;
175
+ if (!rows.length)
176
+ process.exit(0);
177
+ // Relevance floor: inject signal or nothing. Ranking scores on priors too,
178
+ // so a doc can rank well with no real tie to this prompt — drop those rather
179
+ // than pad to a quota with noise (env PHREN_MIN_QUERY_RELEVANCE=0 disables).
180
+ const relevanceFloor = clampFloat(process.env.PHREN_MIN_QUERY_RELEVANCE, DEFAULT_MIN_QUERY_RELEVANCE, 0, 1);
181
+ const preFloorCount = rows.length;
182
+ rows = applyRelevanceFloor(rows, keywords, gitCtx, detectedProject, relevanceFloor);
183
+ if (rows.length !== preFloorCount) {
184
+ debugLog(`relevance-floor: ${preFloorCount} -> ${rows.length} rows (floor=${relevanceFloor})`);
185
+ }
175
186
  if (!rows.length)
176
187
  process.exit(0);
177
188
  let safeTokenBudget = clampInt(process.env.PHREN_CONTEXT_TOKEN_BUDGET, 550, 180, 10000);
@@ -206,7 +217,7 @@ export async function handleHookPrompt() {
206
217
  const kept = [];
207
218
  let runningTokens = 36;
208
219
  for (const s of sorted) {
209
- const est = approximateTokens(s.snippet) + 14;
220
+ const est = approximateTokens(s.snippet) + SNIPPET_OVERHEAD_TOKENS;
210
221
  if (runningTokens + est <= maxInjectTokens) {
211
222
  kept.push(s);
212
223
  runningTokens += est;
@@ -4,7 +4,7 @@ import { type PushStatus, type SyncStatus } from "../shared/governance.js";
4
4
  * Returns lines that contain insight-signal words and look like actionable knowledge.
5
5
  */
6
6
  export declare function extractConversationInsights(text: string): string[];
7
- export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "medium" | "low"): string[];
7
+ export declare function filterConversationInsightsForProactivity(insights: string[], level?: "high" | "low" | "medium"): string[];
8
8
  /**
9
9
  * Build the `lastSync` patch for a sync attempt, carrying the failure streak
10
10
  * forward. Success resets the counter and stamps `lastSuccessfulPushAt`;
@@ -8,7 +8,7 @@ export declare function filterToolFindingsForProactivity(candidates: Array<{
8
8
  text: string;
9
9
  confidence: number;
10
10
  explicit?: boolean;
11
- }>, level?: "high" | "medium" | "low"): Array<{
11
+ }>, level?: "high" | "low" | "medium"): Array<{
12
12
  text: string;
13
13
  confidence: number;
14
14
  explicit?: boolean;
@@ -226,7 +226,7 @@ export const REGISTRY = [
226
226
  {
227
227
  name: "shell",
228
228
  topic: "core",
229
- usage: "phren shell",
229
+ usage: "phren shell [--view <view>] [--project <name>] [--here]",
230
230
  summary: "Interactive memory shell",
231
231
  featured: true,
232
232
  run: async (args, ctx) => {
@@ -4,6 +4,7 @@
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
6
  import * as yaml from "js-yaml";
7
+ import { loadYamlDocument } from "../phren-core.js";
7
8
  import { appendAuditLog, phrenErr, PhrenError, phrenOk, forwardErr, getProjectDirs, isRecord, } from "../shared.js";
8
9
  import { normalizeQueueEntryText, } from "../shared/governance.js";
9
10
  import { addFindingToFile, } from "../shared/content.js";
@@ -111,7 +112,7 @@ function validateAggregateQueueProfile(phrenPath, profile) {
111
112
  }
112
113
  let data;
113
114
  try {
114
- data = yaml.load(fs.readFileSync(profilePath, "utf-8"), { schema: yaml.CORE_SCHEMA });
115
+ data = loadYamlDocument(fs.readFileSync(profilePath, "utf-8"), (text) => yaml.load(text, { schema: yaml.CORE_SCHEMA }));
115
116
  }
116
117
  catch {
117
118
  return phrenErr(`Malformed profile YAML: ${profilePath}`, PhrenError.MALFORMED_YAML);