Skip to content

Commit 8a66241

Browse files
committed
skillwiki
1 parent 6899d92 commit 8a66241

2 files changed

Lines changed: 257 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: "自动生成 SKILL 可行性:wikiskill 闭环 vs CodeWiki 编译复用"
3+
type: Comparison
4+
description: "调研 WikiSkill(arXiv:2608.27454 开源实现)与论文解读后,评估 CodeWiki 知识管线能否承载「自动生成 SKILL」能力:三档方案对比(全闭环/单向编译/半闭环),定档为半闭环起步、MVP 先做单向编译器。"
5+
generated: { by: codewiki/5.6.0, at: 2026-09-05T15:20:04Z }
6+
stale_after: 2026-12-04
7+
aliases: [自动生成SKILL可行性-wikiskill闭环-vs-CodeWiki编译复用]
8+
status: stable
9+
tags: [skill, 他山之石, 可行性, wikiskill, 经验编译]
10+
metadata:
11+
related_modules: ["codewiki/mcp/tools"]
12+
source_refs: ["arXiv:2608.27454", "https://github.com/ashutoshsinghpr7/wikiskill"]
13+
code_fingerprint: sha256:829467a7f49459ddf16d1711753a335b7338eb7409360e8d30565d9f78d11621
14+
---
15+
# 自动生成 SKILL 可行性:wikiskill 闭环 vs CodeWiki 编译复用
16+
17+
## 背景与目标
18+
19+
「他山之石」任务下调研两个外部对象,判断 CodeWiki-CN 能否实现「自动生成 SKILL」:
20+
21+
1. **wikiskill 开源项目**(ashutoshsinghpr7/wikiskill,arXiv:2608.27454 的 faithful 实现,Hermes Agent 后端,兼容 Claude Code/Codex/Copilot CLI)
22+
2. **论文解读文章**(XStack18 转载,介绍 Google Research + Virginia Tech 的 WikiSkill 框架)
23+
24+
目标不是复刻 wikiskill,而是判断:**CodeWiki 既有的知识管线(对话→蒸馏→笔记→确认→L2 场景→L3 doctrine)能否作为地基,长出「自动生成 SKILL」能力**,以及该长成什么形态。
25+
26+
## 候选方案
27+
28+
### 方案 A:WikiSkill 全闭环(外部参照)
29+
30+
进化闭环:`Inference Agent(跑任务产轨迹) → Wiki Maintainer(蒸馏成 wiki/patterns) → Skill Proposer(每次一个原子提案) → 门控(git 回滚,R_val > R_best 才接受)`。
31+
32+
- 三层空间:`skills/`(可回滚)、`wiki/`(永不回滚)、`raw/`(不可变)
33+
- 隔离 profile 门控、skill-impact.md 审计链、demo bench 22 个自动评分任务(13 train / 9 val)
34+
- 论文核心洞察:① Wiki 不暴露给执行者(防抄答案,轨迹质量 63.7%→60.9%)② 知识发现与执行解耦(强模型进化、弱模型执行)③ 被拒提案是下轮素材(复利效应)
35+
- 工程极简:文件系统 + LLM 工具调用 + 50-100 行 Python 编排,无向量库
36+
37+
### 方案 B:单向编译器(CodeWiki 最短路径)
38+
39+
把已确认知识(confirmed notes + wiki/scenarios)编译成 SKILL.md 草稿 → 走既有确认闸门 → 落 `.codebuddy/skills/<name>/`。
40+
41+
- 沿 Mode C「prepare→宿主 agent 当 LLM→submit 确定性簿记」协议(distill_conversation / note_consolidation / doctrine 三先例)
42+
- 门控 = 既有 draft→confirm_note 确认闸门 + 人工试用,不建自动评分
43+
44+
### 方案 C:半闭环(推荐落点)
45+
46+
在 B 之上加回流:用生成的 SKILL 跑真实任务 → 任务记忆/对话被现有采集管线吸收 → 再提炼改进 SKILL。
47+
48+
- 复用 CodeWiki 天然回流(SessionEnd 采集、任务记忆、supersede 增量重捕),无需 Inference Agent 编排与自动评分器
49+
- 「经验复利」在人的确认闭环里发生,而非自动门控
50+
51+
## 对比分析
52+
53+
### 目标产物格式
54+
55+
两者一致:SKILL.md + name/description frontmatter,Anthropic Agent Skill 规范兼容。wikiskill 蒸馏的技能可直接装 `~/.claude/skills/`;CodeWiki 产物同理落 `.codebuddy/skills/`(本仓已实证纯 SKILL.md 直接安装可行)。
56+
57+
### 能力差距对照表
58+
59+
| 维度 | wikiskill(全闭环) | CodeWiki 现状 | 差距 |
60+
|---|---|---|---|
61+
| 素材源 | raw traces(原始轨迹) | notes/scenarios(已蒸馏结构化) | CodeWiki 素材更干净但缺轨迹细节 |
62+
| 蒸馏 | Wiki Maintainer agent | distill_conversation(Mode A/B/C) | 已有等价能力 |
63+
| 提案 | Skill Proposer(自主 ReAct,原子改动) | 无 skill 生成器 | **需新增** |
64+
| 正文写作 LLM | 内嵌 agent | 仓库铁律:工具无状态,LLM 外置 | Mode C 天然适配 |
65+
| 门控 | 自动评分 R_val>R_best + git 回滚 | 人工确认闸门(draft→confirm) | 无自动评分基准是**硬缺口** |
66+
| 审计 | skill-impact.md | notes 生命周期 + aggregation_hint | 可移植 |
67+
| 落盘 | skills/active(受 git 管理) | 无 .codebuddy/skills 写入器 | **需新增** |
68+
| 回流 | 每轮迭代轨迹 | 任务记忆 + raw 采集(SessionEnd/IDE hook) | CodeWiki 已有更强回流 |
69+
| 校验 | — | lint_wiki 只扫 repowiki,不覆盖 .codebuddy | SKILL.md lint **需新增** |
70+
71+
### 可复用的 CodeWiki 骨架(依据本次代码核对)
72+
73+
1. **Mode C 协议**:`distill_conversation.py`、`note_consolidation.py`、`doctrine.py` 三先例,工具负责选材/校验/落盘/溯源,LLM 正文由调用方产出
74+
2. **确认闸门 + 生命周期**:draft→confirm/reject(note_lifecycle.py),草稿技能可复用
75+
3. **聚合/蒸馏纪律**:系统提示里的「自包含/可归因/SOP/判断逻辑/反模式」质量准则 ≈ SKILL.md 正文所需
76+
4. **确定性文件设施**:atomic_write/锁、frontmatter OKF 修补、slugify、冲突预检
77+
5. **分发基建**:hooks.yaml 家族注册 + install_hooks 拷贝管线,可扩展「skills」资产类型
78+
6. **schema 数据驱动**:page_types/note_types 加「skill」类型即可让路由/lint/prompt 感知
79+
80+
### 缺口清单
81+
82+
1. 无 SKILL.md 读写器/技能目录管理器(不写 .codebuddy/skills/)
83+
2. 词汇层无 skill 类型(note_type/page_type 枚举、无技能专用状态机)
84+
3. 无「从经验编译技能」的生成工具/prompt/CLI(consolidate_notes 输出是 scenarios 页,非 SKILL.md)
85+
4. 无 SKILL.md 质量校验/lint、无技能检索/采纳信号
86+
5. 无技能注入/激活执行端(T2/T3 装载是 IDE 原生行为,工具层无代码)
87+
6. 工具侧无 LLM(架构铁律),需配套 spawn 式 worker 剧本(distill-worker.md 可当模板)
88+
89+
## 结论与决策
90+
91+
**结论:能实现。** 且因为知识管线已把「经验→结构化知识」半程走完,CodeWiki 比 wikiskill 更接近「自动生成 SKILL」的前半程(蒸馏已有);缺口集中在「技能产物类型」与「生成工具」两个新增件,不涉及重构。
92+
93+
**定档(决策,2026-09-05):**
94+
95+
1. **推荐形态 = 方案 C 半闭环**:单向编译器(B)是 MVP,先验证「notes/scenarios → SKILL.md draft → 人工确认 → 落 .codebuddy/skills/」闭环;生成质量稳定后再接回流迭代(真实任务轨迹经现有采集管线回流,提炼改进 SKILL)
96+
2. **不建自动评分门控、不编 Inference Agent 编排**——那是重做 wikiskill,CodeWiki 无 held-out 基准且确认闸门已承担质量职责
97+
3. **素材源 = confirmed notes + wiki/scenarios**(raw 太噪需先蒸馏;任务记忆是进度型不直接作正文)
98+
4. **生成分工 = Mode C**:宿主 agent/子代理写 SKILL.md 正文,工具做选材/校验/落盘/溯源(守「无状态工具 + LLM 外置」铁律)
99+
5. **落盘先仓库内 .codebuddy/skills/ 闭环**,稳定后再考虑 hooks.yaml 家族分发;宿主级安装是用户动作,工具不代劳
100+
6. 落地顺序:skill 词汇/状态机 → skill-creator 工具(Mode C)→ SKILL.md lint → 仓库内闭环验证 → 回流迭代
101+
102+
**本次只做定档,代码未动。** 是否进入设计/实现,待用户另行拍板。
103+
104+
## 相关参考
105+
106+
- 论文:WikiSkill: Compiling Agent Experience into Persistent Knowledge for Skill Evolution(arXiv:2608.27454)
107+
- 仓库:github.com/ashutoshsinghpr7/wikiskill(Hermes CLI,`wikiskill evolve` 闭环)
108+
- 解读:XStack18《WikiSkill——把 Agent 经验编译成永久知识》
109+
- 本仓相关笔记:2026-09-05-ponytail-生效机制(T1/T2/T3 加载档位)、2026-09-04-caveman-技能生效机制(SKILL.md 三条加载链路)
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: "skill-creator 设计方案:从 scenario/notes 编译 SKILL.md 的两区制 Mode C 工具"
3+
type: Query
4+
description: "CodeWiki 自动生成 SKILL 能力的落地设计:产物粒度(scenario 直译 + 精选 notes 补充)、选材触发(prepare 列候选 + 显式指定)、两区制确认闸门(草稿区 repowiki/skills 不生效 → install 到 .codebuddy/skills 生效)、重写加变更记录段。含工具 API、frontmatter schema、与 consolidate_notes 的分工、实施步骤与未决问题。"
5+
generated: { by: codewiki/5.6.0, at: 2026-09-05T15:39:24Z }
6+
stale_after: 2026-12-04
7+
aliases: [skill-creator设计方案]
8+
status: stable
9+
tags: [skill, 设计, mode-c, 确认闸门, 他山之石]
10+
metadata:
11+
related_modules: ["codewiki/mcp/tools"]
12+
source_refs: ["wiki/comparisons/自动生成SKILL可行性-wikiskill闭环-vs-CodeWiki编译复用.md"]
13+
code_fingerprint: sha256:829467a7f49459ddf16d1711753a335b7338eb7409360e8d30565d9f78d11621
14+
---
15+
# skill-creator 设计方案:从 scenario/notes 编译 SKILL.md 的两区制 Mode C 工具
16+
17+
## 问题描述
18+
19+
承 [自动生成SKILL可行性-wikiskill闭环-vs-CodeWiki编译复用](../comparisons/自动生成SKILL可行性-wikiskill闭环-vs-CodeWiki编译复用.md) 的定档(方案 C 半闭环,MVP = 单向编译器),本页回答「具体长什么样」:
20+
21+
1. 工具如何选材、如何触发、如何落盘;
22+
2. **如何在 SKILL.md 会被 IDE 即时发现的现实下,仍然守住「落盘必经确认闸门」**;
23+
3. 技能的更新、退役与可检索性如何保证;
24+
4. 与既有 `consolidate_notes`(L2 场景块)如何分工而不重叠。
25+
26+
## 调研过程
27+
28+
已核对的现有实现(依据本次代码核对):
29+
30+
- **`codewiki/mcp/tools/note_consolidation.py`** — 平行工具模板:Mode C `prepare`/`submit`、容量分档预警(red/orange/yellow)、溯源互链(scene `source_notes` ⇄ note `consolidated_into`)、软删除标记 `[DELETED]`、submit 后重建索引、cascade hint 提醒而非自动执行(:344-398 prepare,:400-600 submit,:43-97 聚合系统提示)
31+
- **`codewiki/mcp/tools/note_types.py`** — note_type 权威表,schema `conventions.note_types` 按 key 覆盖(:36-77 默认表,:93-128 合并逻辑)
32+
- **`repowiki/wiki/scenarios/对话蒸馏管线与raw暂存区.md`** — L2 场景块章节骨架:工作场景/适用条件/核心 SOP/判断逻辑/禁忌与反模式/关键事实依据(:23-53)
33+
- **`.codebuddy/skills/grilling/SKILL.md`** — CodeBuddy 技能最小 frontmatter = `name` + `description`(:1-4)
34+
- 缺口:`lint_wiki` 只扫 repowiki 内 md,`.codebuddy` 不进索引不进 lint;无技能目录写入器
35+
36+
关键洞察:scenario 的章节骨架(SOP / 判断逻辑 / 禁忌)**已经是 SKILL.md 正文所需结构**,`description` 天然对应「适用条件」——不复用就是重造一次聚合。
37+
38+
## 方案权衡
39+
40+
### 权衡一:产物粒度与素材来源
41+
42+
| 选项 | 代价 |
43+
|---|---|
44+
| (a) scenario 直译 | 依赖 L2 已聚合,覆盖面取决于 consolidation 频率 |
45+
| (b) 跨主题重新聚合 notes | 重做 consolidate 已做的聚类,逻辑漂移 |
46+
| (c) 按 note_type 精选 | 覆盖面窄 |
47+
48+
**选定 (a) 为主 + (c) 为补充**:scenario 是主素材;未被任何 scenario 吸收的高价值 `pitfall`/`lesson`/`decision` 单条笔记允许作为独立素材(复用 `_pending_confirmed_notes` 同类扫描,按 `metadata.compiled_into` 排除已编译的)。
49+
50+
### 权衡二:选材与触发
51+
52+
- (a) prepare 列候选 → agent 挑:与 consolidate_notes 完全同构,人始终在环
53+
- (b) 用户显式指定 `topic`/`sources`:可控性强
54+
- (c) 全自动按阈值挑选:**违反 Doctrine「触发永远显式」**,排除
55+
56+
**选定 (a) + (b) 并存,无默认自动触发。**
57+
58+
### 权衡三:落盘与确认闸门(核心)
59+
60+
- (a) **两区制**:草稿落 `repowiki/skills/`(不生效、进索引、进 lint),确认后 install 到 `.codebuddy/skills/`(生效)
61+
- (b) 单区 + `status: draft` 标记:草稿期技能**已被 IDE 发现并可触发**,闸门形同虚设——否决
62+
- (c) 即刻生效靠事后回滚:坏技能已污染行为——否决
63+
64+
**选定 (a)。** 代价是多一个 install 动作,但这份代价正是「宿主级安装是用户动作,工具不代劳」的落地。
65+
66+
### 权衡四:更新与退役
67+
68+
- (a) 整份重写:丢 diff 历史
69+
- (b) unified diff patch:保留演化证据但实现重(wikiskill 的 edit_skill)
70+
- (c) 重写 + frontmatter `metadata.revisions` 变更记录段
71+
72+
**选定 (c)**:保住 wikiskill「改动可审计」的价值(`skill-impact.md` 的意义所在),不引入 diff 引擎。退役沿用 `reject_note` 同款语义。
73+
74+
### 与 consolidate_notes 的分工
75+
76+
| | consolidate_notes | skill_creator |
77+
|---|---|---|
78+
| 产物 | `wiki/scenarios/*.md`(知识层,检索消费) | `SKILL.md`(行为层,agent 指令消费) |
79+
| 消费方 | agent 主动 `query_wiki` | IDE 按 description 自动触发 |
80+
| 关系 | 上游 | 下游单向(source_refs 回链 scenario) |
81+
82+
**不合并**:一个是检索知识,一个是行为指令,语义与消费链路都不同。
83+
84+
## 决策结论
85+
86+
### 工具形态
87+
88+
**新工具 `skill_creator`**(`codewiki/mcp/tools/skill_creator.py` + `registry.py` 注册),四种 mode:
89+
90+
| mode | 入参 | 行为 |
91+
|---|---|---|
92+
| `prepare` | `topic?`, `sources?`, `limit?` | 返回候选素材(未编译 scenario + 精选 notes)、草稿区与生效区技能索引、冲突预检、容量预警、正文写作系统提示 |
93+
| `submit` | `report.skills[]` | frontmatter 校验、路径安全、落草稿区、溯源互链(skill `source_refs` ⇄ 素材 `compiled_into`)、`revisions` 追加、索引重建、计数器归零 |
94+
| `install` | `name` | 草稿 → `.codebuddy/skills/<name>/SKILL.md`,写 `installed_at`/`installed_to`,**仅在用户确认后调用** |
95+
| `retire` | `name`, `reason` | 标记 deprecated + 从生效区 uninstall,正文保留(不删,留审计) |
96+
97+
`submit` 的报告条目:`{name, action(created|updated|retired), source_refs[], summary?, revision_note?}`。
98+
99+
### 目录与 frontmatter
100+
101+
```
102+
repowiki/skills/<name>/SKILL.md # 草稿区:不生效、进索引、进 lint
103+
.codebuddy/skills/<name>/SKILL.md # 生效区:IDE 自动发现
104+
```
105+
106+
草稿区 frontmatter(OKF v0.2 风格):
107+
108+
```yaml
109+
---
110+
name: <slug>
111+
description: <触发条件一句话——IDE 据此决定是否调用>
112+
type: Skill
113+
status: draft # draft | stable | deprecated
114+
generated: {by: codewiki/<ver>, at: <ts>}
115+
stale_after: <date>
116+
metadata:
117+
summary: <40 字内>
118+
source_refs: [wiki/scenarios/xxx.md, notes/yyy.md]
119+
revisions: [{at, reason, source}]
120+
installed_at: <ts> # install 后写入
121+
installed_to: .codebuddy/skills/<name>/
122+
---
123+
```
124+
125+
### 选材与防碎片纪律(沿用 consolidate 的成功约束)
126+
127+
1. 默认 UPDATE,不 CREATE;拿不准就 UPDATE
128+
2. 每批最多新建 **1** 份技能
129+
3. 新建前必须读 ≥2 份最相似现有技能,确认无处可归
130+
4. 冲突预检:name/description 相似度(复用 Jaccard 思路,不用向量)
131+
5. 容量硬顶(建议 12,类比 `max_scenarios`=15):红=先合并,橙=只 UPDATE
132+
133+
### 实施步骤(代码层,尚未动工)
134+
135+
1. `schema.yaml` 增 `page_types.skill`(directory: `skills`,required_sections: 工作场景/适用条件/核心 SOP/判断逻辑/禁忌与反模式)——让 lint/路由感知草稿技能
136+
2. `note_types.py` 同款权威表思路:新增 skill 资产声明(freshness/容量/合并策略)
137+
3. `codewiki/src/config.py` 增 `SKILLS_DIR`(草稿区)与生效区常量
138+
4. 实现 `skill_creator.py`(4 mode),复用 `store.locked_rmw` + frontmatter round-trip 辅助 + `aggregation_state`
139+
5. 正文写作系统提示(自包含 / 可归因 / SOP 化 / 禁绝对路径与密钥)
140+
6. SKILL.md lint:description 非空含触发条件、name 合规、正文长度上限、无敏感串
141+
7. `tests/` 补用例;`registry.py` 注册后跑全量测试
142+
143+
### 未决问题(下一轮 grill 收敛)
144+
145+
1. **Q10 回流验证**:半闭环的「技能有效」如何判定——人工试用反馈落到哪(note?`flag_issue`?技能 frontmatter 增 `effectiveness` 字段?)
146+
2. **Q11 lint 与容量**:SKILL.md 必检规则清单、容量上限取值、草稿区是否纳入 `lint_wiki` 扫描
147+
148+
**本页为设计定档,代码未动。**

0 commit comments

Comments
 (0)