@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/session-git.js
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
* Extracted from hooks-session.ts for modularity.
|
|
4
4
|
*/
|
|
5
5
|
import { execFileSync } from "child_process";
|
|
6
|
-
import * as fs from "fs";
|
|
7
6
|
import * as path from "path";
|
|
8
|
-
import { EXEC_TIMEOUT_MS, debugLog
|
|
9
|
-
import { runGit } from "../utils.js";
|
|
10
|
-
import {
|
|
7
|
+
import { EXEC_TIMEOUT_MS, debugLog } from "../shared.js";
|
|
8
|
+
import { errorMessage, runGit } from "../utils.js";
|
|
9
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
11
10
|
import { withFileLock } from "../governance/locks.js";
|
|
12
11
|
import { runtimeFile } from "../phren-paths.js";
|
|
13
|
-
import {
|
|
12
|
+
import { mergeStoreUpstream } from "../sync/store-merge.js";
|
|
13
|
+
import { aheadBehind, logSyncOutcome } from "../sync/outcome.js";
|
|
14
|
+
import { activeStoreAuthFailure, authBackoffActive, isGitAuthFailure, storeAuthDetail, withStoreAuthBackoff } from "../sync/auth.js";
|
|
14
15
|
export function getGitContext(cwd) {
|
|
15
16
|
if (!cwd)
|
|
16
17
|
return null;
|
|
@@ -42,7 +43,7 @@ function shouldRetryGitCommand(args) {
|
|
|
42
43
|
const cmd = args[0] || "";
|
|
43
44
|
return cmd === "push" || cmd === "pull" || cmd === "fetch";
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
async function runBestEffortGitCommand(args, cwd) {
|
|
46
47
|
const retries = shouldRetryGitCommand(args) ? 2 : 0;
|
|
47
48
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
48
49
|
try {
|
|
@@ -51,27 +52,32 @@ export async function runBestEffortGit(args, cwd) {
|
|
|
51
52
|
encoding: "utf8",
|
|
52
53
|
stdio: ["ignore", "pipe", "pipe"],
|
|
53
54
|
timeout: EXEC_TIMEOUT_MS,
|
|
55
|
+
env: nonInteractiveGitEnv(),
|
|
54
56
|
}).trim();
|
|
55
57
|
return { ok: true, output };
|
|
56
58
|
}
|
|
57
59
|
catch (err) {
|
|
58
60
|
const message = errorMessage(err);
|
|
59
|
-
if (attempt < retries && isTransientGitError(message)) {
|
|
61
|
+
if (attempt < retries && !isGitAuthFailure(message) && isTransientGitError(message)) {
|
|
60
62
|
const delayMs = 500 * (attempt + 1);
|
|
61
63
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
62
64
|
continue;
|
|
63
65
|
}
|
|
64
|
-
return { ok: false, error: message };
|
|
66
|
+
return { ok: false, output: "", error: message };
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
return { ok: false, error: "git command failed" };
|
|
69
|
+
return { ok: false, output: "", error: "git command failed" };
|
|
70
|
+
}
|
|
71
|
+
const guardedSessionGit = withStoreAuthBackoff((cwd, args) => runBestEffortGitCommand(args, cwd));
|
|
72
|
+
export async function runBestEffortGit(args, cwd) {
|
|
73
|
+
return guardedSessionGit(cwd, args);
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
76
|
* True when local HEAD and the tracking branch share no common ancestor.
|
|
71
77
|
*
|
|
72
78
|
* This is what happens when a store's remote is re-initialized: every
|
|
73
|
-
*
|
|
74
|
-
*
|
|
79
|
+
* an ordinary pull cannot reconcile it, and the next commit re-enters the
|
|
80
|
+
* same loop forever. A generic "pull failed" sends the user chasing
|
|
75
81
|
* network problems, so it is worth naming — no retry will ever fix it.
|
|
76
82
|
*
|
|
77
83
|
* Returns false when there is no upstream, or when git cannot answer; callers
|
|
@@ -105,7 +111,7 @@ export const TEAM_STORE_PATHSPECS = [
|
|
|
105
111
|
"*/FINDINGS.md.bak",
|
|
106
112
|
"*/summary.md",
|
|
107
113
|
"*/review.md",
|
|
108
|
-
"*/
|
|
114
|
+
"*/AGENTS.md",
|
|
109
115
|
"*/topic-config.json",
|
|
110
116
|
"*/phren.project.yaml",
|
|
111
117
|
"*/reference/**",
|
|
@@ -128,127 +134,46 @@ export async function countUnsyncedCommits(cwd) {
|
|
|
128
134
|
const parsed = Number.parseInt(ahead.output.trim(), 10);
|
|
129
135
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
130
136
|
}
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
const runSessionStoreGit = async (cwd, args) => {
|
|
138
|
+
const result = await runBestEffortGitCommand(args, cwd);
|
|
139
|
+
return { ok: result.ok, output: result.output ?? "", error: result.error };
|
|
140
|
+
};
|
|
141
|
+
/** Startup pulls share the store's Git lock and never rewrite local commits. */
|
|
142
|
+
export async function pullAtSessionStart(cwd, git = runSessionStoreGit, now = Date.now()) {
|
|
143
|
+
const result = await pullAtSessionStartUnlogged(cwd, git, now);
|
|
144
|
+
const counts = await aheadBehind(cwd, git);
|
|
145
|
+
logSyncOutcome(cwd, "session-start-pull", { ok: result.ok, detail: result.ok ? result.output : result.error, counts });
|
|
146
|
+
return counts ? { ...result, counts } : result;
|
|
147
|
+
}
|
|
148
|
+
async function pullAtSessionStartUnlogged(cwd, git, now) {
|
|
133
149
|
try {
|
|
134
150
|
return await withFileLock(runtimeFile(cwd, "git-op"), async () => {
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
return { ok: false, error:
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (!abort.ok)
|
|
146
|
-
return { ok: false, error: `${result.error}; rebase cleanup failed: ${abort.error}` };
|
|
147
|
-
}
|
|
148
|
-
return result;
|
|
151
|
+
const auth = activeStoreAuthFailure(cwd);
|
|
152
|
+
if (authBackoffActive(auth, now))
|
|
153
|
+
return { ok: false, error: storeAuthDetail(auth) };
|
|
154
|
+
const result = await mergeStoreUpstream(cwd, {
|
|
155
|
+
git: withStoreAuthBackoff(git, () => now),
|
|
156
|
+
commitMessage: "auto-save phren (session start)",
|
|
157
|
+
});
|
|
158
|
+
return result.status === "updated" || result.status === "unchanged"
|
|
159
|
+
? { ok: true, output: result.detail }
|
|
160
|
+
: { ok: false, error: result.detail };
|
|
149
161
|
});
|
|
150
162
|
}
|
|
151
163
|
catch (err) {
|
|
152
164
|
return { ok: false, error: errorMessage(err) };
|
|
153
165
|
}
|
|
154
166
|
}
|
|
155
|
-
// ── Merge helpers ───────────────────────────────────────────────────────────
|
|
156
|
-
function isMergeableMarkdown(relPath) {
|
|
157
|
-
const filename = path.basename(relPath).toLowerCase();
|
|
158
|
-
return filename === "findings.md" || isTaskFileName(filename);
|
|
159
|
-
}
|
|
160
|
-
async function snapshotLocalMergeableFiles(cwd) {
|
|
161
|
-
const upstream = await runBestEffortGit(["rev-parse", "--abbrev-ref", "@{upstream}"], cwd);
|
|
162
|
-
if (!upstream.ok || !upstream.output)
|
|
163
|
-
return new Map();
|
|
164
|
-
const changed = await runBestEffortGit(["diff", "--name-only", `${upstream.output.trim()}..HEAD`], cwd);
|
|
165
|
-
if (!changed.ok || !changed.output)
|
|
166
|
-
return new Map();
|
|
167
|
-
const snapshots = new Map();
|
|
168
|
-
for (const relPath of changed.output.split("\n").map((line) => line.trim()).filter(Boolean)) {
|
|
169
|
-
if (!isMergeableMarkdown(relPath))
|
|
170
|
-
continue;
|
|
171
|
-
const fullPath = path.join(cwd, relPath);
|
|
172
|
-
if (!fs.existsSync(fullPath))
|
|
173
|
-
continue;
|
|
174
|
-
snapshots.set(relPath, fs.readFileSync(fullPath, "utf8"));
|
|
175
|
-
}
|
|
176
|
-
return snapshots;
|
|
177
|
-
}
|
|
178
|
-
async function reconcileMergeableFiles(cwd, snapshots) {
|
|
179
|
-
let changedAny = false;
|
|
180
|
-
for (const [relPath, localBeforePull] of snapshots.entries()) {
|
|
181
|
-
const fullPath = path.join(cwd, relPath);
|
|
182
|
-
if (!fs.existsSync(fullPath))
|
|
183
|
-
continue;
|
|
184
|
-
const current = fs.readFileSync(fullPath, "utf8");
|
|
185
|
-
const filename = path.basename(relPath).toLowerCase();
|
|
186
|
-
const merged = filename === "findings.md"
|
|
187
|
-
? mergeFindings(current, localBeforePull)
|
|
188
|
-
: mergeTask(current, localBeforePull);
|
|
189
|
-
if (merged === current)
|
|
190
|
-
continue;
|
|
191
|
-
fs.writeFileSync(fullPath, merged);
|
|
192
|
-
changedAny = true;
|
|
193
|
-
}
|
|
194
|
-
if (!changedAny)
|
|
195
|
-
return false;
|
|
196
|
-
const add = await runBestEffortGit(["add", "--", ...snapshots.keys()], cwd);
|
|
197
|
-
if (!add.ok)
|
|
198
|
-
return false;
|
|
199
|
-
const commit = await runBestEffortGit(["commit", "-m", "auto-merge markdown recovery"], cwd);
|
|
200
|
-
return commit.ok;
|
|
201
|
-
}
|
|
202
167
|
export async function recoverPushConflict(cwd) {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const reconciled = await reconcileMergeableFiles(cwd, localSnapshots);
|
|
207
|
-
const retryPush = await runBestEffortGit(["push"], cwd);
|
|
208
|
-
return {
|
|
209
|
-
ok: retryPush.ok,
|
|
210
|
-
detail: retryPush.ok
|
|
211
|
-
? (reconciled ? "commit pushed after pull --rebase and markdown reconciliation" : "commit pushed after pull --rebase")
|
|
212
|
-
: (retryPush.error || "push failed after pull --rebase"),
|
|
213
|
-
pullStatus: "ok",
|
|
214
|
-
pullDetail: pull.output || "pull --rebase ok",
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
const conflicted = await runBestEffortGit(["diff", "--name-only", "--diff-filter=U"], cwd);
|
|
218
|
-
const conflictedOutput = conflicted.output?.trim() || "";
|
|
219
|
-
if (!conflicted.ok || !conflictedOutput) {
|
|
220
|
-
await runBestEffortGit(["rebase", "--abort"], cwd);
|
|
221
|
-
return {
|
|
222
|
-
ok: false,
|
|
223
|
-
detail: pull.error || "pull --rebase failed",
|
|
224
|
-
pullStatus: "error",
|
|
225
|
-
pullDetail: pull.error || "pull --rebase failed",
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
if (!autoMergeConflicts(cwd)) {
|
|
229
|
-
await runBestEffortGit(["rebase", "--abort"], cwd);
|
|
230
|
-
return {
|
|
231
|
-
ok: false,
|
|
232
|
-
detail: `rebase conflicts require manual resolution: ${conflictedOutput}`,
|
|
233
|
-
pullStatus: "error",
|
|
234
|
-
pullDetail: `rebase conflicts require manual resolution: ${conflictedOutput}`,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
const continued = await runBestEffortGit(["-c", "core.editor=true", "rebase", "--continue"], cwd);
|
|
238
|
-
if (!continued.ok) {
|
|
239
|
-
await runBestEffortGit(["rebase", "--abort"], cwd);
|
|
240
|
-
return {
|
|
241
|
-
ok: false,
|
|
242
|
-
detail: continued.error || "rebase --continue failed",
|
|
243
|
-
pullStatus: "error",
|
|
244
|
-
pullDetail: continued.error || "rebase --continue failed",
|
|
245
|
-
};
|
|
168
|
+
const merged = await mergeStoreUpstream(cwd, { git: withStoreAuthBackoff(runSessionStoreGit), commitLocalWrites: false });
|
|
169
|
+
if (merged.status !== "updated" && merged.status !== "unchanged") {
|
|
170
|
+
return { ok: false, detail: merged.detail, pullStatus: "error", pullDetail: merged.detail };
|
|
246
171
|
}
|
|
247
172
|
const retryPush = await runBestEffortGit(["push"], cwd);
|
|
248
173
|
return {
|
|
249
174
|
ok: retryPush.ok,
|
|
250
|
-
detail: retryPush.ok ? "commit pushed after
|
|
175
|
+
detail: retryPush.ok ? "commit pushed after merging remote changes" : (retryPush.error || "push failed after merging remote changes"),
|
|
251
176
|
pullStatus: "ok",
|
|
252
|
-
pullDetail:
|
|
177
|
+
pullDetail: merged.detail,
|
|
253
178
|
};
|
|
254
179
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { moduleEnabled } from "../modules/runtime.js";
|
|
1
2
|
/**
|
|
2
3
|
* Session start hook handler and onboarding notices.
|
|
3
4
|
* Extracted from hooks-session.ts for modularity.
|
|
@@ -25,7 +26,7 @@ function projectHasBootstrapSignals(phrenPath, project) {
|
|
|
25
26
|
return true;
|
|
26
27
|
}
|
|
27
28
|
const tasksPath = path.join(projectDir, TASKS_FILENAME);
|
|
28
|
-
if (fs.existsSync(tasksPath)) {
|
|
29
|
+
if (moduleEnabled(path.dirname(projectDir), "tasks") && fs.existsSync(tasksPath)) {
|
|
29
30
|
const tasks = fs.readFileSync(tasksPath, "utf8");
|
|
30
31
|
if (/^-\s+\[(?: |x|X)\]/m.test(tasks))
|
|
31
32
|
return true;
|
|
@@ -171,6 +172,7 @@ export async function handleHookSessionStart() {
|
|
|
171
172
|
lastPullDetail: pull.ok ? (pull.output || "pull ok") : (pull.error || "pull failed"),
|
|
172
173
|
lastSuccessfulPullAt: pull.ok && hasRemote ? startedAt : undefined,
|
|
173
174
|
unsyncedCommits,
|
|
175
|
+
...("counts" in pull && pull.counts ? pull.counts : {}),
|
|
174
176
|
},
|
|
175
177
|
});
|
|
176
178
|
appendAuditLog(phrenPath, "hook_session_start", `pull=${hasRemote ? (pull.ok ? "ok" : "fail") : "skipped-local"} doctor=${doctor.ok ? "ok" : "issues"} maintenance=${maintenanceScheduled ? "scheduled" : "skipped"}`);
|
package/dist/cli/session-stop.js
CHANGED
|
@@ -12,6 +12,8 @@ import { assessSyncOutage, getRuntimeHealth, } from "../shared/governance.js";
|
|
|
12
12
|
import { resolveSubprocessArgs, scheduleBackgroundSync, } from "./session-background.js";
|
|
13
13
|
import { spawnDetachedChild } from "../shared/process.js";
|
|
14
14
|
import { resolveManagementCapabilities } from "../init/management-preset.js";
|
|
15
|
+
import { aheadBehind, logSyncOutcome } from "../sync/outcome.js";
|
|
16
|
+
import { storeCommitMessage } from "../machine-identity.js";
|
|
15
17
|
// ── Utility ─────────────────────────────────────────────────────────────────
|
|
16
18
|
/** Read JSON from stdin if it's not a TTY. Returns null if stdin is a TTY or parsing fails. */
|
|
17
19
|
function readStdinJson() {
|
|
@@ -140,7 +142,7 @@ function warnIfSyncDegraded(phrenPath) {
|
|
|
140
142
|
"<phren-notice>",
|
|
141
143
|
assessment.summary,
|
|
142
144
|
`Your findings and tasks are safe on disk in ${phrenPath}, but they are not reaching the remote.`,
|
|
143
|
-
`Diagnose with: phren status (then:
|
|
145
|
+
`Diagnose with: phren status (then: phren store sync)`,
|
|
144
146
|
"<phren-notice>",
|
|
145
147
|
"",
|
|
146
148
|
].join("\n"));
|
|
@@ -422,7 +424,7 @@ export async function handleHookStop() {
|
|
|
422
424
|
}
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
|
-
const commit = add.ok ? await runBestEffortGit(["commit", "-m", commitMsg], phrenPath) : { ok: false, error: add.error };
|
|
427
|
+
const commit = add.ok ? await runBestEffortGit(["commit", "-m", storeCommitMessage(commitMsg)], phrenPath) : { ok: false, error: add.error };
|
|
426
428
|
if (!add.ok || !commit.ok) {
|
|
427
429
|
finalizeTaskSession({
|
|
428
430
|
phrenPath,
|
|
@@ -507,29 +509,34 @@ export async function handleBackgroundSync() {
|
|
|
507
509
|
try {
|
|
508
510
|
await withFileLock(runtimeFile(phrenPathLocal, "git-op"), async () => {
|
|
509
511
|
const previousSync = getRuntimeHealth(phrenPathLocal).lastSync;
|
|
510
|
-
const record = (autoSaveStatus, patch, detail) => {
|
|
512
|
+
const record = async (autoSaveStatus, patch, detail) => {
|
|
513
|
+
// Ahead/behind make a failure actionable: "behind 140" is a different fix from "ahead 23".
|
|
514
|
+
const counts = await aheadBehind(phrenPathLocal, (cwd, args) => runBestEffortGit(args, cwd));
|
|
511
515
|
updateRuntimeHealth(phrenPathLocal, {
|
|
512
516
|
lastAutoSave: { at: now, status: autoSaveStatus, detail },
|
|
513
|
-
lastSync: nextSyncStatus(previousSync, patch, now),
|
|
517
|
+
lastSync: { ...nextSyncStatus(previousSync, patch, now), ...(counts ?? {}) },
|
|
514
518
|
});
|
|
515
519
|
appendAuditLog(phrenPathLocal, "background_sync", `status=${patch.lastPushStatus} detail=${JSON.stringify(detail)}`);
|
|
520
|
+
logSyncOutcome(phrenPathLocal, "background-sync", {
|
|
521
|
+
ok: autoSaveStatus !== "sync-failed", detail: `${patch.lastPushStatus}: ${detail}`, counts,
|
|
522
|
+
});
|
|
516
523
|
};
|
|
517
524
|
const remotes = await runBestEffortGit(["remote"], phrenPathLocal);
|
|
518
525
|
if (!remotes.ok || !remotes.output) {
|
|
519
526
|
const unsyncedCommits = await countUnsyncedCommits(phrenPathLocal);
|
|
520
527
|
const detail = "background sync skipped; no remote configured";
|
|
521
|
-
record("saved-local", { lastPushAt: now, lastPushStatus: "saved-local", lastPushDetail: detail, unsyncedCommits }, detail);
|
|
528
|
+
await record("saved-local", { lastPushAt: now, lastPushStatus: "saved-local", lastPushDetail: detail, unsyncedCommits }, detail);
|
|
522
529
|
return;
|
|
523
530
|
}
|
|
524
531
|
const push = await runBestEffortGit(["push"], phrenPathLocal);
|
|
525
532
|
if (push.ok) {
|
|
526
533
|
const detail = "commit pushed by background sync";
|
|
527
|
-
record("saved-pushed", { lastPushAt: now, lastPushStatus: "saved-pushed", lastPushDetail: detail, unsyncedCommits: 0 }, detail);
|
|
534
|
+
await record("saved-pushed", { lastPushAt: now, lastPushStatus: "saved-pushed", lastPushDetail: detail, unsyncedCommits: 0 }, detail);
|
|
528
535
|
return;
|
|
529
536
|
}
|
|
530
537
|
const recovered = await recoverPushConflict(phrenPathLocal);
|
|
531
538
|
if (recovered.ok) {
|
|
532
|
-
record("saved-pushed", {
|
|
539
|
+
await record("saved-pushed", {
|
|
533
540
|
lastPushAt: now,
|
|
534
541
|
lastPushStatus: "saved-pushed",
|
|
535
542
|
lastPushDetail: recovered.detail,
|
|
@@ -554,7 +561,7 @@ export async function handleBackgroundSync() {
|
|
|
554
561
|
? `local and remote histories are unrelated (no merge base) — the remote was most likely re-initialized. ` +
|
|
555
562
|
`Reconcile manually: cd ${phrenPathLocal} && git fetch && git log --oneline origin/HEAD`
|
|
556
563
|
: (recovered.detail || push.error || "background sync push failed");
|
|
557
|
-
record("sync-failed", {
|
|
564
|
+
await record("sync-failed", {
|
|
558
565
|
lastPushAt: now,
|
|
559
566
|
lastPushStatus: pushStatus,
|
|
560
567
|
lastPushDetail: failDetail,
|
|
@@ -565,6 +572,10 @@ export async function handleBackgroundSync() {
|
|
|
565
572
|
}, failDetail);
|
|
566
573
|
});
|
|
567
574
|
}
|
|
575
|
+
catch (err) {
|
|
576
|
+
logSyncOutcome(phrenPathLocal, "background-sync", { ok: false, detail: errorMessage(err) });
|
|
577
|
+
throw err;
|
|
578
|
+
}
|
|
568
579
|
finally {
|
|
569
580
|
try {
|
|
570
581
|
fs.unlinkSync(lockPath);
|
package/dist/cli/team.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nonInteractiveGitEnv } from "../utils-helpers.js";
|
|
1
2
|
/**
|
|
2
3
|
* Team store CLI commands: init, join, add-project.
|
|
3
4
|
* Creates and manages shared phren stores for team collaboration.
|
|
@@ -6,19 +7,13 @@ import * as fs from "fs";
|
|
|
6
7
|
import * as path from "path";
|
|
7
8
|
import { execFileSync } from "child_process";
|
|
8
9
|
import { getPhrenPath } from "../shared.js";
|
|
10
|
+
import { atomicWriteText } from "../phren-paths.js";
|
|
9
11
|
import { FINDINGS_FILENAME } from "../data/access.js";
|
|
10
12
|
import { TASKS_FILENAME } from "../data/tasks.js";
|
|
11
13
|
import { isValidProjectName, getOptionValue, getPositionalArgs } from "../utils.js";
|
|
12
14
|
import { addProjectToProfile, resolveActiveProfile } from "../profile-store.js";
|
|
13
15
|
import { addStoreToRegistry, findStoreByName, generateStoreId, readTeamBootstrap, updateStoreProjects, } from "../store-registry.js";
|
|
14
16
|
const EXEC_TIMEOUT_MS = 30_000;
|
|
15
|
-
function atomicWriteText(filePath, content) {
|
|
16
|
-
const dir = path.dirname(filePath);
|
|
17
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
18
|
-
const tmp = filePath + ".tmp." + process.pid;
|
|
19
|
-
fs.writeFileSync(tmp, content);
|
|
20
|
-
fs.renameSync(tmp, filePath);
|
|
21
|
-
}
|
|
22
17
|
// ── phren team init <name> [--remote <url>] [--description <desc>] ──────────
|
|
23
18
|
async function handleTeamInit(args) {
|
|
24
19
|
const phrenPath = getPhrenPath();
|
|
@@ -64,17 +59,19 @@ async function handleTeamInit(args) {
|
|
|
64
59
|
// Create global directory with starter files
|
|
65
60
|
const globalDir = path.join(storePath, "global");
|
|
66
61
|
fs.mkdirSync(globalDir, { recursive: true });
|
|
67
|
-
atomicWriteText(path.join(globalDir, "
|
|
62
|
+
atomicWriteText(path.join(globalDir, "AGENTS.md"), `# ${name} Team Store\n\nShared knowledge for the ${name} team.\n`);
|
|
68
63
|
atomicWriteText(path.join(globalDir, FINDINGS_FILENAME), `# global findings\n`);
|
|
69
64
|
// Initialize git repo
|
|
70
65
|
execFileSync("git", ["init"], {
|
|
66
|
+
env: nonInteractiveGitEnv(),
|
|
71
67
|
cwd: storePath,
|
|
72
68
|
stdio: "pipe",
|
|
73
69
|
timeout: EXEC_TIMEOUT_MS,
|
|
74
70
|
});
|
|
75
71
|
// Initial commit
|
|
76
|
-
execFileSync("git", ["add", "-A"], { cwd: storePath, stdio: "pipe", timeout: EXEC_TIMEOUT_MS });
|
|
72
|
+
execFileSync("git", ["add", "-A"], { env: nonInteractiveGitEnv(), cwd: storePath, stdio: "pipe", timeout: EXEC_TIMEOUT_MS });
|
|
77
73
|
execFileSync("git", ["commit", "-m", "phren: initialize team store"], {
|
|
74
|
+
env: nonInteractiveGitEnv(),
|
|
78
75
|
cwd: storePath,
|
|
79
76
|
stdio: "pipe",
|
|
80
77
|
timeout: EXEC_TIMEOUT_MS,
|
|
@@ -82,12 +79,14 @@ async function handleTeamInit(args) {
|
|
|
82
79
|
// Add remote if provided
|
|
83
80
|
if (remote) {
|
|
84
81
|
execFileSync("git", ["remote", "add", "origin", remote], {
|
|
82
|
+
env: nonInteractiveGitEnv(),
|
|
85
83
|
cwd: storePath,
|
|
86
84
|
stdio: "pipe",
|
|
87
85
|
timeout: EXEC_TIMEOUT_MS,
|
|
88
86
|
});
|
|
89
87
|
try {
|
|
90
88
|
execFileSync("git", ["push", "-u", "origin", "main"], {
|
|
89
|
+
env: nonInteractiveGitEnv(),
|
|
91
90
|
cwd: storePath,
|
|
92
91
|
stdio: "pipe",
|
|
93
92
|
timeout: EXEC_TIMEOUT_MS,
|
|
@@ -98,6 +97,7 @@ async function handleTeamInit(args) {
|
|
|
98
97
|
// Try HEAD branch name
|
|
99
98
|
try {
|
|
100
99
|
execFileSync("git", ["push", "-u", "origin", "HEAD"], {
|
|
100
|
+
env: nonInteractiveGitEnv(),
|
|
101
101
|
cwd: storePath,
|
|
102
102
|
stdio: "pipe",
|
|
103
103
|
timeout: EXEC_TIMEOUT_MS,
|
|
@@ -109,7 +109,7 @@ async function handleTeamInit(args) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
//
|
|
112
|
+
// Attach it on this machine only (.runtime/attached-stores.yaml)
|
|
113
113
|
const entry = {
|
|
114
114
|
id: generateStoreId(),
|
|
115
115
|
name,
|
|
@@ -123,6 +123,7 @@ async function handleTeamInit(args) {
|
|
|
123
123
|
console.log(` Path: ${storePath}`);
|
|
124
124
|
console.log(` Role: team`);
|
|
125
125
|
console.log(` ID: ${entry.id}`);
|
|
126
|
+
console.log(` Attached on this machine only. Run phren team join on each other machine that should use it.`);
|
|
126
127
|
if (!remote) {
|
|
127
128
|
console.log(`\nNext: add a remote and push`);
|
|
128
129
|
console.log(` cd ${storePath}`);
|
|
@@ -166,6 +167,7 @@ async function handleTeamJoin(args) {
|
|
|
166
167
|
console.log(`Cloning ${remote}...`);
|
|
167
168
|
fs.mkdirSync(storesDir, { recursive: true });
|
|
168
169
|
execFileSync("git", ["clone", "--", remote, storePath], {
|
|
170
|
+
env: nonInteractiveGitEnv(),
|
|
169
171
|
stdio: "inherit",
|
|
170
172
|
timeout: 60_000,
|
|
171
173
|
});
|
|
@@ -186,6 +188,7 @@ async function handleTeamJoin(args) {
|
|
|
186
188
|
console.log(` Path: ${storePath}`);
|
|
187
189
|
console.log(` Role: ${finalRole}`);
|
|
188
190
|
console.log(` ID: ${entry.id}`);
|
|
191
|
+
console.log(` Attached on this machine only. Run phren team join on each other machine that should use it.`);
|
|
189
192
|
if (bootstrap?.description) {
|
|
190
193
|
console.log(` Description: ${bootstrap.description}`);
|
|
191
194
|
}
|
package/dist/cli-handlers.d.ts
CHANGED
|
@@ -16,4 +16,4 @@ export declare function runMcpModeCommand(args: string[]): Promise<number>;
|
|
|
16
16
|
export declare function runHooksModeCommand(args: string[]): Promise<number>;
|
|
17
17
|
export declare function runPresetCommand(args: string[]): Promise<number>;
|
|
18
18
|
export declare function runSnippetCommand(_args: string[]): Promise<number>;
|
|
19
|
-
export declare function runLinkRemovedNotice(
|
|
19
|
+
export declare function runLinkRemovedNotice(args: string[]): Promise<number>;
|
package/dist/cli-handlers.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import * as fs from "fs";
|
|
11
11
|
import * as path from "path";
|
|
12
|
-
import { defaultPhrenPath, findPhrenPath, isInstallMode,
|
|
12
|
+
import { defaultPhrenPath, findPhrenPath, isInstallMode, } from "./shared.js";
|
|
13
|
+
import { parseProactivityLevel } from "./proactivity.js";
|
|
13
14
|
import { errorMessage, getOptionValue, getPositionalArgs } from "./utils.js";
|
|
14
15
|
import { addProjectFromPath } from "./core/project.js";
|
|
15
16
|
import { PROJECT_OWNERSHIP_MODES, getProjectOwnershipDefault, parseProjectOwnershipMode, } from "./project-config.js";
|
|
@@ -238,7 +239,10 @@ export async function runSnippetCommand(_args) {
|
|
|
238
239
|
return 1;
|
|
239
240
|
}
|
|
240
241
|
}
|
|
241
|
-
export async function runLinkRemovedNotice(
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
export async function runLinkRemovedNotice(args) {
|
|
243
|
+
if (args.length) {
|
|
244
|
+
console.error("The old `phren link` option interface has been removed. Use `phren init` instead.");
|
|
245
|
+
return 1;
|
|
246
|
+
}
|
|
247
|
+
return runInitCommand(args);
|
|
244
248
|
}
|
package/dist/cli-help.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { ModuleSnapshot } from "./modules/runtime.js";
|
|
1
2
|
import { type Topic } from "./cli-registry.js";
|
|
2
|
-
export declare function formatCheatSheet(): string;
|
|
3
|
-
export declare function formatTopic(topic: Topic): string;
|
|
3
|
+
export declare function formatCheatSheet(snapshot?: ModuleSnapshot): string;
|
|
4
|
+
export declare function formatTopic(topic: Topic, snapshot?: ModuleSnapshot): string;
|
|
4
5
|
export declare function formatDocTopic(name: string): string | null;
|
|
5
|
-
export declare function formatCommand(name: string): string | null;
|
|
6
|
-
export declare function formatFullHelp(): string;
|
|
6
|
+
export declare function formatCommand(name: string, snapshot?: ModuleSnapshot): string | null;
|
|
7
|
+
export declare function formatFullHelp(snapshot?: ModuleSnapshot): string;
|
package/dist/cli-help.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Help formatters. Pure functions over the command registry.
|
|
2
|
-
import {
|
|
2
|
+
import { commandsForModules, TOPIC_ORDER, DOC_TOPICS, lookupCommand, } from "./cli-registry.js";
|
|
3
3
|
const TOPIC_TITLES = {
|
|
4
4
|
core: "Core commands",
|
|
5
5
|
projects: "Projects",
|
|
@@ -19,11 +19,11 @@ function pad(usage, summary) {
|
|
|
19
19
|
const gap = Math.max(2, ALIGN_COL - text.length);
|
|
20
20
|
return text + " ".repeat(gap) + summary;
|
|
21
21
|
}
|
|
22
|
-
function visibleCommands() {
|
|
23
|
-
return
|
|
22
|
+
function visibleCommands(snapshot) {
|
|
23
|
+
return commandsForModules(snapshot).filter((c) => !c.hidden);
|
|
24
24
|
}
|
|
25
|
-
function commandsInTopic(topic) {
|
|
26
|
-
return visibleCommands().filter((c) => c.topic === topic);
|
|
25
|
+
function commandsInTopic(topic, snapshot) {
|
|
26
|
+
return visibleCommands(snapshot).filter((c) => c.topic === topic);
|
|
27
27
|
}
|
|
28
28
|
function renderCommandLine(cmd) {
|
|
29
29
|
return pad(cmd.usage, cmd.summary);
|
|
@@ -44,12 +44,12 @@ function renderCommandWithSubs(cmd) {
|
|
|
44
44
|
return lines;
|
|
45
45
|
}
|
|
46
46
|
// ── Cheat sheet (phren --help) ───────────────────────────────────────────────
|
|
47
|
-
export function formatCheatSheet() {
|
|
47
|
+
export function formatCheatSheet(snapshot) {
|
|
48
48
|
const lines = [];
|
|
49
49
|
lines.push("phren - persistent memory for AI agents");
|
|
50
50
|
lines.push("");
|
|
51
51
|
lines.push(pad("phren", "Interactive memory shell"));
|
|
52
|
-
for (const cmd of visibleCommands()) {
|
|
52
|
+
for (const cmd of visibleCommands(snapshot)) {
|
|
53
53
|
if (!cmd.featured)
|
|
54
54
|
continue;
|
|
55
55
|
lines.push(renderCheatSheetLine(cmd));
|
|
@@ -64,8 +64,8 @@ export function formatCheatSheet() {
|
|
|
64
64
|
return lines.join("\n");
|
|
65
65
|
}
|
|
66
66
|
// ── Topic help (phren help <topic>) ──────────────────────────────────────────
|
|
67
|
-
export function formatTopic(topic) {
|
|
68
|
-
const cmds = commandsInTopic(topic);
|
|
67
|
+
export function formatTopic(topic, snapshot) {
|
|
68
|
+
const cmds = commandsInTopic(topic, snapshot);
|
|
69
69
|
const lines = [];
|
|
70
70
|
lines.push(`${TOPIC_TITLES[topic]}:`);
|
|
71
71
|
for (const cmd of cmds) {
|
|
@@ -81,8 +81,8 @@ export function formatDocTopic(name) {
|
|
|
81
81
|
return DOC_TOPICS[name] ?? null;
|
|
82
82
|
}
|
|
83
83
|
// ── Single command (phren <name> --help / phren help <name>) ─────────────────
|
|
84
|
-
export function formatCommand(name) {
|
|
85
|
-
const cmd = lookupCommand(name);
|
|
84
|
+
export function formatCommand(name, snapshot) {
|
|
85
|
+
const cmd = lookupCommand(name, snapshot);
|
|
86
86
|
if (!cmd)
|
|
87
87
|
return null;
|
|
88
88
|
const lines = [];
|
|
@@ -99,23 +99,23 @@ export function formatCommand(name) {
|
|
|
99
99
|
return lines.join("\n");
|
|
100
100
|
}
|
|
101
101
|
// ── Full help (phren help all) ───────────────────────────────────────────────
|
|
102
|
-
export function formatFullHelp() {
|
|
102
|
+
export function formatFullHelp(snapshot) {
|
|
103
103
|
const lines = [];
|
|
104
104
|
lines.push("phren - persistent knowledge for your agents");
|
|
105
105
|
lines.push("");
|
|
106
106
|
lines.push("Usage:");
|
|
107
107
|
lines.push(pad("phren", "Interactive shell"));
|
|
108
|
-
for (const cmd of visibleCommands()) {
|
|
108
|
+
for (const cmd of visibleCommands(snapshot)) {
|
|
109
109
|
if (!cmd.featured)
|
|
110
110
|
continue;
|
|
111
111
|
lines.push(renderCheatSheetLine(cmd));
|
|
112
112
|
}
|
|
113
113
|
lines.push("");
|
|
114
114
|
for (const topic of TOPIC_ORDER) {
|
|
115
|
-
const cmds = commandsInTopic(topic);
|
|
115
|
+
const cmds = commandsInTopic(topic, snapshot);
|
|
116
116
|
if (!cmds.length)
|
|
117
117
|
continue;
|
|
118
|
-
lines.push(formatTopic(topic));
|
|
118
|
+
lines.push(formatTopic(topic, snapshot));
|
|
119
119
|
}
|
|
120
120
|
for (const [docName, body] of Object.entries(DOC_TOPICS)) {
|
|
121
121
|
lines.push(`${docName.charAt(0).toUpperCase()}${docName.slice(1)} reference:`);
|
package/dist/cli-registry.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ModuleSnapshot } from "./modules/runtime.js";
|
|
1
2
|
/**
|
|
2
3
|
* Command registry - single source of truth for help generation and dispatch.
|
|
3
4
|
*
|
|
@@ -38,8 +39,10 @@ export interface Command {
|
|
|
38
39
|
export declare const ENV_HELP = "Environment variables:\n PHREN_PATH Override phren directory (default: ~/.phren)\n PHREN_PROFILE Active profile name\n PHREN_DEBUG Enable debug logging (set to 1)\n PHREN_PULL_INTERVAL_SECONDS Remote check interval in seconds (default: off; 0 disables)\n\n Embeddings:\n PHREN_OLLAMA_URL Ollama base URL (default: http://localhost:11434, 'off' to disable)\n PHREN_EMBEDDING_API_URL OpenAI-compatible /embeddings endpoint\n PHREN_EMBEDDING_API_KEY API key for embedding endpoint\n PHREN_EMBEDDING_MODEL Embedding model (default: nomic-embed-text)\n\n Context injection:\n PHREN_CONTEXT_TOKEN_BUDGET Max tokens injected per prompt (default: 550)\n PHREN_MAX_INJECT_TOKENS Hard cap on total injected tokens (default: 2000)\n PHREN_HOOK_TIMEOUT_MS Hook subprocess timeout in ms (default: 14000)\n\n Feature flags:\n PHREN_FEATURE_AGENTS=1 Show running coding agents on the graph\n PHREN_FEATURE_TOOL_HOOK=0 Skip the PostToolUse subprocess (perf)\n PHREN_FEATURE_AUTO_EXTRACT=0 Disable auto memory extraction\n PHREN_FEATURE_AUTO_CAPTURE=1 Extract insights from conversations\n PHREN_FEATURE_SEMANTIC_DEDUP=1 LLM-based dedup on add_finding\n PHREN_FEATURE_HYBRID_SEARCH=0 Disable TF-IDF cosine fallback\n\n Run 'phren help all' to see everything.\n";
|
|
39
40
|
export declare const DOC_TOPICS: Record<string, string>;
|
|
40
41
|
export declare const REGISTRY: Command[];
|
|
41
|
-
export declare function lookupCommand(name: string): Command | undefined;
|
|
42
|
+
export declare function lookupCommand(name: string, snapshot?: ModuleSnapshot): Command | undefined;
|
|
42
43
|
/** Topic IDs available to `phren help <topic>`, including doc topics and `all`. */
|
|
43
44
|
export declare function helpTopicNames(): string[];
|
|
44
45
|
/** Topic IDs that are command groups (excludes doc topics and `all`). */
|
|
45
46
|
export declare function commandTopics(): readonly Topic[];
|
|
47
|
+
export declare function disabledCommand(command: string, snapshot: ModuleSnapshot): string | undefined;
|
|
48
|
+
export declare function commandsForModules(snapshot?: ModuleSnapshot): Command[];
|