2b4e094982
The synced Codex skills (refactor, review-work, remove-ai-slops) emit `spawn_agent(agent_type="explorer"/"librarian"/"plan", ...)` guidance that sync-skills.mjs injects into every skill containing OpenCode-only orchestration calls. Only codex-ultrawork-reviewer.toml was bundled, so Codex had no matching agent role to dispatch. An older omo-codex release shipped explorer/librarian/plan TOMLs but without the required top-level `name` field, leaving Codex to warn: Ignoring malformed agent role definition: agent role file at ~/.codex/agents/<name>.toml must define a non-empty `name` This commit bundles three correctly-formed TOMLs into components/ultrawork/agents/. Each has the full schema Codex parses: `name`, `description`, `nickname_candidates`, `model`, `model_reasoning_effort`, `service_tier`, `developer_instructions`. The existing sync-agents.py SessionStart hook installs them via rglob into CODEX_HOME/agents/. Models match the original design: explorer + librarian on gpt-5.4-mini low effort (fast contextual + external research); plan on gpt-5.5 xhigh effort (deep reasoning + interview-style planning). Tests: - test/bundled-agents.test.mjs: locks the sync-hook contract by running sync-agents.py against a temp CODEX_HOME and verifying each TOML lands with the expected name + schema. - test/aggregate.test.mjs: locks the schema keys on every bundled TOML and the spawn_agent contract (every in-scope agent_type referenced by a synced skill has a matching bundle). Follow-up: the sync-skills.mjs compatibility table also references `spawn_agent(agent_type="worker", ...)`. No worker.toml is present in CODEX_HOME and Codex does not warn about its absence, suggesting worker is a built-in Codex role. Confirm and ship worker.toml if not.
130 lines
4.3 KiB
JavaScript
130 lines
4.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { spawn } from "node:child_process";
|
|
import { lstat, mkdtemp, readdir, readFile, rm } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import test from "node:test";
|
|
|
|
const testDir = dirname(fileURLToPath(import.meta.url));
|
|
const pluginRoot = dirname(testDir);
|
|
const componentRoot = join(pluginRoot, "components", "ultrawork");
|
|
const syncAgentsPath = join(componentRoot, "hooks", "sync-agents.py");
|
|
|
|
async function makeTempDir() {
|
|
return mkdtemp(join(tmpdir(), "codex-bundled-agents-"));
|
|
}
|
|
|
|
async function runSyncHook(codexHome) {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn("python3", [syncAgentsPath], {
|
|
env: { ...process.env, CODEX_HOME: codexHome },
|
|
});
|
|
let stdout = "";
|
|
let stderr = "";
|
|
child.stdout.setEncoding("utf8");
|
|
child.stderr.setEncoding("utf8");
|
|
child.stdout.on("data", (chunk) => {
|
|
stdout += chunk;
|
|
});
|
|
child.stderr.on("data", (chunk) => {
|
|
stderr += chunk;
|
|
});
|
|
child.once("error", reject);
|
|
child.once("close", (code) => resolve({ code, stdout, stderr }));
|
|
child.stdin.end('{"hook_event_name":"SessionStart"}');
|
|
});
|
|
}
|
|
|
|
test("#given session start #when sync hook runs #then bundles explorer agent", async () => {
|
|
const codexHome = await makeTempDir();
|
|
try {
|
|
const result = await runSyncHook(codexHome);
|
|
assert.equal(result.code, 0);
|
|
assert.equal(result.stdout, "");
|
|
assert.equal(result.stderr, "");
|
|
|
|
const target = join(codexHome, "agents", "explorer.toml");
|
|
const targetStat = await lstat(target);
|
|
assert.equal(targetStat.isFile(), true);
|
|
assert.equal(targetStat.isSymbolicLink(), false);
|
|
|
|
const content = await readFile(target, "utf8");
|
|
assert.match(content, /^name = "explorer"$/m);
|
|
assert.match(content, /^model = /m);
|
|
assert.match(content, /^model_reasoning_effort = /m);
|
|
assert.match(content, /^developer_instructions = """/m);
|
|
assert.match(content, /codebase search specialist/i);
|
|
} finally {
|
|
await rm(codexHome, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("#given session start #when sync hook runs #then bundles librarian agent", async () => {
|
|
const codexHome = await makeTempDir();
|
|
try {
|
|
const result = await runSyncHook(codexHome);
|
|
assert.equal(result.code, 0);
|
|
assert.equal(result.stdout, "");
|
|
assert.equal(result.stderr, "");
|
|
|
|
const target = join(codexHome, "agents", "librarian.toml");
|
|
const targetStat = await lstat(target);
|
|
assert.equal(targetStat.isFile(), true);
|
|
assert.equal(targetStat.isSymbolicLink(), false);
|
|
|
|
const content = await readFile(target, "utf8");
|
|
assert.match(content, /^name = "librarian"$/m);
|
|
assert.match(content, /^model = /m);
|
|
assert.match(content, /^model_reasoning_effort = /m);
|
|
assert.match(content, /^developer_instructions = """/m);
|
|
assert.match(content, /THE LIBRARIAN/);
|
|
} finally {
|
|
await rm(codexHome, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("#given session start #when sync hook runs #then bundles plan agent into CODEX_HOME/agents", async () => {
|
|
const codexHome = await makeTempDir();
|
|
try {
|
|
const result = await runSyncHook(codexHome);
|
|
assert.equal(result.code, 0);
|
|
assert.equal(result.stdout, "");
|
|
assert.equal(result.stderr, "");
|
|
|
|
const target = join(codexHome, "agents", "plan.toml");
|
|
const targetStat = await lstat(target);
|
|
assert.equal(targetStat.isFile(), true);
|
|
assert.equal(targetStat.isSymbolicLink(), false);
|
|
|
|
const content = await readFile(target, "utf8");
|
|
assert.match(content, /^name = "plan"$/m);
|
|
assert.match(content, /^model = /m);
|
|
assert.match(content, /^model_reasoning_effort = /m);
|
|
assert.match(content, /^developer_instructions = """/m);
|
|
assert.match(content, /strategic planning consultant/i);
|
|
} finally {
|
|
await rm(codexHome, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("#given session start #when sync hook runs #then installs exactly the expected bundled set", async () => {
|
|
const codexHome = await makeTempDir();
|
|
try {
|
|
await runSyncHook(codexHome);
|
|
const entries = await readdir(join(codexHome, "agents"), { withFileTypes: true });
|
|
const names = entries
|
|
.filter((entry) => entry.isFile())
|
|
.map((entry) => entry.name)
|
|
.sort();
|
|
assert.deepEqual(names, [
|
|
"codex-ultrawork-reviewer.toml",
|
|
"explorer.toml",
|
|
"librarian.toml",
|
|
"plan.toml",
|
|
]);
|
|
} finally {
|
|
await rm(codexHome, { recursive: true, force: true });
|
|
}
|
|
});
|