fix(git-master): inject user config into skill prompt (#656)
This commit is contained in:
parent
8ed3f7e03b
commit
05cd133e2a
@ -1,12 +1,41 @@
|
|||||||
import { createBuiltinSkills } from "../builtin-skills/skills"
|
import { createBuiltinSkills } from "../builtin-skills/skills"
|
||||||
|
import type { GitMasterConfig } from "../../config/schema"
|
||||||
|
|
||||||
export function resolveSkillContent(skillName: string): string | null {
|
export interface SkillResolutionOptions {
|
||||||
const skills = createBuiltinSkills()
|
gitMasterConfig?: GitMasterConfig
|
||||||
const skill = skills.find((s) => s.name === skillName)
|
|
||||||
return skill?.template ?? null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
resolved: Map<string, string>
|
||||||
notFound: string[]
|
notFound: string[]
|
||||||
} {
|
} {
|
||||||
@ -19,7 +48,11 @@ export function resolveMultipleSkills(skillNames: string[]): {
|
|||||||
for (const name of skillNames) {
|
for (const name of skillNames) {
|
||||||
const template = skillMap.get(name)
|
const template = skillMap.get(name)
|
||||||
if (template) {
|
if (template) {
|
||||||
|
if (name === "git-master" && options?.gitMasterConfig) {
|
||||||
|
resolved.set(name, injectGitMasterConfig(template, options.gitMasterConfig))
|
||||||
|
} else {
|
||||||
resolved.set(name, template)
|
resolved.set(name, template)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
notFound.push(name)
|
notFound.push(name)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -237,6 +237,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
|
|||||||
manager: backgroundManager,
|
manager: backgroundManager,
|
||||||
client: ctx.client,
|
client: ctx.client,
|
||||||
userCategories: pluginConfig.categories,
|
userCategories: pluginConfig.categories,
|
||||||
|
gitMasterConfig: pluginConfig.git_master,
|
||||||
});
|
});
|
||||||
const disabledSkills = new Set(pluginConfig.disabled_skills ?? []);
|
const disabledSkills = new Set(pluginConfig.disabled_skills ?? []);
|
||||||
const systemMcpNames = getSystemMcpServerNames();
|
const systemMcpNames = getSystemMcpServerNames();
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { existsSync, readdirSync } from "node:fs"
|
|||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import type { BackgroundManager } from "../../features/background-agent"
|
import type { BackgroundManager } from "../../features/background-agent"
|
||||||
import type { SisyphusTaskArgs } from "./types"
|
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 { SISYPHUS_TASK_DESCRIPTION, DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS } from "./constants"
|
||||||
import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector"
|
||||||
import { resolveMultipleSkills } from "../../features/opencode-skill-loader/skill-content"
|
import { resolveMultipleSkills } from "../../features/opencode-skill-loader/skill-content"
|
||||||
@ -89,6 +89,7 @@ export interface SisyphusTaskToolOptions {
|
|||||||
manager: BackgroundManager
|
manager: BackgroundManager
|
||||||
client: OpencodeClient
|
client: OpencodeClient
|
||||||
userCategories?: CategoriesConfig
|
userCategories?: CategoriesConfig
|
||||||
|
gitMasterConfig?: GitMasterConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BuildSystemContentInput {
|
export interface BuildSystemContentInput {
|
||||||
@ -111,7 +112,7 @@ export function buildSystemContent(input: BuildSystemContentInput): string | und
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createSisyphusTask(options: SisyphusTaskToolOptions): ToolDefinition {
|
export function createSisyphusTask(options: SisyphusTaskToolOptions): ToolDefinition {
|
||||||
const { manager, client, userCategories } = options
|
const { manager, client, userCategories, gitMasterConfig } = options
|
||||||
|
|
||||||
return tool({
|
return tool({
|
||||||
description: SISYPHUS_TASK_DESCRIPTION,
|
description: SISYPHUS_TASK_DESCRIPTION,
|
||||||
@ -136,7 +137,7 @@ export function createSisyphusTask(options: SisyphusTaskToolOptions): ToolDefini
|
|||||||
|
|
||||||
let skillContent: string | undefined
|
let skillContent: string | undefined
|
||||||
if (args.skills.length > 0) {
|
if (args.skills.length > 0) {
|
||||||
const { resolved, notFound } = resolveMultipleSkills(args.skills)
|
const { resolved, notFound } = resolveMultipleSkills(args.skills, { gitMasterConfig })
|
||||||
if (notFound.length > 0) {
|
if (notFound.length > 0) {
|
||||||
const available = createBuiltinSkills().map(s => s.name).join(", ")
|
const available = createBuiltinSkills().map(s => s.name).join(", ")
|
||||||
return `❌ Skills not found: ${notFound.join(", ")}. Available: ${available}`
|
return `❌ Skills not found: ${notFound.join(", ")}. Available: ${available}`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user