@phren/cli 0.3.0 → 0.3.1
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-hooks.d.ts +15 -6
- package/dist/bridge/agent-hooks.js +55 -24
- package/dist/bridge/claude-question-dialog.d.ts +65 -0
- package/dist/bridge/claude-question-dialog.js +210 -0
- package/dist/bridge/command.js +92 -2
- package/dist/bridge/computers.d.ts +5 -0
- package/dist/bridge/computers.js +10 -4
- package/dist/bridge/conductor-group.d.ts +23 -0
- package/dist/bridge/conductor-group.js +25 -0
- package/dist/bridge/hand-off.js +5 -1
- package/dist/bridge/herdr.d.ts +7 -0
- package/dist/bridge/herdr.js +53 -2
- package/dist/bridge/link.d.ts +48 -0
- package/dist/bridge/link.js +136 -0
- package/dist/bridge/memory-store.d.ts +23 -0
- package/dist/bridge/memory-store.js +152 -0
- package/dist/bridge/pair.d.ts +46 -0
- package/dist/bridge/pair.js +240 -0
- package/dist/bridge/peers.d.ts +9 -0
- package/dist/bridge/peers.js +25 -2
- package/dist/bridge/server-launch.d.ts +9 -0
- package/dist/bridge/server-launch.js +34 -11
- package/dist/bridge/server-pane-routes.js +38 -7
- package/dist/bridge/server-routes.d.ts +1 -0
- package/dist/bridge/server-routes.js +11 -3
- package/dist/bridge/server-stream.js +4 -1
- package/dist/bridge/speech-key.d.ts +33 -0
- package/dist/bridge/speech-key.js +106 -0
- package/dist/bridge/speech-transcribe.js +1 -1
- package/dist/bridge/speech.d.ts +1 -3
- package/dist/bridge/speech.js +2 -16
- package/dist/bridge-hook.mjs +1198 -492
- package/dist/cli-handlers.js +6 -0
- package/dist/cli-registry.js +14 -2
- package/dist/content/learning.js +1 -1
- package/dist/data/tasks.d.ts +26 -0
- package/dist/data/tasks.js +72 -1
- package/dist/entrypoint.js +7 -0
- package/dist/governance/rbac.d.ts +1 -1
- package/dist/governance/rbac.js +1 -0
- package/dist/init/init-walkthrough.d.ts +10 -0
- package/dist/init/init-walkthrough.js +24 -1
- package/dist/init/init.d.ts +5 -0
- package/dist/init/init.js +54 -32
- package/dist/link/doctor.js +10 -0
- package/dist/mcp/profile.js +2 -1
- package/dist/modules/config.d.ts +7 -0
- package/dist/modules/config.js +17 -0
- package/dist/modules/registry.js +5 -4
- package/dist/sync/task-claim.d.ts +22 -0
- package/dist/sync/task-claim.js +45 -0
- package/dist/tools/dispatch.js +2 -2
- package/dist/tools/tasks.js +40 -1
- package/package.json +2 -1
- package/starter/global/skills/conductor/SKILL.md +41 -9
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { runBestEffortGit } from "../cli/session-git.js";
|
|
2
|
+
import { claimTask, resolveTaskItem } from "../data/tasks.js";
|
|
3
|
+
import { withFileLock } from "../governance/locks.js";
|
|
4
|
+
import { runtimeFile } from "../phren-paths.js";
|
|
5
|
+
import { mergeStoreUpstream } from "./store-merge.js";
|
|
6
|
+
const git = async (cwd, args) => {
|
|
7
|
+
const result = await runBestEffortGit(args, cwd);
|
|
8
|
+
return { ok: result.ok, output: result.output ?? "", error: result.error };
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Claims a task across unlinked conductors: pull the store so a claim already
|
|
12
|
+
* pushed elsewhere refuses this one, write the claim, then commit and push.
|
|
13
|
+
* When another computer's claim reached the remote first, the store merge
|
|
14
|
+
* keeps theirs, so the task is read again after the push to see who won.
|
|
15
|
+
*/
|
|
16
|
+
export async function claimTaskSynced(phrenPath, project, match, claim, opts = {}) {
|
|
17
|
+
return withFileLock(runtimeFile(phrenPath, "git-op"), async () => {
|
|
18
|
+
const pulled = await mergeStoreUpstream(phrenPath, { git, commitMessage: "auto-save phren (task claim)" });
|
|
19
|
+
const offline = pulled.status === "error" || pulled.status === "busy" ? pulled.detail : undefined;
|
|
20
|
+
const written = claimTask(phrenPath, project, match, claim, opts);
|
|
21
|
+
if (!written.ok)
|
|
22
|
+
return { claimed: false, synced: !offline, detail: offline ?? "", error: written.error };
|
|
23
|
+
const bid = written.data.stableId ?? match;
|
|
24
|
+
const verb = opts.release ? "releases" : "claims";
|
|
25
|
+
const saved = await mergeStoreUpstream(phrenPath, { git, commitMessage: `phren: ${claim.computer} ${verb} ${project} task ${bid}` });
|
|
26
|
+
if (offline || saved.status === "error" || saved.status === "busy") {
|
|
27
|
+
return { claimed: !opts.release, item: written.data, synced: false, detail: `The change is written on this computer but not synced: ${offline ?? saved.detail}` };
|
|
28
|
+
}
|
|
29
|
+
if (/no tracking remote/i.test(saved.detail)) {
|
|
30
|
+
return { claimed: !opts.release, item: written.data, synced: false, detail: "The store has no remote, so the change is only on this computer." };
|
|
31
|
+
}
|
|
32
|
+
let pushed = await git(phrenPath, ["push", "--quiet"]);
|
|
33
|
+
if (!pushed.ok) {
|
|
34
|
+
const merged = await mergeStoreUpstream(phrenPath, { git, commitLocalWrites: false });
|
|
35
|
+
pushed = merged.status === "updated" || merged.status === "unchanged" ? await git(phrenPath, ["push", "--quiet"]) : { ok: false, output: "", error: merged.detail };
|
|
36
|
+
}
|
|
37
|
+
const current = resolveTaskItem(phrenPath, project, bid);
|
|
38
|
+
const now = current.ok ? current.data : undefined;
|
|
39
|
+
if (!opts.release && now?.claim && now.claim.computer !== claim.computer) {
|
|
40
|
+
return { claimed: false, item: now, heldBy: now.claim, synced: pushed.ok, detail: `${now.claim.computer} claimed this task first.` };
|
|
41
|
+
}
|
|
42
|
+
return { claimed: !opts.release, item: now ?? written.data, synced: pushed.ok,
|
|
43
|
+
detail: pushed.ok ? "Pushed to the store's remote." : `Committed but not pushed: ${pushed.error ?? "push failed"}` };
|
|
44
|
+
});
|
|
45
|
+
}
|
package/dist/tools/dispatch.js
CHANGED
|
@@ -41,9 +41,9 @@ export function register(server) {
|
|
|
41
41
|
try {
|
|
42
42
|
const result = await listLiveSessions();
|
|
43
43
|
const note = result.peerError ? ` Enrolled computers were skipped: ${result.peerError}`
|
|
44
|
-
: result.enrolled === 0 && !result.notLinked.length ? " No other computers are
|
|
44
|
+
: result.enrolled === 0 && !result.notLinked.length ? " No other computers are linked here; `phren bridge discover` lists the ones you already reach over ssh, and `phren bridge link <host>` links one." : "";
|
|
45
45
|
const unlinked = result.notLinked.length
|
|
46
|
-
? ` Not linked, so not checked (this does not mean nothing is running there): ${result.notLinked.map(item => item.aliases?.length ? `${item.name} (also ${item.aliases.join(", ")})` : item.name).join("; ")}.
|
|
46
|
+
? ` Not linked, so not checked (this does not mean nothing is running there): ${result.notLinked.map(item => item.aliases?.length ? `${item.name} (also ${item.aliases.join(", ")})` : item.name).join("; ")}. If you reach one over ssh, the owner can link it with \`phren bridge link <host>\`; never link a computer without the owner asking.` : "";
|
|
47
47
|
return mcpResponse({ ok: true, data: result, message: `${result.sessions.length} live sessions across ${result.enrolled + 1} computers.${note}${unlinked}` });
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
package/dist/tools/tasks.js
CHANGED
|
@@ -10,6 +10,8 @@ import { clearTaskCheckpoint } from "../session/checkpoints.js";
|
|
|
10
10
|
import { incrementSessionTasksCompleted } from "./session.js";
|
|
11
11
|
import { normalizeMemoryScope } from "../shared.js";
|
|
12
12
|
import { permissionDeniedError } from "../governance/rbac.js";
|
|
13
|
+
import { getMachineName } from "../machine-identity.js";
|
|
14
|
+
import { claimTaskSynced } from "../sync/task-claim.js";
|
|
13
15
|
const TASK_SECTION_ORDER = ["Active", "Queue", "Done"];
|
|
14
16
|
const DEFAULT_TASK_LIMIT = 20;
|
|
15
17
|
/** Done items are historical — cap tightly by default to avoid large responses. */
|
|
@@ -80,7 +82,8 @@ function buildTaskSummary(doc, includedSections) {
|
|
|
80
82
|
const prio = item.priority ? ` [${item.priority}]` : "";
|
|
81
83
|
const bidPrefix = item.stableId ? `bid:${item.stableId} ` : "";
|
|
82
84
|
const githubTag = item.githubIssue ? ` [gh:#${item.githubIssue}]` : item.githubUrl ? " [gh]" : "";
|
|
83
|
-
|
|
85
|
+
const claimTag = item.claim ? ` [claimed: ${item.claim.computer}]` : "";
|
|
86
|
+
lines.push(` - ${bidPrefix}${item.line.slice(0, 80)}${item.line.length > 80 ? "\u2026" : ""}${prio}${githubTag}${claimTag}`);
|
|
84
87
|
}
|
|
85
88
|
if (items.length > 3)
|
|
86
89
|
lines.push(` ... and ${items.length - 3} more`);
|
|
@@ -548,6 +551,42 @@ export function register(server, ctx) {
|
|
|
548
551
|
return mcpResponse({ ok: true, message: result.data, data: { project, keep: keep ?? 30, dryRun: dry_run ?? false } });
|
|
549
552
|
});
|
|
550
553
|
});
|
|
554
|
+
server.registerTool("claim_task", {
|
|
555
|
+
title: "◆ phren · claim task",
|
|
556
|
+
description: "Claim a task for this computer so conductors that are not linked do not take the same work: " +
|
|
557
|
+
"syncs the store, moves the task to Active with a `Claimed:` line naming this computer, then commits and pushes. " +
|
|
558
|
+
"Refuses a task another computer holds. With release, clears this computer's claim and returns the task to the Queue. " +
|
|
559
|
+
"Conductors skip tasks claimed by other computers.",
|
|
560
|
+
inputSchema: z.object({
|
|
561
|
+
project: z.string().describe("Project name."),
|
|
562
|
+
item: z.string().describe("Task to claim: bid:XXXXXXXX, a positional ID (Q3) or its text."),
|
|
563
|
+
session: z.string().regex(/^[A-Za-z0-9._:-]{1,128}$/).optional().describe("The claiming conductor's session id, recorded with the claim."),
|
|
564
|
+
release: z.boolean().optional().describe("Release this computer's claim instead of taking one."),
|
|
565
|
+
force: z.boolean().optional().describe("Take over another computer's claim once it is more than a day old."),
|
|
566
|
+
}),
|
|
567
|
+
}, async ({ project: projectInput, item, session, release, force }) => {
|
|
568
|
+
const resolved = resolveStoreForProject(ctx, projectInput);
|
|
569
|
+
const project = resolved.project;
|
|
570
|
+
const targetPath = resolved.phrenPath;
|
|
571
|
+
if (!isValidProjectName(project))
|
|
572
|
+
return mcpResponse({ ok: false, error: `Invalid project name: "${project}"` });
|
|
573
|
+
const denied = permissionDeniedError(targetPath, "claim_task", project);
|
|
574
|
+
if (denied)
|
|
575
|
+
return mcpResponse({ ok: false, error: denied });
|
|
576
|
+
return withWriteQueue(async () => {
|
|
577
|
+
// The Claimed line takes a plain token; a name with spaces would never parse back.
|
|
578
|
+
const computer = getMachineName().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[^A-Za-z0-9]+/, "") || "computer";
|
|
579
|
+
const claim = { computer, at: new Date().toISOString().replace(/\.\d{3}Z$/, "Z"), ...(session ? { session } : {}) };
|
|
580
|
+
const outcome = await claimTaskSynced(targetPath, project, item, claim, { release, force });
|
|
581
|
+
if (outcome.error)
|
|
582
|
+
return mcpResponse({ ok: false, error: outcome.error });
|
|
583
|
+
refreshTaskIndex(updateFileInIndex, targetPath, project);
|
|
584
|
+
const message = release ? `Released in ${project}. ${outcome.detail}`
|
|
585
|
+
: outcome.claimed ? `Claimed for ${claim.computer} in ${project}. ${outcome.detail}` : `Not claimed: ${outcome.detail}`;
|
|
586
|
+
return mcpResponse({ ok: release ? true : outcome.claimed, message,
|
|
587
|
+
data: { project, item: outcome.item?.stableId ? `bid:${outcome.item.stableId}` : item, claim: outcome.item?.claim, heldBy: outcome.heldBy, synced: outcome.synced } });
|
|
588
|
+
});
|
|
589
|
+
});
|
|
551
590
|
server.registerTool("pin_task", {
|
|
552
591
|
title: "◆ phren · pin task",
|
|
553
592
|
description: "Pin or unpin a task. Pinned tasks always appear in hook context regardless of priority, " +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phren/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Knowledge layer for AI agents - CLI, MCP server, and data layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -155,6 +155,7 @@
|
|
|
155
155
|
"inquirer": "^14.2.2",
|
|
156
156
|
"js-yaml": "^5.4.2",
|
|
157
157
|
"sql.js-fts5": "^1.4.0",
|
|
158
|
+
"uqr": "0.1.3",
|
|
158
159
|
"ws": "8.21.3",
|
|
159
160
|
"zod": "^4.6.5"
|
|
160
161
|
},
|
|
@@ -35,19 +35,40 @@ Your tools, use these instead of exploring the CLI or the Hook's files:
|
|
|
35
35
|
- `phren dispatch status`: receipts of what you dispatched.
|
|
36
36
|
- `get_tasks`, `get_project_summary`, `search_knowledge`: the store's memory.
|
|
37
37
|
|
|
38
|
-
Keep
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Keep engineering detail in worker briefs, Phren tasks and findings, and review
|
|
39
|
+
artifacts, not in the owner's chat.
|
|
40
|
+
|
|
41
|
+
## Voice and pace
|
|
42
|
+
|
|
43
|
+
The owner talks to you from the phone, often in talk mode, where your replies
|
|
44
|
+
are read aloud in their voice. Sound like a good dispatcher: short, quick and
|
|
45
|
+
conversational.
|
|
46
|
+
|
|
47
|
+
- Lead with the outcome in one sentence. Keep the whole reply to one to four
|
|
48
|
+
short sentences unless the owner asks for detail.
|
|
49
|
+
- No tables, file paths, SHAs, PR numbers or run IDs in a reply unless the
|
|
50
|
+
owner asks for them. Record them in Phren tasks and findings instead.
|
|
51
|
+
- One short line per dispatch or return: who, what, result. A routine watcher
|
|
52
|
+
or monitor event where nothing changed gets silence or a single line.
|
|
53
|
+
- When the owner gives you a task, dispatch an engineer for it right away and
|
|
54
|
+
say so in one line. That is the owner's standing rule; do not ask first.
|
|
55
|
+
- Ask at most one question at a time, and name the options.
|
|
56
|
+
- Delegate reading and analysis to workers instead of running long
|
|
57
|
+
investigations yourself, so your own turns stay fast.
|
|
58
|
+
- A message that begins with `[voice]` was spoken in talk mode, and your reply
|
|
59
|
+
will be read aloud. Answer in one or two spoken sentences with no markdown,
|
|
60
|
+
lists, symbols or code, written to sound natural read aloud: "back in about
|
|
61
|
+
twenty minutes", not "ETA ~20m".
|
|
41
62
|
|
|
42
63
|
```text
|
|
43
|
-
Linuxbox
|
|
44
|
-
Desk
|
|
64
|
+
Linuxbox has the parser checks on Codex, back around two twenty.
|
|
65
|
+
Desk finished the navigation checks: tests passed, not merged yet.
|
|
45
66
|
```
|
|
46
67
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
If a result or return time is unknown, say so. Surface a worker's question in
|
|
69
|
+
the same short voice, with the worker's own choices.
|
|
70
|
+
|
|
71
|
+
## Dispatching
|
|
51
72
|
|
|
52
73
|
Pick five to ten independent tasks when that many are available and capacity
|
|
53
74
|
permits. Do not manufacture tasks to fill the batch. Separate dependencies and
|
|
@@ -56,6 +77,17 @@ fanout limit, report time and integration instructions. Every brief repeats the
|
|
|
56
77
|
owner's repository constraints, including any prohibition on commits, pushes,
|
|
57
78
|
branches or particular tests. Dispatch never expands the owner's authorization.
|
|
58
79
|
|
|
80
|
+
You are the one conductor for this computer and every computer linked with
|
|
81
|
+
it; a second conductor in the group is refused at launch. Conductors on
|
|
82
|
+
computers that are not linked share only the store, so claim a task before you
|
|
83
|
+
dispatch it: `claim_task` (in core, `manage_task` with `action: "claim"`).
|
|
84
|
+
Skip tasks marked `[claimed: <computer>]` by another computer. A claim that
|
|
85
|
+
comes back not claimed, with `heldBy`, means another conductor got there first:
|
|
86
|
+
move on. Completing a task clears its claim; release one you will not do. Start
|
|
87
|
+
workers with `dispatch` or `hand_off`, never as tabs in your own Herdr
|
|
88
|
+
workspace. When a computer shows up in `notLinked`, tell the owner that
|
|
89
|
+
`phren bridge link <host>` can link it; never link a computer yourself.
|
|
90
|
+
|
|
59
91
|
Prefer Codex. Use OpenCode Go when its account and harness are connected. Use
|
|
60
92
|
OpenRouter only when the owner explicitly requests it; an unavailable account
|
|
61
93
|
does not authorize another paid provider. Name an explicit model when instructed,
|