@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.
- package/mcp/dist/capabilities/cli.js +2 -5
- package/mcp/dist/capabilities/mcp.js +5 -8
- package/mcp/dist/capabilities/types.js +2 -5
- package/mcp/dist/capabilities/vscode.js +2 -5
- package/mcp/dist/capabilities/web-ui.js +2 -5
- package/mcp/dist/{cli-actions.js → cli/actions.js} +25 -21
- package/mcp/dist/{cli.js → cli/cli.js} +13 -13
- package/mcp/dist/{cli-config.js → cli/config.js} +12 -12
- package/mcp/dist/{cli-extract.js → cli/extract.js} +8 -8
- package/mcp/dist/{cli-govern.js → cli/govern.js} +28 -17
- package/mcp/dist/{cli-graph.js → cli/graph.js} +10 -9
- package/mcp/dist/{cli-hooks-citations.js → cli/hooks-citations.js} +2 -2
- package/mcp/dist/{cli-hooks-context.js → cli/hooks-context.js} +23 -23
- package/mcp/dist/{cli-hooks-globs.js → cli/hooks-globs.js} +4 -4
- package/mcp/dist/{cli-hooks-output.js → cli/hooks-output.js} +9 -10
- package/mcp/dist/{cli-hooks-session.js → cli/hooks-session.js} +58 -117
- package/mcp/dist/{cli-hooks.js → cli/hooks.js} +27 -26
- package/mcp/dist/{cli-namespaces.js → cli/namespaces.js} +25 -24
- package/mcp/dist/{cli-ops.js → cli/ops.js} +9 -9
- package/mcp/dist/{cli-search.js → cli/search.js} +12 -11
- package/mcp/dist/cli-hooks-git.js +243 -0
- package/mcp/dist/cli-hooks-prompt.js +323 -0
- package/mcp/dist/cli-hooks-session-handlers.js +337 -0
- package/mcp/dist/cli-hooks-stop.js +519 -0
- package/mcp/dist/{content-archive.js → content/archive.js} +16 -29
- package/mcp/dist/{content-citation.js → content/citation.js} +5 -5
- package/mcp/dist/{content-dedup.js → content/dedup.js} +9 -12
- package/mcp/dist/{content-learning.js → content/learning.js} +41 -20
- package/mcp/dist/{content-validate.js → content/validate.js} +5 -5
- package/mcp/dist/{core-finding.js → core/finding.js} +4 -4
- package/mcp/dist/{core-project.js → core/project.js} +4 -4
- package/mcp/dist/{core-search.js → core/search.js} +2 -2
- package/mcp/dist/{data-access.js → data/access.js} +142 -15
- package/mcp/dist/{data-tasks.js → data/tasks.js} +7 -5
- package/mcp/dist/embedding.js +9 -14
- package/mcp/dist/entrypoint.js +11 -11
- package/mcp/dist/{finding-context.js → finding/context.js} +2 -2
- package/mcp/dist/{finding-impact.js → finding/impact.js} +3 -3
- package/mcp/dist/{finding-journal.js → finding/journal.js} +4 -4
- package/mcp/dist/{finding-lifecycle.js → finding/lifecycle.js} +13 -7
- package/mcp/dist/governance/audit.js +30 -0
- package/mcp/dist/{governance-locks.js → governance/locks.js} +14 -9
- package/mcp/dist/{governance-policy.js → governance/policy.js} +23 -12
- package/mcp/dist/{governance-rbac.js → governance/rbac.js} +4 -4
- package/mcp/dist/{governance-scores.js → governance/scores.js} +10 -11
- package/mcp/dist/hooks.js +53 -37
- package/mcp/dist/index-query.js +4 -1
- package/mcp/dist/index.js +54 -30
- package/mcp/dist/{init-config.js → init/config.js} +6 -6
- package/mcp/dist/{init.js → init/init.js} +80 -69
- package/mcp/dist/{init-preferences.js → init/preferences.js} +3 -3
- package/mcp/dist/{init-setup.js → init/setup.js} +17 -19
- package/mcp/dist/{init-shared.js → init/shared.js} +4 -4
- package/mcp/dist/init-bootstrap.js +21 -0
- package/mcp/dist/init-detect.js +38 -0
- package/mcp/dist/init-env.js +114 -0
- package/mcp/dist/init-fresh.js +234 -0
- package/mcp/dist/init-hooks.js +26 -0
- package/mcp/dist/init-mcp.js +65 -0
- package/mcp/dist/init-modes.js +135 -0
- package/mcp/dist/init-npm.js +37 -0
- package/mcp/dist/init-project-local.js +99 -0
- package/mcp/dist/init-semantic.js +48 -0
- package/mcp/dist/init-types.js +1 -0
- package/mcp/dist/init-uninstall.js +504 -0
- package/mcp/dist/init-update.js +96 -0
- package/mcp/dist/init-walkthrough.js +524 -0
- package/mcp/dist/{link-checksums.js → link/checksums.js} +5 -5
- package/mcp/dist/{link-context.js → link/context.js} +4 -4
- package/mcp/dist/{link-doctor.js → link/doctor.js} +20 -22
- package/mcp/dist/{link.js → link/link.js} +26 -31
- package/mcp/dist/{link-skills.js → link/skills.js} +10 -10
- package/mcp/dist/logger.js +11 -3
- package/mcp/dist/package-metadata.js +1 -1
- package/mcp/dist/phren-art.js +4 -126
- package/mcp/dist/phren-paths.js +30 -12
- package/mcp/dist/proactivity.js +3 -3
- package/mcp/dist/profile-store.js +5 -6
- package/mcp/dist/project-config.js +2 -2
- package/mcp/dist/project-topics.js +17 -47
- package/mcp/dist/provider-adapters.js +1 -1
- package/mcp/dist/query-correlation.js +1 -1
- package/mcp/dist/runtime-profile.js +1 -1
- package/mcp/dist/{session-checkpoints.js → session/checkpoints.js} +3 -3
- package/mcp/dist/{session-utils.js → session/utils.js} +1 -1
- package/mcp/dist/{shared-content.js → shared/content.js} +7 -7
- package/mcp/dist/{shared-data-utils.js → shared/data-utils.js} +28 -3
- package/mcp/dist/{shared-embedding-cache.js → shared/embedding-cache.js} +3 -3
- package/mcp/dist/{shared-fragment-graph.js → shared/fragment-graph.js} +19 -42
- package/mcp/dist/shared/governance.js +4 -0
- package/mcp/dist/{shared-index.js → shared/index.js} +105 -132
- package/mcp/dist/{shared-ollama.js → shared/ollama.js} +25 -7
- package/mcp/dist/shared/process.js +24 -0
- package/mcp/dist/{shared-retrieval.js → shared/retrieval.js} +22 -24
- package/mcp/dist/{shared-search-fallback.js → shared/search-fallback.js} +18 -20
- package/mcp/dist/{shared-sqljs.js → shared/sqljs.js} +3 -3
- package/mcp/dist/{shared-vector-index.js → shared/vector-index.js} +3 -3
- package/mcp/dist/shared.js +6 -60
- package/mcp/dist/{shell-entry.js → shell/entry.js} +6 -6
- package/mcp/dist/{shell-input.js → shell/input.js} +13 -13
- package/mcp/dist/{shell-palette.js → shell/palette.js} +3 -3
- package/mcp/dist/{shell-render.js → shell/render.js} +2 -2
- package/mcp/dist/{shell.js → shell/shell.js} +11 -11
- package/mcp/dist/{shell-state-store.js → shell/state-store.js} +5 -5
- package/mcp/dist/{shell-view-list.js → shell/view-list.js} +1 -1
- package/mcp/dist/{shell-view.js → shell/view.js} +13 -13
- package/mcp/dist/{skill-files.js → skill/files.js} +9 -9
- package/mcp/dist/{skill-registry.js → skill/registry.js} +5 -5
- package/mcp/dist/{skill-state.js → skill/state.js} +1 -4
- package/mcp/dist/startup-embedding.js +2 -2
- package/mcp/dist/status.js +15 -14
- package/mcp/dist/{tasks-github.js → task/github.js} +3 -2
- package/mcp/dist/{task-hygiene.js → task/hygiene.js} +4 -4
- package/mcp/dist/{task-lifecycle.js → task/lifecycle.js} +8 -13
- package/mcp/dist/telemetry.js +3 -4
- package/mcp/dist/tool-registry.js +29 -17
- package/mcp/dist/tools/config.js +530 -0
- package/mcp/dist/{mcp-data.js → tools/data.js} +8 -10
- package/mcp/dist/{mcp-extract-facts.js → tools/extract-facts.js} +6 -6
- package/mcp/dist/{mcp-extract.js → tools/extract.js} +6 -6
- package/mcp/dist/tools/finding.js +584 -0
- package/mcp/dist/{mcp-graph.js → tools/graph.js} +11 -14
- package/mcp/dist/{mcp-hooks.js → tools/hooks.js} +6 -6
- package/mcp/dist/{mcp-memory.js → tools/memory.js} +5 -5
- package/mcp/dist/tools/ops.js +468 -0
- package/mcp/dist/tools/search.js +672 -0
- package/mcp/dist/{mcp-session.js → tools/session.js} +51 -25
- package/mcp/dist/{mcp-skills.js → tools/skills.js} +42 -35
- package/mcp/dist/{mcp-tasks.js → tools/tasks.js} +155 -282
- package/mcp/dist/{memory-ui-data.js → ui/data.js} +31 -17
- package/mcp/dist/{memory-ui.js → ui/memory-ui.js} +3 -3
- package/mcp/dist/{memory-ui-page.js → ui/page.js} +5 -7
- package/mcp/dist/ui/server.js +1024 -0
- package/mcp/dist/update.js +2 -2
- package/mcp/dist/utils.js +63 -19
- package/package.json +2 -2
- package/scripts/preuninstall.mjs +31 -0
- package/starter/global/CLAUDE.md +3 -2
- package/mcp/dist/governance-audit.js +0 -22
- package/mcp/dist/mcp-config.js +0 -551
- package/mcp/dist/mcp-finding.js +0 -594
- package/mcp/dist/mcp-ops.js +0 -363
- package/mcp/dist/mcp-search.js +0 -668
- package/mcp/dist/memory-ui-server.js +0 -1411
- package/mcp/dist/shared-governance.js +0 -4
- /package/mcp/dist/{content-metadata.js → content/metadata.js} +0 -0
- /package/mcp/dist/{shared-stemmer.js → shared/stemmer.js} +0 -0
- /package/mcp/dist/{shell-types.js → shell/types.js} +0 -0
- /package/mcp/dist/{mcp-types.js → tools/types.js} +0 -0
- /package/mcp/dist/{memory-ui-assets.js → ui/assets.js} +0 -0
- /package/mcp/dist/{memory-ui-graph.js → ui/graph.js} +0 -0
- /package/mcp/dist/{memory-ui-scripts.js → ui/scripts.js} +0 -0
- /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.
|
|
36
|
-
"config.
|
|
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:
|
|
18
|
-
"task.github_link": { implemented: true, handler: "index.ts:
|
|
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.
|
|
36
|
-
"config.
|
|
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:
|
|
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.
|
|
33
|
-
"config.
|
|
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.
|
|
36
|
-
"config.
|
|
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.
|
|
36
|
-
"config.
|
|
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 "
|
|
4
|
-
import { recordFeedback, flushEntryScores, getWorkflowPolicy, } from "
|
|
5
|
-
import { upsertCanonical } from "
|
|
6
|
-
import { errorMessage, isValidProjectName } from "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
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("
|
|
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
|
-
|
|
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
|
-
|
|
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("
|
|
197
|
-
const { getEmbeddingCache, formatEmbeddingCoverage } = await import("
|
|
198
|
-
const { listIndexedDocumentPaths } = await import("
|
|
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
|
-
|
|
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 "
|
|
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 "./
|
|
4
|
-
export { scoreFindingCandidate } from "./
|
|
5
|
-
import { handleHookPrompt, handleHookSessionStart, handleHookStop, handleBackgroundSync, handleHookContext, handleHookTool, } from "./
|
|
6
|
-
import { handleExtractMemories } from "./
|
|
7
|
-
import { handleGovernMemories, handlePruneMemories, handleConsolidateMemories, handleMaintain, handleBackgroundMaintenance, } from "./
|
|
8
|
-
import { handleConfig, handleIndexPolicy, handleRetentionPolicy, handleWorkflowPolicy, } from "./
|
|
9
|
-
import { parseSearchArgs } from "./
|
|
10
|
-
import { handleDetectSkills, handleFindingNamespace, handleHooksNamespace, handleProjectsNamespace, handleSkillsNamespace, handleSkillList, handleTaskNamespace, } from "./
|
|
11
|
-
import { handleTaskView, handleSessionsView, handleQuickstart, handleDebugInjection, handleInspectIndex, } from "./
|
|
12
|
-
import { handleAddFinding, handleDoctor, handleFragmentSearch, handleMemoryUi, handlePinCanonical, handleQualityFeedback, handleRelatedDocs, handleReview, handleConsolidationStatus, handleSessionContext, handleSearch, handleShell, handleStatus, handleUpdate, } from "./
|
|
13
|
-
import { handleGraphNamespace } from "./
|
|
14
|
-
import { resolveRuntimeProfile } from "
|
|
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 "
|
|
2
|
-
import { installPreferencesFile } from "
|
|
3
|
-
import { getIndexPolicy, updateIndexPolicy, getRetentionPolicy, updateRetentionPolicy, getWorkflowPolicy, updateWorkflowPolicy, mergeConfig, VALID_TASK_MODES, VALID_FINDING_SENSITIVITY, } from "
|
|
4
|
-
import { listMachines as listMachinesStore, listProfiles as listProfilesStore, listProfiles } from "
|
|
5
|
-
import { setTelemetryEnabled, getTelemetrySummary, resetTelemetry } from "
|
|
6
|
-
import { governanceInstallPreferencesFile, readInstallPreferences, readGovernanceInstallPreferences, writeInstallPreferences, writeGovernanceInstallPreferences, } from "
|
|
7
|
-
import { PROACTIVITY_LEVELS, getProactivityLevel, getProactivityLevelForTask, getProactivityLevelForFindings, } from "
|
|
8
|
-
import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, updateProjectConfigOverrides, } from "
|
|
9
|
-
import { isValidProjectName, learnedSynonymsPath, learnSynonym, loadLearnedSynonyms, removeLearnedSynonym, } from "
|
|
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
|
+
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
|
-
|
|
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
|
-
|
|
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 "
|
|
2
|
-
import { appendReviewQueue, getRetentionPolicy, recordFeedback, flushEntryScores, entryScoreKey, } from "
|
|
3
|
-
import { detectProject } from "
|
|
4
|
-
import { commandExists } from "
|
|
5
|
-
import { runGit as runGitShared, isFeatureEnabled, clampInt, errorMessage, resolveExecCommand } from "
|
|
6
|
-
import { appendFindingJournal, compactFindingJournals } from "
|
|
7
|
-
import { getProactivityLevelForTask, getProactivityLevelForFindings, shouldAutoCaptureFindingsForLevel } from "
|
|
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 "
|
|
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 "
|
|
2
|
-
import { appendReviewQueue, getRetentionPolicy, consolidateProjectFindings, updateRuntimeHealth, pruneDeadMemories, } from "
|
|
3
|
-
import { filterTrustedFindingsDetailed, } from "
|
|
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 "./
|
|
7
|
-
import { errorMessage } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
231
|
+
async function handleGcMaintain(args = []) {
|
|
231
232
|
const dryRun = args.includes("--dry-run");
|
|
232
233
|
const phrenPath = getPhrenPath();
|
|
233
|
-
const {
|
|
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
|
-
|
|
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 =
|
|
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
|
|
298
|
-
const parentOfOldest =
|
|
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
|
-
|
|
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
|
-
|
|
516
|
+
logger.debug("cli-govern", `backgroundMaintenance unlockFinal: ${errorMessage(err)}`);
|
|
506
517
|
}
|
|
507
518
|
}
|
|
508
519
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { getPhrenPath } from "
|
|
2
|
-
import { buildIndex, queryRows } from "
|
|
3
|
-
import { resolveRuntimeProfile } from "
|
|
4
|
-
import { isValidProjectName, errorMessage } from "
|
|
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
|
-
|
|
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
|
-
|
|
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("
|
|
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("
|
|
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
|
-
|
|
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 "
|
|
2
|
-
import { capCache } from "
|
|
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 "
|
|
5
|
-
import { updateRuntimeHealth, } from "
|
|
6
|
-
import { detectProject } from "
|
|
7
|
-
import { getHooksEnabledPreference } from "
|
|
8
|
-
import { isToolHookEnabled } from "
|
|
9
|
-
import { isProjectHookEnabled } from "
|
|
10
|
-
import { resolveRuntimeProfile } from "
|
|
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 "
|
|
42
|
-
export { updateRuntimeHealth, getWorkflowPolicy, withFileLock, appendReviewQueue, recordFeedback, getQualityMultiplier, } from "
|
|
43
|
-
export { detectProject } from "
|
|
44
|
-
export { isProjectHookEnabled, readProjectConfig, getProjectSourcePath } from "
|
|
45
|
-
export { resolveRuntimeProfile } from "
|
|
46
|
-
export { detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, } from "
|
|
47
|
-
export { getProactivityLevelForTask, getProactivityLevelForFindings } from "
|
|
48
|
-
export { hasExplicitFindingSignal, shouldAutoCaptureFindingsForLevel } from "
|
|
49
|
-
export { FINDING_SENSITIVITY_CONFIG } from "./
|
|
50
|
-
export { isFeatureEnabled, errorMessage } from "
|
|
51
|
-
export { bootstrapPhrenDotEnv } from "
|
|
52
|
-
export { finalizeTaskSession } from "
|
|
53
|
-
export { appendFindingJournal } from "
|
|
54
|
-
export { getHooksEnabledPreference } from "
|
|
55
|
-
export { isToolHookEnabled } from "
|
|
56
|
-
export { runDoctor } from "
|
|
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 "
|
|
4
|
-
import { errorMessage } from "
|
|
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
|
-
|
|
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 "
|
|
2
|
-
import { getDocSourceKey, } from "
|
|
3
|
-
import { logImpact, extractFindingIdsFromSnippet, } from "
|
|
4
|
-
import { isFeatureEnabled, errorMessage } from "
|
|
5
|
-
import { annotateStale } from "./
|
|
6
|
-
import { approximateTokens, fileRelevanceBoost, branchMatchBoost } from "
|
|
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
|
-
|
|
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
|
-
|
|
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));
|