refactor: finish companion rename migration

Complete the remaining pi-to-companion rename across companion-os, web, vm-orchestrator, docker, and archived fixtures.

Verification:
- semantic rg sweeps for Pi/piConfig/getPi/.pi runtime references
- npm run check in apps/companion-os (fails in this worktree: biome not found)

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Harivansh Rathi 2026-03-10 07:39:32 -05:00
parent e8fe3d54af
commit 536241053c
303 changed files with 3603 additions and 3602 deletions

View file

@ -28,7 +28,7 @@ describe("ExtensionRunner", () => {
let modelRegistry: ModelRegistry;
beforeEach(() => {
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-runner-test-"));
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "companion-runner-test-"));
extensionsDir = path.join(tempDir, "extensions");
fs.mkdirSync(extensionsDir);
sessionManager = SessionManager.inMemory();
@ -88,8 +88,8 @@ describe("ExtensionRunner", () => {
describe("shortcut conflicts", () => {
it("warns when extension shortcut conflicts with built-in", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+c", {
export default function(companion) {
companion.registerShortcut("ctrl+c", {
description: "Conflicts with built-in",
handler: async () => {},
});
@ -119,8 +119,8 @@ describe("ExtensionRunner", () => {
it("allows a shortcut when the reserved set no longer contains the default key", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+p", {
export default function(companion) {
companion.registerShortcut("ctrl+p", {
description: "Uses freed default",
handler: async () => {},
});
@ -154,8 +154,8 @@ describe("ExtensionRunner", () => {
it("warns but allows when extension uses non-reserved built-in shortcut", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+v", {
export default function(companion) {
companion.registerShortcut("ctrl+v", {
description: "Overrides non-reserved",
handler: async () => {},
});
@ -185,8 +185,8 @@ describe("ExtensionRunner", () => {
it("blocks shortcuts for reserved actions even when rebound", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+x", {
export default function(companion) {
companion.registerShortcut("ctrl+x", {
description: "Conflicts with rebound reserved",
handler: async () => {},
});
@ -223,8 +223,8 @@ describe("ExtensionRunner", () => {
it("blocks shortcuts when reserved action has multiple keys", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+y", {
export default function(companion) {
companion.registerShortcut("ctrl+y", {
description: "Conflicts with multi-key reserved",
handler: async () => {},
});
@ -258,8 +258,8 @@ describe("ExtensionRunner", () => {
it("warns but allows when non-reserved action has multiple keys", async () => {
const extCode = `
export default function(pi) {
pi.registerShortcut("ctrl+y", {
export default function(companion) {
companion.registerShortcut("ctrl+y", {
description: "Overrides multi-key non-reserved",
handler: async () => {},
});
@ -297,16 +297,16 @@ describe("ExtensionRunner", () => {
it("warns when two extensions register same shortcut", async () => {
// Use a non-reserved shortcut
const extCode1 = `
export default function(pi) {
pi.registerShortcut("ctrl+shift+x", {
export default function(companion) {
companion.registerShortcut("ctrl+shift+x", {
description: "First extension",
handler: async () => {},
});
}
`;
const extCode2 = `
export default function(pi) {
pi.registerShortcut("ctrl+shift+x", {
export default function(companion) {
companion.registerShortcut("ctrl+shift+x", {
description: "Second extension",
handler: async () => {},
});
@ -341,8 +341,8 @@ describe("ExtensionRunner", () => {
it("collects tools from multiple extensions", async () => {
const toolCode = (name: string) => `
import { Type } from "@sinclair/typebox";
export default function(pi) {
pi.registerTool({
export default function(companion) {
companion.registerTool({
name: "${name}",
label: "${name}",
description: "Test tool",
@ -380,8 +380,8 @@ describe("ExtensionRunner", () => {
it("keeps first tool when two extensions register the same name", async () => {
const first = `
import { Type } from "@sinclair/typebox";
export default function(pi) {
pi.registerTool({
export default function(companion) {
companion.registerTool({
name: "shared",
label: "shared",
description: "first",
@ -392,8 +392,8 @@ describe("ExtensionRunner", () => {
`;
const second = `
import { Type } from "@sinclair/typebox";
export default function(pi) {
pi.registerTool({
export default function(companion) {
companion.registerTool({
name: "shared",
label: "shared",
description: "second",
@ -423,8 +423,8 @@ describe("ExtensionRunner", () => {
describe("command collection", () => {
it("collects commands from multiple extensions", async () => {
const cmdCode = (name: string) => `
export default function(pi) {
pi.registerCommand("${name}", {
export default function(companion) {
companion.registerCommand("${name}", {
description: "Test command",
handler: async () => {},
});
@ -449,8 +449,8 @@ describe("ExtensionRunner", () => {
it("gets command by name", async () => {
const cmdCode = `
export default function(pi) {
pi.registerCommand("my-cmd", {
export default function(companion) {
companion.registerCommand("my-cmd", {
description: "My command",
handler: async () => {},
});
@ -478,8 +478,8 @@ describe("ExtensionRunner", () => {
it("filters out commands conflict with reseved", async () => {
const cmdCode = (name: string) => `
export default function(pi) {
pi.registerCommand("${name}", {
export default function(companion) {
companion.registerCommand("${name}", {
description: "Test command",
handler: async () => {},
});
@ -517,8 +517,8 @@ describe("ExtensionRunner", () => {
describe("error handling", () => {
it("calls error listeners when handler throws", async () => {
const extCode = `
export default function(pi) {
pi.on("context", async () => {
export default function(companion) {
companion.on("context", async () => {
throw new Error("Handler error!");
});
}
@ -555,8 +555,8 @@ describe("ExtensionRunner", () => {
describe("message renderers", () => {
it("gets message renderer by type", async () => {
const extCode = `
export default function(pi) {
pi.registerMessageRenderer("my-type", (message, options, theme) => null);
export default function(companion) {
companion.registerMessageRenderer("my-type", (message, options, theme) => null);
}
`;
fs.writeFileSync(path.join(extensionsDir, "renderer.ts"), extCode);
@ -581,8 +581,8 @@ describe("ExtensionRunner", () => {
describe("flags", () => {
it("collects flags from extensions", async () => {
const extCode = `
export default function(pi) {
pi.registerFlag("my-flag", {
export default function(companion) {
companion.registerFlag("my-flag", {
description: "My flag",
handler: async () => {},
});
@ -605,8 +605,8 @@ describe("ExtensionRunner", () => {
it("keeps first flag when two extensions register the same name", async () => {
const first = `
export default function(pi) {
pi.registerFlag("shared-flag", {
export default function(companion) {
companion.registerFlag("shared-flag", {
description: "first",
type: "boolean",
default: true,
@ -614,8 +614,8 @@ describe("ExtensionRunner", () => {
}
`;
const second = `
export default function(pi) {
pi.registerFlag("shared-flag", {
export default function(companion) {
companion.registerFlag("shared-flag", {
description: "second",
type: "boolean",
default: false,
@ -641,8 +641,8 @@ describe("ExtensionRunner", () => {
it("can set flag values", async () => {
const extCode = `
export default function(pi) {
pi.registerFlag("test-flag", {
export default function(companion) {
companion.registerFlag("test-flag", {
description: "Test flag",
handler: async () => {},
});
@ -670,8 +670,8 @@ describe("ExtensionRunner", () => {
describe("tool_result chaining", () => {
it("chains content modifications across handlers", async () => {
const extCode1 = `
export default function(pi) {
pi.on("tool_result", async (event) => {
export default function(companion) {
companion.on("tool_result", async (event) => {
return {
content: [...event.content, { type: "text", text: "ext1" }],
};
@ -679,8 +679,8 @@ describe("ExtensionRunner", () => {
}
`;
const extCode2 = `
export default function(pi) {
pi.on("tool_result", async (event) => {
export default function(companion) {
companion.on("tool_result", async (event) => {
return {
content: [...event.content, { type: "text", text: "ext2" }],
};
@ -726,8 +726,8 @@ describe("ExtensionRunner", () => {
it("preserves previous modifications when later handlers return partial patches", async () => {
const extCode1 = `
export default function(pi) {
pi.on("tool_result", async () => {
export default function(companion) {
companion.on("tool_result", async () => {
return {
content: [{ type: "text", text: "first" }],
details: { source: "ext1" },
@ -736,8 +736,8 @@ describe("ExtensionRunner", () => {
}
`;
const extCode2 = `
export default function(pi) {
pi.on("tool_result", async () => {
export default function(companion) {
companion.on("tool_result", async () => {
return {
isError: true,
};
@ -834,8 +834,8 @@ describe("ExtensionRunner", () => {
describe("hasHandlers", () => {
it("returns true when handlers exist for event type", async () => {
const extCode = `
export default function(pi) {
pi.on("tool_call", async () => undefined);
export default function(companion) {
companion.on("tool_call", async () => undefined);
}
`;
fs.writeFileSync(path.join(extensionsDir, "handler.ts"), extCode);