repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

refactor(lint): tighten biome rules and fix violations

f2fe77d27c3c93ffdeafd5e019465433e95df1f0

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

- Enable noUnusedImports, noUnusedVariables (error)
- Enable noUnusedFunctionParameters (warn)
- Enable noVoidTypeReturn, useParseIntRadix, noUselessTernary (error)
- Enable noAssignInExpressions, noGlobalIsNan (error)
- Enable useNodejsImportProtocol (error), auto-fix 15 imports
- Enable noNonNullAssertion (warn) — 49 warnings surfaced for review
- Auto-fix import sorting and formatting across 102 files
- Manual fixes: split void returns, remove unused type alias,
  refactor ??= assignments, fix useless ternary

Changed files (119)

biome.json

Modified
33 33 "noBannedTypes": "off",
34 34 "noImportantStyles": "off",
35 35 "noUselessStringRaw": "off",
36 - "noUselessTernary": "off",
36 + "noUselessTernary": "error",
37 37 "useLiteralKeys": "off"
39 39 "correctness": {
40 - "noUnusedFunctionParameters": "off",
41 - "noUnusedImports": "off",
42 - "noUnusedVariables": "off",
43 - "noVoidTypeReturn": "off",
44 - "useParseIntRadix": "off"
40 + "noUnusedFunctionParameters": "warn",
41 + "noUnusedImports": "error",
42 + "noUnusedVariables": "error",
43 + "noVoidTypeReturn": "error",
44 + "useParseIntRadix": "error"
46 46 "performance": {
47 47 "noAccumulatingSpread": "off"
49 49 "style": {
50 50 "noDescendingSpecificity": "off",
51 - "noNonNullAssertion": "off",
52 - "useNodejsImportProtocol": "off",
51 + "noNonNullAssertion": "warn",
52 + "useNodejsImportProtocol": "error",
53 53 "useTemplate": "off"
55 55 "suspicious": {
56 - "noAssignInExpressions": "off",
56 + "noAssignInExpressions": "error",
57 57 "noControlCharactersInRegex": "off",
58 58 "noExplicitAny": "off",
59 - "noGlobalIsNan": "off",
59 + "noGlobalIsNan": "error",
60 60 "noImplicitAnyLet": "off",
61 61 "noTemplateCurlyInString": "off",
62 62 "useIterableCallbackReturn": "off"

extensions/AGENTS.md

Modified
4 4 # Pi Extensions Workspace
6 6 ## New extension
8 8 1. `extensions/{name}/package.json` — template below
9 9 2. `extensions/{name}/index.ts`
10 -3. `bun install`
10 +3. `npm install`
12 12 ## package.json
24 24 Add only deps actually imported by the extension.
25 25 Prefer `peerDependencies` for Pi packages (`@earendil-works/*`).
26 -Run `bun install` after any structural change.
26 +Run `npm install` after any structural change.
28 28 ## Mandatory test harness
31 31 - Every extension must include a pi-test-harness test that loads `index.ts`
32 32 through the real Pi extension runtime.
33 33 - Add `test:harness`:
34 - `bun test ./__tests__/harness.test.ts`.
34 + `npx vitest run ./__tests__/harness.test.ts`.
35 35 - If no `test` script exists, add `test`:
36 - `bun test ./__tests__/*.test.ts`.
36 + `npx vitest run ./__tests__/*.test.ts`.
38 38 ## Independence

extensions/angel/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("angel pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/angel/package.json

Modified
2 - "name": "@bugabinga/pi-ext-angel",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-ai": "*",
7 - "@earendil-works/pi-coding-agent": "*",
8 - "@earendil-works/pi-tui": "*",
9 - "typebox": "*"
10 - },
11 - "license": "MIT",
12 - "description": "Structured advisor and command guardrail for Pi.",
13 - "keywords": [
14 - "pi",
15 - "pi-extension"
16 - ],
17 - "devDependencies": {
18 - "@marcfargas/pi-test-harness": "^0.6.1"
19 - },
20 - "scripts": {},
21 - "private": true
2 + "name": "@bugabinga/pi-ext-angel",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-ai": "*",
7 + "@earendil-works/pi-coding-agent": "*",
8 + "@earendil-works/pi-tui": "*",
9 + "typebox": "*"
10 + },
11 + "license": "MIT",
12 + "description": "Structured advisor and command guardrail for Pi.",
13 + "keywords": [
14 + "pi",
15 + "pi-extension"
16 + ],
17 + "devDependencies": {
18 + "@marcfargas/pi-test-harness": "^0.6.1"
19 + },
20 + "scripts": {},
21 + "private": true

extensions/builtin-tools/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("builtin-tools pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/builtin-tools/package.json

Modified
2 - "name": "@bugabinga/pi-ext-builtin-tools",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Toggle Pi builtin file-search tools.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-builtin-tools",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Toggle Pi builtin file-search tools.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/context-size/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("context-size pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/context-size/package.json

Modified
2 - "name": "@bugabinga/pi-ext-context-size",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Context-window usage telemetry for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-context-size",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Context-window usage telemetry for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/cost/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
7 7 import { __test } from "../index.ts";
9 9 describe("cost pi-test-harness", () => {

extensions/cost/package.json

Modified
2 - "name": "@bugabinga/pi-ext-cost",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Token and spend telemetry for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-cost",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Token and spend telemetry for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/ctx/__tests__/harness.test.ts

Modified
1 -import { afterEach, beforeEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, beforeEach, describe, expect, it } from "vitest";
8 8 let t: TestSession | undefined;
22 22 input?: Record<string, unknown>;
23 23 isError?: boolean;
24 24 }) {
25 - return await t!.session.extensionRunner.emitToolResult({
25 + return await t?.session.extensionRunner.emitToolResult({
26 26 type: "tool_result",
27 27 toolName: "read",
28 28 input: params.input ?? { path: "big.txt" },

extensions/ctx/package.json

Modified
2 - "name": "@bugabinga/pi-ext-ctx",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "devDependencies": {
7 - "@marcfargas/pi-test-harness": "^0.6.1"
8 - },
9 - "license": "MIT",
10 - "description": "Compacts oversized Pi read results before they hit context.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "private": true
2 + "name": "@bugabinga/pi-ext-ctx",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "devDependencies": {
7 + "@marcfargas/pi-test-harness": "^0.6.1"
8 + },
9 + "license": "MIT",
10 + "description": "Compacts oversized Pi read results before they hit context.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "private": true

extensions/cwd/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("cwd pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/cwd/package.json

Modified
2 - "name": "@bugabinga/pi-ext-cwd",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Switch Pi cwd without leaving the session.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-cwd",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Switch Pi cwd without leaving the session.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/devil/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import {
3 2 createTestSession,
4 3 type TestSession,
5 4 } from "@marcfargas/pi-test-harness";
5 +import { afterEach, describe, expect, it } from "vitest";
7 7 let t: TestSession | undefined;

extensions/devil/__tests__/helpers.test.ts

Modified
9 9 extractSnippet,
10 10 textFromContent,
11 11 } from "../helpers.ts";
12 -import type { DebateOutput } from "../types.ts";
14 13 // ─── textFromContent ──────────────────────────────────────────────────
126 125 controller.abort();
127 126 const result = checkAborted(controller.signal, ["r1"], 2);
128 127 expect(result).not.toBeNull();
129 - expect(result!.aborted).toBe(true);
130 - expect(result!.blockingRaised).toBe(2);
128 + expect(result?.aborted).toBe(true);
129 + expect(result?.blockingRaised).toBe(2);

extensions/devil/package.json

Modified
2 - "name": "@bugabinga/pi-ext-devil",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "peerDependencies": {
7 - "@earendil-works/pi-ai": "*",
8 - "@earendil-works/pi-agent-core": "*",
9 - "@earendil-works/pi-coding-agent": "*",
10 - "@earendil-works/pi-tui": "*"
11 - },
12 - "devDependencies": {
13 - "@marcfargas/pi-test-harness": "^0.6.1"
14 - },
15 - "license": "MIT",
16 - "description": "Devil's advocate debate command for Pi.",
17 - "keywords": [
18 - "pi",
19 - "pi-extension"
20 - ],
21 - "private": true
2 + "name": "@bugabinga/pi-ext-devil",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "peerDependencies": {
7 + "@earendil-works/pi-ai": "*",
8 + "@earendil-works/pi-agent-core": "*",
9 + "@earendil-works/pi-coding-agent": "*",
10 + "@earendil-works/pi-tui": "*"
11 + },
12 + "devDependencies": {
13 + "@marcfargas/pi-test-harness": "^0.6.1"
14 + },
15 + "license": "MIT",
16 + "description": "Devil's advocate debate command for Pi.",
17 + "keywords": [
18 + "pi",
19 + "pi-extension"
20 + ],
21 + "private": true

extensions/fast/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("fast pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/fast/package.json

Modified
2 - "name": "@bugabinga/pi-ext-fast",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-ai": "*",
7 - "@earendil-works/pi-coding-agent": "*"
8 - },
9 - "license": "MIT",
10 - "description": "Priority service tier for OpenAI Codex in Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-fast",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-ai": "*",
7 + "@earendil-works/pi-coding-agent": "*"
8 + },
9 + "license": "MIT",
10 + "description": "Priority service tier for OpenAI Codex in Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/footer/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("footer pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/footer/package.json

Modified
2 - "name": "@bugabinga/pi-ext-footer",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-tui": "*"
8 - },
9 - "license": "MIT",
10 - "description": "Shared stable footer renderer for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-footer",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-tui": "*"
8 + },
9 + "license": "MIT",
10 + "description": "Shared stable footer renderer for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/git-safe/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("git-safe pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/git-safe/clone.ts

Modified
6 6 // - Credential prompt hangs
8 8 import { existsSync, realpathSync } from "node:fs";
9 -import {
10 - mkdir,
11 - readdir,
12 - readFile,
13 - rm,
14 - stat,
15 - writeFile,
16 -} from "node:fs/promises";
9 +import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
17 10 import { homedir, tmpdir } from "node:os";
18 -import { basename, dirname, join, resolve } from "node:path";
11 +import { dirname, join, resolve } from "node:path";
19 12 import {
20 13 SpawnExitError,
21 14 SpawnTimeoutError,
246 239 // Format: <mode> <type> <hash> <size>\t<path>
247 240 const sizeMatch = line.match(/\s+(\d+)\t/);
248 241 if (sizeMatch) {
249 - totalSize += parseInt(sizeMatch[1]);
242 + totalSize += parseInt(sizeMatch[1], 10);
250 243 fileCount++;
253 - } catch (e) {
246 + } catch (_e) {
254 247 // ls-tree may fail on empty repos — that's fine
255 248 warnings.push(
256 249 "Could not compute pre-checkout size (empty repo or ls-tree unavailable).",

extensions/git-safe/index.ts

Modified
20 20 import { realpath } from "node:fs/promises";
21 21 import { resolve } from "node:path";
22 22 import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
23 -import { isToolCallEventType } from "@earendil-works/pi-coding-agent";
24 23 import { Text } from "@earendil-works/pi-tui";
25 24 import { Type } from "typebox";
26 25 import {
220 219 return new Text(text, 0, 0);
223 - async execute(_toolCallId, params, signal, onUpdate, ctx) {
222 + async execute(_toolCallId, params, _signal, onUpdate, ctx) {
224 223 ctx?.ui?.setWorkingMessage(`Cloning ${params.url} safely...`);
225 224 onUpdate?.({
226 225 content: [

extensions/git-safe/package.json

Modified
2 - "name": "@bugabinga/pi-ext-git-safe",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-tui": "*",
8 - "typebox": "*"
9 - },
10 - "license": "MIT",
11 - "description": "Hardened git clone tool for Pi.",
12 - "keywords": [
13 - "pi",
14 - "pi-extension"
15 - ],
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "scripts": {},
20 - "private": true
2 + "name": "@bugabinga/pi-ext-git-safe",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-tui": "*",
8 + "typebox": "*"
9 + },
10 + "license": "MIT",
11 + "description": "Hardened git clone tool for Pi.",
12 + "keywords": [
13 + "pi",
14 + "pi-extension"
15 + ],
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "scripts": {},
20 + "private": true

extensions/git-safe/spawn.ts

Modified
42 42 proc.stderr.on("data", (d: Buffer) => (stderr += d));
43 43 proc.on("close", (code) => {
44 44 clearTimeout(timer);
45 - resolve({ stdout, stderr, code, killed: timer.ref ? false : false });
45 + resolve({ stdout, stderr, code, killed: false });
47 47 proc.on("error", (err) => {
48 48 clearTimeout(timer);

extensions/goal/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import {
3 2 createAssistantMessageEventStream,
4 3 getApiProvider,
8 7 createTestSession,
9 8 type TestSession,
10 9 } from "@marcfargas/pi-test-harness";
10 +import { afterEach, describe, expect, it } from "vitest";
11 11 import { __goalTest, GOAL_PROBE_MESSAGE } from "../index.ts";
13 13 let t: TestSession | undefined;
105 105 function customEvents(kind: string): Array<Record<string, unknown>> {
106 106 return (
107 - t!.session.sessionManager.getEntries() as Array<{
107 + t?.session.sessionManager.getEntries() as Array<{
108 108 type: string;
109 109 customType?: string;
110 110 data?: Record<string, unknown>;
117 117 function customMessages(kind: string): Array<Record<string, unknown>> {
118 118 return (
119 - t!.session.sessionManager.getEntries() as Array<{
119 + t?.session.sessionManager.getEntries() as Array<{
120 120 type: string;
121 121 customType?: string;
122 122 content?: string;
137 137 function uiArgs(method: string): unknown[][] {
138 - return t!.events.ui
138 + return t?.events.ui
139 139 .filter((call) => call.method === method)
140 140 .map((call) => call.args);
147 147 function latestGoal() {
148 148 return __goalTest.latestGoalState({
149 - sessionManager: t!.session.sessionManager,
149 + sessionManager: t?.session.sessionManager,
150 150 } as never);
214 214 await t.session.prompt("initial work");
215 215 await waitFor(
217 - t!.events.all.filter((event) => event.type === "agent_end").length >=
217 + t?.events.all.filter((event) => event.type === "agent_end").length >=
218 218 expectedAgentEnds,
220 220 await new Promise((resolve) => setTimeout(resolve, 25));
697 697 for (const mode of ["direct", "microtask"] as const) {
698 698 it(`${mode} dispatch is still busy inside agent_end`, async () => {
699 699 await runProbe(mode, 1);
700 - const agentStarts = t!.events.all.filter(
700 + const agentStarts = t?.events.all.filter(
701 701 (event) => event.type === "agent_start",
703 - const agentEnds = t!.events.all.filter(
703 + const agentEnds = t?.events.all.filter(
704 704 (event) => event.type === "agent_end",
706 706 const probeEvents = customEvents("goal-probe").map(
717 717 it("setTimeout(0) schedules exactly one continuation after idle", async () => {
718 718 await runProbe("timeout", 2);
720 - const agentStarts = t!.events.all.filter(
720 + const agentStarts = t?.events.all.filter(
721 721 (event) => event.type === "agent_start",
723 - const agentEnds = t!.events.all.filter(
723 + const agentEnds = t?.events.all.filter(
724 724 (event) => event.type === "agent_end",
726 - const assistantMessages = t!.events.messages
726 + const assistantMessages = t?.events.messages
727 727 .filter((message) => message.role === "assistant")
728 728 .map((message) =>
729 729 Array.isArray(message.content)
746 746 expect(probeEvents.at(-1)).toBe("done");
748 - const userMessages = t!.session.sessionManager
748 + const userMessages = t?.session.sessionManager
749 749 .getEntries()
750 750 .filter(
751 751 (entry: {

extensions/goal/__tests__/unit.test.ts

Modified
165 165 ).toBe("━━━━──────");
166 166 expect(
167 167 __goalTest.goalWidgetLines(
168 - goal({ lastReason: "needs tests", createdAt: Date.now(), timeUsedSeconds: 0 }) as never,
168 + goal({
169 + lastReason: "needs tests",
170 + createdAt: Date.now(),
171 + timeUsedSeconds: 0,
172 + }) as never,
169 173 "normal",
446 450 expect(__goalTest.shortText(" a b ", 10)).toBe("a b");
448 452 it("defaults max to 72", () => {
449 - expect(__goalTest.shortText("x".repeat(80)).length).toBeLessThanOrEqual(72);
453 + expect(__goalTest.shortText("x".repeat(80)).length).toBeLessThanOrEqual(
454 + 72,
455 + );
459 465 expect(__goalTest.sanitizeGoalText(" a b ")).toBe("a b");
461 467 it("truncates to max", () => {
462 - expect(__goalTest.sanitizeGoalText("x".repeat(200), 160)).toHaveLength(160);
463 - expect(__goalTest.sanitizeGoalText("x".repeat(200), 160).endsWith("…")).toBe(true);
468 + expect(__goalTest.sanitizeGoalText("x".repeat(200), 160)).toHaveLength(
469 + 160,
470 + );
471 + expect(
472 + __goalTest.sanitizeGoalText("x".repeat(200), 160).endsWith("…"),
473 + ).toBe(true);
465 475 it("defaults max to 160", () => {
466 476 expect(__goalTest.sanitizeGoalText("x".repeat(200))).toHaveLength(160);
507 517 describe("elapsedSeconds", () => {
508 518 it("returns timeUsedSeconds from state", () => {
509 - expect(__goalTest.elapsedSeconds(goal({ timeUsedSeconds: 42 }) as never)).toBe(42);
519 + expect(
520 + __goalTest.elapsedSeconds(goal({ timeUsedSeconds: 42 }) as never),
521 + ).toBe(42);
511 523 it("defaults to 0 when undefined", () => {
512 524 expect(__goalTest.elapsedSeconds(goal() as never)).toBe(0);
526 538 describe("budgetText", () => {
527 539 it("shows elapsed time with no budgets", () => {
528 - const state = goal({ createdAt: Date.now(), timeUsedSeconds: 0 }) as never;
540 + const state = goal({
541 + createdAt: Date.now(),
542 + timeUsedSeconds: 0,
543 + }) as never;
529 544 expect(__goalTest.budgetText(state)).toMatch(/\d+s$/);
531 546 it("shows token budget when set", () => {
571 586 describe("goalPhaseText", () => {
572 587 it("judging shows turn+1", () => {
573 - expect(__goalTest.goalPhaseText(goal({ turnsUsed: 3 }) as never, "judging")).toBe(
574 - "judging 4/5",
575 - );
588 + expect(
589 + __goalTest.goalPhaseText(goal({ turnsUsed: 3 }) as never, "judging"),
590 + ).toBe("judging 4/5");
577 592 it("queued shows continuation label", () => {
578 - expect(__goalTest.goalPhaseText(goal({ turnsUsed: 1 }) as never, "queued")).toBe(
579 - "queued continuation 2/5",
580 - );
593 + expect(
594 + __goalTest.goalPhaseText(goal({ turnsUsed: 1 }) as never, "queued"),
595 + ).toBe("queued continuation 2/5");
582 597 it("normal returns status only (no turn count)", () => {
583 - expect(__goalTest.goalPhaseText(goal() as never, "normal")).toBe("active");
598 + expect(__goalTest.goalPhaseText(goal() as never, "normal")).toBe(
599 + "active",
600 + );
587 604 describe("footerPhaseText", () => {
588 605 it("judging includes goal prefix", () => {
589 - expect(__goalTest.footerPhaseText(goal({ turnsUsed: 2 }) as never, "judging")).toBe(
590 - "goal judging 3/5",
591 - );
606 + expect(
607 + __goalTest.footerPhaseText(goal({ turnsUsed: 2 }) as never, "judging"),
608 + ).toBe("goal judging 3/5");
593 610 it("queued includes goal prefix", () => {
594 611 expect(__goalTest.footerPhaseText(goal() as never, "queued")).toBe(
603 620 it("blocked (no turn budget) omits turns", () => {
604 621 expect(
605 - __goalTest.footerPhaseText(goal({ status: "blocked" }) as never, "normal"),
622 + __goalTest.footerPhaseText(
623 + goal({ status: "blocked" }) as never,
624 + "normal",
625 + ),
606 626 ).toBe("goal blocked");
610 630 describe("judgeStatusText", () => {
611 631 it("shows judging with turn+1", () => {
612 - expect(__goalTest.judgeStatusText(goal() as never)).toBe("goal judging 3/5 · 2c");
632 + expect(__goalTest.judgeStatusText(goal() as never)).toBe(
633 + "goal judging 3/5 · 2c",
634 + );
614 636 it("omits criteria count when empty", () => {
615 - expect(
616 - __goalTest.judgeStatusText(goal({ criteria: [] }) as never),
617 - ).toBe("goal judging 3/5");
637 + expect(__goalTest.judgeStatusText(goal({ criteria: [] }) as never)).toBe(
638 + "goal judging 3/5",
639 + );
621 643 describe("isJudgeParseFailure", () => {
622 644 it("detects judge returned messages", () => {
623 645 expect(
624 - __goalTest.isJudgeParseFailure({ done: false, blocked: false, reason: "judge returned empty" }),
646 + __goalTest.isJudgeParseFailure({
647 + done: false,
648 + blocked: false,
649 + reason: "judge returned empty",
650 + }),
625 651 ).toBe(true);
627 653 it("detects JSON parse errors", () => {
628 654 expect(
629 - __goalTest.isJudgeParseFailure({ done: false, blocked: false, reason: "JSON parse failed: Unexpected token" }),
655 + __goalTest.isJudgeParseFailure({
656 + done: false,
657 + blocked: false,
658 + reason: "JSON parse failed: Unexpected token",
659 + }),
630 660 ).toBe(true);
632 662 it("returns false for normal reasons", () => {
633 663 expect(
634 - __goalTest.isJudgeParseFailure({ done: false, blocked: false, reason: "still working" }),
664 + __goalTest.isJudgeParseFailure({
665 + done: false,
666 + blocked: false,
667 + reason: "still working",
668 + }),
635 669 ).toBe(false);
639 673 describe("judgeVerdictLabel", () => {
640 674 it("returns done/blocked/continue", () => {
641 - expect(__goalTest.judgeVerdictLabel({ done: true, blocked: false, reason: "" })).toBe("done");
642 - expect(__goalTest.judgeVerdictLabel({ done: false, blocked: true, reason: "" })).toBe("blocked");
643 - expect(__goalTest.judgeVerdictLabel({ done: false, blocked: false, reason: "" })).toBe("continue");
675 + expect(
676 + __goalTest.judgeVerdictLabel({
677 + done: true,
678 + blocked: false,
679 + reason: "",
680 + }),
681 + ).toBe("done");
682 + expect(
683 + __goalTest.judgeVerdictLabel({
684 + done: false,
685 + blocked: true,
686 + reason: "",
687 + }),
688 + ).toBe("blocked");
689 + expect(
690 + __goalTest.judgeVerdictLabel({
691 + done: false,
692 + blocked: false,
693 + reason: "",
694 + }),
695 + ).toBe("continue");
647 699 describe("goalVerdictLabel", () => {
648 700 it("returns error for judge failures", () => {
649 701 expect(
650 - __goalTest.goalVerdictLabel({ done: false, blocked: false, reason: "judge failed: timeout" }),
702 + __goalTest.goalVerdictLabel({
703 + done: false,
704 + blocked: false,
705 + reason: "judge failed: timeout",
706 + }),
651 707 ).toBe("error");
652 708 expect(
653 - __goalTest.goalVerdictLabel({ done: false, blocked: false, reason: "normal reason" }),
709 + __goalTest.goalVerdictLabel({
710 + done: false,
711 + blocked: false,
712 + reason: "normal reason",
713 + }),
654 714 ).toBe("continue");
675 735 describe("nextBlockedStreak", () => {
676 736 it("increments when same hash", () => {
677 737 const h = __goalTest.reasonHash("x");
678 - const state = goal({ blockedStreak: { reasonHash: h, count: 3 } }) as never;
738 + const state = goal({
739 + blockedStreak: { reasonHash: h, count: 3 },
740 + }) as never;
679 741 expect(__goalTest.nextBlockedStreak(state, "X")).toEqual({
680 742 reasonHash: h,
681 743 count: 4,
684 746 it("resets to 1 when different hash", () => {
685 - const state = goal({ blockedStreak: { reasonHash: "x", count: 3 } }) as never;
747 + const state = goal({
748 + blockedStreak: { reasonHash: "x", count: 3 },
749 + }) as never;
686 750 expect(__goalTest.nextBlockedStreak(state, "different")).toEqual({
687 751 reasonHash: expect.any(String),
688 752 count: 1,
700 764 describe("showsTurnBudget", () => {
701 765 it("shows for active and paused", () => {
702 - expect(__goalTest.showsTurnBudget(goal({ status: "active" }) as never)).toBe(true);
703 - expect(__goalTest.showsTurnBudget(goal({ status: "paused" }) as never)).toBe(true);
766 + expect(
767 + __goalTest.showsTurnBudget(goal({ status: "active" }) as never),
768 + ).toBe(true);
769 + expect(
770 + __goalTest.showsTurnBudget(goal({ status: "paused" }) as never),
771 + ).toBe(true);
705 773 it("hides for complete and blocked", () => {
706 - expect(__goalTest.showsTurnBudget(goal({ status: "complete" }) as never)).toBe(false);
707 - expect(__goalTest.showsTurnBudget(goal({ status: "blocked" }) as never)).toBe(false);
774 + expect(
775 + __goalTest.showsTurnBudget(goal({ status: "complete" }) as never),
776 + ).toBe(false);
777 + expect(
778 + __goalTest.showsTurnBudget(goal({ status: "blocked" }) as never),
779 + ).toBe(false);
711 783 describe("showsPersistentStatus", () => {
712 784 it("shows for all except complete", () => {
713 - expect(__goalTest.showsPersistentStatus(goal({ status: "active" }) as never)).toBe(true);
714 - expect(__goalTest.showsPersistentStatus(goal({ status: "paused" }) as never)).toBe(true);
715 - expect(__goalTest.showsPersistentStatus(goal({ status: "blocked" }) as never)).toBe(true);
716 - expect(__goalTest.showsPersistentStatus(goal({ status: "complete" }) as never)).toBe(false);
785 + expect(
786 + __goalTest.showsPersistentStatus(goal({ status: "active" }) as never),
787 + ).toBe(true);
788 + expect(
789 + __goalTest.showsPersistentStatus(goal({ status: "paused" }) as never),
790 + ).toBe(true);
791 + expect(
792 + __goalTest.showsPersistentStatus(goal({ status: "blocked" }) as never),
793 + ).toBe(true);
794 + expect(
795 + __goalTest.showsPersistentStatus(goal({ status: "complete" }) as never),
796 + ).toBe(false);
722 802 expect(__goalTest.goalTone(goal() as never, "judging")).toBe("warning");
724 804 it("complete is success", () => {
725 - expect(__goalTest.goalTone(goal({ status: "complete" }) as never, "normal")).toBe("success");
805 + expect(
806 + __goalTest.goalTone(goal({ status: "complete" }) as never, "normal"),
807 + ).toBe("success");
727 809 it("blocked is warning", () => {
728 - expect(__goalTest.goalTone(goal({ status: "blocked" }) as never, "normal")).toBe("warning");
810 + expect(
811 + __goalTest.goalTone(goal({ status: "blocked" }) as never, "normal"),
812 + ).toBe("warning");
730 814 it("paused is muted", () => {
731 - expect(__goalTest.goalTone(goal({ status: "paused" }) as never, "normal")).toBe("muted");
815 + expect(
816 + __goalTest.goalTone(goal({ status: "paused" }) as never, "normal"),
817 + ).toBe("muted");
733 819 it("active is accent", () => {
734 - expect(__goalTest.goalTone(goal({ status: "active" }) as never, "normal")).toBe("accent");
820 + expect(
821 + __goalTest.goalTone(goal({ status: "active" }) as never, "normal"),
822 + ).toBe("accent");
738 826 describe("goalProgress", () => {
739 827 it("calculates percentage", () => {
740 - expect(__goalTest.goalProgress(goal({ turnsUsed: 2, maxTurns: 5 }) as never)).toBe(40);
741 - expect(__goalTest.goalProgress(goal({ turnsUsed: 0, maxTurns: 5 }) as never)).toBe(0);
742 - expect(__goalTest.goalProgress(goal({ turnsUsed: 5, maxTurns: 5 }) as never)).toBe(100);
828 + expect(
829 + __goalTest.goalProgress(goal({ turnsUsed: 2, maxTurns: 5 }) as never),
830 + ).toBe(40);
831 + expect(
832 + __goalTest.goalProgress(goal({ turnsUsed: 0, maxTurns: 5 }) as never),
833 + ).toBe(0);
834 + expect(
835 + __goalTest.goalProgress(goal({ turnsUsed: 5, maxTurns: 5 }) as never),
836 + ).toBe(100);
744 838 it("returns 0 for maxTurns <= 0", () => {
745 839 expect(__goalTest.goalProgress(goal({ maxTurns: 0 }) as never)).toBe(0);
746 840 expect(__goalTest.goalProgress(goal({ maxTurns: -1 }) as never)).toBe(0);
748 842 it("clamps to 100", () => {
749 - expect(__goalTest.goalProgress(goal({ turnsUsed: 10, maxTurns: 5 }) as never)).toBe(100);
843 + expect(
844 + __goalTest.goalProgress(goal({ turnsUsed: 10, maxTurns: 5 }) as never),
845 + ).toBe(100);
794 890 expect(rows[1]).not.toContain("label");
796 892 it("handles zero inner width", () => {
797 - expect(__goalTest.goalWidgetRow("x", "y", 0)).toEqual(["│ x │"]);
893 + expect(__goalTest.goalWidgetRow("x", "y", 0)).toEqual([
894 + "│ x │",
895 + ]);
815 913 expect(lines.some((l) => l.includes("verdict"))).toBe(true);
817 915 it("renders complete status with no widget", () => {
818 - expect(() => __goalTest.goalWidgetLines(
819 - goal({ status: "complete" }) as never,
820 - "normal",
821 - 50,
822 - )).toBeDefined();
916 + expect(() =>
917 + __goalTest.goalWidgetLines(
918 + goal({ status: "complete" }) as never,
919 + "normal",
920 + 50,
921 + ),
922 + ).toBeDefined();
824 924 it("handles zero criteria", () => {
825 925 const lines = __goalTest.goalWidgetLines(
847 947 expect(__goalTest.statusLine(goal() as never)).toContain("2/5 turns");
849 949 it("omits turn count for blocked status", () => {
850 - expect(__goalTest.statusLine(goal({ status: "blocked" }) as never)).not.toContain("turns");
950 + expect(
951 + __goalTest.statusLine(goal({ status: "blocked" }) as never),
952 + ).not.toContain("turns");
852 954 it("includes criteria count", () => {
853 955 expect(__goalTest.statusLine(goal() as never)).toContain("2 criteria");
855 957 it("omits criteria when empty", () => {
856 - expect(__goalTest.statusLine(goal({ criteria: [] }) as never)).not.toContain("criteria");
958 + expect(
959 + __goalTest.statusLine(goal({ criteria: [] }) as never),
960 + ).not.toContain("criteria");
858 962 it("includes last reason when present", () => {
859 - expect(__goalTest.statusLine(goal({ lastReason: "stuck" }) as never)).toContain("stuck");
963 + expect(
964 + __goalTest.statusLine(goal({ lastReason: "stuck" }) as never),
965 + ).toContain("stuck");
861 967 it("omits reason when absent", () => {
862 - const text = __goalTest.statusLine(goal({ lastReason: undefined }) as never);
968 + const text = __goalTest.statusLine(
969 + goal({ lastReason: undefined }) as never,
970 + );
863 971 const parts = text.split("\n");
864 972 expect(parts[0]).not.toMatch(/· \w+$/); // no trailing reason after last part
868 976 describe("compactStatusLine", () => {
869 977 it("shows full criteria list", () => {
870 - expect(__goalTest.compactStatusLine(goal() as never)).toContain("criteria:\n 1. tests pass\n 2. docs updated");
978 + expect(__goalTest.compactStatusLine(goal() as never)).toContain(
979 + "criteria:\n 1. tests pass\n 2. docs updated",
980 + );
872 982 it("omits criteria section when empty", () => {
873 - const text = __goalTest.compactStatusLine(goal({ criteria: [] }) as never);
983 + const text = __goalTest.compactStatusLine(
984 + goal({ criteria: [] }) as never,
985 + );
874 986 expect(text).not.toContain("criteria:");
876 988 it("shows verdict glyph with reason", () => {
877 - expect(__goalTest.compactStatusLine(goal({ lastVerdict: "done", lastReason: "passed" }) as never)).toContain("✓ passed");
878 - expect(__goalTest.compactStatusLine(goal({ lastVerdict: "blocked", lastReason: "stuck" }) as never)).toContain("⊘ stuck");
989 + expect(
990 + __goalTest.compactStatusLine(
991 + goal({ lastVerdict: "done", lastReason: "passed" }) as never,
992 + ),
993 + ).toContain("✓ passed");
994 + expect(
995 + __goalTest.compactStatusLine(
996 + goal({ lastVerdict: "blocked", lastReason: "stuck" }) as never,
997 + ),
998 + ).toContain("⊘ stuck");
880 1000 it("omits reason line when absent", () => {
881 - const text = __goalTest.compactStatusLine(goal({ lastReason: undefined }) as never);
1001 + const text = __goalTest.compactStatusLine(
1002 + goal({ lastReason: undefined }) as never,
1003 + );
882 1004 expect(text).not.toContain("✓");
883 1005 expect(text).not.toContain("⊘");
884 1006 expect(text).not.toContain("…");
886 1008 it("shows budget text", () => {
887 - expect(__goalTest.compactStatusLine(goal({ timeUsedSeconds: 30, createdAt: Date.now() }) as never)).toContain("30s");
1009 + expect(
1010 + __goalTest.compactStatusLine(
1011 + goal({ timeUsedSeconds: 30, createdAt: Date.now() }) as never,
1012 + ),
1013 + ).toContain("30s");
891 1017 describe("goalProgress / goalBar", () => {
892 1018 it("goalBar fills proportionally", () => {
893 - expect(__goalTest.goalBar(goal({ turnsUsed: 0, maxTurns: 5 }) as never)).toBe("──────────");
894 - expect(__goalTest.goalBar(goal({ turnsUsed: 5, maxTurns: 5 }) as never)).toBe("━━━━━━━━━━");
895 - expect(__goalTest.goalBar(goal({ turnsUsed: 3, maxTurns: 10 }) as never)).toBe("━━━───────");
1019 + expect(
1020 + __goalTest.goalBar(goal({ turnsUsed: 0, maxTurns: 5 }) as never),
1021 + ).toBe("──────────");
1022 + expect(
1023 + __goalTest.goalBar(goal({ turnsUsed: 5, maxTurns: 5 }) as never),
1024 + ).toBe("━━━━━━━━━━");
1025 + expect(
1026 + __goalTest.goalBar(goal({ turnsUsed: 3, maxTurns: 10 }) as never),
1027 + ).toBe("━━━───────");
897 1029 it("goalBar custom width", () => {
898 - expect(__goalTest.goalBar(goal({ turnsUsed: 1, maxTurns: 4 }) as never, 4)).toBe("━───");
1030 + expect(
1031 + __goalTest.goalBar(goal({ turnsUsed: 1, maxTurns: 4 }) as never, 4),
1032 + ).toBe("━───");
902 1036 describe("parseJudge edge cases", () => {
903 1037 it("provides defaults for missing fields", () => {
904 1038 expect(__goalTest.parseJudge('{"blocked":false,"reason":"x"}')).toEqual({
905 - done: false, blocked: false, reason: "x",
1039 + done: false,
1040 + blocked: false,
1041 + reason: "x",
907 1043 expect(__goalTest.parseJudge('{"done":false,"reason":"x"}')).toEqual({
908 - done: false, blocked: false, reason: "x",
1044 + done: false,
1045 + blocked: false,
1046 + reason: "x",
911 1049 it("defaults non-string reason", () => {
912 - expect(__goalTest.parseJudge('{"done":true,"blocked":false,"reason":123}').reason).toBe("no reason");
1050 + expect(
1051 + __goalTest.parseJudge('{"done":true,"blocked":false,"reason":123}')
1052 + .reason,
1053 + ).toBe("no reason");
914 1055 it("strips markdown fences", () => {
915 1056 expect(
916 - __goalTest.parseJudge('```json\n{"done":true,"blocked":false,"reason":"ok"}\n```'),
1057 + __goalTest.parseJudge(
1058 + '```json\n{"done":true,"blocked":false,"reason":"ok"}\n```',
1059 + ),
917 1060 ).toEqual({ done: true, blocked: false, reason: "ok" });
921 1064 describe("extractStandingGoalObjective edge cases", () => {
922 1065 it("rejects without standing goal prefix", () => {
923 - expect(__goalTest.extractStandingGoalObjective("<objective>\nx\n</objective>")).toBeUndefined();
1066 + expect(
1067 + __goalTest.extractStandingGoalObjective("<objective>\nx\n</objective>"),
1068 + ).toBeUndefined();
925 1070 it("handles nested objectives", () => {
926 1071 expect(
934 1079 describe("goalWidgetLines wrapping", () => {
935 1080 it("wraps long objective across multiple lines", () => {
936 1081 const lines = __goalTest.goalWidgetLines(
937 - goal({ objective: "a b c d e f g h i j k l m n o p q r s t u v w x y z" }) as never,
1082 + goal({
1083 + objective: "a b c d e f g h i j k l m n o p q r s t u v w x y z",
1084 + }) as never,
938 1085 "normal",
945 1092 it("wraps long criteria", () => {
946 1093 const lines = __goalTest.goalWidgetLines(
947 - goal({ criteria: ["this is a very long criterion that should wrap nicely indeed"] }) as never,
1094 + goal({
1095 + criteria: [
1096 + "this is a very long criterion that should wrap nicely indeed",
1097 + ],
1098 + }) as never,
948 1099 "normal",
1008 1159 describe("criteriaText", () => {
1009 1160 it("lists criteria numbered", () => {
1010 - expect(__goalTest.criteriaText(goal() as never)).toBe("1. tests pass\n2. docs updated");
1161 + expect(__goalTest.criteriaText(goal() as never)).toBe(
1162 + "1. tests pass\n2. docs updated",
1163 + );
1012 1165 it("returns placeholder when empty", () => {
1013 - expect(__goalTest.criteriaText(goal({ criteria: [] }) as never)).toBe("No goal criteria.");
1166 + expect(__goalTest.criteriaText(goal({ criteria: [] }) as never)).toBe(
1167 + "No goal criteria.",
1168 + );
1017 1172 describe("loadSettings edge cases", () => {
1018 1173 it("returns defaults when settings missing", () => {
1019 1174 expect(
1020 - __goalTest.loadSettings({ settingsManager: { getSettings: () => ({}) } } as never),
1175 + __goalTest.loadSettings({
1176 + settingsManager: { getSettings: () => ({}) },
1177 + } as never),
1021 1178 ).toEqual({ maxTurns: 20, judgeModel: undefined, tailBytes: 4096 });
1023 1180 it("returns defaults when goal settings missing", () => {
1024 1181 expect(
1025 - __goalTest.loadSettings({ settingsManager: { getSettings: () => ({ other: true }) } } as never),
1182 + __goalTest.loadSettings({
1183 + settingsManager: { getSettings: () => ({ other: true }) },
1184 + } as never),
1026 1185 ).toEqual({ maxTurns: 20, judgeModel: undefined, tailBytes: 4096 });
1028 1187 it("ignores non-string judgeModel", () => {
1029 1188 expect(
1030 1189 __goalTest.loadSettings({
1031 - settingsManager: { getSettings: () => ({ goal: { judgeModel: 123 } }) },
1190 + settingsManager: {
1191 + getSettings: () => ({ goal: { judgeModel: 123 } }),
1192 + },
1032 1193 } as never).judgeModel,
1033 1194 ).toBeUndefined();
1041 1202 it("returns subcommands for matching prefix", () => {
1042 1203 const items = __goalTest.goalArgumentCompletions("st", undefined);
1043 1204 expect(items).not.toBeNull();
1044 - expect(items!.length).toBeGreaterThanOrEqual(1);
1205 + expect(items?.length).toBeGreaterThanOrEqual(1);
1046 1207 it("returns null for remove without goal", () => {
1047 - expect(__goalTest.goalArgumentCompletions("remove ", undefined)).toBeNull();
1208 + expect(
1209 + __goalTest.goalArgumentCompletions("remove ", undefined),
1210 + ).toBeNull();
1059 1222 it("mergeTurnEvidence handles empty prior", () => {
1060 1223 const ev = __goalTest.buildTurnEvidence({
1061 - message: { content: [{ type: "text", text: "hi" }], usage: { input: 1, output: 1 } },
1224 + message: {
1225 + content: [{ type: "text", text: "hi" }],
1226 + usage: { input: 1, output: 1 },
1227 + },
1062 1228 } as never);
1063 - expect(__goalTest.mergeTurnEvidence(undefined as never, ev).assistantText).toBe("hi");
1229 + expect(
1230 + __goalTest.mergeTurnEvidence(undefined as never, ev).assistantText,
1231 + ).toBe("hi");
1067 1235 describe("footerPhaseText / goalPhaseText / judgeStatusText", () => {
1068 1236 it("footerPhaseText blocked omits turns", () => {
1069 - expect(__goalTest.footerPhaseText(goal({ status: "blocked" }) as never, "normal")).toBe("goal blocked");
1237 + expect(
1238 + __goalTest.footerPhaseText(
1239 + goal({ status: "blocked" }) as never,
1240 + "normal",
1241 + ),
1242 + ).toBe("goal blocked");
1071 1244 it("goalPhaseText blocked returns status only", () => {
1072 - expect(__goalTest.goalPhaseText(goal({ status: "blocked" }) as never, "normal")).toBe("blocked");
1245 + expect(
1246 + __goalTest.goalPhaseText(
1247 + goal({ status: "blocked" }) as never,
1248 + "normal",
1249 + ),
1250 + ).toBe("blocked");
1074 1252 it("judgeStatusText no criteria omits suffix", () => {
1075 - expect(__goalTest.judgeStatusText(goal({ criteria: [] }) as never)).toBe("goal judging 3/5");
1253 + expect(__goalTest.judgeStatusText(goal({ criteria: [] }) as never)).toBe(
1254 + "goal judging 3/5",
1255 + );
1091 1271 expect((entries[0] as any).status).toBe("paused");
1093 1273 it("returns undefined when no state", () => {
1094 - expect(__goalTest.cancelGoalRun({} as never, {} as never, undefined)).toBeUndefined();
1274 + expect(
1275 + __goalTest.cancelGoalRun({} as never, {} as never, undefined),
1276 + ).toBeUndefined();
1130 1312 describe("parseJudge reason truncation", () => {
1131 1313 it("truncates long reasons to 160 chars", () => {
1132 1314 const longReason = "a".repeat(200);
1133 - const verdict = __goalTest.parseJudge(`{"done":true,"blocked":false,"reason":"${longReason}"}`);
1315 + const verdict = __goalTest.parseJudge(
1316 + `{"done":true,"blocked":false,"reason":"${longReason}"}`,
1317 + );
1134 1318 expect(verdict.reason).toHaveLength(160);
1135 1319 expect(verdict.reason.endsWith("…")).toBe(true);
1137 1321 it("keeps short reasons intact", () => {
1138 - const verdict = __goalTest.parseJudge('{"done":true,"blocked":false,"reason":"all tests pass"}');
1322 + const verdict = __goalTest.parseJudge(
1323 + '{"done":true,"blocked":false,"reason":"all tests pass"}',
1324 + );
1139 1325 expect(verdict.reason).toBe("all tests pass");
1143 1329 describe("usageTokenDelta", () => {
1144 1330 it("returns delta from usage record", () => {
1145 - expect(__goalTest.usageTokenDelta({ input: 10, output: 5, cacheRead: 2 })).toBe(13);
1331 + expect(
1332 + __goalTest.usageTokenDelta({ input: 10, output: 5, cacheRead: 2 }),
1333 + ).toBe(13);
1146 1334 expect(__goalTest.usageTokenDelta({ input: 100, output: 50 })).toBe(150);
1148 1336 it("returns undefined for non-record", () => {
1150 1338 expect(__goalTest.usageTokenDelta(null)).toBeUndefined();
1152 1340 it("returns undefined for non-finite values", () => {
1153 - expect(__goalTest.usageTokenDelta({ input: NaN, output: 1 })).toBeUndefined();
1341 + expect(
1342 + __goalTest.usageTokenDelta({ input: NaN, output: 1 }),
1343 + ).toBeUndefined();
1155 1345 it("handles zero cacheRead", () => {
1156 - expect(__goalTest.usageTokenDelta({ input: 10, output: 5, cacheRead: 0 })).toBe(15);
1346 + expect(
1347 + __goalTest.usageTokenDelta({ input: 10, output: 5, cacheRead: 0 }),
1348 + ).toBe(15);
1165 1357 expect(__goalTest.canUseUpdateGoal(undefined)).toBe(false);
1167 1359 it("returns false for non-active status", () => {
1168 - expect(__goalTest.canUseUpdateGoal(goal({ status: "paused" }) as never)).toBe(false);
1360 + expect(
1361 + __goalTest.canUseUpdateGoal(goal({ status: "paused" }) as never),
1362 + ).toBe(false);
1170 1364 it("returns false for zero turns used", () => {
1171 - expect(__goalTest.canUseUpdateGoal(goal({ turnsUsed: 0 }) as never)).toBe(false);
1365 + expect(__goalTest.canUseUpdateGoal(goal({ turnsUsed: 0 }) as never)).toBe(
1366 + false,
1367 + );
1177 1373 expect(__goalTest.parseLooseBoolean(1)).toBe(true);
1178 1374 expect(__goalTest.parseLooseBoolean(0)).toBe(false);
1180 - it("accepts string \"1\"", () => {
1376 + it('accepts string "1"', () => {
1181 1377 expect(__goalTest.parseLooseBoolean("1")).toBe(true);
1183 1379 it("rejects other numbers", () => {

extensions/goal/index.ts

Modified
562 562 state.sessionId && currentSessionId && state.sessionId !== currentSessionId
563 563 ? " · other session"
565 - const criteriaText = state.criteria.length === 0
566 - ? ""
567 - : `\ncriteria:\n${state.criteria.map((c, i) => ` ${i + 1}. ${c}`).join("\n")}`;
565 + const criteriaText =
566 + state.criteria.length === 0
567 + ? ""
568 + : `\ncriteria:\n${state.criteria.map((c, i) => ` ${i + 1}. ${c}`).join("\n")}`;
568 569 const reason = state.lastReason
569 570 ? `\n${verdictGlyph(state.lastVerdict)} ${state.lastReason}`
708 709 for (let i = 0; i < state.criteria.length; i++)
709 - lines.push(...goalWidgetRow("criteria", sanitizeGoalText(`${i + 1}. ${state.criteria[i]}`, maxVal), innerWidth));
710 + lines.push(
711 + ...goalWidgetRow(
712 + "criteria",
713 + sanitizeGoalText(`${i + 1}. ${state.criteria[i]}`, maxVal),
714 + innerWidth,
715 + ),
716 + );
710 717 if (mode === "judging") {
711 718 lines.push(
712 719 ...goalWidgetRow(
771 778 const s = liveGoalState!;
772 779 const m = liveGoalMode;
773 780 const tone = goalTone(s, m);
774 - const lines = goalWidgetLines(
775 - s,
776 - m,
777 - width,
778 - );
781 + const lines = goalWidgetLines(s, m, width);
779 782 return lines.map((rawLine) => theme.fg(tone, rawLine));
802 805 ctx.ui.setStatus(STATUS_KEY, undefined);
803 806 const shown = widgetState(state);
804 - if (!shown) return clearFooter(pi);
807 + if (!shown) {
808 + clearFooter(pi);
809 + return;
805 811 const phase = footerPhaseText(shown, mode);
806 812 const criteria =
807 813 shown.criteria.length === 0 ? "" : ` · ${shown.criteria.length}c`;
1465 1471 timeBudgetSeconds: settings.timeBudgetSeconds,
1466 1472 timeUsedSeconds: 0,
1467 1473 errorRetries: 0,
1468 - sessionId: currentSessionId(ctx),
1469 - createdAt: now,
1474 + sessionId: currentSessionId(ctx),
1475 + createdAt: now,
1470 1476 updatedAt: now,
1472 1478 appendGoal(pi, state);
1554 1560 evidence?.stopReason === "aborted" ||
1555 1561 evidence?.stopReason === "error"
1557 - const errorMessage = evidence.errorMessage || `assistant ${evidence.stopReason}`;
1563 + const errorMessage =
1564 + evidence.errorMessage || `assistant ${evidence.stopReason}`;
1558 1565 const retries = (state.errorRetries ?? 0) + 1;
1559 1566 if (isRetryableError(errorMessage) && retries <= MAX_ERROR_RETRIES) {
1560 1567 state = updateGoal(pi, state, {
1562 1569 lastVerdict: "error",
1563 1570 lastReason: `retry ${retries}/${MAX_ERROR_RETRIES}: ${errorMessage}`,
1565 - appendGoalEvent(pi, "error-retry", state, { reason: errorMessage, retries });
1572 + appendGoalEvent(pi, "error-retry", state, {
1573 + reason: errorMessage,
1574 + retries,
1575 + });
1566 1576 updateUI(pi, ctx, state);
1567 1577 syncUpdateGoalTool();
1568 1578 if (ctx.hasUI)
1569 - ctx.ui.notify(`Goal retry ${retries}/${MAX_ERROR_RETRIES} — ${errorMessage}`, "warning");
1570 - setTimeout(() => scheduleContinuation(pi, ctx, state, continuation), Math.min(30000, 2000 * retries));
1579 + ctx.ui.notify(
1580 + `Goal retry ${retries}/${MAX_ERROR_RETRIES} — ${errorMessage}`,
1581 + "warning",
1582 + );
1583 + setTimeout(
1584 + () => scheduleContinuation(pi, ctx, state, continuation),
1585 + Math.min(30000, 2000 * retries),
1586 + );
1571 1587 return;
1573 1589 state = updateGoal(pi, state, {

extensions/goal/package.json

Modified
2 - "name": "@bugabinga/pi-ext-goal",
3 - "private": true,
4 - "type": "module",
5 - "main": "index.ts",
6 - "peerDependencies": {
7 - "@earendil-works/pi-ai": "*",
8 - "@earendil-works/pi-coding-agent": "*",
9 - "@earendil-works/pi-tui": "*",
10 - "typebox": "*"
11 - },
12 - "devDependencies": {
13 - "@marcfargas/pi-test-harness": "^0.6.1"
14 - },
15 - "scripts": {
16 - "bench": "node bench/goal-state.bench.ts"
17 - },
18 - "license": "MIT",
19 - "description": "Persistent /goal loop for Pi.",
20 - "keywords": [
21 - "pi",
22 - "pi-extension",
23 - "goal"
24 - ]
2 + "name": "@bugabinga/pi-ext-goal",
3 + "private": true,
4 + "type": "module",
5 + "main": "index.ts",
6 + "peerDependencies": {
7 + "@earendil-works/pi-ai": "*",
8 + "@earendil-works/pi-coding-agent": "*",
9 + "@earendil-works/pi-tui": "*",
10 + "typebox": "*"
11 + },
12 + "devDependencies": {
13 + "@marcfargas/pi-test-harness": "^0.6.1"
14 + },
15 + "scripts": {
16 + "bench": "node bench/goal-state.bench.ts"
17 + },
18 + "license": "MIT",
19 + "description": "Persistent /goal loop for Pi.",
20 + "keywords": [
21 + "pi",
22 + "pi-extension",
23 + "goal"
24 + ]

extensions/leaks/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import { mkdirSync, writeFileSync } from "node:fs";
3 2 import os from "node:os";
4 3 import path from "node:path";
8 7 type TestSession,
9 8 when,
10 9 } from "@marcfargas/pi-test-harness";
10 +import { afterEach, describe, expect, it } from "vitest";
12 12 function extPath() {
13 13 return path.resolve(import.meta.dir, "../index.ts");

extensions/leaks/__tests__/real/minimax.test.ts

Modified
1 -import { describe, expect, it } from "vitest";
2 1 import fs from "node:fs";
3 2 import os from "node:os";
4 3 import path from "node:path";
11 10 SessionManager,
12 11 SettingsManager,
13 12 } from "@earendil-works/pi-coding-agent";
13 +import { describe, expect, it } from "vitest";
15 15 const real = process.env.LEAKS_REAL === "1";
16 16 const d = real ? describe : describe.skip;

extensions/leaks/__tests__/unit.test.ts

Modified
1 -import { describe, expect, it } from "vitest";
2 1 import fs, { mkdtempSync, writeFileSync } from "node:fs";
3 2 import { tmpdir } from "node:os";
4 3 import path from "node:path";
4 +import { describe, expect, it } from "vitest";
5 5 import { __test } from "../index.ts";
7 7 describe("leaks engine", () => {

extensions/leaks/package.json

Modified
2 - "name": "@bugabinga/pi-ext-leaks",
3 - "description": "Provider-bound secret redaction for Pi.",
4 - "type": "module",
5 - "main": "index.ts",
6 - "scripts": {
7 - "test:real": "LEAKS_REAL=1 vitest run ./__tests__/real/*.test.ts --timeout 120000"
8 - },
9 - "keywords": [
10 - "pi",
11 - "extension",
12 - "secrets",
13 - "redaction",
14 - "pi-extension"
15 - ],
16 - "license": "MIT",
17 - "peerDependencies": {
18 - "@earendil-works/pi-ai": "*",
19 - "@earendil-works/pi-coding-agent": "*"
20 - },
21 - "devDependencies": {
22 - "@marcfargas/pi-test-harness": "^0.6.1"
23 - },
24 - "private": true
2 + "name": "@bugabinga/pi-ext-leaks",
3 + "description": "Provider-bound secret redaction for Pi.",
4 + "type": "module",
5 + "main": "index.ts",
6 + "scripts": {
7 + "test:real": "LEAKS_REAL=1 vitest run ./__tests__/real/*.test.ts --timeout 120000"
8 + },
9 + "keywords": [
10 + "pi",
11 + "extension",
12 + "secrets",
13 + "redaction",
14 + "pi-extension"
15 + ],
16 + "license": "MIT",
17 + "peerDependencies": {
18 + "@earendil-works/pi-ai": "*",
19 + "@earendil-works/pi-coding-agent": "*"
20 + },
21 + "devDependencies": {
22 + "@marcfargas/pi-test-harness": "^0.6.1"
23 + },
24 + "private": true

extensions/llmiterate/__tests__/__snapshots__/core.test.ts.snap

Modified
1 -// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
1 +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
3 +exports[`llmiterate output snapshots > agent prompt snapshot 1`] = `
4 +"llmiterate request from @a.rs:1
6 +Prompt marker contents:
7 +\`\`\`text
8 +implement foo
9 +\`\`\`
11 +Instructions:
12 +- Work in/around @a.rs.
13 +- Marker span to replace: a.rs:1-1.
14 +- Treat the marker comment line(s) as an inline prompt/TODO, not program code.
15 +- Replace the whole marker span with the requested implementation or code change.
16 +- Do not leave the marker line(s) behind unless impossible; explain if impossible."
17 +`;
3 19 exports[`llmiterate output snapshots agent prompt snapshot 1`] = `
4 20 "llmiterate request from @a.rs:1

extensions/llmiterate/__tests__/__snapshots__/ui.test.ts.snap

Modified
1 -// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
1 +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
3 3 exports[`llmiterate UI widget empty snapshot 1`] = `
4 4 "╭ llmiterate ──────────────────────────────────────────────╮
5 -│no prompts queued yet; /llmiterate log opens latest trans\x1B[0m…\x1B[0m│
5 +│no prompts queued yet; /llmiterate log opens latest trans…│
6 6 ╰──────────────────────────────────────────────────────────╯"

extensions/llmiterate/__tests__/core.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3 2 import { tmpdir } from "node:os";
4 3 import { join } from "node:path";
4 +import { afterEach, describe, expect, test } from "vitest";
5 5 import {
6 6 buildAgentPrompt,
7 7 COMMENT_PREFIXES_BY_EXTENSION,
155 155 test("normalizes CRLF and CR line endings", () => {
156 156 expect(
157 - parseMarkerPrompts("a.ts", "// llmiterate: one\r\n// llmiterate: two")[0]!
158 - .prompt,
157 + parseMarkerPrompts("a.ts", "// llmiterate: one\r\n// llmiterate: two")[0]
158 + ?.prompt,
159 159 ).toBe("one\ntwo");
160 160 expect(
161 - parseMarkerPrompts("a.ts", "// llmiterate: one\r// llmiterate: two")[0]!
162 - .prompt,
161 + parseMarkerPrompts("a.ts", "// llmiterate: one\r// llmiterate: two")[0]
162 + ?.prompt,
163 163 ).toBe("one\ntwo");
288 288 updatedAt: 1,
290 290 saveState(storeDir, state);
291 - expect(loadState(storeDir).markers.a!.status).toBe("failed");
291 + expect(loadState(storeDir).markers.a?.status).toBe("failed");
294 294 test("glob supports globstar, brace alternatives, and excludes", () => {

extensions/llmiterate/__tests__/extension.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import { mkdirSync, writeFileSync } from "node:fs";
3 2 import { join } from "node:path";
3 +import { afterEach, describe, expect, test } from "vitest";
4 4 import { loadState, projectStoreDir } from "../core";
5 5 import { createLlmiterateExtension } from "../index";
6 6 import {
99 99 await pi.command("llmiterate", "on");
100 100 await eventually(() => worker.finished === 1);
101 101 expect(
102 - Object.values(loadState(projectStoreDir(root)).markers)[0]!.status,
102 + Object.values(loadState(projectStoreDir(root)).markers)[0]?.status,
103 103 ).toBe("failed");
105 105 await pi.command("llmiterate", "scan");

extensions/llmiterate/__tests__/gitignore.bench.ts

Modified
60 60 function generatePaths(count: number): string[] {
61 61 const dirs = [
62 - "src", "src/components", "src/utils", "src/lib", "src/hooks",
63 - "tests", "tests/unit", "tests/integration",
64 - "docs", "scripts", "config", "public", "assets",
65 - "packages/core/src", "packages/ui/src", "packages/utils/src",
66 - "node_modules/lodash", "node_modules/react", "node_modules/typescript",
67 - "dist/esm", "dist/cjs", "dist/types",
68 - ".git", ".github", ".vscode", ".idea",
62 + "src",
63 + "src/components",
64 + "src/utils",
65 + "src/lib",
66 + "src/hooks",
67 + "tests",
68 + "tests/unit",
69 + "tests/integration",
70 + "docs",
71 + "scripts",
72 + "config",
73 + "public",
74 + "assets",
75 + "packages/core/src",
76 + "packages/ui/src",
77 + "packages/utils/src",
78 + "node_modules/lodash",
79 + "node_modules/react",
80 + "node_modules/typescript",
81 + "dist/esm",
82 + "dist/cjs",
83 + "dist/types",
84 + ".git",
85 + ".github",
86 + ".vscode",
87 + ".idea",
88 + ];
89 + const exts = [
90 + ".ts",
91 + ".js",
92 + ".tsx",
93 + ".jsx",
94 + ".json",
95 + ".md",
96 + ".css",
97 + ".html",
98 + ".log",
99 + ".tmp",
100 + ".swp",
101 + ".bak",
102 + ".map",
103 + ".min.js",
104 + ];
105 + const names = [
106 + "index",
107 + "main",
108 + "utils",
109 + "config",
110 + "types",
111 + "helpers",
112 + "constants",
113 + "hooks",
114 + "context",
115 + "provider",
116 + "App",
117 + "router",
118 + "store",
119 + "api",
120 + "client",
121 + "server",
70 - const exts = [".ts", ".js", ".tsx", ".jsx", ".json", ".md", ".css", ".html", ".log", ".tmp", ".swp", ".bak", ".map", ".min.js"];
71 - const names = ["index", "main", "utils", "config", "types", "helpers", "constants", "hooks", "context", "provider", "App", "router", "store", "api", "client", "server"];
72 123 const out: string[] = [];
73 124 for (let i = 0; i < count; i++) {
74 125 const dir = dirs[i % dirs.length];

extensions/llmiterate/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("llmiterate pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/llmiterate/__tests__/harness.ts

Modified
1 -import { expect } from "vitest";
2 1 import {
3 2 mkdirSync,
4 3 mkdtempSync,
8 7 } from "node:fs";
9 8 import { tmpdir } from "node:os";
10 9 import { join } from "node:path";
10 +import { expect } from "vitest";
11 11 import type { CompiledPathFilter, LlmiterateConfig } from "../core";
12 12 import { createLlmiterateExtension } from "../index";
13 13 import type { PiRpcWorker } from "../rpc";

extensions/llmiterate/__tests__/lock.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import {
3 2 existsSync,
4 3 mkdirSync,
8 7 } from "node:fs";
9 8 import { hostname, tmpdir } from "node:os";
10 9 import { join } from "node:path";
10 +import { afterEach, describe, expect, test } from "vitest";
11 11 import { acquireLock, type LockHandle, realPath, releaseLock } from "../lock";
13 13 const tempDirs: string[] = [];

extensions/llmiterate/__tests__/log.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import {
3 2 mkdirSync,
4 3 mkdtempSync,
9 8 } from "node:fs";
10 9 import { tmpdir } from "node:os";
11 10 import { join } from "node:path";
11 +import { afterEach, describe, expect, test } from "vitest";
12 12 import {
13 13 latestSessionFile,
14 14 parseEditorCommand,
83 83 expect(latestSessionFile(root)).toBe(newer);
84 84 const target = renderLatestSessionLog(root, join(root, "logs"));
85 85 expect(target?.sessionFile).toBe(newer);
86 - expect(readFileSync(target!.markdownFile, "utf-8")).toContain("new");
86 + expect(readFileSync(target?.markdownFile, "utf-8")).toContain("new");

extensions/llmiterate/__tests__/rpc.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3 2 import { tmpdir } from "node:os";
4 3 import { join } from "node:path";
4 +import { afterEach, describe, expect, test } from "vitest";
5 5 import { LLMITERATE_WORKER_ENV, PiRpcWorker, workerArgs } from "../rpc";
6 6 import type { RpcEvent } from "../types";
12 12 type FakeRpcMode = "ok" | "fail-new-session" | "malformed" | "env" | "hang";
14 14 afterEach(() => {
15 - while (workers.length) workers.pop()!.dispose();
15 + while (workers.length) workers.pop()?.dispose();
16 16 while (tempDirs.length)
17 17 rmSync(tempDirs.pop()!, { recursive: true, force: true });

extensions/llmiterate/__tests__/ui.test.ts

Modified
1 -import { describe, expect, test } from "vitest";
2 1 import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2 +import { describe, expect, test } from "vitest";
3 3 import { defaultConfig, normalizeConfig, parseMarkerPrompts } from "../core";
4 4 import type { LlmiterateRun } from "../types";
5 5 import { renderLlmiterateStatus } from "../ui";

extensions/llmiterate/__tests__/watcher.test.ts

Modified
1 -import { afterEach, describe, expect, test } from "vitest";
2 1 import {
3 2 mkdirSync,
4 3 mkdtempSync,
8 7 } from "node:fs";
9 8 import { tmpdir } from "node:os";
10 9 import { join } from "node:path";
10 +import { afterEach, describe, expect, test } from "vitest";
11 11 import { compilePathFilter, normalizeConfig } from "../core";
12 12 import { ProjectWatcher } from "../watcher";
15 15 const watchers: ProjectWatcher[] = [];
17 17 afterEach(() => {
18 - while (watchers.length) watchers.pop()!.stop();
18 + while (watchers.length) watchers.pop()?.stop();
19 19 while (tempDirs.length)
20 20 rmSync(tempDirs.pop()!, { recursive: true, force: true });

extensions/llmiterate/gitignore.ts

Modified
177 177 * Several fast paths avoid RegExp construction for common patterns:
178 178 * exact names, suffix (`*.ext`), prefix (`foo*`), and anchored literals.
180 -function compileTest(rawPattern: string, directoryOnly: boolean): TestFn | null {
180 +function compileTest(
181 + rawPattern: string,
182 + directoryOnly: boolean,
183 +): TestFn | null {
181 184 const { pattern, info } = analyzePattern(rawPattern);
182 185 const { anchored, isRelative } = info;
189 192 // Fast path: `*.ext` (no slash, no other specials).
190 - if (!anchored && !info.hasSlash && pattern.startsWith("*.") && !hasSpecialChars(pattern.slice(2))) {
193 + if (
194 + !anchored &&
195 + !info.hasSlash &&
196 + pattern.startsWith("*.") &&
197 + !hasSpecialChars(pattern.slice(2))
198 + ) {
191 199 const suffix = pattern.slice(1); // includes the dot
192 200 return (p) => basenameOf(p).endsWith(suffix);
195 203 // Fast path: `foo*` (no slash, trailing star only).
196 - if (!anchored && !info.hasSlash && pattern.endsWith("*") && pattern.indexOf("*") === pattern.length - 1 && !hasSpecialChars(pattern.slice(0, -1))) {
204 + if (
205 + !anchored &&
206 + !info.hasSlash &&
207 + pattern.endsWith("*") &&
208 + pattern.indexOf("*") === pattern.length - 1 &&
209 + !hasSpecialChars(pattern.slice(0, -1))
210 + ) {
197 211 const prefix = pattern.slice(0, -1);
198 212 return (p) => basenameOf(p).startsWith(prefix);
233 247 /* ── RegExp builder ──────────────────────────────────────── */
235 -function buildRegex(pattern: string, anchored: boolean, isRelative: boolean): RegExp | null {
249 +function buildRegex(
250 + pattern: string,
251 + anchored: boolean,
252 + isRelative: boolean,
253 +): RegExp | null {
236 254 let src = "";
237 255 let i = 0;
238 256 while (i < pattern.length) {
297 315 let body: string;
298 316 if (anchored || isRelative) {
299 - body = `^${src}(?=$|\/)`;
317 + body = `^${src}(?=$|/)`;
300 318 } else if (pattern.includes("/")) {
301 - body = `^(?:.*\/)?${src}(?=$|\/)`;
319 + body = `^(?:.*/)?${src}(?=$|/)`;
302 320 } else {
303 - body = `^(?:[^/]*\/)??${src}(?=$|\/)`;
321 + body = `^(?:[^/]*/)??${src}(?=$|/)`;
306 324 return new RegExp(body);

extensions/llmiterate/package.json

Modified
2 - "name": "@bugabinga/pi-ext-llmiterate",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "dependencies": {},
7 - "peerDependencies": {
8 - "@earendil-works/pi-coding-agent": "*",
9 - "@earendil-works/pi-tui": "*"
10 - },
11 - "license": "MIT",
12 - "description": "LLM iteration watcher for Pi.",
13 - "keywords": [
14 - "pi",
15 - "pi-extension"
16 - ],
17 - "devDependencies": {
18 - "@marcfargas/pi-test-harness": "^0.6.1"
19 - },
20 - "private": true
2 + "name": "@bugabinga/pi-ext-llmiterate",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "dependencies": {},
7 + "peerDependencies": {
8 + "@earendil-works/pi-coding-agent": "*",
9 + "@earendil-works/pi-tui": "*"
10 + },
11 + "license": "MIT",
12 + "description": "LLM iteration watcher for Pi.",
13 + "keywords": [
14 + "pi",
15 + "pi-extension"
16 + ],
17 + "devDependencies": {
18 + "@marcfargas/pi-test-harness": "^0.6.1"
19 + },
20 + "private": true

extensions/llmiterate/rpc.ts

Modified
162 162 return new Promise((resolve, reject) => {
163 163 this.pending.set(id, { command: payload.type, resolve, reject });
164 - this.proc!.stdin.write(line, (error) => {
164 + this.proc?.stdin.write(line, (error) => {
165 165 if (!error) return;
166 166 this.pending.delete(id);
167 167 reject(error);

extensions/model-info/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
7 7 import { __test } from "../index.ts";
9 9 describe("model-info pi-test-harness", () => {

extensions/model-info/package.json

Modified
2 - "name": "@bugabinga/pi-ext-model-info",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Model and thinking telemetry for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-model-info",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Model and thinking telemetry for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/neko/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("neko pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/neko/__tests__/lifecycle.test.ts

Modified
1 +import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2 +import { tmpdir } from "node:os";
3 +import { join } from "node:path";
1 4 import {
2 5 afterAll,
3 6 afterEach,
7 10 expect,
9 12 } from "vitest";
10 -import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
11 -import { tmpdir } from "node:os";
12 -import { join } from "node:path";
14 14 type Handler = (event: any, ctx: any) => unknown | Promise<unknown>;
15 15 type Timer = {
19 19 kind: "timeout" | "interval";
22 -type Harness = ReturnType<typeof createHarness>;
24 22 let agentDir = "";
25 23 let projectDir = "";
26 24 let nekoExtension: (pi: any) => void;
215 213 expect(stripAnsi(editor.render(40)[0])).toContain("[");
217 215 await h.emit("session_compact");
218 - expect(compactionTimer!.cleared).toBe(true);
216 + expect(compactionTimer?.cleared).toBe(true);
219 217 expect(stripAnsi(editor.render(40)[0])).toContain("(=^");
250 248 expect(compactionTimers).toHaveLength(2);
251 249 expect(first.cleared).toBe(true);
252 - expect(compactionTimers[1]!.cleared).toBe(false);
250 + expect(compactionTimers[1]?.cleared).toBe(false);
255 253 it("shutdown restores upstream UI and clears editor, error, compaction timers", async () => {

extensions/neko/package.json

Modified
2 - "name": "@bugabinga/pi-ext-neko",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "peerDependencies": {
7 - "@earendil-works/pi-coding-agent": "*",
8 - "@earendil-works/pi-tui": "*"
9 - },
10 - "license": "MIT",
11 - "description": "Tiny animated editor cat for Pi.",
12 - "keywords": [
13 - "pi",
14 - "pi-extension"
15 - ],
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "private": true
2 + "name": "@bugabinga/pi-ext-neko",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "peerDependencies": {
7 + "@earendil-works/pi-coding-agent": "*",
8 + "@earendil-works/pi-tui": "*"
9 + },
10 + "license": "MIT",
11 + "description": "Tiny animated editor cat for Pi.",
12 + "keywords": [
13 + "pi",
14 + "pi-extension"
15 + ],
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "private": true

extensions/nu-bang/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("nu-bang pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/nu-bang/__tests__/nu-bang.test.ts

Modified
1 -import { describe, expect, test } from "vitest";
2 1 import { join } from "node:path";
2 +import { describe, expect, test } from "vitest";
3 3 import {
4 4 completionPrefix,
5 5 cursorOffset,

extensions/nu-bang/__tests__/real-world.test.ts

Modified
1 -import { afterEach, beforeEach, describe, expect, test } from "vitest";
2 1 import { readdirSync } from "node:fs";
3 2 import {
4 3 chmod,
11 10 } from "node:fs/promises";
12 11 import { tmpdir } from "node:os";
13 12 import { join } from "node:path";
13 +import { afterEach, beforeEach, describe, expect, test } from "vitest";
14 14 import {
15 15 createNuBashOperations,
16 16 executeNu,

extensions/nu-bang/package.json

Modified
2 - "name": "@bugabinga/pi-ext-nu-bang",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "peerDependencies": {
7 - "@earendil-works/pi-coding-agent": "*",
8 - "@earendil-works/pi-tui": "*"
9 - },
10 - "license": "MIT",
11 - "description": "Nushell bang-command bridge for Pi.",
12 - "keywords": [
13 - "pi",
14 - "pi-extension"
15 - ],
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "private": true
2 + "name": "@bugabinga/pi-ext-nu-bang",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "peerDependencies": {
7 + "@earendil-works/pi-coding-agent": "*",
8 + "@earendil-works/pi-tui": "*"
9 + },
10 + "license": "MIT",
11 + "description": "Nushell bang-command bridge for Pi.",
12 + "keywords": [
13 + "pi",
14 + "pi-extension"
15 + ],
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "private": true

extensions/prompt-autopsy/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("prompt-autopsy pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/prompt-autopsy/package.json

Modified
2 - "name": "@bugabinga/pi-ext-prompt-autopsy",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-tui": "*"
8 - },
9 - "license": "MIT",
10 - "description": "System-prompt autopsy command for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-prompt-autopsy",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-tui": "*"
8 + },
9 + "license": "MIT",
10 + "description": "System-prompt autopsy command for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/pulse/__tests__/core.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import * as fs from "node:fs";
3 2 import * as os from "node:os";
4 3 import * as path from "node:path";
4 +import { afterEach, describe, expect, it } from "vitest";
5 5 import {
6 6 assertSafeGlob,
7 7 createDirDoc,

extensions/pulse/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3 2 import path from "node:path";
4 3 import {
5 4 createTestSession,
6 5 type TestSession,
7 6 } from "@marcfargas/pi-test-harness";
7 +import { afterEach, describe, expect, it } from "vitest";
9 9 let t: TestSession | undefined;
25 25 function ctx(): any {
26 - return t!.session.extensionRunner.createCommandContext();
26 + return t?.session.extensionRunner.createCommandContext();
29 29 function configPath(): string {
30 - return path.join(t!.cwd, ".pi/pulse.json");
30 + return path.join(t?.cwd, ".pi/pulse.json");
33 33 function writeConfig(config: unknown): void {
38 38 function notifyText(): string[] {
39 - return t!.events.uiCallsFor("notify").map((c) => String(c.args[0]));
39 + return t?.events.uiCallsFor("notify").map((c) => String(c.args[0]));
42 42 function statusText(): string[] {
43 - return t!.events
43 + return t?.events
44 44 .uiCallsFor("setStatus")
45 45 .filter((c) => c.args[0] === "pulse")
46 46 .map((c) => String(c.args[1]));
214 214 expect(tick).toBeDefined();
216 216 now = 6 * 60 * 1000;
217 - tick!();
217 + tick?.();
218 218 await waitFor(
219 219 () => notifyText().some((m) => m.startsWith("Pulse: ")),
220 220 realSetInterval,

extensions/pulse/__tests__/index.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import * as fs from "node:fs";
3 2 import * as os from "node:os";
4 3 import * as path from "node:path";
4 +import { afterEach, describe, expect, it } from "vitest";
6 6 let completionText = '{"updates":[]}';
7 7 let completionTexts: string[] = [];

extensions/pulse/index.ts

Modified
260 260 typeof u.summary === "string"
261 261 ? stripUnsafeText(u.summary).slice(0, MAX_SUMMARY_CHARS)
262 262 : "updated";
263 - if (u.content !== allowed.get(u.path)!.content)
263 + if (u.content !== allowed.get(u.path)?.content)
264 264 out.push({ path: u.path, content: u.content, summary });
265 265 seen.add(u.path);
412 412 throw new Error(`changed while updating: ${update.path}`);
414 414 for (const update of updates) {
415 - fs.writeFileSync(byPath.get(update.path)!.absPath, update.content, "utf-8");
415 + fs.writeFileSync(byPath.get(update.path)?.absPath, update.content, "utf-8");
417 417 return updates;
778 778 for (const doc of docs) {
779 779 const modelKey = doc.model || defaultKey;
780 780 if (!groups.has(modelKey)) groups.set(modelKey, []);
781 - groups.get(modelKey)!.push(doc);
781 + groups.get(modelKey)?.push(doc);
784 784 return Array.from(groups.entries())
957 957 function removeDoc(target: string): { removed: boolean; path?: string } {
958 958 // Try index first
959 959 const index = parseInt(target, 10);
960 - if (!isNaN(index) && index >= 0 && index < state.config.documents.length) {
960 + if (
961 + !Number.isNaN(index) &&
962 + index >= 0 &&
963 + index < state.config.documents.length
964 + ) {
961 965 const doc = state.config.documents.splice(index, 1)[0];
962 966 saveConfig(state.cwd, state.config);
963 967 return { removed: true, path: doc.path };
1491 1495 setStatus(ctx);
1494 - pi.on("session_shutdown", async (_event, ctx) => {
1498 + pi.on("session_shutdown", async (_event, _ctx) => {
1495 1499 generation++;
1496 1500 stopConfigWatcher();
1497 1501 stopTimer();

extensions/pulse/package.json

Modified
2 - "name": "@bugabinga/pi-ext-pulse",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-ai": "*",
7 - "@earendil-works/pi-coding-agent": "*"
8 - },
9 - "license": "MIT",
10 - "description": "Living documentation sync for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "scripts": {},
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "private": true
2 + "name": "@bugabinga/pi-ext-pulse",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-ai": "*",
7 + "@earendil-works/pi-coding-agent": "*"
8 + },
9 + "license": "MIT",
10 + "description": "Living documentation sync for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "scripts": {},
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "private": true

extensions/q/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("q pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/q/package.json

Modified
2 - "name": "@bugabinga/pi-ext-q",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-ai": "*",
8 - "@earendil-works/pi-tui": "*"
9 - },
10 - "license": "MIT",
11 - "description": "Follow-up question fork helper for Pi.",
12 - "keywords": [
13 - "pi",
14 - "pi-extension"
15 - ],
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "scripts": {},
20 - "private": true
2 + "name": "@bugabinga/pi-ext-q",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-ai": "*",
8 + "@earendil-works/pi-tui": "*"
9 + },
10 + "license": "MIT",
11 + "description": "Follow-up question fork helper for Pi.",
12 + "keywords": [
13 + "pi",
14 + "pi-extension"
15 + ],
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "scripts": {},
20 + "private": true

extensions/q/wizard-ui.ts

Modified
100 100 private handleSelectionInput(data: string): void {
101 - if (matchesKey(data, Key.escape)) return this.done({ type: "cancel" });
102 - if (matchesKey(data, Key.up)) return this.move(-1);
103 - if (matchesKey(data, Key.down)) return this.move(1);
104 - if (matchesKey(data, Key.enter)) return this.choose();
101 + if (matchesKey(data, Key.escape)) {
102 + this.done({ type: "cancel" });
103 + return;
105 + if (matchesKey(data, Key.up)) {
106 + this.move(-1);
107 + return;
109 + if (matchesKey(data, Key.down)) {
110 + this.move(1);
111 + return;
113 + if (matchesKey(data, Key.enter)) {
114 + this.choose();
115 + return;
107 119 private move(delta: number): void {
112 124 private choose(): void {
113 125 const choice = this.choices()[this.selected];
114 126 if (!choice) return;
115 - if (choice.type === "answer") return this.accept(choice.value);
116 - if (choice.type === "fork")
117 - return this.done({ type: "fork", state: this.state });
127 + if (choice.type === "answer") {
128 + this.accept(choice.value);
129 + return;
131 + if (choice.type === "fork") {
132 + this.done({ type: "fork", state: this.state });
133 + return;
118 135 this.setMode("custom");

extensions/quota/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
7 7 import { __test } from "../index.ts";
9 9 describe("quota pi-test-harness", () => {

extensions/quota/package.json

Modified
2 - "name": "@bugabinga/pi-ext-quota",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Subscription quota dashboard for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-quota",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Subscription quota dashboard for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/runtime/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("runtime pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/runtime/package.json

Modified
2 - "name": "@bugabinga/pi-ext-runtime",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Runtime detection telemetry for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-runtime",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Runtime detection telemetry for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/session-rename/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("session-rename pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/session-rename/index.ts

Modified
145 145 for (const e of messageEntries.slice(-10)) {
146 - const role = e.message!.role;
146 + const role = e.message?.role;
147 147 if (role === "user") {
148 - const text = extractText(e.message!.content).trim();
148 + const text = extractText(e.message?.content).trim();
149 149 if (text) messageLines.push(`Recent user: ${text.slice(0, 900)}`);
150 150 } else if (role === "assistant") {
151 - const text = extractText(e.message!.content).trim();
151 + const text = extractText(e.message?.content).trim();
152 152 if (text) messageLines.push(`Recent assistant: ${text.slice(0, 900)}`);
153 - messageLines.push(...extractToolCalls(e.message!.content).slice(0, 8));
153 + messageLines.push(...extractToolCalls(e.message?.content).slice(0, 8));
154 154 } else if (role === "toolResult") {
155 - const text = extractText(e.message!.content).trim();
155 + const text = extractText(e.message?.content).trim();
156 156 if (text)
157 157 messageLines.push(
158 - `Result(${e.message!.toolName ?? "tool"}): ${text.slice(0, 300)}`,
158 + `Result(${e.message?.toolName ?? "tool"}): ${text.slice(0, 300)}`,
450 450 export default function (pi: ExtensionAPI) {
451 451 let idleTimer: ReturnType<typeof setTimeout> | undefined;
452 452 let activeController: AbortController | undefined;
453 - let currentCtx: ExtensionContext | undefined;
453 + let _currentCtx: ExtensionContext | undefined;
455 455 const clearTimer = () => {
456 456 if (idleTimer) {
546 546 pi.on("session_start", async (_event, ctx) => {
547 - currentCtx = ctx;
547 + _currentCtx = ctx;
548 548 scheduleRename(ctx, "load", LOAD_DELAY_MS);
551 551 pi.on("turn_end", async (_event, ctx) => {
552 - currentCtx = ctx;
552 + _currentCtx = ctx;
553 553 scheduleRename(ctx, "turn");
571 571 pi.on("session_shutdown", async (_event, ctx) => {
572 572 clearTimer();
573 573 cancelActive(ctx);
574 - currentCtx = undefined;
574 + _currentCtx = undefined;
577 577 pi.registerCommand("session-rename", {

extensions/session-rename/package.json

Modified
2 - "name": "@bugabinga/pi-ext-session-rename",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-ai": "*",
7 - "@earendil-works/pi-coding-agent": "*"
8 - },
9 - "license": "MIT",
10 - "description": "Automatic short session names for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-session-rename",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-ai": "*",
7 + "@earendil-works/pi-coding-agent": "*"
8 + },
9 + "license": "MIT",
10 + "description": "Automatic short session names for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/ssh-tools/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("ssh-tools pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/ssh-tools/index.test.ts

Modified
3 3 * Smoke tests for ssh-tools pure functions.
4 4 * Run: bun test extensions/ssh-tools/index.test.ts
6 -import { describe, expect, test } from "vitest";
6 +import { expect, test } from "vitest";
8 8 test("shellQuote escapes single quotes", () => {
9 9 function shellQuote(s: string) {

extensions/ssh-tools/index.ts

Modified
139 139 if (opts.signal.aborted) onAbort();
140 140 else opts.signal.addEventListener("abort", onAbort, { once: true });
142 - if (opts.stdin !== undefined) child.stdin!.write(opts.stdin);
143 - child.stdin!.end();
142 + if (opts.stdin !== undefined) child.stdin?.write(opts.stdin);
143 + child.stdin?.end();
249 249 // ── extension ───────────────────────────────────────────────────────────
250 250 let target: Target | null = null;
252 -const readBase = createReadToolDefinition("/");
253 -const writeBase = createWriteToolDefinition("/");
252 +const _readBase = createReadToolDefinition("/");
253 +const _writeBase = createWriteToolDefinition("/");
254 254 const editBase = createEditToolDefinition("/");
255 255 const bashBase = createBashToolDefinition("/");
301 301 : {}),
302 302 execute(id, params, signal, onUpdate) {
303 303 assertTarget();
304 - return mkDef(target!.cwd, { operations: ops(target!) }).execute(
304 + return mkDef(target?.cwd, { operations: ops(target!) }).execute(
306 306 params,
307 307 signal,
322 322 parameters: bashBase.parameters,
323 323 execute(id, params, signal, onUpdate) {
324 324 assertTarget();
325 - return createBashToolDefinition(target!.cwd, {
325 + return createBashToolDefinition(target?.cwd, {
326 326 operations: remoteBash(target!),
327 327 }).execute(id, params, signal, onUpdate);

extensions/ssh-tools/package.json

Modified
2 - "name": "@bugabinga/pi-ext-ssh-tools",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-tui": "*"
8 - },
9 - "license": "MIT",
10 - "description": "SSH mode and remote tools for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-ssh-tools",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-tui": "*"
8 + },
9 + "license": "MIT",
10 + "description": "SSH mode and remote tools for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/superpowers/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3 2 import path from "node:path";
4 3 import {
5 4 createTestSession,
6 5 type TestSession,
7 6 } from "@marcfargas/pi-test-harness";
7 +import { afterEach, describe, expect, it } from "vitest";
8 8 import { __test } from "../index.ts";
10 10 let t: TestSession | undefined;
18 18 t!.session.extensionRunner.extensions[0].commands.get("superpowers")!;
19 19 const ctx = () => t!.session.extensionRunner.createCommandContext();
20 20 const notices = () =>
21 - t!.events.uiCallsFor("notify").map((c) => String(c.args[0]));
22 -const tasksPath = () => __test.tasksFile(t!.cwd);
21 + t?.events.uiCallsFor("notify").map((c) => String(c.args[0]));
22 +const tasksPath = () => __test.tasksFile(t?.cwd);
23 23 const tasks = () => JSON.parse(readFileSync(tasksPath(), "utf8"));
24 24 const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
39 39 sessionManager: {
40 40 getSessionFile: () => sessionFile,
41 41 appendCustomEntry: (customType: string, data: unknown) => {
42 - const entry = { id: `e${++entrySeq}`, type: "custom", customType, data };
42 + const entry = {
43 + id: `e${++entrySeq}`,
44 + type: "custom",
45 + customType,
46 + data,
47 + };
43 48 entries.push(entry);
44 49 return entry.id;
81 86 await command().handler("open sp-404", ctx());
82 87 expect(notices()).toContain("superpowers on");
83 88 expect(notices()).toContain("superpowers off");
84 - expect(notices().some((m) => m.includes("superpowers off\nno tasks"))).toBe(true);
89 + expect(notices().some((m) => m.includes("superpowers off\nno tasks"))).toBe(
90 + true,
91 + );
85 92 expect(notices().some((m) => m.includes("/superpowers agent"))).toBe(true);
86 93 expect(notices()).toContain("usage: /superpowers agent <prompt>");
87 94 expect(notices().some((m) => m.includes("no tasks"))).toBe(true);
133 140 ["done", "error"].includes(tasks()["sp-1"]?.status),
135 142 expect(tasks()["sp-1"].agent).toBe("systematic-debugging");
136 - expect(tasks()["sp-1"].prompt).toContain("No fix before root-cause evidence");
143 + expect(tasks()["sp-1"].prompt).toContain(
144 + "No fix before root-cause evidence",
145 + );
137 146 expect(tasks()["sp-1"].prompt).toContain("flaky test");
280 289 process.env.PI_SUPERPOWERS_NO_OPEN = "1";
282 291 await command().handler("visual start", ctx());
283 - await waitFor(() => t!.events.messages.some((m: any) => m.customType === "superpowers"));
292 + await waitFor(() =>
293 + t?.events.messages.some((m: any) => m.customType === "superpowers"),
294 + );
284 295 const firstNotice = notices().at(-1)!;
285 296 expect(firstNotice).toContain("visual live: http://127.0.0.1:");
286 297 expect(firstNotice).toContain("content:");
287 298 expect(firstNotice).toContain("events file:");
288 299 expect(firstNotice).toContain("open manually: browser opener disabled");
289 - const firstMessage = t.events.messages.find((m: any) => m.customType === "superpowers") as any;
290 - expect(firstMessage.content).toContain("Superpowers visual brainstorming");
300 + const firstMessage = t.events.messages.find(
301 + (m: any) => m.customType === "superpowers",
302 + ) as any;
303 + expect(firstMessage.content).toContain(
304 + "Superpowers visual brainstorming",
305 + );
291 306 expect(firstMessage.content).toContain("visual live: http://127.0.0.1:");
292 307 expect(firstMessage.content).toContain("content:");
293 308 expect(firstMessage.content).toContain("events file:");
294 309 expect(firstMessage.content).toContain("Agent rules:");
295 - expect(firstMessage.content).toContain("Use visual only for active user decisions");
296 - expect(firstMessage.content).toContain("Do not use visual as progress reporting");
310 + expect(firstMessage.content).toContain(
311 + "Use visual only for active user decisions",
312 + );
313 + expect(firstMessage.content).toContain(
314 + "Do not use visual as progress reporting",
315 + );
297 316 expect(firstMessage.content).toContain("data-choice");
298 - expect(firstMessage.content).toContain("wait for terminal answer or browser event");
317 + expect(firstMessage.content).toContain(
318 + "wait for terminal answer or browser event",
319 + );
299 320 expect(firstMessage.content).toContain("Read the events file directly");
300 321 expect(firstMessage.content).toContain("Continuing in terminal");
301 322 expect(firstMessage.content).not.toContain("visual events");
305 326 const eventsFile = firstMessage.details.eventsFile;
307 328 await command().handler("visual start", ctx());
308 - await waitFor(() => t!.events.messages.filter((m: any) => m.customType === "superpowers").length >= 2);
329 + await waitFor(
330 + () =>
331 + t?.events.messages.filter((m: any) => m.customType === "superpowers")
332 + .length >= 2,
333 + );
309 334 expect(notices().at(-1)).toContain(`visual already live: ${url}`);
310 - const secondMessage = t.events.messages.filter((m: any) => m.customType === "superpowers").at(-1) as any;
335 + const secondMessage = t.events.messages
336 + .filter((m: any) => m.customType === "superpowers")
337 + .at(-1) as any;
311 338 expect(secondMessage.details.url).toBe(url);
312 339 expect(secondMessage.details.contentDir).toBe(contentDir);
313 340 expect(secondMessage.details.eventsFile).toBe(eventsFile);
331 358 process.env.PI_SUPERPOWERS_NO_OPEN = "1";
333 360 await command().handler("visual start", ctx());
334 - await waitFor(() => t!.events.messages.some((m: any) => m.customType === "superpowers"));
335 - const message = t.events.messages.find((m: any) => m.customType === "superpowers") as any;
361 + await waitFor(() =>
362 + t?.events.messages.some((m: any) => m.customType === "superpowers"),
363 + );
364 + const message = t.events.messages.find(
365 + (m: any) => m.customType === "superpowers",
366 + ) as any;
336 367 const url = message.details.url;
337 368 expect(await fetch(url).then((r) => r.status)).toBe(200);
338 - await t.session.extensionRunner.emit({ type: "session_shutdown", reason: "quit" });
369 + await t.session.extensionRunner.emit({
370 + type: "session_shutdown",
371 + reason: "quit",
372 + });
339 373 for (let i = 0; i < 40; i++) {
341 375 await fetch(url);
345 379 await sleep(25);
347 - expect.unreachable("visual server still accepted requests after shutdown");
381 + expect.unreachable(
382 + "visual server still accepted requests after shutdown",
383 + );
348 384 } finally {
349 385 if (prevNoOpen === undefined) delete process.env.PI_SUPERPOWERS_NO_OPEN;
350 386 else process.env.PI_SUPERPOWERS_NO_OPEN = prevNoOpen;
393 429 kind: "child",
394 430 task: { id: "sp-7", childSession },
396 - expect(child.messages.at(-1)?.content).toContain("Superpowers takeover: sp-7");
397 - expect(child.messages.at(-1)?.content).toContain("/superpowers return <summary>");
432 + expect(child.messages.at(-1)?.content).toContain(
433 + "Superpowers takeover: sp-7",
434 + );
435 + expect(child.messages.at(-1)?.content).toContain(
436 + "/superpowers return <summary>",
437 + );
399 439 await command().handler("return done", child.ctx);
400 440 expect(parent.entries.at(-1)?.data).toMatchObject({
403 443 summary: "done",
404 444 childSession,
406 - expect(parent.messages.at(-1)?.content).toContain("Superpowers return sp-7");
446 + expect(parent.messages.at(-1)?.content).toContain(
447 + "Superpowers return sp-7",
448 + );
407 449 expect(parent.messages.at(-1)?.content).toContain("done");
408 450 expect(parent.messages.at(-1)?.content).toContain(childSession);

extensions/superpowers/__tests__/helpers.test.ts

Modified
1 -import { describe, expect, it } from "vitest";
2 -import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
1 +import {
2 + existsSync,
3 + mkdtempSync,
4 + readdirSync,
5 + readFileSync,
6 + rmSync,
7 + writeFileSync,
8 +} from "node:fs";
3 9 import os from "node:os";
4 10 import path from "node:path";
11 +import { describe, expect, it } from "vitest";
5 12 import { __test } from "../index.ts";
6 13 import { startVisualServer } from "../visual";
10 17 expect(__test.platformStateDir("linux", {}, "/home/me")).toBe(
11 18 "/home/me/.local/state/pi",
13 - expect(__test.platformStateDir("linux", { XDG_STATE_HOME: "/state" }, "/home/me")).toBe("/state/pi");
20 + expect(
21 + __test.platformStateDir(
22 + "linux",
23 + { XDG_STATE_HOME: "/state" },
24 + "/home/me",
25 + ),
26 + ).toBe("/state/pi");
14 27 expect(__test.platformStateDir("darwin", {}, "/Users/me")).toBe(
15 28 "/Users/me/Library/Application Support/pi",
21 34 "C:\\Users\\me",
23 36 ).toBe("C:\\Users\\me\\AppData\\Local\\pi");
24 - expect(__test.dir("/tmp/project")).toContain(path.join("pi", "superpowers"));
37 + expect(__test.dir("/tmp/project")).toContain(
38 + path.join("pi", "superpowers"),
39 + );
27 42 it("ships workflow prompts and skills", () => {
59 74 "utf8",
61 76 expect(skill).toContain("Hard gate");
62 - expect(skill).toContain("Write spec to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`");
77 + expect(skill).toContain(
78 + "Write spec to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`",
79 + );
63 80 expect(skill).toContain("After approval, hand off only to `writing-plans`");
99 116 it("strict prompt protects brainstorming before planning", () => {
100 - const source = readFileSync(path.resolve(import.meta.dir, "../index.ts"), "utf8");
101 - expect(source).toContain("Use brainstorming first for vague goals, UX/UI work");
102 - expect(source).toContain("Do not use writing-plans unless an approved design/spec already exists");
117 + const source = readFileSync(
118 + path.resolve(import.meta.dir, "../index.ts"),
119 + "utf8",
120 + );
121 + expect(source).toContain(
122 + "Use brainstorming first for vague goals, UX/UI work",
123 + );
124 + expect(source).toContain(
125 + "Do not use writing-plans unless an approved design/spec already exists",
126 + );
105 129 it("skills retain vital upstream workflow gates", () => {
106 130 const skill = (name: string) =>
107 - readFileSync(path.resolve(import.meta.dir, `../skills/${name}/SKILL.md`), "utf8");
108 - expect(skill("test-driven-development")).toContain("No production code without a failing test first");
131 + readFileSync(
132 + path.resolve(import.meta.dir, `../skills/${name}/SKILL.md`),
133 + "utf8",
134 + );
135 + expect(skill("test-driven-development")).toContain(
136 + "No production code without a failing test first",
137 + );
109 138 expect(skill("systematic-debugging")).toContain("root-cause evidence");
110 - expect(skill("verification-before-completion")).toContain("Evidence before claims");
139 + expect(skill("verification-before-completion")).toContain(
140 + "Evidence before claims",
141 + );
111 142 expect(skill("writing-plans")).toContain("No `TODO`/`TBD`");
112 - expect(skill("receiving-code-review")).toContain("Verify each finding against the codebase");
113 - expect(skill("using-git-worktrees")).toContain("If already in a linked worktree");
143 + expect(skill("receiving-code-review")).toContain(
144 + "Verify each finding against the codebase",
145 + );
146 + expect(skill("using-git-worktrees")).toContain(
147 + "If already in a linked worktree",
148 + );
116 151 it("review workflow includes deslop and compression passes", () => {

extensions/superpowers/index.ts

Modified
1 +import { execSync } from "node:child_process";
1 2 import { createHash } from "node:crypto";
2 3 import {
4 + appendFileSync,
3 5 existsSync,
4 6 mkdirSync,
5 7 readdirSync,
6 8 readFileSync,
7 - writeFileSync,
8 - appendFileSync,
9 9 rmdirSync,
10 + writeFileSync,
10 11 } from "node:fs";
11 -import { execSync } from "node:child_process";
12 12 import os from "node:os";
13 13 import path from "node:path";
14 14 import { fileURLToPath } from "node:url";
19 19 type ExtensionAPI,
20 20 type ExtensionCommandContext,
21 21 type ExtensionContext,
22 - type ThemeColor,
23 22 getAgentDir,
24 23 SessionManager,
25 24 SettingsManager,
25 + type ThemeColor,
26 26 } from "@earendil-works/pi-coding-agent";
27 27 import { openBrowser, startVisualServer, type VisualSession } from "./visual";
145 145 const paths = platform === "win32" ? path.win32 : path.posix;
146 146 if (platform === "win32")
147 - return paths.join(env.LOCALAPPDATA ?? paths.join(home, "AppData", "Local"), "pi");
147 + return paths.join(
148 + env.LOCALAPPDATA ?? paths.join(home, "AppData", "Local"),
149 + "pi",
150 + );
148 151 if (env.XDG_STATE_HOME) return paths.join(env.XDG_STATE_HOME, "pi");
149 - if (platform === "darwin") return paths.join(home, "Library", "Application Support", "pi");
152 + if (platform === "darwin")
153 + return paths.join(home, "Library", "Application Support", "pi");
150 154 return paths.join(home, ".local", "state", "pi");
152 156 function hashProjectRoot(cwd: string) {
153 157 return createHash("sha256").update(path.resolve(cwd)).digest("hex");
155 -const dir = (cwd: string) => path.join(platformStateDir(), "superpowers", hashProjectRoot(cwd));
159 +const dir = (cwd: string) =>
160 + path.join(platformStateDir(), "superpowers", hashProjectRoot(cwd));
156 161 const tasksFile = (cwd: string) => path.join(dir(cwd), "tasks.json");
157 162 const sessionsDir = (cwd: string) => path.join(dir(cwd), "sessions");
158 -const ensure = (cwd: string) => mkdirSync(sessionsDir(cwd), { recursive: true });
163 +const ensure = (cwd: string) =>
164 + mkdirSync(sessionsDir(cwd), { recursive: true });
159 165 const text = (x: unknown): string =>
160 166 typeof x === "string"
243 249 const message = uiStatusText(ctx.cwd);
244 250 if (hasFooter() && api) {
245 251 (ctx.ui as any).setStatus?.(STATUS_ID, undefined);
246 - const runningTask = Object.values(readTasks(ctx.cwd)).find((t) => t.status === "running");
252 + const runningTask = Object.values(readTasks(ctx.cwd)).find(
253 + (t) => t.status === "running",
254 + );
247 255 const footerColor = runningTask
248 256 ? taskAccent(runningTask.agent, runningTask.accent)
249 - : (active ? "accent" : "muted") as ThemeColor;
257 + : ((active ? "accent" : "muted") as ThemeColor);
250 258 api.events.emit(
251 259 "footer:segment",
252 260 message
273 281 const AGENT_SHORT: Record<string, string> = {
274 282 "requesting-code-review": "review",
275 283 "receiving-code-review": "fix",
276 - "brainstorming": "design",
284 + brainstorming: "design",
277 285 "writing-plans": "plan",
278 286 "executing-plans": "exec",
279 287 "dispatching-parallel-agents": "parallel",
306 314 return ALIAS_ACCENT[AGENT_SHORT[agent] ?? agent] ?? "accent";
308 316 const THEMED_COLORS: Set<string> = new Set([
309 - "accent", "border", "borderAccent", "borderMuted", "success", "error",
310 - "warning", "muted", "dim", "text", "thinkingText", "userMessageText",
311 - "customMessageText", "customMessageLabel", "toolTitle", "toolOutput",
312 - "mdHeading", "mdLink", "mdLinkUrl", "mdCode", "mdCodeBlock",
313 - "mdCodeBlockBorder", "mdQuote", "mdQuoteBorder", "mdHr", "mdListBullet",
314 - "toolDiffAdded", "toolDiffRemoved", "toolDiffContext", "syntaxComment",
315 - "syntaxKeyword", "syntaxFunction", "syntaxVariable", "syntaxString",
316 - "syntaxNumber", "syntaxType", "syntaxOperator", "syntaxPunctuation",
317 - "thinkingOff", "thinkingMinimal", "thinkingLow", "thinkingMedium",
318 - "thinkingHigh", "thinkingXhigh", "bashMode",
317 + "accent",
318 + "border",
319 + "borderAccent",
320 + "borderMuted",
321 + "success",
322 + "error",
323 + "warning",
324 + "muted",
325 + "dim",
326 + "text",
327 + "thinkingText",
328 + "userMessageText",
329 + "customMessageText",
330 + "customMessageLabel",
331 + "toolTitle",
332 + "toolOutput",
333 + "mdHeading",
334 + "mdLink",
335 + "mdLinkUrl",
336 + "mdCode",
337 + "mdCodeBlock",
338 + "mdCodeBlockBorder",
339 + "mdQuote",
340 + "mdQuoteBorder",
341 + "mdHr",
342 + "mdListBullet",
343 + "toolDiffAdded",
344 + "toolDiffRemoved",
345 + "toolDiffContext",
346 + "syntaxComment",
347 + "syntaxKeyword",
348 + "syntaxFunction",
349 + "syntaxVariable",
350 + "syntaxString",
351 + "syntaxNumber",
352 + "syntaxType",
353 + "syntaxOperator",
354 + "syntaxPunctuation",
355 + "thinkingOff",
356 + "thinkingMinimal",
357 + "thinkingLow",
358 + "thinkingMedium",
359 + "thinkingHigh",
360 + "thinkingXhigh",
361 + "bashMode",
320 363 function elapsedLive(start: string) {
321 364 const a = Date.parse(start);
326 369 function compactTaskLine(t: Task) {
327 370 const icon = STATUS_ICONS[t.status] ?? "·";
328 371 const name = AGENT_SHORT[t.agent] ?? t.agent;
329 - const time = t.status === "running" ? elapsedLive(t.startedAt) : elapsed(t.startedAt, t.updatedAt);
372 + const time =
373 + t.status === "running"
374 + ? elapsedLive(t.startedAt)
375 + : elapsed(t.startedAt, t.updatedAt);
330 376 const tools = toolCount(t);
331 377 return `${icon} ${t.id} ${name} ${time}${tools ? ` · ${tools} tools` : ""}`;
346 392 function summaryLine(t: Task) {
347 393 const icon = STATUS_ICONS[t.status] ?? "·";
348 394 const name = AGENT_SHORT[t.agent] ?? t.agent;
349 - const time = t.status === "running" ? elapsedLive(t.startedAt) : elapsed(t.startedAt, t.updatedAt);
395 + const time =
396 + t.status === "running"
397 + ? elapsedLive(t.startedAt)
398 + : elapsed(t.startedAt, t.updatedAt);
350 399 const tools = toolCount(t);
351 400 const tail = firstLine(t.result ?? t.log.at(-1));
352 401 const parts = [`${icon} ${t.id}`, name, time];
357 406 function taskDetails(t: Task) {
358 407 const icon = STATUS_ICONS[t.status] ?? "·";
359 - const time = t.status === "running" ? elapsedLive(t.startedAt) : elapsed(t.startedAt, t.updatedAt);
408 + const time =
409 + t.status === "running"
410 + ? elapsedLive(t.startedAt)
411 + : elapsed(t.startedAt, t.updatedAt);
360 412 const tools = toolCount(t);
361 413 const name = AGENT_SHORT[t.agent] ?? t.agent;
362 414 const tail = firstLine(t.result ?? t.log.at(-1));
391 443 const th = ctx.ui.theme;
392 444 const lines = [
393 - th.fg("dim", `${running.length} worker${running.length > 1 ? "s" : ""} running`),
394 - ...running.map((t) => th.fg(taskAccent(t.agent, t.accent), compactTaskLine(t))),
445 + th.fg(
446 + "dim",
447 + `${running.length} worker${running.length > 1 ? "s" : ""} running`,
448 + ),
449 + ...running.map((t) =>
450 + th.fg(taskAccent(t.agent, t.accent), compactTaskLine(t)),
451 + ),
396 453 (ctx.ui as any).setWidget?.(WIDGET, lines);
397 454 } catch {
503 560 const [provider, ...id] = s?.split("/") ?? [];
504 561 if (provider && id.length) {
505 562 const m = getModel(provider, id.join("/"));
506 - if (m && m.provider && m.id) return m;
563 + if (m?.provider && m.id) return m;
508 565 return fallback ?? getModel("openai", "gpt-4o");
553 610 // ── Repo detection ──────────────────────────────────────────────────────────
555 -type GitLayout = { type: "git"; layout: "standard" | "bare"; gitDir: string; root: string };
612 +type GitLayout = {
613 + type: "git";
614 + layout: "standard" | "bare";
615 + gitDir: string;
616 + root: string;
557 619 type RepoType = "jj" | GitLayout;
560 622 // Prefer jj when colocated
561 623 if (existsSync(path.join(cwd, ".jj"))) return "jj";
563 - const commonDir = execSync("git rev-parse --path-format=absolute --git-common-dir", {
564 - cwd,
565 - encoding: "utf8",
566 - stdio: ["pipe", "pipe", "ignore"],
567 - }).trim();
625 + const commonDir = execSync(
626 + "git rev-parse --path-format=absolute --git-common-dir",
628 + cwd,
629 + encoding: "utf8",
630 + stdio: ["pipe", "pipe", "ignore"],
631 + },
632 + ).trim();
568 633 const isBare =
569 634 execSync("git config --bool core.bare", {
570 635 cwd: commonDir,
574 639 .trim()
575 640 .toLowerCase() === "true";
576 641 if (isBare) {
577 - return { type: "git", layout: "bare", gitDir: commonDir, root: path.dirname(commonDir) };
642 + return {
643 + type: "git",
644 + layout: "bare",
645 + gitDir: commonDir,
646 + root: path.dirname(commonDir),
647 + };
579 - return { type: "git", layout: "standard", gitDir: commonDir, root: path.dirname(commonDir) };
649 + return {
650 + type: "git",
651 + layout: "standard",
652 + gitDir: commonDir,
653 + root: path.dirname(commonDir),
654 + };
580 655 } catch {
581 656 return null;
600 675 const branch = `superpowers-${id}`;
601 676 if (repo.layout === "bare") {
602 677 const wtPath = path.join(repo.root, id);
603 - await pi.exec("git", ["-C", repo.gitDir, "worktree", "add", "-b", branch, wtPath, "HEAD"]);
604 - return { type: "git-bare", path: wtPath, branch, gitDir: repo.gitDir, root: repo.root };
678 + await pi.exec("git", [
679 + "-C",
680 + repo.gitDir,
681 + "worktree",
682 + "add",
683 + "-b",
684 + branch,
685 + wtPath,
686 + "HEAD",
687 + ]);
688 + return {
689 + type: "git-bare",
690 + path: wtPath,
691 + branch,
692 + gitDir: repo.gitDir,
693 + root: repo.root,
694 + };
606 696 // standard checkout
607 697 const wtPath = path.join(cwd, ".git", `wt-${id}`);
617 707 await pi.exec("jj", ["workspace", "forget", isolate.workspaceName!]);
618 708 rmdirSync(isolate.path, { recursive: true });
619 709 } else if (isolate.type === "git-bare") {
620 - await pi.exec("git", ["-C", isolate.gitDir!, "worktree", "remove", "--force", isolate.path]);
621 - await pi.exec("git", ["-C", isolate.gitDir!, "branch", "-D", isolate.branch!]);
710 + await pi.exec("git", [
711 + "-C",
712 + isolate.gitDir!,
713 + "worktree",
714 + "remove",
715 + "--force",
716 + isolate.path,
717 + ]);
718 + await pi.exec("git", [
719 + "-C",
720 + isolate.gitDir!,
721 + "branch",
722 + "-D",
723 + isolate.branch!,
724 + ]);
622 725 } else {
623 726 await pi.exec("git", ["worktree", "remove", "--force", isolate.path]);
624 727 await pi.exec("git", ["branch", "-D", isolate.branch!]);
711 814 const agentModel = modelFrom(requested, model);
712 815 if (requested) {
713 816 const [provider, ...id] = requested.split("/");
714 - const direct = provider && id.length ? getModel(provider, id.join("/")) : null;
715 - if (!direct || !direct.provider) {
716 - notify(ctx, `warn: model "${requested}" not found, using fallback`, "warning");
817 + const direct =
818 + provider && id.length ? getModel(provider, id.join("/")) : null;
819 + if (!direct?.provider) {
820 + notify(
821 + ctx,
822 + `warn: model "${requested}" not found, using fallback`,
823 + "warning",
824 + );
719 827 const created = await createAgentSession({
901 1009 const key = id.trim();
902 1010 if (key) {
903 1011 const t = tasks[key];
904 - notify(ctx, t ? taskDetails(t) : `no such task: ${key}`, t ? "info" : "error");
1012 + notify(
1013 + ctx,
1014 + t ? taskDetails(t) : `no such task: ${key}`,
1015 + t ? "info" : "error",
1016 + );
905 1017 widget(ctx);
906 1018 return;
943 1055 "- When done with visual decisions, write a waiting screen: Continuing in terminal…",
944 1056 "- Ask whether to leave the browser open for inspection or stop it.",
945 1057 ].join("\n");
946 - await Promise.resolve(pi.sendMessage(
948 - customType: ID,
949 - display: true,
950 - content: agentMsg,
951 - details: {
952 - url: session.url,
953 - contentDir: session.contentDir,
954 - eventsFile: session.eventsFile,
1058 + await Promise.resolve(
1059 + pi.sendMessage(
1061 + customType: ID,
1062 + display: true,
1063 + content: agentMsg,
1064 + details: {
1065 + url: session.url,
1066 + contentDir: session.contentDir,
1067 + eventsFile: session.eventsFile,
1068 + },
956 - },
957 - { triggerTurn: false },
958 - ));
1070 + { triggerTurn: false },
1071 + ),
1072 + );
961 -async function visualCommand(args: string, ctx: ExtensionCommandContext, pi: ExtensionAPI) {
1075 +async function visualCommand(
1076 + args: string,
1077 + ctx: ExtensionCommandContext,
1078 + pi: ExtensionAPI,
1079 +) {
962 1080 const [sub = "status"] = args.trim().split(/\s+/);
963 1081 if (sub === "start") {
964 1082 if (visual) {
965 - notify(ctx, `visual already live: ${visual.url}\ncontent: ${visual.contentDir}\nevents file: ${visual.eventsFile}`);
1083 + notify(
1084 + ctx,
1085 + `visual already live: ${visual.url}\ncontent: ${visual.contentDir}\nevents file: ${visual.eventsFile}`,
1086 + );
966 1087 await announceVisualSession(pi, visual);
967 1088 return;
973 1094 `visual live: ${visual.url}`,
974 1095 `content: ${visual.contentDir}`,
975 1096 `events file: ${visual.eventsFile}`,
976 - opened.ok ? `opened: ${opened.command}` : `open manually: ${opened.error}`,
1097 + opened.ok
1098 + ? `opened: ${opened.command}`
1099 + : `open manually: ${opened.error}`,
977 1100 ].join("\n");
978 1101 notify(ctx, msg, opened.ok ? "info" : "warning");
979 1102 await announceVisualSession(pi, visual);
990 1113 if (sub === "events") {
991 1114 if (!visual) return notify(ctx, "no visual session", "warning");
992 - const events = existsSync(visual.eventsFile) ? readFileSync(visual.eventsFile, "utf8") : "";
993 - if (ctx.hasUI) await ctx.ui.editor("superpowers visual events", events || "no events");
1115 + const events = existsSync(visual.eventsFile)
1116 + ? readFileSync(visual.eventsFile, "utf8")
1117 + : "";
1118 + if (ctx.hasUI)
1119 + await ctx.ui.editor("superpowers visual events", events || "no events");
994 1120 else notify(ctx, events || "no events");
995 1121 return;
997 - if (!visual) return notify(ctx, "no visual session. use /superpowers visual start", "warning");
998 - notify(ctx, `visual live: ${visual.url}\ncontent: ${visual.contentDir}\nevents file: ${visual.eventsFile}`);
1123 + if (!visual)
1124 + return notify(
1125 + ctx,
1126 + "no visual session. use /superpowers visual start",
1127 + "warning",
1128 + );
1129 + notify(
1130 + ctx,
1131 + `visual live: ${visual.url}\ncontent: ${visual.contentDir}\nevents file: ${visual.eventsFile}`,
1132 + );
1001 1135 function help(ctx: ExtensionCommandContext) {

extensions/superpowers/package.json

Modified
2 - "name": "@bugabinga/pi-ext-superpowers",
3 - "type": "module",
4 - "main": "index.ts",
5 - "pi": {
6 - "extensions": [
7 - "./index.ts"
8 - ],
9 - "prompts": [
10 - "./prompts"
11 - ],
12 - "skills": [
13 - "./skills"
14 - ]
15 - },
16 - "scripts": {},
17 - "peerDependencies": {
18 - "@earendil-works/pi-ai": "*",
19 - "@earendil-works/pi-coding-agent": "*"
20 - },
21 - "devDependencies": {
22 - "@marcfargas/pi-test-harness": "^0.6.1"
23 - },
24 - "license": "MIT",
25 - "description": "Background subagents and takeover sessions for Pi.",
26 - "keywords": [
27 - "pi",
28 - "pi-extension",
29 - "subagents"
30 - ],
31 - "private": true
2 + "name": "@bugabinga/pi-ext-superpowers",
3 + "type": "module",
4 + "main": "index.ts",
5 + "pi": {
6 + "extensions": [
7 + "./index.ts"
8 + ],
9 + "prompts": [
10 + "./prompts"
11 + ],
12 + "skills": [
13 + "./skills"
14 + ]
15 + },
16 + "scripts": {},
17 + "peerDependencies": {
18 + "@earendil-works/pi-ai": "*",
19 + "@earendil-works/pi-coding-agent": "*"
20 + },
21 + "devDependencies": {
22 + "@marcfargas/pi-test-harness": "^0.6.1"
23 + },
24 + "license": "MIT",
25 + "description": "Background subagents and takeover sessions for Pi.",
26 + "keywords": [
27 + "pi",
28 + "pi-extension",
29 + "subagents"
30 + ],
31 + "private": true

extensions/superpowers/visual.ts

Modified
1 1 import { spawn } from "node:child_process";
2 2 import { randomBytes, randomUUID } from "node:crypto";
3 -import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync, appendFileSync } from "node:fs";
4 -import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http";
3 +import {
4 + appendFileSync,
5 + existsSync,
6 + mkdirSync,
7 + readdirSync,
8 + readFileSync,
9 + statSync,
10 + writeFileSync,
11 +} from "node:fs";
12 +import {
13 + createServer,
14 + type IncomingMessage,
15 + type Server,
16 + type ServerResponse,
17 +} from "node:http";
5 18 import path from "node:path";
7 20 export type VisualSession = {
22 35 const COOKIE = "pi_superpowers_visual";
23 36 const BODY_LIMIT = 64 * 1024;
25 -export async function startVisualServer({ root, preferredPort = 47718 }: StartVisualOptions): Promise<VisualSession> {
38 +export async function startVisualServer({
39 + root,
40 + preferredPort = 47718,
41 +}: StartVisualOptions): Promise<VisualSession> {
26 42 const id = randomUUID();
27 43 const token = randomBytes(32).toString("base64url");
28 44 const sessionRoot = path.join(root, "visual", id);
45 61 void (async () => {
46 62 try {
47 63 const url = new URL(req.url ?? "/", "http://127.0.0.1");
48 - if (!authorized(req, url)) return json(res, 401, { error: "unauthorized" });
64 + if (!authorized(req, url))
65 + return json(res, 401, { error: "unauthorized" });
49 66 if (url.pathname === "/" && req.method === "GET") {
50 - res.setHeader("Set-Cookie", `${COOKIE}=${token}; SameSite=Strict; Path=/`);
51 - return html(res, frame(latestFragment(contentDir), latestStamp(contentDir)));
67 + res.setHeader(
68 + "Set-Cookie",
69 + `${COOKIE}=${token}; SameSite=Strict; Path=/`,
70 + );
71 + return html(
72 + res,
73 + frame(latestFragment(contentDir), latestStamp(contentDir)),
74 + );
53 76 if (url.pathname === "/api/latest" && req.method === "GET")
54 77 return json(res, 200, latestStamp(contentDir));
55 78 if (url.pathname === "/api/events" && req.method === "GET")
56 - return text(res, existsSync(eventsFile) ? readFileSync(eventsFile, "utf8") : "");
79 + return text(
80 + res,
81 + existsSync(eventsFile) ? readFileSync(eventsFile, "utf8") : "",
82 + );
57 83 if (url.pathname === "/api/event" && req.method === "POST") {
58 84 const body = await readBody(req);
59 85 const event = JSON.parse(body || "{}");
60 - appendFileSync(eventsFile, `${JSON.stringify({ ...event, timestamp: Date.now() })}\n`);
86 + appendFileSync(
87 + eventsFile,
88 + `${JSON.stringify({ ...event, timestamp: Date.now() })}\n`,
89 + );
61 90 return json(res, 200, { ok: true });
63 92 return json(res, 404, { error: "not found" });
64 93 } catch (err) {
65 - return json(res, 500, { error: err instanceof Error ? err.message : String(err) });
94 + return json(res, 500, {
95 + error: err instanceof Error ? err.message : String(err),
96 + });
67 98 })();
69 100 await listen(server, preferredPort);
70 101 const address = server.address();
71 - if (!address || typeof address === "string") throw new Error("visual server failed to bind");
102 + if (!address || typeof address === "string")
103 + throw new Error("visual server failed to bind");
72 104 const url = `http://127.0.0.1:${address.port}/?token=${encodeURIComponent(token)}`;
73 105 const info = { id, url, contentDir, stateDir, eventsFile };
74 106 writeFileSync(serverInfoFile, `${JSON.stringify(info, null, "\t")}\n`);
75 107 return { ...info, serverInfoFile, close: () => server.close() };
78 -export async function openBrowser(url: string): Promise<{ ok: boolean; command?: string; error?: string }> {
110 +export async function openBrowser(
111 + url: string,
112 +): Promise<{ ok: boolean; command?: string; error?: string }> {
79 113 if (process.env.NODE_ENV === "test" || process.env.PI_SUPERPOWERS_NO_OPEN)
80 114 return { ok: false, error: "browser opener disabled" };
81 115 for (const candidate of openerCandidates(url)) {
85 119 return { ok: false, error: "no browser opener found" };
88 -function openerCandidates(url: string): Array<{ command: string; args: string[] }> {
89 - if (process.env.TERMUX_VERSION) return [{ command: "termux-open-url", args: [url] }];
122 +function openerCandidates(
123 + url: string,
124 +): Array<{ command: string; args: string[] }> {
125 + if (process.env.TERMUX_VERSION)
126 + return [{ command: "termux-open-url", args: [url] }];
90 127 if (process.platform === "darwin") return [{ command: "open", args: [url] }];
91 - if (process.platform === "win32") return [{ command: "cmd.exe", args: ["/c", "start", "", url] }];
128 + if (process.platform === "win32")
129 + return [{ command: "cmd.exe", args: ["/c", "start", "", url] }];
92 130 return [
93 131 { command: "xdg-open", args: [url] },
94 132 { command: "wslview", args: [url] },
99 -function trySpawn(command: string, args: string[]): Promise<{ ok: boolean; error?: string }> {
137 +function trySpawn(
138 + command: string,
139 + args: string[],
140 +): Promise<{ ok: boolean; error?: string }> {
100 141 return new Promise((resolve) => {
101 142 const child = spawn(command, args, { detached: true, stdio: "ignore" });
102 143 let settled = false;
132 173 function latestFiles(contentDir: string) {
133 174 return readdirSync(contentDir)
134 175 .filter((f) => f.endsWith(".html"))
135 - .map((name) => ({ name, path: path.join(contentDir, name), mtime: statSync(path.join(contentDir, name)).mtimeMs }))
176 + .map((name) => ({
177 + name,
178 + path: path.join(contentDir, name),
179 + mtime: statSync(path.join(contentDir, name)).mtimeMs,
180 + }))
136 181 .sort((a, b) => b.mtime - a.mtime || b.name.localeCompare(a.name));
153 198 function frame(fragment: string, stamp: { name: string; mtime: number }) {
154 - const body = /<html[\s>]/i.test(fragment) || /<!doctype/i.test(fragment) ? fragment : `<main id="main">${fragment}</main>`;
199 + const body =
200 + /<html[\s>]/i.test(fragment) || /<!doctype/i.test(fragment)
201 + ? fragment
202 + : `<main id="main">${fragment}</main>`;
155 203 return `<!doctype html>
156 204 <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
157 205 <title>Pi Superpowers Visual Brainstorming</title><link rel="icon" href="data:,"><style>${css()}</style></head><body data-stamp="${escapeAttr(JSON.stringify(stamp))}">
171 219 let body = "";
172 220 for await (const chunk of req) {
173 221 body += String(chunk);
174 - if (Buffer.byteLength(body, "utf8") > BODY_LIMIT) throw new Error("request body too large");
222 + if (Buffer.byteLength(body, "utf8") > BODY_LIMIT)
223 + throw new Error("request body too large");
176 225 return body;
193 242 res.end(body);
195 244 function escapeHtml(s: string) {
196 - return s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
245 + return s
246 + .replaceAll("&", "&amp;")
247 + .replaceAll("<", "&lt;")
248 + .replaceAll(">", "&gt;");
198 250 function escapeAttr(s: string) {
199 251 return escapeHtml(s).replaceAll('"', "&quot;");

extensions/terminal-notifier/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("terminal-notifier pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/terminal-notifier/focus.ts

Modified
17 17 const G = globalThis as unknown as { __bugabinga_pi_focus?: FocusState };
18 -const state = (G.__bugabinga_pi_focus ??= {
18 +G.__bugabinga_pi_focus ??= {
19 19 refs: 0,
20 20 focused: true,
21 21 listeners: new Set(),
22 22 buf: "",
23 -});
23 +};
24 +const state = G.__bugabinga_pi_focus;
25 26 function notify(next: boolean): void {
26 27 if (next === state.focused) return;

extensions/terminal-notifier/index.ts

Modified
146 146 function notifyWindows(title: string, body: string): void {
147 - const { execFile } = require("child_process");
147 + const { execFile } = require("node:child_process");
148 148 execFile("powershell.exe", [
149 149 "-NoProfile",
150 150 "-Command",
194 194 // Also notify on focus-in if agent had already finished while away
195 - const onFocusChange = (isFocused: boolean) => {
195 + const onFocusChange = (_isFocused: boolean) => {
196 196 // No need to notify when coming back — terminal-signals handles
197 197 // the tab badge. This is for external events via notify:send.

extensions/terminal-notifier/package.json

Modified
2 - "name": "@bugabinga/pi-ext-terminal-notifier",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Terminal notification bridge for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-terminal-notifier",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Terminal notification bridge for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/terminal-signals/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("terminal-signals pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/terminal-signals/focus.ts

Modified
17 17 const G = globalThis as unknown as { __bugabinga_pi_focus?: FocusState };
18 -const state = (G.__bugabinga_pi_focus ??= {
18 +G.__bugabinga_pi_focus ??= {
19 19 refs: 0,
20 20 focused: true,
21 21 listeners: new Set(),
22 22 buf: "",
23 -});
23 +};
24 +const state = G.__bugabinga_pi_focus;
25 26 function notify(next: boolean): void {
26 27 if (next === state.focused) return;

extensions/terminal-signals/package.json

Modified
2 - "name": "@bugabinga/pi-ext-terminal-signals",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Terminal lifecycle signals for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-terminal-signals",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Terminal lifecycle signals for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/terse/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("terse pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/terse/package.json

Modified
2 - "name": "@bugabinga/pi-ext-terse",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Terse response protocol injector for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-terse",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Terse response protocol injector for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/tldr/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("tldr pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/tldr/__tests__/tldr.test.ts

Modified
209 209 maxRetries: 0,
210 210 cacheRetention: "none",
212 - const factory = ctx.widgets["tldr"] as (tui: unknown, theme: unknown) => { render(width: number): string[] };
212 + const factory = ctx.widgets["tldr"] as (
213 + tui: unknown,
214 + theme: unknown,
215 + ) => { render(width: number): string[] };
213 216 expect(typeof factory).toBe("function");
214 217 const component = factory({}, {});
215 218 expect(component.render(80)[1]).toContain("Reading package metadata.");
237 240 scheduler.flush();
238 241 await settle();
239 242 expect(calls).toBe(1);
240 - const factory = ctx.widgets["tldr"] as (tui: unknown, theme: unknown) => { render(width: number): string[] };
243 + const factory = ctx.widgets["tldr"] as (
244 + tui: unknown,
245 + theme: unknown,
246 + ) => { render(width: number): string[] };
241 247 const component = factory({}, {});
242 248 expect(component.render(80)[1]).toContain("Update 1.");

extensions/tldr/index.ts

Modified
203 203 function showTldr(ctx: ExtensionContext, text: string): void {
204 204 if (!ctx.hasUI) return;
205 205 const safe = sanitizeTldrText(text);
206 - if (!safe) return clearTldr(ctx);
206 + if (!safe) {
207 + clearTldr(ctx);
208 + return;
207 210 ctx.ui.setWidget(WIDGET_KEY, (_tui, _theme) => ({
208 211 render(width: number) {
209 212 return boxLines(safe, width);
509 512 if (this.inFlight) return;
510 513 const job = this.queue.shift();
511 514 if (!job) return;
512 - if (job.runId !== this.runId || job.index <= this.latestAcceptedIndex)
513 - return this.pump(ctx);
515 + if (job.runId !== this.runId || job.index <= this.latestAcceptedIndex) {
516 + this.pump(ctx);
517 + return;
514 519 this.inFlight = { index: job.index, runId: job.runId };
515 520 void this.generateCheckpoint(ctx, job);

extensions/tldr/package.json

Modified
2 - "name": "@bugabinga/pi-ext-tldr",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-ai": "*",
7 - "@earendil-works/pi-coding-agent": "*",
8 - "@earendil-works/pi-tui": "*"
9 - },
10 - "license": "MIT",
11 - "description": "Live TLDR widget for Pi.",
12 - "keywords": [
13 - "pi",
14 - "pi-extension"
15 - ],
16 - "devDependencies": {
17 - "@marcfargas/pi-test-harness": "^0.6.1"
18 - },
19 - "scripts": {},
20 - "private": true
2 + "name": "@bugabinga/pi-ext-tldr",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-ai": "*",
7 + "@earendil-works/pi-coding-agent": "*",
8 + "@earendil-works/pi-tui": "*"
9 + },
10 + "license": "MIT",
11 + "description": "Live TLDR widget for Pi.",
12 + "keywords": [
13 + "pi",
14 + "pi-extension"
15 + ],
16 + "devDependencies": {
17 + "@marcfargas/pi-test-harness": "^0.6.1"
18 + },
19 + "scripts": {},
20 + "private": true

extensions/tps/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("tps pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/tps/package.json

Modified
2 - "name": "@bugabinga/pi-ext-tps",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "Tokens-per-second footer segment for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-tps",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "Tokens-per-second footer segment for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/usage/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("usage pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/usage/index.ts

Modified
524 524 const cur = sorted[i]!;
525 525 while (
526 526 right < sorted.length &&
527 - sorted[right]!.timestamp <= cur.timestamp + PARALLEL_WINDOW_MS
527 + sorted[right]?.timestamp <= cur.timestamp + PARALLEL_WINDOW_MS
529 - const sid = sorted[right]!.sessionId;
529 + const sid = sorted[right]?.sessionId;
530 530 const n = (sidCount.get(sid) ?? 0) + 1;
531 531 sidCount.set(sid, n);
532 532 if (n === 1) unique++;
535 535 while (
536 536 left < right &&
537 - sorted[left]!.timestamp < cur.timestamp - PARALLEL_WINDOW_MS
537 + sorted[left]?.timestamp < cur.timestamp - PARALLEL_WINDOW_MS
539 - const sid = sorted[left]!.sessionId;
539 + const sid = sorted[left]?.sessionId;
540 540 const n = (sidCount.get(sid) ?? 0) - 1;
541 541 if (!n) {
542 542 sidCount.delete(sid);

extensions/usage/package.json

Modified
2 - "name": "@bugabinga/pi-ext-usage",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*",
7 - "@earendil-works/pi-tui": "*"
8 - },
9 - "license": "MIT",
10 - "description": "Local usage statistics dashboard for Pi.",
11 - "keywords": [
12 - "pi",
13 - "pi-extension"
14 - ],
15 - "devDependencies": {
16 - "@marcfargas/pi-test-harness": "^0.6.1"
17 - },
18 - "scripts": {},
19 - "private": true
2 + "name": "@bugabinga/pi-ext-usage",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*",
7 + "@earendil-works/pi-tui": "*"
8 + },
9 + "license": "MIT",
10 + "description": "Local usage statistics dashboard for Pi.",
11 + "keywords": [
12 + "pi",
13 + "pi-extension"
14 + ],
15 + "devDependencies": {
16 + "@marcfargas/pi-test-harness": "^0.6.1"
17 + },
18 + "scripts": {},
19 + "private": true

extensions/vcs-status/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("vcs-status pi-test-harness", () => {
9 9 let t: TestSession | undefined;

extensions/vcs-status/package.json

Modified
2 - "name": "@bugabinga/pi-ext-vcs-status",
3 - "type": "module",
4 - "main": "index.ts",
5 - "peerDependencies": {
6 - "@earendil-works/pi-coding-agent": "*"
7 - },
8 - "license": "MIT",
9 - "description": "VCS workspace telemetry for Pi.",
10 - "keywords": [
11 - "pi",
12 - "pi-extension"
13 - ],
14 - "devDependencies": {
15 - "@marcfargas/pi-test-harness": "^0.6.1"
16 - },
17 - "scripts": {},
18 - "private": true
2 + "name": "@bugabinga/pi-ext-vcs-status",
3 + "type": "module",
4 + "main": "index.ts",
5 + "peerDependencies": {
6 + "@earendil-works/pi-coding-agent": "*"
7 + },
8 + "license": "MIT",
9 + "description": "VCS workspace telemetry for Pi.",
10 + "keywords": [
11 + "pi",
12 + "pi-extension"
13 + ],
14 + "devDependencies": {
15 + "@marcfargas/pi-test-harness": "^0.6.1"
16 + },
17 + "scripts": {},
18 + "private": true

extensions/web/__tests__/harness.test.ts

Modified
1 -import { afterEach, describe, expect, it } from "vitest";
2 1 import path from "node:path";
3 2 import {
4 3 createTestSession,
5 4 type TestSession,
6 5 } from "@marcfargas/pi-test-harness";
6 +import { afterEach, describe, expect, it } from "vitest";
8 8 describe("web extension harness", () => {
9 9 let t: TestSession | undefined;

extensions/web/ddg.ts

Modified
105 105 // Reset lastIndex for global regex (module-level constant)
106 106 RESULT_BLOCK_RE.lastIndex = 0;
108 - let blockMatch;
108 + let blockMatch: RegExpExecArray | null;
109 + // biome-ignore lint/suspicious/noAssignInExpressions: standard regex exec loop
109 110 while ((blockMatch = RESULT_BLOCK_RE.exec(html)) !== null) {
110 111 diagnostics.rawBlockCount++;
111 112 const block = blockMatch[1];

extensions/web/extract.ts

Modified
58 58 out = out.replace(
59 59 /<(\w+)([^>]*style=["'])([^"']*)(["'][^>]*)>([\s\S]*?)<\/\1>/gi,
60 - (_match, tag, _before, styleVal, _after, _content) => {
60 + (_match, _tag, _before, styleVal, _after, _content) => {
61 61 return VISUAL_HIDE_PATTERNS.some((p) => p.test(styleVal)) ? "" : _match;

extensions/web/index.ts

Modified
288 288 const raw = await spawnToText("identify", ["-verbose", filePath]);
289 289 return {
290 290 format: raw.match(/Format:\s*(\S+)/i)?.[1] ?? "",
291 - width: parseInt(raw.match(/Geometry:\s*(\d+)x(\d+)/i)?.[1] ?? "0"),
292 - height: parseInt(raw.match(/Geometry:\s*(\d+)x(\d+)/i)?.[2] ?? "0"),
291 + width: parseInt(raw.match(/Geometry:\s*(\d+)x(\d+)/i)?.[1] ?? "0", 10),
292 + height: parseInt(raw.match(/Geometry:\s*(\d+)x(\d+)/i)?.[2] ?? "0", 10),
293 293 colorspace: raw.match(/Colorspace:\s*(\S+)/i)?.[1] ?? "",
294 294 depth: raw.match(/Depth:\s*(\S+)/i)?.[1] ?? "",
295 295 fileSize: raw.match(/Filesize:\s*(\S+)/i)?.[1] ?? "",
350 350 height: stream.height,
351 351 formatName: fmt.format_name,
352 352 bitRate: fmt.bit_rate
353 - ? `${Math.round(parseInt(fmt.bit_rate) / 1000)}kbps`
353 + ? `${Math.round(parseInt(fmt.bit_rate, 10) / 1000)}kbps`
354 354 : undefined,

extensions/web/package.json

Modified
2 - "name": "@bugabinga/pi-ext-web",
3 - "type": "module",
4 - "main": "index.ts",
5 - "scripts": {},
6 - "peerDependencies": {
7 - "@earendil-works/pi-coding-agent": "*",
8 - "@earendil-works/pi-tui": "*",
9 - "typebox": "*"
10 - },
11 - "devDependencies": {
12 - "@marcfargas/pi-test-harness": "^0.6.1"
13 - },
14 - "license": "MIT",
15 - "description": "Web fetch, search, and image tools for Pi.",
16 - "keywords": [
17 - "pi",
18 - "pi-extension"
19 - ],
20 - "private": true
2 + "name": "@bugabinga/pi-ext-web",
3 + "type": "module",
4 + "main": "index.ts",
5 + "scripts": {},
6 + "peerDependencies": {
7 + "@earendil-works/pi-coding-agent": "*",
8 + "@earendil-works/pi-tui": "*",
9 + "typebox": "*"
10 + },
11 + "devDependencies": {
12 + "@marcfargas/pi-test-harness": "^0.6.1"
13 + },
14 + "license": "MIT",
15 + "description": "Web fetch, search, and image tools for Pi.",
16 + "keywords": [
17 + "pi",
18 + "pi-extension"
19 + ],
20 + "private": true

package-lock.json

Modified
11 11 "extensions/*"
13 13 "devDependencies": {
14 + "@playwright/test": "^1.60.0",
14 15 "typescript": "^5.7.3",
15 16 "vitest": "^4.1.8"
3194 3195 "react-dom": "^18.3.1 || ^19.0.0"
3198 + "node_modules/@playwright/test": {
3199 + "version": "1.60.0",
3200 + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.60.0.tgz",
3201 + "integrity": "sha512-O71yZIbAh/PxDMNGns37GHBIfrVkEVyn+AXyIa5dOTfb4/xNvRWV+Vv/NMbNCtODB/pO7vLlF2OTmMVLhmr7Ag==",
3202 + "dev": true,
3203 + "license": "Apache-2.0",
3204 + "dependencies": {
3205 + "playwright": "1.60.0"
3206 + },
3207 + "bin": {
3208 + "playwright": "cli.js"
3209 + },
3210 + "engines": {
3211 + "node": ">=18"
3213 + },
3197 3214 "node_modules/@protobufjs/aspromise": {
3198 3215 "version": "1.1.2",
3199 3216 "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
5106 5123 "url": "https://github.com/sponsors/jonschlinkert"
5126 + "node_modules/playwright": {
5127 + "version": "1.60.0",
5128 + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.60.0.tgz",
5129 + "integrity": "sha512-hheHdokM8cdqCb0lcE3s+zT4t4W+vvjpGxsZlDnikarzx8tSzMebh3UiFtgqwFwnTnjYQcsyMF8ei2mCO/tpeA==",
5130 + "dev": true,
5131 + "license": "Apache-2.0",
5132 + "dependencies": {
5133 + "playwright-core": "1.60.0"
5134 + },
5135 + "bin": {
5136 + "playwright": "cli.js"
5137 + },
5138 + "engines": {
5139 + "node": ">=18"
5140 + },
5141 + "optionalDependencies": {
5142 + "fsevents": "2.3.2"
5144 + },
5145 + "node_modules/playwright-core": {
5146 + "version": "1.60.0",
5147 + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.60.0.tgz",
5148 + "integrity": "sha512-9bW6zvX/m0lEbgTKJ6YppOKx8H3VOPBMOCFh2irXFOT4BbHgrx5hPjwJYLT40Lu+4qtD36qKc/Hn56StUW57IA==",
5149 + "dev": true,
5150 + "license": "Apache-2.0",
5151 + "bin": {
5152 + "playwright-core": "cli.js"
5153 + },
5154 + "engines": {
5155 + "node": ">=18"
5157 + },
5158 + "node_modules/playwright/node_modules/fsevents": {
5159 + "version": "2.3.2",
5160 + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
5161 + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
5162 + "dev": true,
5163 + "hasInstallScript": true,
5164 + "license": "MIT",
5165 + "optional": true,
5166 + "os": [
5167 + "darwin"
5168 + ],
5169 + "engines": {
5170 + "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
5172 + },
5109 5173 "node_modules/postcss": {
5110 5174 "version": "8.5.15",
5111 5175 "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz",

package.json

Modified
12 12 "test:watch": "vitest"
14 14 "devDependencies": {
15 + "@playwright/test": "^1.60.0",
15 16 "typescript": "^5.7.3",
16 17 "vitest": "^4.1.8"

skills/ascii-boxes/index.test.ts

Modified
261 261 const single = drawBox("T", { style: "single" });
262 262 const double = drawBox("T", { style: "double" });
263 263 const bold = drawBox("T", { style: "bold" });
264 - expect(single.includes("┌") && single.includes("─") && single.includes("│")).toBe(true);
265 - expect(double.includes("╔") && double.includes("═") && double.includes("║")).toBe(true);
266 - expect(bold.includes("┏") && bold.includes("━") && bold.includes("┃")).toBe(true);
264 + expect(
265 + single.includes("┌") && single.includes("─") && single.includes("│"),
266 + ).toBe(true);
267 + expect(
268 + double.includes("╔") && double.includes("═") && double.includes("║"),
269 + ).toBe(true);
270 + expect(bold.includes("┏") && bold.includes("━") && bold.includes("┃")).toBe(
271 + true,
272 + );
267 273 expect(single).not.toInclude("╔");
268 274 expect(double).not.toInclude("┌");

skills/chrome-cdp/scripts/cdp.mjs

Modified
8 8 // the CDP session open. Chrome's "Allow debugging" modal fires once per
9 9 // daemon (= once per tab). Daemons auto-exit after 20min idle.
11 -import { spawn } from "child_process";
11 +import { spawn } from "node:child_process";
12 12 import {
13 13 chmodSync,
14 14 existsSync,
17 17 readFileSync,
18 18 unlinkSync,
19 19 writeFileSync,
20 -} from "fs";
21 -import net from "net";
22 -import { homedir, tmpdir, userInfo } from "os";
23 -import { join, resolve } from "path";
20 +} from "node:fs";
21 +import net from "node:net";
22 +import { homedir, tmpdir, userInfo } from "node:os";
23 +import { join, resolve } from "node:path";
25 25 function envInt(name, fallback, { min = 1 } = {}) {
26 26 const raw = process.env[name];
580 580 async function clickXyStr(cdp, sid, x, y) {
581 581 const cx = parseFloat(x);
582 582 const cy = parseFloat(y);
583 - if (isNaN(cx) || isNaN(cy))
583 + if (Number.isNaN(cx) || Number.isNaN(cy))
584 584 throw new Error("x and y must be numbers (CSS pixels)");
585 585 const base = { x: cx, y: cy, button: "left", clickCount: 1, modifiers: 0 };
586 586 await cdp.send(
802 802 sessionId,
803 803 args[0],
804 - args[1] ? parseInt(args[1]) : undefined,
804 + args[1] ? parseInt(args[1], 10) : undefined,
806 806 break;
807 807 case "evalraw":

skills/firefox-bidi/scripts/bidi.integration.test.mjs

Modified
1 1 import assert from "node:assert/strict";
2 2 import { spawn } from "node:child_process";
3 -import { createHash, randomBytes } from "node:crypto";
3 +import { createHash } from "node:crypto";
4 4 import { existsSync } from "node:fs";
5 5 import {
6 6 chmod,

skills/firefox-bidi/scripts/bidi.mjs

Modified
3 3 #!/usr/bin/env node
4 4 // bidi - lightweight Firefox WebDriver BiDi CLI for agents.
5 5 // No dependencies. Requires Node 22+ (built-in WebSocket).
6 6 // Auto-starts a managed Firefox with --remote-debugging-port 0 unless a WS URL is supplied.
8 -import { writeFileSync } from "fs";
9 -import { join } from "path";
8 +import { writeFileSync } from "node:fs";
9 +import { join } from "node:path";
10 10 import {
11 11 envInt,
12 12 freeTcpPort,

skills/firefox-bidi/scripts/firefox-common.mjs

Modified
1 -import { spawn } from "child_process";
1 +import { spawn } from "node:child_process";
2 2 import {
3 3 chmodSync,
4 4 mkdirSync,
5 5 readFileSync,
6 6 unlinkSync,
7 7 writeFileSync,
8 -} from "fs";
9 -import { createServer } from "net";
10 -import { tmpdir, userInfo } from "os";
11 -import { join, resolve } from "path";
8 +} from "node:fs";
9 +import { createServer } from "node:net";
10 +import { tmpdir, userInfo } from "node:os";
11 +import { join, resolve } from "node:path";
13 13 export const DEFAULT_FIREFOX_APP_ID = "pi-firefox-debug";

skills/firefox-bidi/scripts/rdp.mjs

Modified
3 3 #!/usr/bin/env node
5 5 // rdp - experimental Firefox DevTools Remote Debugging Protocol console capture.
6 6 // No dependencies. Uses raw TCP RDP framing: <byte-length>:<json>.
8 -import { createConnection } from "net";
9 -import { join } from "path";
8 +import { createConnection } from "node:net";
9 +import { join } from "node:path";
10 10 import {
11 11 envInt,
12 12 freeTcpPort,

tsconfig.json

Modified
16 16 "prompts/**/*.ts",
17 17 "themes/**/*.ts"
19 - "exclude": [
20 - "node_modules",
21 - "**/*.test.ts"
22 - ]
19 + "exclude": ["node_modules", "**/*.test.ts"]

vitest.workspace.ts

Modified
2 2 import { defineWorkspace } from "vitest/config";
4 4 export default defineWorkspace(
5 5 // Auto-discover all extension test suites
6 - [
7 - "extensions/*",
8 - "skills/*",
9 - ],
6 + ["extensions/*", "skills/*"],