@phren/cli 0.0.27 → 0.0.32

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 (149) 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} +22 -21
  7. package/mcp/dist/{cli.js → cli/cli.js} +13 -13
  8. package/mcp/dist/{cli-config.js → cli/config.js} +9 -9
  9. package/mcp/dist/{cli-extract.js → cli/extract.js} +8 -8
  10. package/mcp/dist/{cli-govern.js → cli/govern.js} +10 -9
  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} +42 -57
  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} +8 -7
  21. package/mcp/dist/cli-hooks-git.js +243 -0
  22. package/mcp/dist/cli-hooks-prompt.js +319 -0
  23. package/mcp/dist/cli-hooks-session-handlers.js +349 -0
  24. package/mcp/dist/cli-hooks-stop.js +557 -0
  25. package/mcp/dist/{content-archive.js → content/archive.js} +8 -9
  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} +12 -12
  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} +131 -13
  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 +13 -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} +4 -4
  41. package/mcp/dist/{governance-audit.js → governance/audit.js} +2 -2
  42. package/mcp/dist/{governance-locks.js → governance/locks.js} +14 -9
  43. package/mcp/dist/{governance-policy.js → governance/policy.js} +10 -12
  44. package/mcp/dist/{governance-rbac.js → governance/rbac.js} +3 -3
  45. package/mcp/dist/{governance-scores.js → governance/scores.js} +8 -10
  46. package/mcp/dist/hooks.js +39 -31
  47. package/mcp/dist/index-query.js +4 -1
  48. package/mcp/dist/index.js +53 -29
  49. package/mcp/dist/{init-config.js → init/config.js} +6 -6
  50. package/mcp/dist/{init.js → init/init.js} +28 -29
  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} +3 -3
  54. package/mcp/dist/init-bootstrap.js +68 -0
  55. package/mcp/dist/init-detect.js +38 -0
  56. package/mcp/dist/init-dryrun.js +55 -0
  57. package/mcp/dist/init-env.js +114 -0
  58. package/mcp/dist/init-fresh.js +239 -0
  59. package/mcp/dist/init-hooks.js +26 -0
  60. package/mcp/dist/init-mcp.js +65 -0
  61. package/mcp/dist/init-migrate.js +51 -0
  62. package/mcp/dist/init-modes.js +135 -0
  63. package/mcp/dist/init-npm.js +37 -0
  64. package/mcp/dist/init-project-local.js +99 -0
  65. package/mcp/dist/init-semantic.js +48 -0
  66. package/mcp/dist/init-types.js +1 -0
  67. package/mcp/dist/init-uninstall.js +482 -0
  68. package/mcp/dist/init-update.js +96 -0
  69. package/mcp/dist/init-walkthrough-merge.js +90 -0
  70. package/mcp/dist/init-walkthrough.js +529 -0
  71. package/mcp/dist/{link-checksums.js → link/checksums.js} +5 -5
  72. package/mcp/dist/{link-context.js → link/context.js} +4 -4
  73. package/mcp/dist/{link-doctor.js → link/doctor.js} +20 -22
  74. package/mcp/dist/{link.js → link/link.js} +26 -31
  75. package/mcp/dist/{link-skills.js → link/skills.js} +10 -10
  76. package/mcp/dist/logger.js +11 -3
  77. package/mcp/dist/phren-art.js +0 -6
  78. package/mcp/dist/phren-paths.js +30 -12
  79. package/mcp/dist/proactivity.js +2 -2
  80. package/mcp/dist/profile-store.js +5 -6
  81. package/mcp/dist/project-config.js +2 -2
  82. package/mcp/dist/project-topics.js +1 -1
  83. package/mcp/dist/query-correlation.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} +3 -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} +15 -24
  90. package/mcp/dist/shared/governance.js +4 -0
  91. package/mcp/dist/{shared-index.js → shared/index.js} +92 -123
  92. package/mcp/dist/{shared-ollama.js → shared/ollama.js} +2 -2
  93. package/mcp/dist/{shared-retrieval.js → shared/retrieval.js} +16 -21
  94. package/mcp/dist/{shared-search-fallback.js → shared/search-fallback.js} +17 -20
  95. package/mcp/dist/{shared-sqljs.js → shared/sqljs.js} +3 -3
  96. package/mcp/dist/{shared-vector-index.js → shared/vector-index.js} +3 -3
  97. package/mcp/dist/shared.js +4 -59
  98. package/mcp/dist/{shell-entry.js → shell/entry.js} +6 -6
  99. package/mcp/dist/{shell-input.js → shell/input.js} +13 -13
  100. package/mcp/dist/{shell-palette.js → shell/palette.js} +3 -3
  101. package/mcp/dist/{shell-render.js → shell/render.js} +1 -1
  102. package/mcp/dist/{shell.js → shell/shell.js} +11 -11
  103. package/mcp/dist/{shell-state-store.js → shell/state-store.js} +5 -5
  104. package/mcp/dist/{shell-view-list.js → shell/view-list.js} +1 -1
  105. package/mcp/dist/{shell-view.js → shell/view.js} +13 -13
  106. package/mcp/dist/{skill-files.js → skill/files.js} +9 -9
  107. package/mcp/dist/{skill-registry.js → skill/registry.js} +4 -4
  108. package/mcp/dist/{skill-state.js → skill/state.js} +1 -1
  109. package/mcp/dist/startup-embedding.js +2 -2
  110. package/mcp/dist/status.js +15 -14
  111. package/mcp/dist/{tasks-github.js → task/github.js} +2 -2
  112. package/mcp/dist/{task-hygiene.js → task/hygiene.js} +4 -4
  113. package/mcp/dist/{task-lifecycle.js → task/lifecycle.js} +7 -7
  114. package/mcp/dist/telemetry.js +3 -4
  115. package/mcp/dist/tool-registry.js +29 -17
  116. package/mcp/dist/tools/config.js +515 -0
  117. package/mcp/dist/{mcp-data.js → tools/data.js} +8 -10
  118. package/mcp/dist/{mcp-extract-facts.js → tools/extract-facts.js} +6 -6
  119. package/mcp/dist/{mcp-extract.js → tools/extract.js} +6 -6
  120. package/mcp/dist/{mcp-finding.js → tools/finding.js} +97 -124
  121. package/mcp/dist/{mcp-graph.js → tools/graph.js} +11 -14
  122. package/mcp/dist/{mcp-hooks.js → tools/hooks.js} +6 -6
  123. package/mcp/dist/{mcp-memory.js → tools/memory.js} +5 -5
  124. package/mcp/dist/{mcp-ops.js → tools/ops.js} +169 -71
  125. package/mcp/dist/{mcp-search.js → tools/search.js} +19 -23
  126. package/mcp/dist/{mcp-session.js → tools/session.js} +48 -23
  127. package/mcp/dist/{mcp-skills.js → tools/skills.js} +33 -35
  128. package/mcp/dist/{mcp-tasks.js → tools/tasks.js} +155 -282
  129. package/mcp/dist/{memory-ui-data.js → ui/data.js} +31 -17
  130. package/mcp/dist/{memory-ui.js → ui/memory-ui.js} +3 -3
  131. package/mcp/dist/{memory-ui-page.js → ui/page.js} +4 -6
  132. package/mcp/dist/{memory-ui-server.js → ui/server.js} +30 -22
  133. package/mcp/dist/update.js +2 -2
  134. package/mcp/dist/utils.js +51 -11
  135. package/package.json +17 -11
  136. package/scripts/preuninstall.mjs +139 -0
  137. package/starter/global/CLAUDE.md +3 -2
  138. package/mcp/dist/mcp-config.js +0 -551
  139. package/mcp/dist/shared-governance.js +0 -4
  140. package/starter/global/skills/pipeline.md +0 -35
  141. package/starter/global/skills/release.md +0 -35
  142. /package/mcp/dist/{content-metadata.js → content/metadata.js} +0 -0
  143. /package/mcp/dist/{shared-stemmer.js → shared/stemmer.js} +0 -0
  144. /package/mcp/dist/{shell-types.js → shell/types.js} +0 -0
  145. /package/mcp/dist/{mcp-types.js → tools/types.js} +0 -0
  146. /package/mcp/dist/{memory-ui-assets.js → ui/assets.js} +0 -0
  147. /package/mcp/dist/{memory-ui-graph.js → ui/graph.js} +0 -0
  148. /package/mcp/dist/{memory-ui-scripts.js → ui/scripts.js} +0 -0
  149. /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
  }
@@ -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,12 +1,12 @@
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
11
  export function parseProjectArg(args) {
12
12
  const project = args.find((a) => a.startsWith("--project="))?.slice("--project=".length)
@@ -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
@@ -502,7 +503,7 @@ export async function handleBackgroundMaintenance(projectArg) {
502
503
  }
503
504
  catch (err) {
504
505
  if ((process.env.PHREN_DEBUG))
505
- process.stderr.write(`[phren] cli-govern backgroundMaintenance unlockFinal: ${errorMessage(err)}\n`);
506
+ logger.debug("cli-govern", `backgroundMaintenance unlockFinal: ${errorMessage(err)}`);
506
507
  }
507
508
  }
508
509
  }
@@ -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, 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));