chore(vendor): import pi 1.3.0
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
51
third_party/pi/scripts/coding-agent-smoke.mjs
vendored
Normal file
51
third_party/pi/scripts/coding-agent-smoke.mjs
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
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}).`);
|
||||
}
|
||||
Reference in New Issue
Block a user