@phren/cli 0.2.14 → 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.d.ts +2 -0
- package/dist/init/init-walkthrough.js +17 -6
- 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/cli-registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { commandOwner, disabledHint } from "./modules/registry.js";
|
|
1
2
|
/**
|
|
2
3
|
* Command registry - single source of truth for help generation and dispatch.
|
|
3
4
|
*
|
|
@@ -63,6 +64,15 @@ const PROJECTS_SUBCOMMANDS = [
|
|
|
63
64
|
{ name: "configure", usage: "phren projects configure <name> [--ownership <mode>] [--hooks on|off]", summary: "Update per-project settings" },
|
|
64
65
|
{ name: "remove", usage: "phren projects remove <name>", summary: "Remove a project" },
|
|
65
66
|
];
|
|
67
|
+
const SCHEDULE_SUBCOMMANDS = [
|
|
68
|
+
{ name: "list", usage: "phren schedule list [project]", summary: "List scheduled prompts" },
|
|
69
|
+
{ name: "add", usage: "phren schedule add <project> --name <name> --harness <name> --computer <name> [--model <model>] --every <kind> [timing] (--prompt <text>|--prompt-file <path>)", summary: "Add a scheduled prompt" },
|
|
70
|
+
{ name: "remove", usage: "phren schedule remove <project> <id>", summary: "Remove a scheduled prompt" },
|
|
71
|
+
{ name: "enable", usage: "phren schedule enable <project> <id>", summary: "Resume a scheduled prompt" },
|
|
72
|
+
{ name: "disable", usage: "phren schedule disable <project> <id>", summary: "Pause a scheduled prompt" },
|
|
73
|
+
{ name: "run", usage: "phren schedule run <project> <id>", summary: "Run a schedule through the local Hook" },
|
|
74
|
+
{ name: "history", usage: "phren schedule history [project] [--id <id>] [--limit <n>]", summary: "Show local schedule runs" },
|
|
75
|
+
];
|
|
66
76
|
const SKILLS_SUBCOMMANDS = [
|
|
67
77
|
{ name: "list", usage: "phren skills list", summary: "List installed skills" },
|
|
68
78
|
{ name: "add", usage: "phren skills add <project> <path>", summary: "Link a skill into a project" },
|
|
@@ -86,7 +96,9 @@ const CONFIG_SUBCOMMANDS = [
|
|
|
86
96
|
{ name: "show", usage: "phren config show [--project <name>]", summary: "Show current config" },
|
|
87
97
|
{ name: "policy", usage: "phren config policy [get|set ...]", summary: "Retention, TTL, confidence, decay" },
|
|
88
98
|
{ name: "workflow", usage: "phren config workflow [get|set ...]", summary: "Risky-memory thresholds" },
|
|
89
|
-
{ name: "proactivity", usage: "phren config proactivity [level]", summary: "
|
|
99
|
+
{ name: "proactivity", usage: "phren config proactivity [level] [--scope base|findings|tasks]", summary: "Auto-capture level; --scope limits it to findings or tasks" },
|
|
100
|
+
{ name: "proactivity.findings", usage: "phren config proactivity.findings [level]", summary: "Findings-only auto-capture level" },
|
|
101
|
+
{ name: "proactivity.tasks", usage: "phren config proactivity.tasks [level]", summary: "Task-only auto-capture level" },
|
|
90
102
|
{ name: "task-mode", usage: "phren config task-mode [mode]", summary: "Set task automation mode" },
|
|
91
103
|
{ name: "finding-sensitivity", usage: "phren config finding-sensitivity [lvl]", summary: "Set finding capture sensitivity" },
|
|
92
104
|
{ name: "index", usage: "phren config index [get|set ...]", summary: "Indexer include/exclude globs" },
|
|
@@ -120,14 +132,44 @@ const TEAM_SUBCOMMANDS = [
|
|
|
120
132
|
// ── Registry ─────────────────────────────────────────────────────────────────
|
|
121
133
|
export const REGISTRY = [
|
|
122
134
|
{
|
|
123
|
-
name: "bridge", topic: "setup", usage: "phren bridge <install|status|doctor|update|rollback|uninstall>",
|
|
124
|
-
summary: "Install
|
|
135
|
+
name: "bridge", topic: "setup", usage: "phren bridge <install|status|doctor|update|rollback|uninstall|enroll-computer|fanouts archive>",
|
|
136
|
+
summary: "Install Phren Hook and enroll phone or computer connections",
|
|
137
|
+
subcommands: [
|
|
138
|
+
{ name: "enroll-computer", usage: "phren bridge enroll-computer <name> [--accept <public-key-file>]", summary: "Print or accept a restricted computer dispatch key" },
|
|
139
|
+
{ name: "fanouts archive", usage: "phren bridge fanouts archive [--dry-run] [--parent <session-id>] [--older-than <minutes>]", summary: "Archive finished fan-out jobs older than 24 hours, or one parent chat's, or older than N minutes" },
|
|
140
|
+
],
|
|
125
141
|
run: async (args) => {
|
|
126
142
|
const { runBridge } = await import("./bridge/command.js");
|
|
127
143
|
const { VERSION } = await import("./package-metadata.js");
|
|
128
144
|
return runBridge(args, VERSION);
|
|
129
145
|
},
|
|
130
146
|
},
|
|
147
|
+
{
|
|
148
|
+
name: "dispatch", topic: "core", usage: "phren dispatch <computer|anywhere> <project> --label <label> --prompt <brief> [--harness codex|claude|opencode] [--model <model>]",
|
|
149
|
+
summary: "Dispatch a worker brief through Phren Hook",
|
|
150
|
+
subcommands: [{ name: "status", usage: "phren dispatch status", summary: "List local dispatch receipts" },
|
|
151
|
+
{ name: "returns", usage: "phren dispatch returns", summary: "List unread worker returns (done, needs you, blocked, gone) and mark them read" },
|
|
152
|
+
{ name: "sessions", usage: "phren dispatch sessions", summary: "List live agent sessions on this and every enrolled computer" }],
|
|
153
|
+
run: async (args) => (await import("./bridge/dispatch-command.js")).runDispatch(args),
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "hand-off", topic: "core", usage: "phren hand-off <computer|local> --session <id> --text <prompt>",
|
|
157
|
+
summary: "Send work to an existing agent session through Phren Hook",
|
|
158
|
+
run: async (args) => (await import("./bridge/dispatch-command.js")).runHandOff(args),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "canary", topic: "core", usage: "phren canary [--daily on|off]",
|
|
162
|
+
summary: "Exercise launch, schedules, transcripts and peers through Phren Hook; saves canary.json",
|
|
163
|
+
run: async (args) => (await import("./bridge/canary.js")).runCanaryCommand(args),
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "conductor", topic: "core", usage: "phren conductor <subcommand>",
|
|
167
|
+
summary: "Manage conductor standing grants",
|
|
168
|
+
subcommands: [
|
|
169
|
+
{ name: "grants", usage: "phren conductor grants [list|add|remove]", summary: "List, add, or remove conductor grants" },
|
|
170
|
+
],
|
|
171
|
+
run: async (args) => (await import("./bridge/dispatch-command.js")).runConductor(args),
|
|
172
|
+
},
|
|
131
173
|
// Setup (featured: init, quickstart)
|
|
132
174
|
{
|
|
133
175
|
name: "init",
|
|
@@ -169,6 +211,17 @@ export const REGISTRY = [
|
|
|
169
211
|
await handleProjectsNamespace(args, ctx.profile());
|
|
170
212
|
},
|
|
171
213
|
},
|
|
214
|
+
{
|
|
215
|
+
name: "schedule",
|
|
216
|
+
topic: "projects",
|
|
217
|
+
usage: "phren schedule <subcommand>",
|
|
218
|
+
summary: "Manage scheduled prompts",
|
|
219
|
+
subcommands: SCHEDULE_SUBCOMMANDS,
|
|
220
|
+
run: async (args, ctx) => {
|
|
221
|
+
const { handleScheduleCommand } = await import("./cli/schedules.js");
|
|
222
|
+
return handleScheduleCommand(args, ctx.phrenPath());
|
|
223
|
+
},
|
|
224
|
+
},
|
|
172
225
|
// Core (featured: search, status, doctor, web-ui, tasks, graph, shell)
|
|
173
226
|
{
|
|
174
227
|
name: "search",
|
|
@@ -237,6 +290,22 @@ export const REGISTRY = [
|
|
|
237
290
|
await handleGraphNamespace(args);
|
|
238
291
|
},
|
|
239
292
|
},
|
|
293
|
+
{
|
|
294
|
+
name: "code",
|
|
295
|
+
topic: "core",
|
|
296
|
+
usage: "phren code <index|status|search|outline|refs|def|usage> [project]",
|
|
297
|
+
summary: "Index and query a project's code symbols and references",
|
|
298
|
+
subcommands: [
|
|
299
|
+
{ name: "index", usage: "phren code index <project> [--full] [--repo <path>]", summary: "Build or refresh the code index" },
|
|
300
|
+
{ name: "status", usage: "phren code status <project> [--top <n>]", summary: "Show index counts, languages and hot symbols" },
|
|
301
|
+
{ name: "search", usage: "phren code search <project> <query> [--kind k] [--limit n]", summary: "Ranked symbol search" },
|
|
302
|
+
{ name: "outline", usage: "phren code outline <project> <path>", summary: "A file's symbols in source order, nested" },
|
|
303
|
+
{ name: "refs", usage: "phren code refs <project> <symbol>", summary: "References to a symbol, grouped by file" },
|
|
304
|
+
{ name: "def", usage: "phren code def <project> <symbol>", summary: "A symbol's definition, doc, snippet and last change" },
|
|
305
|
+
{ name: "usage", usage: "phren code usage <project> [--top n]", summary: "Hottest and coldest symbols by reference count" },
|
|
306
|
+
],
|
|
307
|
+
run: async (args, ctx) => (await (await import("./modules/code-package.js")).requireCodePackage(ctx.phrenPath())).runCodeCommand(args, ctx),
|
|
308
|
+
},
|
|
240
309
|
{
|
|
241
310
|
name: "shell",
|
|
242
311
|
topic: "core",
|
|
@@ -413,6 +482,25 @@ export const REGISTRY = [
|
|
|
413
482
|
},
|
|
414
483
|
},
|
|
415
484
|
// Config
|
|
485
|
+
{
|
|
486
|
+
name: "fanout",
|
|
487
|
+
topic: "config",
|
|
488
|
+
usage: "phren fanout run|usage|resume|review|list|archive",
|
|
489
|
+
summary: "Launch and manage usage-aware agent workers",
|
|
490
|
+
run: async (args, ctx) => (await import("./fanout/command.js")).runFanout(args, ctx),
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: "modules",
|
|
494
|
+
topic: "config",
|
|
495
|
+
usage: "phren modules <list|enable|disable> [name] [--profile <name>]",
|
|
496
|
+
summary: "List or configure enabled modules",
|
|
497
|
+
subcommands: [
|
|
498
|
+
{ name: "list", usage: "phren modules list [--profile <name>]", summary: "Show effective enablement and source" },
|
|
499
|
+
{ name: "enable", usage: "phren modules enable <name> [--profile <name>]", summary: "Enable a module" },
|
|
500
|
+
{ name: "disable", usage: "phren modules disable <name> [--profile <name>]", summary: "Disable a module, preserving its data" },
|
|
501
|
+
],
|
|
502
|
+
run: async (args, ctx) => (await import("./modules/command.js")).runModules(args, ctx),
|
|
503
|
+
},
|
|
416
504
|
{
|
|
417
505
|
name: "config",
|
|
418
506
|
topic: "config",
|
|
@@ -749,14 +837,14 @@ export const REGISTRY = [
|
|
|
749
837
|
name: "link",
|
|
750
838
|
topic: "setup",
|
|
751
839
|
usage: "phren link",
|
|
752
|
-
summary: "
|
|
840
|
+
summary: "Reconcile the existing installation",
|
|
753
841
|
hidden: true,
|
|
754
842
|
run: native("runLinkRemovedNotice"),
|
|
755
843
|
},
|
|
756
844
|
];
|
|
757
845
|
// ── Lookup ───────────────────────────────────────────────────────────────────
|
|
758
|
-
export function lookupCommand(name) {
|
|
759
|
-
for (const cmd of
|
|
846
|
+
export function lookupCommand(name, snapshot) {
|
|
847
|
+
for (const cmd of commandsForModules(snapshot)) {
|
|
760
848
|
if (cmd.name === name)
|
|
761
849
|
return cmd;
|
|
762
850
|
if (cmd.aliases?.includes(name))
|
|
@@ -772,3 +860,28 @@ export function helpTopicNames() {
|
|
|
772
860
|
export function commandTopics() {
|
|
773
861
|
return TOPIC_ORDER;
|
|
774
862
|
}
|
|
863
|
+
export function disabledCommand(command, snapshot) {
|
|
864
|
+
if (!snapshot.has("tasks") && /^config proactivity .*--scope(?:=|\s+)(?:tasks|task)(?:\s|$)/.test(command))
|
|
865
|
+
return disabledHint("tasks");
|
|
866
|
+
const owner = commandOwner(command);
|
|
867
|
+
return owner && !snapshot.has(owner.name) ? disabledHint(owner.name) : undefined;
|
|
868
|
+
}
|
|
869
|
+
export function commandsForModules(snapshot) {
|
|
870
|
+
if (!snapshot)
|
|
871
|
+
return REGISTRY;
|
|
872
|
+
return REGISTRY.filter(command => !disabledCommand(command.name, snapshot)).map(command => ({
|
|
873
|
+
...command,
|
|
874
|
+
usage: command.usage.replace(/<([^<>]*\|[^<>]*)>/g, (_match, choices) => `<${choices.split("|").filter(choice => !disabledCommand(`${command.name} ${choice}`, snapshot)).join("|")}>`),
|
|
875
|
+
aliases: command.aliases?.filter(alias => !disabledCommand(alias, snapshot)),
|
|
876
|
+
subcommands: command.subcommands?.filter(sub => !disabledCommand(`${command.name} ${sub.name}`, snapshot))
|
|
877
|
+
.map(sub => snapshot.has("tasks") ? sub : { ...sub, usage: sub.usage.replace("base|findings|tasks", "base|findings"), summary: sub.summary?.replace("findings or tasks", "findings") }),
|
|
878
|
+
run: async (args, ctx) => {
|
|
879
|
+
const unavailable = disabledCommand([command.name, ...args].join(" "), snapshot);
|
|
880
|
+
if (unavailable) {
|
|
881
|
+
console.error(unavailable);
|
|
882
|
+
return 1;
|
|
883
|
+
}
|
|
884
|
+
return command.run(args, ctx);
|
|
885
|
+
},
|
|
886
|
+
}));
|
|
887
|
+
}
|
package/dist/content/archive.js
CHANGED
|
@@ -4,12 +4,12 @@ import * as crypto from "crypto";
|
|
|
4
4
|
import { debugLog, runtimeFile, phrenOk, phrenErr, PhrenError, appendAuditLog, tryUnlink } from "../shared.js";
|
|
5
5
|
import { isValidProjectName, errorMessage } from "../utils.js";
|
|
6
6
|
import { storeAwareProjectPath } from "../store-routing.js";
|
|
7
|
-
import { withFileLock } from "../
|
|
7
|
+
import { withFileLock } from "../governance/locks.js";
|
|
8
8
|
import { walkDirectory } from "../shared/data-utils.js";
|
|
9
9
|
import { appendArchivedEntriesToTopicDoc, classifyTopicForText, readProjectTopics, topicReferencePath } from "../project-topics.js";
|
|
10
10
|
import { isCitationLine, isArchiveStart, isArchiveEnd, stripComments } from "./metadata.js";
|
|
11
11
|
import { logger } from "../logger.js";
|
|
12
|
-
import { FINDINGS_FILENAME } from "../
|
|
12
|
+
import { FINDINGS_FILENAME } from "../filenames.js";
|
|
13
13
|
/**
|
|
14
14
|
* Count active (non-archived) finding entries in FINDINGS.md content.
|
|
15
15
|
* Entries inside archive blocks are considered archived.
|
|
@@ -5,6 +5,15 @@ export interface FindingCitation {
|
|
|
5
5
|
file?: string;
|
|
6
6
|
line?: number;
|
|
7
7
|
commit?: string;
|
|
8
|
+
/**
|
|
9
|
+
* A symbol the finding is about, as `Name`, `Type.member` or `name()`.
|
|
10
|
+
* Auto-attached on write when the project has a code index and the finding
|
|
11
|
+
* text names exactly one resolvable symbol; an explicit one is validated
|
|
12
|
+
* against the index and stored either way.
|
|
13
|
+
*/
|
|
14
|
+
symbol?: string;
|
|
15
|
+
/** True when an explicit symbol citation could not be resolved in the index. */
|
|
16
|
+
symbol_unresolved?: boolean;
|
|
8
17
|
supersedes?: string;
|
|
9
18
|
task_item?: string;
|
|
10
19
|
}
|
|
@@ -48,6 +57,8 @@ export declare function buildScopeComment(scope: string | undefined): string;
|
|
|
48
57
|
export declare function parseScopeComment(line: string): string | undefined;
|
|
49
58
|
export declare function parseSourceComment(line: string): FindingProvenance | null;
|
|
50
59
|
export declare function parseCitationComment(line: string): FindingCitation | null;
|
|
60
|
+
/** Every distinct `symbol:` value in a document's `phren:cite` comments, in order. */
|
|
61
|
+
export declare function collectSymbolCitations(content: string): string[];
|
|
51
62
|
export declare function validateFindingCitation(citation: FindingCitation): boolean;
|
|
52
63
|
export declare function filterTrustedFindings(content: string, ttlDays: number): string;
|
|
53
64
|
export declare function filterTrustedFindingsDetailed(content: string, opts: number | TrustFilterOptions): {
|
package/dist/content/citation.js
CHANGED
|
@@ -163,6 +163,8 @@ export function parseCitationComment(line) {
|
|
|
163
163
|
file: typeof parsed.file === "string" ? parsed.file : undefined,
|
|
164
164
|
line: typeof parsed.line === "number" ? parsed.line : undefined,
|
|
165
165
|
commit: typeof parsed.commit === "string" ? parsed.commit : undefined,
|
|
166
|
+
symbol: typeof parsed.symbol === "string" && parsed.symbol.trim() ? parsed.symbol : undefined,
|
|
167
|
+
symbol_unresolved: parsed.symbol_unresolved === true ? true : undefined,
|
|
166
168
|
supersedes: typeof parsed.supersedes === "string" ? parsed.supersedes : undefined,
|
|
167
169
|
task_item: typeof parsed.task_item === "string" ? parsed.task_item : undefined,
|
|
168
170
|
};
|
|
@@ -172,6 +174,16 @@ export function parseCitationComment(line) {
|
|
|
172
174
|
return null;
|
|
173
175
|
}
|
|
174
176
|
}
|
|
177
|
+
/** Every distinct `symbol:` value in a document's `phren:cite` comments, in order. */
|
|
178
|
+
export function collectSymbolCitations(content) {
|
|
179
|
+
const found = new Set();
|
|
180
|
+
for (const line of content.split("\n")) {
|
|
181
|
+
const citation = parseCitationComment(line);
|
|
182
|
+
if (citation?.symbol)
|
|
183
|
+
found.add(citation.symbol);
|
|
184
|
+
}
|
|
185
|
+
return [...found];
|
|
186
|
+
}
|
|
175
187
|
function resolveCitationFile(citation) {
|
|
176
188
|
if (!citation.file)
|
|
177
189
|
return null;
|
|
@@ -237,6 +249,12 @@ function cachedBlame(repoPath, relFile, line) {
|
|
|
237
249
|
}
|
|
238
250
|
}
|
|
239
251
|
export function validateFindingCitation(citation) {
|
|
252
|
+
// A symbol citation is resolved against the project's code index at write
|
|
253
|
+
// time (the index lives outside the synced store, so it is not available
|
|
254
|
+
// here). The write path records `symbol_unresolved` when it could not
|
|
255
|
+
// resolve one; that is the symbol counterpart of a missing cited file.
|
|
256
|
+
if (citation.symbol && citation.symbol_unresolved)
|
|
257
|
+
return false;
|
|
240
258
|
if (citation.repo && !fs.existsSync(citation.repo))
|
|
241
259
|
return false;
|
|
242
260
|
if (citation.commit && citation.repo && !commitExists(citation.repo, citation.commit))
|
package/dist/content/learning.js
CHANGED
|
@@ -32,6 +32,8 @@ function buildFindingCitation(citationInput, nowIso, inferredRepo, headCommit) {
|
|
|
32
32
|
file: citationInput?.file,
|
|
33
33
|
line: citationInput?.line,
|
|
34
34
|
commit: citationInput?.commit || (citationInput?.repo || inferredRepo ? headCommit ?? getHeadCommit(citationInput?.repo || inferredRepo || "") : undefined),
|
|
35
|
+
symbol: citationInput?.symbol,
|
|
36
|
+
symbol_unresolved: citationInput?.symbol_unresolved ? true : undefined,
|
|
35
37
|
supersedes: citationInput?.supersedes,
|
|
36
38
|
task_item: citationInput?.task_item,
|
|
37
39
|
};
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Give the archive a shape.
|
|
3
|
-
*
|
|
4
|
-
* Findings age out of FINDINGS.md into reference/topics/<topic>.md, append-only,
|
|
5
|
-
* grouped under "## Archived <date>" headings. A store a year old carries
|
|
6
|
-
* hundreds of thousands of words there, reachable only by keyword: search finds
|
|
7
|
-
* bullet 312, and nothing says what the topic amounts to. This writes a "## Now"
|
|
8
|
-
* block at the top of each topic file — structural by default (counts, tags,
|
|
9
|
-
* what is mentioned most, the newest headlines), a prose paragraph when an LLM
|
|
10
|
-
* is configured — and a "What phren knows" block at the end of summary.md that
|
|
11
|
-
* the prompt hook injects once per session for the project at hand. Both live
|
|
12
|
-
* between markers, so re-running replaces rather than accumulates. Nothing in
|
|
13
|
-
* the archive itself is rewritten; a topic file past a size cap is split, oldest
|
|
14
|
-
* sections first, into <topic>.older.md.
|
|
15
|
-
*/
|
|
16
1
|
export declare const NOW_START = "<!-- phren:now:start -->";
|
|
17
2
|
export declare const NOW_END = "<!-- phren:now:end -->";
|
|
18
3
|
export declare const KNOWS_START = "<!-- phren:knows:start -->";
|
|
@@ -89,6 +74,20 @@ export interface ProjectSummary {
|
|
|
89
74
|
summaryPath: string | null;
|
|
90
75
|
summaryUpdated: boolean;
|
|
91
76
|
}
|
|
77
|
+
export declare function countActiveFindingsIn(findingsPath: string): number;
|
|
78
|
+
export declare function countOpenTasks(tasksPath: string): number;
|
|
79
|
+
/** What a project holds, counted the same way everywhere a count is shown:
|
|
80
|
+
* live findings, team journal findings, everything archived into topic files
|
|
81
|
+
* (older halves included), and open tasks. Every graph and project list reads
|
|
82
|
+
* this so no surface shows only the slice it happened to draw. */
|
|
83
|
+
export interface ProjectMemoryCounts {
|
|
84
|
+
active: number;
|
|
85
|
+
journal: number;
|
|
86
|
+
archived: number;
|
|
87
|
+
findings: number;
|
|
88
|
+
openTasks: number;
|
|
89
|
+
}
|
|
90
|
+
export declare function projectMemoryCounts(phrenPath: string, project: string): ProjectMemoryCounts;
|
|
92
91
|
/** Summarize every topic file of a project and refresh the "What phren knows" block in summary.md. */
|
|
93
92
|
export declare function summarizeProject(phrenPath: string, project: string, opts?: SummarizeOptions): Promise<ProjectSummary>;
|
|
94
93
|
export interface TopicFile {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
1
2
|
/**
|
|
2
3
|
* Give the archive a shape.
|
|
3
4
|
*
|
|
@@ -287,7 +288,7 @@ export async function summarizeTopicFile(filePath, slug, opts = {}) {
|
|
|
287
288
|
atomicWriteText(filePath, next);
|
|
288
289
|
return { slug, file: filePath, bullets: bullets.length, updated: next !== content, split: split ?? undefined, now };
|
|
289
290
|
}
|
|
290
|
-
function countActiveFindingsIn(findingsPath) {
|
|
291
|
+
export function countActiveFindingsIn(findingsPath) {
|
|
291
292
|
try {
|
|
292
293
|
let inArchive = false;
|
|
293
294
|
let n = 0;
|
|
@@ -305,7 +306,7 @@ function countActiveFindingsIn(findingsPath) {
|
|
|
305
306
|
return 0;
|
|
306
307
|
}
|
|
307
308
|
}
|
|
308
|
-
function countOpenTasks(tasksPath) {
|
|
309
|
+
export function countOpenTasks(tasksPath) {
|
|
309
310
|
try {
|
|
310
311
|
return fs.readFileSync(tasksPath, "utf8").split("\n").filter((l) => /^- \[ \]/.test(l)).length;
|
|
311
312
|
}
|
|
@@ -313,6 +314,57 @@ function countOpenTasks(tasksPath) {
|
|
|
313
314
|
return 0;
|
|
314
315
|
}
|
|
315
316
|
}
|
|
317
|
+
function olderBullets(topicsDir) {
|
|
318
|
+
if (!topicsDir || !fs.existsSync(topicsDir))
|
|
319
|
+
return 0;
|
|
320
|
+
let n = 0;
|
|
321
|
+
for (const entry of fs.readdirSync(topicsDir)) {
|
|
322
|
+
if (!entry.endsWith(".older.md"))
|
|
323
|
+
continue;
|
|
324
|
+
try {
|
|
325
|
+
n += parseTopicBullets(fs.readFileSync(path.join(topicsDir, entry), "utf8")).length;
|
|
326
|
+
}
|
|
327
|
+
catch { /* unreadable: not counted */ }
|
|
328
|
+
}
|
|
329
|
+
return n;
|
|
330
|
+
}
|
|
331
|
+
function archivedBullets(topicsDir) {
|
|
332
|
+
if (!topicsDir || !fs.existsSync(topicsDir))
|
|
333
|
+
return 0;
|
|
334
|
+
let n = 0;
|
|
335
|
+
for (const entry of fs.readdirSync(topicsDir)) {
|
|
336
|
+
if (!entry.endsWith(".md"))
|
|
337
|
+
continue;
|
|
338
|
+
try {
|
|
339
|
+
n += parseTopicBullets(fs.readFileSync(path.join(topicsDir, entry), "utf8")).length;
|
|
340
|
+
}
|
|
341
|
+
catch { /* unreadable: not counted */ }
|
|
342
|
+
}
|
|
343
|
+
return n;
|
|
344
|
+
}
|
|
345
|
+
function journalBullets(journalDir) {
|
|
346
|
+
if (!journalDir || !fs.existsSync(journalDir))
|
|
347
|
+
return 0;
|
|
348
|
+
let n = 0;
|
|
349
|
+
for (const entry of fs.readdirSync(journalDir)) {
|
|
350
|
+
if (!entry.endsWith(".md"))
|
|
351
|
+
continue;
|
|
352
|
+
try {
|
|
353
|
+
n += fs.readFileSync(path.join(journalDir, entry), "utf8").split("\n").filter((l) => l.startsWith("- ")).length;
|
|
354
|
+
}
|
|
355
|
+
catch { /* unreadable: not counted */ }
|
|
356
|
+
}
|
|
357
|
+
return n;
|
|
358
|
+
}
|
|
359
|
+
export function projectMemoryCounts(phrenPath, project) {
|
|
360
|
+
const findingsPath = storeAwareProjectPath(phrenPath, project, "FINDINGS.md");
|
|
361
|
+
const tasksPath = storeAwareProjectPath(phrenPath, project, "tasks.md");
|
|
362
|
+
const active = findingsPath ? countActiveFindingsIn(findingsPath) : 0;
|
|
363
|
+
const journal = journalBullets(storeAwareProjectPath(phrenPath, project, "journal"));
|
|
364
|
+
const archived = archivedBullets(storeAwareProjectPath(phrenPath, project, "reference", "topics"));
|
|
365
|
+
const openTasks = tasksPath ? countOpenTasks(tasksPath) : 0;
|
|
366
|
+
return { active, journal, archived, findings: active + journal + archived, openTasks };
|
|
367
|
+
}
|
|
316
368
|
/** Summarize every topic file of a project and refresh the "What phren knows" block in summary.md. */
|
|
317
369
|
export async function summarizeProject(phrenPath, project, opts = {}) {
|
|
318
370
|
// The store's .env carries the LLM endpoint and model; a CLI path that has
|
|
@@ -346,11 +398,14 @@ export async function summarizeProject(phrenPath, project, opts = {}) {
|
|
|
346
398
|
if (!summaryPath)
|
|
347
399
|
return { project, topics: results, summaryPath: null, summaryUpdated: false };
|
|
348
400
|
const findingsPath = storeAwareProjectPath(phrenPath, project, "FINDINGS.md");
|
|
349
|
-
const
|
|
401
|
+
const tasksEnabled = moduleEnabled(path.dirname(path.dirname(summaryPath)), "tasks");
|
|
402
|
+
const tasksPath = tasksEnabled ? storeAwareProjectPath(phrenPath, project, "tasks.md") : null;
|
|
350
403
|
const active = findingsPath ? countActiveFindingsIn(findingsPath) : 0;
|
|
351
|
-
|
|
404
|
+
// An oversized topic's older half lives in <topic>.older.md; it is not
|
|
405
|
+
// summarized as a topic of its own, but its findings are still archived.
|
|
406
|
+
const archived = results.reduce((n, r) => n + r.bullets, 0) + olderBullets(topicsDir);
|
|
352
407
|
const open = tasksPath ? countOpenTasks(tasksPath) : 0;
|
|
353
|
-
const lines = [`- ${plural(active, "active finding")}, ${archived} archived across ${plural(results.filter((r) => r.bullets > 0).length, "topic")}
|
|
408
|
+
const lines = [`- ${plural(active, "active finding")}, ${archived} archived across ${plural(results.filter((r) => r.bullets > 0).length, "topic")}${tasksEnabled ? `, ${plural(open, "open task")}` : ""}.`];
|
|
354
409
|
for (const r of results.filter((r) => r.bullets > 0).sort((a, b) => b.bullets - a.bullets)) {
|
|
355
410
|
const first = r.now.split(/(?<=\.)\s/)[0] ?? r.now;
|
|
356
411
|
lines.push(`- **${r.slug}** — ${first}`);
|
|
@@ -63,8 +63,10 @@ export declare function mergeFindings(ours: string, theirs: string): string;
|
|
|
63
63
|
* Ours wins on conflict. Section order follows Active > Queue > Done.
|
|
64
64
|
*/
|
|
65
65
|
export declare function mergeTask(ours: string, theirs: string): string;
|
|
66
|
+
/** The store paths whose record-oriented markdown can safely use union merge. */
|
|
67
|
+
export declare function isAutoMergeableStorePath(relFile: string): boolean;
|
|
66
68
|
/**
|
|
67
|
-
* Attempt to auto-resolve git conflicts in
|
|
69
|
+
* Attempt to auto-resolve git conflicts in union-safe store markdown files.
|
|
68
70
|
* Returns true if all conflicts were resolved, false if any remain.
|
|
69
71
|
*/
|
|
70
72
|
export declare function autoMergeConflicts(phrenPath: string): boolean;
|
package/dist/content/validate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
1
2
|
import * as fs from "fs";
|
|
2
3
|
import * as path from "path";
|
|
3
4
|
import * as crypto from "crypto";
|
|
@@ -5,10 +6,10 @@ import { execFileSync } from "child_process";
|
|
|
5
6
|
import { debugLog, EXEC_TIMEOUT_MS, getProjectDirs } from "../shared.js";
|
|
6
7
|
import { errorMessage } from "../utils.js";
|
|
7
8
|
import { countActiveFindings } from "./archive.js";
|
|
8
|
-
import { isTaskFileName } from "../
|
|
9
|
+
import { isTaskFileName } from "../filenames.js";
|
|
9
10
|
import { METADATA_REGEX } from "./metadata.js";
|
|
10
11
|
import { getNonPrimaryStores, getStoreProjectDirs } from "../store-registry.js";
|
|
11
|
-
import { FINDINGS_FILENAME } from "../
|
|
12
|
+
import { FINDINGS_FILENAME } from "../filenames.js";
|
|
12
13
|
/** Maximum allowed length for a single finding entry (token budget protection). */
|
|
13
14
|
export const MAX_FINDING_LENGTH = 2000;
|
|
14
15
|
function safeParseDate(s) {
|
|
@@ -333,8 +334,13 @@ export function mergeFindings(ours, theirs) {
|
|
|
333
334
|
}
|
|
334
335
|
return lines.join("\n");
|
|
335
336
|
}
|
|
336
|
-
/**
|
|
337
|
-
|
|
337
|
+
/**
|
|
338
|
+
* Pattern for the stable bid comment embedded in task lines. The comment carries
|
|
339
|
+
* more than the bid in real files (`<!-- bid:HASH rank:N created:... -->`), so the
|
|
340
|
+
* pattern must accept any trailing fields up to the closing `-->` — matching only
|
|
341
|
+
* `<!-- bid:HASH -->` silently disabled stable-ID dedup in the union merge.
|
|
342
|
+
*/
|
|
343
|
+
const MERGE_BID_PATTERN = /<!--\s*bid:([a-z0-9]{8})\b[^>]*-->/;
|
|
338
344
|
/** Render a TaskRecord back to its original lines. */
|
|
339
345
|
function renderTaskRecord(record) {
|
|
340
346
|
return [record.bullet, ...record.continuations];
|
|
@@ -372,7 +378,10 @@ function parseTaskSections(content) {
|
|
|
372
378
|
continuations: [],
|
|
373
379
|
};
|
|
374
380
|
}
|
|
375
|
-
else if (currentRecord && line.
|
|
381
|
+
else if (currentRecord && line.startsWith(" ") && line.trim()) {
|
|
382
|
+
// Any indented, non-empty line belongs to the preceding task: Context:,
|
|
383
|
+
// GitHub:, sub-bullets. Keeping only Context: dropped GitHub links (and any
|
|
384
|
+
// future continuation field) from the merged file.
|
|
376
385
|
currentRecord.continuations.push(line);
|
|
377
386
|
}
|
|
378
387
|
else {
|
|
@@ -426,14 +435,23 @@ export function mergeTask(ours, theirs) {
|
|
|
426
435
|
}
|
|
427
436
|
return lines.join("\n");
|
|
428
437
|
}
|
|
438
|
+
/** The store paths whose record-oriented markdown can safely use union merge. */
|
|
439
|
+
export function isAutoMergeableStorePath(relFile) {
|
|
440
|
+
const normalized = relFile.replace(/\\/g, "/");
|
|
441
|
+
const filename = path.posix.basename(normalized).toLowerCase();
|
|
442
|
+
return filename === "findings.md"
|
|
443
|
+
|| isTaskFileName(filename)
|
|
444
|
+
|| /^\.config\/task-archive\/[^/]+\.md$/i.test(normalized);
|
|
445
|
+
}
|
|
429
446
|
/**
|
|
430
|
-
* Attempt to auto-resolve git conflicts in
|
|
447
|
+
* Attempt to auto-resolve git conflicts in union-safe store markdown files.
|
|
431
448
|
* Returns true if all conflicts were resolved, false if any remain.
|
|
432
449
|
*/
|
|
433
450
|
export function autoMergeConflicts(phrenPath) {
|
|
434
451
|
let conflictedFiles;
|
|
435
452
|
try {
|
|
436
453
|
const out = execFileSync("git", ["diff", "--name-only", "--diff-filter=U"], {
|
|
454
|
+
env: nonInteractiveGitEnv(),
|
|
437
455
|
cwd: phrenPath,
|
|
438
456
|
encoding: "utf8",
|
|
439
457
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -451,7 +469,7 @@ export function autoMergeConflicts(phrenPath) {
|
|
|
451
469
|
for (const relFile of conflictedFiles) {
|
|
452
470
|
const fullPath = path.join(phrenPath, relFile);
|
|
453
471
|
const filename = path.basename(relFile).toLowerCase();
|
|
454
|
-
const canAutoMerge =
|
|
472
|
+
const canAutoMerge = isAutoMergeableStorePath(relFile);
|
|
455
473
|
if (!canAutoMerge) {
|
|
456
474
|
debugLog(`Cannot auto-merge: ${relFile} (not a known mergeable file)`);
|
|
457
475
|
allResolved = false;
|
|
@@ -468,7 +486,7 @@ export function autoMergeConflicts(phrenPath) {
|
|
|
468
486
|
const tmpMergePath = fullPath + `.tmp-${crypto.randomUUID()}`;
|
|
469
487
|
fs.writeFileSync(tmpMergePath, merged);
|
|
470
488
|
fs.renameSync(tmpMergePath, fullPath);
|
|
471
|
-
execFileSync("git", ["add", "--", relFile], { cwd: phrenPath, stdio: ["ignore", "ignore", "ignore"], timeout: EXEC_TIMEOUT_MS });
|
|
489
|
+
execFileSync("git", ["add", "--", relFile], { env: nonInteractiveGitEnv(), cwd: phrenPath, stdio: ["ignore", "ignore", "ignore"], timeout: EXEC_TIMEOUT_MS });
|
|
472
490
|
debugLog(`Auto-merged: ${relFile}`);
|
|
473
491
|
}
|
|
474
492
|
catch (err) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ProjectOwnershipMode } from "../project-config.js";
|
|
2
|
+
import { type BuiltinTopic } from "../project-topics.js";
|
|
3
|
+
/** Project domain used to pick starter topics and the AGENTS.md template. */
|
|
4
|
+
export type InitProjectDomain = "software" | "music" | "game" | "research" | "writing" | "creative" | "other";
|
|
5
|
+
interface BootstrapProjectOptions {
|
|
6
|
+
profile?: string;
|
|
7
|
+
profilePhrenPath?: string;
|
|
8
|
+
ownership?: ProjectOwnershipMode;
|
|
9
|
+
}
|
|
10
|
+
interface BootstrapProjectResult {
|
|
11
|
+
project: string;
|
|
12
|
+
ownership: ProjectOwnershipMode;
|
|
13
|
+
claudePath: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface InferredInitScaffold {
|
|
16
|
+
domain: InitProjectDomain;
|
|
17
|
+
topics: BuiltinTopic[];
|
|
18
|
+
referenceHints: string[];
|
|
19
|
+
commandHints: string[];
|
|
20
|
+
confidence: number;
|
|
21
|
+
reason: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function inferInitScaffoldFromRepo(repoRoot: string, fallbackDomain?: InitProjectDomain): InferredInitScaffold | null;
|
|
24
|
+
export declare function ensureProjectScaffold(projectDir: string, projectName: string, domain?: InitProjectDomain, inference?: InferredInitScaffold | null): void;
|
|
25
|
+
export declare function bootstrapFromExisting(phrenPath: string, projectPath: string, opts?: string | BootstrapProjectOptions): BootstrapProjectResult;
|
|
26
|
+
export {};
|