Publish reviewed development agents and WUI draft with recovery evidence (#1497)
This commit is contained in:
@@ -7,13 +7,20 @@ import { join, resolve } from 'node:path';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
const source = resolve(import.meta.dirname, '..');
|
||||
test('Darkwing launch context, resources, session recovery, and refusals', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'darkwing launch '));
|
||||
for (const agent of ['darkwing', 'dewey', 'filbert']) test(`${agent} launch context, resources, session recovery, and refusals`, () => {
|
||||
const root = mkdtempSync(join(tmpdir(), `${agent} launch `));
|
||||
try {
|
||||
for (const dir of ['agents', 'scripts', 'contracts', 'user', 'node_modules/.bin', 'extensions/goal']) {
|
||||
mkdirSync(join(root, dir), { recursive: true });
|
||||
}
|
||||
cpSync(join(source, 'agents/darkwing'), join(root, 'agents/darkwing'), { recursive: true });
|
||||
// Copy only runtime inputs. Agent work/scratch may be large or actively
|
||||
// authored and is unrelated to isolated launcher verification.
|
||||
mkdirSync(join(root, `agents/${agent}`), { recursive: true });
|
||||
for (const file of ['launch.sh', 'SOUL.md', 'CONTEXT.md', 'validate-sessions.mjs']) {
|
||||
cpSync(join(source, `agents/${agent}`, file), join(root, `agents/${agent}`, file));
|
||||
}
|
||||
assert.equal(existsSync(join(root, `agents/${agent}/work`)), false);
|
||||
assert.equal(existsSync(join(root, `agents/${agent}/scratch`)), false);
|
||||
cpSync(join(source, 'scripts/agent-host-dev.sh'), join(root, 'scripts/agent-host-dev.sh'));
|
||||
cpSync(join(source, 'scripts/agent.sh'), join(root, 'scripts/agent.sh'));
|
||||
cpSync(join(source, 'skills'), join(root, 'skills'), { recursive: true });
|
||||
@@ -27,15 +34,15 @@ test('Darkwing launch context, resources, session recovery, and refusals', () =>
|
||||
writeFileSync(join(root, 'node_modules/.bin/pi'), `#!/usr/bin/env node
|
||||
const fs = require('node:fs');
|
||||
if (process.argv[2] === '--version') { console.log('0.84.4'); process.exit(0); }
|
||||
fs.writeFileSync('capture.json', JSON.stringify({args: process.argv.slice(2), incarnation: process.env.MOSAIC_LAUNCH_INCARNATION}));
|
||||
fs.writeFileSync('capture.json', JSON.stringify({args: process.argv.slice(2), agent: process.env.MOSAIC_AGENT_NAME, incarnation: process.env.MOSAIC_LAUNCH_INCARNATION}));
|
||||
`, { mode: 0o755 });
|
||||
const launch = (args = '', tty = true) => spawnSync(tty ? 'script' : 'bash', tty
|
||||
? ['-q', '-e', '-c', `bash agents/darkwing/launch.sh ${args}`, '/dev/null']
|
||||
: ['agents/darkwing/launch.sh', ...args.split(' ').filter(Boolean)],
|
||||
? ['-q', '-e', '-c', `bash agents/${agent}/launch.sh ${args}`, '/dev/null']
|
||||
: [`agents/${agent}/launch.sh`, ...args.split(' ').filter(Boolean)],
|
||||
{ cwd: root, env: { ...process.env, MOSAIC_LAUNCH_INCARNATION: 'must-not-inherit' }, encoding: 'utf8', timeout: 10000 });
|
||||
const ok = (result) => assert.equal(result.status, 0, result.stdout + result.stderr);
|
||||
ok(launch('--check', false));
|
||||
const direct = spawnSync('bash', [join(root, 'scripts/agent.sh'), '--host-dev', 'darkwing', '--check'],
|
||||
const direct = spawnSync('bash', [join(root, 'scripts/agent.sh'), '--host-dev', agent, '--check'],
|
||||
{ cwd: tmpdir(), encoding: 'utf8', timeout: 10000 });
|
||||
ok(direct);
|
||||
assert.match(direct.stdout, /configuration checks passed/);
|
||||
@@ -44,6 +51,11 @@ fs.writeFileSync('capture.json', JSON.stringify({args: process.argv.slice(2), in
|
||||
ok(launch());
|
||||
let captured = JSON.parse(readFileSync(join(root, 'capture.json')));
|
||||
assert.equal(captured.incarnation, undefined);
|
||||
assert.equal(captured.agent, agent);
|
||||
assert.equal(captured.args[captured.args.indexOf('--provider') + 1], agent === 'filbert' ? 'openai-codex' : 'test');
|
||||
assert.equal(captured.args[captured.args.indexOf('--model') + 1], agent === 'filbert' ? 'gpt-6-astra' : 'test-model');
|
||||
if (agent === 'filbert') assert.equal(captured.args[captured.args.indexOf('--thinking') + 1], 'low');
|
||||
assert.equal(captured.args[captured.args.indexOf('--session-dir') + 1], join(root, `.pi/state/${agent}/sessions`));
|
||||
assert.equal(captured.args.includes('--continue'), false);
|
||||
assert.ok(captured.args.includes('--no-context-files'));
|
||||
assert.ok(captured.args.includes('--no-skills'));
|
||||
@@ -54,8 +66,8 @@ fs.writeFileSync('capture.json', JSON.stringify({args: process.argv.slice(2), in
|
||||
assert.match(context, /fixture contracts\/CONSTITUTION.md/);
|
||||
assert.match(context, /fixture user\/USER.md/);
|
||||
assert.match(context, /fixture AGENTS.md/);
|
||||
assert.match(context, /You are Darkwing/);
|
||||
const sessions = join(root, '.pi/state/darkwing/sessions');
|
||||
assert.match(context, new RegExp(`You are ${agent[0].toUpperCase() + agent.slice(1)}`));
|
||||
const sessions = join(root, `.pi/state/${agent}/sessions`);
|
||||
const session = join(sessions, 'history.jsonl');
|
||||
const history = JSON.stringify({ type: 'session', version: 3, id: 'test', cwd: root, timestamp: new Date().toISOString() }) + '\n';
|
||||
writeFileSync(session, history);
|
||||
@@ -73,10 +85,10 @@ fs.writeFileSync('capture.json', JSON.stringify({args: process.argv.slice(2), in
|
||||
assert.notEqual(launch('--unexpected', false).status, 0);
|
||||
assert.notEqual(launch('', false).status, 0);
|
||||
const locked = spawnSync('script', ['-q', '-e', '-c',
|
||||
'flock .pi/state/darkwing/launch.lock bash agents/darkwing/launch.sh --fresh', '/dev/null'],
|
||||
`flock .pi/state/${agent}/launch.lock bash agents/${agent}/launch.sh --fresh`, '/dev/null'],
|
||||
{ cwd: root, encoding: 'utf8', timeout: 10000 });
|
||||
assert.notEqual(locked.status, 0);
|
||||
assert.match(locked.stdout, /another darkwing TUI/);
|
||||
assert.match(locked.stdout, new RegExp(`another ${agent} TUI`));
|
||||
writeFileSync(join(root, 'alternate.md'), 'alternate user context\n');
|
||||
ok(launch('--fresh --user alternate.md'));
|
||||
captured = JSON.parse(readFileSync(join(root, 'capture.json')));
|
||||
|
||||
Reference in New Issue
Block a user