repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

fix(ultra): choose workflow persistence from intent

36b736054b03fbab76f365a63b62262d73360578

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (6)

CHANGELOG.md

Modified
42 42 - Add terse artifact detail budgets for System docs; plans stay at module/interface/package/class level and avoid real code snippets
43 43 - Fix The System runtime warning so it stays quiet until a project opts into `.system`
44 44 - Use `/ultra exec <instructions>` to design or execute a workflow and `/ultra run <name> [args]` to run a saved workflow; bare `/ultra` enables the hidden workflow tool and confirms activation
45 +- Make `/ultra exec` show the complete orchestration prompt as a user message, choose between a one-off and saved workflow from reuse intent, and ask one focused question when uncertain
45 46 - Add `/ultra` autocomplete for `exec` and `run`, with saved workflows completed under `run`
46 47 - Remove Ultra background runs and `/ultra history`; workflows now run interactively without persisted run history
47 48 - Make Ultra discover newly saved workflows without requiring `/reload`
54 55 - Fix Ultra progress so phase transitions and completion preserve terminal scrollback
55 56 - Require two Esc presses to confirm aborting an entire Ultra run
56 57 - Fix Ultra tool-step cleanup so teardown errors do not hide a completed workflow step
57 -- Remove Ultra's exported authoring skill; `/ultra` now injects the workflow authoring prompt internally
58 +- Remove Ultra's exported authoring skill; `/ultra exec` now sends the workflow authoring prompt internally
58 59 - Fix Pulse TAB completion
59 60 - Fix Notes so `/tree` restores notes from the selected branch and `/new` asks whether to carry pending notes into the new session
60 61 - Fix the uv extension on Windows by skipping incompatible shell shims while retaining command blocking

extensions/ultra/README.md

Modified
8 8 ## Two surfaces
10 10 - **`/ultra`**: enables the hidden `workflow` tool for later agent turns, confirms activation, and does not start a turn.
11 -- **`/ultra exec <instructions>`**: enables the tool, injects the authoring prompt, and starts an agent turn to design or run a workflow.
11 +- **`/ultra exec <instructions>`**: enables the tool, sends the complete orchestration prompt as a visible user message, and starts an agent turn to choose, design, or run a workflow.
12 12 - **`/ultra run <name> [args]`**: runs a saved workflow behind a phase-first live overlay with keyboard phase toggling, agent focus, streaming transcripts, steering, targeted abort, and confirmed whole-run abort.
13 13 - **`workflow` tool**: model-callable after `/ultra` enables it. Pass a saved
14 14 workflow `name` (+ optional `args`), or an inline `spec` object for a one-off
32 32 ### Authoring
34 -Run `/ultra exec <instructions>` to inject the authoring prompt and enable the `workflow` tool for the next agent turn.
35 -It walks through co-designing and saving a workflow: phases, the read-only
36 -fan-out rule, schemas + join-keys, interpolation, and where to save.
34 +Run `/ultra exec <instructions>` to send the complete orchestration prompt as a visible user message and enable the `workflow` tool for the next agent turn.
35 +The agent chooses an ephemeral one-off or persisted workflow when confidence is high, and asks one focused question when it is not.
36 +Persisted authoring covers phases, the read-only fan-out rule, schemas + join-keys, interpolation, and where to save.
38 38 ### Where workflows live

extensions/ultra/__tests__/harness.test.ts

