@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { resolveStoreForProject } from "./types.js";
|
|
3
|
+
import { loadCodePackage, CODE_PACKAGE_HINT } from "../modules/code-package.js";
|
|
4
|
+
/**
|
|
5
|
+
* Read tools over the `code` module's local code index (stage 2).
|
|
6
|
+
*
|
|
7
|
+
* These answer questions about functions, types and variables from the project's own index instead of a grep
|
|
8
|
+
* sweep: a definition, the references grouped by file, a file's outline, a
|
|
9
|
+
* ranked search and the most and least used functions and types. Every tool lives in the
|
|
10
|
+
* `code` module, so it is absent until the module is enabled and the project is
|
|
11
|
+
* indexed; the result is compact text, one line per hit, not a JSON dump.
|
|
12
|
+
*/
|
|
13
|
+
function text(value) {
|
|
14
|
+
return { content: [{ type: "text", text: value }] };
|
|
15
|
+
}
|
|
16
|
+
function noIndex(project) {
|
|
17
|
+
return `No code index for "${project}". Build one with: phren code index ${project}`;
|
|
18
|
+
}
|
|
19
|
+
function resolveTarget(ctx, projectInput) {
|
|
20
|
+
try {
|
|
21
|
+
const { phrenPath, project } = resolveStoreForProject(ctx, projectInput, "read");
|
|
22
|
+
return { store: phrenPath, project };
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return { error: err instanceof Error ? err.message : String(err) };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function compactLines(textValue) {
|
|
29
|
+
return textValue.split("\n").filter(line => line.trim().length > 0).join("\n");
|
|
30
|
+
}
|
|
31
|
+
function outlineLines(entries, depth = 0) {
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
const signature = entry.signature ? ` ${entry.signature}` : "";
|
|
35
|
+
const doc = entry.doc ? ` | ${entry.doc.split("\n")[0]}` : "";
|
|
36
|
+
out.push(`${" ".repeat(depth)}${entry.line} ${entry.kind} ${entry.name}${signature}${doc}`);
|
|
37
|
+
out.push(...outlineLines(entry.children, depth + 1));
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function usageLine(entry) {
|
|
42
|
+
return `${entry.file}:${entry.line} ${entry.kind} ${entry.name} ${entry.uses}`;
|
|
43
|
+
}
|
|
44
|
+
export function register(server, ctx) {
|
|
45
|
+
server.registerTool("code_search", {
|
|
46
|
+
title: "◆ phren · code search",
|
|
47
|
+
description: "Find functions, methods, types (classes, structs, enums, interfaces) and variables in a project's code index by name, signature or doc text. Use this instead of grep when you want a declaration rather than raw text: results are ranked exact name, then prefix, then full-text relevance, then how often it is used, and each hit carries its kind, signature, doc and path:line. Pass `kind` to narrow to function, method, class, struct, enum, interface, type or variable.",
|
|
48
|
+
inputSchema: z.object({
|
|
49
|
+
project: z.string().describe("Project name, optionally store-qualified."),
|
|
50
|
+
query: z.string().describe("A name, or words from its signature or doc comment."),
|
|
51
|
+
kind: z.enum(["function", "method", "class", "struct", "enum", "interface", "type", "variable"]).optional().describe("Only this kind."),
|
|
52
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum hits. Defaults to 20."),
|
|
53
|
+
}),
|
|
54
|
+
}, async ({ project: projectInput, query, kind, limit }) => {
|
|
55
|
+
const code = await loadCodePackage(ctx.phrenPath);
|
|
56
|
+
if (!code)
|
|
57
|
+
return text(CODE_PACKAGE_HINT);
|
|
58
|
+
const { search, formatSymbolLine } = code;
|
|
59
|
+
const target = resolveTarget(ctx, projectInput);
|
|
60
|
+
if ("error" in target)
|
|
61
|
+
return text(target.error);
|
|
62
|
+
const result = await search(target.store, target.project, query, kind, limit ?? 20);
|
|
63
|
+
if (!result.available)
|
|
64
|
+
return text(noIndex(target.project));
|
|
65
|
+
if (result.value.length === 0)
|
|
66
|
+
return text(`Nothing named or described "${query}" in ${target.project}.`);
|
|
67
|
+
return text(`${target.project}: ${result.value.length} match(es) for "${query}"\n${result.value.map(formatSymbolLine).join("\n")}`);
|
|
68
|
+
});
|
|
69
|
+
server.registerTool("code_definition", {
|
|
70
|
+
title: "◆ phren · code definition",
|
|
71
|
+
description: "Go to where a function, method, type or variable is defined, from a project's code index. Use this instead of grep: it accepts `Foo`, `Foo.bar` and `bar()` forms and returns the file and lines, signature, doc comment, the last change (a blame hash and date, never a name), a short source snippet and any Phren findings linked to it. When a common name matches several declarations it prefers an exported, non-variable one and reports how many candidates there were.",
|
|
72
|
+
inputSchema: z.object({
|
|
73
|
+
project: z.string().describe("Project name, optionally store-qualified."),
|
|
74
|
+
name: z.string().optional().describe("What to look up: Foo, Foo.bar or bar()."),
|
|
75
|
+
symbol: z.string().optional().describe("Deprecated: use name. Accepted until @phren/cli 0.3.1."),
|
|
76
|
+
}),
|
|
77
|
+
}, async ({ project: projectInput, name: nameInput, symbol: legacyName }) => {
|
|
78
|
+
const symbol = nameInput ?? legacyName;
|
|
79
|
+
if (!symbol)
|
|
80
|
+
return text("Pass name: the function, type or variable to look up.");
|
|
81
|
+
const code = await loadCodePackage(ctx.phrenPath);
|
|
82
|
+
if (!code)
|
|
83
|
+
return text(CODE_PACKAGE_HINT);
|
|
84
|
+
const { definition, findingsCitingSymbol, formatCitingFinding } = code;
|
|
85
|
+
const target = resolveTarget(ctx, projectInput);
|
|
86
|
+
if ("error" in target)
|
|
87
|
+
return text(target.error);
|
|
88
|
+
const result = await definition(target.store, target.project, symbol);
|
|
89
|
+
if (!result.available)
|
|
90
|
+
return text(noIndex(target.project));
|
|
91
|
+
if (!result.value)
|
|
92
|
+
return text(`Nothing named "${symbol}" in ${target.project}.`);
|
|
93
|
+
const { symbol: hit, candidates, snippet, blame } = result.value;
|
|
94
|
+
const lines = [
|
|
95
|
+
`${hit.file}:${hit.line}-${hit.endLine} ${hit.kind} ${hit.name}${hit.exported ? " (exported)" : ""}`,
|
|
96
|
+
hit.signature,
|
|
97
|
+
hit.doc,
|
|
98
|
+
candidates > 1 ? `${candidates} candidates shared this name; showing the best.` : "",
|
|
99
|
+
blame ? `last change ${blame.at} ${blame.authorHash.slice(0, 12)}` : "",
|
|
100
|
+
];
|
|
101
|
+
const citing = findingsCitingSymbol(target.store, target.project, symbol);
|
|
102
|
+
const findingsBlock = citing.length > 0 ? ["Findings", ...citing.map(formatCitingFinding)] : [];
|
|
103
|
+
return text(compactLines([...lines, snippet, ...findingsBlock].filter(Boolean).join("\n")));
|
|
104
|
+
});
|
|
105
|
+
server.registerTool("code_references", {
|
|
106
|
+
title: "◆ phren · code references",
|
|
107
|
+
description: "Find every place a function, method, type or variable is used, from a project's code index, grouped by file. Use this instead of grep to answer who calls or uses it: it accepts `Foo`, `Foo.bar` and `bar()` forms and counts only uses the index could resolve to exactly one definition. Common-name ambiguity is reported as a candidate count.",
|
|
108
|
+
inputSchema: z.object({
|
|
109
|
+
project: z.string().describe("Project name, optionally store-qualified."),
|
|
110
|
+
name: z.string().optional().describe("What to look up: Foo, Foo.bar or bar()."),
|
|
111
|
+
symbol: z.string().optional().describe("Deprecated: use name. Accepted until @phren/cli 0.3.1."),
|
|
112
|
+
limit: z.number().int().min(1).max(500).optional().describe("Maximum reference lines. Defaults to 200."),
|
|
113
|
+
}),
|
|
114
|
+
}, async ({ project: projectInput, name: nameInput, symbol: legacyName, limit }) => {
|
|
115
|
+
const symbol = nameInput ?? legacyName;
|
|
116
|
+
if (!symbol)
|
|
117
|
+
return text("Pass name: the function, type or variable to look up.");
|
|
118
|
+
const code = await loadCodePackage(ctx.phrenPath);
|
|
119
|
+
if (!code)
|
|
120
|
+
return text(CODE_PACKAGE_HINT);
|
|
121
|
+
const { references } = code;
|
|
122
|
+
const target = resolveTarget(ctx, projectInput);
|
|
123
|
+
if ("error" in target)
|
|
124
|
+
return text(target.error);
|
|
125
|
+
const result = await references(target.store, target.project, symbol, limit ?? 200);
|
|
126
|
+
if (!result.available)
|
|
127
|
+
return text(noIndex(target.project));
|
|
128
|
+
if (!result.value)
|
|
129
|
+
return text(`Nothing named "${symbol}" in ${target.project}.`);
|
|
130
|
+
const { symbol: hit, candidates, groups, total } = result.value;
|
|
131
|
+
const header = `references for ${hit.name} (${hit.file}:${hit.line} ${hit.kind}), ${total} in ${groups.length} file(s)`;
|
|
132
|
+
const note = candidates > 1 ? `\n${candidates} candidates shared this name; showing the best.` : "";
|
|
133
|
+
if (groups.length === 0)
|
|
134
|
+
return text(`${header}\nNo resolved references.${note}`);
|
|
135
|
+
const body = groups.map(group => `${group.file}\n${group.references.map(ref => ` ${ref.line} ${ref.kind}`).join("\n")}`).join("\n");
|
|
136
|
+
return text(`${header}${note}\n${body}`);
|
|
137
|
+
});
|
|
138
|
+
server.registerTool("code_outline", {
|
|
139
|
+
title: "◆ phren · code outline",
|
|
140
|
+
description: "List a file's functions, types and variables in source order, methods nested under their class or container. Use this before reading a large file: it is far cheaper than opening the source and it shows the structure with each declaration's line, signature and doc. The path is the project-relative path the index uses.",
|
|
141
|
+
inputSchema: z.object({
|
|
142
|
+
project: z.string().describe("Project name, optionally store-qualified."),
|
|
143
|
+
path: z.string().describe("Project-relative file path, as stored in the index."),
|
|
144
|
+
}),
|
|
145
|
+
}, async ({ project: projectInput, path: filePath }) => {
|
|
146
|
+
const code = await loadCodePackage(ctx.phrenPath);
|
|
147
|
+
if (!code)
|
|
148
|
+
return text(CODE_PACKAGE_HINT);
|
|
149
|
+
const { outline } = code;
|
|
150
|
+
const target = resolveTarget(ctx, projectInput);
|
|
151
|
+
if ("error" in target)
|
|
152
|
+
return text(target.error);
|
|
153
|
+
const result = await outline(target.store, target.project, filePath);
|
|
154
|
+
if (!result.available)
|
|
155
|
+
return text(noIndex(target.project));
|
|
156
|
+
if (result.value.length === 0)
|
|
157
|
+
return text(`No functions, types or variables indexed for ${filePath} in ${target.project}.`);
|
|
158
|
+
const count = result.value.reduce((n, entry) => n + 1 + countOutline(entry.children), 0);
|
|
159
|
+
return text(`${target.project}/${filePath} (${count} declarations)\n${outlineLines(result.value).join("\n")}`);
|
|
160
|
+
});
|
|
161
|
+
server.registerTool("code_usage", {
|
|
162
|
+
title: "◆ phren · code usage",
|
|
163
|
+
description: "Show a project's most used and least used functions and types, by how many places use them. Use this instead of grep to see what code is central and what is barely used: it returns the top and bottom N so rarely used code is visible too. Local variables are left out of the most-used list so a busy one-function local or a one-letter loop name cannot dominate it.",
|
|
164
|
+
inputSchema: z.object({
|
|
165
|
+
project: z.string().describe("Project name, optionally store-qualified."),
|
|
166
|
+
top: z.number().int().min(1).max(100).optional().describe("How many most used and how many least used. Defaults to 10."),
|
|
167
|
+
}),
|
|
168
|
+
}, async ({ project: projectInput, top }) => {
|
|
169
|
+
const code = await loadCodePackage(ctx.phrenPath);
|
|
170
|
+
if (!code)
|
|
171
|
+
return text(CODE_PACKAGE_HINT);
|
|
172
|
+
const { usage } = code;
|
|
173
|
+
const target = resolveTarget(ctx, projectInput);
|
|
174
|
+
if ("error" in target)
|
|
175
|
+
return text(target.error);
|
|
176
|
+
const result = await usage(target.store, target.project, top ?? 10);
|
|
177
|
+
if (!result.available)
|
|
178
|
+
return text(noIndex(target.project));
|
|
179
|
+
const { top: hot, bottom: cold } = result.value;
|
|
180
|
+
const section = (label, entries) => entries.length === 0 ? `${label}\nnone` : `${label}\n${entries.map(usageLine).join("\n")}`;
|
|
181
|
+
return text(`${target.project} functions and types by how many places use them\n${section("most used", hot)}\n${section("least used", cold)}`);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function countOutline(entries) {
|
|
185
|
+
return entries.reduce((sum, entry) => sum + 1 + countOutline(entry.children), 0);
|
|
186
|
+
}
|
package/dist/tools/config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
2
|
+
import { disabledHint } from "../modules/registry.js";
|
|
1
3
|
import * as fs from "fs";
|
|
2
4
|
import * as path from "path";
|
|
3
5
|
import { mcpResponse, resolveStoreForProject } from "./types.js";
|
|
@@ -64,6 +66,9 @@ function getTopicConfigData(phrenPath, project) {
|
|
|
64
66
|
domain: result.domain ?? raw?.domain ?? null,
|
|
65
67
|
topics: result.topics,
|
|
66
68
|
pinnedTopics: raw?.pinnedTopics ?? [],
|
|
69
|
+
// A topic-config.json that exists but was rejected reported source
|
|
70
|
+
// "default" with no hint that the file was being ignored.
|
|
71
|
+
...(result.error ? { configError: result.error } : {}),
|
|
67
72
|
},
|
|
68
73
|
};
|
|
69
74
|
}
|
|
@@ -220,6 +225,9 @@ async function handleGetConfig(ctx, { domain, project }) {
|
|
|
220
225
|
}
|
|
221
226
|
async function handleSetConfig(ctx, { domain, settings, project }) {
|
|
222
227
|
const { phrenPath } = ctx;
|
|
228
|
+
if (!moduleEnabled(phrenPath, "tasks", ctx.profile) && (domain === "taskMode" || settings.scope === "tasks" || "taskMode" in settings || "proactivityTask" in settings)) {
|
|
229
|
+
return mcpResponse({ ok: false, error: disabledHint("tasks"), errorCode: "UNAVAILABLE" });
|
|
230
|
+
}
|
|
223
231
|
switch (domain) {
|
|
224
232
|
// ── proactivity ───────────────────────────────────────────────
|
|
225
233
|
case "proactivity": {
|
package/dist/tools/data.js
CHANGED
|
@@ -10,6 +10,7 @@ const importPayloadSchema = z.object({
|
|
|
10
10
|
project: z.string(),
|
|
11
11
|
overwrite: z.boolean().optional(),
|
|
12
12
|
summary: z.string().optional(),
|
|
13
|
+
agentsMd: z.string().optional(),
|
|
13
14
|
claudeMd: z.string().optional(),
|
|
14
15
|
taskRaw: z.string().optional(),
|
|
15
16
|
findingsRaw: z.string().optional(),
|
|
@@ -70,9 +71,14 @@ export function register(server, ctx) {
|
|
|
70
71
|
if (taskRawPath && fs.existsSync(taskRawPath))
|
|
71
72
|
exported.taskRaw = fs.readFileSync(taskRawPath, "utf8");
|
|
72
73
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const agentsPath = safeProjectPath(projectDir, "AGENTS.md");
|
|
75
|
+
const legacyPath = safeProjectPath(projectDir, "CLAUDE.md");
|
|
76
|
+
const instructionsPath = agentsPath && fs.existsSync(agentsPath) ? agentsPath : legacyPath;
|
|
77
|
+
if (instructionsPath && fs.existsSync(instructionsPath)) {
|
|
78
|
+
const instructions = fs.readFileSync(instructionsPath, "utf8");
|
|
79
|
+
exported.agentsMd = instructions;
|
|
80
|
+
exported.claudeMd = instructions; // Deprecated export alias for older clients.
|
|
81
|
+
}
|
|
76
82
|
return mcpResponse({ ok: true, message: `Exported project "${project}".`, data: exported });
|
|
77
83
|
});
|
|
78
84
|
server.registerTool("import_project", {
|
|
@@ -97,7 +103,7 @@ export function register(server, ctx) {
|
|
|
97
103
|
}
|
|
98
104
|
const parsed = parsedResult.data;
|
|
99
105
|
// Warn about unknown fields silently discarded by .passthrough()
|
|
100
|
-
const knownTopLevel = new Set(["project", "overwrite", "summary", "claudeMd", "learnings", "task", "taskRaw", "exportedAt", "version", "findingsRaw"]);
|
|
106
|
+
const knownTopLevel = new Set(["project", "overwrite", "summary", "agentsMd", "claudeMd", "learnings", "task", "taskRaw", "exportedAt", "version", "findingsRaw"]);
|
|
101
107
|
const unknownFields = Object.keys(decoded).filter(k => !knownTopLevel.has(k));
|
|
102
108
|
if (unknownFields.length > 0) {
|
|
103
109
|
debugLog(`import_project: unknown fields will be ignored: ${unknownFields.join(", ")}`);
|
|
@@ -181,9 +187,10 @@ export function register(server, ctx) {
|
|
|
181
187
|
fs.writeFileSync(path.join(stagedProjectDir, "summary.md"), parsed.summary);
|
|
182
188
|
imported.push("summary.md");
|
|
183
189
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
const instructions = parsed.agentsMd ?? parsed.claudeMd;
|
|
191
|
+
if (instructions) {
|
|
192
|
+
fs.writeFileSync(path.join(stagedProjectDir, "AGENTS.md"), instructions);
|
|
193
|
+
imported.push("AGENTS.md");
|
|
187
194
|
}
|
|
188
195
|
const findingsContent = typeof parsed.findingsRaw === "string" ? parsed.findingsRaw : buildFindingsContent();
|
|
189
196
|
if (findingsContent) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { hookRequest } from "../bridge/client.js";
|
|
2
|
+
import { dispatchSchema } from "../bridge/dispatch.js";
|
|
3
|
+
import { handOff, handOffSchema, listLiveSessions } from "../bridge/hand-off.js";
|
|
4
|
+
import { herdrPaneFromEnv } from "../bridge/herdr.js";
|
|
5
|
+
import { mcpResponse } from "./types.js";
|
|
6
|
+
export function register(server) {
|
|
7
|
+
server.registerTool("dispatch", {
|
|
8
|
+
title: "◆ phren · dispatch",
|
|
9
|
+
description: "Send a worker brief to an enrolled computer through the local Phren Hook. Returns a launch receipt and remote target. The worker's finish, question or exit comes back later through dispatch_returns. Never automatically retry an uncertain delivery.",
|
|
10
|
+
inputSchema: dispatchSchema,
|
|
11
|
+
}, async (input) => {
|
|
12
|
+
try {
|
|
13
|
+
// The pane this agent runs in receives the one-line return notices.
|
|
14
|
+
const origin = herdrPaneFromEnv();
|
|
15
|
+
const result = await hookRequest("/v1/dispatch", { ...input, ...(origin ? { origin } : {}) }, undefined, 180_000);
|
|
16
|
+
return mcpResponse({ ok: result.ok === true, data: result, message: `${result.computer}: ${result.state}.` });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return mcpResponse({ ok: false, error: error instanceof Error ? error.message : "Dispatch failed." });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
server.registerTool("dispatch_returns", {
|
|
23
|
+
title: "◆ phren · dispatch returns",
|
|
24
|
+
description: "List unread returns from dispatched workers and mark them read: the worker finished (done, with its final reply), finished by asking the owner something (needs-you, with the question), failed (the harness ended the turn on an error such as a usage limit, with the error), is blocked on terminal input, or its pane is gone. Each row has the dispatch id, computer, project, label and the worker's target for hand_off.",
|
|
25
|
+
inputSchema: {},
|
|
26
|
+
}, async () => {
|
|
27
|
+
try {
|
|
28
|
+
const result = await hookRequest("/v1/dispatch/returns", {});
|
|
29
|
+
const returns = Array.isArray(result.returns) ? result.returns : [];
|
|
30
|
+
return mcpResponse({ ok: true, data: result, message: returns.length ? `${returns.length} unread returns.` : "No unread returns." });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return mcpResponse({ ok: false, error: error instanceof Error ? error.message : "Could not read dispatch returns." });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
server.registerTool("live_sessions", {
|
|
37
|
+
title: "◆ phren · live sessions",
|
|
38
|
+
description: "List the live agent sessions on this computer and every enrolled computer: computer, project, harness, status, idleFor (seconds since the tab last changed), role and the target hand_off takes. Computers that could not be reached are listed separately, and computers registered in the store but not linked in hooks.yaml come back in notLinked: their sessions are unknown, not absent.",
|
|
39
|
+
inputSchema: {},
|
|
40
|
+
}, async () => {
|
|
41
|
+
try {
|
|
42
|
+
const result = await listLiveSessions();
|
|
43
|
+
const note = result.peerError ? ` Enrolled computers were skipped: ${result.peerError}`
|
|
44
|
+
: result.enrolled === 0 && !result.notLinked.length ? " No other computers are enrolled here; run `phren bridge enroll-computer` to add them." : "";
|
|
45
|
+
const unlinked = result.notLinked.length
|
|
46
|
+
? ` Not linked, so not checked (this does not mean nothing is running there): ${result.notLinked.map(item => item.aliases?.length ? `${item.name} (also ${item.aliases.join(", ")})` : item.name).join("; ")}. Link one with \`phren bridge enroll-computer\`.` : "";
|
|
47
|
+
return mcpResponse({ ok: true, data: result, message: `${result.sessions.length} live sessions across ${result.enrolled + 1} computers.${note}${unlinked}` });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return mcpResponse({ ok: false, error: error instanceof Error ? error.message : "Could not list live sessions." });
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
server.registerTool("hand_off", {
|
|
54
|
+
title: "◆ phren · hand off",
|
|
55
|
+
description: "Deliver a prompt to an existing local or enrolled-computer agent session through Phren Hook. Prefer a session that already owns the project and is idle or doing related work.",
|
|
56
|
+
inputSchema: handOffSchema,
|
|
57
|
+
}, async (input) => {
|
|
58
|
+
try {
|
|
59
|
+
const result = await handOff(input);
|
|
60
|
+
return mcpResponse({ ok: result.ok, data: result, message: result.delivered ? "Prompt delivered to the existing session." : "Prompt delivery was not confirmed." });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return mcpResponse({ ok: false, error: error instanceof Error ? error.message : "Hand-off failed." });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
package/dist/tools/finding.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { type McpContext } from "./types.js";
|
|
3
3
|
export declare function findConflictCandidates(phrenPath: string, project: string, finding: string): string[];
|
|
4
|
+
export interface TeamStoreSyncResult {
|
|
5
|
+
store: string;
|
|
6
|
+
pushed: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Commit and push the team-safe pathspecs of every attached team store. Team
|
|
11
|
+
* stores are independent repos, so push_changes runs this whatever happens to
|
|
12
|
+
* the primary store.
|
|
13
|
+
*/
|
|
14
|
+
export declare function syncTeamStores(phrenPath: string): Promise<TeamStoreSyncResult[]>;
|
|
4
15
|
export declare function register(server: McpServer, ctx: McpContext): void;
|