pi-straw-boss 0.100.2 → 0.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/{chunk-CS4SR3S3.mjs → chunk-WTEFOEUM.mjs} +2 -0
- package/dist/server/cli.mjs +1 -1
- package/dist/server/main.mjs +3 -2
- package/package.json +1 -1
- package/prompts/member.md +1 -1
- package/prompts/planning.md +2 -1
- package/src/callpeer.ts +52 -0
- package/src/header.ts +1 -1
- package/src/index.ts +3 -1
- package/src/items.ts +3 -3
- package/src/membership.ts +1 -1
- package/src/planhint.ts +57 -0
- package/src/session.ts +2 -0
- package/src/tools.ts +1 -1
|
@@ -5472,6 +5472,7 @@ var AGENT_DUTY = { worker: "worker", scout: "scout", planner: "planner", reviewe
|
|
|
5472
5472
|
var GRAPHS = ["single-loop", "fan-out/fan-in", "orchestrator-worker"];
|
|
5473
5473
|
var isCoordinatorDuty = (v) => typeof v === "string" && COORDINATOR_DUTIES.includes(v);
|
|
5474
5474
|
var isMainKind = (v) => isCoordinatorDuty(v) || v === "worker";
|
|
5475
|
+
var isGraph = (v) => typeof v === "string" && GRAPHS.includes(v);
|
|
5475
5476
|
var graphOf = (v) => v === "orchestrator-worker" ? v : v === "fan-out/fan-in" || v === "fan-out" ? "fan-out/fan-in" : v === "single" || typeof v === "string" && v.startsWith("single-loop") ? "single-loop" : void 0;
|
|
5476
5477
|
var dutyOfAgent = (name) => name !== void 0 && Object.hasOwn(AGENT_DUTY, name) ? AGENT_DUTY[name] : void 0;
|
|
5477
5478
|
|
|
@@ -8291,6 +8292,7 @@ export {
|
|
|
8291
8292
|
GRAPHS,
|
|
8292
8293
|
isCoordinatorDuty,
|
|
8293
8294
|
isMainKind,
|
|
8295
|
+
isGraph,
|
|
8294
8296
|
graphOf,
|
|
8295
8297
|
markOf,
|
|
8296
8298
|
sessionMark,
|
package/dist/server/cli.mjs
CHANGED
package/dist/server/main.mjs
CHANGED
|
@@ -139,6 +139,7 @@ import {
|
|
|
139
139
|
intercomOf,
|
|
140
140
|
isCode,
|
|
141
141
|
isCoordinatorDuty,
|
|
142
|
+
isGraph,
|
|
142
143
|
isHead,
|
|
143
144
|
isHeadKey,
|
|
144
145
|
isMainKind,
|
|
@@ -307,7 +308,7 @@ import {
|
|
|
307
308
|
writeStartError,
|
|
308
309
|
writerAlive,
|
|
309
310
|
yardPath
|
|
310
|
-
} from "./chunk-
|
|
311
|
+
} from "./chunk-WTEFOEUM.mjs";
|
|
311
312
|
|
|
312
313
|
// src/server/main.ts
|
|
313
314
|
import { homedir as homedir18 } from "node:os";
|
|
@@ -6224,7 +6225,7 @@ function todosOf(snapshot) {
|
|
|
6224
6225
|
if (!s2 || !Array.isArray(s2.tasks) || typeof s2.nextId !== "number") return void 0;
|
|
6225
6226
|
return s2.tasks.slice(0, 200).flatMap((t) => {
|
|
6226
6227
|
if (!(typeof t?.id === "number" && typeof t.subject === "string" && STATUSES2.has(t.status))) return [];
|
|
6227
|
-
const sb = stepInfo(t.metadata), graph = obj(t.metadata) ? graphOf(t.metadata.graph) : void 0, points = pointsOf(obj(t.metadata) ? t.metadata.points : void 0) ?? pointsOf(t.points);
|
|
6228
|
+
const sb = stepInfo(t.metadata), graph = isGraph(t.graph) ? t.graph : obj(t.metadata) ? graphOf(t.metadata.graph) : void 0, points = pointsOf(obj(t.metadata) ? t.metadata.points : void 0) ?? pointsOf(t.points);
|
|
6228
6229
|
const e = Array.isArray(t.evidence) ? t.evidence.at(-1) : void 0;
|
|
6229
6230
|
const evidence2 = e && typeof e.command === "string" && (e.result === "pass" || e.result === "fail") && typeof e.at === "string" && Number.isFinite(Date.parse(e.at)) ? { command: e.command.slice(0, 500), result: e.result, at: e.at, ...typeof e.sha === "string" && { sha: e.sha.slice(0, 7) } } : void 0;
|
|
6230
6231
|
return [{ ...typeof t.anchor === "string" && t.anchor && { anchor: t.anchor.slice(0, 500) }, ...evidence2 && { evidence: evidence2 }, id: t.id, subject: t.subject.slice(0, 300), status: t.status, ...typeof t.activeForm === "string" && { activeForm: t.activeForm.slice(0, 120) }, ...sb && { sb }, ...graph && { graph }, ...typeof t.owner === "string" && t.owner.trim() && { owner: t.owner.trim().slice(0, 64) }, ...Array.isArray(t.blockedBy) && { blockedBy: t.blockedBy.filter(Number.isSafeInteger).slice(0, 50) }, ...points !== void 0 && { points } }];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
4
4
|
"description": "Straw Boss coordination for pi in Herdr: sessions join a tab's net by choice, the first joiner is its main agent, a workspace tower opens on demand with a live monitoring dashboard, and boss_broadcast reaches the rest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/prompts/member.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Straw Boss: you are a member of tab {{tab}} of workspace {{workspace}}, and the tab has a main agent
|
|
1
|
+
Straw Boss: you are a member of tab {{tab}} of workspace {{workspace}}, and the tab has a main agent. Before you dispatch a subagent, tell it with `call_peer` (to: main) what you will do and which resources (ports, databases, files, branches) it uses; take other shared-resource questions there too. Write to agents terse, caveman-style: point first, no ceremony; keep negations, numbers, paths, IDs, and quoted decisions verbatim; full sentences where a fragment could mislead; a brief still carries its goal, context, reasons with their cause, scope, what others own, and acceptance check, because a thin brief makes workers redo or miss work; a reader unsure of the intent restates it or asks before acting. Report coordination friction, such as an agent, endpoint, or shared resource you cannot reach, with `call_tower` and `why: blocked`.
|
package/prompts/planning.md
CHANGED
|
@@ -20,7 +20,8 @@ For fan-out and orchestrator-worker, one todo per task:
|
|
|
20
20
|
- `owner`: the subagent's name, or `self`.
|
|
21
21
|
- `description`: the app, the worktree branch for a parallel writer, the anchor and who exercises it, and the exact artifact path a dependent will read.
|
|
22
22
|
- `blockedBy`: the tasks whose output or landed change this one needs; the rest run in parallel, on an unattended device within its capacity budget. Serialize only on a real dependency or shared files.
|
|
23
|
-
- `
|
|
23
|
+
- `graph`: a graph name from section 1, exactly.
|
|
24
|
+
- `metadata`: `{ "anchor": "...", "checkpoint": "own" | "<checkpoint todo id>", "points": <n> }`: its weight against the budget, as the boss or project weighs it (default 1; 0.25 for a light, API-bound worker).
|
|
24
25
|
- Defer: `metadata.until` (ISO) or `metadata.waitsOn` (person). Your monitor, loop or `boss_watch` prevents stale notices.
|
|
25
26
|
|
|
26
27
|
## 3. Name the anchors
|
package/src/callpeer.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { Reach } from "./reach.ts";
|
|
3
|
+
import type { Kit } from "./state.ts";
|
|
4
|
+
|
|
5
|
+
// `call_peer`: a member's way to a peer of its tab's net, found by sb when it is called (the boss, 2026-11-26: 「sb 包一個工具,當下找 main」; intercom stays the fallback). The one target now is `main`: the broker's record
|
|
6
|
+
// of the tab's main, read again at the call (`sync`), so a handover or a rotation never sends to the old session. Only a member has it in its active tools, set before each run's first model call as thread_post is
|
|
7
|
+
// (threadtools.ts); a main, a train, a tower, and a subagent never see it, and a call from any of them is refused.
|
|
8
|
+
|
|
9
|
+
export const PEER_TOOL = "call_peer";
|
|
10
|
+
export const PEER_DESCRIPTION = "Message a peer of your tab; sb finds it at the call. to: main (now, after a handover too). ask: you expect a reply (it comes by intercom).";
|
|
11
|
+
export const peerParameters = () => Type.Object({
|
|
12
|
+
to: Type.Literal("main"),
|
|
13
|
+
message: Type.String(),
|
|
14
|
+
ask: Type.Optional(Type.Boolean()),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export interface PeerDeps {
|
|
18
|
+
post: Reach["post"];
|
|
19
|
+
/** The membership's refresh: reads the broker's record of the tab's main and the live sessions again. */
|
|
20
|
+
sync: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Returns the registration, made once at the join (a joined session's tools come then); the active set follows the role at every run's start. */
|
|
24
|
+
export function createPeerTool({ pi, s, role }: Kit, { post, sync }: PeerDeps): () => void {
|
|
25
|
+
let registered = false;
|
|
26
|
+
pi.on("before_agent_start", () => {
|
|
27
|
+
if (!registered) return;
|
|
28
|
+
const active = pi.getActiveTools(), want = role() === "member" ? [...new Set([...active, PEER_TOOL])] : active.filter((name) => name !== PEER_TOOL);
|
|
29
|
+
if (want.length !== active.length) pi.setActiveTools(want);
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
if (registered) return;
|
|
33
|
+
registered = true;
|
|
34
|
+
pi.registerTool({
|
|
35
|
+
name: PEER_TOOL, label: PEER_TOOL, description: PEER_DESCRIPTION, parameters: peerParameters(), defaultActive: false,
|
|
36
|
+
execute: async (_id, { message, ask }) => {
|
|
37
|
+
if (role() !== "member") throw new Error(`${PEER_TOOL} is for a tab's members; this session is ${role() ?? "in no tab's net"}. Use intercom, or call_tower for your tower.`);
|
|
38
|
+
if (!message.trim()) throw new Error("The message is empty");
|
|
39
|
+
await sync();
|
|
40
|
+
const main = s.mainId;
|
|
41
|
+
if (!main) throw new Error(`Your tab ${s.info.tab ?? ""} has no main agent. When your work grows, call boss_promote to become it (dispatching a subagent promotes you); report coordination friction with call_tower.`);
|
|
42
|
+
const name = s.info.main || main;
|
|
43
|
+
const result = await post(main, message, "call_peer", "tab", ask === true);
|
|
44
|
+
if (result.status !== "sent") throw new Error(`The main ${name} (${main.slice(0, 8)}) did not take the message: ${[result.status, result.code, result.detail].filter(Boolean).join(" ")}`);
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "text", text: `Sent to ${name}, the main of tab ${s.info.tab}. ${ask ? "Its reply comes by intercom." : "No reply is expected."}` }],
|
|
47
|
+
details: { to: "main", id: main, name, status: result.status, ask: ask === true },
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/header.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { restrictLabel } from "./link/text.ts";
|
|
9
9
|
|
|
10
|
-
export type Kind = "call_tower" | "broadcast" | "tower_send" | "tower_reply" | "handoff" | "link_reply" | "wait_card" | "car_notice" | "board_clear" | "auto_notice" | "capacity_notice" | "wait_parked" | "wait_returned" | "watch_report" | "link_wait" | "link_wait_state" | "link_notice";
|
|
10
|
+
export type Kind = "call_tower" | "call_peer" | "broadcast" | "tower_send" | "tower_reply" | "handoff" | "link_reply" | "wait_card" | "car_notice" | "board_clear" | "auto_notice" | "capacity_notice" | "wait_parked" | "wait_returned" | "watch_report" | "link_wait" | "link_wait_state" | "link_notice";
|
|
11
11
|
/** The roles a joined session publishes in its pane's `sb_role` token, and so the roles a header names (`train`: the worker the tower opened for an integrator's manifest). */
|
|
12
12
|
export const ROLE_WORDS = ["tower", "main", "member", "train"] as const;
|
|
13
13
|
/** `session` is a pi session that did not join the net (a scope `all` broadcast reaches it). `head`: the tower of the head workspace. */
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { createLink } from "./link/runtime.ts";
|
|
|
29
29
|
import { createMainDuty } from "./mainduty.ts";
|
|
30
30
|
import { createMembership } from "./membership.ts";
|
|
31
31
|
import { createPresence } from "./presence.ts";
|
|
32
|
+
import { createPeerTool } from "./callpeer.ts";
|
|
32
33
|
import { createReach } from "./reach.ts";
|
|
33
34
|
import { createRunMode } from "./runmode.ts";
|
|
34
35
|
import { createRoles } from "./roles.ts";
|
|
@@ -101,8 +102,9 @@ export function createStrawBoss({ run: given, world: reading, api = herdrApi(),
|
|
|
101
102
|
const cars = carLink(kit);
|
|
102
103
|
pi.on("session_start", () => void (kit.s.toolSet ??= { link: link.inUse() && link.attended(), cars: cars.enabled(), carApp: hasIntegrationApp(cfg.cwd()) }));
|
|
103
104
|
let trainGuard: TrainGuard | undefined;
|
|
105
|
+
const addPeer = createPeerTool(kit, { post: reach.post, sync: () => membership.sync() }); // a member's call_peer (callpeer.ts)
|
|
104
106
|
const addTrainCar = trainCarTool(kit, () => trainGuard, cars, (text) => reach.callTower(text, undefined, false, "blocked"));
|
|
105
|
-
const membership = createMembership(kit, { presence, election, guard, briefing, roles, openTower: reach.openTower, register: () => (tools.addNetTools(), s.isTower || (watch.addTool(), pair.addTool(), wrap.addTool()), tools.addPromote(), tools.addDuty(), tools.addHandover(), addTrainCar()), onMain: link.look, control: () => control });
|
|
107
|
+
const membership = createMembership(kit, { presence, election, guard, briefing, roles, openTower: reach.openTower, register: () => (tools.addNetTools(), s.isTower || (watch.addTool(), pair.addTool(), wrap.addTool()), tools.addPromote(), tools.addDuty(), tools.addHandover(), addTrainCar(), addPeer()), onMain: link.look, control: () => control });
|
|
106
108
|
// `look` (above) starts and upgrades the sb server (src/server/) and is the way to it; a session that is no part of that has none.
|
|
107
109
|
const pair = createBossPair(kit, { ask: cfg.ask ?? look?.ask, remote: () => Boolean(link.remoteScope()) }); // boss_pair and board_read's review threads (bosspair.ts)
|
|
108
110
|
createCapFill(kit); // a main's capacity facts for the board (capfill.ts)
|
package/src/items.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FileHandle, open } from "node:fs/promises";
|
|
2
2
|
import { basename } from "node:path";
|
|
3
|
-
import { type Graph, graphOf } from "./duty.ts";
|
|
3
|
+
import { type Graph, graphOf, isGraph } from "./duty.ts";
|
|
4
4
|
import { cleanLabel } from "./eventmarks.ts";
|
|
5
5
|
import { MAX_SB_BYTES, tooDeep } from "./train/spec.ts";
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ export const FULL_LIMIT = FULL;
|
|
|
12
12
|
|
|
13
13
|
export interface Tool { id: string; name: string; summary: string; args?: string; cut?: true }
|
|
14
14
|
/** One task of a session's todo list, as pi-todo-ledger (its `todo/v1` entries) or @juicesharp/rpiv-todo (its snapshot entries and todo results) keeps it; deleted ones are left out. */
|
|
15
|
-
export interface Todo { id: number; subject: string; status: "pending" | "in_progress" | "completed"; activeForm?: string; /** A train's step (`metadata.sb`), bounded: see `stepInfo`. */ sb?: StepInfo; /** The plan's graph (`metadata.graph` through `graphOf
|
|
15
|
+
export interface Todo { id: number; subject: string; status: "pending" | "in_progress" | "completed"; activeForm?: string; /** A train's step (`metadata.sb`), bounded: see `stepInfo`. */ sb?: StepInfo; /** The plan's graph: the todo's own `graph` (pi-todo-ledger 0.4.0, a name of `GRAPHS` exactly), else a legacy `metadata.graph` through `graphOf`, when the todo names one. */ graph?: Graph; /** Who works on it (rpiv-todo's `owner`), the ids it waits on, and its capacity points (`metadata.points`, else the ledger's own `points`, 0 to 10; capacity.ts). */ owner?: string; blockedBy?: number[]; points?: number; anchor?: string; evidence?: { command: string; result: "pass" | "fail"; sha?: string; at: string } }
|
|
16
16
|
/** What the page keeps of a step's `metadata.sb` (docs/specs/2026-11-07-train-workers.md §11.1): its kind and name, whose it is, the check's type, what it holds and needs, and how it ended; never a command, a path, or evidence text. */
|
|
17
17
|
export interface StepInfo {
|
|
18
18
|
kind: string; name?: string; project?: string; app?: string; train?: string; round?: number; check?: string;
|
|
@@ -52,7 +52,7 @@ export function todosOf(snapshot: unknown): Todo[] | undefined {
|
|
|
52
52
|
if (!s || !Array.isArray(s.tasks) || typeof s.nextId !== "number") return undefined;
|
|
53
53
|
return s.tasks.slice(0, 200).flatMap((t: Json) => {
|
|
54
54
|
if (!(typeof t?.id === "number" && typeof t.subject === "string" && STATUSES.has(t.status))) return [];
|
|
55
|
-
const sb = stepInfo(t.metadata), graph = obj(t.metadata) ? graphOf(t.metadata.graph) : undefined, points = pointsOf(obj(t.metadata) ? t.metadata.points : undefined) ?? pointsOf(t.points);
|
|
55
|
+
const sb = stepInfo(t.metadata), graph = isGraph(t.graph) ? t.graph : obj(t.metadata) ? graphOf(t.metadata.graph) : undefined, points = pointsOf(obj(t.metadata) ? t.metadata.points : undefined) ?? pointsOf(t.points);
|
|
56
56
|
const e = Array.isArray(t.evidence) ? t.evidence.at(-1) : undefined;
|
|
57
57
|
const evidence = e && typeof e.command === "string" && (e.result === "pass" || e.result === "fail") && typeof e.at === "string" && Number.isFinite(Date.parse(e.at)) ? { command: e.command.slice(0, 500), result: e.result, at: e.at, ...(typeof e.sha === "string" && { sha: e.sha.slice(0, 7) }) } : undefined;
|
|
58
58
|
return [{ ...(typeof t.anchor === "string" && t.anchor && { anchor: t.anchor.slice(0, 500) }), ...(evidence && { evidence }), id: t.id, subject: t.subject.slice(0, 300), status: t.status, ...(typeof t.activeForm === "string" && { activeForm: t.activeForm.slice(0, 120) }), ...(sb && { sb }), ...(graph && { graph }), ...(typeof t.owner === "string" && t.owner.trim() && { owner: t.owner.trim().slice(0, 64) }), ...(Array.isArray(t.blockedBy) && { blockedBy: t.blockedBy.filter(Number.isSafeInteger).slice(0, 50) }), ...(points !== undefined && { points }) }];
|
package/src/membership.ts
CHANGED
|
@@ -137,6 +137,6 @@ export function createMembership({ pi, cfg, s, me, tell }: Kit, { presence, elec
|
|
|
137
137
|
}
|
|
138
138
|
return { promoted: true, text: `You are now the main agent of tab ${s.info.tab}.` };
|
|
139
139
|
};
|
|
140
|
-
return { connect, connected, joinNet, promote, adoptOpener };
|
|
140
|
+
return { connect, connected, joinNet, promote, adoptOpener, /** Reads the tab's net again (its main, the labels); call_peer looks before it sends (callpeer.ts). */ sync };
|
|
141
141
|
}
|
|
142
142
|
export type Membership = ReturnType<typeof createMembership>;
|
package/src/planhint.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { type Todo, todosOf } from "./items.ts";
|
|
5
|
+
import { todosOfBranch } from "./todo.ts";
|
|
6
|
+
|
|
7
|
+
// The planning rule at the moment it is missed (docs/specs/2026-11-26-plan-graph-jit.md; boss 2026-11-26 「sb 在派工當下送規則」): a coordinator or standing main whose `todo` create leaves it with open
|
|
8
|
+
// todos and none names a graph gets planning.md §1 and §2 on that result, condensed from the file itself, so the wording has one source. Once, and once more only after its open todos named a graph
|
|
9
|
+
// (or it had none open) and then again named none. main.md keeps only its pointer; nothing here reaches a member, a worker, a train, or a tower.
|
|
10
|
+
|
|
11
|
+
/** The block's last line: what the main does with it. */
|
|
12
|
+
export const PLAN_HINT_END = "Set the `graph` field on these todos.";
|
|
13
|
+
const OPENING = "sb: your open todos name no graph. From planning.md:";
|
|
14
|
+
/** The text of planning.md §1 and §2 the block leaves out, to stay near 1.2 KB: what the page shows, the capacity details (capacity notices carry them), and deferring. Each must be there: a cut that no longer matches is a file error. */
|
|
15
|
+
const DROPPED = ["The page shows it beside your kind. ", ", on an unattended device within its capacity budget", " (default 1; 0.25 for a light, API-bound worker)", /^- Defer: .*\n?/m, /\*\*/g];
|
|
16
|
+
|
|
17
|
+
/** One `## <n>.` section of planning.md, without its heading; a missing one is a file error. */
|
|
18
|
+
function section(text: string, n: number): string {
|
|
19
|
+
const found = new RegExp(`^## ${n}\\. ([^\\n]+)\\n([\\s\\S]*?)(?=^## |(?![\\s\\S]))`, "m").exec(text);
|
|
20
|
+
if (!found) throw new Error(`planning.md has no section ${n}`);
|
|
21
|
+
return `${found[1]}: ${found[2].trim()}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The block from planning.md's text: §1 and §2, condensed, then its end line. */
|
|
25
|
+
export function planHint(planning: string): string {
|
|
26
|
+
let body = [1, 2].map((n) => section(planning, n)).join("\n");
|
|
27
|
+
for (const cut of DROPPED) {
|
|
28
|
+
const next = body.replace(cut, "");
|
|
29
|
+
if (next === body) throw new Error(`planning.md §1-§2 no longer hold ${String(cut)}`);
|
|
30
|
+
body = next;
|
|
31
|
+
}
|
|
32
|
+
body = body.replace(/\n{2,}/g, "\n").trim();
|
|
33
|
+
return `${OPENING}\n${body}\n${PLAN_HINT_END}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Whether a `todo` call creates a todo: a single create or a batch. */
|
|
37
|
+
const creates = (input: unknown) => typeof input === "object" && input !== null && (input as { action?: unknown }).action === "create";
|
|
38
|
+
/** The open todos of a plan: not completed, and not a train's step. */
|
|
39
|
+
const openOf = (list: readonly Todo[]) => list.filter((t) => t.status !== "completed" && !t.sb);
|
|
40
|
+
|
|
41
|
+
/** `kind`: this session's main kind now (none while it is no main or runs a tower run); `planning`: the folder of planning.md (its §1-§2 hold no integration blocks), or its text for a test, read at the moment the block is sent. */
|
|
42
|
+
export function registerPlanHint(pi: ExtensionAPI, kind: () => string | undefined, planning: string | (() => string)): void {
|
|
43
|
+
let armed = true; // false after the block was shown, until the open todos name a graph or none is open
|
|
44
|
+
pi.on("session_start", () => void (armed = true));
|
|
45
|
+
pi.on("tool_result", (event, ctx) => {
|
|
46
|
+
const k = kind();
|
|
47
|
+
if (event.toolName !== "todo" || event.isError || (k !== "coordinator" && k !== "standing")) return;
|
|
48
|
+
const list = todosOf(event.details) ?? (ctx ? todosOfBranch(ctx.sessionManager.getBranch()) : undefined);
|
|
49
|
+
if (!list) return;
|
|
50
|
+
const open = openOf(list), missing = open.length > 0 && !open.some((t) => t.graph);
|
|
51
|
+
if (!missing) return void (armed = true);
|
|
52
|
+
if (!armed || !creates(event.input)) return;
|
|
53
|
+
const text = planHint(typeof planning === "string" ? readFileSync(join(planning, "planning.md"), "utf8") : planning()); // a planning.md without its sections throws: pi passes the result through and reports the hook's error; tests/plan-hint.test.ts holds the file to them
|
|
54
|
+
armed = false;
|
|
55
|
+
return { content: [...event.content, { type: "text" as const, text }] };
|
|
56
|
+
});
|
|
57
|
+
}
|
package/src/session.ts
CHANGED
|
@@ -23,6 +23,7 @@ import type { Presence } from "./presence.ts";
|
|
|
23
23
|
import { registerCarOff } from "./carslip.ts";
|
|
24
24
|
import type { Reach } from "./reach.ts";
|
|
25
25
|
import type { Roles } from "./roles.ts";
|
|
26
|
+
import { registerPlanHint } from "./planhint.ts";
|
|
26
27
|
import { registerStandingHint } from "./standinghint.ts";
|
|
27
28
|
import { ENTRY, type Kit } from "./state.ts";
|
|
28
29
|
import { ARM_MESSAGE } from "./idlewake.ts";
|
|
@@ -371,6 +372,7 @@ export function registerSession(kit: Kit, { mainDuty, runMode, briefing, roles,
|
|
|
371
372
|
});
|
|
372
373
|
|
|
373
374
|
registerStandingHint(pi, () => (role() === "main" && !runMode.active() ? mainDuty.now() : undefined)); // a coordinator that starts a watch is told of `standing` once (D8)
|
|
375
|
+
registerPlanHint(pi, () => (role() === "main" && !runMode.active() ? mainDuty.now() : undefined), cfg.promptDir); // a plan with no graph: planning.md §1-§2 on that todo result (planhint.ts)
|
|
374
376
|
registerCarOff(pi, () => role() === "main" && !runMode.active() && !mainDuty.integrationOn()); // a car slip that reaches a main with integration off: how to answer it (carslip.ts)
|
|
375
377
|
pi.on("session_shutdown", async (event) => {
|
|
376
378
|
// A run's own shutdown is runmode.ts's: it joined nothing and holds no pane, tokens, or board entry. So is that of a pi that never became a normal session (undecided, or plain after no answer from the server):
|
package/src/tools.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const linkRequestParameters = () => Type.Object({
|
|
|
44
44
|
reason: Type.String({ description: "One line: why you ask. The boss reads it in the dialog." }),
|
|
45
45
|
});
|
|
46
46
|
/** Every tool sb registers, all of them after the child return (index.ts): a role that lists one fails `/boss roles-check` (rolescheck.ts). tests/roles-check.test.ts pins it to the recorded registry. */
|
|
47
|
-
export const PARENT_ONLY: readonly string[] = ["board_read", "board_set", "boss_auto", "boss_broadcast", "boss_close_main", "boss_duty", "boss_handover", "boss_open_main", "boss_pair", "boss_promote", "boss_rename", "boss_revive_main", "boss_server", "boss_wait_ask", "boss_watch", "boss_wrap", "call_tower", "ledger_sweep", "link_request", "tower_done", "tower_list", "tower_memory", "tower_reply", "tower_send", "train_car"];
|
|
47
|
+
export const PARENT_ONLY: readonly string[] = ["board_read", "board_set", "boss_auto", "boss_broadcast", "boss_close_main", "boss_duty", "boss_handover", "boss_open_main", "boss_pair", "boss_promote", "boss_rename", "boss_revive_main", "boss_server", "boss_wait_ask", "boss_watch", "boss_wrap", "call_peer", "call_tower", "ledger_sweep", "link_request", "tower_done", "tower_list", "tower_memory", "tower_reply", "tower_send", "train_car"];
|
|
48
48
|
/** `boss_revive_main` (docs/specs/2026-11-23-tower-revive.md §4): its description and parameters, the same for a tower session and a tower run (runmode.ts proxies the latter to the server). */
|
|
49
49
|
export const REVIVE_DESCRIPTION = "List the mains and trains of this workspace that have a role record, with their state (live, dead, quit, restoring, stale, invalid), or revive a dead one: the same pi session comes back in a new tab as the same Straw Boss identity (its role, kind, name, board row, todos, and the waits it held), and it picks up its own subagents. Call it when a main_died notice names one and its work is not done, or when a request names a main that died. Revive a quit one only when a request names it. Refused, with the reason, for members, towers, mains opened for a teammate's device, a session a live pane runs, a second try of one death, and a session that died twice in a day after a revive.";
|
|
50
50
|
export const reviveParameters = () => Type.Object({
|