@phren/cli 0.2.15 → 0.3.0
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/README.md +2 -2
- package/dist/agent-instructions.d.ts +12 -0
- package/dist/agent-instructions.js +52 -0
- package/dist/bridge/agent-hook-stores.d.ts +32 -0
- package/dist/bridge/agent-hook-stores.js +67 -0
- package/dist/bridge/agent-hooks.d.ts +195 -2
- package/dist/bridge/agent-hooks.js +1049 -38
- package/dist/bridge/canary.d.ts +27 -0
- package/dist/bridge/canary.js +189 -0
- package/dist/bridge/changes.d.ts +57 -0
- package/dist/bridge/changes.js +403 -0
- package/dist/bridge/client.d.ts +3 -0
- package/dist/bridge/client.js +36 -0
- package/dist/bridge/code-note.d.ts +23 -0
- package/dist/bridge/code-note.js +51 -0
- package/dist/bridge/code-routes.d.ts +151 -0
- package/dist/bridge/code-routes.js +442 -0
- package/dist/bridge/codex-threads.d.ts +27 -0
- package/dist/bridge/codex-threads.js +442 -0
- package/dist/bridge/command.d.ts +7 -0
- package/dist/bridge/command.js +50 -5
- package/dist/bridge/computer-names.d.ts +4 -0
- package/dist/bridge/computer-names.js +16 -0
- package/dist/bridge/computers.d.ts +9 -0
- package/dist/bridge/computers.js +111 -0
- package/dist/bridge/context.d.ts +14 -0
- package/dist/bridge/context.js +149 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +93 -0
- package/dist/bridge/dispatch-hosts.d.ts +23 -0
- package/dist/bridge/dispatch-hosts.js +25 -0
- package/dist/bridge/dispatch-returns.d.ts +125 -0
- package/dist/bridge/dispatch-returns.js +283 -0
- package/dist/bridge/dispatch-tree.d.ts +54 -0
- package/dist/bridge/dispatch-tree.js +198 -0
- package/dist/bridge/dispatch.d.ts +210 -0
- package/dist/bridge/dispatch.js +286 -0
- package/dist/bridge/enroll.d.ts +31 -0
- package/dist/bridge/enroll.js +236 -0
- package/dist/bridge/fanout-messages.d.ts +74 -0
- package/dist/bridge/fanout-messages.js +230 -0
- package/dist/bridge/fanouts.d.ts +160 -0
- package/dist/bridge/fanouts.js +702 -0
- package/dist/bridge/file-range.d.ts +16 -0
- package/dist/bridge/file-range.js +90 -0
- package/dist/bridge/files.d.ts +20 -0
- package/dist/bridge/files.js +54 -0
- package/dist/bridge/git-publish.d.ts +23 -0
- package/dist/bridge/git-publish.js +145 -0
- package/dist/bridge/git-worktrees.d.ts +21 -0
- package/dist/bridge/git-worktrees.js +150 -0
- package/dist/bridge/git.d.ts +54 -0
- package/dist/bridge/git.js +552 -0
- package/dist/bridge/grants.d.ts +31 -0
- package/dist/bridge/grants.js +181 -0
- package/dist/bridge/hand-off.d.ts +79 -0
- package/dist/bridge/hand-off.js +151 -0
- package/dist/bridge/health.d.ts +128 -0
- package/dist/bridge/health.js +260 -0
- package/dist/bridge/herdr.d.ts +79 -6
- package/dist/bridge/herdr.js +292 -27
- package/dist/bridge/hook-main.js +2 -0
- package/dist/bridge/install.d.ts +28 -1
- package/dist/bridge/install.js +225 -38
- package/dist/bridge/launch-worktree.d.ts +21 -0
- package/dist/bridge/launch-worktree.js +70 -0
- package/dist/bridge/limits.d.ts +20 -0
- package/dist/bridge/limits.js +65 -0
- package/dist/bridge/locate.d.ts +16 -0
- package/dist/bridge/locate.js +75 -0
- package/dist/bridge/metrics.d.ts +29 -0
- package/dist/bridge/metrics.js +71 -0
- package/dist/bridge/model-switch.d.ts +35 -0
- package/dist/bridge/model-switch.js +250 -0
- package/dist/bridge/models.d.ts +46 -0
- package/dist/bridge/models.js +257 -0
- package/dist/bridge/opencode-approvals.d.ts +6 -0
- package/dist/bridge/opencode-approvals.js +60 -0
- package/dist/bridge/pane-text.d.ts +15 -0
- package/dist/bridge/pane-text.js +23 -0
- package/dist/bridge/peers.d.ts +27 -0
- package/dist/bridge/peers.js +130 -0
- package/dist/bridge/projects.d.ts +12 -1
- package/dist/bridge/projects.js +268 -20
- package/dist/bridge/protocol.d.ts +35 -2
- package/dist/bridge/protocol.js +61 -7
- package/dist/bridge/push.d.ts +83 -0
- package/dist/bridge/push.js +199 -0
- package/dist/bridge/questions.d.ts +38 -0
- package/dist/bridge/questions.js +205 -0
- package/dist/bridge/schedule-format.d.ts +103 -0
- package/dist/bridge/schedule-format.js +266 -0
- package/dist/bridge/schedule-launch.d.ts +11 -0
- package/dist/bridge/schedule-launch.js +169 -0
- package/dist/bridge/schedule-watch.d.ts +54 -0
- package/dist/bridge/schedule-watch.js +255 -0
- package/dist/bridge/schedules.d.ts +48 -0
- package/dist/bridge/schedules.js +205 -0
- package/dist/bridge/server-launch.d.ts +14 -0
- package/dist/bridge/server-launch.js +218 -0
- package/dist/bridge/server-overview.d.ts +45 -0
- package/dist/bridge/server-overview.js +102 -0
- package/dist/bridge/server-pane-routes.d.ts +36 -0
- package/dist/bridge/server-pane-routes.js +479 -0
- package/dist/bridge/server-routes.d.ts +108 -0
- package/dist/bridge/server-routes.js +556 -0
- package/dist/bridge/server-stream.d.ts +46 -0
- package/dist/bridge/server-stream.js +253 -0
- package/dist/bridge/server.d.ts +3 -15
- package/dist/bridge/server.js +162 -264
- package/dist/bridge/session-servers.d.ts +24 -0
- package/dist/bridge/session-servers.js +136 -0
- package/dist/bridge/side-questions.d.ts +74 -0
- package/dist/bridge/side-questions.js +252 -0
- package/dist/bridge/simulators.d.ts +28 -0
- package/dist/bridge/simulators.js +198 -0
- package/dist/bridge/speech-transcribe.d.ts +24 -0
- package/dist/bridge/speech-transcribe.js +124 -0
- package/dist/bridge/speech.d.ts +35 -0
- package/dist/bridge/speech.js +98 -0
- package/dist/bridge/steps.d.ts +13 -0
- package/dist/bridge/steps.js +222 -0
- package/dist/bridge/tab-activity.d.ts +18 -0
- package/dist/bridge/tab-activity.js +99 -0
- package/dist/bridge/terminal-choice.d.ts +64 -0
- package/dist/bridge/terminal-choice.js +281 -0
- package/dist/bridge/transcript-claude.d.ts +22 -0
- package/dist/bridge/transcript-claude.js +353 -0
- package/dist/bridge/transcript-codex.d.ts +30 -0
- package/dist/bridge/transcript-codex.js +282 -0
- package/dist/bridge/transcript-copilot.d.ts +4 -0
- package/dist/bridge/transcript-copilot.js +14 -0
- package/dist/bridge/transcript-opencode.d.ts +5 -0
- package/dist/bridge/transcript-opencode.js +26 -0
- package/dist/bridge/transcript-preview.d.ts +96 -0
- package/dist/bridge/transcript-preview.js +491 -0
- package/dist/bridge/transcripts.d.ts +81 -4
- package/dist/bridge/transcripts.js +332 -67
- package/dist/bridge/transport.d.ts +3 -0
- package/dist/bridge/transport.js +96 -15
- package/dist/bridge/uploads.d.ts +15 -0
- package/dist/bridge/uploads.js +44 -2
- package/dist/bridge/usage.d.ts +124 -0
- package/dist/bridge/usage.js +859 -0
- package/dist/bridge-hook.mjs +46545 -21051
- package/dist/cli/actions.js +14 -1
- package/dist/cli/config-policy.js +25 -0
- package/dist/cli/config-proactivity.d.ts +3 -1
- package/dist/cli/config-proactivity.js +35 -3
- package/dist/cli/config.js +4 -1
- package/dist/cli/extract.d.ts +0 -8
- package/dist/cli/extract.js +4 -7
- package/dist/cli/govern.js +5 -2
- package/dist/cli/hooks-globs.js +1 -1
- package/dist/cli/hooks.d.ts +1 -1
- package/dist/cli/hooks.js +9 -7
- package/dist/cli/namespaces-projects.js +12 -6
- package/dist/cli/namespaces-store.js +37 -6
- package/dist/cli/namespaces-tasks.js +1 -1
- package/dist/cli/schedules.d.ts +1 -0
- package/dist/cli/schedules.js +164 -0
- package/dist/cli/session-background.js +1 -1
- package/dist/cli/session-git.d.ts +8 -5
- package/dist/cli/session-git.js +45 -120
- package/dist/cli/session-start.js +3 -1
- package/dist/cli/session-stop.js +19 -8
- package/dist/cli/team.js +13 -10
- package/dist/cli-handlers.d.ts +1 -1
- package/dist/cli-handlers.js +8 -4
- package/dist/cli-help.d.ts +5 -4
- package/dist/cli-help.js +15 -15
- package/dist/cli-registry.d.ts +4 -1
- package/dist/cli-registry.js +119 -6
- package/dist/content/archive.js +2 -2
- package/dist/content/citation.d.ts +11 -0
- package/dist/content/citation.js +18 -0
- package/dist/content/learning.js +2 -0
- package/dist/content/summarize.d.ts +14 -15
- package/dist/content/summarize.js +60 -5
- package/dist/content/validate.d.ts +17 -4
- package/dist/content/validate.js +200 -122
- package/dist/core/project-registry.d.ts +26 -0
- package/dist/core/project-registry.js +573 -0
- package/dist/core/project.js +2 -3
- package/dist/data/access.d.ts +16 -1
- package/dist/data/access.js +31 -3
- package/dist/data/tasks.d.ts +18 -3
- package/dist/data/tasks.js +8 -7
- package/dist/entrypoint.js +44 -10
- package/dist/fanout/adapters/claude.d.ts +2 -0
- package/dist/fanout/adapters/claude.js +7 -0
- package/dist/fanout/adapters/codex.d.ts +2 -0
- package/dist/fanout/adapters/codex.js +9 -0
- package/dist/fanout/adapters/opencode.d.ts +4 -0
- package/dist/fanout/adapters/opencode.js +9 -0
- package/dist/fanout/adapters/types.d.ts +21 -0
- package/dist/fanout/adapters/types.js +3 -0
- package/dist/fanout/command.d.ts +2 -0
- package/dist/fanout/command.js +78 -0
- package/dist/fanout/launcher.d.ts +27 -0
- package/dist/fanout/launcher.js +156 -0
- package/dist/fanout/opencode-serve.d.ts +24 -0
- package/dist/fanout/opencode-serve.js +191 -0
- package/dist/fanout/picker.d.ts +91 -0
- package/dist/fanout/picker.js +51 -0
- package/dist/fanout/usage.d.ts +5 -0
- package/dist/fanout/usage.js +51 -0
- package/dist/fanout/watchdog.d.ts +10 -0
- package/dist/fanout/watchdog.js +27 -0
- package/dist/filenames.d.ts +9 -0
- package/dist/filenames.js +11 -0
- package/dist/finding/context.js +4 -22
- package/dist/generated/memory-ui-graph.browser.js +525 -419
- package/dist/governance/policy-constants.d.ts +11 -0
- package/dist/governance/policy-constants.js +9 -0
- package/dist/governance/policy.d.ts +5 -8
- package/dist/governance/policy.js +11 -8
- package/dist/graph-core/camera.d.ts +24 -0
- package/dist/graph-core/camera.js +18 -0
- package/dist/graph-core/index.d.ts +2 -0
- package/dist/graph-core/index.js +2 -0
- package/dist/graph-core/labels.d.ts +77 -0
- package/dist/graph-core/labels.js +124 -0
- package/dist/graph-core/model.d.ts +13 -0
- package/dist/graph-core/model.js +33 -0
- package/dist/graph-core/types.d.ts +2 -0
- package/dist/home-paths.d.ts +7 -0
- package/dist/home-paths.js +21 -0
- package/dist/hooks.d.ts +3 -15
- package/dist/hooks.js +14 -1
- package/dist/index.js +24 -2
- package/dist/init/guard-globals.d.ts +1 -1
- package/dist/init/guard-globals.js +4 -4
- package/dist/init/init-configure.js +3 -3
- package/dist/init/init-uninstall.js +15 -5
- package/dist/init/init-walkthrough.js +1 -1
- package/dist/init/init.js +26 -6
- package/dist/init/management-preset.d.ts +1 -1
- package/dist/init/management-preset.js +2 -2
- package/dist/init/preferences.js +1 -1
- package/dist/init/self-wiring.js +1 -1
- package/dist/init/setup.d.ts +3 -26
- package/dist/init/setup.js +68 -593
- package/dist/init/shared.js +2 -0
- package/dist/init/store-gitignore.d.ts +1 -6
- package/dist/init/store-gitignore.js +2 -8
- package/dist/init/teardown.d.ts +1 -1
- package/dist/init/teardown.js +2 -2
- package/dist/link/context-imports.d.ts +15 -0
- package/dist/link/context-imports.js +101 -0
- package/dist/link/context.js +1 -1
- package/dist/link/doctor.d.ts +22 -1
- package/dist/link/doctor.js +128 -58
- package/dist/link/link.js +29 -61
- package/dist/link/refresh.js +2 -2
- package/dist/link/skills.js +26 -5
- package/dist/machine-identity.d.ts +3 -0
- package/dist/machine-identity.js +6 -0
- package/dist/mcp/profile.d.ts +2 -19
- package/dist/mcp/profile.js +64 -22
- package/dist/memory-ui-graph.runtime.js +525 -419
- package/dist/modules/code-package.d.ts +16 -0
- package/dist/modules/code-package.js +160 -0
- package/dist/modules/command.d.ts +2 -0
- package/dist/modules/command.js +67 -0
- package/dist/modules/config.d.ts +4 -0
- package/dist/modules/config.js +70 -0
- package/dist/modules/manifest.d.ts +41 -0
- package/dist/modules/manifest.js +1 -0
- package/dist/modules/provision.d.ts +3 -0
- package/dist/modules/provision.js +84 -0
- package/dist/modules/registry.d.ts +16 -0
- package/dist/modules/registry.js +250 -0
- package/dist/modules/runtime.d.ts +15 -0
- package/dist/modules/runtime.js +59 -0
- package/dist/package-metadata.js +10 -2
- package/dist/phren-dotenv.js +4 -2
- package/dist/phren-paths.d.ts +3 -2
- package/dist/phren-paths.js +4 -5
- package/dist/profile-store.js +43 -8
- package/dist/project-config.d.ts +19 -1
- package/dist/project-config.js +29 -3
- package/dist/project-topics.d.ts +1 -0
- package/dist/project-topics.js +13 -10
- package/dist/provider-adapters.js +1 -4
- package/dist/query-correlation.js +6 -6
- package/dist/session/artifacts.js +5 -5
- package/dist/session/checkpoints.js +5 -0
- package/dist/session/utils.d.ts +2 -2
- package/dist/session/utils.js +6 -6
- package/dist/shared/content.d.ts +1 -1
- package/dist/shared/content.js +1 -1
- package/dist/shared/data-utils.js +1 -1
- package/dist/shared/fragment-graph.d.ts +1 -1
- package/dist/shared/fragment-graph.js +5 -5
- package/dist/shared/index.js +48 -7
- package/dist/shared/retrieval.d.ts +18 -3
- package/dist/shared/retrieval.js +101 -12
- package/dist/shared/search-fallback.js +4 -6
- package/dist/shared/sqljs.d.ts +2 -0
- package/dist/shared/sqljs.js +4 -2
- package/dist/shared.d.ts +0 -1
- package/dist/shared.js +0 -1
- package/dist/shell/input.d.ts +1 -5
- package/dist/shell/input.js +16 -10
- package/dist/shell/palette.d.ts +2 -2
- package/dist/shell/palette.js +3 -7
- package/dist/shell/render.d.ts +3 -1
- package/dist/shell/render.js +4 -4
- package/dist/shell/shell.js +4 -1
- package/dist/shell/types.d.ts +1 -0
- package/dist/shell/types.js +4 -0
- package/dist/shell/view.d.ts +0 -4
- package/dist/shell/view.js +19 -27
- package/dist/skill/registry.js +25 -17
- package/dist/skill/state.d.ts +3 -0
- package/dist/skill/state.js +13 -7
- package/dist/status.js +38 -17
- package/dist/store-registry.d.ts +44 -18
- package/dist/store-registry.js +169 -60
- package/dist/store-weight.d.ts +1 -6
- package/dist/store-weight.js +4 -2
- package/dist/sync/auth-doctor.d.ts +8 -0
- package/dist/sync/auth-doctor.js +27 -0
- package/dist/sync/auth.d.ts +27 -0
- package/dist/sync/auth.js +114 -0
- package/dist/sync/conflict-resolve.d.ts +9 -0
- package/dist/sync/conflict-resolve.js +146 -0
- package/dist/sync/git-state.d.ts +4 -0
- package/dist/sync/git-state.js +49 -0
- package/dist/sync/outcome.d.ts +34 -0
- package/dist/sync/outcome.js +57 -0
- package/dist/sync/pull.d.ts +15 -7
- package/dist/sync/pull.js +84 -35
- package/dist/sync/store-merge.d.ts +29 -0
- package/dist/sync/store-merge.js +137 -0
- package/dist/sync/task-merge.d.ts +22 -0
- package/dist/sync/task-merge.js +158 -0
- package/dist/task/github.js +1 -1
- package/dist/task/lifecycle.d.ts +5 -0
- package/dist/task/lifecycle.js +67 -23
- package/dist/terminal-text.d.ts +5 -0
- package/dist/terminal-text.js +11 -0
- package/dist/test-global-setup.js +7 -0
- package/dist/tool-registry.d.ts +1 -1
- package/dist/tool-registry.js +3 -1
- package/dist/tools/code.d.ts +3 -0
- package/dist/tools/code.js +186 -0
- package/dist/tools/config.js +8 -0
- package/dist/tools/data.js +14 -7
- package/dist/tools/dispatch.d.ts +2 -0
- package/dist/tools/dispatch.js +66 -0
- package/dist/tools/finding.d.ts +11 -0
- package/dist/tools/finding.js +180 -123
- package/dist/tools/ops.js +5 -2
- package/dist/tools/search.js +21 -8
- package/dist/tools/session.js +21 -22
- package/dist/tools/tasks.js +8 -2
- package/dist/tools/types.d.ts +2 -2
- package/dist/tools/types.js +2 -2
- package/dist/ui/assets.js +1 -1
- package/dist/ui/data.js +14 -15
- package/dist/ui/deep-void.d.ts +1 -1
- package/dist/ui/deep-void.js +0 -1
- package/dist/ui/graph-chrome.d.ts +1 -1
- package/dist/ui/graph-chrome.js +51 -0
- package/dist/ui/page.js +5 -5
- package/dist/ui/scripts.js +67 -30
- package/dist/ui/server.js +52 -7
- package/dist/update.js +22 -11
- package/dist/utils-fts.js +1 -0
- package/dist/utils-helpers.d.ts +7 -0
- package/dist/utils-helpers.js +17 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +49 -7
- package/plugins/opencode/phren-transcript.js +340 -0
- package/starter/README.md +4 -4
- package/starter/global/{CLAUDE.md → AGENTS.md} +2 -2
- package/starter/global/skills/conductor/SKILL.md +106 -0
- package/starter/global/skills/fanout/SKILL.md +20 -0
- package/starter/global/skills/phren-discover/SKILL.md +6 -6
- package/starter/global/skills/phren-init/SKILL.md +4 -4
- package/starter/global/skills/phren-sync/SKILL.md +3 -3
- package/starter/templates/frontend/reference/README.md +1 -1
- package/starter/templates/library/reference/README.md +1 -1
- package/starter/templates/monorepo/reference/README.md +1 -1
- package/starter/templates/python-project/reference/README.md +1 -1
- /package/starter/templates/frontend/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/library/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/monorepo/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/python-project/{CLAUDE.md → AGENTS.md} +0 -0
package/dist/tools/finding.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
1
2
|
import { mcpResponse, resolveStoreForProject } from "./types.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import * as fs from "fs";
|
|
@@ -7,9 +8,12 @@ import { isValidProjectName, errorMessage } from "../utils.js";
|
|
|
7
8
|
import { storeAwareProjectPath } from "../store-routing.js";
|
|
8
9
|
import { removeFinding as removeFindingCore, removeFindings as removeFindingsCore, applyFindingTypePrefix, } from "../core/finding.js";
|
|
9
10
|
import { debugLog, EXEC_TIMEOUT_MS, FINDING_TYPES, normalizeMemoryScope, } from "../shared.js";
|
|
10
|
-
import { getCurrentActor, getMachineName } from "../machine-identity.js";
|
|
11
|
-
import {
|
|
11
|
+
import { getCurrentActor, getMachineName, storeCommitMessage } from "../machine-identity.js";
|
|
12
|
+
import { loadCodePackage } from "../modules/code-package.js";
|
|
13
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
14
|
+
import { addFindingToFile, addFindingsToFile, checkSemanticConflicts, } from "../shared/content.js";
|
|
12
15
|
import { jaccardTokenize, jaccardSimilarity, stripMetadata, detectConflicts, extractDynamicEntities } from "../content/dedup.js";
|
|
16
|
+
import { scanForSecrets } from "../content/secrets.js";
|
|
13
17
|
import { runCustomHooks } from "../hooks.js";
|
|
14
18
|
import { incrementSessionFindings } from "./session.js";
|
|
15
19
|
import { extractFragmentNames } from "../shared/fragment-graph.js";
|
|
@@ -21,6 +25,7 @@ import { permissionDeniedError } from "../governance/rbac.js";
|
|
|
21
25
|
import { TEAM_STORE_PATHSPECS } from "../cli/session-git.js";
|
|
22
26
|
import { withFileLock } from "../governance/locks.js";
|
|
23
27
|
import { runtimeFile } from "../phren-paths.js";
|
|
28
|
+
import { mergeStoreUpstream } from "../sync/store-merge.js";
|
|
24
29
|
const JACCARD_MAYBE_LOW = 0.25;
|
|
25
30
|
const JACCARD_MAYBE_HIGH = 0.40; // above this isDuplicateFinding already catches it
|
|
26
31
|
function findJaccardCandidates(phrenPath, project, finding) {
|
|
@@ -113,7 +118,14 @@ function withLifecycleMutation(phrenPath, project, writeQueue, updateIndex, hand
|
|
|
113
118
|
}
|
|
114
119
|
// ── Handlers ─────────────────────────────────────────────────────────────────
|
|
115
120
|
async function handleAddFinding(ctx, params) {
|
|
116
|
-
const { finding,
|
|
121
|
+
const { finding, sessionId, findingType, scope } = params;
|
|
122
|
+
// `name` is the citation's code link (a function, type or variable);
|
|
123
|
+
// `symbol` is its deprecated spelling, accepted until 0.3.1. The stored
|
|
124
|
+
// citation keeps its existing key.
|
|
125
|
+
const { name: citedName, ...citationRest } = params.citation ?? {};
|
|
126
|
+
const citation = params.citation
|
|
127
|
+
? { ...citationRest, ...(citedName ?? citationRest.symbol ? { symbol: citedName ?? citationRest.symbol } : {}) }
|
|
128
|
+
: undefined;
|
|
117
129
|
// Resolve store-qualified project names (e.g., "team/arc" → store path + "arc")
|
|
118
130
|
let phrenPath;
|
|
119
131
|
let project;
|
|
@@ -137,35 +149,67 @@ async function handleAddFinding(ctx, params) {
|
|
|
137
149
|
actor: getCurrentActor(),
|
|
138
150
|
session_id: sessionId,
|
|
139
151
|
};
|
|
152
|
+
const normalizedScope = normalizeMemoryScope(scope ?? "shared");
|
|
153
|
+
if (!normalizedScope)
|
|
154
|
+
return mcpResponse({ ok: false, error: `Invalid scope: "${scope}". Use lowercase letters/numbers with '-' or '_' (max 64 chars), e.g. "researcher".` });
|
|
155
|
+
// Size caps apply to every store; they used to sit after the team branch.
|
|
156
|
+
const findingList = Array.isArray(finding) ? finding : [finding];
|
|
157
|
+
if (findingList.length > 100)
|
|
158
|
+
return mcpResponse({ ok: false, error: "Bulk add limited to 100 findings per call." });
|
|
159
|
+
if (findingList.some((f) => f.length > 5000)) {
|
|
160
|
+
return mcpResponse({
|
|
161
|
+
ok: false,
|
|
162
|
+
error: Array.isArray(finding) ? "One or more findings exceed 5000 character limit." : "Finding text exceeds 5000 character limit.",
|
|
163
|
+
});
|
|
164
|
+
}
|
|
140
165
|
// Team stores: use append-only journal (no FINDINGS.md mutation, no merge conflicts)
|
|
141
166
|
{
|
|
142
167
|
const storeResolved = resolveStoreForProject(ctx, params.project);
|
|
143
168
|
if (storeResolved.storeRole === "team") {
|
|
144
169
|
const { appendTeamJournal } = await import("../finding/journal.js");
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
// The journal is pushed to a repo shared with colleagues, so it gets the
|
|
171
|
+
// same secret scan the personal store applies.
|
|
172
|
+
const rejected = [];
|
|
173
|
+
const accepted = [];
|
|
174
|
+
for (const f of findingList) {
|
|
175
|
+
const secretType = scanForSecrets(f);
|
|
176
|
+
if (secretType)
|
|
177
|
+
rejected.push({ finding: f.slice(0, 60), reason: `Contains ${secretType}` });
|
|
178
|
+
else
|
|
179
|
+
accepted.push(applyFindingTypePrefix(f, findingType));
|
|
152
180
|
}
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
181
|
+
return withWriteQueue(async () => {
|
|
182
|
+
const added = [];
|
|
183
|
+
const journals = new Set();
|
|
184
|
+
for (const taggedFinding of accepted) {
|
|
185
|
+
const result = appendTeamJournal(phrenPath, project, taggedFinding, provenance.actor, provenance.machine);
|
|
186
|
+
if (result.ok) {
|
|
187
|
+
added.push(taggedFinding);
|
|
188
|
+
journals.add(path.join(phrenPath, project, "journal", result.data));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
rejected.push({ finding: taggedFinding.slice(0, 60), reason: result.error });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (const journalPath of journals)
|
|
195
|
+
updateFileInIndex(journalPath);
|
|
196
|
+
if (added.length === 0) {
|
|
197
|
+
return mcpResponse({
|
|
198
|
+
ok: false,
|
|
199
|
+
error: `No findings written to ${params.project} journal: ${rejected.map((r) => `"${r.finding}" ${r.reason}`).join("; ")}`,
|
|
200
|
+
data: { project: params.project, rejected, journalMode: true },
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return mcpResponse({
|
|
204
|
+
ok: true,
|
|
205
|
+
message: `Added ${added.length} finding(s) to ${params.project} journal${rejected.length > 0 ? `, ${rejected.length} rejected` : ""}`,
|
|
206
|
+
data: { project: params.project, added, journalMode: true, ...(rejected.length > 0 ? { rejected } : {}) },
|
|
207
|
+
});
|
|
157
208
|
});
|
|
158
209
|
}
|
|
159
210
|
}
|
|
160
|
-
const normalizedScope = normalizeMemoryScope(scope ?? "shared");
|
|
161
|
-
if (!normalizedScope)
|
|
162
|
-
return mcpResponse({ ok: false, error: `Invalid scope: "${scope}". Use lowercase letters/numbers with '-' or '_' (max 64 chars), e.g. "researcher".` });
|
|
163
211
|
if (Array.isArray(finding)) {
|
|
164
212
|
const findings = finding;
|
|
165
|
-
if (findings.length > 100)
|
|
166
|
-
return mcpResponse({ ok: false, error: "Bulk add limited to 100 findings per call." });
|
|
167
|
-
if (findings.some((f) => f.length > 5000))
|
|
168
|
-
return mcpResponse({ ok: false, error: "One or more findings exceed 5000 character limit." });
|
|
169
213
|
return withWriteQueue(async () => {
|
|
170
214
|
runCustomHooks(phrenPath, "pre-finding", { PHREN_PROJECT: project });
|
|
171
215
|
const allPotentialDuplicates = [];
|
|
@@ -216,18 +260,24 @@ async function handleAddFinding(ctx, params) {
|
|
|
216
260
|
});
|
|
217
261
|
});
|
|
218
262
|
}
|
|
219
|
-
if (finding.length > 5000)
|
|
220
|
-
return mcpResponse({ ok: false, error: "Finding text exceeds 5000 character limit." });
|
|
221
263
|
return withWriteQueue(async () => {
|
|
222
264
|
try {
|
|
223
265
|
const taggedFinding = applyFindingTypePrefix(finding, findingType);
|
|
266
|
+
// Memory link: link the finding to the one function, type or variable it
|
|
267
|
+
// names, or validate an explicit citation `name`. Never rewrites the
|
|
268
|
+
// finding text; only the citation comment gains the link.
|
|
269
|
+
const code = moduleEnabled(phrenPath, "code") ? await loadCodePackage(phrenPath) : undefined;
|
|
270
|
+
const symbolCitation = code ? await code.symbolCitationForFinding(phrenPath, project, taggedFinding, citation?.symbol) : citation?.symbol ? { symbol: citation.symbol } : {};
|
|
271
|
+
const citationForWrite = (citation || symbolCitation.symbol)
|
|
272
|
+
? { ...(citation ?? {}), ...symbolCitation }
|
|
273
|
+
: undefined;
|
|
224
274
|
// Jaccard "maybe zone" scan — free, no LLM call. Return candidates so the agent decides.
|
|
225
275
|
const potentialDuplicates = findJaccardCandidates(phrenPath, project, taggedFinding);
|
|
226
276
|
// Heuristic contradiction candidates — also free, also agent-decides. No extra API call.
|
|
227
277
|
const potentialConflicts = findConflictCandidates(phrenPath, project, taggedFinding);
|
|
228
278
|
const semanticConflicts = await checkSemanticConflicts(phrenPath, project, taggedFinding);
|
|
229
279
|
runCustomHooks(phrenPath, "pre-finding", { PHREN_PROJECT: project });
|
|
230
|
-
const result = addFindingToFile(phrenPath, project, taggedFinding,
|
|
280
|
+
const result = addFindingToFile(phrenPath, project, taggedFinding, citationForWrite, {
|
|
231
281
|
sessionId,
|
|
232
282
|
scope: normalizedScope,
|
|
233
283
|
extraAnnotations: semanticConflicts.checked ? semanticConflicts.annotations : undefined,
|
|
@@ -496,6 +546,87 @@ async function handleRemoveFinding(ctx, { project: projectInput, finding }) {
|
|
|
496
546
|
return mcpResponse({ ok: true, message: result.message, data: result.data });
|
|
497
547
|
});
|
|
498
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Commit and push the team-safe pathspecs of every attached team store. Team
|
|
551
|
+
* stores are independent repos, so push_changes runs this whatever happens to
|
|
552
|
+
* the primary store.
|
|
553
|
+
*/
|
|
554
|
+
export async function syncTeamStores(phrenPath) {
|
|
555
|
+
const teamResults = [];
|
|
556
|
+
try {
|
|
557
|
+
const { execFileSync } = await import("child_process");
|
|
558
|
+
const { getNonPrimaryStores } = await import("../store-registry.js");
|
|
559
|
+
const teamStores = getNonPrimaryStores(phrenPath).filter((s) => s.role === "team");
|
|
560
|
+
for (const store of teamStores) {
|
|
561
|
+
if (!fs.existsSync(store.path) || !fs.existsSync(path.join(store.path, ".git")))
|
|
562
|
+
continue;
|
|
563
|
+
const runStoreGit = (args, opts = {}) => execFileSync("git", args, {
|
|
564
|
+
cwd: store.path,
|
|
565
|
+
encoding: "utf8",
|
|
566
|
+
timeout: opts.timeout ?? EXEC_TIMEOUT_MS,
|
|
567
|
+
env: nonInteractiveGitEnv(opts.env),
|
|
568
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
569
|
+
}).trim();
|
|
570
|
+
const mergeStoreGit = async (_cwd, gitArgs) => {
|
|
571
|
+
try {
|
|
572
|
+
return { ok: true, output: runStoreGit(gitArgs) };
|
|
573
|
+
}
|
|
574
|
+
catch (err) {
|
|
575
|
+
return { ok: false, output: "", error: errorMessage(err) };
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
try {
|
|
579
|
+
if (!runStoreGit(["status", "--porcelain"]))
|
|
580
|
+
continue;
|
|
581
|
+
// Stage each team-safe pathspec individually — a single no-match
|
|
582
|
+
// (e.g. no */truths.md in this store) used to abort the whole add.
|
|
583
|
+
for (const spec of TEAM_STORE_PATHSPECS) {
|
|
584
|
+
try {
|
|
585
|
+
runStoreGit(["add", "--sparse", "--", spec]);
|
|
586
|
+
}
|
|
587
|
+
catch { /* best-effort */ }
|
|
588
|
+
}
|
|
589
|
+
if (!runStoreGit(["diff", "--cached", "--name-only"]))
|
|
590
|
+
continue;
|
|
591
|
+
const actor = process.env.PHREN_ACTOR || process.env.USER || "unknown";
|
|
592
|
+
runStoreGit(["commit", "-m", storeCommitMessage(`phren: ${actor} team sync`)]);
|
|
593
|
+
try {
|
|
594
|
+
runStoreGit(["push"], { timeout: 15000 });
|
|
595
|
+
teamResults.push({ store: store.name, pushed: true });
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
try {
|
|
599
|
+
const merged = await mergeStoreUpstream(store.path, { git: mergeStoreGit, commitLocalWrites: false });
|
|
600
|
+
if (merged.status !== "updated" && merged.status !== "unchanged")
|
|
601
|
+
throw new Error(merged.detail);
|
|
602
|
+
runStoreGit(["push"], { timeout: 15000 });
|
|
603
|
+
teamResults.push({ store: store.name, pushed: true });
|
|
604
|
+
}
|
|
605
|
+
catch (retryErr) {
|
|
606
|
+
teamResults.push({ store: store.name, pushed: false, error: errorMessage(retryErr) });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
catch (storeErr) {
|
|
611
|
+
teamResults.push({ store: store.name, pushed: false, error: errorMessage(storeErr) });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
catch (err) {
|
|
616
|
+
debugLog(`syncTeamStores: ${errorMessage(err)}`);
|
|
617
|
+
}
|
|
618
|
+
return teamResults;
|
|
619
|
+
}
|
|
620
|
+
/** Team-store outcomes appended to a push_changes message, so a failure is visible. */
|
|
621
|
+
function describeTeamSync(results) {
|
|
622
|
+
if (results.length === 0)
|
|
623
|
+
return "";
|
|
624
|
+
const pushed = results.filter((r) => r.pushed).map((r) => r.store);
|
|
625
|
+
const parts = pushed.length > 0 ? [`Pushed ${pushed.length} team store(s): ${pushed.join(", ")}.`] : [];
|
|
626
|
+
for (const failure of results.filter((r) => !r.pushed))
|
|
627
|
+
parts.push(`Team store "${failure.store}" failed: ${failure.error ?? "unknown error"}.`);
|
|
628
|
+
return ` ${parts.join(" ")}`;
|
|
629
|
+
}
|
|
499
630
|
async function handlePushChanges(ctx, { message }) {
|
|
500
631
|
const { phrenPath, withWriteQueue } = ctx;
|
|
501
632
|
return withWriteQueue(async () => withFileLock(runtimeFile(phrenPath, "git-op"), async () => {
|
|
@@ -504,13 +635,24 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
504
635
|
cwd: phrenPath,
|
|
505
636
|
encoding: "utf8",
|
|
506
637
|
timeout: opts.timeout ?? EXEC_TIMEOUT_MS,
|
|
507
|
-
env: opts.env,
|
|
638
|
+
env: nonInteractiveGitEnv(opts.env),
|
|
508
639
|
stdio: ["ignore", "pipe", "pipe"],
|
|
509
640
|
}).trim();
|
|
641
|
+
const mergeGit = async (_cwd, args) => {
|
|
642
|
+
try {
|
|
643
|
+
return { ok: true, output: runGit(args) };
|
|
644
|
+
}
|
|
645
|
+
catch (err) {
|
|
646
|
+
return { ok: false, output: "", error: errorMessage(err) };
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
const teamResults = await syncTeamStores(phrenPath);
|
|
650
|
+
const teamSuffix = describeTeamSync(teamResults);
|
|
651
|
+
const teamData = teamResults.length > 0 ? { teamStores: teamResults } : {};
|
|
510
652
|
try {
|
|
511
653
|
const status = runGit(["status", "--porcelain"]);
|
|
512
654
|
if (!status)
|
|
513
|
-
return mcpResponse({ ok: true, message:
|
|
655
|
+
return mcpResponse({ ok: true, message: `Nothing to save. Phren is up to date.${teamSuffix}`, data: { files: 0, pushed: false, ...teamData } });
|
|
514
656
|
const files = status.split("\n").filter(Boolean);
|
|
515
657
|
const projectNames = Array.from(new Set(files
|
|
516
658
|
.map((line) => line.slice(3).trim().split("/")[0])
|
|
@@ -530,7 +672,7 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
530
672
|
runGit(["reset", "HEAD", "--", ".env", "**/.env", "*.pem", "*.key", ".config/auth-profiles.json"]);
|
|
531
673
|
}
|
|
532
674
|
catch { /* best effort */ }
|
|
533
|
-
runGit(["commit", "-m", commitMsg]);
|
|
675
|
+
runGit(["commit", "-m", storeCommitMessage(commitMsg)]);
|
|
534
676
|
let hasRemote = false;
|
|
535
677
|
try {
|
|
536
678
|
const remotes = runGit(["remote"]);
|
|
@@ -541,7 +683,7 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
541
683
|
}
|
|
542
684
|
if (!hasRemote) {
|
|
543
685
|
const changedFiles = status.split("\n").filter(Boolean).length;
|
|
544
|
-
return mcpResponse({ ok: true, message: `Saved ${changedFiles} changed file(s). No remote configured, skipping push
|
|
686
|
+
return mcpResponse({ ok: true, message: `Saved ${changedFiles} changed file(s). No remote configured, skipping push.${teamSuffix}`, data: { files: changedFiles, pushed: false, ...teamData } });
|
|
545
687
|
}
|
|
546
688
|
let pushed = false;
|
|
547
689
|
let lastPushError = "";
|
|
@@ -556,39 +698,10 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
556
698
|
lastPushError = pushErr instanceof Error ? pushErr.message : String(pushErr);
|
|
557
699
|
debugLog(`Push attempt ${attempt + 1} failed: ${lastPushError}`);
|
|
558
700
|
if (attempt < 3) {
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
logger.warn("push_changes", `pullRebase: ${pullErr instanceof Error ? pullErr.message : String(pullErr)}`);
|
|
564
|
-
const resolved = autoMergeConflicts(phrenPath);
|
|
565
|
-
if (resolved) {
|
|
566
|
-
try {
|
|
567
|
-
runGit(["rebase", "--continue"], {
|
|
568
|
-
timeout: 10000,
|
|
569
|
-
env: { ...process.env, GIT_EDITOR: "true" },
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
catch (continueErr) {
|
|
573
|
-
logger.warn("push_changes", `rebaseContinue: ${continueErr instanceof Error ? continueErr.message : String(continueErr)}`);
|
|
574
|
-
try {
|
|
575
|
-
runGit(["rebase", "--abort"]);
|
|
576
|
-
}
|
|
577
|
-
catch (abortErr) {
|
|
578
|
-
logger.warn("push_changes", `rebaseAbort: ${abortErr instanceof Error ? abortErr.message : String(abortErr)}`);
|
|
579
|
-
}
|
|
580
|
-
break;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
try {
|
|
585
|
-
runGit(["rebase", "--abort"]);
|
|
586
|
-
}
|
|
587
|
-
catch (abortErr) {
|
|
588
|
-
logger.warn("push_changes", `rebaseAbort2: ${abortErr instanceof Error ? abortErr.message : String(abortErr)}`);
|
|
589
|
-
}
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
701
|
+
const merged = await mergeStoreUpstream(phrenPath, { git: mergeGit, commitLocalWrites: false });
|
|
702
|
+
if (merged.status !== "updated" && merged.status !== "unchanged") {
|
|
703
|
+
logger.warn("push_changes", `mergeRemote: ${merged.detail}`);
|
|
704
|
+
break;
|
|
592
705
|
}
|
|
593
706
|
await new Promise(r => setTimeout(r, delays[attempt]));
|
|
594
707
|
}
|
|
@@ -597,76 +710,18 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
597
710
|
const changedFiles = status.split("\n").filter(Boolean).length;
|
|
598
711
|
runCustomHooks(phrenPath, "post-save", { PHREN_FILES_CHANGED: String(changedFiles), PHREN_PUSHED: String(pushed) });
|
|
599
712
|
if (pushed) {
|
|
600
|
-
return mcpResponse({ ok: true, message: `Saved ${changedFiles} changed file(s). Pushed to remote
|
|
713
|
+
return mcpResponse({ ok: true, message: `Saved ${changedFiles} changed file(s). Pushed to remote.${teamSuffix}`, data: { files: changedFiles, pushed: true, ...teamData } });
|
|
601
714
|
}
|
|
602
715
|
else {
|
|
603
716
|
return mcpResponse({
|
|
604
717
|
ok: true,
|
|
605
|
-
message: `Changes were committed but push failed.\n\nGit error: ${lastPushError}\n\nRun 'git push' manually from your phren directory
|
|
606
|
-
data: { files: changedFiles, pushed: false, pushError: lastPushError },
|
|
718
|
+
message: `Changes were committed but push failed.\n\nGit error: ${lastPushError}\n\nRun 'git push' manually from your phren directory.${teamSuffix}`,
|
|
719
|
+
data: { files: changedFiles, pushed: false, pushError: lastPushError, ...teamData },
|
|
607
720
|
});
|
|
608
721
|
}
|
|
609
722
|
}
|
|
610
723
|
catch (err) {
|
|
611
|
-
return mcpResponse({ ok: false, error: `Save failed: ${errorMessage(err)}`, errorCode: "INTERNAL_ERROR" });
|
|
612
|
-
}
|
|
613
|
-
// Sync team stores: commit and push journal/tasks/truths changes
|
|
614
|
-
try {
|
|
615
|
-
const { getNonPrimaryStores } = await import("../store-registry.js");
|
|
616
|
-
const teamStores = getNonPrimaryStores(phrenPath).filter((s) => s.role === "team");
|
|
617
|
-
const teamResults = [];
|
|
618
|
-
for (const store of teamStores) {
|
|
619
|
-
if (!fs.existsSync(store.path) || !fs.existsSync(path.join(store.path, ".git")))
|
|
620
|
-
continue;
|
|
621
|
-
const runStoreGit = (args, opts = {}) => execFileSync("git", args, {
|
|
622
|
-
cwd: store.path,
|
|
623
|
-
encoding: "utf8",
|
|
624
|
-
timeout: opts.timeout ?? EXEC_TIMEOUT_MS,
|
|
625
|
-
env: opts.env,
|
|
626
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
627
|
-
}).trim();
|
|
628
|
-
try {
|
|
629
|
-
const storeStatus = runStoreGit(["status", "--porcelain"]);
|
|
630
|
-
if (!storeStatus) {
|
|
631
|
-
teamResults.push({ store: store.name, pushed: false });
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
// Stage each team-safe pathspec individually — a single no-match
|
|
635
|
-
// (e.g. no */truths.md in this store) used to abort the whole add.
|
|
636
|
-
for (const spec of TEAM_STORE_PATHSPECS) {
|
|
637
|
-
try {
|
|
638
|
-
runStoreGit(["add", "--sparse", "--", spec]);
|
|
639
|
-
}
|
|
640
|
-
catch { /* best-effort */ }
|
|
641
|
-
}
|
|
642
|
-
const actor = process.env.PHREN_ACTOR || process.env.USER || "unknown";
|
|
643
|
-
runStoreGit(["commit", "-m", `phren: ${actor} team sync`]);
|
|
644
|
-
try {
|
|
645
|
-
runStoreGit(["push"], { timeout: 15000 });
|
|
646
|
-
teamResults.push({ store: store.name, pushed: true });
|
|
647
|
-
}
|
|
648
|
-
catch {
|
|
649
|
-
try {
|
|
650
|
-
runStoreGit(["pull", "--rebase", "--quiet"], { timeout: 15000 });
|
|
651
|
-
runStoreGit(["push"], { timeout: 15000 });
|
|
652
|
-
teamResults.push({ store: store.name, pushed: true });
|
|
653
|
-
}
|
|
654
|
-
catch (retryErr) {
|
|
655
|
-
teamResults.push({ store: store.name, pushed: false, error: errorMessage(retryErr) });
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
catch (storeErr) {
|
|
660
|
-
teamResults.push({ store: store.name, pushed: false, error: errorMessage(storeErr) });
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
// Team store results are best-effort — don't fail the primary push for them
|
|
664
|
-
if (teamResults.length > 0) {
|
|
665
|
-
debugLog(`push_changes team stores: ${JSON.stringify(teamResults)}`);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
catch {
|
|
669
|
-
// store-registry not available — skip silently
|
|
724
|
+
return mcpResponse({ ok: false, error: `Save failed: ${errorMessage(err)}${teamSuffix}`, errorCode: "INTERNAL_ERROR" });
|
|
670
725
|
}
|
|
671
726
|
}));
|
|
672
727
|
}
|
|
@@ -687,6 +742,8 @@ export function register(server, ctx) {
|
|
|
687
742
|
line: z.number().int().positive().optional().describe("1-based line number in file."),
|
|
688
743
|
repo: z.string().optional().describe("Git repository root path for citation validation."),
|
|
689
744
|
commit: z.string().optional().describe("Git commit SHA that supports this finding."),
|
|
745
|
+
name: z.string().optional().describe("The function, type or variable this finding is about: Name, Type.member or name(). Validated against the project's code index; stored unresolved when it does not resolve."),
|
|
746
|
+
symbol: z.string().optional().describe("Deprecated: use name. Accepted until @phren/cli 0.3.1."),
|
|
690
747
|
supersedes: z.string().optional().describe("First 60 chars of the old finding this one replaces. The old entry will be marked as superseded."),
|
|
691
748
|
task_item: z.string().optional().describe("Task item stable ID like bid:abcd1234, positional ID like A1, or item text to link this finding to."),
|
|
692
749
|
}).optional().describe("Optional source citation for traceability (only used when finding is a single string)."),
|
package/dist/tools/ops.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
1
2
|
import { mcpResponse, resolveStoreForProject } from "./types.js";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import * as fs from "fs";
|
|
@@ -159,6 +160,7 @@ async function handleHealthCheck(ctx, { include_consolidation }) {
|
|
|
159
160
|
try {
|
|
160
161
|
const { execFileSync } = await import("child_process");
|
|
161
162
|
const remote = execFileSync("git", ["-C", phrenPath, "remote", "get-url", "origin"], {
|
|
163
|
+
env: nonInteractiveGitEnv(),
|
|
162
164
|
encoding: "utf8",
|
|
163
165
|
stdio: ["ignore", "pipe", "ignore"],
|
|
164
166
|
timeout: 5_000,
|
|
@@ -166,6 +168,7 @@ async function handleHealthCheck(ctx, { include_consolidation }) {
|
|
|
166
168
|
if (remote) {
|
|
167
169
|
try {
|
|
168
170
|
execFileSync("git", ["-C", phrenPath, "ls-remote", "--exit-code", "origin"], {
|
|
171
|
+
env: nonInteractiveGitEnv(),
|
|
169
172
|
stdio: ["ignore", "ignore", "ignore"],
|
|
170
173
|
timeout: 10_000,
|
|
171
174
|
});
|
|
@@ -448,14 +451,14 @@ export function register(server, ctx) {
|
|
|
448
451
|
server.registerTool("add_project", {
|
|
449
452
|
title: "◆ phren · add project",
|
|
450
453
|
description: "Bootstrap a project into phren from a repo or working directory. " +
|
|
451
|
-
"Copies or creates
|
|
454
|
+
"Copies or creates AGENTS.md/summary/tasks/findings under ~/.phren/<project> and adds the project to the active profile.",
|
|
452
455
|
inputSchema: z.object({
|
|
453
456
|
path: z.string().describe("Project path to import. Pass the current repo path explicitly."),
|
|
454
457
|
profile: z.string().optional().describe("Profile to update. Defaults to the active profile."),
|
|
455
458
|
ownership: z.enum(PROJECT_OWNERSHIP_MODES).optional()
|
|
456
459
|
.describe("How Phren should treat repo-facing instruction files: phren-managed, detached, or repo-managed."),
|
|
457
460
|
store: z.string().optional()
|
|
458
|
-
.describe("Target store name (
|
|
461
|
+
.describe("Target store name (one attached on this machine). If omitted, auto-routes to the store that claims this project, or falls back to the primary store."),
|
|
459
462
|
}),
|
|
460
463
|
}, (params) => handleAddProject(ctx, params));
|
|
461
464
|
server.registerTool("health_check", {
|
package/dist/tools/search.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
2
|
+
import { projectMemoryCounts } from "../content/summarize.js";
|
|
3
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
1
4
|
import { mcpResponse, resolveStoreForProject } from "./types.js";
|
|
2
5
|
import { z } from "zod";
|
|
3
6
|
import * as fs from "fs";
|
|
@@ -15,7 +18,7 @@ import { entryScoreKey, getQualityMultiplier, getRetentionPolicy, recordLookupEv
|
|
|
15
18
|
import { bestFindingNodeId } from "../finding-graph-id.js";
|
|
16
19
|
import { callLlm } from "../content/dedup.js";
|
|
17
20
|
import { rankResults, searchKnowledgeRows, applyTrustFilter, searchFederatedStores } from "../shared/retrieval.js";
|
|
18
|
-
import { formatActorAttribution, parseScopeComment, parseSourceComment } from "../content/citation.js";
|
|
21
|
+
import { formatActorAttribution, parseScopeComment, parseSourceComment, collectSymbolCitations } from "../content/citation.js";
|
|
19
22
|
import { resolveActiveSessionScope } from "./session.js";
|
|
20
23
|
import { logger } from "../logger.js";
|
|
21
24
|
/**
|
|
@@ -368,6 +371,7 @@ async function handleSearchKnowledge(ctx, { query, limit, project, type, tag, si
|
|
|
368
371
|
const snippet = extractSnippet(row.content, query);
|
|
369
372
|
const lifecycle = row.type === "findings" ? lifecycleByRowKey.get(findingRowKey(row)) : undefined;
|
|
370
373
|
const federationSource = "federationSource" in row ? row.federationSource : undefined;
|
|
374
|
+
const symbols = row.type === "findings" ? collectSymbolCitations(row.content) : [];
|
|
371
375
|
return {
|
|
372
376
|
project: row.project,
|
|
373
377
|
filename: row.filename,
|
|
@@ -376,6 +380,7 @@ async function handleSearchKnowledge(ctx, { query, limit, project, type, tag, si
|
|
|
376
380
|
path: row.path,
|
|
377
381
|
status: lifecycle?.primaryStatus,
|
|
378
382
|
statuses: lifecycle?.statuses,
|
|
383
|
+
...(symbols.length > 0 ? { symbol: symbols[0], symbols } : {}),
|
|
379
384
|
...(federationSource ? { federation_source: federationSource } : {}),
|
|
380
385
|
};
|
|
381
386
|
});
|
|
@@ -497,7 +502,9 @@ async function handleGetProjectSummary(ctx, { name }) {
|
|
|
497
502
|
if (store && fs.existsSync(path.join(store.path, lookupName))) {
|
|
498
503
|
const projDir = path.join(store.path, lookupName);
|
|
499
504
|
const fsDocs = [];
|
|
500
|
-
for (const [file, type] of [["summary.md", "summary"], ["
|
|
505
|
+
for (const [file, type] of [["summary.md", "summary"], ["AGENTS.md", "claude"], [FINDINGS_FILENAME, "findings"], ["tasks.md", "task"], ["truths.md", "canonical"]]) {
|
|
506
|
+
if (type === "task" && !moduleEnabled(store.path, "tasks", ctx.profile))
|
|
507
|
+
continue;
|
|
501
508
|
const filePath = path.join(projDir, file);
|
|
502
509
|
if (fs.existsSync(filePath)) {
|
|
503
510
|
fsDocs.push({ project: lookupName, filename: file, type, content: fs.readFileSync(filePath, "utf8").slice(0, 8000), path: filePath });
|
|
@@ -524,7 +531,7 @@ async function handleGetProjectSummary(ctx, { name }) {
|
|
|
524
531
|
parts.push("\n*No summary.md found for this project.*");
|
|
525
532
|
}
|
|
526
533
|
if (claudeDoc) {
|
|
527
|
-
parts.push(`\n##
|
|
534
|
+
parts.push(`\n## AGENTS.md path\n\`${claudeDoc.path}\``);
|
|
528
535
|
}
|
|
529
536
|
// Show truths if they exist
|
|
530
537
|
if (canonicalDoc) {
|
|
@@ -541,6 +548,9 @@ async function handleGetProjectSummary(ctx, { name }) {
|
|
|
541
548
|
data: {
|
|
542
549
|
name,
|
|
543
550
|
summary: summaryDoc?.content ?? null,
|
|
551
|
+
// What the project holds, counted the way every graph counts it.
|
|
552
|
+
counts: projectMemoryCounts(storeName ? (resolveAllStores(ctx.phrenPath).find((s) => s.name === storeName)?.path ?? ctx.phrenPath) : ctx.phrenPath, lookupName),
|
|
553
|
+
agentsMdPath: claudeDoc?.path ?? null,
|
|
544
554
|
claudeMdPath: claudeDoc?.path ?? null,
|
|
545
555
|
truthsPath: canonicalDoc?.path ?? null,
|
|
546
556
|
files: indexedFiles,
|
|
@@ -589,7 +599,7 @@ async function handleListProjects(ctx, { page, page_size }) {
|
|
|
589
599
|
return mcpResponse({ ok: false, error: `Page ${pageNum} out of range. Total pages: ${totalPages}.` });
|
|
590
600
|
}
|
|
591
601
|
const badgeTypes = ["claude", "findings", "summary", "task"];
|
|
592
|
-
const badgeLabels = { claude: "
|
|
602
|
+
const badgeLabels = { claude: "AGENTS.md", findings: "FINDINGS", summary: "summary", task: "task" };
|
|
593
603
|
const projectList = pageProjects.map((entry) => {
|
|
594
604
|
// Primary store projects: query the DB for badge info
|
|
595
605
|
if (!entry.store) {
|
|
@@ -611,13 +621,13 @@ async function handleListProjects(ctx, { page, page_size }) {
|
|
|
611
621
|
const projDir = store ? path.join(store.path, entry.name) : "";
|
|
612
622
|
const badges = [];
|
|
613
623
|
if (projDir) {
|
|
614
|
-
if (fs.existsSync(path.join(projDir, "
|
|
615
|
-
badges.push("
|
|
624
|
+
if (fs.existsSync(path.join(projDir, "AGENTS.md")))
|
|
625
|
+
badges.push("AGENTS.md");
|
|
616
626
|
if (fs.existsSync(path.join(projDir, FINDINGS_FILENAME)))
|
|
617
627
|
badges.push("FINDINGS");
|
|
618
628
|
if (fs.existsSync(path.join(projDir, "summary.md")))
|
|
619
629
|
badges.push("summary");
|
|
620
|
-
if (fs.existsSync(path.join(projDir, "tasks.md")))
|
|
630
|
+
if (store && moduleEnabled(store.path, "tasks", ctx.profile) && fs.existsSync(path.join(projDir, "tasks.md")))
|
|
621
631
|
badges.push("task");
|
|
622
632
|
}
|
|
623
633
|
return { name: entry.name, store: entry.store, brief: "", badges, fileCount: badges.length };
|
|
@@ -672,6 +682,7 @@ async function handleGetFindings(ctx, { project, limit, include_superseded, incl
|
|
|
672
682
|
}
|
|
673
683
|
const capped = filteredItems.slice(0, limit ?? 50).map(entry => ({
|
|
674
684
|
...entry,
|
|
685
|
+
symbol: entry.citationData?.symbol,
|
|
675
686
|
lifecycle: {
|
|
676
687
|
status: entry.status,
|
|
677
688
|
status_updated: entry.status_updated,
|
|
@@ -686,6 +697,8 @@ async function handleGetFindings(ctx, { project, limit, include_superseded, incl
|
|
|
686
697
|
metadata.push(`task=${entry.taskItem}`);
|
|
687
698
|
if (entry.scope)
|
|
688
699
|
metadata.push(`scope=${entry.scope}`);
|
|
700
|
+
if (entry.symbol)
|
|
701
|
+
metadata.push(`symbol=${entry.symbol}`);
|
|
689
702
|
if (entry.supersedes)
|
|
690
703
|
metadata.push(`supersedes="${entry.supersedes.slice(0, 30)}"`);
|
|
691
704
|
if (entry.supersededBy)
|
|
@@ -713,7 +726,7 @@ async function handleStoreList(ctx) {
|
|
|
713
726
|
// Get last sync time from git log
|
|
714
727
|
let lastSync = null;
|
|
715
728
|
try {
|
|
716
|
-
const result = execFileSync("git", ["log", "-1", "--format=%ci"], { cwd: store.path, encoding: "utf8", timeout: 3000 }).trim();
|
|
729
|
+
const result = execFileSync("git", ["log", "-1", "--format=%ci"], { env: nonInteractiveGitEnv(), cwd: store.path, encoding: "utf8", timeout: 3000 }).trim();
|
|
717
730
|
lastSync = result || null;
|
|
718
731
|
}
|
|
719
732
|
catch { /* non-critical */ }
|