@phren/cli 0.0.28 → 0.0.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 (153) hide show
  1. package/mcp/dist/capabilities/cli.js +2 -5
  2. package/mcp/dist/capabilities/mcp.js +5 -8
  3. package/mcp/dist/capabilities/types.js +2 -5
  4. package/mcp/dist/capabilities/vscode.js +2 -5
  5. package/mcp/dist/capabilities/web-ui.js +2 -5
  6. package/mcp/dist/{cli-actions.js → cli/actions.js} +25 -21
  7. package/mcp/dist/{cli.js → cli/cli.js} +13 -13
  8. package/mcp/dist/{cli-config.js → cli/config.js} +12 -12
  9. package/mcp/dist/{cli-extract.js → cli/extract.js} +8 -8
  10. package/mcp/dist/{cli-govern.js → cli/govern.js} +28 -17
  11. package/mcp/dist/{cli-graph.js → cli/graph.js} +10 -9
  12. package/mcp/dist/{cli-hooks-citations.js → cli/hooks-citations.js} +2 -2
  13. package/mcp/dist/{cli-hooks-context.js → cli/hooks-context.js} +23 -23
  14. package/mcp/dist/{cli-hooks-globs.js → cli/hooks-globs.js} +4 -4
  15. package/mcp/dist/{cli-hooks-output.js → cli/hooks-output.js} +9 -10
  16. package/mcp/dist/{cli-hooks-session.js → cli/hooks-session.js} +58 -117
  17. package/mcp/dist/{cli-hooks.js → cli/hooks.js} +27 -26
  18. package/mcp/dist/{cli-namespaces.js → cli/namespaces.js} +25 -24
  19. package/mcp/dist/{cli-ops.js → cli/ops.js} +9 -9
  20. package/mcp/dist/{cli-search.js → cli/search.js} +12 -11
  21. package/mcp/dist/cli-hooks-git.js +243 -0
  22. package/mcp/dist/cli-hooks-prompt.js +323 -0
  23. package/mcp/dist/cli-hooks-session-handlers.js +337 -0
  24. package/mcp/dist/cli-hooks-stop.js +519 -0
  25. package/mcp/dist/{content-archive.js → content/archive.js} +16 -29
  26. package/mcp/dist/{content-citation.js → content/citation.js} +5 -5
  27. package/mcp/dist/{content-dedup.js → content/dedup.js} +9 -12
  28. package/mcp/dist/{content-learning.js → content/learning.js} +41 -20
  29. package/mcp/dist/{content-validate.js → content/validate.js} +5 -5
  30. package/mcp/dist/{core-finding.js → core/finding.js} +4 -4
  31. package/mcp/dist/{core-project.js → core/project.js} +4 -4
  32. package/mcp/dist/{core-search.js → core/search.js} +2 -2
  33. package/mcp/dist/{data-access.js → data/access.js} +142 -15
  34. package/mcp/dist/{data-tasks.js → data/tasks.js} +7 -5
  35. package/mcp/dist/embedding.js +9 -14
  36. package/mcp/dist/entrypoint.js +11 -11
  37. package/mcp/dist/{finding-context.js → finding/context.js} +2 -2
  38. package/mcp/dist/{finding-impact.js → finding/impact.js} +3 -3
  39. package/mcp/dist/{finding-journal.js → finding/journal.js} +4 -4
  40. package/mcp/dist/{finding-lifecycle.js → finding/lifecycle.js} +13 -7
  41. package/mcp/dist/governance/audit.js +30 -0
  42. package/mcp/dist/{governance-locks.js → governance/locks.js} +14 -9
  43. package/mcp/dist/{governance-policy.js → governance/policy.js} +23 -12
  44. package/mcp/dist/{governance-rbac.js → governance/rbac.js} +4 -4
  45. package/mcp/dist/{governance-scores.js → governance/scores.js} +10 -11
  46. package/mcp/dist/hooks.js +53 -37
  47. package/mcp/dist/index-query.js +4 -1
  48. package/mcp/dist/index.js +54 -30
  49. package/mcp/dist/{init-config.js → init/config.js} +6 -6
  50. package/mcp/dist/{init.js → init/init.js} +80 -69
  51. package/mcp/dist/{init-preferences.js → init/preferences.js} +3 -3
  52. package/mcp/dist/{init-setup.js → init/setup.js} +17 -19
  53. package/mcp/dist/{init-shared.js → init/shared.js} +4 -4
  54. package/mcp/dist/init-bootstrap.js +21 -0
  55. package/mcp/dist/init-detect.js +38 -0
  56. package/mcp/dist/init-env.js +114 -0
  57. package/mcp/dist/init-fresh.js +234 -0
  58. package/mcp/dist/init-hooks.js +26 -0
  59. package/mcp/dist/init-mcp.js +65 -0
  60. package/mcp/dist/init-modes.js +135 -0
  61. package/mcp/dist/init-npm.js +37 -0
  62. package/mcp/dist/init-project-local.js +99 -0
  63. package/mcp/dist/init-semantic.js +48 -0
  64. package/mcp/dist/init-types.js +1 -0
  65. package/mcp/dist/init-uninstall.js +504 -0
  66. package/mcp/dist/init-update.js +96 -0
  67. package/mcp/dist/init-walkthrough.js +524 -0
  68. package/mcp/dist/{link-checksums.js → link/checksums.js} +5 -5
  69. package/mcp/dist/{link-context.js → link/context.js} +4 -4
  70. package/mcp/dist/{link-doctor.js → link/doctor.js} +20 -22
  71. package/mcp/dist/{link.js → link/link.js} +26 -31
  72. package/mcp/dist/{link-skills.js → link/skills.js} +10 -10
  73. package/mcp/dist/logger.js +11 -3
  74. package/mcp/dist/package-metadata.js +1 -1
  75. package/mcp/dist/phren-art.js +4 -126
  76. package/mcp/dist/phren-paths.js +30 -12
  77. package/mcp/dist/proactivity.js +3 -3
  78. package/mcp/dist/profile-store.js +5 -6
  79. package/mcp/dist/project-config.js +2 -2
  80. package/mcp/dist/project-topics.js +17 -47
  81. package/mcp/dist/provider-adapters.js +1 -1
  82. package/mcp/dist/query-correlation.js +1 -1
  83. package/mcp/dist/runtime-profile.js +1 -1
  84. package/mcp/dist/{session-checkpoints.js → session/checkpoints.js} +3 -3
  85. package/mcp/dist/{session-utils.js → session/utils.js} +1 -1
  86. package/mcp/dist/{shared-content.js → shared/content.js} +7 -7
  87. package/mcp/dist/{shared-data-utils.js → shared/data-utils.js} +28 -3
  88. package/mcp/dist/{shared-embedding-cache.js → shared/embedding-cache.js} +3 -3
  89. package/mcp/dist/{shared-fragment-graph.js → shared/fragment-graph.js} +19 -42
  90. package/mcp/dist/shared/governance.js +4 -0
  91. package/mcp/dist/{shared-index.js → shared/index.js} +105 -132
  92. package/mcp/dist/{shared-ollama.js → shared/ollama.js} +25 -7
  93. package/mcp/dist/shared/process.js +24 -0
  94. package/mcp/dist/{shared-retrieval.js → shared/retrieval.js} +22 -24
  95. package/mcp/dist/{shared-search-fallback.js → shared/search-fallback.js} +18 -20
  96. package/mcp/dist/{shared-sqljs.js → shared/sqljs.js} +3 -3
  97. package/mcp/dist/{shared-vector-index.js → shared/vector-index.js} +3 -3
  98. package/mcp/dist/shared.js +6 -60
  99. package/mcp/dist/{shell-entry.js → shell/entry.js} +6 -6
  100. package/mcp/dist/{shell-input.js → shell/input.js} +13 -13
  101. package/mcp/dist/{shell-palette.js → shell/palette.js} +3 -3
  102. package/mcp/dist/{shell-render.js → shell/render.js} +2 -2
  103. package/mcp/dist/{shell.js → shell/shell.js} +11 -11
  104. package/mcp/dist/{shell-state-store.js → shell/state-store.js} +5 -5
  105. package/mcp/dist/{shell-view-list.js → shell/view-list.js} +1 -1
  106. package/mcp/dist/{shell-view.js → shell/view.js} +13 -13
  107. package/mcp/dist/{skill-files.js → skill/files.js} +9 -9
  108. package/mcp/dist/{skill-registry.js → skill/registry.js} +5 -5
  109. package/mcp/dist/{skill-state.js → skill/state.js} +1 -4
  110. package/mcp/dist/startup-embedding.js +2 -2
  111. package/mcp/dist/status.js +15 -14
  112. package/mcp/dist/{tasks-github.js → task/github.js} +3 -2
  113. package/mcp/dist/{task-hygiene.js → task/hygiene.js} +4 -4
  114. package/mcp/dist/{task-lifecycle.js → task/lifecycle.js} +8 -13
  115. package/mcp/dist/telemetry.js +3 -4
  116. package/mcp/dist/tool-registry.js +29 -17
  117. package/mcp/dist/tools/config.js +530 -0
  118. package/mcp/dist/{mcp-data.js → tools/data.js} +8 -10
  119. package/mcp/dist/{mcp-extract-facts.js → tools/extract-facts.js} +6 -6
  120. package/mcp/dist/{mcp-extract.js → tools/extract.js} +6 -6
  121. package/mcp/dist/tools/finding.js +584 -0
  122. package/mcp/dist/{mcp-graph.js → tools/graph.js} +11 -14
  123. package/mcp/dist/{mcp-hooks.js → tools/hooks.js} +6 -6
  124. package/mcp/dist/{mcp-memory.js → tools/memory.js} +5 -5
  125. package/mcp/dist/tools/ops.js +468 -0
  126. package/mcp/dist/tools/search.js +672 -0
  127. package/mcp/dist/{mcp-session.js → tools/session.js} +51 -25
  128. package/mcp/dist/{mcp-skills.js → tools/skills.js} +42 -35
  129. package/mcp/dist/{mcp-tasks.js → tools/tasks.js} +155 -282
  130. package/mcp/dist/{memory-ui-data.js → ui/data.js} +31 -17
  131. package/mcp/dist/{memory-ui.js → ui/memory-ui.js} +3 -3
  132. package/mcp/dist/{memory-ui-page.js → ui/page.js} +5 -7
  133. package/mcp/dist/ui/server.js +1024 -0
  134. package/mcp/dist/update.js +2 -2
  135. package/mcp/dist/utils.js +63 -19
  136. package/package.json +2 -2
  137. package/scripts/preuninstall.mjs +31 -0
  138. package/starter/global/CLAUDE.md +3 -2
  139. package/mcp/dist/governance-audit.js +0 -22
  140. package/mcp/dist/mcp-config.js +0 -551
  141. package/mcp/dist/mcp-finding.js +0 -594
  142. package/mcp/dist/mcp-ops.js +0 -363
  143. package/mcp/dist/mcp-search.js +0 -668
  144. package/mcp/dist/memory-ui-server.js +0 -1411
  145. package/mcp/dist/shared-governance.js +0 -4
  146. /package/mcp/dist/{content-metadata.js → content/metadata.js} +0 -0
  147. /package/mcp/dist/{shared-stemmer.js → shared/stemmer.js} +0 -0
  148. /package/mcp/dist/{shell-types.js → shell/types.js} +0 -0
  149. /package/mcp/dist/{mcp-types.js → tools/types.js} +0 -0
  150. /package/mcp/dist/{memory-ui-assets.js → ui/assets.js} +0 -0
  151. /package/mcp/dist/{memory-ui-graph.js → ui/graph.js} +0 -0
  152. /package/mcp/dist/{memory-ui-scripts.js → ui/scripts.js} +0 -0
  153. /package/mcp/dist/{memory-ui-styles.js → ui/styles.js} +0 -0
