fix(git-master): inject user config into skill prompt (#656)

This commit is contained in:
Gladdonilli
2026-01-11 18:02:36 +08:00
committed by GitHub
parent 8ed3f7e03b
commit 05cd133e2a
3 changed files with 44 additions and 9 deletions
@@ -1,12 +1,41 @@
import { createBuiltinSkills } from "../builtin-skills/skills"
import type { GitMasterConfig } from "../../config/schema"
export function resolveSkillContent(skillName: string): string | null {
const skills = createBuiltinSkills()
const skill = skills.find((s) => s.name === skillName)
return skill?.template ?? null
export interface SkillResolutionOptions {
gitMasterConfig?: GitMasterConfig
}
export function resolveMultipleSkills(skillNames: string[]): {
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 {
const skills = createBuiltinSkills()
const skill = skills.find((s) => s.name === skillName)
if (!skill) return null
if (skillName === "git-master" && options?.gitMasterConfig) {
return injectGitMasterConfig(skill.template, options.gitMasterConfig)
}
return skill.template
}
export function resolveMultipleSkills(skillNames: string[], options?: SkillResolutionOptions): {
resolved: Map<string, string>
notFound: string[]
} {
@@ -19,7 +48,11 @@ export function resolveMultipleSkills(skillNames: string[]): {
for (const name of skillNames) {
const template = skillMap.get(name)
if (template) {
resolved.set(name, template)
if (name === "git-master" && options?.gitMasterConfig) {
resolved.set(name, injectGitMasterConfig(template, options.gitMasterConfig))
} else {
resolved.set(name, template)
}
} else {
notFound.push(name)
}