Deliver the Codex asset-producer subagent reliably (#161)

Codex reads custom subagents from .codex/agents/*.toml, a directory
separate from where it reads skills (.agents/skills). Skill installers
(notably `npx skills add`, see vercel-labs/skills#1290) only carry the
skills/ subtree, so the asset-producer agent was never delivered.

- build: bundle the codex .toml inside the skill dir for the variants
  Codex loads as a skill (agents, codex), so it travels with the skill.
- cli: skills install/update now write .codex/agents/ for Codex-likely
  projects (a .agents target or a global ~/.codex); update heals a
  missing sidecar. Non-Codex projects are untouched.
- context.mjs: on boot under a Codex install, emit a self-healing
  CODEX_AGENT_MISSING directive pointing at the bundled copy when the
  project's .codex/agents/ definition is absent. Self-resolves on copy.

CLI 2.2.0 -> 2.3.0 (published). Skill stays 3.5.0 (unpublished); the
note is folded into the existing 3.5.0 changelog entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-05-28 15:07:40 -07:00
co-authored by Claude Opus 4.8
parent e58a4c571f
commit 7253b3870a
19 changed files with 1056 additions and 28 deletions
+21
View File
@@ -49,6 +49,12 @@ const FIELD_SPECS = {
},
};
// Provider builds that Codex loads as a skill (it reads skills from .agents/skills,
// and the .codex build mirrors it). For these, the Codex subagent .toml also travels
// INSIDE the skill dir so context.mjs can point a running Codex agent at a local copy
// when the sibling .codex/agents/ definition is missing (see skill/scripts/context.mjs).
const CODEX_SKILL_PROVIDERS = new Set(['agents', 'codex']);
function humanizeSkillName(name) {
return name
.split('-')
@@ -259,6 +265,21 @@ export function createTransformer(config) {
scriptCount++;
}
}
// Bundle the Codex subagent .toml inside the skill dir for the variants
// Codex actually loads. The sibling .codex/agents/ definition is what Codex
// reads at runtime, but installers (notably `npx skills add`) only carry the
// skills/ subtree -- so context.mjs uses this in-skill copy to self-heal.
if (CODEX_SKILL_PROVIDERS.has(provider)) {
for (const agent of skill.agents || []) {
if (agent.providers && !agent.providers.includes('codex')) continue;
let agentBody = compileProviderBlocks(agent.body, providerTags);
agentBody = replacePlaceholders(agentBody, placeholderKey, [], allSkillNames);
const filename = `${agent.codexName || agent.name.replace(/-/g, '_')}.toml`;
ensureDir(path.join(skillDir, 'agents'));
writeFile(path.join(skillDir, 'agents', filename), buildCodexAgent(agent, agentBody));
}
}
}
if (config.agentFormat) {