@phren/cli 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agent-instructions.d.ts +12 -0
- package/dist/agent-instructions.js +52 -0
- package/dist/bridge/agent-hook-stores.d.ts +32 -0
- package/dist/bridge/agent-hook-stores.js +67 -0
- package/dist/bridge/agent-hooks.d.ts +195 -2
- package/dist/bridge/agent-hooks.js +1049 -38
- package/dist/bridge/canary.d.ts +27 -0
- package/dist/bridge/canary.js +189 -0
- package/dist/bridge/changes.d.ts +57 -0
- package/dist/bridge/changes.js +403 -0
- package/dist/bridge/client.d.ts +3 -0
- package/dist/bridge/client.js +36 -0
- package/dist/bridge/code-note.d.ts +23 -0
- package/dist/bridge/code-note.js +51 -0
- package/dist/bridge/code-routes.d.ts +151 -0
- package/dist/bridge/code-routes.js +442 -0
- package/dist/bridge/codex-threads.d.ts +27 -0
- package/dist/bridge/codex-threads.js +442 -0
- package/dist/bridge/command.d.ts +7 -0
- package/dist/bridge/command.js +50 -5
- package/dist/bridge/computer-names.d.ts +4 -0
- package/dist/bridge/computer-names.js +16 -0
- package/dist/bridge/computers.d.ts +9 -0
- package/dist/bridge/computers.js +111 -0
- package/dist/bridge/context.d.ts +14 -0
- package/dist/bridge/context.js +149 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +93 -0
- package/dist/bridge/dispatch-hosts.d.ts +23 -0
- package/dist/bridge/dispatch-hosts.js +25 -0
- package/dist/bridge/dispatch-returns.d.ts +125 -0
- package/dist/bridge/dispatch-returns.js +283 -0
- package/dist/bridge/dispatch-tree.d.ts +54 -0
- package/dist/bridge/dispatch-tree.js +198 -0
- package/dist/bridge/dispatch.d.ts +210 -0
- package/dist/bridge/dispatch.js +286 -0
- package/dist/bridge/enroll.d.ts +31 -0
- package/dist/bridge/enroll.js +236 -0
- package/dist/bridge/fanout-messages.d.ts +74 -0
- package/dist/bridge/fanout-messages.js +230 -0
- package/dist/bridge/fanouts.d.ts +160 -0
- package/dist/bridge/fanouts.js +702 -0
- package/dist/bridge/file-range.d.ts +16 -0
- package/dist/bridge/file-range.js +90 -0
- package/dist/bridge/files.d.ts +20 -0
- package/dist/bridge/files.js +54 -0
- package/dist/bridge/git-publish.d.ts +23 -0
- package/dist/bridge/git-publish.js +145 -0
- package/dist/bridge/git-worktrees.d.ts +21 -0
- package/dist/bridge/git-worktrees.js +150 -0
- package/dist/bridge/git.d.ts +54 -0
- package/dist/bridge/git.js +552 -0
- package/dist/bridge/grants.d.ts +31 -0
- package/dist/bridge/grants.js +181 -0
- package/dist/bridge/hand-off.d.ts +79 -0
- package/dist/bridge/hand-off.js +151 -0
- package/dist/bridge/health.d.ts +128 -0
- package/dist/bridge/health.js +260 -0
- package/dist/bridge/herdr.d.ts +79 -6
- package/dist/bridge/herdr.js +292 -27
- package/dist/bridge/hook-main.js +2 -0
- package/dist/bridge/install.d.ts +28 -1
- package/dist/bridge/install.js +225 -38
- package/dist/bridge/launch-worktree.d.ts +21 -0
- package/dist/bridge/launch-worktree.js +70 -0
- package/dist/bridge/limits.d.ts +20 -0
- package/dist/bridge/limits.js +65 -0
- package/dist/bridge/locate.d.ts +16 -0
- package/dist/bridge/locate.js +75 -0
- package/dist/bridge/metrics.d.ts +29 -0
- package/dist/bridge/metrics.js +71 -0
- package/dist/bridge/model-switch.d.ts +35 -0
- package/dist/bridge/model-switch.js +250 -0
- package/dist/bridge/models.d.ts +46 -0
- package/dist/bridge/models.js +257 -0
- package/dist/bridge/opencode-approvals.d.ts +6 -0
- package/dist/bridge/opencode-approvals.js +60 -0
- package/dist/bridge/pane-text.d.ts +15 -0
- package/dist/bridge/pane-text.js +23 -0
- package/dist/bridge/peers.d.ts +27 -0
- package/dist/bridge/peers.js +130 -0
- package/dist/bridge/projects.d.ts +12 -1
- package/dist/bridge/projects.js +268 -20
- package/dist/bridge/protocol.d.ts +35 -2
- package/dist/bridge/protocol.js +61 -7
- package/dist/bridge/push.d.ts +83 -0
- package/dist/bridge/push.js +199 -0
- package/dist/bridge/questions.d.ts +38 -0
- package/dist/bridge/questions.js +205 -0
- package/dist/bridge/schedule-format.d.ts +103 -0
- package/dist/bridge/schedule-format.js +266 -0
- package/dist/bridge/schedule-launch.d.ts +11 -0
- package/dist/bridge/schedule-launch.js +169 -0
- package/dist/bridge/schedule-watch.d.ts +54 -0
- package/dist/bridge/schedule-watch.js +255 -0
- package/dist/bridge/schedules.d.ts +48 -0
- package/dist/bridge/schedules.js +205 -0
- package/dist/bridge/server-launch.d.ts +14 -0
- package/dist/bridge/server-launch.js +218 -0
- package/dist/bridge/server-overview.d.ts +45 -0
- package/dist/bridge/server-overview.js +102 -0
- package/dist/bridge/server-pane-routes.d.ts +36 -0
- package/dist/bridge/server-pane-routes.js +479 -0
- package/dist/bridge/server-routes.d.ts +108 -0
- package/dist/bridge/server-routes.js +556 -0
- package/dist/bridge/server-stream.d.ts +46 -0
- package/dist/bridge/server-stream.js +253 -0
- package/dist/bridge/server.d.ts +3 -15
- package/dist/bridge/server.js +162 -264
- package/dist/bridge/session-servers.d.ts +24 -0
- package/dist/bridge/session-servers.js +136 -0
- package/dist/bridge/side-questions.d.ts +74 -0
- package/dist/bridge/side-questions.js +252 -0
- package/dist/bridge/simulators.d.ts +28 -0
- package/dist/bridge/simulators.js +198 -0
- package/dist/bridge/speech-transcribe.d.ts +24 -0
- package/dist/bridge/speech-transcribe.js +124 -0
- package/dist/bridge/speech.d.ts +35 -0
- package/dist/bridge/speech.js +98 -0
- package/dist/bridge/steps.d.ts +13 -0
- package/dist/bridge/steps.js +222 -0
- package/dist/bridge/tab-activity.d.ts +18 -0
- package/dist/bridge/tab-activity.js +99 -0
- package/dist/bridge/terminal-choice.d.ts +64 -0
- package/dist/bridge/terminal-choice.js +281 -0
- package/dist/bridge/transcript-claude.d.ts +22 -0
- package/dist/bridge/transcript-claude.js +353 -0
- package/dist/bridge/transcript-codex.d.ts +30 -0
- package/dist/bridge/transcript-codex.js +282 -0
- package/dist/bridge/transcript-copilot.d.ts +4 -0
- package/dist/bridge/transcript-copilot.js +14 -0
- package/dist/bridge/transcript-opencode.d.ts +5 -0
- package/dist/bridge/transcript-opencode.js +26 -0
- package/dist/bridge/transcript-preview.d.ts +96 -0
- package/dist/bridge/transcript-preview.js +491 -0
- package/dist/bridge/transcripts.d.ts +81 -4
- package/dist/bridge/transcripts.js +332 -67
- package/dist/bridge/transport.d.ts +3 -0
- package/dist/bridge/transport.js +96 -15
- package/dist/bridge/uploads.d.ts +15 -0
- package/dist/bridge/uploads.js +44 -2
- package/dist/bridge/usage.d.ts +124 -0
- package/dist/bridge/usage.js +859 -0
- package/dist/bridge-hook.mjs +46545 -21051
- package/dist/cli/actions.js +14 -1
- package/dist/cli/config-policy.js +25 -0
- package/dist/cli/config-proactivity.d.ts +3 -1
- package/dist/cli/config-proactivity.js +35 -3
- package/dist/cli/config.js +4 -1
- package/dist/cli/extract.d.ts +0 -8
- package/dist/cli/extract.js +4 -7
- package/dist/cli/govern.js +5 -2
- package/dist/cli/hooks-globs.js +1 -1
- package/dist/cli/hooks.d.ts +1 -1
- package/dist/cli/hooks.js +9 -7
- package/dist/cli/namespaces-projects.js +12 -6
- package/dist/cli/namespaces-store.js +37 -6
- package/dist/cli/namespaces-tasks.js +1 -1
- package/dist/cli/schedules.d.ts +1 -0
- package/dist/cli/schedules.js +164 -0
- package/dist/cli/session-background.js +1 -1
- package/dist/cli/session-git.d.ts +8 -5
- package/dist/cli/session-git.js +45 -120
- package/dist/cli/session-start.js +3 -1
- package/dist/cli/session-stop.js +19 -8
- package/dist/cli/team.js +13 -10
- package/dist/cli-handlers.d.ts +1 -1
- package/dist/cli-handlers.js +8 -4
- package/dist/cli-help.d.ts +5 -4
- package/dist/cli-help.js +15 -15
- package/dist/cli-registry.d.ts +4 -1
- package/dist/cli-registry.js +119 -6
- package/dist/content/archive.js +2 -2
- package/dist/content/citation.d.ts +11 -0
- package/dist/content/citation.js +18 -0
- package/dist/content/learning.js +2 -0
- package/dist/content/summarize.d.ts +14 -15
- package/dist/content/summarize.js +60 -5
- package/dist/content/validate.d.ts +17 -4
- package/dist/content/validate.js +200 -122
- package/dist/core/project-registry.d.ts +26 -0
- package/dist/core/project-registry.js +573 -0
- package/dist/core/project.js +2 -3
- package/dist/data/access.d.ts +16 -1
- package/dist/data/access.js +31 -3
- package/dist/data/tasks.d.ts +18 -3
- package/dist/data/tasks.js +8 -7
- package/dist/entrypoint.js +44 -10
- package/dist/fanout/adapters/claude.d.ts +2 -0
- package/dist/fanout/adapters/claude.js +7 -0
- package/dist/fanout/adapters/codex.d.ts +2 -0
- package/dist/fanout/adapters/codex.js +9 -0
- package/dist/fanout/adapters/opencode.d.ts +4 -0
- package/dist/fanout/adapters/opencode.js +9 -0
- package/dist/fanout/adapters/types.d.ts +21 -0
- package/dist/fanout/adapters/types.js +3 -0
- package/dist/fanout/command.d.ts +2 -0
- package/dist/fanout/command.js +78 -0
- package/dist/fanout/launcher.d.ts +27 -0
- package/dist/fanout/launcher.js +156 -0
- package/dist/fanout/opencode-serve.d.ts +24 -0
- package/dist/fanout/opencode-serve.js +191 -0
- package/dist/fanout/picker.d.ts +91 -0
- package/dist/fanout/picker.js +51 -0
- package/dist/fanout/usage.d.ts +5 -0
- package/dist/fanout/usage.js +51 -0
- package/dist/fanout/watchdog.d.ts +10 -0
- package/dist/fanout/watchdog.js +27 -0
- package/dist/filenames.d.ts +9 -0
- package/dist/filenames.js +11 -0
- package/dist/finding/context.js +4 -22
- package/dist/generated/memory-ui-graph.browser.js +525 -419
- package/dist/governance/policy-constants.d.ts +11 -0
- package/dist/governance/policy-constants.js +9 -0
- package/dist/governance/policy.d.ts +5 -8
- package/dist/governance/policy.js +11 -8
- package/dist/graph-core/camera.d.ts +24 -0
- package/dist/graph-core/camera.js +18 -0
- package/dist/graph-core/index.d.ts +2 -0
- package/dist/graph-core/index.js +2 -0
- package/dist/graph-core/labels.d.ts +77 -0
- package/dist/graph-core/labels.js +124 -0
- package/dist/graph-core/model.d.ts +13 -0
- package/dist/graph-core/model.js +33 -0
- package/dist/graph-core/types.d.ts +2 -0
- package/dist/home-paths.d.ts +7 -0
- package/dist/home-paths.js +21 -0
- package/dist/hooks.d.ts +3 -15
- package/dist/hooks.js +14 -1
- package/dist/index.js +24 -2
- package/dist/init/guard-globals.d.ts +1 -1
- package/dist/init/guard-globals.js +4 -4
- package/dist/init/init-configure.js +3 -3
- package/dist/init/init-uninstall.js +15 -5
- package/dist/init/init-walkthrough.js +1 -1
- package/dist/init/init.js +26 -6
- package/dist/init/management-preset.d.ts +1 -1
- package/dist/init/management-preset.js +2 -2
- package/dist/init/preferences.js +1 -1
- package/dist/init/self-wiring.js +1 -1
- package/dist/init/setup.d.ts +3 -26
- package/dist/init/setup.js +68 -593
- package/dist/init/shared.js +2 -0
- package/dist/init/store-gitignore.d.ts +1 -6
- package/dist/init/store-gitignore.js +2 -8
- package/dist/init/teardown.d.ts +1 -1
- package/dist/init/teardown.js +2 -2
- package/dist/link/context-imports.d.ts +15 -0
- package/dist/link/context-imports.js +101 -0
- package/dist/link/context.js +1 -1
- package/dist/link/doctor.d.ts +22 -1
- package/dist/link/doctor.js +128 -58
- package/dist/link/link.js +29 -61
- package/dist/link/refresh.js +2 -2
- package/dist/link/skills.js +26 -5
- package/dist/machine-identity.d.ts +3 -0
- package/dist/machine-identity.js +6 -0
- package/dist/mcp/profile.d.ts +2 -19
- package/dist/mcp/profile.js +64 -22
- package/dist/memory-ui-graph.runtime.js +525 -419
- package/dist/modules/code-package.d.ts +16 -0
- package/dist/modules/code-package.js +160 -0
- package/dist/modules/command.d.ts +2 -0
- package/dist/modules/command.js +67 -0
- package/dist/modules/config.d.ts +4 -0
- package/dist/modules/config.js +70 -0
- package/dist/modules/manifest.d.ts +41 -0
- package/dist/modules/manifest.js +1 -0
- package/dist/modules/provision.d.ts +3 -0
- package/dist/modules/provision.js +84 -0
- package/dist/modules/registry.d.ts +16 -0
- package/dist/modules/registry.js +250 -0
- package/dist/modules/runtime.d.ts +15 -0
- package/dist/modules/runtime.js +59 -0
- package/dist/package-metadata.js +10 -2
- package/dist/phren-dotenv.js +4 -2
- package/dist/phren-paths.d.ts +3 -2
- package/dist/phren-paths.js +4 -5
- package/dist/profile-store.js +43 -8
- package/dist/project-config.d.ts +19 -1
- package/dist/project-config.js +29 -3
- package/dist/project-topics.d.ts +1 -0
- package/dist/project-topics.js +13 -10
- package/dist/provider-adapters.js +1 -4
- package/dist/query-correlation.js +6 -6
- package/dist/session/artifacts.js +5 -5
- package/dist/session/checkpoints.js +5 -0
- package/dist/session/utils.d.ts +2 -2
- package/dist/session/utils.js +6 -6
- package/dist/shared/content.d.ts +1 -1
- package/dist/shared/content.js +1 -1
- package/dist/shared/data-utils.js +1 -1
- package/dist/shared/fragment-graph.d.ts +1 -1
- package/dist/shared/fragment-graph.js +5 -5
- package/dist/shared/index.js +48 -7
- package/dist/shared/retrieval.d.ts +18 -3
- package/dist/shared/retrieval.js +101 -12
- package/dist/shared/search-fallback.js +4 -6
- package/dist/shared/sqljs.d.ts +2 -0
- package/dist/shared/sqljs.js +4 -2
- package/dist/shared.d.ts +0 -1
- package/dist/shared.js +0 -1
- package/dist/shell/input.d.ts +1 -5
- package/dist/shell/input.js +16 -10
- package/dist/shell/palette.d.ts +2 -2
- package/dist/shell/palette.js +3 -7
- package/dist/shell/render.d.ts +3 -1
- package/dist/shell/render.js +4 -4
- package/dist/shell/shell.js +4 -1
- package/dist/shell/types.d.ts +1 -0
- package/dist/shell/types.js +4 -0
- package/dist/shell/view.d.ts +0 -4
- package/dist/shell/view.js +19 -27
- package/dist/skill/registry.js +25 -17
- package/dist/skill/state.d.ts +3 -0
- package/dist/skill/state.js +13 -7
- package/dist/status.js +38 -17
- package/dist/store-registry.d.ts +44 -18
- package/dist/store-registry.js +169 -60
- package/dist/store-weight.d.ts +1 -6
- package/dist/store-weight.js +4 -2
- package/dist/sync/auth-doctor.d.ts +8 -0
- package/dist/sync/auth-doctor.js +27 -0
- package/dist/sync/auth.d.ts +27 -0
- package/dist/sync/auth.js +114 -0
- package/dist/sync/conflict-resolve.d.ts +9 -0
- package/dist/sync/conflict-resolve.js +146 -0
- package/dist/sync/git-state.d.ts +4 -0
- package/dist/sync/git-state.js +49 -0
- package/dist/sync/outcome.d.ts +34 -0
- package/dist/sync/outcome.js +57 -0
- package/dist/sync/pull.d.ts +15 -7
- package/dist/sync/pull.js +84 -35
- package/dist/sync/store-merge.d.ts +29 -0
- package/dist/sync/store-merge.js +137 -0
- package/dist/sync/task-merge.d.ts +22 -0
- package/dist/sync/task-merge.js +158 -0
- package/dist/task/github.js +1 -1
- package/dist/task/lifecycle.d.ts +5 -0
- package/dist/task/lifecycle.js +67 -23
- package/dist/terminal-text.d.ts +5 -0
- package/dist/terminal-text.js +11 -0
- package/dist/test-global-setup.js +7 -0
- package/dist/tool-registry.d.ts +1 -1
- package/dist/tool-registry.js +3 -1
- package/dist/tools/code.d.ts +3 -0
- package/dist/tools/code.js +186 -0
- package/dist/tools/config.js +8 -0
- package/dist/tools/data.js +14 -7
- package/dist/tools/dispatch.d.ts +2 -0
- package/dist/tools/dispatch.js +66 -0
- package/dist/tools/finding.d.ts +11 -0
- package/dist/tools/finding.js +180 -123
- package/dist/tools/ops.js +5 -2
- package/dist/tools/search.js +21 -8
- package/dist/tools/session.js +21 -22
- package/dist/tools/tasks.js +8 -2
- package/dist/tools/types.d.ts +2 -2
- package/dist/tools/types.js +2 -2
- package/dist/ui/assets.js +1 -1
- package/dist/ui/data.js +14 -15
- package/dist/ui/deep-void.d.ts +1 -1
- package/dist/ui/deep-void.js +0 -1
- package/dist/ui/graph-chrome.d.ts +1 -1
- package/dist/ui/graph-chrome.js +51 -0
- package/dist/ui/page.js +5 -5
- package/dist/ui/scripts.js +67 -30
- package/dist/ui/server.js +52 -7
- package/dist/update.js +22 -11
- package/dist/utils-fts.js +1 -0
- package/dist/utils-helpers.d.ts +7 -0
- package/dist/utils-helpers.js +17 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +49 -7
- package/plugins/opencode/phren-transcript.js +340 -0
- package/starter/README.md +4 -4
- package/starter/global/{CLAUDE.md → AGENTS.md} +2 -2
- package/starter/global/skills/conductor/SKILL.md +106 -0
- package/starter/global/skills/fanout/SKILL.md +20 -0
- package/starter/global/skills/phren-discover/SKILL.md +6 -6
- package/starter/global/skills/phren-init/SKILL.md +4 -4
- package/starter/global/skills/phren-sync/SKILL.md +3 -3
- package/starter/templates/frontend/reference/README.md +1 -1
- package/starter/templates/library/reference/README.md +1 -1
- package/starter/templates/monorepo/reference/README.md +1 -1
- package/starter/templates/python-project/reference/README.md +1 -1
- /package/starter/templates/frontend/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/library/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/monorepo/{CLAUDE.md → AGENTS.md} +0 -0
- /package/starter/templates/python-project/{CLAUDE.md → AGENTS.md} +0 -0
package/dist/init/shared.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as path from "path";
|
|
|
7
7
|
import { execFileSync } from "child_process";
|
|
8
8
|
import { homePath, EXEC_TIMEOUT_QUICK_MS, debugLog } from "../shared.js";
|
|
9
9
|
import { errorMessage } from "../utils.js";
|
|
10
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
10
11
|
import { ROOT as PACKAGE_ROOT, VERSION } from "../package-metadata.js";
|
|
11
12
|
export const ROOT = PACKAGE_ROOT;
|
|
12
13
|
export { VERSION };
|
|
@@ -22,6 +23,7 @@ export function commandVersion(cmd, args = ["--version"]) {
|
|
|
22
23
|
const effectiveCmd = process.platform === "win32" && (cmd === "npm" || cmd === "npx") ? `${cmd}.cmd` : cmd;
|
|
23
24
|
try {
|
|
24
25
|
return execFileSync(effectiveCmd, args, {
|
|
26
|
+
env: cmd === "git" ? nonInteractiveGitEnv() : process.env,
|
|
25
27
|
encoding: "utf8",
|
|
26
28
|
stdio: ["ignore", "pipe", "ignore"],
|
|
27
29
|
shell: process.platform === "win32" && effectiveCmd.endsWith(".cmd"),
|
|
@@ -21,9 +21,4 @@
|
|
|
21
21
|
* `phren init` writes into the store itself and which the docs tell users to
|
|
22
22
|
* put `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` / `PHREN_LLM_KEY` in.
|
|
23
23
|
*/
|
|
24
|
-
export declare const STORE_SECRET_GITIGNORE_LINES: readonly [".runtime/", ".sessions/", ".env", "*.pem", "*.key", ".config/auth-profiles.json"];
|
|
25
|
-
/**
|
|
26
|
-
* Whether a .gitignore body already covers every secret-bearing entry.
|
|
27
|
-
* Compares whole trimmed lines, so a commented-out entry does not count.
|
|
28
|
-
*/
|
|
29
|
-
export declare function missingSecretGitignoreLines(content: string): string[];
|
|
24
|
+
export declare const STORE_SECRET_GITIGNORE_LINES: readonly [".runtime/", ".sessions/", ".env", "*.pem", "*.key", ".config/auth-profiles.json", ".config/modules.yaml.migration-backup"];
|
|
@@ -37,12 +37,6 @@ export const STORE_SECRET_GITIGNORE_LINES = [
|
|
|
37
37
|
// store created before the move, or one where the migration has not run yet,
|
|
38
38
|
// never has its credentials committed.
|
|
39
39
|
".config/auth-profiles.json",
|
|
40
|
+
// Legacy module migration backups were once written into the working tree.
|
|
41
|
+
".config/modules.yaml.migration-backup",
|
|
40
42
|
];
|
|
41
|
-
/**
|
|
42
|
-
* Whether a .gitignore body already covers every secret-bearing entry.
|
|
43
|
-
* Compares whole trimmed lines, so a commented-out entry does not count.
|
|
44
|
-
*/
|
|
45
|
-
export function missingSecretGitignoreLines(content) {
|
|
46
|
-
const present = new Set(content.split("\n").map((line) => line.trim()));
|
|
47
|
-
return STORE_SECRET_GITIGNORE_LINES.filter((entry) => !present.has(entry));
|
|
48
|
-
}
|
package/dist/init/teardown.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function sweepAgentSkillSymlinks(phrenPath: string): void;
|
|
|
7
7
|
/** Remove the given exclude entries (and the phren-managed marker) from a repo's .git/info/exclude. */
|
|
8
8
|
export declare function removeGitExcludes(projectDir: string, entries: string[]): void;
|
|
9
9
|
/**
|
|
10
|
-
* Remove per-project repo mirror symlinks (
|
|
10
|
+
* Remove per-project repo mirror symlinks (AGENTS.md, REFERENCE.md, findings,
|
|
11
11
|
* AGENTS.md, CLAUDE-*.md, .github/copilot-instructions.md, .claude/skills/*) that
|
|
12
12
|
* phren created in phren-managed repos, and strip the matching exclude lines.
|
|
13
13
|
* Only removes symlinks that resolve back into the phren store.
|
package/dist/init/teardown.js
CHANGED
|
@@ -147,7 +147,7 @@ export function removeGitExcludes(projectDir, entries) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* Remove per-project repo mirror symlinks (
|
|
150
|
+
* Remove per-project repo mirror symlinks (AGENTS.md, REFERENCE.md, findings,
|
|
151
151
|
* AGENTS.md, CLAUDE-*.md, .github/copilot-instructions.md, .claude/skills/*) that
|
|
152
152
|
* phren created in phren-managed repos, and strip the matching exclude lines.
|
|
153
153
|
* Only removes symlinks that resolve back into the phren store.
|
|
@@ -213,7 +213,7 @@ export function sweepProjectMirrors(phrenPath) {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
// Fixed mirror files.
|
|
216
|
-
for (const f of ["
|
|
216
|
+
for (const f of ["AGENTS.md", "CLAUDE.md", "REFERENCE.md", FINDINGS_FILENAME, path.join(".github", "copilot-instructions.md")]) {
|
|
217
217
|
removeMirror(f);
|
|
218
218
|
}
|
|
219
219
|
// CLAUDE-*.md split files.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ContextImportHit {
|
|
2
|
+
scope: string;
|
|
3
|
+
file: string;
|
|
4
|
+
line: number;
|
|
5
|
+
target: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function findContextImportLines(content: string): Array<{
|
|
8
|
+
line: number;
|
|
9
|
+
target: string;
|
|
10
|
+
}>;
|
|
11
|
+
/** Turn each run of `@path` lines into one plain reference list. */
|
|
12
|
+
export declare function rewriteContextImports(content: string): string;
|
|
13
|
+
export declare function scanContextImports(phrenPath: string): ContextImportHit[];
|
|
14
|
+
/** Rewrite every flagged file in place; returns the files changed. */
|
|
15
|
+
export declare function fixContextImports(phrenPath: string, hits: ContextImportHit[]): string[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { AGENT_INSTRUCTIONS_FILENAME, LEGACY_AGENT_INSTRUCTIONS_FILENAME } from "../agent-instructions.js";
|
|
4
|
+
import { atomicWriteText, debugLog, getProjectDirs } from "../shared.js";
|
|
5
|
+
import { errorMessage } from "../utils.js";
|
|
6
|
+
// Claude Code expands `@path` lines in CLAUDE.md as file imports, resolved
|
|
7
|
+
// against the real location of the file. A repo's CLAUDE.md is a symlink into
|
|
8
|
+
// the store, so every such import lands in ~/.phren/<project>/... — outside
|
|
9
|
+
// the repo — and Claude Code (2.1.278+) blocks on an "Allow external CLAUDE.md
|
|
10
|
+
// file imports?" dialog per project, or silently drops the import headless.
|
|
11
|
+
// The archive is retrieved by the hook on demand anyway, so the fix is a plain
|
|
12
|
+
// mention instead of an import.
|
|
13
|
+
const IMPORT_LINE_RE = /^@(?![a-z0-9-]+\/[a-z0-9-]+$)(\S+)\s*$/i;
|
|
14
|
+
export function findContextImportLines(content) {
|
|
15
|
+
const hits = [];
|
|
16
|
+
let inFence = false;
|
|
17
|
+
content.split("\n").forEach((raw, i) => {
|
|
18
|
+
const line = raw.trimEnd();
|
|
19
|
+
if (/^\s*(```|~~~)/.test(line)) {
|
|
20
|
+
inFence = !inFence;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (inFence)
|
|
24
|
+
return;
|
|
25
|
+
const m = IMPORT_LINE_RE.exec(line);
|
|
26
|
+
if (m)
|
|
27
|
+
hits.push({ line: i + 1, target: m[1] });
|
|
28
|
+
});
|
|
29
|
+
return hits;
|
|
30
|
+
}
|
|
31
|
+
/** Turn each run of `@path` lines into one plain reference list. */
|
|
32
|
+
export function rewriteContextImports(content) {
|
|
33
|
+
const lines = content.split("\n");
|
|
34
|
+
const flagged = new Set(findContextImportLines(content).map((h) => h.line - 1));
|
|
35
|
+
const out = [];
|
|
36
|
+
for (let i = 0; i < lines.length; i++) {
|
|
37
|
+
if (!flagged.has(i)) {
|
|
38
|
+
out.push(lines[i]);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const run = [];
|
|
42
|
+
while (i < lines.length && (flagged.has(i) || (run.length && lines[i].trim() === "" && flagged.has(i + 1)))) {
|
|
43
|
+
if (flagged.has(i))
|
|
44
|
+
run.push(lines[i].trim().slice(1));
|
|
45
|
+
i++;
|
|
46
|
+
}
|
|
47
|
+
i--;
|
|
48
|
+
out.push("Reference docs (the phren hook injects relevant parts on demand; not imported):");
|
|
49
|
+
for (const target of run)
|
|
50
|
+
out.push(`- \`${target}\``);
|
|
51
|
+
}
|
|
52
|
+
return out.join("\n");
|
|
53
|
+
}
|
|
54
|
+
function contextFilesIn(dir) {
|
|
55
|
+
return [AGENT_INSTRUCTIONS_FILENAME, LEGACY_AGENT_INSTRUCTIONS_FILENAME]
|
|
56
|
+
.map((name) => path.join(dir, name))
|
|
57
|
+
.filter((file) => {
|
|
58
|
+
try {
|
|
59
|
+
return fs.lstatSync(file).isFile();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function scanContextImports(phrenPath) {
|
|
67
|
+
const hits = [];
|
|
68
|
+
const scopeDirs = [path.join(phrenPath, "global"), ...getProjectDirs(phrenPath)];
|
|
69
|
+
for (const dir of scopeDirs) {
|
|
70
|
+
for (const file of contextFilesIn(dir)) {
|
|
71
|
+
let content;
|
|
72
|
+
try {
|
|
73
|
+
content = fs.readFileSync(file, "utf8");
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
for (const hit of findContextImportLines(content))
|
|
79
|
+
hits.push({ scope: path.basename(dir), file, ...hit });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return hits;
|
|
83
|
+
}
|
|
84
|
+
/** Rewrite every flagged file in place; returns the files changed. */
|
|
85
|
+
export function fixContextImports(phrenPath, hits) {
|
|
86
|
+
const fixed = [];
|
|
87
|
+
for (const file of [...new Set(hits.map((h) => h.file))]) {
|
|
88
|
+
try {
|
|
89
|
+
const content = fs.readFileSync(file, "utf8");
|
|
90
|
+
const next = rewriteContextImports(content);
|
|
91
|
+
if (next !== content) {
|
|
92
|
+
atomicWriteText(file, next);
|
|
93
|
+
fixed.push(file);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
debugLog(`context-imports: could not rewrite ${file}: ${errorMessage(err)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return fixed;
|
|
101
|
+
}
|
package/dist/link/context.js
CHANGED
|
@@ -212,7 +212,7 @@ export function rebuildMemory(phrenPath, projects) {
|
|
|
212
212
|
managed += `| ${displayName(project)} | ${what} | MEMORY-${project}.md |\n`;
|
|
213
213
|
}
|
|
214
214
|
managed += "\n<!-- phren:projects:end -->";
|
|
215
|
-
const freshHeader = "# Root Memory\n\n## Machine Context\nRead `~/.phren-context.md` for profile, active projects, last sync date.\n\n## Cross-Project Notes\n- Read a project's
|
|
215
|
+
const freshHeader = "# Root Memory\n\n## Machine Context\nRead `~/.phren-context.md` for profile, active projects, last sync date.\n\n## Cross-Project Notes\n- Read a project's AGENTS.md before making changes.\n- Per-project memory files (MEMORY-{name}.md) have commands, versions, findings.\n\n";
|
|
216
216
|
fs.writeFileSync(memoryFile, (header || freshHeader) + managed + "\n");
|
|
217
217
|
log(` rebuilt ${memoryFile} (pointer format)`);
|
|
218
218
|
const SUMMARY_START = "<!-- phren:summary:start -->";
|
package/dist/link/doctor.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import type { DoctorResult } from "./link.js";
|
|
2
|
-
|
|
2
|
+
import { type ConfirmStoreRemoval } from "../sync/auth-doctor.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where `tool` stands relative to its ~/.local/bin wrapper, as far as this
|
|
5
|
+
* process can tell. Doctor often runs without the user's shell setup (over
|
|
6
|
+
* SSH, from a hook or a LaunchAgent), where ~/.local/bin is added only by
|
|
7
|
+
* .zshrc; then PATH says nothing about what the user's shell runs, and an
|
|
8
|
+
* installed wrapper is reported as unconfirmed rather than missing.
|
|
9
|
+
*/
|
|
10
|
+
export type WrapperState = {
|
|
11
|
+
state: "active" | "missing" | "off-path";
|
|
12
|
+
} | {
|
|
13
|
+
state: "shadowed";
|
|
14
|
+
by: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function wrapperState(tool: string, env?: NodeJS.ProcessEnv, resolve?: (tool: string) => string): WrapperState;
|
|
17
|
+
/** One doctor line per wrapper. The phren wrapper works off PATH too: hooks call it by its full path. */
|
|
18
|
+
export declare function wrapperCheck(tool: string, state: WrapperState): {
|
|
19
|
+
name: string;
|
|
20
|
+
ok: boolean;
|
|
21
|
+
detail: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function runDoctor(phrenPath: string, fix?: boolean, checkData?: boolean, confirmStoreRemoval?: ConfirmStoreRemoval): Promise<DoctorResult>;
|
package/dist/link/doctor.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 { execFileSync } from "child_process";
|
|
@@ -10,7 +11,7 @@ import { validateGovernanceJson } from "../shared/governance.js";
|
|
|
10
11
|
import { errorMessage } from "../utils.js";
|
|
11
12
|
import { buildIndex, queryRows } from "../shared/index.js";
|
|
12
13
|
import { validateTaskFormat, validateFindingsFormat } from "../shared/content.js";
|
|
13
|
-
import { detectInstalledTools, isEphemeralNpxPath, findStaleHookEntrypoints } from "../hooks.js";
|
|
14
|
+
import { commandExists, detectInstalledTools, isEphemeralNpxPath, findStaleHookEntrypoints } from "../hooks.js";
|
|
14
15
|
import { validateSkillFrontmatter, validateSkillsDir } from "./skills.js";
|
|
15
16
|
import { verifyFileChecksums, updateFileChecksums } from "./checksums.js";
|
|
16
17
|
import { buildSkillManifest } from "../skill/registry.js";
|
|
@@ -21,38 +22,77 @@ import { repairPreexistingInstall } from "../init/setup.js";
|
|
|
21
22
|
import { getManagementPreset, resolveManagementCapabilities } from "../init/management-preset.js";
|
|
22
23
|
import { getMachineName, lookupProfile, findProfileFile, getProfileProjects, findProjectDir, } from "./link.js";
|
|
23
24
|
import { claudeProjectKey } from "./context.js";
|
|
25
|
+
import { scanContextImports, fixContextImports } from "./context-imports.js";
|
|
24
26
|
import { getProjectOwnershipMode, readProjectConfig } from "../project-config.js";
|
|
25
27
|
import { readInstallPreferences } from "../init/preferences.js";
|
|
26
28
|
import { logger } from "../logger.js";
|
|
27
29
|
import { CONTEXT_COST_LIMITS, medianHookInjectionTokens, storeWeight } from "../store-weight.js";
|
|
28
30
|
import { resolveMcpProfile } from "../mcp/profile.js";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
import { activeStoreAuthFailure, isGitAuthFailure, recordStoreAuthFailure, storeAuthDetail, storeSyncRemote } from "../sync/auth.js";
|
|
32
|
+
import { storeCredentialCheck } from "../sync/auth-doctor.js";
|
|
33
|
+
import { describeAutoSave } from "../sync/outcome.js";
|
|
34
|
+
export function wrapperState(tool, env = process.env, resolve = resolveOnPath) {
|
|
31
35
|
const isWindows = process.platform === "win32";
|
|
32
|
-
const
|
|
33
|
-
const wrapperPath = homePath(".local", "bin", wrapperName);
|
|
36
|
+
const wrapperPath = homePath(".local", "bin", isWindows ? `${tool}.cmd` : tool);
|
|
34
37
|
if (!fs.existsSync(wrapperPath))
|
|
35
|
-
return
|
|
38
|
+
return { state: "missing" };
|
|
39
|
+
const same = (a, b) => path.resolve(a).toLowerCase() === path.resolve(b).toLowerCase();
|
|
40
|
+
const dirs = (env.PATH ?? env.Path ?? "").split(path.delimiter).filter(Boolean);
|
|
41
|
+
if (!dirs.some((dir) => same(dir, path.dirname(wrapperPath))))
|
|
42
|
+
return { state: "off-path" };
|
|
43
|
+
const first = resolve(tool);
|
|
44
|
+
return first && same(first, wrapperPath) ? { state: "active" } : { state: "shadowed", by: first };
|
|
45
|
+
}
|
|
46
|
+
function resolveOnPath(tool) {
|
|
36
47
|
try {
|
|
37
|
-
const
|
|
38
|
-
const whichArgs = isWindows ? [tool] : [tool];
|
|
39
|
-
const raw = execFileSync(whichCmd, whichArgs, {
|
|
48
|
+
const raw = execFileSync(process.platform === "win32" ? "where.exe" : "which", [tool], {
|
|
40
49
|
encoding: "utf8",
|
|
41
50
|
stdio: ["ignore", "pipe", "ignore"],
|
|
42
51
|
timeout: EXEC_TIMEOUT_QUICK_MS,
|
|
43
52
|
}).trim();
|
|
44
53
|
// `where.exe` can print multiple paths, one per line; check the first hit.
|
|
45
|
-
|
|
46
|
-
return path.resolve(first).toLowerCase() === path.resolve(wrapperPath).toLowerCase();
|
|
54
|
+
return raw.split(/\r?\n/).map((line) => line.trim()).find(Boolean) ?? "";
|
|
47
55
|
}
|
|
48
56
|
catch (err) {
|
|
49
|
-
debugLog(`
|
|
50
|
-
return
|
|
57
|
+
debugLog(`wrapperState: resolve ${tool} failed: ${errorMessage(err)}`);
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** One doctor line per wrapper. The phren wrapper works off PATH too: hooks call it by its full path. */
|
|
62
|
+
export function wrapperCheck(tool, state) {
|
|
63
|
+
const where = `~/.local/bin/${tool}${process.platform === "win32" ? ".cmd" : ""}`;
|
|
64
|
+
const name = tool === "phren" ? "wrapper:phren-cli" : `wrapper:${tool}`;
|
|
65
|
+
const label = tool === "phren" ? "phren CLI" : tool;
|
|
66
|
+
switch (state.state) {
|
|
67
|
+
case "active":
|
|
68
|
+
return { name, ok: true, detail: `${label} wrapper active via ${where}` };
|
|
69
|
+
case "off-path":
|
|
70
|
+
return {
|
|
71
|
+
name, ok: true,
|
|
72
|
+
detail: `${label} wrapper installed at ${where}; ~/.local/bin is not on this process's PATH ` +
|
|
73
|
+
`(shell startup files such as .zshrc add it only to interactive shells), so doctor cannot confirm it comes first there`,
|
|
74
|
+
};
|
|
75
|
+
case "shadowed":
|
|
76
|
+
return {
|
|
77
|
+
name, ok: false,
|
|
78
|
+
detail: state.by
|
|
79
|
+
? `${tool} resolves to ${state.by} before the wrapper at ${where}; move ~/.local/bin earlier in PATH`
|
|
80
|
+
: `${label} wrapper at ${where} is on PATH but does not run; check that it is executable`,
|
|
81
|
+
};
|
|
82
|
+
case "missing":
|
|
83
|
+
return {
|
|
84
|
+
name, ok: false,
|
|
85
|
+
detail: tool === "phren" ? "phren CLI wrapper missing — run 'npx @phren/cli init' to install" : `${tool} wrapper missing`,
|
|
86
|
+
};
|
|
51
87
|
}
|
|
52
88
|
}
|
|
53
89
|
function gitRemoteStatus(phrenPath, syncIntent) {
|
|
90
|
+
const auth = activeStoreAuthFailure(phrenPath);
|
|
91
|
+
if (auth)
|
|
92
|
+
return { ok: false, detail: storeAuthDetail(auth) };
|
|
54
93
|
try {
|
|
55
94
|
execFileSync("git", ["-C", phrenPath, "rev-parse", "--is-inside-work-tree"], {
|
|
95
|
+
env: nonInteractiveGitEnv(),
|
|
56
96
|
stdio: ["ignore", "ignore", "ignore"],
|
|
57
97
|
timeout: EXEC_TIMEOUT_QUICK_MS,
|
|
58
98
|
});
|
|
@@ -61,8 +101,10 @@ function gitRemoteStatus(phrenPath, syncIntent) {
|
|
|
61
101
|
return { ok: false, detail: "phren path is not a git repository" };
|
|
62
102
|
}
|
|
63
103
|
let remote;
|
|
104
|
+
const remoteName = storeSyncRemote(phrenPath)?.remoteName || "origin";
|
|
64
105
|
try {
|
|
65
|
-
remote = execFileSync("git", ["-C", phrenPath, "remote", "get-url", "
|
|
106
|
+
remote = execFileSync("git", ["-C", phrenPath, "remote", "get-url", "--", remoteName], {
|
|
107
|
+
env: nonInteractiveGitEnv(),
|
|
66
108
|
encoding: "utf8",
|
|
67
109
|
stdio: ["ignore", "pipe", "ignore"],
|
|
68
110
|
timeout: EXEC_TIMEOUT_QUICK_MS,
|
|
@@ -82,17 +124,21 @@ function gitRemoteStatus(phrenPath, syncIntent) {
|
|
|
82
124
|
}
|
|
83
125
|
// Remote exists — verify it's reachable
|
|
84
126
|
try {
|
|
85
|
-
execFileSync("git", ["-C", phrenPath, "ls-remote", "--exit-code", "
|
|
86
|
-
|
|
127
|
+
execFileSync("git", ["-C", phrenPath, "ls-remote", "--exit-code", "--", remoteName], {
|
|
128
|
+
env: nonInteractiveGitEnv(),
|
|
129
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
87
130
|
timeout: 10_000,
|
|
88
131
|
});
|
|
89
|
-
return { ok: true, detail:
|
|
132
|
+
return { ok: true, detail: `${remoteName}=${remote}` };
|
|
90
133
|
}
|
|
91
|
-
catch {
|
|
134
|
+
catch (err) {
|
|
135
|
+
if (isGitAuthFailure(err)) {
|
|
136
|
+
return { ok: false, detail: storeAuthDetail(recordStoreAuthFailure(phrenPath, remoteName, remote)) };
|
|
137
|
+
}
|
|
92
138
|
if (syncIntent === "sync") {
|
|
93
|
-
return { ok: false, detail:
|
|
139
|
+
return { ok: false, detail: `${remoteName}=${remote} (unreachable); check your network or SSH keys` };
|
|
94
140
|
}
|
|
95
|
-
return { ok: true, detail:
|
|
141
|
+
return { ok: true, detail: `${remoteName}=${remote} (unreachable, local-only mode)` };
|
|
96
142
|
}
|
|
97
143
|
}
|
|
98
144
|
/**
|
|
@@ -107,6 +153,7 @@ function rootConfigStatus(phrenPath, filename) {
|
|
|
107
153
|
}
|
|
108
154
|
try {
|
|
109
155
|
execFileSync("git", ["cat-file", "-e", `HEAD:${filename}`], {
|
|
156
|
+
env: nonInteractiveGitEnv(),
|
|
110
157
|
cwd: phrenPath,
|
|
111
158
|
stdio: "ignore",
|
|
112
159
|
timeout: EXEC_TIMEOUT_QUICK_MS,
|
|
@@ -121,6 +168,7 @@ function rootConfigStatus(phrenPath, filename) {
|
|
|
121
168
|
function materializeRootConfig(phrenPath, filename) {
|
|
122
169
|
try {
|
|
123
170
|
execFileSync("git", ["sparse-checkout", "add", `/${filename}`], {
|
|
171
|
+
env: nonInteractiveGitEnv(),
|
|
124
172
|
cwd: phrenPath,
|
|
125
173
|
stdio: "ignore",
|
|
126
174
|
timeout: EXEC_TIMEOUT_QUICK_MS,
|
|
@@ -172,7 +220,7 @@ function pushSkillMirrorChecks(checks, scope, manifest, destDir) {
|
|
|
172
220
|
});
|
|
173
221
|
}
|
|
174
222
|
}
|
|
175
|
-
export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
223
|
+
export async function runDoctor(phrenPath, fix = false, checkData = false, confirmStoreRemoval) {
|
|
176
224
|
// Import runLink lazily to avoid circular dependency at module load time
|
|
177
225
|
const { runLink } = await import("./link.js");
|
|
178
226
|
const checks = [];
|
|
@@ -283,35 +331,38 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
283
331
|
? "could not benchmark filesystem, check ~/.phren permissions"
|
|
284
332
|
: `write+read+delete in ${fsMs}ms${fsSlow ? " (slow, check if ~/.phren is on a network mount)" : ""}`,
|
|
285
333
|
});
|
|
334
|
+
// Both generated home files are self-heal surfaces; under a preset without
|
|
335
|
+
// selfHeal a missing one is expected, not a failure.
|
|
336
|
+
const notSelfHealed = `not re-created under ${managementPreset} preset`;
|
|
286
337
|
const contextFile = homePath(".phren-context.md");
|
|
287
338
|
checks.push({
|
|
288
339
|
name: "context-file",
|
|
289
|
-
ok: fs.existsSync(contextFile),
|
|
290
|
-
detail: fs.existsSync(contextFile) ? contextFile : "missing ~/.phren-context.md",
|
|
340
|
+
ok: fs.existsSync(contextFile) || !caps.selfHeal,
|
|
341
|
+
detail: fs.existsSync(contextFile) ? contextFile : caps.selfHeal ? "missing ~/.phren-context.md" : notSelfHealed,
|
|
291
342
|
});
|
|
292
343
|
const memoryFile = path.join(homeDir(), ".claude", "projects", claudeProjectKey(), "memory", "MEMORY.md");
|
|
293
344
|
checks.push({
|
|
294
345
|
name: "root-memory",
|
|
295
|
-
ok: fs.existsSync(memoryFile),
|
|
296
|
-
detail: fs.existsSync(memoryFile) ? memoryFile : "missing generated MEMORY.md",
|
|
346
|
+
ok: fs.existsSync(memoryFile) || !caps.selfHeal,
|
|
347
|
+
detail: fs.existsSync(memoryFile) ? memoryFile : caps.selfHeal ? "missing generated MEMORY.md" : notSelfHealed,
|
|
297
348
|
});
|
|
298
349
|
// Under presets that don't symlink into ~/.claude, the "missing" links are
|
|
299
350
|
// expected — report them as ok with a preset note instead of failures.
|
|
300
351
|
if (caps.linkGlobalClaudeMd) {
|
|
301
|
-
const globalClaudeSrc = path.join(phrenPath, "global", "
|
|
352
|
+
const globalClaudeSrc = path.join(phrenPath, "global", "AGENTS.md");
|
|
302
353
|
const globalClaudeDest = homePath(".claude", "CLAUDE.md");
|
|
303
354
|
let globalLinkOk = false;
|
|
304
355
|
try {
|
|
305
356
|
globalLinkOk = fs.existsSync(globalClaudeDest) && fs.realpathSync(globalClaudeDest) === fs.realpathSync(globalClaudeSrc);
|
|
306
357
|
}
|
|
307
358
|
catch (err) {
|
|
308
|
-
debugLog(`doctor: global
|
|
359
|
+
debugLog(`doctor: global AGENTS.md symlink check failed: ${errorMessage(err)}`);
|
|
309
360
|
globalLinkOk = false;
|
|
310
361
|
}
|
|
311
362
|
checks.push({
|
|
312
363
|
name: "global-link",
|
|
313
364
|
ok: globalLinkOk,
|
|
314
|
-
detail: globalLinkOk ? "global
|
|
365
|
+
detail: globalLinkOk ? "global AGENTS.md symlink ok" : "global AGENTS.md link drifted/missing",
|
|
315
366
|
});
|
|
316
367
|
}
|
|
317
368
|
else {
|
|
@@ -353,7 +404,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
353
404
|
checks.push({ name: `project-path:${project}`, ok: false, detail: "project directory not found on disk" });
|
|
354
405
|
continue;
|
|
355
406
|
}
|
|
356
|
-
for (const f of ["
|
|
407
|
+
for (const f of ["AGENTS.md", "REFERENCE.md", FINDINGS_FILENAME]) {
|
|
357
408
|
const src = path.join(phrenPath, project, f);
|
|
358
409
|
if (!fs.existsSync(src))
|
|
359
410
|
continue;
|
|
@@ -376,17 +427,27 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
376
427
|
}
|
|
377
428
|
// Store registry health
|
|
378
429
|
try {
|
|
379
|
-
const { resolveAllStores, storesFilePath, describeUnavailableStore } = await import("../store-registry.js");
|
|
380
|
-
|
|
381
|
-
if (fs.existsSync(storesFile)) {
|
|
430
|
+
const { resolveAllStores, storesFilePath, attachedStoresFilePath, describeUnavailableStore, ignoredSyncedStores } = await import("../store-registry.js");
|
|
431
|
+
if (fs.existsSync(storesFilePath(phrenPath)) || fs.existsSync(attachedStoresFilePath(phrenPath))) {
|
|
382
432
|
const stores = resolveAllStores(phrenPath);
|
|
383
433
|
checks.push({
|
|
384
434
|
name: "store-registry",
|
|
385
435
|
ok: stores.length > 0,
|
|
386
436
|
detail: stores.length > 0
|
|
387
|
-
? `${stores.length} stores
|
|
437
|
+
? `${stores.length} stores on this machine`
|
|
388
438
|
: "stores.yaml exists but no stores parsed",
|
|
389
439
|
});
|
|
440
|
+
// Only this machine's attachments are checked. Team stores another
|
|
441
|
+
// machine joined with an older phren still sit in the synced file.
|
|
442
|
+
const ignored = ignoredSyncedStores(phrenPath);
|
|
443
|
+
if (ignored.length > 0) {
|
|
444
|
+
checks.push({
|
|
445
|
+
name: "store-registry-synced",
|
|
446
|
+
ok: true,
|
|
447
|
+
detail: `ignoring ${ignored.map((s) => s.name).join(", ")} in the synced ${path.basename(storesFilePath(phrenPath))}: ` +
|
|
448
|
+
`team stores are attached per machine (${attachedStoresFilePath(phrenPath)}); remove them from stores.yaml once every machine runs this phren`,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
390
451
|
// Projects claimed by a store that is not attached here cannot be written
|
|
391
452
|
// at all — phren refuses rather than diverting them to the primary store.
|
|
392
453
|
const orphanedClaims = stores
|
|
@@ -400,6 +461,11 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
400
461
|
: `projects claimed by unattached stores (writes to them will fail): ${orphanedClaims.join("; ")}`,
|
|
401
462
|
});
|
|
402
463
|
for (const store of stores) {
|
|
464
|
+
const credentials = await storeCredentialCheck(phrenPath, store, fix, confirmStoreRemoval);
|
|
465
|
+
if (credentials) {
|
|
466
|
+
checks.push(credentials);
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
403
469
|
const pathExists = store.available !== false;
|
|
404
470
|
const gitExists = pathExists && fs.existsSync(path.join(store.path, ".git"));
|
|
405
471
|
if (!pathExists) {
|
|
@@ -552,7 +618,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
552
618
|
const injection = medianHookInjectionTokens(phrenPath);
|
|
553
619
|
const problems = [];
|
|
554
620
|
if (weight.globalClaude > CONTEXT_COST_LIMITS.globalClaudeWords)
|
|
555
|
-
problems.push(`global
|
|
621
|
+
problems.push(`global AGENTS.md is ${weight.globalClaude} words (aim under ${CONTEXT_COST_LIMITS.globalClaudeWords})`);
|
|
556
622
|
if (profile === "full")
|
|
557
623
|
problems.push("MCP profile is full (61 tools, ~53k chars of schema per session); `phren config mcp-profile core` is ~17k");
|
|
558
624
|
if (injection.medianTokens > CONTEXT_COST_LIMITS.medianInjectionTokens)
|
|
@@ -562,7 +628,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
562
628
|
ok: problems.length === 0,
|
|
563
629
|
detail: problems.length
|
|
564
630
|
? problems.join("; ")
|
|
565
|
-
: `global
|
|
631
|
+
: `global AGENTS.md ${weight.globalClaude} words · MCP profile ${profile} (${profile === "core" ? "10 tools, ~17k chars" : "61 tools, ~53k chars"})${injection.prompts ? ` · median injection ${injection.medianTokens} tokens over ${injection.prompts} prompts` : ""} · store: findings ${weight.findings.toLocaleString("en-US")} words, archive ${weight.reference.toLocaleString("en-US")}, tasks ${weight.tasks.toLocaleString("en-US")}, skills ${weight.skills.toLocaleString("en-US")}`,
|
|
566
632
|
});
|
|
567
633
|
}
|
|
568
634
|
catch (err) {
|
|
@@ -580,9 +646,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
580
646
|
checks.push({
|
|
581
647
|
name: "runtime-auto-save",
|
|
582
648
|
ok: autoSaveStatus === "saved-pushed" || autoSaveStatus === "saved-local" || autoSaveStatus === "clean",
|
|
583
|
-
detail: autoSaveStatus
|
|
584
|
-
? `last auto-save: ${autoSaveStatus}${autoSaveAt ? ` @ ${autoSaveAt}` : ""}`
|
|
585
|
-
: "no auto-save runtime record yet",
|
|
649
|
+
detail: describeAutoSave({ status: autoSaveStatus, at: autoSaveAt, detail: typeof autoSaveObj?.["detail"] === "string" ? autoSaveObj["detail"] : undefined }, isRecord(runtime?.["lastSync"]) ? runtime["lastSync"] : undefined),
|
|
586
650
|
});
|
|
587
651
|
checks.push({
|
|
588
652
|
name: "runtime-prompt",
|
|
@@ -649,28 +713,14 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
649
713
|
detail: codexWritable ? `writable: ${codexHooks}` : `not writable: ${codexHooks}`,
|
|
650
714
|
});
|
|
651
715
|
}
|
|
652
|
-
const wrapperSuffix = process.platform === "win32" ? ".cmd" : "";
|
|
653
716
|
for (const tool of ["copilot", "cursor", "codex"]) {
|
|
654
|
-
|
|
717
|
+
// A tool can count as detected from its config folder alone (Copilot's
|
|
718
|
+
// ~/.copilot, say); a wrapper only makes sense around a binary on PATH.
|
|
719
|
+
if (!detected.has(tool) || !commandExists(tool))
|
|
655
720
|
continue;
|
|
656
|
-
|
|
657
|
-
checks.push({
|
|
658
|
-
name: `wrapper:${tool}`,
|
|
659
|
-
ok: active,
|
|
660
|
-
detail: active
|
|
661
|
-
? `${tool} wrapper active via ~/.local/bin/${tool}${wrapperSuffix}`
|
|
662
|
-
: `${tool} wrapper missing or not first in PATH`,
|
|
663
|
-
});
|
|
721
|
+
checks.push(wrapperCheck(tool, wrapperState(tool)));
|
|
664
722
|
}
|
|
665
|
-
|
|
666
|
-
const phrenCliActive = isWrapperActive("phren");
|
|
667
|
-
checks.push({
|
|
668
|
-
name: "wrapper:phren-cli",
|
|
669
|
-
ok: phrenCliActive,
|
|
670
|
-
detail: phrenCliActive
|
|
671
|
-
? `phren CLI wrapper active via ~/.local/bin/phren${wrapperSuffix}`
|
|
672
|
-
: "phren CLI wrapper missing — run 'npx @phren/cli init' to install",
|
|
673
|
-
});
|
|
723
|
+
checks.push(wrapperCheck("phren", wrapperState("phren")));
|
|
674
724
|
if (fix) {
|
|
675
725
|
const repaired = repairPreexistingInstall(phrenPath);
|
|
676
726
|
const details = [];
|
|
@@ -789,7 +839,7 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
789
839
|
const projectName = path.basename(projectDir);
|
|
790
840
|
if (projectName === "global")
|
|
791
841
|
continue;
|
|
792
|
-
for (const mdFile of [FINDINGS_FILENAME, ...TASK_FILE_ALIASES, "review.md", "
|
|
842
|
+
for (const mdFile of [FINDINGS_FILENAME, ...TASK_FILE_ALIASES, "review.md", "AGENTS.md", "REFERENCE.md"]) {
|
|
793
843
|
const filePath = path.join(projectDir, mdFile);
|
|
794
844
|
if (!fs.existsSync(filePath))
|
|
795
845
|
continue;
|
|
@@ -864,6 +914,26 @@ export async function runDoctor(phrenPath, fix = false, checkData = false) {
|
|
|
864
914
|
catch (err) {
|
|
865
915
|
debugLog(`doctor: zombie task scan failed: ${errorMessage(err)}`);
|
|
866
916
|
}
|
|
917
|
+
// `@path` import lines in store-managed AGENTS.md/CLAUDE.md resolve outside
|
|
918
|
+
// the repo (the repo file is a symlink into the store), so Claude Code blocks
|
|
919
|
+
// on its external-imports dialog. With --fix, rewrite them as plain mentions.
|
|
920
|
+
try {
|
|
921
|
+
const importHits = scanContextImports(phrenPath);
|
|
922
|
+
const fixedFiles = importHits.length && fix ? fixContextImports(phrenPath, importHits) : [];
|
|
923
|
+
const scopes = [...new Set(importHits.map((h) => h.scope))];
|
|
924
|
+
checks.push({
|
|
925
|
+
name: "context-imports",
|
|
926
|
+
ok: importHits.length === 0 || fixedFiles.length > 0,
|
|
927
|
+
detail: importHits.length === 0
|
|
928
|
+
? "no @imports in managed AGENTS.md/CLAUDE.md"
|
|
929
|
+
: fixedFiles.length
|
|
930
|
+
? `rewrote ${importHits.length} @import line(s) as plain references in ${fixedFiles.length} file(s) (${scopes.join(", ")})`
|
|
931
|
+
: `${importHits.length} @import line(s) in ${scopes.join(", ")} resolve outside the repo and trigger Claude Code's "Allow external CLAUDE.md file imports?" dialog. Run \`phren doctor --fix\` to rewrite them as plain references.`,
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
catch (err) {
|
|
935
|
+
debugLog(`doctor: context-imports scan failed: ${errorMessage(err)}`);
|
|
936
|
+
}
|
|
867
937
|
const ok = checks.every((c) => c.ok);
|
|
868
938
|
return { ok, machine, profile: profile || undefined, checks };
|
|
869
939
|
}
|