@phren/cli 0.2.15 → 0.2.16
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 +193 -2
- package/dist/bridge/agent-hooks.js +1045 -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 +22 -0
- package/dist/bridge/code-note.js +42 -0
- package/dist/bridge/code-routes.d.ts +133 -0
- package/dist/bridge/code-routes.js +319 -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 +123 -0
- package/dist/bridge/dispatch-returns.js +279 -0
- package/dist/bridge/dispatch-tree.d.ts +54 -0
- package/dist/bridge/dispatch-tree.js +198 -0
- package/dist/bridge/dispatch.d.ts +207 -0
- package/dist/bridge/dispatch.js +261 -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 +32 -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 +42 -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 +52 -0
- package/dist/bridge/schedule-watch.js +242 -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 +29 -0
- package/dist/bridge/server-pane-routes.js +400 -0
- package/dist/bridge/server-routes.d.ts +106 -0
- package/dist/bridge/server-routes.js +538 -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 +94 -0
- package/dist/bridge/transcript-preview.js +476 -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 +41246 -21385
- package/dist/cli/actions.js +14 -1
- 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.js +3 -6
- 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 +3 -1
- package/dist/content/validate.js +26 -8
- 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 +7 -1
- package/dist/data/access.js +13 -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 +279 -283
- 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 +7 -5
- 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 -0
- package/dist/hooks.js +13 -0
- 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 +2 -2
- 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 +49 -588
- package/dist/init/shared.js +2 -0
- package/dist/init/store-gitignore.d.ts +1 -1
- package/dist/init/store-gitignore.js +2 -0
- package/dist/init/teardown.d.ts +1 -1
- package/dist/init/teardown.js +2 -2
- package/dist/link/context.js +1 -1
- package/dist/link/doctor.d.ts +22 -1
- package/dist/link/doctor.js +100 -54
- 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 -15
- package/dist/mcp/profile.js +64 -9
- package/dist/memory-ui-graph.runtime.js +279 -283
- package/dist/modules/code-package.d.ts +16 -0
- package/dist/modules/code-package.js +152 -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 +4 -5
- package/dist/project-config.d.ts +19 -1
- package/dist/project-config.js +29 -3
- package/dist/project-topics.js +4 -4
- 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 -1
- package/dist/shared/retrieval.js +100 -11
- 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 +178 -0
- package/dist/tools/config.js +5 -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.js +43 -41
- 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 +34 -6
- package/dist/update.js +1 -1
- 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 +45 -3
- 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,8 +8,10 @@ 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";
|
|
13
16
|
import { runCustomHooks } from "../hooks.js";
|
|
14
17
|
import { incrementSessionFindings } from "./session.js";
|
|
@@ -21,6 +24,7 @@ import { permissionDeniedError } from "../governance/rbac.js";
|
|
|
21
24
|
import { TEAM_STORE_PATHSPECS } from "../cli/session-git.js";
|
|
22
25
|
import { withFileLock } from "../governance/locks.js";
|
|
23
26
|
import { runtimeFile } from "../phren-paths.js";
|
|
27
|
+
import { mergeStoreUpstream } from "../sync/store-merge.js";
|
|
24
28
|
const JACCARD_MAYBE_LOW = 0.25;
|
|
25
29
|
const JACCARD_MAYBE_HIGH = 0.40; // above this isDuplicateFinding already catches it
|
|
26
30
|
function findJaccardCandidates(phrenPath, project, finding) {
|
|
@@ -221,13 +225,21 @@ async function handleAddFinding(ctx, params) {
|
|
|
221
225
|
return withWriteQueue(async () => {
|
|
222
226
|
try {
|
|
223
227
|
const taggedFinding = applyFindingTypePrefix(finding, findingType);
|
|
228
|
+
// Memory link: auto-attach a symbol citation when the finding names one
|
|
229
|
+
// unique symbol, or validate an explicit `symbol:` citation. Never rewrites
|
|
230
|
+
// the finding text; only the citation comment gains the symbol.
|
|
231
|
+
const code = moduleEnabled(phrenPath, "code") ? await loadCodePackage(phrenPath) : undefined;
|
|
232
|
+
const symbolCitation = code ? await code.symbolCitationForFinding(phrenPath, project, taggedFinding, citation?.symbol) : citation?.symbol ? { symbol: citation.symbol } : {};
|
|
233
|
+
const citationForWrite = (citation || symbolCitation.symbol)
|
|
234
|
+
? { ...(citation ?? {}), ...symbolCitation }
|
|
235
|
+
: undefined;
|
|
224
236
|
// Jaccard "maybe zone" scan — free, no LLM call. Return candidates so the agent decides.
|
|
225
237
|
const potentialDuplicates = findJaccardCandidates(phrenPath, project, taggedFinding);
|
|
226
238
|
// Heuristic contradiction candidates — also free, also agent-decides. No extra API call.
|
|
227
239
|
const potentialConflicts = findConflictCandidates(phrenPath, project, taggedFinding);
|
|
228
240
|
const semanticConflicts = await checkSemanticConflicts(phrenPath, project, taggedFinding);
|
|
229
241
|
runCustomHooks(phrenPath, "pre-finding", { PHREN_PROJECT: project });
|
|
230
|
-
const result = addFindingToFile(phrenPath, project, taggedFinding,
|
|
242
|
+
const result = addFindingToFile(phrenPath, project, taggedFinding, citationForWrite, {
|
|
231
243
|
sessionId,
|
|
232
244
|
scope: normalizedScope,
|
|
233
245
|
extraAnnotations: semanticConflicts.checked ? semanticConflicts.annotations : undefined,
|
|
@@ -504,9 +516,17 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
504
516
|
cwd: phrenPath,
|
|
505
517
|
encoding: "utf8",
|
|
506
518
|
timeout: opts.timeout ?? EXEC_TIMEOUT_MS,
|
|
507
|
-
env: opts.env,
|
|
519
|
+
env: nonInteractiveGitEnv(opts.env),
|
|
508
520
|
stdio: ["ignore", "pipe", "pipe"],
|
|
509
521
|
}).trim();
|
|
522
|
+
const mergeGit = async (_cwd, args) => {
|
|
523
|
+
try {
|
|
524
|
+
return { ok: true, output: runGit(args) };
|
|
525
|
+
}
|
|
526
|
+
catch (err) {
|
|
527
|
+
return { ok: false, output: "", error: errorMessage(err) };
|
|
528
|
+
}
|
|
529
|
+
};
|
|
510
530
|
try {
|
|
511
531
|
const status = runGit(["status", "--porcelain"]);
|
|
512
532
|
if (!status)
|
|
@@ -530,7 +550,7 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
530
550
|
runGit(["reset", "HEAD", "--", ".env", "**/.env", "*.pem", "*.key", ".config/auth-profiles.json"]);
|
|
531
551
|
}
|
|
532
552
|
catch { /* best effort */ }
|
|
533
|
-
runGit(["commit", "-m", commitMsg]);
|
|
553
|
+
runGit(["commit", "-m", storeCommitMessage(commitMsg)]);
|
|
534
554
|
let hasRemote = false;
|
|
535
555
|
try {
|
|
536
556
|
const remotes = runGit(["remote"]);
|
|
@@ -556,39 +576,10 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
556
576
|
lastPushError = pushErr instanceof Error ? pushErr.message : String(pushErr);
|
|
557
577
|
debugLog(`Push attempt ${attempt + 1} failed: ${lastPushError}`);
|
|
558
578
|
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
|
-
}
|
|
579
|
+
const merged = await mergeStoreUpstream(phrenPath, { git: mergeGit, commitLocalWrites: false });
|
|
580
|
+
if (merged.status !== "updated" && merged.status !== "unchanged") {
|
|
581
|
+
logger.warn("push_changes", `mergeRemote: ${merged.detail}`);
|
|
582
|
+
break;
|
|
592
583
|
}
|
|
593
584
|
await new Promise(r => setTimeout(r, delays[attempt]));
|
|
594
585
|
}
|
|
@@ -622,9 +613,17 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
622
613
|
cwd: store.path,
|
|
623
614
|
encoding: "utf8",
|
|
624
615
|
timeout: opts.timeout ?? EXEC_TIMEOUT_MS,
|
|
625
|
-
env: opts.env,
|
|
616
|
+
env: nonInteractiveGitEnv(opts.env),
|
|
626
617
|
stdio: ["ignore", "pipe", "pipe"],
|
|
627
618
|
}).trim();
|
|
619
|
+
const mergeStoreGit = async (_cwd, gitArgs) => {
|
|
620
|
+
try {
|
|
621
|
+
return { ok: true, output: runStoreGit(gitArgs) };
|
|
622
|
+
}
|
|
623
|
+
catch (err) {
|
|
624
|
+
return { ok: false, output: "", error: errorMessage(err) };
|
|
625
|
+
}
|
|
626
|
+
};
|
|
628
627
|
try {
|
|
629
628
|
const storeStatus = runStoreGit(["status", "--porcelain"]);
|
|
630
629
|
if (!storeStatus) {
|
|
@@ -640,14 +639,16 @@ async function handlePushChanges(ctx, { message }) {
|
|
|
640
639
|
catch { /* best-effort */ }
|
|
641
640
|
}
|
|
642
641
|
const actor = process.env.PHREN_ACTOR || process.env.USER || "unknown";
|
|
643
|
-
runStoreGit(["commit", "-m", `phren: ${actor} team sync`]);
|
|
642
|
+
runStoreGit(["commit", "-m", storeCommitMessage(`phren: ${actor} team sync`)]);
|
|
644
643
|
try {
|
|
645
644
|
runStoreGit(["push"], { timeout: 15000 });
|
|
646
645
|
teamResults.push({ store: store.name, pushed: true });
|
|
647
646
|
}
|
|
648
647
|
catch {
|
|
649
648
|
try {
|
|
650
|
-
|
|
649
|
+
const merged = await mergeStoreUpstream(store.path, { git: mergeStoreGit, commitLocalWrites: false });
|
|
650
|
+
if (merged.status !== "updated" && merged.status !== "unchanged")
|
|
651
|
+
throw new Error(merged.detail);
|
|
651
652
|
runStoreGit(["push"], { timeout: 15000 });
|
|
652
653
|
teamResults.push({ store: store.name, pushed: true });
|
|
653
654
|
}
|
|
@@ -687,6 +688,7 @@ export function register(server, ctx) {
|
|
|
687
688
|
line: z.number().int().positive().optional().describe("1-based line number in file."),
|
|
688
689
|
repo: z.string().optional().describe("Git repository root path for citation validation."),
|
|
689
690
|
commit: z.string().optional().describe("Git commit SHA that supports this finding."),
|
|
691
|
+
symbol: z.string().optional().describe("A code symbol this finding is about: Name, Type.member or name(). Validated against the project's code index; stored unresolved when it does not resolve."),
|
|
690
692
|
supersedes: z.string().optional().describe("First 60 chars of the old finding this one replaces. The old entry will be marked as superseded."),
|
|
691
693
|
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
694
|
}).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 */ }
|
package/dist/tools/session.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
2
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
1
3
|
import { mcpResponse, resolveStoreForProject } from "./types.js";
|
|
2
4
|
import { z } from "zod";
|
|
3
5
|
import * as fs from "fs";
|
|
@@ -14,15 +16,15 @@ import { readTasks } from "../data/tasks.js";
|
|
|
14
16
|
import { readFindings, FINDINGS_FILENAME } from "../data/access.js";
|
|
15
17
|
import { getActiveTaskForSession } from "../task/lifecycle.js";
|
|
16
18
|
import { listTaskCheckpoints, writeTaskCheckpoint } from "../session/checkpoints.js";
|
|
17
|
-
import { findMostRecentSummaryWithProject as findMostRecentSummaryRecord, writeLastSummary
|
|
19
|
+
import { findMostRecentSummaryWithProject as findMostRecentSummaryRecord, writeLastSummary, } from "../session/artifacts.js";
|
|
18
20
|
import { markImpactEntriesCompletedForSession } from "../finding/impact.js";
|
|
19
|
-
import { debugError, scanSessionFiles,
|
|
21
|
+
import { debugError, scanSessionFiles, runtimeSessionsDir, sessionFileForId, readSessionStateFile, writeSessionStateFile, } from "../session/utils.js";
|
|
20
22
|
import { getRuntimeHealth } from "../governance/policy.js";
|
|
21
23
|
import { getProjectSourcePath, readProjectConfig } from "../project-config.js";
|
|
22
24
|
const STALE_SESSION_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
23
25
|
function collectGitStatusSnapshot(cwd) {
|
|
24
26
|
try {
|
|
25
|
-
const output = execFileSync("git", ["status", "--short"], { cwd, encoding: "utf8" }).trim();
|
|
27
|
+
const output = execFileSync("git", ["status", "--short"], { env: nonInteractiveGitEnv(), cwd, encoding: "utf8" }).trim();
|
|
26
28
|
if (!output)
|
|
27
29
|
return { gitStatus: "", editedFiles: [] };
|
|
28
30
|
const lines = output.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
@@ -96,7 +98,7 @@ const MAX_SESSION_MAP_ENTRIES = 200;
|
|
|
96
98
|
const _sessionMap = new Map();
|
|
97
99
|
/** Find the most recent *active* (not ended) session file by mtime. */
|
|
98
100
|
function findMostRecentSession(phrenPath) {
|
|
99
|
-
const dir =
|
|
101
|
+
const dir = runtimeSessionsDir(phrenPath);
|
|
100
102
|
const results = scanSessionFiles(dir, readSessionStateFile, (state) => !state.endedAt, { errorScope: "findMostRecentSession" });
|
|
101
103
|
if (results.length === 0)
|
|
102
104
|
return null;
|
|
@@ -108,7 +110,7 @@ export function resolveActiveSessionScope(phrenPath, project) {
|
|
|
108
110
|
const envScope = normalizeMemoryScope(process.env.PHREN_SCOPE);
|
|
109
111
|
if (envScope)
|
|
110
112
|
return envScope;
|
|
111
|
-
const dir =
|
|
113
|
+
const dir = runtimeSessionsDir(phrenPath);
|
|
112
114
|
const results = scanSessionFiles(dir, readSessionStateFile, (state) => {
|
|
113
115
|
if (state.endedAt)
|
|
114
116
|
return false;
|
|
@@ -128,10 +130,6 @@ export function resolveActiveSessionScope(phrenPath, project) {
|
|
|
128
130
|
}
|
|
129
131
|
return normalizeMemoryScope(bestState?.agentScope);
|
|
130
132
|
}
|
|
131
|
-
/** Write the last summary for fast retrieval by next session_start. */
|
|
132
|
-
function writeLastSummary(phrenPath, summary, sessionId, project) {
|
|
133
|
-
writeLastSummaryRecord(phrenPath, { summary, sessionId, project, endedAt: new Date().toISOString() });
|
|
134
|
-
}
|
|
135
133
|
/** Find the most recent session with a summary (including ended sessions).
|
|
136
134
|
* @internal Exported for tests. */
|
|
137
135
|
export function findMostRecentSummary(phrenPath) {
|
|
@@ -163,7 +161,7 @@ function resolveSessionFile(phrenPath, sessionId, connectionId) {
|
|
|
163
161
|
}
|
|
164
162
|
/** Remove session files older than 24 hours. */
|
|
165
163
|
function cleanupStaleSessions(phrenPath) {
|
|
166
|
-
const dir =
|
|
164
|
+
const dir = runtimeSessionsDir(phrenPath);
|
|
167
165
|
// Scan all session files (keep all, we'll filter and unlink manually)
|
|
168
166
|
const results = scanSessionFiles(dir, (filePath) => readSessionStateFile(filePath) ?? null, () => true, // accept everything — we decide inside the loop
|
|
169
167
|
{ includeMtime: false, errorScope: "cleanupStaleSessions" });
|
|
@@ -230,7 +228,7 @@ function incrementSessionCounter(phrenPath, field, count = 1, sessionId, project
|
|
|
230
228
|
}
|
|
231
229
|
/** List all sessions (both active and ended) from the sessions directory, sorted newest first. */
|
|
232
230
|
export function listAllSessions(phrenPath, limit = 50) {
|
|
233
|
-
const dir =
|
|
231
|
+
const dir = runtimeSessionsDir(phrenPath);
|
|
234
232
|
// scanSessionFiles returns results sorted by mtime (newest first)
|
|
235
233
|
const results = scanSessionFiles(dir, readSessionStateFile, () => true, { errorScope: "listAllSessions" });
|
|
236
234
|
const entries = [];
|
|
@@ -357,6 +355,7 @@ function computeSessionDiff(phrenPath, project, lastSessionEnd) {
|
|
|
357
355
|
}
|
|
358
356
|
export function register(server, ctx) {
|
|
359
357
|
const { phrenPath } = ctx;
|
|
358
|
+
const tasksEnabled = moduleEnabled(phrenPath, "tasks", ctx.profile);
|
|
360
359
|
server.registerTool("session_start", {
|
|
361
360
|
title: "◆ phren · session start",
|
|
362
361
|
description: "Mark the start of a new session and retrieve context from prior sessions. Call this at the start of a conversation when not using hooks. Returns prior session summary and recent project findings. The returned sessionId should be passed to session_end and session_context to avoid cross-client collisions.",
|
|
@@ -565,7 +564,7 @@ export function register(server, ctx) {
|
|
|
565
564
|
// session_start can restore project context even after a normal session_end.
|
|
566
565
|
const effectiveSummary = endedState.summary;
|
|
567
566
|
if (effectiveSummary) {
|
|
568
|
-
writeLastSummary(phrenPath, effectiveSummary, state.sessionId, endedState.project);
|
|
567
|
+
writeLastSummary(phrenPath, { summary: effectiveSummary, sessionId: state.sessionId, project: endedState.project });
|
|
569
568
|
}
|
|
570
569
|
if (endedState.project && isValidProjectName(endedState.project)) {
|
|
571
570
|
const projectStorePath = (() => {
|
|
@@ -579,7 +578,7 @@ export function register(server, ctx) {
|
|
|
579
578
|
}
|
|
580
579
|
})();
|
|
581
580
|
try {
|
|
582
|
-
const trackedActiveTask = getActiveTaskForSession(projectStorePath, state.sessionId, endedState.project);
|
|
581
|
+
const trackedActiveTask = moduleEnabled(projectStorePath, "tasks", ctx.profile) ? getActiveTaskForSession(projectStorePath, state.sessionId, endedState.project) : null;
|
|
583
582
|
const activeTask = trackedActiveTask ?? (() => {
|
|
584
583
|
const tasks = readTasks(projectStorePath, endedState.project);
|
|
585
584
|
if (!tasks.ok)
|
|
@@ -591,7 +590,7 @@ export function register(server, ctx) {
|
|
|
591
590
|
const projectConfig = readProjectConfig(projectStorePath, endedState.project);
|
|
592
591
|
const snapshotRoot = getProjectSourcePath(projectStorePath, endedState.project, projectConfig) ||
|
|
593
592
|
path.join(projectStorePath, endedState.project);
|
|
594
|
-
const { gitStatus, editedFiles } = collectGitStatusSnapshot(snapshotRoot);
|
|
593
|
+
const { gitStatus, editedFiles } = moduleEnabled(projectStorePath, "git", ctx.profile) ? collectGitStatusSnapshot(snapshotRoot) : { gitStatus: "", editedFiles: [] };
|
|
595
594
|
const resumptionHint = extractResumptionHint(effectiveSummary, activeTask.line, activeTask.context || "No prior attempt captured");
|
|
596
595
|
writeTaskCheckpoint(phrenPath, {
|
|
597
596
|
project: endedState.project,
|
|
@@ -626,17 +625,17 @@ export function register(server, ctx) {
|
|
|
626
625
|
PHREN_SESSION_ID: state.sessionId,
|
|
627
626
|
PHREN_DURATION_MINS: String(durationMins),
|
|
628
627
|
PHREN_FINDINGS_ADDED: String(endedState.findingsAdded),
|
|
629
|
-
PHREN_TASKS_COMPLETED: String(Number.isFinite(endedState.tasksCompleted) ? endedState.tasksCompleted : 0),
|
|
628
|
+
...(tasksEnabled ? { PHREN_TASKS_COMPLETED: String(Number.isFinite(endedState.tasksCompleted) ? endedState.tasksCompleted : 0) } : {}),
|
|
630
629
|
...(endedState.project ? { PHREN_PROJECT: endedState.project } : {}),
|
|
631
630
|
});
|
|
632
631
|
return mcpResponse({
|
|
633
632
|
ok: true,
|
|
634
|
-
message: `Session ended. Duration: ~${durationMins} min. ${endedState.findingsAdded} finding(s) added
|
|
633
|
+
message: `Session ended. Duration: ~${durationMins} min. ${endedState.findingsAdded} finding(s) added${tasksEnabled ? `, ${Number.isFinite(endedState.tasksCompleted) ? endedState.tasksCompleted : 0} task(s) completed` : ""}.${summary ? " Summary saved for next session." : ""}`,
|
|
635
634
|
data: {
|
|
636
635
|
sessionId: state.sessionId,
|
|
637
636
|
durationMins,
|
|
638
637
|
findingsAdded: endedState.findingsAdded,
|
|
639
|
-
tasksCompleted: Number.isFinite(endedState.tasksCompleted) ? endedState.tasksCompleted : 0,
|
|
638
|
+
...(tasksEnabled ? { tasksCompleted: Number.isFinite(endedState.tasksCompleted) ? endedState.tasksCompleted : 0 } : {}),
|
|
640
639
|
},
|
|
641
640
|
});
|
|
642
641
|
});
|
|
@@ -664,7 +663,7 @@ export function register(server, ctx) {
|
|
|
664
663
|
`Started: ${state.startedAt}`,
|
|
665
664
|
`Duration: ~${durationMins} min`,
|
|
666
665
|
`Findings added: ${state.findingsAdded}`,
|
|
667
|
-
`Tasks completed: ${Number.isFinite(state.tasksCompleted) ? state.tasksCompleted : 0}
|
|
666
|
+
...(tasksEnabled ? [`Tasks completed: ${Number.isFinite(state.tasksCompleted) ? state.tasksCompleted : 0}`] : []),
|
|
668
667
|
];
|
|
669
668
|
if (state.summary)
|
|
670
669
|
parts.push(`Prior summary: ${state.summary}`);
|
|
@@ -672,10 +671,10 @@ export function register(server, ctx) {
|
|
|
672
671
|
});
|
|
673
672
|
server.registerTool("session_history", {
|
|
674
673
|
title: "◆ phren · session history",
|
|
675
|
-
description: "List past sessions with their duration, findings count, and summary. Optionally drill into a specific session to see all
|
|
674
|
+
description: "List past sessions with their duration, findings count, and summary. Optionally drill into a specific session to see all artifacts created during it.",
|
|
676
675
|
inputSchema: z.object({
|
|
677
676
|
limit: z.number().optional().describe("Max sessions to return (default 20)."),
|
|
678
|
-
sessionId: z.string().optional().describe("If provided, return full artifacts
|
|
677
|
+
sessionId: z.string().optional().describe("If provided, return full session artifacts for this session instead of listing all sessions."),
|
|
679
678
|
project: z.string().optional().describe("Filter sessions and artifacts by project."),
|
|
680
679
|
}),
|
|
681
680
|
}, async ({ limit, sessionId: targetSessionId, project }) => {
|
|
@@ -693,7 +692,7 @@ export function register(server, ctx) {
|
|
|
693
692
|
`Status: ${session.status}`,
|
|
694
693
|
`Duration: ~${session.durationMins ?? 0} min`,
|
|
695
694
|
`Findings: ${artifacts.findings.length}`,
|
|
696
|
-
`Tasks: ${artifacts.tasks.length}
|
|
695
|
+
...(tasksEnabled ? [`Tasks: ${artifacts.tasks.length}`] : []),
|
|
697
696
|
];
|
|
698
697
|
if (session.summary)
|
|
699
698
|
parts.push(`\nSummary: ${session.summary}`);
|
|
@@ -722,7 +721,7 @@ export function register(server, ctx) {
|
|
|
722
721
|
const dur = s.durationMins != null ? `${s.durationMins}m` : "?";
|
|
723
722
|
const status = s.status === "active" ? " ●" : "";
|
|
724
723
|
const findings = s.findingsAdded > 0 ? ` ${s.findingsAdded}f` : "";
|
|
725
|
-
const tasks = s.tasksCompleted > 0 ? ` ${s.tasksCompleted}t` : "";
|
|
724
|
+
const tasks = tasksEnabled && s.tasksCompleted > 0 ? ` ${s.tasksCompleted}t` : "";
|
|
726
725
|
const date = s.startedAt.slice(0, 16).replace("T", " ");
|
|
727
726
|
return `${id}${status} ${date} ${dur}${findings}${tasks} ${proj}${s.summary ? " " + s.summary.slice(0, 60) : ""}`;
|
|
728
727
|
});
|
package/dist/tools/tasks.js
CHANGED
|
@@ -370,9 +370,15 @@ export function register(server, ctx) {
|
|
|
370
370
|
promote: z.boolean().optional().describe("If true, clear the speculative flag on this task (confirm the user wants it)."),
|
|
371
371
|
move_to_active: z.boolean().optional().describe("Used with promote: also move the task to the Active section."),
|
|
372
372
|
work_next: z.boolean().optional().describe("If true, pick the highest-priority Queue item and move it to Active. Ignores item param."),
|
|
373
|
+
item: z.unknown().optional().describe("Not read here: item is a top-level parameter beside updates."),
|
|
373
374
|
}).describe("Fields to update. All are optional."),
|
|
374
375
|
}),
|
|
375
|
-
}, async ({ project: projectInput, item, updates }) => {
|
|
376
|
+
}, async ({ project: projectInput, item, updates: given }) => {
|
|
377
|
+
// A caller that nests item inside updates would otherwise hear only that item is missing.
|
|
378
|
+
const { item: misplacedItem, ...updates } = given;
|
|
379
|
+
if (misplacedItem !== undefined) {
|
|
380
|
+
return mcpResponse({ ok: false, error: "item is a top-level parameter, not a field of updates. Pass it beside updates: { project, item, updates }." });
|
|
381
|
+
}
|
|
376
382
|
const resolved = resolveStoreForProject(ctx, projectInput);
|
|
377
383
|
const project = resolved.project;
|
|
378
384
|
const targetPath = resolved.phrenPath;
|
|
@@ -453,7 +459,7 @@ export function register(server, ctx) {
|
|
|
453
459
|
if (!repo) {
|
|
454
460
|
return mcpResponse({
|
|
455
461
|
ok: false,
|
|
456
|
-
error: "Could not infer a GitHub repo. Add a GitHub URL to
|
|
462
|
+
error: "Could not infer a GitHub repo. Add a GitHub URL to AGENTS.md or summary.md, or link an existing issue instead.",
|
|
457
463
|
});
|
|
458
464
|
}
|
|
459
465
|
const created = createGithubIssueForTask({
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -28,8 +28,8 @@ export interface McpContext {
|
|
|
28
28
|
*/
|
|
29
29
|
export type StoreAccessMode = "read" | "write";
|
|
30
30
|
/**
|
|
31
|
-
* Error raised when a project is claimed by a store that is
|
|
32
|
-
*
|
|
31
|
+
* Error raised when a project is claimed by a store that is attached on this
|
|
32
|
+
* machine but whose directory is missing. Distinct class so callers
|
|
33
33
|
* can special-case it if they ever want to offer an interactive fix.
|
|
34
34
|
*/
|
|
35
35
|
export declare class StoreUnavailableError extends Error {
|
package/dist/tools/types.js
CHANGED
|
@@ -2,8 +2,8 @@ import { parseStoreQualified } from "../store-routing.js";
|
|
|
2
2
|
import { describeUnavailableStore, resolveAllStores } from "../store-registry.js";
|
|
3
3
|
import { logger } from "../logger.js";
|
|
4
4
|
/**
|
|
5
|
-
* Error raised when a project is claimed by a store that is
|
|
6
|
-
*
|
|
5
|
+
* Error raised when a project is claimed by a store that is attached on this
|
|
6
|
+
* machine but whose directory is missing. Distinct class so callers
|
|
7
7
|
* can special-case it if they ever want to offer an interactive fix.
|
|
8
8
|
*/
|
|
9
9
|
export class StoreUnavailableError extends Error {
|