fix: propagate project skills to background task sessions (#2687)

prompt-builder.ts now includes project-level skills from
.opencode/skills/ when building delegated session prompts.

5007 tests pass, tsc clean.

Closes #2687
This commit is contained in:
YeonGyu-Kim
2026-04-07 15:24:22 +09:00
parent be562905d6
commit 2465205356
2 changed files with 154 additions and 2 deletions
+29 -2
View File
@@ -1,4 +1,5 @@
import type { BuildSystemContentInput } from "./types"
import type { AvailableSkill } from "../../agents/dynamic-agent-prompt-builder"
import { buildPlanAgentSystemPrepend, isPlanAgent } from "./constants"
import { buildSystemContentWithTokenLimit } from "./token-limiter"
@@ -21,6 +22,22 @@ ${TDD_LINE}`
return PLAN_AGENT_PROMPT_BASE
}
function buildAvailableSkillsSection(skills: AvailableSkill[]): string {
if (skills.length === 0) {
return ""
}
const rows = skills
.map((s) => `- \`${s.name}\`: ${s.description || s.name}`)
.join("\n")
return `<available_skills>
Skills provide specialized instructions. Load via load_skills parameter when delegating tasks.
${rows}
</available_skills>`
}
function usesFreeOrLocalModel(model: { providerID: string; modelID: string; variant?: string } | undefined): boolean {
if (!model) {
return false
@@ -51,10 +68,20 @@ export function buildSystemContent(input: BuildSystemContentInput): string | und
availableSkills,
} = input
const planAgentPrepend = isPlanAgent(agentName)
const isPlan = isPlanAgent(agentName)
const planAgentPrepend = isPlan
? buildPlanAgentSystemPrepend(availableCategories, availableSkills)
: ""
const skillsSection = !isPlan
? buildAvailableSkillsSection(availableSkills ?? [])
: ""
const baseAgentsContext = agentsContext ?? planAgentPrepend
const effectiveAgentsContext = !isPlan && skillsSection
? [baseAgentsContext, skillsSection].filter(Boolean).join("\n\n")
: baseAgentsContext
const effectiveMaxPromptTokens = maxPromptTokens
?? (usesFreeOrLocalModel(model) ? FREE_OR_LOCAL_PROMPT_TOKEN_LIMIT : undefined)
@@ -63,7 +90,7 @@ export function buildSystemContent(input: BuildSystemContentInput): string | und
skillContent,
skillContents,
categoryPromptAppend,
agentsContext: agentsContext ?? planAgentPrepend,
agentsContext: effectiveAgentsContext,
planAgentPrepend,
},
effectiveMaxPromptTokens