Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/tui/lib/coding-agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"./auth-storage": "./src/core/auth-storage.ts",
"./model-registry": "./src/core/model-registry.ts",
"./settings-manager": "./src/core/settings-manager.ts",
"./slash-commands": "./src/core/slash-commands.ts",
"./timings": "./src/core/timings.ts",
"./messages": "./src/core/messages.ts",
"./theme": "./src/modes/interactive/theme/theme.ts"
Expand Down
2 changes: 1 addition & 1 deletion apps/tui/src/native-agent-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type {
} from "@earendil-works/pi-coding-agent/agent-connection";
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
import type { ContextTreeNode } from "../lib/coding-agent/src/core/context-tree.js";
import { PERMISSIONS_COMMAND_ENABLED } from "../lib/coding-agent/src/core/slash-commands.js";
import { PERMISSIONS_COMMAND_ENABLED } from "@earendil-works/pi-coding-agent/slash-commands";
import type { BashResult } from "../lib/coding-agent/src/core/bash-executor.js";
import { measureAsync } from "@earendil-works/pi-coding-agent/timings";
import { StdioJsonRpc, type JsonRpcId } from "./stdio-jsonrpc.js";
Expand Down
40 changes: 40 additions & 0 deletions apps/tui/src/runtime-imports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import assert from "node:assert/strict";
import test from "node:test";
import { readdirSync, readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";

/**
* The release bundle deletes apps/tui's `lib/` directory after materializing
* the file: packages under node_modules (scripts/runtime/tui.ts). A runtime
* value import that escapes into `../lib/...` therefore only fails in the
* shipped product, never in the repo checkout. Keep value imports on package
* specifiers (`@earendil-works/...`); `import type` is erased at transpile and
* stays fine.
*/
const repoTui = join(dirname(fileURLToPath(import.meta.url)), "..");

function collectSourceFiles(directory: string): string[] {
const files: string[] = [];
for (const item of readdirSync(directory, { withFileTypes: true })) {
const path = join(directory, item.name);
if (item.isDirectory()) {
if (item.name !== "node_modules") files.push(...collectSourceFiles(path));
} else if (item.name.endsWith(".ts") && !/\.(test|spec|d)\.ts$/.test(item.name)) {
files.push(path);
}
}
return files;
}

test("runtime sources never value-import from the deleted lib directory", () => {
const offenders: string[] = [];
for (const path of collectSourceFiles(join(repoTui, "src"))) {
const text = readFileSync(path, "utf8");
for (const match of text.matchAll(/import\s+(type\s+)?([^"]*?)from\s+"(\.\.[/])+lib[/]/g)) {
const isTypeOnly = Boolean(match[1]) || /^type[\s{]/.test(match[2]);
if (!isTypeOnly) offenders.push(`${path.replace(repoTui + "/", "")}: ${match[0]}`);
}
}
assert.deepEqual(offenders, []);
});
Loading