* feat(commands): add /compound-engineering-setup for configurable agents Adds a new setup command that allows users to configure which review agents to use instead of hardcoding them in workflows. This enables: - Multi-step onboarding with AskUserQuestion for easy setup - Auto-detection of project type (Rails, Python, TypeScript, etc.) - Three setup modes: Quick (smart defaults), Advanced, and Minimal - Configuration stored in .claude/compound-engineering.json - Support for both global (~/.claude/) and project-specific config Updated workflows to read from config: - /workflows:review - reads reviewAgents from config - /plan_review - reads planReviewAgents from config - /workflows:work - references config for reviewer agents - /workflows:compound - references config for specialized agents 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: auto-trigger setup when no config exists Workflows now detect missing config and offer inline quick setup: - "Quick Setup" - auto-detect project type, create config, continue - "Full Setup" - run /compound-engineering-setup for customization - "Skip" - use defaults just this once This ensures users get onboarded automatically when running any workflow for the first time, without needing to know about the setup command beforehand. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(review): wire all conditionalAgents categories Extended /workflows:review to invoke conditional agents for: - migrations (existing) - frontend (new): JS/TS/Stimulus changes - architecture (new): structural changes, 10+ files - data (new): model/ActiveRecord changes Each category reads from conditionalAgents.* config key and runs appropriate specialized agents when file patterns match. Resolves: todos/001-ready-p2-conditional-agents-not-invoked.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: mark todo #001 as complete * feat(setup): add custom agent discovery and modify flow - Auto-detect custom agents in .claude/agents/ and ~/.claude/agents/ - Add modify existing config flow (add/remove agents, view config) - Include guide for creating custom review agents - Add customAgents mapping in config to track agent file paths - Update changelog with new config schema including customAgents Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * chore: remove completed todos directory Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * [2.29.1] Improve /workflows:brainstorm question flow - Add "Ask more questions" option at handoff phase - Clarify that Claude should ask the user questions (not wait for user) - Require resolving ALL open questions before offering to proceed Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Simplify plugin settings: replace 486-line wizard with .local.md pattern - Rewrite setup.md (486 → 95 lines): detect project type, create .claude/compound-engineering.local.md with smart defaults - Make review.md and work.md config-aware: read agents from .local.md frontmatter, fall back to auto-detected defaults - Wire schema-drift-detector into review.md migrations conditional block - Delete technical_review.md (duplicated /plan_review) - Add disable-model-invocation to setup.md - Bump to v2.32.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Rewrite .claude/ paths for OpenCode/Codex targets, add npm publish workflow - Converters now rewrite .claude/ → .opencode/ (OpenCode) and .codex/ (Codex) in command bodies and agent bodies so .local.md settings work cross-platform - Apply transformContentForCodex to agent bodies (was only commands before) - Add GitHub Action to auto-publish to npm on version bump merge to main - Bump to v0.4.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(workflows-work): require post-deploy monitoring section Add a mandatory Post-Deploy Monitoring & Validation section to the /workflows:work PR template, include no-impact fallback guidance, and enforce it in the quality checklist. * Add learnings-researcher to review workflow, fix docs site counts - Add learnings-researcher as parallel agent #14 in /workflows:review so past solutions from docs/solutions/ are surfaced during code review - Make /release-docs command invocable (remove disable-model-invocation) - Fix stale counts across docs site (agents 28→29, commands 19→24, skills 15→18, MCP servers 2→1) - Bump version to 2.32.1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move /release-docs to local .claude/commands/, bump to 2.32.2 Repo maintenance command doesn't need to be distributed to plugin users. Update command count 24 → 23 across plugin.json, marketplace.json, and docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move settings to project root: compound-engineering.local.md Tool-agnostic location — works for Claude, Codex, OpenCode without path rewriting. No global fallback, just project root. Update commands (setup, review, work) and converter tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Make /compound-engineering-setup interactive with auto-detect fast path Two paths: "Auto-configure" (one click, smart defaults) or "Customize" (pick stack, focus areas, review depth). Uses AskUserQuestion throughout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Replace /compound-engineering-setup command with setup skill Setup is now a skill invoked on-demand when compound-engineering.local.md doesn't exist. Review and work commands just say "invoke the setup skill" instead of inlining the full setup flow. - Remove commands/setup.md (command) - Add skills/setup/SKILL.md (skill with interactive AskUserQuestion flow) - Simplify review.md and work.md to reference the skill - Counts: 29 agents, 22 commands, 19 skills Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Prepare v2.33.0 release: setup skill, configurable review agents - Bump version to 2.33.0 - Consolidate CHANGELOG entries for this branch - Fix README: update counts (29/22/19), add setup + resolve-pr-parallel skills - Remove stale /compound-engineering-setup command reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
188 lines
7.0 KiB
TypeScript
188 lines
7.0 KiB
TypeScript
import { formatFrontmatter } from "../utils/frontmatter"
|
|
import type { ClaudeAgent, ClaudeCommand, ClaudePlugin } from "../types/claude"
|
|
import type { CodexBundle, CodexGeneratedSkill } from "../types/codex"
|
|
import type { ClaudeToOpenCodeOptions } from "./claude-to-opencode"
|
|
|
|
export type ClaudeToCodexOptions = ClaudeToOpenCodeOptions
|
|
|
|
const CODEX_DESCRIPTION_MAX_LENGTH = 1024
|
|
|
|
export function convertClaudeToCodex(
|
|
plugin: ClaudePlugin,
|
|
_options: ClaudeToCodexOptions,
|
|
): CodexBundle {
|
|
const promptNames = new Set<string>()
|
|
const skillDirs = plugin.skills.map((skill) => ({
|
|
name: skill.name,
|
|
sourceDir: skill.sourceDir,
|
|
}))
|
|
|
|
const usedSkillNames = new Set<string>(skillDirs.map((skill) => normalizeName(skill.name)))
|
|
const commandSkills: CodexGeneratedSkill[] = []
|
|
const invocableCommands = plugin.commands.filter((command) => !command.disableModelInvocation)
|
|
const prompts = invocableCommands.map((command) => {
|
|
const promptName = uniqueName(normalizeName(command.name), promptNames)
|
|
const commandSkill = convertCommandSkill(command, usedSkillNames)
|
|
commandSkills.push(commandSkill)
|
|
const content = renderPrompt(command, commandSkill.name)
|
|
return { name: promptName, content }
|
|
})
|
|
|
|
const agentSkills = plugin.agents.map((agent) => convertAgent(agent, usedSkillNames))
|
|
const generatedSkills = [...commandSkills, ...agentSkills]
|
|
|
|
return {
|
|
prompts,
|
|
skillDirs,
|
|
generatedSkills,
|
|
mcpServers: plugin.mcpServers,
|
|
}
|
|
}
|
|
|
|
function convertAgent(agent: ClaudeAgent, usedNames: Set<string>): CodexGeneratedSkill {
|
|
const name = uniqueName(normalizeName(agent.name), usedNames)
|
|
const description = sanitizeDescription(
|
|
agent.description ?? `Converted from Claude agent ${agent.name}`,
|
|
)
|
|
const frontmatter: Record<string, unknown> = { name, description }
|
|
|
|
let body = transformContentForCodex(agent.body.trim())
|
|
if (agent.capabilities && agent.capabilities.length > 0) {
|
|
const capabilities = agent.capabilities.map((capability) => `- ${capability}`).join("\n")
|
|
body = `## Capabilities\n${capabilities}\n\n${body}`.trim()
|
|
}
|
|
if (body.length === 0) {
|
|
body = `Instructions converted from the ${agent.name} agent.`
|
|
}
|
|
|
|
const content = formatFrontmatter(frontmatter, body)
|
|
return { name, content }
|
|
}
|
|
|
|
function convertCommandSkill(command: ClaudeCommand, usedNames: Set<string>): CodexGeneratedSkill {
|
|
const name = uniqueName(normalizeName(command.name), usedNames)
|
|
const frontmatter: Record<string, unknown> = {
|
|
name,
|
|
description: sanitizeDescription(
|
|
command.description ?? `Converted from Claude command ${command.name}`,
|
|
),
|
|
}
|
|
const sections: string[] = []
|
|
if (command.argumentHint) {
|
|
sections.push(`## Arguments\n${command.argumentHint}`)
|
|
}
|
|
if (command.allowedTools && command.allowedTools.length > 0) {
|
|
sections.push(`## Allowed tools\n${command.allowedTools.map((tool) => `- ${tool}`).join("\n")}`)
|
|
}
|
|
// Transform Task agent calls to Codex skill references
|
|
const transformedBody = transformTaskCalls(command.body.trim())
|
|
sections.push(transformedBody)
|
|
const body = sections.filter(Boolean).join("\n\n").trim()
|
|
const content = formatFrontmatter(frontmatter, body.length > 0 ? body : command.body)
|
|
return { name, content }
|
|
}
|
|
|
|
/**
|
|
* Transform Claude Code content to Codex-compatible content.
|
|
*
|
|
* Handles multiple syntax differences:
|
|
* 1. Task agent calls: Task agent-name(args) → Use the $agent-name skill to: args
|
|
* 2. Slash commands: /command-name → /prompts:command-name
|
|
* 3. Agent references: @agent-name → $agent-name skill
|
|
*
|
|
* This bridges the gap since Claude Code and Codex have different syntax
|
|
* for invoking commands, agents, and skills.
|
|
*/
|
|
function transformContentForCodex(body: string): string {
|
|
let result = body
|
|
|
|
// 1. Transform Task agent calls
|
|
// Match: Task repo-research-analyst(feature_description)
|
|
// Match: - Task learnings-researcher(args)
|
|
const taskPattern = /^(\s*-?\s*)Task\s+([a-z][a-z0-9-]*)\(([^)]+)\)/gm
|
|
result = result.replace(taskPattern, (_match, prefix: string, agentName: string, args: string) => {
|
|
const skillName = normalizeName(agentName)
|
|
const trimmedArgs = args.trim()
|
|
return `${prefix}Use the $${skillName} skill to: ${trimmedArgs}`
|
|
})
|
|
|
|
// 2. Transform slash command references
|
|
// Match: /command-name or /workflows:command but NOT /path/to/file or URLs
|
|
// Look for slash commands in contexts like "Run /command", "use /command", etc.
|
|
// Avoid matching file paths (contain multiple slashes) or URLs (contain ://)
|
|
const slashCommandPattern = /(?<![:\w])\/([a-z][a-z0-9_:-]*?)(?=[\s,."')\]}`]|$)/gi
|
|
result = result.replace(slashCommandPattern, (match, commandName: string) => {
|
|
// Skip if it looks like a file path (contains /)
|
|
if (commandName.includes('/')) return match
|
|
// Skip common non-command patterns
|
|
if (['dev', 'tmp', 'etc', 'usr', 'var', 'bin', 'home'].includes(commandName)) return match
|
|
// Transform to Codex prompt syntax
|
|
const normalizedName = normalizeName(commandName)
|
|
return `/prompts:${normalizedName}`
|
|
})
|
|
|
|
// 3. Rewrite .claude/ paths to .codex/
|
|
result = result
|
|
.replace(/~\/\.claude\//g, "~/.codex/")
|
|
.replace(/\.claude\//g, ".codex/")
|
|
|
|
// 4. Transform @agent-name references
|
|
// Match: @agent-name in text (not emails)
|
|
const agentRefPattern = /@([a-z][a-z0-9-]*-(?:agent|reviewer|researcher|analyst|specialist|oracle|sentinel|guardian|strategist))/gi
|
|
result = result.replace(agentRefPattern, (_match, agentName: string) => {
|
|
const skillName = normalizeName(agentName)
|
|
return `$${skillName} skill`
|
|
})
|
|
|
|
return result
|
|
}
|
|
|
|
// Alias for backward compatibility
|
|
const transformTaskCalls = transformContentForCodex
|
|
|
|
function renderPrompt(command: ClaudeCommand, skillName: string): string {
|
|
const frontmatter: Record<string, unknown> = {
|
|
description: command.description,
|
|
"argument-hint": command.argumentHint,
|
|
}
|
|
const instructions = `Use the $${skillName} skill for this command and follow its instructions.`
|
|
// Transform Task calls in prompt body too (not just skill body)
|
|
const transformedBody = transformTaskCalls(command.body)
|
|
const body = [instructions, "", transformedBody].join("\n").trim()
|
|
return formatFrontmatter(frontmatter, body)
|
|
}
|
|
|
|
function normalizeName(value: string): string {
|
|
const trimmed = value.trim()
|
|
if (!trimmed) return "item"
|
|
const normalized = trimmed
|
|
.toLowerCase()
|
|
.replace(/[\\/]+/g, "-")
|
|
.replace(/[:\s]+/g, "-")
|
|
.replace(/[^a-z0-9_-]+/g, "-")
|
|
.replace(/-+/g, "-")
|
|
.replace(/^-+|-+$/g, "")
|
|
return normalized || "item"
|
|
}
|
|
|
|
function sanitizeDescription(value: string, maxLength = CODEX_DESCRIPTION_MAX_LENGTH): string {
|
|
const normalized = value.replace(/\s+/g, " ").trim()
|
|
if (normalized.length <= maxLength) return normalized
|
|
const ellipsis = "..."
|
|
return normalized.slice(0, Math.max(0, maxLength - ellipsis.length)).trimEnd() + ellipsis
|
|
}
|
|
|
|
function uniqueName(base: string, used: Set<string>): string {
|
|
if (!used.has(base)) {
|
|
used.add(base)
|
|
return base
|
|
}
|
|
let index = 2
|
|
while (used.has(`${base}-${index}`)) {
|
|
index += 1
|
|
}
|
|
const name = `${base}-${index}`
|
|
used.add(name)
|
|
return name
|
|
}
|