ai-spec-tool 0.1.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/LICENSE +21 -0
- package/README.md +35 -0
- package/assets/.agents/skills/bugfix/SKILL.md +32 -0
- package/assets/.agents/skills/plan/SKILL.md +323 -0
- package/assets/.agents/skills/plan-executor/SKILL.md +310 -0
- package/assets/.agents/skills/rules-creator/SKILL.md +19 -0
- package/assets/.agents/skills/rules-creator/assets/architecture-gen.md +214 -0
- package/assets/.agents/skills/rules-creator/assets/naming-rule-gen.md +77 -0
- package/assets/.agents/skills/rules-creator/assets/ui-architecture-gen.md +332 -0
- package/assets/.agents/skills/rules-creator/assets/ui-template-gen.md +127 -0
- package/assets/.agents/skills/rules-creator/assets/vision-gen.md +613 -0
- package/assets/.agents/skills/spec-executor/SKILL.md +120 -0
- package/assets/AGENTS.md +30 -0
- package/bin/ai-spec-tool.js +150 -0
- package/package.json +25 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# ai-spec-tool
|
|
2
|
+
|
|
3
|
+
Installable agents + rules for AI spec workflows.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx ai-spec-tool init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### What it does
|
|
12
|
+
|
|
13
|
+
- Installs `.agents/` into the current project (merge-safe).
|
|
14
|
+
- Updates/creates `AGENTS.md` using an anchored block so local edits are preserved.
|
|
15
|
+
- Conflicts are written as `*.incoming` next to the original file.
|
|
16
|
+
|
|
17
|
+
### AGENTS.md update strategy
|
|
18
|
+
|
|
19
|
+
The CLI looks for the block below and replaces its content if present. If not found, it appends the block.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
<!-- AI-SPEC-TOOL:START -->
|
|
23
|
+
... managed content ...
|
|
24
|
+
<!-- AI-SPEC-TOOL:END -->
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Conflict handling
|
|
28
|
+
|
|
29
|
+
- New file missing: copy in
|
|
30
|
+
- Same file: skip
|
|
31
|
+
- Different file: write `<file>.incoming` (do not overwrite your file)
|
|
32
|
+
|
|
33
|
+
## Requirements
|
|
34
|
+
|
|
35
|
+
- Node.js 18+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bugfix
|
|
3
|
+
description: 用户提供报错信息或描述异常行为时使用
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## 依赖(必须存在且必须遵守)
|
|
7
|
+
- docs/global/naming-rule.md
|
|
8
|
+
- docs/global/vision.md
|
|
9
|
+
- docs/global/architecture.md
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 流程(严格执行)
|
|
13
|
+
|
|
14
|
+
### 1) 依赖检查(强制)
|
|
15
|
+
- 你必须先尝试读取并理解所有依赖文件内容。
|
|
16
|
+
- 若任何依赖文件无法读取/不存在/内容为空:视为“依赖未满足”,进入步骤 2。
|
|
17
|
+
- 若所有依赖已满足:进入步骤 3。
|
|
18
|
+
|
|
19
|
+
### 2) 依赖缺失
|
|
20
|
+
- 你必须只输出以下内容(禁止其他内容):
|
|
21
|
+
`缺少依赖[<依赖名称>]\n回复「Y」开始创建依赖。`
|
|
22
|
+
- 下一run使用 skill: rules-creator
|
|
23
|
+
|
|
24
|
+
### 3) 依赖满足
|
|
25
|
+
- 帮助用户修正问题
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan
|
|
3
|
+
description: 用户明确需要一个新的系统、模块或功能体系,或对既有系统进行修改;本 skill 用于生成“非确定性架构裁决 Plan”
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
#前置依赖(强制)
|
|
7
|
+
|
|
8
|
+
## 依赖的规范文件(必须全部存在)
|
|
9
|
+
- docs/global/vision.md
|
|
10
|
+
- docs/global/architecture.md
|
|
11
|
+
- docs/global/naming-rule.md
|
|
12
|
+
|
|
13
|
+
## 依赖检查流程(不可跳过)
|
|
14
|
+
- 你必须先尝试读取并理解所有依赖文件内容
|
|
15
|
+
- 若任何依赖文件无法读取 / 不存在 / 内容为空:
|
|
16
|
+
- **只能输出以下内容(禁止输出任何其他文字)**
|
|
17
|
+
> 缺少依赖[<依赖名称>]
|
|
18
|
+
> 回复「Y」开始创建依赖
|
|
19
|
+
- 下一次 run 必须使用 skill: rules-creator
|
|
20
|
+
- 若所有依赖均存在,才可继续
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1) 框架存在性检查(强制)
|
|
25
|
+
|
|
26
|
+
在进入需求澄清前,必须确认当前项目是否已建立 `docs/global/architecture.md` 中「技术栈选择」指定的主框架。
|
|
27
|
+
默认项目根目录为 `./project`(若不存在则视为尚未建立框架)。
|
|
28
|
+
|
|
29
|
+
执行规则:
|
|
30
|
+
- 先读取 `docs/global/architecture.md` 的「技术栈选择」
|
|
31
|
+
- 判断 `./project` 内是否已具备该框架的标准结构/配置
|
|
32
|
+
- 若尚未建立:
|
|
33
|
+
- 必须先询问用户是否需要你建立框架
|
|
34
|
+
- 若用户同意:**只能使用该框架的主流标准初始化指令**(例如官方 CLI/脚手架),且必须初始化在 `./project`
|
|
35
|
+
- **禁止在 `./` 根目录初始化**,也禁止手动逐文件创建
|
|
36
|
+
- 若用户拒绝:停止并等待用户自行处理
|
|
37
|
+
- 若已建立框架:
|
|
38
|
+
- 检查 `.vscode/launch.json` 是否存在
|
|
39
|
+
- 若不存在:询问用户是否需要你建立**符合该技术框架**的快速启动方案
|
|
40
|
+
- **专案根目录为 `./project/`,但`launch.json`是在`.vscode/launch.json` 而不是`.vscode/project/launch.json`
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 2) 需求澄清阶段(强制)
|
|
45
|
+
|
|
46
|
+
### 2.1 澄清目的(不可偏离)
|
|
47
|
+
|
|
48
|
+
* 本阶段**仅用于理解用户真实意图与需求边界**
|
|
49
|
+
* 本阶段**不产出任何设计或结论**
|
|
50
|
+
* 在本阶段中 **严禁**:
|
|
51
|
+
|
|
52
|
+
* 讨论或暗示模块类型(Service / Adapter / Core 等)
|
|
53
|
+
* 讨论架构、分层、依赖关系
|
|
54
|
+
* 讨论技术选型、实现方式、数据结构
|
|
55
|
+
* 产出任何 spec、plan 或设计草案
|
|
56
|
+
|
|
57
|
+
> ⚠️ 本阶段的唯一目标:**把「用户真正想做什么」问清楚**
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### 2.2 澄清问题(强制逐题、单题执行)
|
|
62
|
+
|
|
63
|
+
* 以下问题 **必须按顺序逐题完成**
|
|
64
|
+
* **一次只允许提出一个问题**
|
|
65
|
+
* 在当前问题尚未获得用户确认前:
|
|
66
|
+
|
|
67
|
+
* ❌ 不得显示后续问题
|
|
68
|
+
* ❌ 不得列出问题清单
|
|
69
|
+
* ❌ 不得暗示「接下来还会问什么」
|
|
70
|
+
* 每一题都视为一个独立对话回合
|
|
71
|
+
|
|
72
|
+
> ⚠️ 违反上述规则,视为澄清流程失败
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### 2.3 提问与回应格式(强制)
|
|
77
|
+
|
|
78
|
+
**每一轮提问必须严格遵守以下结构,不得增删:**
|
|
79
|
+
|
|
80
|
+
1. 提出 **当前问题(仅此一题)**
|
|
81
|
+
2. 基于以下信息,给出一段 **猜测性建议答案**:
|
|
82
|
+
|
|
83
|
+
* 已完成的前序问题回答
|
|
84
|
+
* `vision.md`
|
|
85
|
+
* `architecture.md`
|
|
86
|
+
* `naming-rule.md`
|
|
87
|
+
3. 明确提示用户操作方式:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
回复「Y」接受上述建议,
|
|
91
|
+
或直接输入你的实际答案。
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
* 猜测性建议答案的目的仅是:
|
|
95
|
+
|
|
96
|
+
* 帮助用户更快理解问题
|
|
97
|
+
* 降低回答成本
|
|
98
|
+
* **不得**:
|
|
99
|
+
|
|
100
|
+
* 引导用户做架构、模块、实现相关决策
|
|
101
|
+
* 在建议答案中偷渡解决方案
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### 2.4 澄清问题池(内部使用,不得一次性输出)
|
|
106
|
+
|
|
107
|
+
> 以下问题仅作为**内部顺序控制用**
|
|
108
|
+
> **不得在任何一次输出中同时展示多个问题**
|
|
109
|
+
|
|
110
|
+
#### 问题 1
|
|
111
|
+
|
|
112
|
+
你这次想新增或修改的核心能力是什么?
|
|
113
|
+
(完成后,系统「多了什么」或「哪里不一样」?)
|
|
114
|
+
|
|
115
|
+
#### 问题 2
|
|
116
|
+
|
|
117
|
+
这个能力通常在什么情境下被需要?
|
|
118
|
+
(谁、在什么情况下,会用到它?)
|
|
119
|
+
|
|
120
|
+
#### 问题 3
|
|
121
|
+
|
|
122
|
+
和现在相比,这次变更会让哪些行为或结果发生改变?
|
|
123
|
+
|
|
124
|
+
#### 问题 4
|
|
125
|
+
|
|
126
|
+
你觉得这个能力最容易出问题的地方是什么?
|
|
127
|
+
(例如:状态混乱、规则分散、依赖外部、不稳定)
|
|
128
|
+
|
|
129
|
+
#### 问题 5
|
|
130
|
+
|
|
131
|
+
如果这次改动出错,你最不能接受的失败结果是什么?
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 2.5 推进规则(状态机约束)
|
|
136
|
+
|
|
137
|
+
* 若尚未取得 **问题 N** 的有效回答:
|
|
138
|
+
|
|
139
|
+
* **只能**继续停留在问题 N
|
|
140
|
+
* 当用户:
|
|
141
|
+
|
|
142
|
+
* 回复「Y」→ 视为接受建议答案,记录为该题结论
|
|
143
|
+
* 输入自定义答案 → 以用户答案为准,覆盖建议
|
|
144
|
+
* 完成问题 N 后:
|
|
145
|
+
|
|
146
|
+
* 下一轮对话 **只能**提出问题 N+1
|
|
147
|
+
* 在问题 1~5 全部完成前:
|
|
148
|
+
|
|
149
|
+
* ❌ 不得总结
|
|
150
|
+
* ❌ 不得生成 plan / spec / 模块拆分
|
|
151
|
+
* ❌ 不得进入下一阶段
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### 2.6 违规防护(强制)
|
|
156
|
+
|
|
157
|
+
* 若当前问题未完成,却出现以下任一行为,必须立即自我修正并重新提问当前问题:
|
|
158
|
+
|
|
159
|
+
* 提前出现后续问题内容
|
|
160
|
+
* 总结尚未完成的澄清结果
|
|
161
|
+
* 引入架构 / 模块 / 实现讨论
|
|
162
|
+
* 解释「接下来会做什么」
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 3) Plan 生成原则(非常重要)
|
|
167
|
+
|
|
168
|
+
### 3.1 Plan 的角色定义
|
|
169
|
+
- plan.md 是 **非确定性架构裁决的集合**
|
|
170
|
+
- plan.md 是 **plan 执行器的输入**
|
|
171
|
+
- plan.md 的内容应:
|
|
172
|
+
- 让后续 module spec 的生成 **几乎不需要猜**
|
|
173
|
+
- 明确哪些事情已经被裁决,后续不得再推断
|
|
174
|
+
|
|
175
|
+
### 3.2 禁止在 Plan 中出现的内容
|
|
176
|
+
- ❌ 文件创建顺序
|
|
177
|
+
- ❌ 技术选型
|
|
178
|
+
- ❌ 实现细节
|
|
179
|
+
- ❌ 函数名 / API / 参数
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 4) plan.md 输出结构(强制使用,不得增删章节)
|
|
184
|
+
|
|
185
|
+
你**必须**生成符合以下结构的 plan.md:
|
|
186
|
+
|
|
187
|
+
<以下为plan.md输出范例>
|
|
188
|
+
---
|
|
189
|
+
plan_id: <自动生成>
|
|
190
|
+
kind: <feature|update|refactor>
|
|
191
|
+
scope: <系统或子系统>
|
|
192
|
+
version: 1
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### intent
|
|
198
|
+
|
|
199
|
+
* goal: 架构目标(列表)
|
|
200
|
+
* non_goals: 明确不做的事(列表)
|
|
201
|
+
* success_criteria: 可验证完成标准(列表)
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### modules
|
|
206
|
+
|
|
207
|
+
* 必须以 **module 为单位**
|
|
208
|
+
* 每个 module **必须包含以下字段**:
|
|
209
|
+
|
|
210
|
+
* name
|
|
211
|
+
* type
|
|
212
|
+
* change
|
|
213
|
+
* purpose
|
|
214
|
+
* capabilities(reads / writes / events / subscribes / calls 等)
|
|
215
|
+
* ownership(ssot_facts / state_owner)
|
|
216
|
+
* dependencies(must / forbid)
|
|
217
|
+
* constraints(must / must_not)
|
|
218
|
+
* collaboration
|
|
219
|
+
* 若 state_owner=true,必须包含 state_model
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
### flows
|
|
224
|
+
|
|
225
|
+
* use_cases:以结构化 chain 描述关键流程
|
|
226
|
+
* 每个 use case 必须明确:
|
|
227
|
+
|
|
228
|
+
* trigger
|
|
229
|
+
* actor
|
|
230
|
+
* action
|
|
231
|
+
* target
|
|
232
|
+
* outcome
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### rules
|
|
237
|
+
|
|
238
|
+
* hard: 全局不可违反规则(列表)
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
### execution_steps
|
|
242
|
+
|
|
243
|
+
* 必须提供「建议修改流程」的最小步骤
|
|
244
|
+
* 必须按 **模块依赖关系** 排序:先基础依赖、后上层组合
|
|
245
|
+
* **必须覆盖本次 plan 中所有 modules**
|
|
246
|
+
* 每一步 **只能提到一个 module**(新增或修改),不得合并
|
|
247
|
+
* 每一步必须使用 **有序列表**(1. 2. 3.)来强调顺序
|
|
248
|
+
* 允许引用模块名或章节名,但不得包含实现细节、函数名、API 或文件路径
|
|
249
|
+
* 每一步需可被 spec-executor 按序执行或核对
|
|
250
|
+
* 若依赖顺序无法确定,必须停止并向用户补问
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
<以上为plan.md输出范例>
|
|
254
|
+
|
|
255
|
+
## 5) 若信息不足的处理规则(强制)
|
|
256
|
+
|
|
257
|
+
* 若无法确定 module 边界 / 状态归属 / SSOT:
|
|
258
|
+
|
|
259
|
+
* **必须停止**
|
|
260
|
+
* 明确列出缺失信息
|
|
261
|
+
* 向用户提问补充
|
|
262
|
+
* ❌ 不得在信息不足时生成假设性 plan.md
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 6) 最终输出要求(非常重要)
|
|
267
|
+
- 1.生成一份 Plan 文件
|
|
268
|
+
- 文件路径:`./docs/plan/<index>-<plan目标>.md`
|
|
269
|
+
- `<index>`:根据 `./docs/plan/` 目录下已有文件数量顺序递增生成
|
|
270
|
+
- `<plan目标>`:在完成需求澄清后,根据本次变更的核心意图自动总结生成
|
|
271
|
+
- 输出格式:Markdown
|
|
272
|
+
- 语言:中文为主
|
|
273
|
+
|
|
274
|
+
- 2.文字输出
|
|
275
|
+
> 已完成plan文件的生成<显示文件名(带有超链接)>
|
|
276
|
+
>
|
|
277
|
+
> 接下来
|
|
278
|
+
> 1.讨论修改plan文件细节
|
|
279
|
+
> 2.直接执行plan
|
|
280
|
+
- 直接执行plan → 使用 skill: plan-executor
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
## 6) 最终输出要求(非常重要)
|
|
284
|
+
|
|
285
|
+
### 6.1 Plan 文件生成(强制)
|
|
286
|
+
|
|
287
|
+
- 在完成「需求澄清阶段」全部问题后:
|
|
288
|
+
- **必须生成一份 Plan 文件**
|
|
289
|
+
- **不得将 Plan 文件内容直接输出在对话中**
|
|
290
|
+
|
|
291
|
+
#### 文件路径规则
|
|
292
|
+
- 文件路径:`./docs/plan/<index>-<plan目标>.md`
|
|
293
|
+
|
|
294
|
+
- `<index>`:
|
|
295
|
+
- 根据 `./docs/plan/` 目录下已有文件数量
|
|
296
|
+
- 以递增顺序生成(001, 002, 003 ...)
|
|
297
|
+
|
|
298
|
+
- `<plan目标>`:
|
|
299
|
+
- 在完成需求澄清后
|
|
300
|
+
- 根据本次变更的核心意图自动总结生成
|
|
301
|
+
- 不包含技术名词或实现细节
|
|
302
|
+
|
|
303
|
+
#### 文件格式
|
|
304
|
+
- 内容格式:Markdown
|
|
305
|
+
- 语言:中文为主
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
### 6.2 对话反馈(唯一允许的文字输出)
|
|
310
|
+
|
|
311
|
+
在 Plan 文件生成完成后,对话中**只允许**输出以下结构:
|
|
312
|
+
|
|
313
|
+
> 已完成 Plan 文件的生成:
|
|
314
|
+
> `<文件名>`(需为可点击超链接)
|
|
315
|
+
|
|
316
|
+
> 接下来你可以选择:
|
|
317
|
+
> 1. 讨论并修改 Plan 文件细节
|
|
318
|
+
> 2. 直接执行 Plan(将进入 plan-executor,并把 plan 改名为 `.processing.md`)
|
|
319
|
+
|
|
320
|
+
- 若用户选择「直接执行 Plan」:
|
|
321
|
+
- **必须使用** `skill: plan-executor`
|
|
322
|
+
- 不得再次生成或修改 Plan 文件
|
|
323
|
+
```
|