@@ -32,11 +32,8 @@ export const cliManifest = {
32
32
  "graph.visualize": { implemented: false, reason: "Graph visualization is VS Code / web only" },
33
33
  "graph.link_findings": { implemented: true, handler: "cli-graph.ts:handleGraphLink" },
34
34
  // Config
35
- "config.proactivity": { implemented: true, handler: "cli-config.ts:handleProactivity" },
36
- "config.task_mode": { implemented: true, handler: "cli-config.ts:handleConfigTaskMode" },
37
- "config.retention": { implemented: true, handler: "cli-config.ts:handleRetentionPolicy" },
38
- "config.workflow": { implemented: true, handler: "cli-config.ts:handleWorkflowPolicy" },
39
- "config.index": { implemented: true, handler: "cli-config.ts:handleIndexPolicy" },
35
+ "config.get": { implemented: true, handler: "cli-config.ts:handleConfigGet (per-domain)" },
36
+ "config.set": { implemented: true, handler: "cli-config.ts:handleConfigSet (proactivity, taskMode, findingSensitivity, retention, workflow, index)" },
40
37
  // Health / Sync / Session
41
38
  "health.check": { implemented: true, handler: "cli-actions.ts:handleDoctor" },
42
39
  "health.doctor_fix": { implemented: true, handler: "cli-actions.ts:handleDoctor --fix" },
@@ -14,8 +14,8 @@ export const mcpManifest = {
14
14
  "task.remove": { implemented: true, handler: "index.ts:remove_task" },
15
15
  "task.update": { implemented: true, handler: "index.ts:update_task" },
16
16
  "task.list": { implemented: true, handler: "index.ts:get_tasks" },
17
- "task.pin": { implemented: true, handler: "index.ts:pin_task" },
18
- "task.github_link": { implemented: true, handler: "index.ts:link_task_issue, promote_task_to_issue" },
17
+ "task.pin": { implemented: true, handler: "index.ts:update_task (pin)" },
18
+ "task.github_link": { implemented: true, handler: "index.ts:update_task (github_issue/github_url)" },
19
19
  // Hook management
20
20
  "hook.list": { implemented: true, handler: "index.ts:list_hooks" },
21
21
  "hook.toggle": { implemented: true, handler: "index.ts:toggle_hooks" },
@@ -32,11 +32,8 @@ export const mcpManifest = {
32
32
  "graph.visualize": { implemented: false, reason: "MCP returns data only; visualization is client-side" },
33
33
  "graph.link_findings": { implemented: true, handler: "index.ts:link_findings" },
34
34
  // Config
35
- "config.proactivity": { implemented: true, handler: "index.ts:get_config, set_proactivity" },
36
- "config.task_mode": { implemented: true, handler: "index.ts:get_config, set_task_mode" },
37
- "config.retention": { implemented: true, handler: "index.ts:get_config, set_retention_policy" },
38
- "config.workflow": { implemented: true, handler: "index.ts:get_config, set_workflow_policy, set_finding_sensitivity" },
39
- "config.index": { implemented: true, handler: "index.ts:get_config, set_index_policy" },
35
+ "config.get": { implemented: true, handler: "index.ts:get_config (supports all domains including topic)" },
36
+ "config.set": { implemented: true, handler: "index.ts:set_config (proactivity, taskMode, findingSensitivity, retention, workflow, index, topic)" },
40
37
  // Health / Sync / Session
41
38
  "health.check": { implemented: true, handler: "index.ts:health_check" },
42
39
  "health.doctor_fix": { implemented: true, handler: "index.ts:doctor_fix" },
@@ -46,7 +43,7 @@ export const mcpManifest = {
46
43
  // Skill management
47
44
  "skill.list": { implemented: true, handler: "index.ts:list_skills" },
48
45
  "skill.read": { implemented: true, handler: "index.ts:read_skill" },
49
- "skill.enable": { implemented: true, handler: "index.ts:enable_skill, disable_skill" },
46
+ "skill.enable": { implemented: true, handler: "index.ts:toggle_skill" },
50
47
  "skill.write": { implemented: true, handler: "index.ts:write_skill" },
51
48
  // Project management
52
49
  "project.list": { implemented: true, handler: "index.ts:list_projects" },
@@ -29,11 +29,8 @@ export const ACTION_KEYS = [
29
29
  "graph.visualize",
30
30
  "graph.link_findings",
31
31
  // Config
32
- "config.proactivity",
33
- "config.task_mode",
34
- "config.retention",
35
- "config.workflow",
36
- "config.index",
32
+ "config.get",
33
+ "config.set",
37
34
  // Health / Sync / Session
38
35
  "health.check",
39
36
  "health.doctor_fix",
@@ -32,11 +32,8 @@ export const vscodeManifest = {
32
32
  "graph.visualize": { implemented: true, handler: "graphWebview.ts:showGraphWebview (webview panel)" },
33
33
  "graph.link_findings": { implemented: false, reason: "Link findings is MCP-only" },
34
34
  // Config
35
- "config.proactivity": { implemented: false, reason: "Config tools are CLI-only" },
36
- "config.task_mode": { implemented: false, reason: "Config tools are CLI-only" },
37
- "config.retention": { implemented: false, reason: "Config tools are CLI-only" },
38
- "config.workflow": { implemented: false, reason: "Config tools are CLI-only" },
39
- "config.index": { implemented: false, reason: "Config tools are CLI-only" },
35
+ "config.get": { implemented: false, reason: "Config tools are CLI-only" },
36
+ "config.set": { implemented: false, reason: "Config tools are CLI-only" },
40
37
  // Health / Sync / Session
41
38
  "health.check": { implemented: true, handler: "extension.ts:phren.doctor" },
42
39
  "health.doctor_fix": { implemented: true, handler: "extension.ts:phren.doctorFix" },
@@ -32,11 +32,8 @@ export const webUiManifest = {
32
32
  "graph.visualize": { implemented: true, handler: "memory-ui-graph-app.ts:graph tab (Sigma.js v3 + ForceAtlas2)" },
33
33
  "graph.link_findings": { implemented: false, reason: "No link findings action in web UI" },
34
34
  // Config
35
- "config.proactivity": { implemented: false, reason: "Config is CLI-only" },
36
- "config.task_mode": { implemented: true, handler: "memory-ui-server.ts:/api/settings (workflow policy)" },
37
- "config.retention": { implemented: false, reason: "Config is CLI-only" },
38
- "config.workflow": { implemented: true, handler: "memory-ui-server.ts:/api/settings (workflow policy)" },
39
- "config.index": { implemented: false, reason: "Config is CLI-only" },
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)" },
40
37
  // Health / Sync / Session
41
38
  "health.check": { implemented: true, handler: "memory-ui-server.ts:/api/runtime-health" },
42
39
  "health.doctor_fix": { implemented: false, reason: "Doctor --fix is CLI-only" },
@@ -1,19 +1,20 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
- import { runtimeFile, getPhrenPath, getProjectDirs } from "./shared.js";
4
- import { recordFeedback, flushEntryScores, getWorkflowPolicy, } from "./shared-governance.js";
5
- import { upsertCanonical } from "./shared-content.js";
6
- import { errorMessage, isValidProjectName } from "./utils.js";
7
- import { addFinding as addFindingCore } from "./core-finding.js";
8
- import { runDoctor } from "./link.js";
9
- import { startWebUi } from "./memory-ui.js";
10
- import { startShell } from "./shell.js";
11
- import { runPhrenUpdate } from "./update.js";
12
- import { readRuntimeHealth, readReviewQueue, readReviewQueueAcrossProjects } from "./data-access.js";
13
- import { runSearch, runFragmentSearch, parseFragmentSearchArgs, runRelatedDocs, parseRelatedDocsArgs } from "./cli-search.js";
14
- import { resolveRuntimeProfile } from "./runtime-profile.js";
15
- import { getProjectConsolidationStatus, CONSOLIDATION_ENTRY_THRESHOLD } from "./content-validate.js";
16
- import { listAllSessions } from "./mcp-session.js";
3
+ import { runtimeFile, getPhrenPath, getProjectDirs } from "../shared.js";
4
+ import { recordFeedback, flushEntryScores, getWorkflowPolicy, } from "../shared/governance.js";
5
+ import { upsertCanonical } from "../shared/content.js";
6
+ import { errorMessage, isValidProjectName } from "../utils.js";
7
+ import { logger } from "../logger.js";
8
+ import { addFinding as addFindingCore } from "../core/finding.js";
9
+ import { runDoctor } from "../link/link.js";
10
+ import { startWebUi } from "../ui/memory-ui.js";
11
+ import { startShell } from "../shell/shell.js";
12
+ import { runPhrenUpdate } from "../update.js";
13
+ import { readRuntimeHealth, readReviewQueue, readReviewQueueAcrossProjects } from "../data/access.js";
14
+ import { runSearch, runFragmentSearch, parseFragmentSearchArgs, runRelatedDocs, parseRelatedDocsArgs } from "./search.js";
15
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
16
+ import { getProjectConsolidationStatus, CONSOLIDATION_ENTRY_THRESHOLD } from "../content/validate.js";
17
+ import { listAllSessions } from "../tools/session.js";
17
18
  async function runAndPrint(fn) {
18
19
  const result = await fn();
19
20
  if (result.lines.length > 0)
@@ -69,7 +70,7 @@ export async function handleDoctor(args) {
69
70
  const agentsOnly = args.includes("--agents");
70
71
  const parityCheck = args.includes("--parity");
71
72
  if (parityCheck) {
72
- const { ALL_MANIFESTS, ACTION_KEYS } = await import("./capabilities/index.js");
73
+ const { ALL_MANIFESTS, ACTION_KEYS } = await import("../capabilities/index.js");
73
74
  const gaps = [];
74
75
  for (const key of ACTION_KEYS) {
75
76
  for (const manifest of ALL_MANIFESTS) {
@@ -157,7 +158,7 @@ export async function handleDoctor(args) {
157
158
  }
158
159
  catch (err) {
159
160
  if ((process.env.PHREN_DEBUG))
160
- process.stderr.write(`[phren] doctor searchMissParse: ${errorMessage(err)}\n`);
161
+ logger.debug("cli-actions", `doctor searchMissParse: ${errorMessage(err)}`);
161
162
  }
162
163
  }
163
164
  const topMisses = [...tokenCounts.entries()]
@@ -174,7 +175,7 @@ export async function handleDoctor(args) {
174
175
  }
175
176
  catch (err) {
176
177
  if ((process.env.PHREN_DEBUG))
177
- process.stderr.write(`[phren] doctor searchMissAnalysis: ${errorMessage(err)}\n`);
178
+ logger.debug("cli-actions", `doctor searchMissAnalysis: ${errorMessage(err)}`);
178
179
  }
179
180
  const semStatus = await getSemanticSearchStatus(getPhrenPath(), profile || undefined);
180
181
  if (!semStatus.ollamaUrl) {
@@ -193,9 +194,9 @@ export async function handleDoctor(args) {
193
194
  }
194
195
  async function getSemanticSearchStatus(phrenPath, profile) {
195
196
  try {
196
- const { checkOllamaAvailable, checkModelAvailable, getOllamaUrl, getEmbeddingModel } = await import("./shared-ollama.js");
197
- const { getEmbeddingCache, formatEmbeddingCoverage } = await import("./shared-embedding-cache.js");
198
- const { listIndexedDocumentPaths } = await import("./shared-index.js");
197
+ const { checkOllamaAvailable, checkModelAvailable, getOllamaUrl, getEmbeddingModel } = await import("../shared/ollama.js");
198
+ const { getEmbeddingCache, formatEmbeddingCoverage } = await import("../shared/embedding-cache.js");
199
+ const { listIndexedDocumentPaths } = await import("../shared/index.js");
199
200
  const ollamaUrl = getOllamaUrl();
200
201
  if (!ollamaUrl)
201
202
  return { ollamaUrl: null };
@@ -213,7 +214,7 @@ async function getSemanticSearchStatus(phrenPath, profile) {
213
214
  }
214
215
  catch (err) {
215
216
  if ((process.env.PHREN_DEBUG))
216
- process.stderr.write(`[phren] getSemanticSearchStatus: ${errorMessage(err)}\n`);
217
+ logger.debug("cli-actions", `getSemanticSearchStatus: ${errorMessage(err)}`);
217
218
  return { ollamaUrl: null, status: "error", error: errorMessage(err) };
218
219
  }
219
220
  }
@@ -289,6 +290,9 @@ export async function handleUpdate(args) {
289
290
  if (!result.ok) {
290
291
  process.exitCode = 1;
291
292
  }
293
+ else {
294
+ console.log("Run 'npx phren init' to refresh hooks and config.");
295
+ }
292
296
  }
293
297
  export async function handleReview(args) {
294
298
  const phrenPath = getPhrenPath();
@@ -1,17 +1,17 @@
1
- import { getPhrenPath } from "./shared.js";
1
+ import { getPhrenPath } from "../shared.js";
2
2
  // Re-export from split modules so existing test imports keep working
3
- export { detectTaskIntent, parseHookInput, applyTrustFilter, rankResults, selectSnippets, buildHookOutput, trackSessionMetrics, filterTaskByPriority, parseCitations, validateCitation, annotateStale, getProjectGlobBoost, clearProjectGlobCache, clearCitationValidCache, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, } from "./cli-hooks.js";
4
- export { scoreFindingCandidate } from "./cli-extract.js";
5
- import { handleHookPrompt, handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, } from "./cli-hooks.js";
6
- import { handleExtractMemories } from "./cli-extract.js";
7
- import { handleGovernMemories, handlePruneMemories, handleConsolidateMemories, handleMaintain, handleBackgroundMaintenance, } from "./cli-govern.js";
8
- import { handleConfig, handleIndexPolicy, handleRetentionPolicy, handleWorkflowPolicy, } from "./cli-config.js";
9
- import { parseSearchArgs } from "./cli-search.js";
10
- import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handleTaskNamespace, } from "./cli-namespaces.js";
11
- import { handleTaskView, handleSessionsView, handleQuickstart, handleDebugInjection, handleInspectIndex, } from "./cli-ops.js";
12
- import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleReview, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./cli-actions.js";
13
- import { handleGraphNamespace } from "./cli-graph.js";
14
- import { resolveRuntimeProfile } from "./runtime-profile.js";
3
+ export { detectTaskIntent, parseHookInput, applyTrustFilter, rankResults, selectSnippets, buildHookOutput, trackSessionMetrics, filterTaskByPriority, parseCitations, validateCitation, annotateStale, getProjectGlobBoost, clearProjectGlobCache, clearCitationValidCache, filterConversationInsightsForProactivity, extractToolFindings, filterToolFindingsForProactivity, } from "./hooks.js";
4
+ export { scoreFindingCandidate } from "./extract.js";
5
+ import { handleHookPrompt, handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, } from "./hooks.js";
6
+ import { handleExtractMemories } from "./extract.js";
7
+ import { handleGovernMemories, handlePruneMemories, handleConsolidateMemories, handleMaintain, handleBackgroundMaintenance, } from "./govern.js";
8
+ import { handleConfig, handleIndexPolicy, handleRetentionPolicy, handleWorkflowPolicy, } from "./config.js";
9
+ import { parseSearchArgs } from "./search.js";
10
+ import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handleTaskNamespace, } from "./namespaces.js";
11
+ import { handleTaskView, handleSessionsView, handleQuickstart, handleDebugInjection, handleInspectIndex, } from "./ops.js";
12
+ import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleReview, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./actions.js";
13
+ import { handleGraphNamespace } from "./graph.js";
14
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
15
15
  // ── CLI router ───────────────────────────────────────────────────────────────
16
16
  export async function runCliCommand(command, args) {
17
17
  const getProfile = () => resolveRuntimeProfile(getPhrenPath());
@@ -1,14 +1,14 @@
1
- import { getPhrenPath, readRootManifest } from "./shared.js";
2
- import { installPreferencesFile } from "./phren-paths.js";
3
- import { getIndexPolicy, updateIndexPolicy, getRetentionPolicy, updateRetentionPolicy, getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, VALID_TASK_MODES, VALID_FINDING_SENSITIVITY, } from "./shared-governance.js";
4
- import { listMachines as listMachinesStore, listProfiles as listProfilesStore, listProfiles } from "./data-access.js";
5
- import { setTelemetryEnabled, getTelemetrySummary, resetTelemetry } from "./telemetry.js";
6
- import { governanceInstallPreferencesFile, readInstallPreferences, readGovernanceInstallPreferences, writeInstallPreferences, writeGovernanceInstallPreferences, } from "./init-preferences.js";
7
- import { PROACTIVITY_LEVELS, getProactivityLevel, getProactivityLevelForTask, getProactivityLevelForFindings, } from "./proactivity.js";
8
- import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, updateProjectConfigOverrides, } from "./project-config.js";
9
- import { isValidProjectName, learnedSynonymsPath, learnSynonym, loadLearnedSynonyms, removeLearnedSynonym, } from "./utils.js";
1
+ import { getPhrenPath, readRootManifest } from "../shared.js";
2
+ import { installPreferencesFile } from "../phren-paths.js";
3
+ import { getIndexPolicy, updateIndexPolicy, getRetentionPolicy, updateRetentionPolicy, getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, VALID_TASK_MODES, VALID_FINDING_SENSITIVITY, } from "../shared/governance.js";
4
+ import { listMachines as listMachinesStore, listProfiles as listProfilesStore, listProfiles } from "../data/access.js";
5
+ import { setTelemetryEnabled, getTelemetrySummary, resetTelemetry } from "../telemetry.js";
6
+ import { governanceInstallPreferencesFile, readInstallPreferences, readGovernanceInstallPreferences, writeInstallPreferences, writeGovernanceInstallPreferences, } from "../init/preferences.js";
7
+ import { PROACTIVITY_LEVELS, getProactivityLevel, getProactivityLevelForTask, getProactivityLevelForFindings, } from "../proactivity.js";
8
+ import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, updateProjectConfigOverrides, } from "../project-config.js";
9
+ import { isValidProjectName, learnedSynonymsPath, learnSynonym, loadLearnedSynonyms, removeLearnedSynonym, } from "../utils.js";
10
10
  // ── Shared helpers ────────────────────────────────────────────────────────────
11
- export function parseProjectArg(args) {
11
+ function parseProjectArg(args) {
12
12
  const project = args.find((a) => a.startsWith("--project="))?.slice("--project=".length)
13
13
  ?? (args.indexOf("--project") !== -1 ? args[args.indexOf("--project") + 1] : undefined);
14
14
  const rest = args.filter((a, i) => a !== "--project" && !a.startsWith("--project=") && args[i - 1] !== "--project");
@@ -53,7 +53,7 @@ function formatConfigAsTable(label, rows) {
53
53
  console.log(` ${k.padEnd(maxKey)} ${v}`);
54
54
  }
55
55
  }
56
- export function handleConfigShow(args) {
56
+ function handleConfigShow(args) {
57
57
  const phrenPath = getPhrenPath();
58
58
  const { project: projectArg } = parseProjectArg(args);
59
59
  if (projectArg) {
@@ -461,7 +461,7 @@ function handleConfigFindingSensitivity(args) {
461
461
  // ── LLM config ───────────────────────────────────────────────────────────────
462
462
  const EXPENSIVE_MODEL_RE = /opus|sonnet|gpt-4(?!o-mini)/i;
463
463
  const DEFAULT_LLM_MODEL = "gpt-4o-mini / claude-haiku-4-5-20251001";
464
- export function printSemanticCostNotice(model) {
464
+ function printSemanticCostNotice(model) {
465
465
  const effectiveModel = model || process.env.PHREN_LLM_MODEL || DEFAULT_LLM_MODEL;
466
466
  console.log(` Note: Each semantic check is ~80 input + ~5 output tokens (one call per 'maybe' pair, cached 24h).`);
467
467
  console.log(` Current model: ${effectiveModel}`);
@@ -1,16 +1,16 @@
1
- import { debugLog, appendAuditLog, EXEC_TIMEOUT_MS, getPhrenPath, } from "./shared.js";
2
- import { appendReviewQueue, getRetentionPolicy, recordFeedback, flushEntryScores, entryScoreKey, } from "./shared-governance.js";
3
- import { detectProject } from "./shared-index.js";
4
- import { commandExists } from "./hooks.js";
5
- import { runGit as runGitShared, isFeatureEnabled, clampInt, errorMessage, resolveExecCommand } from "./utils.js";
6
- import { appendFindingJournal, compactFindingJournals } from "./finding-journal.js";
7
- import { getProactivityLevelForTask, getProactivityLevelForFindings, shouldAutoCaptureFindingsForLevel } from "./proactivity.js";
1
+ import { debugLog, appendAuditLog, EXEC_TIMEOUT_MS, getPhrenPath, } from "../shared.js";
2
+ import { appendReviewQueue, getRetentionPolicy, recordFeedback, flushEntryScores, entryScoreKey, } from "../shared/governance.js";
3
+ import { detectProject } from "../shared/index.js";
4
+ import { commandExists } from "../hooks.js";
5
+ import { runGit as runGitShared, isFeatureEnabled, clampInt, errorMessage, resolveExecCommand } from "../utils.js";
6
+ import { appendFindingJournal, compactFindingJournals } from "../finding/journal.js";
7
+ import { getProactivityLevelForTask, getProactivityLevelForFindings, shouldAutoCaptureFindingsForLevel } from "../proactivity.js";
8
8
  import * as fs from "fs";
9
9
  import * as os from "os";
10
10
  import * as path from "path";
11
11
  import * as crypto from "crypto";
12
12
  import { execFileSync } from "child_process";
13
- import { resolveRuntimeProfile } from "./runtime-profile.js";
13
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
14
14
  function runGit(cwd, args) {
15
15
  return runGitShared(cwd, args, EXEC_TIMEOUT_MS, debugLog);
16
16
  }
@@ -1,12 +1,13 @@
1
- import { appendAuditLog, qualityMarkers, getProjectDirs, getPhrenPath, } from "./shared.js";
2
- import { appendReviewQueue, getRetentionPolicy, consolidateProjectFindings, updateRuntimeHealth, pruneDeadMemories, } from "./shared-governance.js";
3
- import { filterTrustedFindingsDetailed, } from "./shared-content.js";
1
+ import { appendAuditLog, qualityMarkers, getProjectDirs, getPhrenPath, } from "../shared.js";
2
+ import { appendReviewQueue, getRetentionPolicy, consolidateProjectFindings, updateRuntimeHealth, pruneDeadMemories, } from "../shared/governance.js";
3
+ import { filterTrustedFindingsDetailed, } from "../shared/content.js";
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
- import { handleExtractMemories } from "./cli-extract.js";
7
- import { errorMessage } from "./utils.js";
8
- import { compactFindingJournals } from "./finding-journal.js";
9
- import { resolveRuntimeProfile } from "./runtime-profile.js";
6
+ import { handleExtractMemories } from "./extract.js";
7
+ import { errorMessage } from "../utils.js";
8
+ import { logger } from "../logger.js";
9
+ import { compactFindingJournals } from "../finding/journal.js";
10
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
10
11
  // ── Shared helpers ───────────────────────────────────────────────────────────
11
12
  function targetProjects(projectArg) {
12
13
  const profile = resolveRuntimeProfile(getPhrenPath());
@@ -145,7 +146,7 @@ export async function handlePruneMemories(args = []) {
145
146
  }
146
147
  catch (err) {
147
148
  if ((process.env.PHREN_DEBUG))
148
- process.stderr.write(`[phren] cli-govern retrievalLog readParse: ${errorMessage(err)}\n`);
149
+ logger.debug("cli-govern", `retrievalLog readParse: ${errorMessage(err)}`);
149
150
  }
150
151
  }
151
152
  // Build map of last retrieval date by file+bullet key
@@ -227,10 +228,10 @@ export async function handleConsolidateMemories(args = []) {
227
228
  return;
228
229
  console.log(`Updated backups (${backups.length}): ${backups.join(", ")}`);
229
230
  }
230
- export async function handleGcMaintain(args = []) {
231
+ async function handleGcMaintain(args = []) {
231
232
  const dryRun = args.includes("--dry-run");
232
233
  const phrenPath = getPhrenPath();
233
- const { execSync } = await import("child_process");
234
+ const { execFileSync } = await import("child_process");
234
235
  const report = {
235
236
  gitGcRan: false,
236
237
  commitsSquashed: 0,
@@ -243,7 +244,7 @@ export async function handleGcMaintain(args = []) {
243
244
  }
244
245
  else {
245
246
  try {
246
- execSync("git gc --aggressive --quiet", { cwd: phrenPath, stdio: "pipe" });
247
+ execFileSync("git", ["gc", "--aggressive", "--quiet"], { cwd: phrenPath, stdio: "pipe" });
247
248
  report.gitGcRan = true;
248
249
  console.log("git gc --aggressive: done");
249
250
  }
@@ -255,7 +256,10 @@ export async function handleGcMaintain(args = []) {
255
256
  const sevenDaysAgo = new Date(Date.now() - 7 * 86400000).toISOString().slice(0, 10);
256
257
  let oldCommits = [];
257
258
  try {
258
- const raw = execSync(`git log --before="${sevenDaysAgo}" --format="%H %ci %s"`, { cwd: phrenPath, encoding: "utf8" }).trim();
259
+ const raw = execFileSync("git", ["log", `--before=${sevenDaysAgo}`, "--format=%H %ci %s"], {
260
+ cwd: phrenPath,
261
+ encoding: "utf8",
262
+ }).trim();
259
263
  if (raw) {
260
264
  oldCommits = raw.split("\n").filter((l) => l.includes("auto-save:") || l.includes("[auto]"));
261
265
  }
@@ -294,8 +298,11 @@ export async function handleGcMaintain(args = []) {
294
298
  try {
295
299
  const oldest = hashes[hashes.length - 1];
296
300
  const newest = hashes[0];
297
- // Use git rebase --onto to squash: squash all into the oldest parent
298
- const parentOfOldest = execSync(`git rev-parse ${oldest}^`, { cwd: phrenPath, encoding: "utf8" }).trim();
301
+ // Use git rev-parse to get the parent of the oldest commit
302
+ const parentOfOldest = execFileSync("git", ["rev-parse", `${oldest}^`], {
303
+ cwd: phrenPath,
304
+ encoding: "utf8",
305
+ }).trim();
299
306
  // Build rebase script via env variable to squash all but first to "squash"
300
307
  const rebaseScript = hashes
301
308
  .map((h, i) => `${i === hashes.length - 1 ? "pick" : "squash"} ${h} auto-save`)
@@ -303,8 +310,12 @@ export async function handleGcMaintain(args = []) {
303
310
  .join("\n");
304
311
  const scriptPath = path.join(phrenPath, ".runtime", `gc-rebase-${weekKey}.sh`);
305
312
  fs.writeFileSync(scriptPath, rebaseScript);
306
- // Use GIT_SEQUENCE_EDITOR to feed our script
307
- execSync(`GIT_SEQUENCE_EDITOR="cat ${scriptPath} >" git rebase -i ${parentOfOldest}`, { cwd: phrenPath, stdio: "pipe" });
313
+ // Use GIT_SEQUENCE_EDITOR env var to feed our script to git rebase
314
+ execFileSync("git", ["rebase", "-i", parentOfOldest], {
315
+ cwd: phrenPath,
316
+ stdio: "pipe",
317
+ env: { ...process.env, GIT_SEQUENCE_EDITOR: `cat ${scriptPath} >` },
318
+ });
308
319
  fs.unlinkSync(scriptPath);
309
320
  report.commitsSquashed += hashes.length - 1;
310
321
  console.log(`Squashed ${hashes.length} auto-save commits for week of ${weekKey} (${newest.slice(0, 7)}..${oldest.slice(0, 7)}).`);
@@ -502,7 +513,7 @@ export async function handleBackgroundMaintenance(projectArg) {
502
513
  }
503
514
  catch (err) {
504
515
  if ((process.env.PHREN_DEBUG))
505
- process.stderr.write(`[phren] cli-govern backgroundMaintenance unlockFinal: ${errorMessage(err)}\n`);
516
+ logger.debug("cli-govern", `backgroundMaintenance unlockFinal: ${errorMessage(err)}`);
506
517
  }
507
518
  }
508
519
  }
@@ -1,7 +1,8 @@
1
- import { getPhrenPath } from "./shared.js";
2
- import { buildIndex, queryRows } from "./shared-index.js";
3
- import { resolveRuntimeProfile } from "./runtime-profile.js";
4
- import { isValidProjectName, errorMessage } from "./utils.js";
1
+ import { getPhrenPath } from "../shared.js";
2
+ import { buildIndex, queryRows } from "../shared/index.js";
3
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
4
+ import { isValidProjectName, errorMessage } from "../utils.js";
5
+ import { logger } from "../logger.js";
5
6
  /**
6
7
  * CLI: phren graph [--project <name>] [--limit <n>]
7
8
  * Displays the fragment knowledge graph as a table.
@@ -105,7 +106,7 @@ export async function handleGraphLink(args) {
105
106
  }
106
107
  catch (err) {
107
108
  if (process.env.PHREN_DEBUG)
108
- process.stderr.write(`[phren] graph link insert fragment: ${errorMessage(err)}\n`);
109
+ logger.debug("cli-graph", `graph link insert fragment: ${errorMessage(err)}`);
109
110
  }
110
111
  const fragmentResult = db.exec("SELECT id FROM entities WHERE name = ? AND type = ?", [normalizedFragment, "fragment"]);
111
112
  if (!fragmentResult?.length || !fragmentResult[0]?.values?.length) {
@@ -118,7 +119,7 @@ export async function handleGraphLink(args) {
118
119
  }
119
120
  catch (err) {
120
121
  if (process.env.PHREN_DEBUG)
121
- process.stderr.write(`[phren] graph link insert document: ${errorMessage(err)}\n`);
122
+ logger.debug("cli-graph", `graph link insert document: ${errorMessage(err)}`);
122
123
  }
123
124
  const docResult = db.exec("SELECT id FROM entities WHERE name = ? AND type = ?", [sourceDoc, "document"]);
124
125
  if (!docResult?.length || !docResult[0]?.values?.length) {
@@ -134,10 +135,10 @@ export async function handleGraphLink(args) {
134
135
  process.exit(1);
135
136
  }
136
137
  // Persist to manual-links.json
137
- const { runtimeFile } = await import("./shared.js");
138
+ const { runtimeFile } = await import("../shared.js");
138
139
  const fs = await import("fs");
139
140
  const crypto = await import("crypto");
140
- const { withFileLock } = await import("./shared-governance.js");
141
+ const { withFileLock } = await import("../shared/governance.js");
141
142
  const manualLinksPath = runtimeFile(phrenPath, "manual-links.json");
142
143
  try {
143
144
  withFileLock(manualLinksPath, () => {
@@ -147,7 +148,7 @@ export async function handleGraphLink(args) {
147
148
  existing = JSON.parse(fs.readFileSync(manualLinksPath, "utf8"));
148
149
  }
149
150
  catch (err) {
150
- process.stderr.write(`[phren] link_fragment: manual-links.json is malformed — aborting to avoid data loss: ${err instanceof Error ? err.message : String(err)}\n`);
151
+ logger.error("cli-graph", `link_fragment: manual-links.json is malformed — aborting to avoid data loss: ${err instanceof Error ? err.message : String(err)}`);
151
152
  throw err;
152
153
  }
153
154
  }
@@ -1,5 +1,5 @@
1
- import { parseCitationComment, validateFindingCitation, } from "./content-citation.js";
2
- import { capCache } from "./shared.js";
1
+ import { parseCitationComment, validateFindingCitation, } from "../content/citation.js";
2
+ import { capCache } from "../shared.js";
3
3
  // ── Citation validation ──────────────────────────────────────────────────────
4
4
  const citationValidCache = new Map();
5
5
  export function clearCitationValidCache() {
@@ -1,13 +1,13 @@
1
1
  // cli-hooks-context.ts — HookContext: everything a hook handler needs as plain data + helpers.
2
2
  // Centralizes the "resolve state and check guards" pattern so hook handlers don't
3
3
  // reach into governance, init, project-config, hooks, init-setup, etc. directly.
4
- import { getPhrenPath, readRootManifest, appendAuditLog, } from "./shared.js";
5
- import { updateRuntimeHealth, } from "./shared-governance.js";
6
- import { detectProject } from "./shared-index.js";
7
- import { getHooksEnabledPreference } from "./init.js";
8
- import { isToolHookEnabled } from "./hooks.js";
9
- import { isProjectHookEnabled } from "./project-config.js";
10
- import { resolveRuntimeProfile } from "./runtime-profile.js";
4
+ import { getPhrenPath, readRootManifest, appendAuditLog, } from "../shared.js";
5
+ import { updateRuntimeHealth, } from "../shared/governance.js";
6
+ import { detectProject } from "../shared/index.js";
7
+ import { getHooksEnabledPreference } from "../init/init.js";
8
+ import { isToolHookEnabled } from "../hooks.js";
9
+ import { isProjectHookEnabled } from "../project-config.js";
10
+ import { resolveRuntimeProfile } from "../runtime-profile.js";
11
11
  /** Build a HookContext from the current process environment. */
12
12
  export function buildHookContext() {
13
13
  const phrenPath = getPhrenPath();
@@ -38,19 +38,19 @@ export function handleGuardSkip(ctx, hookName, reason, healthUpdate) {
38
38
  appendAuditLog(ctx.phrenPath, hookName, `status=${reason}`);
39
39
  }
40
40
  // Re-export frequently used functions so hook handlers can import from one place
41
- export { debugLog, appendAuditLog, getPhrenPath, readRootManifest, sessionMarker, runtimeFile, EXEC_TIMEOUT_MS, getProjectDirs, findProjectNameCaseInsensitive, homePath, } from "./shared.js";
42
- export { updateRuntimeHealth, getWorkflowPolicy, withFileLock, appendReviewQueue, recordFeedback, getQualityMultiplier, } from "./shared-governance.js";
43
- export { detectProject } from "./shared-index.js";
44
- export { isProjectHookEnabled, readProjectConfig, getProjectSourcePath } from "./project-config.js";
45
- export { resolveRuntimeProfile } from "./runtime-profile.js";
46
- export { detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, } from "./init-setup.js";
47
- export { getProactivityLevelForTask, getProactivityLevelForFindings } from "./proactivity.js";
48
- export { hasExplicitFindingSignal, shouldAutoCaptureFindingsForLevel } from "./proactivity.js";
49
- export { FINDING_SENSITIVITY_CONFIG } from "./cli-config.js";
50
- export { isFeatureEnabled, errorMessage } from "./utils.js";
51
- export { bootstrapPhrenDotEnv } from "./phren-dotenv.js";
52
- export { finalizeTaskSession } from "./task-lifecycle.js";
53
- export { appendFindingJournal } from "./finding-journal.js";
54
- export { getHooksEnabledPreference } from "./init.js";
55
- export { isToolHookEnabled } from "./hooks.js";
56
- export { runDoctor } from "./link.js";
41
+ export { debugLog, appendAuditLog, getPhrenPath, readRootManifest, sessionMarker, runtimeFile, EXEC_TIMEOUT_MS, getProjectDirs, findProjectNameCaseInsensitive, homePath, } from "../shared.js";
42
+ export { updateRuntimeHealth, buildSyncStatus, getWorkflowPolicy, withFileLock, appendReviewQueue, recordFeedback, getQualityMultiplier, } from "../shared/governance.js";
43
+ export { detectProject } from "../shared/index.js";
44
+ export { isProjectHookEnabled, readProjectConfig, getProjectSourcePath } from "../project-config.js";
45
+ export { resolveRuntimeProfile } from "../runtime-profile.js";
46
+ export { detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, } from "../init/setup.js";
47
+ export { getProactivityLevelForTask, getProactivityLevelForFindings } from "../proactivity.js";
48
+ export { hasExplicitFindingSignal, shouldAutoCaptureFindingsForLevel } from "../proactivity.js";
49
+ export { FINDING_SENSITIVITY_CONFIG } from "./config.js";
50
+ export { isFeatureEnabled, errorMessage } from "../utils.js";
51
+ export { bootstrapPhrenDotEnv } from "../phren-dotenv.js";
52
+ export { finalizeTaskSession } from "../task/lifecycle.js";
53
+ export { appendFindingJournal } from "../finding/journal.js";
54
+ export { getHooksEnabledPreference } from "../init/init.js";
55
+ export { isToolHookEnabled } from "../hooks.js";
56
+ export { runDoctor } from "../link/link.js";
@@ -1,7 +1,8 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
- import { capCache } from "./shared.js";
4
- import { errorMessage } from "./utils.js";
3
+ import { capCache } from "../shared.js";
4
+ import { errorMessage } from "../utils.js";
5
+ import { logger } from "../logger.js";
5
6
  // ── Glob matching and project frontmatter ────────────────────────────────────
6
7
  const projectGlobCache = new Map();
7
8
  export function clearProjectGlobCache() {
@@ -45,8 +46,7 @@ function parseProjectGlobs(phrenPathLocal, project) {
45
46
  }
46
47
  }
47
48
  catch (err) {
48
- if (process.env.PHREN_DEBUG)
49
- process.stderr.write(`[phren] getProjectGlobs: ${errorMessage(err)}\n`);
49
+ logger.debug("hooks-globs", `getProjectGlobs: ${errorMessage(err)}`);
50
50
  }
51
51
  projectGlobCache.set(project, globs);
52
52
  capCache(projectGlobCache);
@@ -1,9 +1,10 @@
1
- import { recordInjection, recordRetrieval, } from "./shared-governance.js";
2
- import { getDocSourceKey, } from "./shared-index.js";
3
- import { logImpact, extractFindingIdsFromSnippet, } from "./finding-impact.js";
4
- import { isFeatureEnabled, errorMessage } from "./utils.js";
5
- import { annotateStale } from "./cli-hooks-citations.js";
6
- import { approximateTokens, fileRelevanceBoost, branchMatchBoost } from "./shared-retrieval.js";
1
+ import { recordInjection, recordRetrieval, } from "../shared/governance.js";
2
+ import { getDocSourceKey, } from "../shared/index.js";
3
+ import { logImpact, extractFindingIdsFromSnippet, } from "../finding/impact.js";
4
+ import { isFeatureEnabled, errorMessage } from "../utils.js";
5
+ import { annotateStale } from "./hooks-citations.js";
6
+ import { approximateTokens, fileRelevanceBoost, branchMatchBoost } from "../shared/retrieval.js";
7
+ import { logger } from "../logger.js";
7
8
  // ── Progressive disclosure helpers ────────────────────────────────────────────
8
9
  function buildOneLiner(snippet) {
9
10
  const lines = snippet.split("\n").map(l => l.trim()).filter(l => l.length > 0);
@@ -55,8 +56,7 @@ export function buildHookOutput(selected, usedTokens, intent, gitCtx, detectedPr
55
56
  recordRetrieval(phrenPathLocal, `${injected.doc.project}/${injected.doc.filename}`, injected.doc.type);
56
57
  }
57
58
  catch (err) {
58
- if (process.env.PHREN_DEBUG)
59
- process.stderr.write(`[phren] injectContext recordRetrieval: ${errorMessage(err)}\n`);
59
+ logger.debug("hooks-output", `injectContext recordRetrieval: ${errorMessage(err)}`);
60
60
  }
61
61
  }
62
62
  }
@@ -107,8 +107,7 @@ export function buildHookOutput(selected, usedTokens, intent, gitCtx, detectedPr
107
107
  recordRetrieval(phrenPathLocal, doc.path ?? doc.filename, doc.type);
108
108
  }
109
109
  catch (err) {
110
- if (process.env.PHREN_DEBUG)
111
- process.stderr.write(`[phren] injectContext recordRetrievalOrdered: ${errorMessage(err)}\n`);
110
+ logger.debug("hooks-output", `injectContext recordRetrievalOrdered: ${errorMessage(err)}`);
112
111
  }
113
112
  parts.push(`[${getDocSourceKey(doc, phrenPathLocal)}] (${doc.type})`);
114
113
  parts.push(annotateStale(snippet));