pi-straw-boss 0.107.1 → 0.108.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-straw-boss",
3
- "version": "0.107.1",
3
+ "version": "0.108.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",
@@ -1,7 +1,5 @@
1
1
  # Planning work
2
2
 
3
- Revise the plan when the work changes.
4
-
5
3
  ## 1. Name the graph
6
4
 
7
5
  The page shows it beside your kind. Take the first case that matches:
@@ -26,21 +24,28 @@ For fan-out and orchestrator-worker, one todo per task:
26
24
 
27
25
  ## 3. Name the anchors
28
26
 
29
- Each anchor is the lightest check that can fail before the change and still reach what changed:
27
+ Use the lightest check that reaches the change and can fail before it:
30
28
 
31
- - **testing**: the default for code changes. Use the smallest test that goes red first. Repo-wide suites, lint, and type checks run once, at the shared checkpoint or before merge, never inside each task.<!-- integration --> In an `integration` app, see below.<!-- /integration -->
32
- - **pseudo-human**: a browser or computer operates the real interface and records screenshots and measurements.
33
- - **human**: the boss operates or judges the result: UI feel, wording, a business rule.
34
- - **adversarial-review**: a fresh-context agent challenges the result against the requirement. Use it for read-only work that has no executable checkpoint.
29
+ - **testing** (code): smallest red-first test. Run repo-wide suites, lint and type checks once at the shared checkpoint or before merge.<!-- integration --> In an `integration` app, see below.<!-- /integration -->
30
+ - **pseudo-human**: operate the real interface; capture screenshots and measurements.
31
+ - **human**: the boss tests or judges feel, wording or a business rule.
32
+ - **adversarial-review**: fresh-context challenge against requirements for read-only work without an executable check.
35
33
 
36
- Tasks that share one anchor share one checkpoint. Give each such group one checkpoint todo, `blockedBy` every task it covers, and tell those workers to hand it their evidence. A task whose check is distinct, or plainly cheaper in place, keeps its own.
34
+ Tasks with one anchor share one checkpoint todo, `blockedBy` all contributors; workers hand it evidence. Keep distinct or cheaper local checks in place.
37
35
 
38
36
  <!-- integration -->
39
- In an app that declares `integration`, follow `integrating`'s Principle: your anchor before handoff is your review (P0 and P1 clear), behaviour tests aimed at your own change, and the project skill's `Light checks`; repo-wide quality gates run once, by the integrator, on the integrated pre-dev head (its `Full gates`). Run the app's `integration.accept` on your branch before the slip, as the project skill's `## Acceptance` says, get the boss's nod, and write the evidence file (absolute paths in `accept:` and `evidence`); check it with the `train check` command in your main prompt (`--accept none` when `integration.accept` is empty): `--accept <file> --app-accept <integration.accept> --slip <slip>` before you send the slip; a `human` anchor is this acceptance, not the train's.
37
+ For `integration`, follow `integrating`'s Principle: before handoff clear P0/P1 review, test your change and run the project skill's `Light checks`. `Full gates` run once, by the integrator, on the integrated pre-dev head. Before sending the slip, run `integration.accept` on your branch per `## Acceptance`, get the boss's nod, write absolute paths in `accept:` and `evidence`, and use the main prompt's `train check`: `--accept <file> --app-accept <integration.accept> --slip <slip>` (`--accept none` for empty `integration.accept`); a `human` anchor is this acceptance, not the train's.
40
38
 
41
39
  <!-- /integration -->
42
- A change-set that touches a shared contract, authorization or permission data, or a migration gets one fresh-context reviewer after its anchor passes. Other change-sets take the author's own read of the diff against the brief.
40
+ After a passing anchor, get one fresh-context reviewer for shared contracts, authorization or permission data, or migrations. Otherwise review your diff against the brief.
43
41
 
44
42
  ## 4. Start
45
43
 
46
- Dispatch without asking the boss to confirm the plan, and change it the same way: the todos record it. Before offering the boss a design choice, read the owning app's instructions and the UI and architecture rules they name; drop the options they forbid, and quote the rule that settles the design in the brief. Through your question tool, bring the boss only the decisions the plan cannot settle, before the task they block: a requirement that is unclear or contradicts the architecture, and an authorization the work needs, such as a merge to a shared branch or a deploy.
44
+ Dispatch and revise todos without asking the boss to confirm the plan. Before offering choices, read the owning app's instructions and its UI and architecture rules; exclude forbidden options and quote the rule that settles the design in the brief. Ask via question tool before blocked work: a requirement is unclear or contradicts the architecture, or you need authorization (shared merge, deploy).
45
+
46
+ ## 5. When the boss adds work mid-plan
47
+
48
+ - Same project, any app: add a todo here and quote the boss verbatim in `description`. Another project: use `call_tower` with its `workspace` to open a main there.
49
+ - Finish your current step at a safe boundary, then take the insert first. Leave displaced work pending with a note; do not delete it.
50
+ - Keep dispatched workers running. Stop or redirect one only for shared files or if the new request invalidates its brief. For shared files, set `blockedBy` and name the worktree in `description`.
51
+ - Tell the boss in one line where the insert went; don't ask for confirmation. Use `boss_rename` if the tab's focus changes.
package/src/planhint.ts CHANGED
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
4
4
  import { type Todo, todosOf } from "./items.ts";
5
- import { todosOfBranch } from "./todo.ts";
5
+ import { snapshotOfBranch } from "./todo.ts";
6
6
 
7
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
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
@@ -40,18 +40,25 @@ const openOf = (list: readonly Todo[]) => list.filter((t) => t.status !== "compl
40
40
 
41
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
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));
43
+ let armed = true, insertArmed = true;
44
+ pi.on("session_start", () => { armed = insertArmed = true; });
45
+ pi.on("input", ({ source }) => { if (source !== "extension") insertArmed = true; });
45
46
  pi.on("tool_result", (event, ctx) => {
46
47
  const k = kind();
47
48
  if (event.toolName !== "todo" || event.isError || (k !== "coordinator" && k !== "standing")) return;
48
- const list = todosOf(event.details) ?? (ctx ? todosOfBranch(ctx.sessionManager.getBranch()) : undefined);
49
+ let snapshot = event.details, list = todosOf(snapshot);
50
+ if (!list && ctx) list = todosOf(snapshot = snapshotOfBranch(ctx.sessionManager.getBranch()));
49
51
  if (!list) return;
50
52
  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 }] };
53
+ if (!missing) armed = true;
54
+ if (!creates(event.input) || (event.details as { error?: string } | undefined)?.error) return;
55
+ // A successful create allocates consecutive ids ending just before nextId, including a batch.
56
+ const firstNew = (snapshot as { nextId: number }).nextId - (Array.isArray(event.input.tasks) ? event.input.tasks.length : 1);
57
+ const insert = insertArmed && open.some((t) => t.id < firstNew && t.status === "in_progress");
58
+ if (!(armed && missing) && !insert) return;
59
+ const doc = typeof planning === "string" ? readFileSync(join(planning, "planning.md"), "utf8") : planning(), content = [...event.content];
60
+ if (armed && missing) { content.push({ type: "text", text: planHint(doc) }); armed = false; }
61
+ if (insert) { content.push({ type: "text", text: section(doc, 5).replace(/\n- /g, "\n").replace(": - ", ":\n") }); insertArmed = false; }
62
+ return { content };
56
63
  });
57
64
  }