pi-braid 0.43.37 → 0.43.39

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/CHANGELOG.md CHANGED
@@ -96,6 +96,39 @@ record; the tag scheme above applies unchanged.
96
96
  note that a clean disable releases it, because a refusal an operator cannot act on
97
97
  is a support ticket.
98
98
 
99
+ ## Core — 0.43.39 (2026-11-09: one command per object, and a menu bar for the services)
100
+
101
+ - **`/modules` replaces six commands.** A registry that offered `modules-list`, `-enable`, `-disable`,
102
+ `-toggle`, `-reset` and `-status` offered six names for one object; it now offers one command with verbs
103
+ (`on`, `off`, `toggle`, `reset`, `all on|off`, `list`), a `SettingsList` in the TUI and the same rows as
104
+ text in RPC mode. The six old names forward for one release, so a script that calls them keeps working.
105
+ - **Four commands stop answering RPC mode with silence.** `tools` and `utility-model` printed into a void
106
+ when no component could render; both now notify the same information, and the TUI path is unchanged.
107
+ `utility-model`, `logs`, `telegram` and the modules command gained argument completion, and the
108
+ constructor-arity probe is replaced by the 1.5.0 selector signature it was probing for.
109
+ - **Three tests that did not exist**: the exact registered set, the two modes reaching one writer, and each
110
+ command's RPC shape. A planted revert per half reddens them.
111
+
112
+ ## Skills — 0.2.6 / Core 0.43.38
113
+
114
+ - **The whisper in an exported session was JSON, not prose.** A context-lifecycle proposal was stored as a
115
+ content array of two text parts, and pi-core's export template falls back to `JSON.stringify` for a
116
+ non-string custom message, so an exported HTML showed `[{"type":"text",…},{"type":"text","text":"[braid-whisper-end]"}]`
117
+ where the reader expected a suggestion. The channel now stores text, envelope first and marker last, which
118
+ is also exactly what the agent reads on resume.
119
+ (2026-11-09: a landing page is a set of mechanisms and a set of refusals)
120
+
121
+ - **`landing-page` joins the pack.** The family-tree landing was rebuilt against a professional reference
122
+ and the knowledge that made it safe existed only in that wave's report: the rail-and-panel switcher whose
123
+ no-script form is jump links, the timeline drawn as a line with stops, price tiers on shared rows, the
124
+ header action that survives 320px, and the rule that a form with no endpoint is a lie.
125
+ - **The refusals are the load-bearing half.** A page whose promise is that every fact has a source cannot
126
+ open with a testimonial from a client nobody served, an invented number, or a contact nobody answers. The
127
+ skill states that before it states any technique.
128
+ - **It names the gate that text checks cannot replace**: a headless browser at 320, 375, 768 and 1280 asking
129
+ whether the document is wider than its viewport, and whether any element's box crosses an edge from
130
+ outside every clipping ancestor.
131
+
99
132
  ## Core — 0.43.37 (2026-11-08: the shapes were rare, and the instrument policed the wrong text)
100
133
 
101
134
  - **Measured over the shipped corpus, the seven sentence shapes fired in 8 of 61 files.** 21 hits in
package/CONTRIBUTING.md CHANGED
@@ -207,7 +207,7 @@ Extensions are registered in the flat manifest at [`src/extensions/manifest.ts`]
207
207
 
208
208
  Config resolution order (highest priority first):
209
209
 
210
- 1. Runtime subagent API (`/modules-toggle`, `/modules-enable`, `/modules-disable`)
210
+ 1. Runtime subagent API (`/modules on`, `/modules off`, `/modules toggle`). The six former names (`/modules-enable`, `/modules-disable`, `/modules-toggle`, `/modules-list`, `/modules-status`, `/modules-reset`) forward to it for one release.
211
211
  2. `~/.pi/agent/settings.json` → `braid.modules`
212
212
  3. `BRAID_MODULES` env var
213
213
  4. Defaults (all non-opt-in extensions enabled)
package/build-info.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-braid",
3
- "version": "0.43.37",
4
- "sha": "7f456b784fa2259feec41d77d6c81c4bb7e64de9",
5
- "shaShort": "7f456b78",
3
+ "version": "0.43.39",
4
+ "sha": "9a833277c0434574ccf169f716b2031cba83efdd",
5
+ "shaShort": "9a833277",
6
6
  "branch": "detached",
7
7
  "dirty": false,
