feat: fix skill transformation pipeline across all targets (#334)

This commit is contained in:
Trevin Chow
2026-03-21 19:45:20 -07:00
committed by GitHub
parent 0f6448d81c
commit 4087e1df82
33 changed files with 624 additions and 86 deletions

View File

@@ -90,16 +90,19 @@ function convertAgent(agent: ClaudeAgent, usedNames: Set<string>): PiGeneratedSk
}
}
function transformContentForPi(body: string): string {
export function transformContentForPi(body: string): string {
let result = body
// Task repo-research-analyst(feature_description)
// Task repo-research-analyst(feature_description) or Task compound-engineering:research:repo-research-analyst(args)
// -> Run subagent with agent="repo-research-analyst" and task="feature_description"
const taskPattern = /^(\s*-?\s*)Task\s+([a-z][a-z0-9-]*)\(([^)]+)\)/gm
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 finalSegment = agentName.includes(":") ? agentName.split(":").pop()! : agentName
const skillName = normalizeName(finalSegment)
const trimmedArgs = args.trim().replace(/\s+/g, " ")
return `${prefix}Run subagent with agent=\"${skillName}\" and task=\"${trimmedArgs}\".`
return trimmedArgs
? `${prefix}Run subagent with agent=\"${skillName}\" and task=\"${trimmedArgs}\".`
: `${prefix}Run subagent with agent=\"${skillName}\".`
})
// Claude-specific tool references