pi-straw-boss 0.125.1 → 0.125.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-straw-boss",
3
- "version": "0.125.1",
3
+ "version": "0.125.2",
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",
@@ -10,4 +10,4 @@ Schedule one project's trains for apps with an `integration` field ({{dir}}/apps
10
10
  - Name: `boss_rename` yourself `integ <project>` and never rename again. Keep the ledger at `<project>/<app>.json` in the `trains` folder your role prompt names.
11
11
  - To depart, `call_tower` with `why: shared` and one `train:` block: `project:`, `code:`, then `app`, `base`, `stages`, `targets`, `skill`, your session id. Unlike a heads-up, this one waits for the tower's answer: the train's session id, or a refusal, which means no train opened. sb appends each car's slip verbatim from the tower's forward; restate none.
12
12
  - A missing heading and a binding you cannot reach are `why=blocked`, naming the cause.
13
- - After a train lands, call `team_work close` once per work order from its writer session: pass one merged ticket from that order and `mergedSha`. Queue, pending opens and closures clear: `call_tower` idle, `why=milestone`, reply false; the tower closes you.
13
+ - {{ticketClose}}Queue, pending opens and closures clear: `call_tower` idle, `why=milestone`, reply false; the tower closes you.
package/src/briefing.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import type { SessionEntry } from "@earendil-works/pi-coding-agent";
3
+ import { hasTeamWork } from "./teamwork.ts";
3
4
  import { roleView } from "./briefview.ts";
4
5
  import type { MainDuty } from "./mainduty.ts";
5
6
  import { cliCommand } from "./server/version.ts";
@@ -9,7 +10,6 @@ import { type PromptSet, promptSet } from "./trainswitch.ts";
9
10
  const LABEL_GRACE_MS = 10_000;
10
11
  const LOCATION_LABELS = ["tab", "workspace"] as const;
11
12
  const PROMPTS = ["main", "tower", "member", "member-no-main", "train", "integrator", "standing", "worker"];
12
-
13
13
  /** What a run was briefed with: the role and a main's kind. A plan's graph is no part of it (docs/specs/2026-11-23-lite-main.md §1): the dispatch rules are main.md's, for a coordinator and an integrator; a standing main has a prompt of its own. */
14
14
  interface Briefed { name: string | undefined; duty: string }
15
15
  /** A steer's `details`: what it tells, and what it was written against (`null`: it replaces the whole role prompt, whatever the model held; every steer since 0.83.0 is one); it signs the role prompt it carries (`sig`). */
@@ -44,7 +44,7 @@ export function createBriefing({ pi, cfg, s, role, guiDir, tell }: Kit, mainDuty
44
44
  const now = cfg.now();
45
45
  return now >= (labelDeadline ??= now + LABEL_GRACE_MS);
46
46
  };
47
- const compose = ({ name, duty }: Briefed, parts = name ? partsOf(name, duty) : []) => parts.map((part) => prompts[part]).join("\n\n").replace(/\{\{(\w+)\}\}/g, (_, key: string) => ({ dir: files ? files.dir : cfg.promptDir, state: guiDir, cli: cliCommand(), ...(labels ?? labelsOf()), duty } as Record<string, string | undefined>)[key] || "none yet");
47
+ const compose = ({ name, duty }: Briefed, parts = name ? partsOf(name, duty) : []) => parts.map((part) => prompts[part]).join("\n\n").replace(/\{\{(\w+)\}\}/g, (_, key: string) => key === "ticketClose" ? (hasTeamWork(pi) ? "After a train lands, call `team_work close` once per work order from its writer session: pass one merged ticket from that order and `mergedSha`. " : "") : ({ dir: files ? files.dir : cfg.promptDir, state: guiDir, cli: cliCommand(), ...(labels ?? labelsOf()), duty } as Record<string, string | undefined>)[key] || "none yet");
48
48
  // A compaction that retries no turn gets the message stored, not steered: a steer queued then would make pi continue a run that had ended (runmode.ts does the same with a run's brief).
