2026-01-09 02:24:43 +09:00
|
|
|
import { createBuiltinSkills } from "../builtin-skills/skills"
|
2026-01-11 18:02:36 +08:00
|
|
|
import type { GitMasterConfig } from "../../config/schema"
|
2026-01-09 02:24:43 +09:00
|
|
|
|
2026-01-11 18:02:36 +08:00
|
|
|
export interface SkillResolutionOptions {
|
|
|
|
|
gitMasterConfig?: GitMasterConfig
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function injectGitMasterConfig(template: string, config?: GitMasterConfig): string {
|
|
|
|
|
if (!config) return template
|
|
|
|
|
|
|
|
|
|
const commitFooter = config.commit_footer ?? true
|
|
|
|
|
const includeCoAuthoredBy = config.include_co_authored_by ?? true
|
|
|
|
|
|
|
|
|
|
const configHeader = `## Git Master Configuration (from oh-my-opencode.json)
|
|
|
|
|
|
|
|
|
|
**IMPORTANT: These values override the defaults in section 5.5:**
|
|
|
|
|
- \`commit_footer\`: ${commitFooter} ${!commitFooter ? "(DISABLED - do NOT add footer)" : ""}
|
|
|
|
|
- \`include_co_authored_by\`: ${includeCoAuthoredBy} ${!includeCoAuthoredBy ? "(DISABLED - do NOT add Co-authored-by)" : ""}
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
`
|
|
|
|
|
return configHeader + template
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function resolveSkillContent(skillName: string, options?: SkillResolutionOptions): string | null {
|
2026-01-09 02:24:43 +09:00
|
|
|
const skills = createBuiltinSkills()
|
|
|
|
|
const skill = skills.find((s) => s.name === skillName)
|
2026-01-11 18:02:36 +08:00
|
|
|
if (!skill) return null
|
|
|
|
|
|
|
|
|
|
if (skillName === "git-master" && options?.gitMasterConfig) {
|
|
|
|
|
return injectGitMasterConfig(skill.template, options.gitMasterConfig)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return skill.template
|
2026-01-09 02:24:43 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-11 18:02:36 +08:00
|
|
|
export function resolveMultipleSkills(skillNames: string[], options?: SkillResolutionOptions): {
|
2026-01-09 02:24:43 +09:00
|
|
|
resolved: Map<string, string>
|
|
|
|
|
notFound: string[]
|
|
|
|
|
} {
|
|
|
|
|
const skills = createBuiltinSkills()
|
|
|
|
|
const skillMap = new Map(skills.map((s) => [s.name, s.template]))
|
|
|
|
|
|
|
|
|
|
const resolved = new Map<string, string>()
|
|
|
|
|
const notFound: string[] = []
|
|
|
|
|
|
|
|
|
|
for (const name of skillNames) {
|
|
|
|
|
const template = skillMap.get(name)
|
|
|
|
|
if (template) {
|
2026-01-11 18:02:36 +08:00
|
|
|
if (name === "git-master" && options?.gitMasterConfig) {
|
|
|
|
|
resolved.set(name, injectGitMasterConfig(template, options.gitMasterConfig))
|
|
|
|
|
} else {
|
|
|
|
|
resolved.set(name, template)
|
|
|
|
|
}
|
2026-01-09 02:24:43 +09:00
|
|
|
} else {
|
|
|
|
|
notFound.push(name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { resolved, notFound }
|
|
|
|
|
}
|