8
- "packedAt": "2026-11-08T21:09:34.250Z"
8
+ "packedAt": "2026-11-09T19:55:14.389Z"
9
9
  }
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Three concerns:
5
5
  * 1. Model selection: /utility-model (the merged role) opens the
6
- * ModelSelectorComponent UI. Model resolution is handled by
6
+ * ModelSelectorComponent UI in the TUI and prints the current setting as
7
+ * text elsewhere. Model resolution is handled by
7
8
  * src/lib/ai/model-resolver.ts (used by vision/metacognition tools
8
9
  * directly).
9
10
  * 2. Session manager patches: context_navigate and context_compress tools
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Three concerns:
5
5
  * 1. Model selection: /utility-model (the merged role) opens the
6
- * ModelSelectorComponent UI. Model resolution is handled by
6
+ * ModelSelectorComponent UI in the TUI and prints the current setting as
7
+ * text elsewhere. Model resolution is handled by
7
8
  * src/lib/ai/model-resolver.ts (used by vision/metacognition tools
8
9
  * directly).
9
10
  * 2. Session manager patches: context_navigate and context_compress tools
@@ -22,7 +23,7 @@
22
23
  * pi-core from an extension, so it surfaces as a once-per-process warning
23
24
  * naming the value to set.
24
25
  */
25
- import { ModelSelectorComponent, SettingsManager } from "@earendil-works/pi-coding-agent";
26
+ import { ModelSelectorComponent } from "@earendil-works/pi-coding-agent";
26
27
  import { resolveUtilityModel, normaliseRoleSetting } from "../../../lib/ai/model-resolver.js";
27
28
  import { applyCompactionReserveTokens, applyConfiguredContextWindow, } from "../../../lib/config/braid-settings.js";
28
29
  import { onEvent } from "../../../lib/events/event-types.js";
@@ -31,6 +32,31 @@ import { registerSessionCleanup } from "../../../lib/state/extension-state.js";
31
32
  import { readSettingsFile, updateSettings } from "../../../lib/config/per-tool-settings.js";
32
33
  import { createLogger } from "../../../lib/core/logger.js";
33
34
  const log = createLogger("polyfill");
35
+ /**
36
+ * The last context a run or a command handed the extension. Argument
37
+ * completion receives only the typed prefix - no ctx - so the model list it
38
+ * offers comes from here. Captured on session start and before each run, the
39
+ * points where the registry is bound.
40
+ */
41
+ let completionCtx;
42
+ /** Complete /utility-model's argument: the clear verb and the available
43
+ * catalogue as provider/model patterns. Only models the registry reports as
44
+ * available are named, so a completion cannot suggest a model the resolver
45
+ * would then refuse. */
46
+ function completeUtilityModel(prefix) {
47
+ const typed = (prefix ?? "").toLowerCase();
48
+ const items = [];
49
+ if ("clear".startsWith(typed)) {
50
+ items.push({ value: "clear", label: "clear", description: "Use the session model" });
51
+ }
52
+ for (const model of completionCtx?.modelRegistry.getAvailable() ?? []) {
53
+ const value = `${model.provider}/${model.id}`;
54
+ if (!value.toLowerCase().startsWith(typed))
55
+ continue;
56
+ items.push({ value, label: value, description: "Set the utility model" });
57
+ }
58
+ return items.length > 0 ? items : null;
59
+ }
34
60
  /** Custom settings keys managed by the model commands */
35
61
  import { getCustomModelKey, getCustomModelKeys, UTILITY_MODEL_KEY, } from "../../../lib/state/global-state.js";
36
62
  /** Shared sessionManager reference - used by patchSessionManagerMethods */
