fix: resolve 25 pre-publish blockers

- postinstall.mjs: fix alias package detection
- migrate-legacy-plugin-entry: dedupe + regression tests
- task_system: default consistency across runtime paths
- task() contract: consistent tool behavior
- runtime model selection, tool cap, stale-task cancellation
- recovery sanitization, context-limit gating
- Ralph semantic DONE hardening, Atlas fallback persistence
- native-skill description/content, skill path traversal guard
- publish workflow: platform awaited via reusable workflow job
- release: version edits reapplied before commit/tag
- JSONC plugin migration: top-level plugin key safety
- cold-cache: user fallback models skip disconnected providers
- docs/version/release framing updates

Verified: bun test (4599 pass), tsc --noEmit clean, bun run build clean
This commit is contained in:
YeonGyu-Kim
2026-03-28 15:24:18 +09:00
parent 44b039bef6
commit d2c576c510
62 changed files with 1264 additions and 292 deletions
@@ -76,7 +76,9 @@ describe("resolveModelForDelegateTask", () => {
})
describe("#when availableModels is empty (cache exists but empty)", () => {
test("#then falls through to category default model (existing behavior)", () => {
test("#then keeps the category default when its provider is connected", () => {
const readConnectedProvidersSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["anthropic"])
const result = resolveModelForDelegateTask({
categoryDefaultModel: "anthropic/claude-sonnet-4-6",
fallbackChain: [
@@ -87,6 +89,40 @@ describe("resolveModelForDelegateTask", () => {
})
expect(result).toEqual({ model: "anthropic/claude-sonnet-4-6" })
readConnectedProvidersSpy.mockRestore()
})
test("#then skips a disconnected category default and resolves via a connected fallback", () => {
const readConnectedProvidersSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["openai"])
const result = resolveModelForDelegateTask({
categoryDefaultModel: "anthropic/claude-sonnet-4-6",
fallbackChain: [
{ providers: ["openai"], model: "gpt-5.4", variant: "high" },
],
availableModels: new Set(),
systemDefaultModel: "anthropic/claude-sonnet-4-6",
})
expect(result).toEqual({
model: "openai/gpt-5.4",
variant: "high",
fallbackEntry: { providers: ["openai"], model: "gpt-5.4", variant: "high" },
matchedFallback: true,
})
readConnectedProvidersSpy.mockRestore()
})
test("#then skips disconnected user fallback models and keeps the first connected fallback", () => {
const readConnectedProvidersSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["openai"])
const result = resolveModelForDelegateTask({
userFallbackModels: ["anthropic/claude-sonnet-4-6", "openai/gpt-5.4"],
availableModels: new Set(),
})
expect(result).toEqual({ model: "openai/gpt-5.4", matchedFallback: true })
readConnectedProvidersSpy.mockRestore()
})
})
@@ -225,16 +261,23 @@ describe("resolveModelForDelegateTask", () => {
})
describe("#when availableModels is empty", () => {
test("#then falls through to existing resolution (cache partially ready)", () => {
test("#then uses connected providers to avoid disconnected category defaults", () => {
const readConnectedProvidersSpy = spyOn(connectedProvidersCache, "readConnectedProvidersCache").mockReturnValue(["openai"])
const result = resolveModelForDelegateTask({
categoryDefaultModel: "anthropic/claude-sonnet-4-6",
fallbackChain: [
{ providers: ["anthropic"], model: "claude-sonnet-4-6" },
{ providers: ["openai"], model: "gpt-5.4" },
],
availableModels: new Set(),
})
expect(result).toBeDefined()
expect(result).toEqual({
model: "openai/gpt-5.4",
fallbackEntry: { providers: ["openai"], model: "gpt-5.4" },
matchedFallback: true,
})
readConnectedProvidersSpy.mockRestore()
})
})
})
+24 -5
View File
@@ -59,6 +59,8 @@ export function resolveModelForDelegateTask(input: {
return { model: userModel }
}
const connectedProviders = input.availableModels.size === 0 ? readConnectedProvidersCache() : null
// Before provider cache is created (first run), skip model resolution entirely.
// OpenCode will use its system default model when no model is specified in the prompt.
if (input.availableModels.size === 0 && !hasProviderModelsCache() && !hasConnectedProvidersCache()) {
@@ -77,7 +79,15 @@ export function resolveModelForDelegateTask(input: {
}
if (input.availableModels.size === 0) {
return { model: categoryDefault }
const categoryProvider = categoryDefault.includes("/") ? categoryDefault.split("/")[0] : undefined
if (!connectedProviders || !categoryProvider || connectedProviders.includes(categoryProvider)) {
return { model: categoryDefault }
}
log("[resolveModelForDelegateTask] skipping disconnected category default on cold cache", {
categoryDefault,
connectedProviders,
})
}
const parts = categoryDefault.split("/")
@@ -95,9 +105,19 @@ export function resolveModelForDelegateTask(input: {
const userFallbackModels = input.userFallbackModels
if (userFallbackModels && userFallbackModels.length > 0) {
if (input.availableModels.size === 0) {
const first = userFallbackModels[0] ? parseUserFallbackModel(userFallbackModels[0]) : undefined
if (first) {
return { model: first.baseModel, variant: first.variant, matchedFallback: true }
for (const fallbackModel of userFallbackModels) {
const parsedFallback = parseUserFallbackModel(fallbackModel)
if (!parsedFallback) continue
if (
connectedProviders &&
parsedFallback.providerHint &&
!parsedFallback.providerHint.some((provider) => connectedProviders.includes(provider))
) {
continue
}
return { model: parsedFallback.baseModel, variant: parsedFallback.variant, matchedFallback: true }
}
} else {
for (const fallbackModel of userFallbackModels) {
@@ -115,7 +135,6 @@ export function resolveModelForDelegateTask(input: {
const fallbackChain = input.fallbackChain
if (fallbackChain && fallbackChain.length > 0) {
if (input.availableModels.size === 0) {
const connectedProviders = readConnectedProvidersCache()
if (connectedProviders) {
const connectedSet = new Set(connectedProviders)
for (const entry of fallbackChain) {
+4 -4
View File
@@ -76,13 +76,13 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
- category: For task delegation (uses Sisyphus-Junior with category-optimized model)
- subagent_type: For direct agent invocation (explore, librarian, oracle, etc.)
**DO NOT provide both.** If category is provided, subagent_type is ignored.
**DO NOT provide both.** category and subagent_type are mutually exclusive.
- load_skills: ALWAYS REQUIRED. Pass [] if no skills needed, or ["skill-1", "skill-2"] for category tasks.
- category: Use predefined category → Spawns Sisyphus-Junior with category config
Available categories:
${categoryList}
- subagent_type: Use specific agent directly (explore, librarian, oracle, metis, momus)
- subagent_type: Use a specific callable non-primary agent directly (for example: explore, librarian, oracle, metis, momus)
- run_in_background: REQUIRED. true=async (returns task_id), false=sync (waits). Use background=true ONLY for parallel exploration with 5+ independent queries.
- session_id: Existing Task session to continue (from previous task output). Continues agent with FULL CONTEXT PRESERVED - saves tokens, maintains continuity.
- command: The command that triggered this task (optional, for slash command tracking).
@@ -102,7 +102,7 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
prompt: tool.schema.string().describe("Full detailed prompt for the agent"),
run_in_background: tool.schema.boolean().describe("REQUIRED. true=async (returns task_id), false=sync (waits). Use false for task delegation, true ONLY for parallel exploration."),
category: tool.schema.string().optional().describe(`REQUIRED if subagent_type not provided. Do NOT provide both category and subagent_type.`),
subagent_type: tool.schema.string().optional().describe("REQUIRED if category not provided. Do NOT provide both category and subagent_type. Valid values: explore, librarian, oracle, metis, momus"),
subagent_type: tool.schema.string().optional().describe("REQUIRED if category not provided. Do NOT provide both category and subagent_type. Must be a callable non-primary agent name returned by app.agents()."),
session_id: tool.schema.string().optional().describe("Existing Task session to continue"),
command: tool.schema.string().optional().describe("The command that triggered this task"),
},
@@ -115,7 +115,7 @@ export function createDelegateTask(options: DelegateTaskToolOptions): ToolDefini
` - You provided: category="${args.category}", subagent_type="${args.subagent_type}"\n` +
` - Use category for task delegation (e.g., category="${categoryExamples.split(", ")[0]}")\n` +
` - Use subagent_type for direct agent invocation (e.g., subagent_type="explore")\n` +
` - Valid subagent_type values: explore, librarian, oracle, metis, momus`
` - subagent_type must be a callable non-primary agent name returned by app.agents()`
)
}
if (args.category) {
+28 -1
View File
@@ -616,6 +616,33 @@ describe("skill tool - browserProvider forwarding", () => {
})
describe("skill tool - nativeSkills integration", () => {
it("includes native skills in the description even when skills are pre-seeded", async () => {
//#given
const tool = createSkillTool({
skills: [createMockSkill("seeded-skill")],
nativeSkills: {
async all() {
return [{
name: "native-visible-skill",
description: "Native skill exposed from config",
location: "/external/skills/native-visible-skill/SKILL.md",
content: "Native visible skill body",
}]
},
async get() { return undefined },
async dirs() { return [] },
},
})
//#when
expect(tool.description).toContain("seeded-skill")
await tool.execute({ name: "native-visible-skill" }, mockContext)
//#then
expect(tool.description).toContain("seeded-skill")
expect(tool.description).toContain("native-visible-skill")
})
it("merges native skills exposed by PluginInput.skills.all()", async () => {
//#given
const tool = createSkillTool({
@@ -639,6 +666,6 @@ describe("skill tool - nativeSkills integration", () => {
//#then
expect(result).toContain("external-plugin-skill")
expect(result).toContain("Test skill body content")
expect(result).toContain("External plugin skill body")
})
})
+12 -2
View File
@@ -105,6 +105,11 @@ async function extractSkillBody(skill: LoadedSkill): Promise<string> {
return templateMatch ? templateMatch[1].trim() : fullTemplate
}
if (skill.scope === "config" && skill.definition.template) {
const templateMatch = skill.definition.template.match(/<skill-instruction>([\s\S]*?)<\/skill-instruction>/)
return templateMatch ? templateMatch[1].trim() : skill.definition.template
}
if (skill.path) {
return extractSkillTemplate(skill)
}
@@ -235,11 +240,13 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
return cachedDescription
}
// Eagerly build description when callers pre-provide skills/commands.
if (options.skills !== undefined) {
const skillInfos = options.skills.map(loadedSkillToInfo)
const commandsForDescription = options.commands ?? []
cachedDescription = formatCombinedDescription(skillInfos, commandsForDescription)
if (options.nativeSkills) {
void buildDescription()
}
} else if (options.commands !== undefined) {
cachedDescription = formatCombinedDescription([], options.commands)
} else {
@@ -248,6 +255,9 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
return tool({
get description() {
if (cachedDescription === null) {
void buildDescription()
}
return cachedDescription ?? TOOL_DESCRIPTION_PREFIX
},
args: {
@@ -259,8 +269,8 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
},
async execute(args: SkillArgs, ctx?: { agent?: string }) {
const skills = await getSkills()
cachedDescription = null
const commands = getCommands()
cachedDescription = formatCombinedDescription(skills.map(loadedSkillToInfo), commands)
const requestedName = args.name.replace(/^\//, "")