@phren/cli 0.3.11 → 0.3.12
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/dist/bridge/agent-hook-stores.d.ts +3 -0
- package/dist/bridge/agent-hook-stores.js +5 -0
- package/dist/bridge/agent-hooks.d.ts +159 -5
- package/dist/bridge/agent-hooks.js +663 -49
- package/dist/bridge/approval-summary.d.ts +16 -0
- package/dist/bridge/approval-summary.js +133 -0
- package/dist/bridge/authority-command.d.ts +20 -0
- package/dist/bridge/authority-command.js +120 -0
- package/dist/bridge/authority.d.ts +223 -0
- package/dist/bridge/authority.js +231 -0
- package/dist/bridge/claude-account-setup.d.ts +14 -0
- package/dist/bridge/claude-account-setup.js +69 -0
- package/dist/bridge/claude-accounts.d.ts +49 -0
- package/dist/bridge/claude-accounts.js +195 -0
- package/dist/bridge/code-routes.js +2 -2
- package/dist/bridge/codex-app-server.d.ts +144 -0
- package/dist/bridge/codex-app-server.js +319 -0
- package/dist/bridge/codex-auth-refresh.d.ts +33 -0
- package/dist/bridge/codex-auth-refresh.js +71 -0
- package/dist/bridge/codex-question-reply.d.ts +16 -0
- package/dist/bridge/codex-question-reply.js +57 -0
- package/dist/bridge/codex-review-mode.d.ts +10 -0
- package/dist/bridge/codex-review-mode.js +74 -0
- package/dist/bridge/codex-servers.d.ts +217 -0
- package/dist/bridge/codex-servers.js +636 -0
- package/dist/bridge/command.js +94 -4
- package/dist/bridge/computer-identity.d.ts +75 -0
- package/dist/bridge/computer-identity.js +166 -0
- package/dist/bridge/conductor-group.d.ts +91 -8
- package/dist/bridge/conductor-group.js +105 -9
- package/dist/bridge/conductor-role.d.ts +94 -0
- package/dist/bridge/conductor-role.js +176 -0
- package/dist/bridge/conductor-sets.d.ts +20 -0
- package/dist/bridge/conductor-sets.js +59 -0
- package/dist/bridge/dispatch-command.d.ts +3 -0
- package/dist/bridge/dispatch-command.js +75 -11
- package/dist/bridge/dispatch-returns.d.ts +123 -19
- package/dist/bridge/dispatch-returns.js +357 -50
- package/dist/bridge/dispatch.d.ts +103 -2
- package/dist/bridge/dispatch.js +272 -40
- package/dist/bridge/fanouts.d.ts +7 -1
- package/dist/bridge/fanouts.js +39 -4
- package/dist/bridge/folder-trust.d.ts +56 -0
- package/dist/bridge/folder-trust.js +195 -0
- package/dist/bridge/grants.d.ts +22 -1
- package/dist/bridge/grants.js +57 -9
- package/dist/bridge/hand-off.d.ts +21 -9
- package/dist/bridge/hand-off.js +58 -45
- package/dist/bridge/harness-status.d.ts +11 -0
- package/dist/bridge/harness-status.js +32 -0
- package/dist/bridge/harnesses.d.ts +39 -0
- package/dist/bridge/harnesses.js +65 -0
- package/dist/bridge/health.d.ts +2 -0
- package/dist/bridge/health.js +1 -1
- package/dist/bridge/herdr.d.ts +11 -2
- package/dist/bridge/herdr.js +98 -23
- package/dist/bridge/hook-fast.d.ts +4 -0
- package/dist/bridge/hook-fast.js +68 -0
- package/dist/bridge/install.d.ts +16 -1
- package/dist/bridge/install.js +88 -21
- package/dist/bridge/launch-brief.d.ts +96 -0
- package/dist/bridge/launch-brief.js +164 -0
- package/dist/bridge/model-switch.d.ts +3 -0
- package/dist/bridge/model-switch.js +17 -1
- package/dist/bridge/models.d.ts +8 -4
- package/dist/bridge/models.js +24 -8
- package/dist/bridge/mux-wire.d.ts +9 -0
- package/dist/bridge/mux-wire.js +19 -0
- package/dist/bridge/opencode-pane-server.d.ts +113 -0
- package/dist/bridge/opencode-pane-server.js +332 -0
- package/dist/bridge/opencode-panes.d.ts +111 -0
- package/dist/bridge/opencode-panes.js +295 -0
- package/dist/bridge/pane-accounts.d.ts +8 -0
- package/dist/bridge/pane-accounts.js +46 -0
- package/dist/bridge/prompt-startup.d.ts +5 -0
- package/dist/bridge/prompt-startup.js +24 -0
- package/dist/bridge/protocol.d.ts +5 -0
- package/dist/bridge/protocol.js +4 -0
- package/dist/bridge/push.d.ts +5 -4
- package/dist/bridge/push.js +6 -4
- package/dist/bridge/questions.d.ts +37 -2
- package/dist/bridge/questions.js +158 -15
- package/dist/bridge/resources.d.ts +9 -3
- package/dist/bridge/resources.js +24 -8
- package/dist/bridge/schedule-format.d.ts +2 -0
- package/dist/bridge/schedule-format.js +3 -0
- package/dist/bridge/schedule-launch.d.ts +2 -1
- package/dist/bridge/schedule-launch.js +23 -53
- package/dist/bridge/schedule-watch.d.ts +10 -1
- package/dist/bridge/schedule-watch.js +54 -2
- package/dist/bridge/server-launch.d.ts +22 -5
- package/dist/bridge/server-launch.js +225 -29
- package/dist/bridge/server-overview.d.ts +3 -3
- package/dist/bridge/server-overview.js +22 -14
- package/dist/bridge/server-pane-routes.d.ts +2 -0
- package/dist/bridge/server-pane-routes.js +145 -15
- package/dist/bridge/server-routes.d.ts +7 -0
- package/dist/bridge/server-routes.js +163 -35
- package/dist/bridge/server-stream.d.ts +2 -0
- package/dist/bridge/server-stream.js +22 -8
- package/dist/bridge/server.d.ts +6 -1
- package/dist/bridge/server.js +44 -12
- package/dist/bridge/session-activity.d.ts +81 -0
- package/dist/bridge/session-activity.js +117 -0
- package/dist/bridge/session-rename.d.ts +48 -0
- package/dist/bridge/session-rename.js +190 -0
- package/dist/bridge/session-servers.js +2 -2
- package/dist/bridge/settings-switch.d.ts +60 -0
- package/dist/bridge/settings-switch.js +287 -0
- package/dist/bridge/speech-voice.d.ts +55 -0
- package/dist/bridge/speech-voice.js +132 -0
- package/dist/bridge/speech.d.ts +70 -11
- package/dist/bridge/speech.js +169 -41
- package/dist/bridge/terminal-herdr.js +9 -3
- package/dist/bridge/terminal-tmux.d.ts +3 -3
- package/dist/bridge/terminal-tmux.js +24 -9
- package/dist/bridge/terminal.d.ts +27 -4
- package/dist/bridge/terminal.js +8 -1
- package/dist/bridge/transcript-claude.js +57 -12
- package/dist/bridge/transcript-codex.d.ts +0 -2
- package/dist/bridge/transcript-codex.js +29 -4
- package/dist/bridge/transcript-preview.d.ts +1 -0
- package/dist/bridge/transcript-preview.js +24 -4
- package/dist/bridge/transcripts.d.ts +15 -2
- package/dist/bridge/transcripts.js +47 -16
- package/dist/bridge/turn-records.d.ts +85 -0
- package/dist/bridge/turn-records.js +143 -0
- package/dist/bridge/uploads.d.ts +3 -0
- package/dist/bridge/uploads.js +14 -0
- package/dist/bridge/usage.d.ts +39 -10
- package/dist/bridge/usage.js +155 -44
- package/dist/bridge-hook.mjs +19169 -13176
- package/dist/cli/claude-unmanaged.d.ts +12 -0
- package/dist/cli/claude-unmanaged.js +105 -0
- package/dist/cli/schedules.js +2 -1
- package/dist/cli/session-start.js +10 -1
- package/dist/cli/session-stop.js +9 -1
- package/dist/cli-registry.js +24 -5
- package/dist/data/task-receipts.d.ts +19 -0
- package/dist/data/task-receipts.js +68 -0
- package/dist/data/tasks.js +4 -1
- package/dist/generated/memory-ui-graph.browser.js +63 -63
- package/dist/graph-core/model.js +24 -3
- package/dist/graph-core/types.d.ts +4 -1
- package/dist/graph-core/types.js +1 -0
- package/dist/init/init-preset.js +7 -3
- package/dist/init/init-uninstall.js +2 -11
- package/dist/init/teardown.d.ts +3 -0
- package/dist/init/teardown.js +47 -0
- package/dist/link/context.js +21 -9
- package/dist/mcp/plugin-mode.js +1 -1
- package/dist/memory-ui-graph.runtime.js +63 -63
- package/dist/modules/code-package.d.ts +1 -0
- package/dist/modules/code-package.js +36 -7
- package/dist/modules/registry.js +14 -13
- package/dist/profile-store.d.ts +6 -0
- package/dist/profile-store.js +25 -1
- package/dist/shell/graph/glyphs.js +4 -0
- package/dist/shell/graph/graph-view.js +2 -0
- package/dist/status.js +7 -1
- package/dist/sync/task-claim.js +3 -2
- package/dist/task/lifecycle.js +25 -4
- package/dist/test-global-setup.js +5 -0
- package/dist/tools/dispatch.js +35 -2
- package/dist/tools/tasks.js +10 -1
- package/package.json +1 -1
- package/plugins/opencode/phren-transcript.js +87 -4
- package/starter/global/skills/conductor/SKILL.md +17 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ClaudeHookPayload {
|
|
2
|
+
session_id?: string;
|
|
3
|
+
transcript_path?: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function readClaudeHookPayload(): ClaudeHookPayload | undefined;
|
|
7
|
+
/** Returns true for a recognized unmanaged headless worker, even when already registered. */
|
|
8
|
+
export declare function registerUnmanagedClaude(payload: ClaudeHookPayload | undefined, store: string, cwd: string, env?: NodeJS.ProcessEnv, processInfo?: {
|
|
9
|
+
pid: number;
|
|
10
|
+
headless: boolean;
|
|
11
|
+
}): boolean;
|
|
12
|
+
export declare function finishUnmanagedClaude(payload: ClaudeHookPayload | undefined, store: string): boolean;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { jobsRoot, listJobs, readJob, writeManifest } from "../fanout/launcher.js";
|
|
6
|
+
import { uuid } from "../fanout/adapters/types.js";
|
|
7
|
+
export function readClaudeHookPayload() {
|
|
8
|
+
if (process.stdin.isTTY)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(fs.readFileSync(0, "utf8"));
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function claudeProcess() {
|
|
18
|
+
let pid = process.ppid;
|
|
19
|
+
for (let depth = 0; depth < 8 && pid > 1; depth++) {
|
|
20
|
+
let row;
|
|
21
|
+
try {
|
|
22
|
+
row = execFileSync("ps", ["-o", "ppid=,comm=,tty=", "-p", String(pid)], { encoding: "utf8", timeout: 1_000 }).trim();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const match = /^(\d+)\s+(\S+)\s+(\S+)$/.exec(row);
|
|
28
|
+
if (!match)
|
|
29
|
+
return;
|
|
30
|
+
if (path.basename(match[2]) === "claude")
|
|
31
|
+
return { pid, headless: match[3] === "?" || match[3] === "??" };
|
|
32
|
+
pid = Number(match[1]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function nativePath(file, session) {
|
|
36
|
+
const root = path.join(homedir(), ".claude", "projects");
|
|
37
|
+
if (!path.isAbsolute(file) || path.basename(file) !== `${session}.jsonl` || !file.startsWith(root + path.sep))
|
|
38
|
+
return false;
|
|
39
|
+
try {
|
|
40
|
+
return fs.realpathSync(path.dirname(file)).startsWith(fs.realpathSync(root) + path.sep);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Returns true for a recognized unmanaged headless worker, even when already registered. */
|
|
47
|
+
export function registerUnmanagedClaude(payload, store, cwd, env = process.env, processInfo) {
|
|
48
|
+
if (env.PHREN_FANOUT_JOB || env.PHREN_FANOUT_DIR)
|
|
49
|
+
return false;
|
|
50
|
+
const session = uuid(payload?.session_id);
|
|
51
|
+
const transcript = payload?.transcript_path;
|
|
52
|
+
const parentCodex = uuid(env.CODEX_THREAD_ID || env.CODEX_SESSION_ID);
|
|
53
|
+
const parentClaude = uuid(env.CLAUDE_CODE_SESSION_ID);
|
|
54
|
+
const parent = parentCodex ? { provider: "codex", session: parentCodex }
|
|
55
|
+
: parentClaude && parentClaude !== session ? { provider: "claude", session: parentClaude } : undefined;
|
|
56
|
+
if (!session || !parent || typeof transcript !== "string" || !nativePath(transcript, session))
|
|
57
|
+
return false;
|
|
58
|
+
const running = processInfo ?? claudeProcess();
|
|
59
|
+
if (!running?.pid || !(running.headless || env.CLAUDE_CODE_ENTRYPOINT?.startsWith("sdk-")))
|
|
60
|
+
return false;
|
|
61
|
+
const root = jobsRoot(store), id = `claude-unmanaged-${session}`;
|
|
62
|
+
if (fs.existsSync(root) && fs.realpathSync(root) !== path.join(fs.realpathSync(store), ".runtime", "agent-fanouts"))
|
|
63
|
+
return false;
|
|
64
|
+
if (fs.existsSync(root) && listJobs(store).some(job => job.provider === "claude" && job.session === session))
|
|
65
|
+
return true;
|
|
66
|
+
const job = path.join(root, id);
|
|
67
|
+
fs.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
68
|
+
fs.chmodSync(root, 0o700);
|
|
69
|
+
try {
|
|
70
|
+
fs.mkdirSync(job, { mode: 0o700 });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code === "EEXIST")
|
|
74
|
+
return true;
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
const now = new Date().toISOString(), worktree = path.resolve(payload?.cwd || cwd);
|
|
78
|
+
fs.writeFileSync(path.join(job, "events.jsonl"), "", { mode: 0o600 });
|
|
79
|
+
writeManifest(job, { schemaVersion: 1, id, parent, provider: "claude", session,
|
|
80
|
+
taskLabel: `Claude worker · ${path.basename(worktree)}`, cwd: worktree, worktree,
|
|
81
|
+
eventLog: "events.jsonl", nativeTranscript: transcript, unmanagedPid: running.pid,
|
|
82
|
+
createdAt: now, startedAt: now, updatedAt: now, status: "running" });
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
export function finishUnmanagedClaude(payload, store) {
|
|
86
|
+
const session = uuid(payload?.session_id);
|
|
87
|
+
if (!session)
|
|
88
|
+
return false;
|
|
89
|
+
const id = `claude-unmanaged-${session}`, job = path.join(jobsRoot(store), id);
|
|
90
|
+
let manifest;
|
|
91
|
+
try {
|
|
92
|
+
manifest = readJob(store, id);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (!manifest.nativeTranscript || (payload?.transcript_path && manifest.nativeTranscript !== payload.transcript_path))
|
|
98
|
+
return false;
|
|
99
|
+
if (manifest.status === "running") {
|
|
100
|
+
const now = new Date().toISOString();
|
|
101
|
+
writeManifest(job, { ...manifest, status: "completed", updatedAt: now, finishedAt: now, exitCode: 0 });
|
|
102
|
+
fs.writeFileSync(path.join(job, "exit.txt"), "0\n", { mode: 0o600 });
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
package/dist/cli/schedules.js
CHANGED
|
@@ -71,7 +71,8 @@ async function add(store, args) {
|
|
|
71
71
|
const now = new Date().toISOString();
|
|
72
72
|
const schedule = {
|
|
73
73
|
id: newScheduleId(file.schedules.map(item => item.id)), name, enabled: true, computer, harness,
|
|
74
|
-
...(option(args, "--model") ? { model: option(args, "--model") } : {}),
|
|
74
|
+
...(option(args, "--model") ? { model: option(args, "--model") } : {}),
|
|
75
|
+
...(option(args, "--account") ? { account: option(args, "--account") } : {}), every, prompt, createdAt: now, updatedAt: now,
|
|
75
76
|
...(option(args, "--at") ? { at: option(args, "--at") } : {}),
|
|
76
77
|
...(option(args, "--days") ? { days: option(args, "--days").split(",").map(day => day.trim().toLowerCase()) } : {}),
|
|
77
78
|
...(option(args, "--interval") ? { interval: option(args, "--interval") } : {}),
|
|
@@ -6,7 +6,7 @@ import { moduleEnabled } from "../modules/runtime.js";
|
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import * as crypto from "crypto";
|
|
9
|
-
import { buildHookContext, handleGuardSkip, debugLog, appendAuditLog, runtimeFile, sessionMarker, getProjectDirs, findProjectNameCaseInsensitive, projectSlugFromPath, updateRuntimeHealth, withFileLock, detectProject, isProjectHookEnabled, readProjectConfig, getProjectSourcePath, detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, errorMessage, resolveRuntimeProfile, } from "./hooks-context.js";
|
|
9
|
+
import { buildHookContext, handleGuardSkip, debugLog, appendAuditLog, runtimeFile, sessionMarker, getProjectDirs, findProjectNameCaseInsensitive, projectSlugFromPath, updateRuntimeHealth, withFileLock, detectProject, isProjectHookEnabled, readProjectConfig, getProjectSourcePath, detectProjectDir, ensureLocalGitRepo, isProjectTracked, repairPreexistingInstall, errorMessage, getPhrenPath, resolveRuntimeProfile, } from "./hooks-context.js";
|
|
10
10
|
import { TASKS_FILENAME } from "../data/tasks.js";
|
|
11
11
|
import { FINDINGS_FILENAME } from "../data/access.js";
|
|
12
12
|
import { readInstallPreferences } from "../init/preferences.js";
|
|
@@ -15,6 +15,7 @@ import { sessionFileForId, readSessionStateFile, writeSessionStateFile, } from "
|
|
|
15
15
|
import { runBestEffortGit, countUnsyncedCommits, pullAtSessionStart } from "./session-git.js";
|
|
16
16
|
import { scheduleBackgroundMaintenance } from "./session-background.js";
|
|
17
17
|
import { runDoctor } from "./hooks-context.js";
|
|
18
|
+
import { readClaudeHookPayload, registerUnmanagedClaude } from "./claude-unmanaged.js";
|
|
18
19
|
const SESSION_START_ONBOARDING_MARKER = "session-start-onboarding-v1";
|
|
19
20
|
const SYNC_WARN_MARKER = "sync-broken-warned-v1";
|
|
20
21
|
function projectHasBootstrapSignals(phrenPath, project) {
|
|
@@ -107,6 +108,14 @@ export function getSessionStartOnboardingNotice(phrenPath, cwd, activeProject) {
|
|
|
107
108
|
].join("\n");
|
|
108
109
|
}
|
|
109
110
|
export async function handleHookSessionStart() {
|
|
111
|
+
const payload = readClaudeHookPayload();
|
|
112
|
+
// A hand-rolled claude -p worker registers under its launcher, then gets the usual context.
|
|
113
|
+
try {
|
|
114
|
+
registerUnmanagedClaude(payload, getPhrenPath(), process.cwd());
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
debugLog(`hook-session-start worker registration failed: ${errorMessage(err)}`);
|
|
118
|
+
}
|
|
110
119
|
const startedAt = new Date().toISOString();
|
|
111
120
|
const ctx = buildHookContext();
|
|
112
121
|
const { phrenPath, cwd, activeProject, manifest } = ctx;
|
package/dist/cli/session-stop.js
CHANGED
|
@@ -14,6 +14,7 @@ import { spawnDetachedChild } from "../shared/process.js";
|
|
|
14
14
|
import { resolveManagementCapabilities } from "../init/management-preset.js";
|
|
15
15
|
import { aheadBehind, logSyncOutcome } from "../sync/outcome.js";
|
|
16
16
|
import { storeCommitMessage } from "../machine-identity.js";
|
|
17
|
+
import { finishUnmanagedClaude } from "./claude-unmanaged.js";
|
|
17
18
|
// ── Utility ─────────────────────────────────────────────────────────────────
|
|
18
19
|
/** Read JSON from stdin if it's not a TTY. Returns null if stdin is a TTY or parsing fails. */
|
|
19
20
|
function readStdinJson() {
|
|
@@ -173,6 +174,14 @@ function getSessionCap() {
|
|
|
173
174
|
}
|
|
174
175
|
// ── Hook stop handler ───────────────────────────────────────────────────────
|
|
175
176
|
export async function handleHookStop() {
|
|
177
|
+
// Stop is the terminal event for a one-shot Claude print session.
|
|
178
|
+
const stdinPayload = readStdinJson();
|
|
179
|
+
try {
|
|
180
|
+
finishUnmanagedClaude(stdinPayload ?? undefined, getPhrenPath());
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
debugLog(`hook-stop worker finish failed: ${errorMessage(err)}`);
|
|
184
|
+
}
|
|
176
185
|
const ctx = buildHookContext();
|
|
177
186
|
const { phrenPath, activeProject, manifest } = ctx;
|
|
178
187
|
const now = new Date().toISOString();
|
|
@@ -197,7 +206,6 @@ export async function handleHookStop() {
|
|
|
197
206
|
}
|
|
198
207
|
// Read stdin early — it's a stream and can only be consumed once.
|
|
199
208
|
// Needed for auto-capture transcript_path parsing.
|
|
200
|
-
const stdinPayload = readStdinJson();
|
|
201
209
|
const taskSessionId = typeof stdinPayload?.session_id === "string" ? stdinPayload.session_id : undefined;
|
|
202
210
|
const taskLevel = getProactivityLevelForTask(phrenPath);
|
|
203
211
|
if (taskSessionId && taskLevel !== "high") {
|
package/dist/cli-registry.js
CHANGED
|
@@ -66,7 +66,7 @@ const PROJECTS_SUBCOMMANDS = [
|
|
|
66
66
|
];
|
|
67
67
|
const SCHEDULE_SUBCOMMANDS = [
|
|
68
68
|
{ name: "list", usage: "phren schedule list [project]", summary: "List scheduled prompts" },
|
|
69
|
-
{ name: "add", usage: "phren schedule add <project> --name <name> --harness <name> --computer <name> [--model <model>] --every <kind> [timing] (--prompt <text>|--prompt-file <path>)", summary: "Add a scheduled prompt" },
|
|
69
|
+
{ name: "add", usage: "phren schedule add <project> --name <name> --harness <name> --computer <name> [--model <model>] [--account <id>] --every <kind> [timing] (--prompt <text>|--prompt-file <path>)", summary: "Add a scheduled prompt" },
|
|
70
70
|
{ name: "remove", usage: "phren schedule remove <project> <id>", summary: "Remove a scheduled prompt" },
|
|
71
71
|
{ name: "enable", usage: "phren schedule enable <project> <id>", summary: "Resume a scheduled prompt" },
|
|
72
72
|
{ name: "disable", usage: "phren schedule disable <project> <id>", summary: "Pause a scheduled prompt" },
|
|
@@ -141,14 +141,17 @@ export const REGISTRY = [
|
|
|
141
141
|
},
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
|
-
name: "bridge", topic: "setup", usage: "phren bridge <install|status|doctor|update|rollback|uninstall|enroll-computer|discover|link|fanouts archive|speech-key set>",
|
|
144
|
+
name: "bridge", topic: "setup", usage: "phren bridge <install|status|doctor|update|rollback|uninstall|enroll-computer|accounts|discover|link|fanouts archive|speech-key set|speech-voice|speech-model>",
|
|
145
145
|
summary: "Install Phren Hook and enroll phone or computer connections",
|
|
146
146
|
subcommands: [
|
|
147
147
|
{ name: "enroll-computer", usage: "phren bridge enroll-computer <name> [--accept <public-key-file>]", summary: "Print or accept a restricted computer dispatch key" },
|
|
148
|
+
{ name: "accounts", usage: "phren bridge accounts [add <slug> [--label <name>] | label <id> <label>]", summary: "List this computer's harnesses and Claude accounts, add a Claude account home, or label one" },
|
|
148
149
|
{ name: "discover", usage: "phren bridge discover", summary: "List computers you already reach over ssh that run Phren Hook and are not linked" },
|
|
149
150
|
{ name: "link", usage: "phren bridge link <ssh-host> [--name <name>] [--as <name>] [--back-address <address>] [--yes]", summary: "Link this computer and an ssh host both ways in one step, after confirming" },
|
|
150
151
|
{ name: "fanouts archive", usage: "phren bridge fanouts archive [--dry-run] [--parent <session-id>] [--older-than <minutes>]", summary: "Archive finished fan-out jobs older than 24 hours, or one parent chat's, or older than N minutes" },
|
|
151
152
|
{ name: "speech-key set", usage: "phren bridge speech-key set", summary: "Store this computer's ElevenLabs key for spoken replies and dictation (read from stdin, mode 600)" },
|
|
153
|
+
{ name: "speech-voice", usage: "phren bridge speech-voice [show | set <voice-id> | clear]", summary: "Show or set the ElevenLabs voice talk mode speaks with; kept across install and update" },
|
|
154
|
+
{ name: "speech-model", usage: "phren bridge speech-model [show | set <model-id> | clear]", summary: "Show or set the ElevenLabs model talk mode speaks with (default eleven_v4_turbo); kept across install and update" },
|
|
152
155
|
],
|
|
153
156
|
run: async (args) => {
|
|
154
157
|
const { runBridge } = await import("./bridge/command.js");
|
|
@@ -157,7 +160,7 @@ export const REGISTRY = [
|
|
|
157
160
|
},
|
|
158
161
|
},
|
|
159
162
|
{
|
|
160
|
-
name: "dispatch", topic: "core", usage: "phren dispatch <computer|anywhere> <project> --label <label> --prompt <brief> [--harness codex|claude|opencode] [--model <model>]",
|
|
163
|
+
name: "dispatch", topic: "core", usage: "phren dispatch <computer|anywhere> <project> --label <label> --prompt <brief> [--harness codex|claude|opencode] [--model <model>] [--effort <effort>] [--account <id>] [--permission-mode <mode>]",
|
|
161
164
|
summary: "Dispatch a worker brief through Phren Hook",
|
|
162
165
|
subcommands: [{ name: "status", usage: "phren dispatch status", summary: "List local dispatch receipts" },
|
|
163
166
|
{ name: "returns", usage: "phren dispatch returns", summary: "List unread worker returns (done, needs you, blocked, gone) and mark them read" },
|
|
@@ -178,7 +181,7 @@ export const REGISTRY = [
|
|
|
178
181
|
run: async (args) => (await import("./computers/command.js")).runUsage(args),
|
|
179
182
|
},
|
|
180
183
|
{
|
|
181
|
-
name: "hand-off", topic: "core", usage: "phren hand-off <computer|local> --session <id> --text <prompt>",
|
|
184
|
+
name: "hand-off", topic: "core", usage: "phren hand-off <computer|local> --session <id> --text <prompt> [--account <id>]",
|
|
182
185
|
summary: "Send work to an existing agent session through Phren Hook",
|
|
183
186
|
run: async (args) => (await import("./bridge/dispatch-command.js")).runHandOff(args),
|
|
184
187
|
},
|
|
@@ -189,12 +192,28 @@ export const REGISTRY = [
|
|
|
189
192
|
},
|
|
190
193
|
{
|
|
191
194
|
name: "conductor", topic: "core", usage: "phren conductor <subcommand>",
|
|
192
|
-
summary: "
|
|
195
|
+
summary: "Make or stop this computer's conductor, list linked computer sets, and manage standing grants",
|
|
193
196
|
subcommands: [
|
|
197
|
+
{ name: "status", usage: "phren conductor status", summary: "This computer's conductor and the set name it holds" },
|
|
198
|
+
{ name: "make", usage: "phren conductor make [--pane <id>] [--mux herdr:<name>|tmux:<name>]", summary: "Make the agent in this pane (or --pane) this computer's conductor" },
|
|
199
|
+
{ name: "stop", usage: "phren conductor stop [--pane <id>]", summary: "End this computer's conductor role; the agent keeps running" },
|
|
200
|
+
{ name: "sets", usage: "phren conductor sets [--json] | phren conductor sets name <name>|--clear", summary: "List linked computer sets with reachability and conductors, or name this computer's set" },
|
|
194
201
|
{ name: "grants", usage: "phren conductor grants [list|add|remove]", summary: "List, add, or remove conductor grants" },
|
|
195
202
|
],
|
|
196
203
|
run: async (args) => (await import("./bridge/dispatch-command.js")).runConductor(args),
|
|
197
204
|
},
|
|
205
|
+
{
|
|
206
|
+
name: "authority", topic: "core", usage: "phren authority [list | show <project> | set <project> ... | clear <project> | confirm <project> <actions>]",
|
|
207
|
+
summary: "Read the owner's release authority policy; the owner changes it or confirms an ask-first release",
|
|
208
|
+
subcommands: [
|
|
209
|
+
{ name: "list", usage: "phren authority list", summary: "Every project the policy names, and confirmations waiting to be used" },
|
|
210
|
+
{ name: "show", usage: "phren authority show <project>", summary: "One project's go and ask-first actions, ceiling, and the line to quote in a brief" },
|
|
211
|
+
{ name: "set", usage: "phren authority set <project> [--default go|ask] [--go <actions>] [--ask <actions>] [--max-permission-mode <mode>|none] [--note <text>]", summary: "Change a project's entry (owner, interactive terminal)" },
|
|
212
|
+
{ name: "clear", usage: "phren authority clear <project>", summary: "Remove a project's entry (owner, interactive terminal)" },
|
|
213
|
+
{ name: "confirm", usage: "phren authority confirm <project> <actions> [--minutes <n>]", summary: "Let one agent dispatch do ask-first release actions (owner, interactive terminal)" },
|
|
214
|
+
],
|
|
215
|
+
run: async (args) => (await import("./bridge/authority-command.js")).runAuthority(args),
|
|
216
|
+
},
|
|
198
217
|
// Setup (featured: init, quickstart)
|
|
199
218
|
{
|
|
200
219
|
name: "init",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RunStoreGit } from "../sync/store-merge.js";
|
|
2
|
+
export interface TaskWriteReceipt {
|
|
3
|
+
path: string;
|
|
4
|
+
/** A verified commit containing this write, or null if none was observed. */
|
|
5
|
+
commit: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** Scope receipts to one queued mutation, including its asynchronous claim sync. */
|
|
8
|
+
export declare function captureTaskWrites<T>(fn: () => Promise<T>): Promise<{
|
|
9
|
+
result: T;
|
|
10
|
+
write: TaskWriteReceipt | null;
|
|
11
|
+
}>;
|
|
12
|
+
/** Called only after the task file's atomic rename succeeds. */
|
|
13
|
+
export declare function recordTaskWrite(file: string, content: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Observe commits made by task claim sync without changing when it commits.
|
|
16
|
+
* Keep the autosave's hash even if a later fetch/merge moves HEAD or push fails.
|
|
17
|
+
* Reading HEAD alone would also acknowledge unrelated or failed commits.
|
|
18
|
+
*/
|
|
19
|
+
export declare function trackTaskWriteCommits(git: RunStoreGit): RunStoreGit;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const writes = new AsyncLocalStorage();
|
|
5
|
+
/** Scope receipts to one queued mutation, including its asynchronous claim sync. */
|
|
6
|
+
export async function captureTaskWrites(fn) {
|
|
7
|
+
const state = {};
|
|
8
|
+
return writes.run(state, async () => ({ result: await fn(), write: state.write?.receipt ?? null }));
|
|
9
|
+
}
|
|
10
|
+
/** Called only after the task file's atomic rename succeeds. */
|
|
11
|
+
export function recordTaskWrite(file, content) {
|
|
12
|
+
const state = writes.getStore();
|
|
13
|
+
if (state)
|
|
14
|
+
state.write = { receipt: { path: path.resolve(file), commit: null }, content };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Observe commits made by task claim sync without changing when it commits.
|
|
18
|
+
* Keep the autosave's hash even if a later fetch/merge moves HEAD or push fails.
|
|
19
|
+
* Reading HEAD alone would also acknowledge unrelated or failed commits.
|
|
20
|
+
*/
|
|
21
|
+
export function trackTaskWriteCommits(git) {
|
|
22
|
+
return async (cwd, args) => {
|
|
23
|
+
const write = writes.getStore()?.write;
|
|
24
|
+
const committing = args[0] === "commit" || (args[0] === "-c" && args[2] === "commit");
|
|
25
|
+
if (!write || !committing)
|
|
26
|
+
return git(cwd, args);
|
|
27
|
+
let before;
|
|
28
|
+
try {
|
|
29
|
+
before = await git(cwd, ["rev-parse", "--verify", "HEAD"]);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return git(cwd, args);
|
|
33
|
+
}
|
|
34
|
+
const result = await git(cwd, args);
|
|
35
|
+
if (!result.ok)
|
|
36
|
+
return result;
|
|
37
|
+
// Verification is best effort and must never turn a completed write into a failure.
|
|
38
|
+
try {
|
|
39
|
+
const relative = path.relative(path.resolve(cwd), write.receipt.path).split(path.sep).join("/");
|
|
40
|
+
if (relative.startsWith("../") || path.isAbsolute(relative))
|
|
41
|
+
return result;
|
|
42
|
+
const head = await git(cwd, ["rev-list", "--parents", "-n", "1", "HEAD"]);
|
|
43
|
+
if (!head.ok)
|
|
44
|
+
return result;
|
|
45
|
+
const [commit, ...parents] = head.output.trim().split(/\s+/);
|
|
46
|
+
if (!/^[0-9a-f]{40,64}$/.test(commit))
|
|
47
|
+
return result;
|
|
48
|
+
if (before.ok ? parents.length !== 1 || parents[0] !== before.output.trim() : parents.length !== 0)
|
|
49
|
+
return result;
|
|
50
|
+
const tree = await git(cwd, ["ls-tree", commit, "--", relative]);
|
|
51
|
+
const blob = tree.ok && /^\d+ blob ([0-9a-f]+)\t/.exec(tree.output)?.[1];
|
|
52
|
+
if (!blob)
|
|
53
|
+
return result;
|
|
54
|
+
const expected = createHash(blob.length === 64 ? "sha256" : "sha1")
|
|
55
|
+
.update(`blob ${Buffer.byteLength(write.content)}\0`).update(write.content).digest("hex");
|
|
56
|
+
if (blob !== expected)
|
|
57
|
+
return result;
|
|
58
|
+
if (parents.length) {
|
|
59
|
+
const prior = await git(cwd, ["ls-tree", parents[0], "--", relative]);
|
|
60
|
+
if (!prior.ok || /^\d+ blob ([0-9a-f]+)\t/.exec(prior.output)?.[1] === blob)
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
write.receipt.commit = commit;
|
|
64
|
+
}
|
|
65
|
+
catch { /* Leave the receipt uncommitted when verification is unavailable. */ }
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
}
|
package/dist/data/tasks.js
CHANGED
|
@@ -9,6 +9,7 @@ import { withSafeLock, ensureProject } from "../shared/data-utils.js";
|
|
|
9
9
|
import { getNonPrimaryStores, getStoreProjectDirs } from "../store-registry.js";
|
|
10
10
|
import { storeAwareProjectPath } from "../store-routing.js";
|
|
11
11
|
import { TASKS_FILENAME } from "../filenames.js";
|
|
12
|
+
import { recordTaskWrite } from "./task-receipts.js";
|
|
12
13
|
const ACTIVE_HEADINGS = new Set(["active", "in progress", "in-progress", "current", "wip"]);
|
|
13
14
|
const QUEUE_HEADINGS = new Set(["queue", "queued", "task", "todo", "upcoming", "next"]);
|
|
14
15
|
const DONE_HEADINGS = new Set(["done", "completed", "finished", "archived"]);
|
|
@@ -348,8 +349,10 @@ function taskItemNotFound(project, match) {
|
|
|
348
349
|
}
|
|
349
350
|
function writeTaskDoc(doc) {
|
|
350
351
|
const tmpPath = `${doc.path}.tmp-${randomUUID()}`;
|
|
351
|
-
|
|
352
|
+
const content = renderTask(doc);
|
|
353
|
+
fs.writeFileSync(tmpPath, content);
|
|
352
354
|
fs.renameSync(tmpPath, doc.path);
|
|
355
|
+
recordTaskWrite(doc.path, content);
|
|
353
356
|
}
|
|
354
357
|
function taskArchivePath(phrenPath, project) {
|
|
355
358
|
return path.join(phrenPath, ".config", "task-archive", `${project}.md`);
|