Modified
73 + it("sends exec instructions as the visible user message that starts the turn", async () => {
74 + t = await createTestSession({ extensions: [ultraPath()] });
75 + const [extension] = t.session.extensionRunner.extensions;
76 + const sendUserMessage = vi
77 + .spyOn(t.session, "sendUserMessage")
78 + .mockResolvedValue();
79 + const beforeNotifications = t.events.uiCallsFor("notify").length;
81 + await extension.commands
82 + .get("ultra")
83 + .handler(
84 + "exec inspect this failure once",
85 + t.session.extensionRunner.createCommandContext(),
86 + );
88 + expect(t.session.getActiveToolNames()).toContain("workflow");
89 + expect(sendUserMessage).toHaveBeenCalledOnce();
90 + const prompt = sendUserMessage.mock.calls[0]?.[0];
91 + expect(prompt).toEqual(expect.any(String));
92 + expect(prompt).toContain("# Authoring ultra workflows");
93 + expect(prompt).toContain("# Ultra workflow spec reference");
94 + expect(prompt).toContain("# User request\n\ninspect this failure once");
95 + expect(t.events.uiCallsFor("notify")).toHaveLength(beforeNotifications);
96 + });
73 98 it("renders workflow progress as an overlay without replacing session content", async () => {
74 99 t = await createTestSession({ extensions: [ultraPath()] });
75 100 const [extension] = t.session.extensionRunner.extensions;

extensions/ultra/__tests__/prompt.test.ts

Modified
36 36 expect(reference).toContain("Every step returns a JSON object");
37 37 expect(prompt).toContain("Ultra refuses to start the workflow");
38 38 expect(reference).toContain("Ultra refuses to start the workflow");
39 + expect(prompt).toContain("When confidence is high, act on that choice");
40 + expect(prompt).toContain(
41 + "When confidence is not high, ask one focused question",
42 + );
43 + expect(prompt).toContain(
44 + "Do not treat `/ultra exec` itself or generic creation verbs as evidence for persistence",
45 + );
46 + expect(prompt).not.toContain(
47 + "When in genuine doubt with creation language, persist",
48 + );
39 49 const readme = fs.readFileSync(README_PATH, "utf8");
40 50 expect(readme).toContain("`/ultra exec <instructions>`");
41 51 expect(readme).toContain("`/ultra run <name> [args]`");

extensions/ultra/index.ts

Modified
271 271 pi.on("session_start", () => deactivateWorkflowTool());
273 - const injectAuthoringPrompt = (request: string) => {
273 + const sendAuthoringPrompt = (request: string) => {
274 274 activateWorkflowTool();
275 - pi.sendMessage(
276 - {
277 - customType: "ultra-authoring",
278 - content: `${loadAuthoringPrompt()}\n\n# User request\n\n${request}\n\nThe workflow tool is now available; use it only when ultra orchestration is justified.`,
279 - display: false,
280 - details: { request },
281 - },
282 - { triggerTurn: true, deliverAs: "followUp" },
275 + pi.sendUserMessage(
276 + `${loadAuthoringPrompt()}\n\n# User request\n\n${request}\n\nThe workflow tool is now available; use it only when ultra orchestration is justified.`,
311 305 return;
313 307 if (command.subcommand === "exec") {
314 - injectAuthoringPrompt(command.instructions);
315 - ctx.ui.notify("ultra authoring prompt sent.", "info");
308 + sendAuthoringPrompt(command.instructions);
316 309 return;
318 311 if (command.subcommand === "invalid") {

extensions/ultra/prompts/authoring-workflows.md

Modified
1 1 # Authoring ultra workflows
3 -These instructions help you co-design a **persisted** ultra workflow with the
4 -user and save it to disk so they can re-run it as `/ultra run <name>`. The canonical
5 -spec format is injected below — use it before writing any spec; do not restate it
6 -from memory.
3 +These instructions help you choose between running an **ephemeral one-off**
4 +ultra workflow and co-designing a **persisted** workflow the user can re-run as
5 +`/ultra run <name>`.
6 +The canonical spec format is injected below; use it before writing any spec and
7 +do not restate it from memory.
8 -## First: persist vs. one-off (decide silently)
9 +## First: persist vs. one-off
10 -Creation language — "create / author / build / save / write me a workflow that
11 -…" — means the user wants a **persisted** workflow. That is the default this
12 -prompt serves: co-design the spec and write the JSON file.
11 +Infer the user's intent from the request and its context.
12 +Choose a **persisted** workflow when durable reuse is explicit or strongly implied, such as repeated use, a named utility, sharing, or future `/ultra run` invocations.
13 +Choose an **ephemeral one-off** when the request seeks one bounded result now and gives no meaningful reuse signal.
14 +Do not treat `/ultra exec` itself or generic creation verbs as evidence for persistence.
14 -Divert to an **ephemeral one-off** — call the `workflow` tool with an inline
15 -`spec` and skip the authoring/saving flow entirely — only on an explicit
16 -override cue:
18 -- "just run it once" / "one-off" / "don't save it" / "throwaway"
19 -- "try this without saving" / "ad hoc"
21 -Decide silently. **Do not ask "should I save this or just run it?"** and do not
22 -announce the routing — the user's wording already carries the intent, and the
23 -choice is cheap to reverse: a one-off can be saved afterward, and a saved file
24 -can be deleted. When in genuine doubt with creation language, persist (the
25 -reversible, lower-regret default).
16 +When confidence is high, act on that choice without asking or announcing the routing.
17 +When confidence is not high, ask one focused question before invoking the workflow tool or writing a workflow file.
18 +Never resolve uncertainty by defaulting to persistence or ephemerality.
27 20 ## Single-agent gate
98 91 ## Ephemeral one-off
100 -On an explicit override cue, skip the flow above: construct the spec inline and
101 -call the `workflow` tool with it as `spec`. Same format and rules
102 -(`spec-format.md`, read-only fan-out), but nothing is written to disk. If the
103 -user later likes it, save it via the persisted flow.
93 +For a one-off, skip the persisted flow: construct the spec inline and call the
94 +`workflow` tool with it as `spec`.
95 +Use the same format and rules (`spec-format.md`, read-only fan-out), but write
96 +nothing to disk.
97 +If the user later wants reuse, save it via the persisted flow.