fix(git-master): inject user config into skill prompt (#656)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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}`
|
||||
|
||||
Reference in New Issue
Block a user