pi-mono/scripts/coding-agent-smoke.mjs
Mario Zechner 7472cda0d6 feat(coding-agent): remove the experimental server stack and the client, protocol, and server packages
Deletes packages/client, packages/protocol (CBOR codec), packages/server, coding-agent's
src/experimental (except source-resolver.ts, which source runs still preload), src/cli/experimental,
src/client, the example plugin, and their tests. coding-agent no longer depends on @earendil-works/chord.
The installer lock drops esbuild, so its platform-package sanity check goes too.
2026-10-12 10:41:59 +00:00

51 lines
2 KiB
JavaScript

import { execFileSync } from "node:child_process";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
export const codingAgentName = "@earendil-works/pi-coding-agent";
export function smokeTestCodingAgent(directory, runtime = process.execPath) {
const packageDir = join(directory, "node_modules", codingAgentName);
const manifest = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
const home = mkdtempSync(join(tmpdir(), "pi-coding-agent-smoke-home-"));
const entry = join(directory, "coding-agent-smoke.mjs");
const env = {
PATH: process.env.PATH,
HOME: home,
USERPROFILE: home,
APPDATA: home,
LOCALAPPDATA: home,
XDG_CONFIG_HOME: home,
XDG_CACHE_HOME: home,
PI_CODING_AGENT_DIR: join(home, ".pi", "agent"),
PI_OFFLINE: "1",
PI_TELEMETRY: "0",
};
for (const name of ["SystemRoot", "SYSTEMROOT", "WINDIR", "COMSPEC", "PATHEXT"]) {
if (process.env[name]) env[name] = process.env[name];
}
try {
writeFileSync(entry, `import assert from "node:assert/strict";
import { createAgentSession, SessionManager, ModelRuntime } from "${codingAgentName}";
assert.equal(typeof createAgentSession, "function");
assert.equal(typeof SessionManager.inMemory, "function");
assert.equal(typeof ModelRuntime.create, "function");
`);
execFileSync(runtime, [entry], { cwd: directory, env, stdio: ["inherit", "pipe", "pipe"], timeout: 30_000 });
for (const cli of new Set([manifest.bin.pi, "dist/cli.js"])) {
const output = execFileSync(runtime, [join(packageDir, cli), "--version"], {
cwd: directory,
encoding: "utf8",
env,
stdio: ["inherit", "pipe", "pipe"],
timeout: 30_000,
});
if (output.trim() !== manifest.version) throw new Error(`Unexpected version from ${cli}: ${output}`);
}
} finally {
rmSync(entry, { force: true });
rmSync(home, { recursive: true, force: true });
}
console.log(`Coding-agent policy smoke tests passed (${runtime}).`);
}