From 8f8fe92089618f1a9ebfae92f2eae62960d5e81a Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 30 Nov 2026 17:27:34 +0000 Subject: [PATCH] Add ultra keyword configuration --- src/config.ts | 15 +++++++++++++++ test/config.test.ts | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/config.ts b/src/config.ts index 3421cdb..ee94ec0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -63,6 +63,21 @@ export function readUltraNotify(value: string | undefined): { value: boolean; wa return { value: true, warning: `Invalid PI_SUBAGENT_ULTRA_NOTIFY="${value}"; using on.` }; } +/** + * Whether a human-typed prompt containing the `ultracode` keyword forces one + * plan-first run. + * + * `PI_SUBAGENT_ULTRA_KEYWORD=off` disables the trigger; the default is on, and + * an unrecognized value keeps the default with a warning. The `PI_SUBAGENT_ULTRA` + * kill switch disables this surface along with the rest of the layer. + */ +export function readUltraKeyword(value: string | undefined): { value: boolean; warning?: string } { + if (value === undefined || value === "") return { value: true }; + if (value === "on") return { value: true }; + if (value === "off") return { value: false }; + return { value: true, warning: `Invalid PI_SUBAGENT_ULTRA_KEYWORD="${value}"; using on.` }; +} + /** * The session's starting ultra-mode state. * diff --git a/test/config.test.ts b/test/config.test.ts index 64b5776..727d7fc 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -5,6 +5,7 @@ import { readMaxWorkers, readUltraEnabled, readUltraGuideline, + readUltraKeyword, readUltraMode, readUltraNotify, } from "../src/config.ts"; @@ -70,6 +71,19 @@ test("ultra mode defaults off, accepts on/off, and warns on invalid values", () } }); +test("the ultra keyword defaults on, disables only on an explicit off, and warns on invalid values", () => { + assert.deepEqual(readUltraKeyword(undefined), { value: true }); + assert.deepEqual(readUltraKeyword(""), { value: true }); + assert.deepEqual(readUltraKeyword("on"), { value: true }); + assert.deepEqual(readUltraKeyword("off"), { value: false }); + for (const invalid of ["0", "false", "OFF", " maybe", "disabled"]) { + const result = readUltraKeyword(invalid); + assert.equal(result.value, true); + assert.match(result.warning ?? "", /PI_SUBAGENT_ULTRA_KEYWORD/); + assert.match(result.warning ?? "", /using on/); + } +}); + test("ultra size guideline defaults to medium, accepts the four values, and warns on invalid values", () => { assert.deepEqual(readUltraGuideline(undefined), { value: "medium" }); assert.deepEqual(readUltraGuideline(""), { value: "medium" });