49
49
  let quiet = false;
50
50
  // A stored message is in the transcript at the turn's end, and pi reports it to no extension: it is told as it is sent. So is a steer sent while pi is idle (awaiting `agent_settled` handlers, or after a run
package/src/forkmain.ts CHANGED
@@ -79,7 +79,7 @@ export function createForks(kit: Kit, d: ForkDeps) {
79
79
  const file = handoffPath(dir, f.id), temp = `${file}.${process.pid}.${randomUUID().slice(0, 8)}.tmp`;
80
80
  writeFileSync(temp, forkHandoff(f, tasks, f.topic), { mode: 0o600 });
81
81
  renameSync(temp, file);
82
- return ticketHandoff(tasks);
82
+ return ticketHandoff(pi, tasks);
83
83
  };
84
84
  /** Asks the tower to open the fork's main (`why=fork fork=<id>`); the record counts the ask. */
85
85
  const ask = async (f: Fork): Promise<{ fork: Fork; refusal?: string }> => {
package/src/teamwork.ts CHANGED
@@ -1,11 +1,11 @@
1
- // pi-team-work's team_work start seeds the subject as `${ticket.id}: ${ticket.title}`.
2
- // A reference elsewhere is not a binding. Completed tasks travel as evidence, not as work to hand off.
3
- export function ticketHandoff(tasks: readonly Record<string, unknown>[] = []): string {
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ type Registry = Pick<ExtensionAPI, "getAllTools">;
3
+ export const hasTeamWork = (pi: Registry): boolean => pi.getAllTools().some(({ name }) => name === "team_work");
4
+ export function ticketHandoff(pi: Registry, tasks: readonly Record<string, unknown>[] = []): string {
4
5
  const ids = new Set<string>();
5
- for (const task of tasks) {
6
- if ((task.status !== "pending" && task.status !== "in_progress") || typeof task.subject !== "string") continue;
7
- const id = /^([A-Z][A-Z0-9]*-\d+): /.exec(task.subject)?.[1];
8
- if (id) ids.add(id);
6
+ for (const { status, metadata } of hasTeamWork(pi) ? tasks : []) {
7
+ if (status !== "pending" && status !== "in_progress") continue;
8
+ if (metadata && typeof metadata === "object" && "ticket" in metadata && typeof metadata.ticket === "string" && metadata.ticket.trim()) ids.add(metadata.ticket.trim());
9
9
  }
10
10
  return ids.size ? ` Call team_work handoff for each ticket not yet handed off: ${[...ids].join(", ")}. Posting requires confirmation.` : "";
11
11
  }
package/src/tools.ts CHANGED
@@ -259,7 +259,7 @@ export function createTools({ pi, cfg, s, guiDir, me, role, tell }: Kit, { mainD
259
259
  if (s.openedBy?.startsWith("link:")) throw new Error(`A main opened for a teammate's device (${s.openedBy.slice(0, 40)}) does not hand over: its successor would run outside the device's revoke and signed stop. Finish or report what you can; the device asks again`);
260
260
  const why = reason.replace(/\s+/g, " ").trim();
261
261
  if (!why || why.length > 200) throw new Error("reason is required: one line of 1 to 200 characters");
262
- const advice = (snapshot: unknown) => ticketHandoff(handoverSnapshot(snapshot).data?.tasks);
262
+ const advice = (snapshot: unknown) => ticketHandoff(pi, handoverSnapshot(snapshot).data?.tasks);
263
263
  if (handoff === undefined) return { text: `No successor opened.${advice(snapshotOfBranch(s.branch()))} Write the handoff and call boss_handover with its path and reason.`, details: { prepared: true } };
264
264
  const cwd = process.cwd(), path = isAbsolute(handoff) ? handoff : resolve(cwd, handoff);
265
265
  let regular = false;