From 05cd133e2a0815ce71522df15982607c73220b57 Mon Sep 17 00:00:00 2001 From: Gladdonilli Date: Sun, 11 Jan 2026 18:02:36 +0800 Subject: [PATCH] fix(git-master): inject user config into skill prompt (#656) --- .../opencode-skill-loader/skill-content.ts | 45 ++++++++++++++++--- src/index.ts | 1 + src/tools/sisyphus-task/tools.ts | 7 +-- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/features/opencode-skill-loader/skill-content.ts b/src/features/opencode-skill-loader/skill-content.ts index a6a058a57..6929ec320 100644 --- a/src/features/opencode-skill-loader/skill-content.ts +++ b/src/features/opencode-skill-loader/skill-content.ts @@ -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 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) } diff --git a/src/index.ts b/src/index.ts index 218c425c5..22e75cba6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -237,6 +237,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => { manager: backgroundManager, client: ctx.client, userCategories: pluginConfig.categories, + gitMasterConfig: pluginConfig.git_master, }); const disabledSkills = new Set(pluginConfig.disabled_skills ?? []); const systemMcpNames = getSystemMcpServerNames(); diff --git a/src/tools/sisyphus-task/tools.ts b/src/tools/sisyphus-task/tools.ts index cfe0b5ba6..42113ca52 100644 --- a/src/tools/sisyphus-task/tools.ts +++ b/src/tools/sisyphus-task/tools.ts @@ -3,7 +3,7 @@ import { existsSync, readdirSync } from "node:fs" import { join } from "node:path" import type { BackgroundManager } from "../../features/background-agent" import type { SisyphusTaskArgs } from "./types" -import type { CategoryConfig, CategoriesConfig } from "../../config/schema" +import type { CategoryConfig, CategoriesConfig, GitMasterConfig } from "../../config/schema" import { SISYPHUS_TASK_DESCRIPTION, DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS } from "./constants" import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector" import { resolveMultipleSkills } from "../../features/opencode-skill-loader/skill-content" @@ -89,6 +89,7 @@ export interface SisyphusTaskToolOptions { manager: BackgroundManager client: OpencodeClient userCategories?: CategoriesConfig + gitMasterConfig?: GitMasterConfig } export interface BuildSystemContentInput { @@ -111,7 +112,7 @@ export function buildSystemContent(input: BuildSystemContentInput): string | und } export function createSisyphusTask(options: SisyphusTaskToolOptions): ToolDefinition { - const { manager, client, userCategories } = options + const { manager, client, userCategories, gitMasterConfig } = options return tool({ description: SISYPHUS_TASK_DESCRIPTION, @@ -136,7 +137,7 @@ export function createSisyphusTask(options: SisyphusTaskToolOptions): ToolDefini let skillContent: string | undefined if (args.skills.length > 0) { - const { resolved, notFound } = resolveMultipleSkills(args.skills) + const { resolved, notFound } = resolveMultipleSkills(args.skills, { gitMasterConfig }) if (notFound.length > 0) { const available = createBuiltinSkills().map(s => s.name).join(", ") return `❌ Skills not found: ${notFound.join(", ")}. Available: ${available}`