self-evolve-framework 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -5
- package/bin/cli.js +24 -2
- package/package.json +1 -1
- package/template/rules/self-evolve.mdc +68 -4
- package/template/skills/skillopt-sleep/SKILL.md +5 -0
package/README.md
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
>
|
|
5
5
|
> ⚠️ 此包专为 [CodeBuddy](https://www.codebuddy.ai) 设计,依赖 `.codebuddy/rules/` 和 `.codebuddy/skills/` 目录结构,非 CodeBuddy 环境无效。
|
|
6
6
|
|
|
7
|
+
## 由来
|
|
8
|
+
|
|
9
|
+
维护了两个项目,各自打磨了一套 Skill 规则。每次改进都要在两边重复复制粘贴,很快变得难以同步。直到 AI 建议:"为什么不打包成 npm 包?"
|
|
10
|
+
|
|
11
|
+
于是有了 Self-Evolve Framework。
|
|
12
|
+
|
|
13
|
+
一套规则,`npx` 即用,两边同步,不再需要手动搬运。
|
|
14
|
+
|
|
15
|
+
这本质上是一个私人工具箱——觉得好用的 Skill、好用的规则,会持续往里集成。方便自己,也顺手方便别人。
|
|
16
|
+
|
|
7
17
|
## 安装
|
|
8
18
|
|
|
9
19
|
```bash
|
|
@@ -22,6 +32,9 @@ npx self-evolve-framework init --dry-run
|
|
|
22
32
|
|
|
23
33
|
# 跳过 CLAUDE.md 更新
|
|
24
34
|
npx self-evolve-framework init --skip-claude-md
|
|
35
|
+
|
|
36
|
+
# 跳过 Impeccable 设计质量工具安装
|
|
37
|
+
npx self-evolve-framework init --skip-impeccable
|
|
25
38
|
```
|
|
26
39
|
|
|
27
40
|
## 安装了什么
|
|
@@ -37,13 +50,16 @@ npx self-evolve-framework init --skip-claude-md
|
|
|
37
50
|
CLAUDE.md ← 追加自我进化章节
|
|
38
51
|
```
|
|
39
52
|
|
|
53
|
+
安装过程还会自动运行 `npx impeccable install` 安装 [Impeccable](https://impeccable.style) 设计质量检查工具(可用 `--skip-impeccable` 跳过)。
|
|
54
|
+
首次使用前请在 CodeBuddy 对话中运行 `/impeccable init` 创建设计上下文。<!-- 命令由 Impeccable 技能处理 -->
|
|
55
|
+
|
|
40
56
|
## 使用
|
|
41
57
|
|
|
42
58
|
### 每日自动生效
|
|
43
59
|
|
|
44
60
|
self-evolve rule 在每个对话中 always 激活:
|
|
45
|
-
- **改代码前** → Ponytail 检查 + CodeGraph 影响评估
|
|
46
|
-
- **改代码后** → 自动 `npm run build` + `cargo check` 验证
|
|
61
|
+
- **改代码前** → Ponytail 检查 + CodeGraph 影响评估 + 核心边界审计
|
|
62
|
+
- **改代码后** → 自动 `npm run build` + `cargo check` 验证 + Impeccable 设计审计
|
|
47
63
|
- **验证失败** → 分析修复 → 记录到记忆 → ≥2 次同模式 → 自动写规则
|
|
48
64
|
- **会话结束** → 超 7 天未审计 → 提醒
|
|
49
65
|
|
|
@@ -55,8 +71,15 @@ self-evolve rule 在每个对话中 always 激活:
|
|
|
55
71
|
skillopt-sleep dry-run → 每日健康检查,5 秒出报告
|
|
56
72
|
skillopt-sleep run → 周改进提案
|
|
57
73
|
skillopt-sleep adopt → 采纳建议
|
|
74
|
+
impeccable audit → 设计质量技术审计
|
|
75
|
+
impeccable critique → 设计评审
|
|
76
|
+
impeccable polish → 页面润色
|
|
58
77
|
```
|
|
59
78
|
|
|
79
|
+
### 设计上下文
|
|
80
|
+
|
|
81
|
+
Impeccable 首次使用前运行 `/impeccable init` 生成 `PRODUCT.md` 和 `DESIGN.md`。<!-- 该命令由 Impeccable 技能处理 -->
|
|
82
|
+
|
|
60
83
|
## 前提
|
|
61
84
|
|
|
62
85
|
- CodeBuddy IDE(VSCode 系)
|
|
@@ -68,13 +91,13 @@ skillopt-sleep adopt → 采纳建议
|
|
|
68
91
|
```
|
|
69
92
|
self-evolve-framework/
|
|
70
93
|
├── package.json # npm 包配置
|
|
71
|
-
├── bin/cli.js # CLI
|
|
94
|
+
├── bin/cli.js # CLI 安装工具(含 Impeccable 自动安装)
|
|
72
95
|
├── template/
|
|
73
96
|
│ ├── rules/
|
|
74
|
-
│ │ ├── self-evolve.mdc
|
|
97
|
+
│ │ ├── self-evolve.mdc ← 编排层(含 Impeccable 集成)
|
|
75
98
|
│ │ └── ponytail.mdc
|
|
76
99
|
│ └── skills/
|
|
77
100
|
│ └── skillopt-sleep/
|
|
78
|
-
│ └── SKILL.md
|
|
101
|
+
│ └── SKILL.md ← 离线进化引擎(含设计质量分析)
|
|
79
102
|
└── README.md
|
|
80
103
|
```
|
package/bin/cli.js
CHANGED
|
@@ -33,12 +33,13 @@ function showHelp() {
|
|
|
33
33
|
选项:
|
|
34
34
|
--project <path> 指定目标项目路径(默认当前目录)
|
|
35
35
|
--skip-claude-md 跳过更新 CLAUDE.md
|
|
36
|
+
--skip-impeccable 跳过安装 Impeccable 设计质量工具
|
|
36
37
|
--dry-run 预览要复制的文件,不实际写入
|
|
37
38
|
|
|
38
39
|
示例:
|
|
39
40
|
npx self-evolve-framework init
|
|
40
41
|
npx self-evolve-framework init --project ./my-app
|
|
41
|
-
npx self-evolve-framework init --skip-claude-md --dry-run
|
|
42
|
+
npx self-evolve-framework init --skip-claude-md --skip-impeccable --dry-run
|
|
42
43
|
`)
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -46,6 +47,7 @@ async function init(args) {
|
|
|
46
47
|
const baseDir = resolve(args["--project"] || process.cwd())
|
|
47
48
|
const dryRun = !!args["--dry-run"]
|
|
48
49
|
const skipClaudeMd = !!args["--skip-claude-md"]
|
|
50
|
+
const skipImpeccable = !!args["--skip-impeccable"]
|
|
49
51
|
|
|
50
52
|
console.log(`📍 项目路径: ${baseDir}`)
|
|
51
53
|
console.log(`🧪 ${dryRun ? "DRY RUN — 不写入文件" : "执行中..."}\n`)
|
|
@@ -67,6 +69,25 @@ async function init(args) {
|
|
|
67
69
|
count++
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
// 安装 Impeccable 设计质量工具
|
|
73
|
+
if (!skipImpeccable) {
|
|
74
|
+
if (!dryRun) {
|
|
75
|
+
try {
|
|
76
|
+
console.log("\n📐 正在安装 Impeccable(设计质量检查工具)...")
|
|
77
|
+
const { execSync } = await import("child_process")
|
|
78
|
+
execSync("npx --yes impeccable install", { cwd: baseDir, stdio: "inherit" })
|
|
79
|
+
console.log(" ✅ Impeccable 安装完成")
|
|
80
|
+
console.log(" ℹ️ 运行 /impeccable init 创建设计上下文(DESIGN.md + PRODUCT.md)")
|
|
81
|
+
count++
|
|
82
|
+
} catch {
|
|
83
|
+
console.log(" ⚠️ Impeccable 安装失败(网络问题?),可稍后手动运行 npx impeccable install")
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
console.log(" 🔍 将安装 Impeccable(npx impeccable install)")
|
|
87
|
+
count++
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
70
91
|
// 更新 CLAUDE.md
|
|
71
92
|
if (!skipClaudeMd) {
|
|
72
93
|
const claudePath = resolve(baseDir, "CLAUDE.md")
|
|
@@ -74,7 +95,7 @@ async function init(args) {
|
|
|
74
95
|
## 自我进化(always 激活)
|
|
75
96
|
|
|
76
97
|
统一由 \`.codebuddy/rules/self-evolve.mdc\` 编排。
|
|
77
|
-
调度 Ponytail(代码最小化)+ CodeGraph(依赖分析)+ Skillopt-Sleep
|
|
98
|
+
调度 Ponytail(代码最小化)+ CodeGraph(依赖分析)+ Skillopt-Sleep(离线进化)+ Impeccable(设计质量)
|
|
78
99
|
→ 形成 **post-edit 验证 → 错误记忆 → 规则推荐** 闭环。
|
|
79
100
|
`
|
|
80
101
|
if (existsSync(claudePath)) {
|
|
@@ -102,6 +123,7 @@ async function init(args) {
|
|
|
102
123
|
console.log("\n📖 使用指南(在 CodeBuddy 对话中输入):")
|
|
103
124
|
console.log(" skillopt-sleep dry-run → 每日健康检查")
|
|
104
125
|
console.log(" skillopt-sleep run → 周改进提案")
|
|
126
|
+
console.log(" impeccable audit/critique → 设计质量审查")
|
|
105
127
|
}
|
|
106
128
|
}
|
|
107
129
|
|
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ alwaysApply: true
|
|
|
13
13
|
self-evolve.mdc(编排层 — 当前文件)
|
|
14
14
|
├── ponytail.mdc → 代码最小化检查(每个操作前)
|
|
15
15
|
├── CodeGraph MCP → 依赖图分析(重构/调 bug 时)
|
|
16
|
+
├── 核心边界审计 → 删/改功能前确认承重墙(本文件内联)
|
|
17
|
+
├── Impeccable → 设计质量审计(前端修改后自动触发)
|
|
16
18
|
└── skillopt-sleep → 离线进化分析(按需调)
|
|
17
19
|
↓
|
|
18
20
|
post-edit 验证闭环 ← ⭐ 核心
|
|
@@ -24,21 +26,28 @@ self-evolve.mdc(编排层 — 当前文件)
|
|
|
24
26
|
|
|
25
27
|
### 步骤 1:前置检查(修改前)
|
|
26
28
|
```
|
|
27
|
-
┌─ 修改范围 > 3
|
|
28
|
-
|
|
29
|
+
┌─ 修改范围 > 3 个文件?──────→ 调 Ponytail 约束 → 询问用户是否可缩小
|
|
30
|
+
├─ 重构/修复 bug?─────────→ 调 CodeGraph MCP → 评估影响范围
|
|
31
|
+
└─ ★ 删/重构功能代码?──────→ 核心边界审计 → 问"这段代码影响哪条用户路径?删了谁兜底?"
|
|
29
32
|
```
|
|
30
33
|
|
|
31
34
|
### 步骤 2:执行修改
|
|
32
35
|
按 Ponytail 原则写最少代码。
|
|
33
36
|
|
|
37
|
+
**核心边界约束**:如果涉及功能删减,确保受影响的核心路径有替代方案兜底,并在注释或 commit 信息中注明承重墙依据。
|
|
38
|
+
|
|
34
39
|
### 步骤 3:自动验证(修改后)
|
|
35
40
|
```
|
|
36
41
|
1. 前端:运行 npm run build
|
|
37
42
|
→ 失败 → 分析错误 → 修复 → 重试 build → 最多 3 次
|
|
38
43
|
2. Rust:在 src-tauri 目录运行 cargo check(如果存在)
|
|
39
44
|
→ 失败 → 分析错误 → 修复 → 重试 cargo check → 最多 3 次
|
|
40
|
-
3.
|
|
41
|
-
|
|
45
|
+
3. ★ 设计质量:如果修改涉及前端文件(html/css/jsx/tsx/vue/svelte),
|
|
46
|
+
运行 npx impeccable detect(如果已安装)
|
|
47
|
+
→ 发现 P0/P1 问题 → 修复 → 重新检测
|
|
48
|
+
→ P2/P3 问题 → 记入记忆,下次会话再处理
|
|
49
|
+
4. 全部通过 → 进入步骤 4
|
|
50
|
+
5. 3 次仍失败 → 停止,向用户报告错误并请求协助
|
|
42
51
|
```
|
|
43
52
|
|
|
44
53
|
### 步骤 4:写入记忆
|
|
@@ -55,6 +64,11 @@ self-evolve.mdc(编排层 — 当前文件)
|
|
|
55
64
|
|
|
56
65
|
同类型错误出现 ≥2 次 → 自动创建规则:
|
|
57
66
|
create .codebuddy/rules/{pattern-name}.mdc
|
|
67
|
+
|
|
68
|
+
涉及核心功能路径的修改,额外记录:
|
|
69
|
+
- 受影响路径
|
|
70
|
+
- 兜底方案
|
|
71
|
+
- 当前依赖方(谁在调用/依赖这段代码)
|
|
58
72
|
```
|
|
59
73
|
|
|
60
74
|
### 步骤 5:会话结束检查
|
|
@@ -63,6 +77,25 @@ self-evolve.mdc(编排层 — 当前文件)
|
|
|
63
77
|
→ 超过 7 天 → 提示:"项目已 {N} 天未审计,需要跑 skillopt-sleep 吗?"
|
|
64
78
|
```
|
|
65
79
|
|
|
80
|
+
## 🔧 核心边界审计规则
|
|
81
|
+
|
|
82
|
+
> 删改功能代码前必经的一道门——不是阻止删,而是确保删之前知道不能丢什么。
|
|
83
|
+
|
|
84
|
+
### 审计步骤
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
1. 定位:这段代码影响哪些用户可见的功能路径?
|
|
88
|
+
2. 溯源:谁在调用/依赖这段代码?→ 调 codegraph_callers
|
|
89
|
+
3. 兜底:如果没有这段代码,受影响的功能还有没有其他实现路径?
|
|
90
|
+
4. 结论:
|
|
91
|
+
✅ 有兜底 → 可以删,commit 信息注明兜底方案
|
|
92
|
+
⚠️ 无兜底 → 不能直接删,先补兜底或向用户说明风险
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 关键词触发
|
|
96
|
+
|
|
97
|
+
`删除`、`弃用`、`移除`、`deprecated`、`不再需要`、`改接口`、`重构`
|
|
98
|
+
|
|
66
99
|
## 🔧 CodeGraph MCP 使用规则
|
|
67
100
|
|
|
68
101
|
| 场景 | 必须调用的工具 |
|
|
@@ -84,6 +117,37 @@ self-evolve.mdc(编排层 — 当前文件)
|
|
|
84
117
|
| `skillopt-sleep run` | 每周总结时(生成周改进提案) |
|
|
85
118
|
| `skillopt-sleep adopt` | 审阅后采纳建议 |
|
|
86
119
|
|
|
120
|
+
## 🔧 Impeccable 设计质量规则
|
|
121
|
+
|
|
122
|
+
> 当项目已安装 [Impeccable](https://impeccable.style) 时,每次前端修改自动触发设计审计。
|
|
123
|
+
|
|
124
|
+
### 自动审计触发条件
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
触发时机:步骤 3(自动验证)中检测到前端文件改动
|
|
128
|
+
运行命令:npx impeccable detect
|
|
129
|
+
质量分级:
|
|
130
|
+
P0(阻断)→ 立即修复
|
|
131
|
+
P1(严重)→ 立即修复
|
|
132
|
+
P2(一般)→ 记入记忆,下次会话处理
|
|
133
|
+
P3(建议)→ 记入记忆,下次会话处理
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 按需审查
|
|
137
|
+
|
|
138
|
+
在 CodeBuddy 对话中输入:
|
|
139
|
+
|
|
140
|
+
| 命令 | 作用 |
|
|
141
|
+
|------|------|
|
|
142
|
+
| `impeccable audit` | 五维度技术质量检查 |
|
|
143
|
+
| `impeccable critique` | 设计评审(评分 + 角色测试) |
|
|
144
|
+
| `impeccable polish` | 最终润色打磨 |
|
|
145
|
+
| `impeccable detect` | 自动检测反模式 |
|
|
146
|
+
|
|
147
|
+
### 设计上下文
|
|
148
|
+
|
|
149
|
+
首次使用前运行 `/impeccable init`,生成 `PRODUCT.md` 和 `DESIGN.md` 作为设计上下文,让审计更精准。
|
|
150
|
+
|
|
87
151
|
## 记忆存储路径
|
|
88
152
|
|
|
89
153
|
```text
|
|
@@ -15,6 +15,8 @@ AI 从以下来源收集项目数据:
|
|
|
15
15
|
- 构建/编译错误记录(从 `.codebuddy/memory/`)
|
|
16
16
|
- 已知问题列表
|
|
17
17
|
- 现有规则集(`.codebuddy/rules/`)
|
|
18
|
+
- 设计上下文(`PRODUCT.md`、`DESIGN.md`,如果存在)
|
|
19
|
+
- 前端文件的设计质量报告(如果安装了 Impeccable,运行 `npx impeccable detect` 或读取历史记录)
|
|
18
20
|
|
|
19
21
|
### 阶段 2:Mine — 挖掘模式
|
|
20
22
|
分析收集到的数据,识别:
|
|
@@ -22,6 +24,8 @@ AI 从以下来源收集项目数据:
|
|
|
22
24
|
- **代码异嗅**:循环依赖、过度耦合、重复代码
|
|
23
25
|
- **缺失约束**:重复发生但无规则防范的问题
|
|
24
26
|
- **优化机会**:可简化的逻辑、可合并的文件
|
|
27
|
+
- **★ 核心边界**:识别模块间的契约接口、关键用户路径和其依赖方,标记"改/删前必须审慎"的承重区域
|
|
28
|
+
- **★ 设计异嗅**:分析 Impeccable 检测报告中的 P0/P1 反复出现的问题模式,识别设计约束缺失或 DESIGN.md 与实现不一致的区域
|
|
25
29
|
|
|
26
30
|
### 阶段 3:Replay — 回放验证
|
|
27
31
|
对每个发现的问题:
|
|
@@ -35,6 +39,7 @@ AI 从以下来源收集项目数据:
|
|
|
35
39
|
- **更新规则**:现有规则描述模糊或过时
|
|
36
40
|
- **删除规则**:不再相关或从未被触发的规则
|
|
37
41
|
- **优化 memory**:合并重复的错误模式记录
|
|
42
|
+
- **★ 边界标记**:涉及核心功能路径的删除/修改建议,加 ⚠️ 标签要求人工确认,不可自动采纳
|
|
38
43
|
|
|
39
44
|
### 阶段 5:Stage — 暂存
|
|
40
45
|
所有建议先写入 `.codebuddy/memory/skillopt-staging/` 目录,**不修改任何活文件**。
|