pi-ext
bugabingas pi extensions
owned by admin
feat(ultra): auto-enable workflow tool from settings
9e23201fd8a564e3f2003b2e60367b96cff6d962
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (7)
11 11 - Change Tune's fullscreen shortcut to `Ctrl+Alt+T`
12 12 - Generate git-safe's fixed-executable wrapper on first Bash use and reuse it across reloads
13 13 - Defer unused extension implementations, PATH checks, settings reads, prompt loading, and RTK probes beyond startup and reload
14 -- Lazy-load Ultra execution, workflow discovery, settings, validation, and workflow tool registration when Ultra is first used
14 +- Lazy-load Ultra execution, workflow discovery, validation, and workflow tool registration until first use unless `ultra.auto_enable` is enabled
15 +- Let `ultra.auto_enable` activate Ultra's workflow tool when each session starts
15 16 - Retain Ultra sub-agent sessions as named parent-linked children, resume matching interrupted steps, and provide an explicit stateless opt-out
16 17 - Let Ultra load one static extension-name allowlist into every sub-agent while preserving `"all"` as the default
17 18 - Let loaded extensions activate their own Ultra sub-agent tools without extension-specific workflow tool names
extensions/ultra/README.md
Modified105 105 | Key | Default | Meaning |
106 106 | ----------------------------- | ------- | ---------------------------------------------------------- |
107 107 | `ultra.enabled` | `true` | When false, the tool + command refuse to run. |
108 +| `ultra.auto_enable` | `false` | Enable `run_workflow` when each session starts. |
108 109 | `ultra.concurrency` | `5` | Max concurrent sub-agents in a `fanout` phase. |
109 110 | `ultra.maxRetries` | `2` | Result-submission reminders after a missing output. |
110 111 | `ultra.subagentExtensions` | `"all"` | Load all, none, or a static extension-name list. |
extensions/ultra/__tests__/harness.test.ts
Modified 1 -import { mkdirSync, readFileSync, writeFileSync }
from "node:fs";
8 +import { tmpdir }
from "node:os";
2 9 import { join }
from "node:path";
3 10 import { fileURLToPath }
from "node:url";
4 11 import type { ExtensionCommandContext }
from "@earendil-works/pi-coding-agent";
13 + createTestSession
as createHarnessSession,
8 15 }
from "@marcfargas/pi-test-harness";
9 16 import { afterEach, describe, expect, it, vi }
from "vitest";
10 17 import { WorkflowSpecSchema }
from "../spec.ts";
12 19 let t
: TestSession | undefined;
20 +let root
: string | undefined;
24 + if (
root)
rmSync(
root, { recursive:
true, force:
true });
19 29 function ultraPath()
: string {
20 30 return fileURLToPath(
new URL(
"../index.ts",
import.
meta.url));
33 +async function createTestSession(options
: {
34 + extensions
: string[];
36 +})
: Promise<
TestSession> {
37 + if (options.cwd)
return createHarnessSession(options);
38 + root = mkdtempSync(
join(
tmpdir(),
"ultra-harness-"));
39 + mkdirSync(
join(
root,
".pi"), { recursive:
true });
41 + join(
root,
".pi",
"settings.json"),
42 + JSON.
stringify({ ultra: { auto_enable:
false } }),
44 + return createHarnessSession({
...options, cwd:
root });
23 47 function saveWorkflow(
24 48 session
: TestSession,
89 113 expect(extension.commands.
has(
"ultra-runs")).
toBe(
false);
116 + it(
"auto-enables the workflow tool when configured",
async ()
=> {
117 + root = mkdtempSync(
join(
tmpdir(),
"ultra-auto-enable-"));
118 + mkdirSync(
join(
root,
".pi"), { recursive:
true });
120 + join(
root,
".pi",
"settings.json"),
121 + JSON.
stringify({ ultra: { auto_enable:
true } }),
124 + t
= await createTestSession({ cwd:
root, extensions: [
ultraPath()] });
125 + const [extension]
= t.session.extensionRunner.extensions;
127 + expect(extension.tools.
has(
"run_workflow")).
toBe(
true);
128 + expect(t.session.
getActiveToolNames()).
toContain(
"run_workflow");
129 + expect(t.session.systemPrompt).
toContain(
"- run_workflow:");
92 132 it(
"completes subcommands first and saved workflows below run",
async ()
=> {
93 133 t
= await createTestSession({ extensions: [
ultraPath()] });
94 134 const [extension]
= t.session.extensionRunner.extensions;
extensions/ultra/__tests__/settings.test.ts
Modified 10 10 it(
"matches the documented defaults", ()
=> {
11 11 expect(ULTRA_DEFAULTS).
toEqual({
15 16 subagentExtensions:
"all",
25 +describe(
"auto_enable setting", ()
=> {
26 + it(
"defaults to false and accepts booleans", ()
=> {
27 + expect(ULTRA_DEFAULTS.autoEnable).
toBe(
false);
28 + expect(
pickUltra({ ultra: { auto_enable:
true } })).
toEqual({
31 + expect(
pickUltra({ ultra: { auto_enable:
"true" } })).
toEqual({});
34 + it(
"merges later valid values and ignores invalid ones", ()
=> {
36 + mergeUltraSettings({ autoEnable:
true }, { autoEnable:
false })
39 + expect(
mergeUltraSettings({ autoEnable:
"yes" as never }).autoEnable).
toBe(
24 45 describe(
"subagentExtensions setting", ()
=> {
25 46 it(
'defaults to "all"', ()
=> {
26 47 expect(ULTRA_DEFAULTS.subagentExtensions).
toBe(
"all");
129 151 actionSummarizerModel:
" openai/gpt-5-mini ",
131 153 small:
"openai/gpt-5-mini:low",
142 165 actionSummarizerModel:
"openai/gpt-5-mini",
186 210 subagentExtensions:
"all",
209 233 const merged
= loadUltraSettings({
213 238 actionSummarizerModel:
"openai/gpt-5-mini",
214 239 modelTiers: { small:
"openai/gpt-5-mini" },
225 250 expect(merged).
toEqual({
229 255 subagentExtensions:
"all",
extensions/ultra/implementation.ts
Modified 349 + activateWorkflowTool,
349 350 getArgumentCompletions: (prefix
: string)
=> 350 351 completeUltraCommand(
discover(
process.
cwd()), prefix),
351 352 handleCommand:
async (argString
: string, ctx
: ExtensionCommandContext)
=> {
extensions/ultra/index.ts
Modified 5 5 ExtensionCommandContext,
6 6 }
from "@earendil-works/pi-coding-agent";
7 -import { getMarkdownTheme }
from "@earendil-works/pi-coding-agent";
10 +}
from "@earendil-works/pi-coding-agent";
8 11 import { type AutocompleteItem, Markdown }
from "@earendil-works/pi-tui";
9 12 import type { WorkflowResult }
from "./engine.ts";
10 13 import { formatUltraResultMarkdown }
from "./result.ts";
14 +import { loadUltraSettings }
from "./settings.ts";
12 16 interface UltraRuntime {
17 + activateWorkflowTool()
: void;
13 18 getArgumentCompletions(prefix
: string)
: AutocompleteItem[]
| null;
14 19 handleCommand(argString
: string, ctx
: ExtensionCommandContext)
: Promise<
void>;
41 46 ({ createUltraRuntime })
=> createUltraRuntime(pi),
49 + pi.
on(
"session_start",
async (_event, ctx)
=> {
50 + const manager
= SettingsManager.
create(ctx.cwd);
51 + const settings
= loadUltraSettings({
52 + global: manager.
getGlobalSettings(),
53 + project: manager.
getProjectSettings(),
55 + if (settings.enabled
&& settings.autoEnable)
56 + (
await runtime()).
activateWorkflowTool();
44 59 pi.
registerCommand(
"ultra", {
46 61 "Enable ultra, execute workflow instructions, or run a saved workflow.",
extensions/ultra/settings.ts
Modified 9 9 export interface UltraSettings {
13 + autoEnable
: boolean;
13 15 concurrency
: number;
31 33 export const ULTRA_DEFAULTS
: UltraSettings = {
35 38 subagentExtensions:
"all",
64 67 if (
!isPlainObject(ultra))
return {};
65 68 const out
: Partial<
UltraSettings>
= {};
66 69 if (
typeof ultra.enabled
=== "boolean") out.enabled
= ultra.enabled;
70 + if (
typeof ultra.auto_enable
=== "boolean")
71 + out.autoEnable
= ultra.auto_enable;
67 72 if (
typeof ultra.concurrency
=== "number")
68 73 out.concurrency
= ultra.concurrency;
69 74 if (
typeof ultra.maxRetries
=== "number") out.maxRetries
= ultra.maxRetries;
104 109 return partials.
reduce<
UltraSettings>(
106 111 enabled:
typeof p.enabled
=== "boolean" ? p.enabled
: into.enabled,
113 + typeof p.autoEnable
=== "boolean" ? p.autoEnable
: into.autoEnable,
108 115 typeof p.concurrency
=== "number" ? p.concurrency
: into.concurrency,