@@ -89,8 +115,9 @@ async function setRoleSettingFromArgs(ctx, key, roleLabel, note, argsText) {
89
115
  * vision analysis falls back to, so there is no separate vision command.
90
116
  */
91
117
  async function runUtilityModelCommand(args, ctx) {
118
+ completionCtx = ctx;
92
119
  if (!args || args.trim() === "") {
93
- if (ctx.hasUI) {
120
+ if (ctx.mode === "tui" && ctx.hasUI) {
94
121
  await openModelSelectorUI(ctx, UTILITY_MODEL_KEY, "Utility", resolveUtilityModel);
95
122
  }
96
123
  else {
@@ -171,6 +198,7 @@ export default function polyfillExtension(pi) {
171
198
  // here makes display and enforcement agree before the first run, not only
172
199
  // at the next agent turn. No-op when the setting is unset.
173
200
  pi.on(SESSION_START, (_event, ctx) => {
201
+ completionCtx = ctx;
174
202
  applyConfiguredContextWindow(ctx);
175
203
  // Pair the window with the reserve it implies: pi-core decides WHEN to
176
204
  // compact from its own `compaction.reserveTokens` (a fixed token count),
@@ -191,6 +219,7 @@ export default function polyfillExtension(pi) {
191
219
  });
192
220
  // Patch session manager methods on before_agent_start (fires for --no-session mode)
193
221
  pi.on("before_agent_start", async (_event, ctx) => {
222
+ completionCtx = ctx;
194
223
  patchSessionManagerMethods(pi, ctx);
195
224
  // Re-apply the configured window per run so a mid-session model switch
196
225
  // (a fresh catalog model object carrying the provider window) is
@@ -216,9 +245,10 @@ export default function polyfillExtension(pi) {
216
245
  description: "Set or show the utility model for classification tasks. " +
217
246
  "Accepts one model or an ordered list (comma-separated), tried in order " +
218
247
  "until the provider layer reports a route usable. " +
219
- "No args = show current setting. Smaller/faster models preferred. " +
220
- "Examples: /utility-model provider/model-id, /utility-model a/b,c/d, " +
221
- "/utility-model clear",
248
+ "No args shows the current setting (the TUI opens the selector). " +
249
+ "Smaller/faster models preferred. Examples: /utility-model provider/model-id, " +
250
+ "/utility-model a/b,c/d, /utility-model clear",
251
+ getArgumentCompletions: completeUtilityModel,
222
252
  handler: (args, ctx) => runUtilityModelCommand(args, ctx),
223
253
  });
224
254
  }
@@ -252,26 +282,18 @@ function resolveModelPattern(ctx, pattern) {
252
282
  /**
253
283
  * Open ModelSelectorComponent via ctx.ui.custom() for model selection.
254
284
  *
255
- * Approach:
256
- * - Use SettingsManager.inMemory() for ModelSelectorComponent (its
257
- * setDefaultModelAndProvider is a no-op for disk persistence - that's fine
258
- * since we call pi.setModel() afterwards which goes through AgentSession
259
- * and persists via the real settings manager).
260
- * - Capture the selected model in the onSelect callback.
261
- * - After ctx.ui.custom() resolves, call pi.setModel() and setModelSetting().
285
+ * The component reads and writes models through the ModelRuntime and the
286
+ * scoped list it is handed; persistence is this extension's job, so the
287
+ * selected pattern is written to the role setting after the dialog resolves.
288
+ * The selection callback stores the model before the dialog closes, which is
289
+ * the only state the handler keeps from it: choosing a role model must not
290
+ * change the session's default model.
262
291
  */
263
292
  async function openModelSelectorUI(ctx, settingKey, roleLabel, resolveFn) {
264
293
  const modelRegistry = ctx.modelRegistry;
265
- // ModelSelectorComponent writes through an in-memory SettingsManager:
266
- // setDefaultModelAndProvider() sets fields in memory but never persists,
267
- // so pi.setModel() below does the real persistence.
268
- const settingsManager = SettingsManager.inMemory();
269
- // ModelSelectorComponent's 4th parameter is the ModelRuntime. The extension
270
- // context exposes only the ModelRegistry facade, which holds the runtime as
271
- // a private field (`runtime`); read it directly. The retired
272
- // getAvailableSnapshot probe tested the registry for a method that exists
273
- // only on ModelRuntime, so it was false by construction on every supported
274
- // build.
294
+ // The extension context exposes only the ModelRegistry facade, which holds
295
+ // the runtime as a private field (`runtime`); the selector's 1.5.0
296
+ // signature takes that runtime directly.
275
297
  const modelRuntime = modelRegistry.runtime;
276
298
  // Priority: selected model first, then same provider, then others
277
299
  const currentRoleModel = resolveFn(ctx);
@@ -300,25 +322,11 @@ async function openModelSelectorUI(ctx, settingKey, roleLabel, resolveFn) {
300
322
  done(model);
301
323
  };
302
324
  const onCancel = () => done(undefined);
303
- // 0.80.8: (tui, currentModel, settingsManager, modelRuntime, scopedModels,
304
- // onSelect, onCancel) — ctor.length 7. 0.84.4: (tui, currentModel,
305
- // modelRuntime, scopedModels, onSelect, onCancel, initialSearchInput?,
306
- // onSelectAsDefault?, defaultModel?) — SettingsManager dropped; the
307
- // compiled ctor declares 9 plain params (no defaults) → length 9. NB:
308
- // function.length counts params BEFORE the first default — the d.ts's
309
- // "optional" suffixes don't exist in compiled JS. So length !== 7 = new. The installed
310
- // devDependency types may lag the running pi dist (0.82.1 d.ts vs 0.84.4
311
- // runtime), so the new-signature branch is typed loosely on purpose.
312
- const isNewSelector = ModelSelectorComponent.length !== 7;
313
- // structural component — pi renders it via ctx.ui.custom. Return type is
314
- // `object` (not {}): the new-signature branch is typed loosely on purpose.
315
- const SelectorCtor = ModelSelectorComponent;
316
- const selector = isNewSelector
317
- ? new SelectorCtor(tui, currentRoleModel, modelRuntime, scopedModels, onSelect, onCancel)
318
- : // 0.85.1 devDep types carry only the new signature (3rd param
319
- // ModelRuntime), so the legacy branch can no longer type against
320
- // them — same deliberate loose typing as the new branch above.
321
- new SelectorCtor(tui, currentRoleModel, settingsManager, modelRuntime, scopedModels, onSelect, onCancel);
325
+ // Installed 1.5.0 signature: (tui, currentModel, modelRuntime,
326
+ // scopedModels, onSelect, onCancel, initialSearchInput?,
327
+ // onSelectAsDefault?, defaultModel?). The runtime is read off the registry
328
+ // above; the types ship with the package, so no arity probe is needed.
329
+ const selector = new ModelSelectorComponent(tui, currentRoleModel, modelRuntime, scopedModels, onSelect, onCancel);
322
330
  return selector;
323
331
  });
324
332
  if (!selectedModel)
@@ -411,7 +411,12 @@ async function queueProposal(evaluated, pi, ctx, branchLength) {
411
411
  // measured deliveries). The source must be the TRUE family, so the
412
412
  // envelope says context-lifecycle.
413
413
  applyWhisperEnvelope(proposalContent, "context-lifecycle/proposal");
414
- sm?.appendCustomMessageEntry?.(PROPOSAL_CUSTOM_TYPE, proposalContent, true, proposal);
414
+ // A custom message rendered into an exported session prints its content
415
+ // as JSON when the content is an array of parts (pi-core's export template
416
+ // falls back to JSON.stringify for a non-string). The proposal is text, so
417
+ // it is stored as text: one string, envelope first and marker last, which
418
+ // is also what the agent reads on resume.
419
+ sm?.appendCustomMessageEntry?.(PROPOSAL_CUSTOM_TYPE, proposalContent.map((part) => part.text).join("\n"), true, proposal);
415
420
  // Record the suggestion class so a repeat re-fire is suppressed while
416
421
  // this one is still actionable (gate + dedupe rely on this map).
417
422
  state(ctx).proposalKeys.set(proposalKeyFor(proposal.message, proposal.suggested_action), Date.now());
@@ -169,6 +169,7 @@ export default function healthMaintenanceExtension(pi) {
169
169
  // than "none" will corrupt the TUI rendering.
170
170
  pi.registerCommand("logs", {
171
171
  description: "Show/clear the in-memory log buffer (TUI-safe default: no console writes)",
172
+ getArgumentCompletions: completeLogs,
172
173
  handler: async (args, ctx) => {
173
174
  const trimmed = (args ?? "").trim();
174
175
  const parts = trimmed.split(/\s+/);
@@ -204,6 +205,31 @@ export default function healthMaintenanceExtension(pi) {
204
205
  return { name: "health-maintenance", version: "3.0.0" };
205
206
  }
206
207
  // Action Handlers
208
+ const LOG_LEVELS = ["none", "error", "warn", "info", "debug"];
209
+ /** Complete /logs: its two verbs, then the level values after `level`. */
210
+ function completeLogs(prefix) {
211
+ const text = prefix ?? "";
212
+ const space = text.indexOf(" ");
213
+ if (space === -1) {
214
+ const typed = text.toLowerCase();
215
+ const verbs = [
216
+ { value: "clear", label: "clear", description: "Clear the in-memory buffer" },
217
+ { value: "level", label: "level", description: "Set the console log level" },
218
+ ];
219
+ const matches = verbs.filter((item) => item.value.startsWith(typed));
220
+ return matches.length > 0 ? matches : null;
221
+ }
222
+ const verb = text.slice(0, space).toLowerCase();
223
+ if (verb !== "level")
224
+ return null;
225
+ const typed = text.slice(space + 1).toLowerCase();
226
+ const matches = LOG_LEVELS.filter((level) => level.startsWith(typed)).map((level) => ({
227
+ value: `level ${level}`,
228
+ label: level,
229
+ description: level === "none" ? "TUI-safe (no console writes)" : "Writes to the console",
230
+ }));
231
+ return matches.length > 0 ? matches : null;
232
+ }
207
233
  async function executeHealthMaintenanceAction(params, _pi, ctx) {
208
234
  switch (params.action) {
209
235
  case "status":
package/dist/index.d.ts CHANGED
@@ -16,9 +16,10 @@
16
16
  * Reference targets: extension IDs ("enforcement") or module groups ("heartbeat").
17
17
  *
18
18
  * Subagent API:
19
- * Researcher subagents can call `/modules-enable`, `/modules-disable`,
20
- * `/modules-toggle`, `/modules-list`, `/modules-status`, `/modules-reset`
21
- * to control extension loading during benchmark experiments.
19
+ * Researcher subagents can call `/modules` (verbs: on, off, toggle, reset,
20
+ * all on|off, list) to control extension loading during benchmark experiments.
21
+ * The six former names (modules-enable, modules-disable, modules-toggle,
22
+ * modules-reset, modules-list, modules-status) forward to it for one release.
22
23
  */
23
24
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
24
25
  export default function braidExtension(pi: ExtensionAPI): Promise<void>;
package/dist/index.js CHANGED
@@ -16,9 +16,10 @@
16
16
  * Reference targets: extension IDs ("enforcement") or module groups ("heartbeat").
17
17
  *
18
18
  * Subagent API:
19
- * Researcher subagents can call `/modules-enable`, `/modules-disable`,
20
- * `/modules-toggle`, `/modules-list`, `/modules-status`, `/modules-reset`
21
- * to control extension loading during benchmark experiments.
19
+ * Researcher subagents can call `/modules` (verbs: on, off, toggle, reset,
20
+ * all on|off, list) to control extension loading during benchmark experiments.
21
+ * The six former names (modules-enable, modules-disable, modules-toggle,
22
+ * modules-reset, modules-list, modules-status) forward to it for one release.
22
23
  */
23
24
  import { readFileSync } from "node:fs";
24
25
  import { dirname, join } from "node:path";
@@ -1,18 +1,27 @@
1
1
  /**
2
- * Subagent API for module/toggle.
2
+ * Subagent API for extension toggling.
3
3
  *
4
- * Registers commands that a researcher subagent can call during benchmarks
5
- * to enable/disable extensions (or module groups) and query their state:
4
+ * One command, `/modules`, with a verb as its first argument:
6
5
  *
7
- * modules-enable <id> - Enable an extension or module group
8
- * modules-disable <id> - Disable an extension or module group
9
- * modules-toggle <id> - Toggle an extension or module group
10
- * modules-list - Show all extensions and their state
11
- * modules-status - Show current session extension state
12
- * modules-reset - Reset all runtime overrides
6
+ * /modules - TUI: open the extension list; RPC: print its rows as text
7
+ * /modules on <ref> - Enable an extension or module group
8
+ * /modules off <ref> - Disable an extension or module group
9
+ * /modules toggle <ref> - Flip the effective state
10
+ * /modules all on|off - Apply to every extension in the manifest
11
+ * /modules reset - Clear in-process overrides (persisted state stays)
12
+ * /modules list - Print the rows as text in every mode
13
13
  *
14
- * Reference targets can be individual extension IDs (e.g. "enforcement")
15
- * or module group names (e.g. "memory" expands to all memory extensions).
14
+ * Reference targets are extension IDs (e.g. "enforcement") or module group
15
+ * names (e.g. "memory", which expands to every extension in the group). A
16
+ * reference the resolver does not know is refused with the offending text
17
+ * alone; argument completion and `list` are the places that enumerate what is
18
+ * accepted.
19
+ *
20
+ * The six command names this file used to register remain as forwarding
21
+ * aliases for one release: modules-enable, modules-disable, modules-toggle,
22
+ * modules-reset, modules-list, modules-status. Each maps its whole argument
23
+ * onto the equivalent argv, so a script written against the old names keeps
24
+ * working until it is pointed at `/modules`.
16
25
  */
17
26
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
18
27
  export default function modulesApiExtension(pi: ExtensionAPI): Promise<void>;