repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

feat(the-system): propose board updates after exec

3cda4c6c2ce3ed65922e00cb99d43d80854a8342

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (10)

extensions/the-system/CHANGELOG.md

Modified
16 16 - Keep board proposals and repeatable artifact slots available across clarification turns and compaction.
17 17 - Add a generally invocable vertical-slicing skill and require it for `/system exec`.
18 18 - Replace unconditional core-document blocking with validated one-shot human approval.
19 +- Let completed `/system exec` runs propose evidence-backed board updates for human review.
20 21 ## 0.0.3

extensions/the-system/README.md

Modified
24 24 The agent calls it for each new bundle after choosing a semantic title, then uses the returned ID and path exactly.
25 25 Context determines which bundles, if any, the command creates.
27 -Assessment temporarily enables `system_board_propose` through clarification until one assessment submission completes.
28 -Its proposals remain ephemeral until a human applies selected changes through `/system board`.
27 +Assessment and exec temporarily enable `system_board_propose` through clarification until one proposal submission completes.
28 +Exec proposes evidence-backed updates for referenced artifacts after fresh verification.
29 +Proposals remain ephemeral until a human applies selected changes through `/system board`.
30 31 ## Board

extensions/the-system/__e2e__/renderer.spec.ts

Modified
186 186 const root = systemFixture();
187 187 const runtime = createBoardRuntime();
189 - runtime.beginAssessment(root);
189 + runtime.beginProposal(root);
190 190 await runtime.tool.execute(
191 191 "assessment",
202 202 undefined,
203 203 { cwd: root } as never,
205 - runtime.endAssessment();
205 + runtime.endProposal();
206 206 const notice = await runtime.open(root);
207 207 const url = notice.match(/http:\/\/127\.0\.0\.1:\d+\/\?k=[^\s]+/)?.[0];
208 208 expect(url).toBeTruthy();

extensions/the-system/__tests__/board-runtime.test.ts

Modified
38 38 assert.notEqual(tool.promptSnippet, tool.description);
39 39 assert.match(tool.description, /does not modify \.system\/board\.json/);
40 40 assert.deepEqual(tool.promptGuidelines, [
41 - "During /system assess, call system_board_propose exactly once after inspection; use an empty items list when no state changes are justified.",
41 + "During /system assess or after completing /system exec, call system_board_propose exactly once with evidence-backed state changes; use an empty items list when no changes are justified.",

extensions/the-system/__tests__/harness.test.ts

Modified
2 2 import { mkdirSync, writeFileSync } from "node:fs";
3 3 import path from "node:path";
4 4 import { afterEach, describe, expect, it, vi } from "vitest";
5 5 import { createTestSession, type TestSession } from "../../../test/harness";
6 +import { applyInitialization } from "../init.ts";
7 8 describe("the-system pi-test-harness", () => {
8 9 let t: TestSession | undefined;
22 23 it("keeps system_slot through clarification and cancels it on the next lifecycle", async () => {
23 24 const extensionPath = path.resolve(import.meta.dirname, "../index.ts");
24 25 t = await createTestSession({ extensions: [extensionPath] });
26 + mkdirSync(path.join(t.cwd, ".git"));
27 + applyInitialization(t.cwd, "PX");
25 28 const [extension] = t.session.extensionRunner.extensions;
26 29 const sendUserMessage = vi
27 30 .spyOn(t.session, "sendUserMessage")

extensions/the-system/__tests__/the-system.test.ts

Modified
215 215 agentSettled?.({}, ctx);
216 216 assert.ok(!activeTools.includes("system_board_propose"));
218 + await command.handler("exec PX-SPEC-SPEC0001", ctx);
219 + assert.ok(activeTools.includes("system_board_propose"));
220 + agentSettled?.({}, ctx);
221 + assert.ok(activeTools.includes("system_board_propose"));
222 + await boardTool.execute(
223 + "exec-proposal",
225 + items: [
227 + id: "PX-SPEC-SPEC0001",
228 + state: "done",
229 + rationale: "Fresh verification passed.",
230 + },
231 + ],
232 + },
233 + undefined,
234 + undefined,
235 + ctx,
236 + );
237 + agentSettled?.({}, ctx);
238 + assert.ok(!activeTools.includes("system_board_propose"));
217 239 assert.deepEqual(
218 240 JSON.parse(readFileSync(path.join(project, ".system/board.json"), "utf8")),
219 241 { schemaVersion: 0, items: {} },
592 614 validSystem(project);
593 615 const sent: string[] = [];
594 616 let activations = 0;
595 - let assessments = 0;
617 + let boardRuns = 0;
596 618 const command = createSystemCommand(
598 620 sendUserMessage: (message: string) => sent.push(message),
599 621 } as never,
601 623 activateArtifactTool: () => activations++,
602 - activateAssessmentTool: () => assessments++,
624 + activateBoardTool: () => boardRuns++,
605 627 for (const subcommand of [
621 643 for (const message of sent)
622 644 assert.match(message, /The System document contract/);
623 645 assert.equal(activations, 10);
624 - assert.equal(assessments, 2);
646 + assert.equal(boardRuns, 4);
625 647 assert.doesNotMatch(sent.join("\n"), /Extension-generated artifact slot/);
626 - assert.match(
627 - sent.find((item) => item.includes("# /system exec")) ?? "",
628 - /spec\+plan/,
629 - );
648 + const execPrompt =
649 + sent.find((item) => item.includes("# /system exec")) ?? "";
650 + assert.match(execPrompt, /spec\+plan/);
651 + assert.match(execPrompt, /call system_board_propose exactly once/);
652 + assert.match(execPrompt, /never apply automatically/);
630 653 const assessPrompt =
631 654 sent.find((item) => item.includes("# /system assess")) ?? "";
632 655 assert.match(assessPrompt, /Submit the assessment through system_board_propose/);

extensions/the-system/board-runtime.ts

Modified
28 28 export function createBoardRuntime() {
29 - let assessmentRoot: string | undefined;
30 - let assessmentFinished = false;
29 + let proposalRoot: string | undefined;
30 + let proposalFinished = false;
31 31 const proposals = new Map<string, Map<string, BoardProposal>>();
32 32 const servers = new Set<BoardServer>();
33 33 const tool = defineTool({
37 37 "Record evidence-backed proposed board states for human review. Accepts existing spec, plan, or issue IDs and does not modify .system/board.json.",
38 38 promptSnippet: "Propose System board states for human review",
39 39 promptGuidelines: [
40 - "During /system assess, call system_board_propose exactly once after inspection; use an empty items list when no state changes are justified.",
40 + "During /system assess or after completing /system exec, call system_board_propose exactly once with evidence-backed state changes; use an empty items list when no changes are justified.",
42 42 parameters: proposalParameters,
43 43 renderCall(args, theme, context) {
99 99 async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
100 100 const root = discoverProjectRoot(ctx.cwd);
101 - if (root !== assessmentRoot)
101 + if (root !== proposalRoot)
102 102 throw new Error(
103 - "system_board_propose is only available during /system assess",
103 + "system_board_propose is only available during /system assess or /system exec",
105 105 const index = loadProjectIndex(root);
106 106 const byId = new Map(
129 129 proposals.set(root, proposed);
130 - assessmentFinished = true;
130 + proposalFinished = true;
131 131 const items = [...proposed.values()].sort((left, right) =>
132 132 left.id.localeCompare(right.id),
146 146 return {
148 - beginAssessment(cwd: string) {
148 + beginProposal(cwd: string) {
149 149 const root = discoverProjectRoot(cwd);
150 150 const index = loadProjectIndex(root);
151 151 readBoardState(root, index.prefix);
152 - assessmentRoot = root;
153 - assessmentFinished = false;
152 + proposalRoot = root;
153 + proposalFinished = false;
154 154 proposals.set(root, new Map());
156 - assessmentComplete() {
157 - return assessmentRoot !== undefined && assessmentFinished;
156 + proposalComplete() {
157 + return proposalRoot !== undefined && proposalFinished;
159 - endAssessment() {
160 - assessmentRoot = undefined;
161 - assessmentFinished = false;
159 + endProposal() {
160 + proposalRoot = undefined;
161 + proposalFinished = false;
163 163 async open(cwd: string): Promise<string> {
164 164 const index = loadProjectIndex(cwd);
183 183 : `System board running: ${server.url}\nBrowser: ${opened.error}`;
185 185 shutdown() {
186 - assessmentRoot = undefined;
187 - assessmentFinished = false;
186 + proposalRoot = undefined;
187 + proposalFinished = false;
188 188 for (const server of servers) server.close();
189 189 servers.clear();

extensions/the-system/index.ts

Modified
21 21 let warningNotified = false;
22 22 let artifactSlotRunActive = false;
23 23 let artifactSlotUsed = false;
24 - let boardAssessmentRunActive = false;
24 + let boardProposalRunActive = false;
25 25 let bundleMigrationRunActive = false;
26 26 const mockup = createMockupRuntime();
27 27 const artifactSlot = createArtifactSlotTool(() => {
42 42 artifactSlotRunActive = false;
43 43 artifactSlotUsed = false;
45 - const activateBoardAssessment = (cwd: string) => {
46 - board.beginAssessment(cwd);
45 + const activateBoardProposal = (cwd: string) => {
46 + board.beginProposal(cwd);
47 47 const active = pi.getActiveTools();
48 48 if (!active.includes(board.tool.name))
49 49 pi.setActiveTools([...active, board.tool.name]);
50 - boardAssessmentRunActive = true;
50 + boardProposalRunActive = true;
52 - const deactivateBoardAssessment = () => {
52 + const deactivateBoardProposal = () => {
53 53 const active = pi.getActiveTools();
54 54 if (active.includes(board.tool.name))
55 55 pi.setActiveTools(active.filter((name) => name !== board.tool.name));
56 - board.endAssessment();
57 - boardAssessmentRunActive = false;
56 + board.endProposal();
57 + boardProposalRunActive = false;
59 59 const activateBundleMigration = () => {
60 60 bundleMigrationRunActive = true;
62 62 const beginLifecycle = () => {
63 63 if (artifactSlotRunActive) deactivateArtifactSlot();
64 - if (boardAssessmentRunActive) deactivateBoardAssessment();
64 + if (boardProposalRunActive) deactivateBoardProposal();
67 67 const syncRuntimeIndicator = async (
110 110 pi.on("session_start", (_event, ctx) => {
111 111 deactivateArtifactSlot();
112 - deactivateBoardAssessment();
112 + deactivateBoardProposal();
113 113 bundleMigrationRunActive = false;
114 114 const ticket = ++generation;
115 115 warningNotified = false;
127 127 warningNotified = false;
128 128 artifactSlotRunActive = false;
129 129 artifactSlotUsed = false;
130 - boardAssessmentRunActive = false;
130 + boardProposalRunActive = false;
131 131 bundleMigrationRunActive = false;
132 132 board.shutdown();
133 133 mockup.shutdown(ctx);
153 153 mockup.agentSettled(ctx);
154 154 if (artifactSlotRunActive && artifactSlotUsed) deactivateArtifactSlot();
155 - if (boardAssessmentRunActive && board.assessmentComplete())
156 - deactivateBoardAssessment();
155 + if (boardProposalRunActive && board.proposalComplete())
156 + deactivateBoardProposal();
157 157 bundleMigrationRunActive = false;
159 159 pi.on("tool_call", async (event, ctx) => {
185 185 await createSystemCommand(pi, {
186 186 beginLifecycle,
187 187 activateArtifactTool: activateArtifactSlot,
188 - activateAssessmentTool: activateBoardAssessment,
188 + activateBoardTool: activateBoardProposal,
189 189 activateBundleMigration,
190 190 openBoard: board.open,
191 191 }).handler(args, ctx);

extensions/the-system/system-command.ts

Modified
42 42 type SystemCommandHooks = Readonly<{
43 43 beginLifecycle?: () => void;
44 44 activateArtifactTool?: () => void;
45 - activateAssessmentTool?: (cwd: string) => void;
45 + activateBoardTool?: (cwd: string) => void;
46 46 activateBundleMigration?: () => void;
47 47 openBoard?: (cwd: string) => Promise<string>;
123 123 hooks.beginLifecycle?.();
124 124 if (ARTIFACT_SUBCOMMANDS.has(parsed.subcommand))
125 125 hooks.activateArtifactTool?.();
126 - if (parsed.subcommand === "assess")
127 - hooks.activateAssessmentTool?.(ctx.cwd);
126 + if (parsed.subcommand === "assess" || parsed.subcommand === "exec")
127 + hooks.activateBoardTool?.(ctx.cwd);
128 128 pi.sendUserMessage(systemPromptFor(parsed.subcommand, parsed.rest));
129 129 if (ctx.mode === "print" || ctx.mode === "json") {
130 130 await new Promise((resolve) => setTimeout(resolve, 0));

extensions/the-system/system-prompts.ts

Modified
74 74 Use tests for nontrivial behavior.
75 75 Debug root cause before fixing bugs.
76 76 Before claiming implementation complete, run fresh verification and read the full result.
77 +After fresh verification, call system_board_propose exactly once with evidence-backed state changes for referenced artifacts; use an empty items list when no changes are justified.
78 +Board proposals require human review and never apply automatically.
77 79 Final log includes refs, changed areas, verification, and a copyable View block.
78 80 Commit messages tell the document-linked story, not file/test inventory.