Files
plan2code/plan2code-app/scripts/smoke-agent.mjs
T
2026-12-05 13:19:59 -08:00

31 lines
1.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
// A stand-in agent for CI's smoke run of the built app (.github/workflows/app.yml);
// point PLAN2CODE_APP_AGENT_BIN at it. Like a real agent, it opens a web console
// dashboard with the environment the app gave it, so the console announces
// itself to the window and the dashboard frame has something to connect to
// (smoke-frame.mjs checks it did). fake-agent opens no console.
//
// Needs PLAN2CODE_CONSOLE_DIR (the folder holding console.mjs), ignores the
// app's arguments, and waits until its input closes. The console server is
// detached; the smoke run stops it with `console.mjs stop --all`.
import { spawnSync } from 'node:child_process';
import { join } from 'node:path';
const consoleDir = process.env.PLAN2CODE_CONSOLE_DIR;
if (!consoleDir) {
console.error('smoke-agent: PLAN2CODE_CONSOLE_DIR is not set; it names the folder holding console.mjs');
process.exit(2);
}
const open = spawnSync(process.execPath, [join(consoleDir, 'console.mjs'), 'open', '--workflow', 'dashboard'], {
stdio: ['ignore', 'inherit', 'inherit'],
});
if (open.error || open.status !== 0) {
console.error(`smoke-agent: console.mjs open failed (${open.error ? open.error.message : `exit ${open.status}`})`);
process.exit(1);
}
console.log('smoke-agent: dashboard open; waiting on input');
process.stdin.resume();
process.stdin.on('end', () => process.exit(0));