Skip to content

Commit 8e221d8

Browse files
committed
refactor(skill): externalize customize-opencode built-in skill anomalyco#212
Task 2: 移除 index.ts 中内置 customize-opencode 技能的 import、常量与注册块,删除 prompt/customize-opencode.md 源文件。 Task 3: 清理 skill.test.ts 中 16 处 .filter((s) => s.location !== "<built-in>") 死代码过滤,改为直接使用 skill.all();测试全量通过 (20 pass / 0 fail)。
1 parent 4b16e98 commit 8e221d8

3 files changed

Lines changed: 16 additions & 411 deletions

File tree

‎packages/opencode/src/skill/index.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Flag } from "@opencode-ai/core/flag/flag"
1515
import { Glob } from "@opencode-ai/core/util/glob"
1616
import * as Log from "@opencode-ai/core/util/log"
1717
import { Discovery } from "./discovery"
18-
import CUSTOMIZE_OPENCODE_SKILL_BODY from "./prompt/customize-opencode.md" with { type: "text" }
1918
import { isRecord } from "@/util/record"
2019

2120
const log = Log.create({ service: "skill" })
@@ -25,15 +24,6 @@ const EXTERNAL_SKILL_PATTERN = "skills/**/SKILL.md"
2524
const OPENCODE_SKILL_PATTERN = "{skill,skills}/**/SKILL.md"
2625
const SKILL_PATTERN = "**/SKILL.md"
2726

28-
// Built-in skill that ships with opencode. The model's intuition for what an
29-
// opencode.json should look like is often wrong, and opencode hard-fails on
30-
// invalid config, so users hit cryptic startup errors. Loading this skill
31-
// when the model is asked to touch opencode's own config files gives it the
32-
// actual schemas instead of guesses.
33-
const CUSTOMIZE_OPENCODE_SKILL_NAME = "customize-opencode"
34-
const CUSTOMIZE_OPENCODE_SKILL_DESCRIPTION =
35-
"Use ONLY when the user is editing or creating opencode's own configuration: opencode.json, opencode.jsonc, files under .opencode/, or files under ~/.config/opencode/. Also use when creating or fixing opencode agents, subagents, skills, plugins, MCP servers, or permission rules. Do not use for the user's own application code, or for any project that is not configuring opencode itself."
36-
3727
export const Info = Schema.Struct({
3828
name: Schema.String,
3929
description: Schema.optional(Schema.String),
@@ -364,14 +354,6 @@ export const layer = Layer.effect(
364354
const state = yield* InstanceState.make(
365355
Effect.fn("Skill.state")(function* () {
366356
const s: State = { skills: {}, dirs: new Set() }
367-
// Register the built-in skill BEFORE disk discovery so a user-disk
368-
// skill with the same name can override it.
369-
s.skills[CUSTOMIZE_OPENCODE_SKILL_NAME] = {
370-
name: CUSTOMIZE_OPENCODE_SKILL_NAME,
371-
description: CUSTOMIZE_OPENCODE_SKILL_DESCRIPTION,
372-
location: "<built-in>",
373-
content: CUSTOMIZE_OPENCODE_SKILL_BODY,
374-
}
375357
yield* loadSkills(s, yield* InstanceState.get(discovered), bus, (yield* InstanceState.get(discovered)).spaceDir)
376358
return s
377359
}),

0 commit comments

Comments
 (0)