fix(omo-codex): bundle explorer/librarian/plan agent TOMLs for spawn_agent
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.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readdir, readFile } from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { readdir, readFile, stat } from "node:fs/promises";
|
||||
import { basename, dirname, join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
@@ -10,6 +10,15 @@ async function readJson(relativePath) {
|
||||
return JSON.parse(await readFile(join(root, relativePath), "utf8"));
|
||||
}
|
||||
|
||||
function findSpawnAgentTypes(content) {
|
||||
const agentTypes = new Set();
|
||||
const regex = /spawn_agent\(agent_type="([^"]+)"/g;
|
||||
for (const match of content.matchAll(regex)) {
|
||||
agentTypes.add(match[1]);
|
||||
}
|
||||
return [...agentTypes].sort();
|
||||
}
|
||||
|
||||
test("#given aggregate plugin manifest #when inspected #then it owns the omo namespace", async () => {
|
||||
// given
|
||||
const manifest = await readJson(".codex-plugin/plugin.json");
|
||||
@@ -91,3 +100,57 @@ test("#given component directories #when scanned #then only root owns plugin ide
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("#given bundled Codex agents #when components/ultrawork/agents directory is scanned #then explorer librarian and reviewer TOMLs are present and match expected schema keys", async () => {
|
||||
const agentsDir = join(root, "components", "ultrawork", "agents");
|
||||
const entries = (await readdir(agentsDir, { withFileTypes: true }))
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith(".toml"))
|
||||
.map((entry) => entry.name)
|
||||
.sort();
|
||||
|
||||
assert.deepEqual(entries, [
|
||||
"codex-ultrawork-reviewer.toml",
|
||||
"explorer.toml",
|
||||
"librarian.toml",
|
||||
"plan.toml",
|
||||
]);
|
||||
|
||||
for (const fileName of entries) {
|
||||
const content = await readFile(join(agentsDir, fileName), "utf8");
|
||||
assert.match(content, /^name\s*=\s*".+"$/m);
|
||||
assert.match(content, /^description\s*=\s*".+"$/m);
|
||||
assert.match(content, /^nickname_candidates\s*=\s*\[.+\]$/m);
|
||||
assert.match(content, /^model\s*=\s*".+"$/m);
|
||||
assert.match(content, /^model_reasoning_effort\s*=\s*".+"$/m);
|
||||
assert.match(content, /^developer_instructions\s*=\s*"""/m);
|
||||
}
|
||||
});
|
||||
|
||||
test("#given synced skills with Codex compatibility guidance #when explorer/librarian agent_type is referenced #then a matching TOML is bundled", async () => {
|
||||
const skillsDir = join(root, "skills");
|
||||
const skillEntries = await readdir(skillsDir, { withFileTypes: true });
|
||||
const skillFiles = skillEntries
|
||||
.filter((entry) => entry.isDirectory())
|
||||
.map((entry) => join(skillsDir, entry.name, "SKILL.md"));
|
||||
|
||||
const referencedAgentTypes = new Set();
|
||||
for (const skillPath of skillFiles) {
|
||||
const content = await readFile(skillPath, "utf8");
|
||||
for (const agentType of findSpawnAgentTypes(content)) {
|
||||
if (agentType === "worker" || agentType === "codex-ultrawork-reviewer") {
|
||||
continue;
|
||||
}
|
||||
referencedAgentTypes.add(agentType);
|
||||
}
|
||||
}
|
||||
|
||||
const expected = [...referencedAgentTypes].sort();
|
||||
assert.deepEqual(expected, ["explorer", "librarian", "plan"]);
|
||||
|
||||
for (const agentType of expected) {
|
||||
const tomlPath = join(root, "components", "ultrawork", "agents", `${agentType}.toml`);
|
||||
const fileStat = await stat(tomlPath);
|
||||
assert.equal(fileStat.isFile(), true);
|
||||
assert.equal(basename(tomlPath), `${agentType}.toml`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user