code-copilot 1.0.0

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/AGENTS.md ADDED
@@ -0,0 +1,60 @@
1
+ # Code Copilot — 渐进式 Spec 编码框架
2
+
3
+ > 跨平台 AI 编码协作框架。适用于 Claude Code、Cursor、Cline、Windsurf、OpenClaw、opencode、Aider 等主流 AI 编码工具。
4
+
5
+ ---
6
+
7
+ ## 身份
8
+
9
+ 你是一个 Spec 驱动的编码协作助手。在写代码之前,先用结构化文档把"做什么、怎么做、有什么约束"说清楚,然后围绕文档编码。
10
+
11
+ **完整行为准则和命令定义,请读取 `core/agents/copilot-prompt.md`。**
12
+
13
+ ---
14
+
15
+ ## 核心法则(必须遵守)
16
+
17
+ 1. **No Spec, No Code** — 没有文档,不准写代码(小改动如修字段、加日志除外)
18
+ 2. **Spec is Truth** — 文档和代码冲突时,错的一定是代码
19
+ 3. **Reverse Sync** — 发现偏差,先修文档再修代码
20
+ 4. **代码现状必须有出处** — 每个结论标注文件路径和类名/方法名
21
+ 5. **Verification 铁律** — 完成任务后必须展示可验证证据,禁止"应该没问题"
22
+ 6. **零偏差原则** — Plan 是合同,AI 是打印机
23
+ 7. **HARD-GATE** — spec 全部确认后才能开始编码
24
+
25
+ ---
26
+
27
+ ## 意图识别(自然语言触发)
28
+
29
+ 收到用户指令时,先识别意图并映射到对应的工作流步骤:
30
+
31
+ | 用户可能说的话 | 工作流步骤 |
32
+ |---|---|
33
+ | "修复 xxx" / "改一下 xxx" / "fix xxx" | `/fix` 流程 |
34
+ | "我要做 xxx 需求" / "新增 xxx 功能" / "开发 xxx" | `/propose` 流程 |
35
+ | "开始写代码" / "继续执行" / "开始实现" | `/apply` 流程 |
36
+ | "帮我看看代码" / "review 一下" / "审查" | `/review` 流程 |
37
+ | "写测试" / "补单测" / "写单元测试" | `/test` 流程 |
38
+ | "归档 xxx" / "结束这个需求" | `/archive` 流程 |
39
+ | "初始化项目" / "设置项目上下文" | `/init` 流程 |
40
+
41
+ 触发工作流后,**读取 `core/agents/copilot-prompt.md` 中对应命令的详细执行逻辑。**
42
+
43
+ 纯技术讨论不需要走工作流,直接回答。
44
+
45
+ ---
46
+
47
+ ## 渐进式复杂度
48
+
49
+ - 🟢 **小改动**(改字段、修 bug、加日志)→ 直接改,Rules 始终生效
50
+ - 🟡 **中等需求**(新增接口、改业务逻辑)→ Rules + Spec + Tasks
51
+ - 🔴 **大需求**(跨模块重构、涉及 5+ 模块)→ 全流程
52
+
53
+ ---
54
+
55
+ ## 项目规则
56
+
57
+ 读取 `core/rules/` 下标记 `alwaysApply: true` 的文件:
58
+ - `core/rules/project-context.md` — 工程结构和技术栈
59
+ - `core/rules/coding-style.md` — 编码规范
60
+ - `core/rules/security.md` — 安全红线
package/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # Code Copilot — Progressive Spec Coding Framework
2
+
3
+ [中文](#中文) | [English](#english)
4
+
5
+ ---
6
+
7
+ ## 中文
8
+
9
+ > 跨平台 AI 编码协作框架,基于 Spec 驱动的渐进式编码方法论。
10
+ > 支持 Claude Code、Cursor、Cline、Windsurf、OpenClaw、CoPaw、OpenCode、Aider 等工具。
11
+
12
+ ### 一键安装
13
+
14
+ 在你的项目根目录执行一条命令即可:
15
+
16
+ ```bash
17
+ # Node.js 用户(推荐)
18
+ npx code-copilot init # 默认安装 Claude Code 适配
19
+ npx code-copilot init cursor # 安装 Cursor 适配
20
+ npx code-copilot init openclaw # 安装 OpenClaw 适配
21
+ npx code-copilot init all # 安装所有平台适配
22
+ ```
23
+
24
+ ```bash
25
+ # Mac / Linux 用户(无需 Node.js)
26
+ curl -fsSL https://raw.githubusercontent.com/lawushanshan/code-copilot/main/install.sh | bash -s -- claude
27
+ ```
28
+
29
+ 可选平台:`claude`、`openclaw`、`copaw`、`cursor`、`cline`、`windsurf`、`opencode`、`aider`、`all`
30
+
31
+ ### 核心理念
32
+
33
+ 在让 AI 写代码之前,先用结构化文档(Spec)把"要做什么、怎么做、有什么约束"说清楚,然后 AI 围绕这份文档编码。
34
+
35
+ **三条铁律**:
36
+ 1. **No Spec, No Code** — 没有文档,不准写代码
37
+ 2. **Spec is Truth** — 文档和代码冲突时,错的一定是代码
38
+ 3. **Reverse Sync** — 发现偏差,先修文档再修代码
39
+
40
+ **渐进式复杂度**:不同复杂度的需求暴露不同深度的流程 — 小改动直接改,中等需求走 Spec+Tasks,大需求走全流程。
41
+
42
+ ### 目录结构
43
+
44
+ ```
45
+ .
46
+ ├── AGENTS.md # 通用适配入口(所有平台自动识别)
47
+ ├── README.md # 本文件
48
+ ├── core/ # 核心(平台无关)
49
+ │ ├── rules/ # 项目约束(始终加载)
50
+ │ │ ├── project-context.md # 工程结构和技术栈(/init 填充)
51
+ │ │ ├── coding-style.md # 编码规范
52
+ │ │ ├── security.md # 安全红线
53
+ │ │ └── domain-rules.md # 业务领域约束
54
+ │ ├── knowledge/ # 领域知识(按需加载)
55
+ │ │ └── index.md # 知识索引(知识飞轮输出)
56
+ │ ├── agents/ # Prompt 模板(核心资产)
57
+ │ │ ├── copilot-prompt.md # 主 Agent 完整指令
58
+ │ │ ├── spec-reviewer.md # Spec 合规审查
59
+ │ │ └── code-quality-reviewer.md # 代码质量审查
60
+ │ ├── templates/ # 文件模板
61
+ │ │ ├── spec.md # Spec 文档模板
62
+ │ │ ├── tasks.md # 任务拆分模板
63
+ │ │ ├── test-spec.md # 单测 Spec 模板
64
+ │ │ └── log.md # 变更日志模板
65
+ │ └── changes/ # 变更目录(运行时创建)
66
+ └── adapters/ # 平台适配层(薄壳)
67
+ ├── claude-code/ # Claude Code(斜杠命令)
68
+ ├── openclaw/ # OpenClaw(AGENTS.md + SOUL.md + IDENTITY.md)
69
+ ├── copaw/ # CoPaw(Skills + config.yaml)
70
+ ├── cursor/ # Cursor(.cursorrules)
71
+ ├── cline/ # Cline(.clinerules)
72
+ ├── windsurf/ # Windsurf(.windsurfrules)
73
+ ├── opencode/ # OpenCode(opencode.json)
74
+ └── aider/ # Aider(.aider.conf.yml)
75
+ ```
76
+
77
+ ### 快速开始
78
+
79
+ 推荐使用一键安装(见上方),也可以手动复制:
80
+
81
+ ```bash
82
+ git clone https://github.com/lawushanshan/code-copilot.git
83
+ # 然后将 AGENTS.md、core/ 和对应平台的适配文件复制到你的项目中
84
+ ```
85
+
86
+ ### 初始化
87
+
88
+ 安装完成后,让 AI 分析你的项目并填充工程上下文:
89
+
90
+ ```
91
+ /init
92
+ ```
93
+
94
+ 或非 Claude Code 平台:
95
+
96
+ ```
97
+ 请初始化项目上下文,分析工程结构并填充 project-context.md
98
+ ```
99
+
100
+ ### 工作流概览
101
+
102
+ ```
103
+ /init → /propose → /apply → /review → /fix(如需) → /archive
104
+ ↗ ↓
105
+ 直接改(小改动) /test(可选)
106
+ ```
107
+
108
+ | 阶段 | 角色分工 | 产出 |
109
+ |------|---------|------|
110
+ | `/init` | AI 全自动 | `rules/project-context.md` |
111
+ | `/propose` | 人主导,AI 辅助 | `changes/<名>/spec.md` + `tasks.md` + `log.md` |
112
+ | `/apply` | AI 主导,人审查 | 代码 + git commits |
113
+ | `/review` | AI 审查 | 合规报告 + 质量报告 |
114
+ | `/fix` | AI 执行,人审查 | 增量代码修正 |
115
+ | `/archive` | 人决定,AI 执行 | 知识沉淀到 `knowledge/` |
116
+
117
+ ### 自定义指南
118
+
119
+ | 想改什么 | 编辑哪个文件 |
120
+ |---------|------------|
121
+ | 编码规范 | `core/rules/coding-style.md` |
122
+ | 业务规则 | `core/rules/domain-rules.md` |
123
+ | 安全规则 | `core/rules/security.md` |
124
+ | 核心工作流 | `core/agents/copilot-prompt.md` |
125
+ | 文档模板 | `core/templates/` 下对应文件 |
126
+
127
+ ### 设计原则
128
+
129
+ - **核心逻辑在 `core/`,适配器只是薄壳** — 更新框架只需改 core
130
+ - **纯 Markdown,零依赖** — 复制即用,无需安装
131
+ - **双触发模式** — 斜杠命令(Claude Code)+ 自然语言意图映射(所有平台)
132
+ - **知识飞轮** — 每次变更的经验自动沉淀,持续提升 AI 理解力
133
+
134
+ ---
135
+
136
+ ## English
137
+
138
+ > A cross-platform AI coding collaboration framework based on Spec-driven progressive coding methodology.
139
+ > Supports Claude Code, Cursor, Cline, Windsurf, OpenClaw, CoPaw, OpenCode, Aider, and more.
140
+
141
+ ### Core Philosophy
142
+
143
+ Before letting AI write code, use structured documentation (Spec) to clarify *what to do, how to do it, and what constraints exist*. Then AI codes around that document.
144
+
145
+ **Three Iron Laws**:
146
+ 1. **No Spec, No Code** — No documentation, no coding allowed
147
+ 2. **Spec is Truth** — When code conflicts with docs, code is wrong
148
+ 3. **Reverse Sync** — When deviations are found, fix docs first, then code
149
+
150
+ **Progressive Complexity**: Different requirement complexities expose different workflow depths — small changes go direct, medium needs go through Spec+Tasks, large needs use the full workflow.
151
+
152
+ ### Directory Structure
153
+
154
+ ```
155
+ .
156
+ ├── AGENTS.md # Universal adapter entry (auto-detected by all platforms)
157
+ ├── README.md # This file
158
+ ├── core/ # Core (platform-agnostic)
159
+ │ ├── rules/ # Project constraints (always loaded)
160
+ │ │ ├── project-context.md # Project structure & tech stack (filled by /init)
161
+ │ │ ├── coding-style.md # Coding conventions
162
+ │ │ ├── security.md # Security red lines
163
+ │ │ └── domain-rules.md # Business domain constraints
164
+ │ ├── knowledge/ # Domain knowledge (loaded on demand)
165
+ │ │ └── index.md # Knowledge index (knowledge flywheel output)
166
+ │ ├── agents/ # Prompt templates (core asset)
167
+ │ │ ├── copilot-prompt.md # Main Agent full instructions
168
+ │ │ ├── spec-reviewer.md # Spec compliance review
169
+ │ │ └── code-quality-reviewer.md # Code quality review
170
+ │ ├── templates/ # Document templates
171
+ │ │ ├── spec.md # Spec document template
172
+ │ │ ├── tasks.md # Task breakdown template
173
+ │ │ ├── test-spec.md # Unit test spec template
174
+ │ │ └── log.md # Change log template
175
+ │ └── changes/ # Changes directory (created at runtime)
176
+ └── adapters/ # Platform adapters (thin shells)
177
+ ├── claude-code/ # Claude Code (slash commands)
178
+ ├── openclaw/ # OpenClaw (AGENTS.md + SOUL.md + IDENTITY.md)
179
+ ├── copaw/ # CoPaw (Skills + config.yaml)
180
+ ├── cursor/ # Cursor (.cursorrules)
181
+ ├── cline/ # Cline (.clinerules)
182
+ ├── windsurf/ # Windsurf (.windsurfrules)
183
+ ├── opencode/ # OpenCode (opencode.json)
184
+ └── aider/ # Aider (.aider.conf.yml)
185
+ ```
186
+
187
+ ### One-Line Install
188
+
189
+ Run one command in your project root:
190
+
191
+ ```bash
192
+ # Node.js users (recommended)
193
+ npx code-copilot init # Claude Code (default)
194
+ npx code-copilot init cursor # Cursor
195
+ npx code-copilot init openclaw # OpenClaw
196
+ npx code-copilot init all # All adapters
197
+ ```
198
+
199
+ ```bash
200
+ # Mac / Linux users (no Node.js required)
201
+ curl -fsSL https://raw.githubusercontent.com/lawushanshan/code-copilot/main/install.sh | bash -s -- claude
202
+ ```
203
+
204
+ Available platforms: `claude`, `openclaw`, `copaw`, `cursor`, `cline`, `windsurf`, `opencode`, `aider`, `all`
205
+
206
+ ### Quick Start
207
+
208
+ One-line install is recommended (see above). You can also install manually:
209
+
210
+ ```bash
211
+ git clone https://github.com/lawushanshan/code-copilot.git
212
+ # Then copy AGENTS.md, core/, and your platform's adapter files into your project
213
+ ```
214
+
215
+ ### Initialize
216
+
217
+ After installation, let AI analyze your project and fill the engineering context:
218
+
219
+ ```
220
+ /init
221
+ ```
222
+
223
+ Or for non-Claude Code platforms:
224
+
225
+ ```
226
+ Please initialize the project context, analyze the project structure and fill project-context.md
227
+ ```
228
+
229
+ ### Workflow Overview
230
+
231
+ ```
232
+ /init → /propose → /apply → /review → /fix (if needed) → /archive
233
+ ↗ ↓
234
+ Direct fix /test (optional)
235
+ (small changes)
236
+ ```
237
+
238
+ | Phase | Role | Output |
239
+ |-------|------|--------|
240
+ | `/init` | AI fully automatic | `rules/project-context.md` |
241
+ | `/propose` | Human-led, AI-assisted | `changes/<name>/spec.md` + `tasks.md` + `log.md` |
242
+ | `/apply` | AI-led, human reviews | Code + git commits |
243
+ | `/review` | AI reviews | Compliance report + quality report |
244
+ | `/fix` | AI executes, human reviews | Incremental code fixes |
245
+ | `/archive` | Human decides, AI executes | Knowledge captured in `knowledge/` |
246
+
247
+ ### Customization Guide
248
+
249
+ | What to customize | Which file to edit |
250
+ |-------------------|-------------------|
251
+ | Coding conventions | `core/rules/coding-style.md` |
252
+ | Business rules | `core/rules/domain-rules.md` |
253
+ | Security rules | `core/rules/security.md` |
254
+ | Core workflow | `core/agents/copilot-prompt.md` |
255
+ | Document templates | Corresponding file in `core/templates/` |
256
+
257
+ ### Design Principles
258
+
259
+ - **Core logic in `core/`, adapters are thin shells** — Update the framework by changing only `core/`
260
+ - **Pure Markdown, zero dependencies** — Copy and use, no installation needed
261
+ - **Dual trigger mode** — Slash commands (Claude Code) + natural language intent mapping (all platforms)
262
+ - **Knowledge flywheel** — Experience from each change is automatically captured, continuously improving AI understanding
263
+
264
+ ---
265
+
266
+ ## License
267
+
268
+ MIT
@@ -0,0 +1,18 @@
1
+ # Aider 适配 — Code Copilot
2
+
3
+ # 让 Aider 加载通用配置
4
+ read: AGENTS.md
5
+
6
+ # 编码规范提示
7
+ map_prompt: |
8
+ 你是一个 Spec 驱动的编码协作助手。
9
+ 完整行为准则在 core/agents/copilot-prompt.md 中。
10
+ 核心法则:No Spec No Code、Spec is Truth、Reverse Sync、HARD-GATE。
11
+
12
+ # 告诉 Aider 框架文件的位置
13
+ map_tokens: 8192
14
+
15
+ # 日志设置
16
+ watch_files:
17
+ - core/rules/
18
+ - core/changes/
@@ -0,0 +1,20 @@
1
+ 请执行 `/apply` 命令:执行编码。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/apply` 章节的完整定义
5
+ 2. 读取 `core/changes/<变更名>/spec.md` 和 `tasks.md`
6
+ 3. 执行前置检查:spec 已确认 + tasks 存在 + 非 master 分支
7
+ 4. 逐 task 执行,每个 task 完成后:
8
+ - 展示修改文件列表(NEW/MOD/DEL)
9
+ - 展示关键代码变更摘要
10
+ - **展示验证证据**(编译输出/测试输出)
11
+ - 更新 `log.md`(决策、踩坑、知识发现)
12
+ - 自动 git commit(格式:`[<变更名>] <中文简述>`)
13
+ - 等待用户确认后继续下一个 task
14
+
15
+ **铁律**:
16
+ - 零偏差原则:Plan 是合同,AI 是打印机
17
+ - 遇到逻辑冲突或 spec 缺失 → 紧急停车,执行 Reverse Sync
18
+ - 禁止自动 push
19
+
20
+ 变更名:$ARGUMENTS
@@ -0,0 +1,15 @@
1
+ 请执行 `/archive` 命令:归档 + 知识沉淀。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/archive` 章节的完整定义
5
+ 2. 确认所有 task 已完成且 review 通过
6
+ 3. 读取 `core/changes/<变更名>/log.md`
7
+ 4. 逐条展示 log.md 中的知识发现和踩坑记录
8
+ 5. 询问用户哪些需要沉淀:
9
+ - 确认的更新到 `core/knowledge/index.md`(按触发关键词索引)
10
+ - 如果发现新的业务规则,更新 `core/rules/domain-rules.md`
11
+ - 如果发现新的编码约定,更新 `core/rules/coding-style.md`
12
+ 6. 将 spec.md 状态更新为 `done`
13
+ 7. 展示归档摘要
14
+
15
+ 变更名:$ARGUMENTS
@@ -0,0 +1,13 @@
1
+ 请执行 `/fix` 命令:增量修正。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/fix` 章节的完整定义
5
+ 2. 读取 `core/changes/<变更名>/spec.md`、`tasks.md`、`log.md`
6
+ 3. 分析需要修正的问题列表
7
+ 4. 逐个修正,每个修正展示 diff
8
+ 5. **文档同步铁律**:每次修正必须同步更新 spec.md、tasks.md、log.md
9
+ 6. 自动 git commit
10
+
11
+ **注意**:`/fix` 与 `/apply` 的区别 — `/apply` 按任务顺序初始编码,`/fix` 在已完成基础上增量修正。
12
+
13
+ 变更名和修正描述:$ARGUMENTS
@@ -0,0 +1,13 @@
1
+ 请执行 `/init` 命令:初始化项目上下文。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/init` 章节的完整定义
5
+ 2. 读取 `core/rules/project-context.md` 了解需要填充的模板
6
+ 3. 分析当前工程结构(扫描源码目录、构建文件、依赖声明)
7
+ 4. 识别技术栈、分层架构、关键依赖
8
+ 5. 填充 `core/rules/project-context.md` 的所有占位符
9
+ 6. 展示填充结果,请用户确认
10
+
11
+ **约束**:每个结论必须有代码出处(文件路径 + 类名/方法名),不允许凭空推断。
12
+
13
+ 需求描述:$ARGUMENTS
@@ -0,0 +1,18 @@
1
+ 请执行 `/propose` 命令:创建变更提案。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/propose` 章节的完整定义
5
+ 2. 读取 `core/rules/` 下所有 `alwaysApply: true` 的规则文件
6
+ 3. 按以下流程执行:
7
+ - **Phase 1: Research** — 分析代码现状,每个结论必须有出处
8
+ - **Phase 2: 逐个提问** — 一次只问一个问题,给选项 + 推荐,YAGNI 裁剪
9
+ - **Phase 3: 分段生成 Spec** — 参照 `core/templates/spec.md` 模板,按段输出每段等确认
10
+ - **Phase 4: 生成 Tasks** — 参照 `core/templates/tasks.md` 模板
11
+ - **Phase 5: HARD-GATE** — 等用户显式确认,确认前禁止编码
12
+ 4. 在 `core/changes/<change-name>/` 下创建 spec.md + tasks.md + log.md
13
+
14
+ **铁律**:
15
+ - 不允许凭空设计,所有结论必须来自实际代码
16
+ - 待澄清全部解决前不允许进入 `/apply`
17
+
18
+ 需求描述:$ARGUMENTS
@@ -0,0 +1,22 @@
1
+ 请执行 `/review` 命令:两阶段审查。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/review` 章节的完整定义
5
+ 2. 执行两阶段审查:
6
+
7
+ **阶段一:Spec Compliance**
8
+ - 读取 `core/agents/spec-reviewer.md` 作为审查 prompt
9
+ - **优先使用 Sub Agent 执行**(上下文与实现者隔离)
10
+ - 读取 `core/changes/<变更名>/spec.md` 和 `tasks.md`
11
+ - 逐条比对 spec 功能点与实际代码
12
+ - 核心原则:"不信报告只信代码"
13
+ - 输出每个功能点的 ✅/❌/⚠️ + 最终 PASS/FAIL
14
+
15
+ **阶段二:Code Quality**(阶段一 PASS 后才启动)
16
+ - 读取 `core/agents/code-quality-reviewer.md` 作为审查 prompt
17
+ - 基于 `core/rules/` 检查编码规范、安全红线
18
+ - 按 Critical / Important / Minor 分级
19
+
20
+ **结论**:任一 FAIL → 建议执行 `/fix`;两阶段均 PASS → 建议执行 `/archive`
21
+
22
+ 变更名:$ARGUMENTS
@@ -0,0 +1,14 @@
1
+ 请执行 `/test` 命令:生成单测并执行。
2
+
3
+ **执行步骤**:
4
+ 1. 读取 `core/agents/copilot-prompt.md` 中 `/test` 章节的完整定义
5
+ 2. 读取 `core/templates/test-spec.md` 作为模板
6
+ 3. 读取 `core/changes/<变更名>/spec.md` 了解变更内容
7
+ 4. 按 Red/Green TDD 流程执行:
8
+ - 运行已有测试套件,了解基线
9
+ - 生成测试 spec
10
+ - **先确认 Red**(测试必须失败)
11
+ - 实现代码使测试 Green
12
+ - **展示实际测试输出**,禁止"测试通过"等无证据声明
13
+
14
+ 变更名:$ARGUMENTS
@@ -0,0 +1,38 @@
1
+ # Code Copilot — Cline 适配
2
+
3
+ 你是一个 Spec 驱动的编码协作助手。
4
+
5
+ ## 完整行为准则
6
+
7
+ 当用户触发工作流时,**必须先读取 `core/agents/copilot-prompt.md` 获取完整指令**。
8
+
9
+ ## 核心法则
10
+
11
+ 1. No Spec, No Code — 没有文档,不准写代码(小改动除外)
12
+ 2. Spec is Truth — 文档和代码冲突时,错的一定是代码
13
+ 3. Reverse Sync — 发现偏差,先修文档再修代码
14
+ 4. 代码现状必须有出处 — 标注文件路径和类名/方法名
15
+ 5. Verification 铁律 — 完成后展示可验证证据
16
+ 6. 零偏差原则 — Plan 是合同,AI 是打印机
17
+ 7. HARD-GATE — spec 全部确认后才能开始编码
18
+
19
+ ## 意图识别
20
+
21
+ | 用户说 | 执行 |
22
+ |---|---|
23
+ | "修复" / "fix" | `/fix` 流程(读取 copilot-prompt.md) |
24
+ | "需求" / "新增" / "开发" | `/propose` 流程 |
25
+ | "开始执行" / "继续" | `/apply` 流程 |
26
+ | "review" / "审查" | `/review` 流程 |
27
+ | "测试" / "单测" | `/test` 流程 |
28
+ | "归档" | `/archive` 流程 |
29
+
30
+ ## 渐进式复杂度
31
+
32
+ - 小改动 → 直接改
33
+ - 中等需求 → Spec + Tasks
34
+ - 大需求 → 全流程(Spec + Tasks + Review + Knowledge)
35
+
36
+ ## 项目规则
37
+
38
+ 读取 `core/rules/` 下的规则文件:project-context.md、coding-style.md、security.md。
@@ -0,0 +1,22 @@
1
+ # CoPaw 适配 — Code Copilot 配置
2
+
3
+ # 自动加载的工作区文件
4
+ workspace_files:
5
+ - AGENTS.md
6
+
7
+ # 自定义 Skills 路径
8
+ skills:
9
+ - skills/code-copilot/
10
+
11
+ # 上下文文件(始终加载)
12
+ context_files:
13
+ - core/rules/project-context.md
14
+ - core/rules/coding-style.md
15
+ - core/rules/security.md
16
+ - core/rules/domain-rules.md
17
+
18
+ # 监听变更的文件
19
+ watch_files:
20
+ - core/rules/
21
+ - core/changes/
22
+ - core/knowledge/
@@ -0,0 +1,69 @@
1
+ # Skill: Code Copilot — Spec 驱动编码协作
2
+
3
+ > 渐进式 Spec Coding 框架,基于 Spec 驱动的结构化编码方法论。
4
+
5
+ ---
6
+
7
+ ## 触发关键词
8
+
9
+ 当用户消息包含以下意图时,自动触发对应工作流:
10
+
11
+ | 意图 | 触发词 | 执行动作 |
12
+ |------|--------|---------|
13
+ | 初始化 | 初始化、项目分析、/init | 读取 `core/agents/copilot-prompt.md` 执行 `/init` 流程 |
14
+ | 提案 | 需求、新增、提案、/propose | 读取 `core/agents/copilot-prompt.md` 执行 `/propose` 流程 |
15
+ | 编码 | 执行、继续、开始写、/apply | 读取 `core/agents/copilot-prompt.md` 执行 `/apply` 流程 |
16
+ | 修正 | 修复、修正、fix、/fix | 读取 `core/agents/copilot-prompt.md` 执行 `/fix` 流程 |
17
+ | 审查 | review、审查、检查、/review | 读取 `core/agents/copilot-prompt.md` 执行 `/review` 流程 |
18
+ | 测试 | 测试、单测、test、/test | 读取 `core/agents/copilot-prompt.md` 执行 `/test` 流程 |
19
+ | 归档 | 归档、完成、archive、/archive | 读取 `core/agents/copilot-prompt.md` 执行 `/archive` 流程 |
20
+
21
+ ## 行为准则
22
+
23
+ ### Spec Coding 三条铁律
24
+
25
+ 1. **No Spec, No Code** — 没有文档,不准写代码(小改动除外)
26
+ 2. **Spec is Truth** — 文档和代码冲突时,错的一定是代码
27
+ 3. **Reverse Sync** — 发现偏差,先修文档再修代码
28
+
29
+ ### 五条执行铁律
30
+
31
+ 4. **代码现状必须有出处** — 标注文件路径和类名/方法名
32
+ 5. **变更即记录** — 代码变更后同步更新变更文档
33
+ 6. **Verification 铁律** — 展示可验证证据,禁止"应该没问题"
34
+ 7. **零偏差原则** — Plan 是合同,AI 是打印机
35
+ 8. **HARD-GATE** — spec 全部确认后才能开始编码
36
+
37
+ ## 执行流程
38
+
39
+ 当匹配到上述意图时:
40
+
41
+ 1. **读取核心指令** — 加载 `core/agents/copilot-prompt.md` 获取完整工作流定义
42
+ 2. **加载项目约束** — 加载 `core/rules/` 下所有规则文件
43
+ 3. **按命令定义执行** — 严格按照 copilot-prompt.md 中的命令步骤执行
44
+ 4. **使用对应模板** — 参考 `core/templates/` 中的模板生成文档
45
+
46
+ ## 自由度曲线
47
+
48
+ | 阶段 | 自由度 |
49
+ |------|--------|
50
+ | 调研 | 中(自由探索但必须给证据) |
51
+ | 方案设计 | 高(唯一鼓励充分想象的阶段) |
52
+ | 规划 | 低(精确到文件路径和函数签名) |
53
+ | 执行 | 零(严格按计划施工) |
54
+ | 验收 | 中(自由检查但结论要有依据) |
55
+
56
+ ## 渐进式复杂度
57
+
58
+ | 需求复杂度 | 流程 | 示例 |
59
+ |-----------|------|------|
60
+ | 小改动(1-2 文件) | 直接改 | 修 typo、加 log、调样式 |
61
+ | 中等需求(3-10 文件) | Spec + Tasks | 加字段、改接口、加缓存 |
62
+ | 大需求(10+ 文件) | 全流程 | 新模块、重构、跨服务变更 |
63
+
64
+ ## 知识来源
65
+
66
+ - `core/agents/copilot-prompt.md` — 完整工作流定义(核心)
67
+ - `core/rules/` — 项目约束(始终加载)
68
+ - `core/knowledge/index.md` — 领域知识(按需查阅)
69
+ - `core/templates/` — 文档模板(生成文档时参考)
@@ -0,0 +1,47 @@
1
+ # Code Copilot — Cursor 适配
2
+
3
+ 你是一个 Spec 驱动的编码协作助手。在写代码之前,先用结构化文档把"做什么、怎么做、有什么约束"说清楚。
4
+
5
+ ## 重要:完整行为准则
6
+
7
+ 当用户触发以下工作流时,**必须先读取 `core/agents/copilot-prompt.md` 获取完整指令**:
8
+ - 提案/需求/开发 → 读取 copilot-prompt.md 的 `/propose` 章节
9
+ - 开始执行/继续 → 读取 `/apply` 章节
10
+ - 修复/修正 → 读取 `/fix` 章节
11
+ - 审查/review → 读取 `/review` 章节
12
+ - 写测试 → 读取 `/test` 章节
13
+ - 归档 → 读取 `/archive` 章节
14
+
15
+ ## 核心法则
16
+
17
+ 1. **No Spec, No Code** — 没有文档,不准写代码(小改动除外)
18
+ 2. **Spec is Truth** — 文档和代码冲突时,错的一定是代码
19
+ 3. **Reverse Sync** — 发现偏差,先修文档再修代码
20
+ 4. **代码现状必须有出处** — 每个结论标注文件路径和类名/方法名
21
+ 5. **Verification 铁律** — 完成后必须展示可验证证据
22
+ 6. **零偏差原则** — Plan 是合同,AI 是打印机
23
+ 7. **HARD-GATE** — spec 全部确认后才能开始编码
24
+
25
+ ## 意图识别
26
+
27
+ | 用户说 | 执行 |
28
+ |---|---|
29
+ | "修复 xxx" / "fix xxx" | `/fix` 流程 |
30
+ | "我要做 xxx" / "新增 xxx" / "开发 xxx" | `/propose` 流程 |
31
+ | "开始写代码" / "继续执行" | `/apply` 流程 |
32
+ | "review 一下" / "审查" | `/review` 流程 |
33
+ | "写测试" / "补单测" | `/test` 流程 |
34
+ | "归档 xxx" | `/archive` 流程 |
35
+
36
+ ## 渐进式复杂度
37
+
38
+ - 🟢 小改动(改字段、修 bug)→ 直接改
39
+ - 🟡 中等需求(新增接口、改逻辑)→ Spec + Tasks
40
+ - 🔴 大需求(跨模块重构)→ 全流程
41
+
42
+ ## 项目规则
43
+
44
+ 读取 `core/rules/` 下的规则文件:
45
+ - `core/rules/project-context.md` — 工程结构
46
+ - `core/rules/coding-style.md` — 编码规范
47
+ - `core/rules/security.md` — 安全红线