nano-spec 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/LICENSE +21 -0
- package/README.md +651 -0
- package/bin/nanospec.js +2 -0
- package/dist/adapters/cline.d.ts +2 -0
- package/dist/adapters/cline.js +51 -0
- package/dist/adapters/cline.test.d.ts +1 -0
- package/dist/adapters/cline.test.js +81 -0
- package/dist/adapters/cursor.d.ts +2 -0
- package/dist/adapters/cursor.js +51 -0
- package/dist/adapters/cursor.test.d.ts +1 -0
- package/dist/adapters/cursor.test.js +81 -0
- package/dist/adapters/iflow.d.ts +2 -0
- package/dist/adapters/iflow.js +39 -0
- package/dist/adapters/iflow.test.d.ts +1 -0
- package/dist/adapters/iflow.test.js +82 -0
- package/dist/adapters/index.d.ts +29 -0
- package/dist/adapters/index.js +16 -0
- package/dist/adapters/index.test.d.ts +1 -0
- package/dist/adapters/index.test.js +73 -0
- package/dist/adapters/qwen.d.ts +2 -0
- package/dist/adapters/qwen.js +51 -0
- package/dist/adapters/qwen.test.d.ts +1 -0
- package/dist/adapters/qwen.test.js +81 -0
- package/dist/adapters/utils.d.ts +59 -0
- package/dist/adapters/utils.js +183 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +52 -0
- package/dist/commands/init.test.d.ts +1 -0
- package/dist/commands/init.test.js +78 -0
- package/dist/commands/new.d.ts +1 -0
- package/dist/commands/new.js +26 -0
- package/dist/commands/new.test.d.ts +1 -0
- package/dist/commands/new.test.js +87 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/static/_AGENTS.md +142 -0
- package/dist/static/commands/spec.1-spec.toml +65 -0
- package/dist/static/commands/spec.2-plan.toml +87 -0
- package/dist/static/commands/spec.3-execute.toml +53 -0
- package/dist/static/commands/spec.accept.toml +60 -0
- package/dist/static/commands/spec.align.toml +58 -0
- package/dist/static/commands/spec.summary.toml +67 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xxih
|
|
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,651 @@
|
|
|
1
|
+
# NanoSpec CLI
|
|
2
|
+
|
|
3
|
+
[English](#english) | [中文](#中文)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 中文
|
|
8
|
+
|
|
9
|
+
一个极简且可扩展的规格驱动框架。不仅适用于代码——也适用于写作、研究和任何你想完成的事情。
|
|
10
|
+
|
|
11
|
+
### 概述
|
|
12
|
+
|
|
13
|
+
NanoSpec CLI 是一个轻量级的命令行工具,帮助你快速初始化规格驱动开发工作流的项目结构。它支持多种 AI 工具(Cursor、qwen、iflow、cline),并提供标准化的规格、规划、执行和验收工作流。
|
|
14
|
+
|
|
15
|
+
### 特性
|
|
16
|
+
|
|
17
|
+
- **极简优先**:只有 6 个斜杠命令,CLI 专注于初始化
|
|
18
|
+
- **即开即用**:`nanospec init` 一键初始化
|
|
19
|
+
- **多 AI 适配**:支持生成不同 AI 工具的命令文件
|
|
20
|
+
- **可定制**:通过修改模板和添加公共文档实现定制
|
|
21
|
+
|
|
22
|
+
### 安装
|
|
23
|
+
|
|
24
|
+
#### 全局安装
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install -g nano-spec
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
#### 本地开发
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 克隆仓库
|
|
34
|
+
git clone <repository-url>
|
|
35
|
+
cd nano-spec
|
|
36
|
+
|
|
37
|
+
# 安装依赖
|
|
38
|
+
npm install
|
|
39
|
+
|
|
40
|
+
# 构建项目
|
|
41
|
+
npm run build
|
|
42
|
+
|
|
43
|
+
# 链接到全局以便测试
|
|
44
|
+
npm link
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 快速开始
|
|
48
|
+
|
|
49
|
+
1. **在项目中初始化 NanoSpec**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 使用默认 AI 工具(Cursor)初始化
|
|
53
|
+
nanospec init
|
|
54
|
+
|
|
55
|
+
# 使用指定的 AI 工具初始化
|
|
56
|
+
nanospec init --ai qwen
|
|
57
|
+
nanospec init --ai iflow
|
|
58
|
+
nanospec init --ai cline
|
|
59
|
+
|
|
60
|
+
# 强制覆盖已存在的文件
|
|
61
|
+
nanospec init --force
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **创建新任务**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 创建默认名称的任务
|
|
68
|
+
nanospec new
|
|
69
|
+
|
|
70
|
+
# 创建自定义名称的任务
|
|
71
|
+
nanospec new "用户认证功能"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **开始工作流**
|
|
75
|
+
|
|
76
|
+
编辑任务目录中的 `brief.md` 文件描述需求,然后使用斜杠命令:
|
|
77
|
+
|
|
78
|
+
- `/spec.1-spec` - 撰写规格
|
|
79
|
+
- `/spec.2-plan` - 创建技术方案和任务拆解
|
|
80
|
+
- `/spec.3-execute` - 执行交付
|
|
81
|
+
- `/spec.accept` - 创建验收用例
|
|
82
|
+
- `/spec.align` - 对齐纠偏
|
|
83
|
+
- `/spec.summary` - 总结沉淀
|
|
84
|
+
|
|
85
|
+
### 项目结构
|
|
86
|
+
|
|
87
|
+
初始化后,你的项目将具有以下结构:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
your-project/
|
|
91
|
+
├── nanospec/
|
|
92
|
+
│ ├── AGENTS.md # 通用规则和指南
|
|
93
|
+
│ ├── templates/ # 输出模板
|
|
94
|
+
│ │ ├── 1-spec.md
|
|
95
|
+
│ │ ├── 2-plan.md
|
|
96
|
+
│ │ ├── 3-tasks.md
|
|
97
|
+
│ │ ├── acceptance.md
|
|
98
|
+
│ │ ├── alignment.md
|
|
99
|
+
│ │ └── summary.md
|
|
100
|
+
│ └── <task-name>/ # 任务目录
|
|
101
|
+
│ ├── brief.md # 需求描述
|
|
102
|
+
│ ├── assets/ # 辅助素材
|
|
103
|
+
│ ├── alignment.md # 对齐记录(可选)
|
|
104
|
+
│ └── outputs/
|
|
105
|
+
│ ├── 1-spec.md
|
|
106
|
+
│ ├── 2-plan.md
|
|
107
|
+
│ ├── 3-tasks.md
|
|
108
|
+
│ ├── acceptance.md
|
|
109
|
+
│ └── summary-*.md
|
|
110
|
+
├── .cursor/commands/ # Cursor 命令(如果使用)
|
|
111
|
+
│ ├── spec.1-spec.md
|
|
112
|
+
│ ├── spec.2-plan.md
|
|
113
|
+
│ ├── spec.3-execute.md
|
|
114
|
+
│ ├── spec.accept.md
|
|
115
|
+
│ ├── spec.align.md
|
|
116
|
+
│ └── spec.summary.md
|
|
117
|
+
└── ... (其他项目文件)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 命令参考
|
|
121
|
+
|
|
122
|
+
#### nanospec init
|
|
123
|
+
|
|
124
|
+
初始化 nanospec 项目结构。
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
nanospec init [选项]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**选项:**
|
|
131
|
+
|
|
132
|
+
- `--ai <tool>`:AI 工具类型(默认:cursor)
|
|
133
|
+
- 可用:cursor, qwen, iflow, cline
|
|
134
|
+
- `-f, --force`:强制覆盖已存在的文件
|
|
135
|
+
|
|
136
|
+
#### nanospec new
|
|
137
|
+
|
|
138
|
+
创建新的任务目录。
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
nanospec new [名称]
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**参数:**
|
|
145
|
+
|
|
146
|
+
- `名称`:任务名称(可选,默认:"待命名")
|
|
147
|
+
|
|
148
|
+
### 工作流指南
|
|
149
|
+
|
|
150
|
+
#### 1. 规格阶段
|
|
151
|
+
|
|
152
|
+
使用 `/spec.1-spec` 根据 `brief.md` 中的需求和 `assets/` 中的辅助材料撰写详细规格。
|
|
153
|
+
|
|
154
|
+
**输出:** `outputs/1-spec.md`
|
|
155
|
+
|
|
156
|
+
#### 2. 规划阶段
|
|
157
|
+
|
|
158
|
+
使用 `/spec.2-plan` 创建技术方案和任务拆解。
|
|
159
|
+
|
|
160
|
+
**输出:**
|
|
161
|
+
|
|
162
|
+
- `outputs/2-plan.md` - 技术方案
|
|
163
|
+
- `outputs/3-tasks.md` - 任务清单
|
|
164
|
+
|
|
165
|
+
#### 3. 执行阶段
|
|
166
|
+
|
|
167
|
+
使用 `/spec.3-execute` 执行任务并交付结果。
|
|
168
|
+
|
|
169
|
+
**操作:** 更新 `outputs/3-tasks.md` 中的任务完成状态
|
|
170
|
+
|
|
171
|
+
#### 4. 验收阶段
|
|
172
|
+
|
|
173
|
+
使用 `/spec.accept` 创建验收用例。
|
|
174
|
+
|
|
175
|
+
**输出:** `outputs/acceptance.md`(可选)
|
|
176
|
+
|
|
177
|
+
#### 5. 对齐阶段
|
|
178
|
+
|
|
179
|
+
当发现冲突、歧义或偏差时,使用 `/spec.align`。
|
|
180
|
+
|
|
181
|
+
**输出:** `alignment.md`(仅在需要时创建)
|
|
182
|
+
|
|
183
|
+
#### 6. 总结阶段
|
|
184
|
+
|
|
185
|
+
使用 `/spec.summary` 总结和文档化已完成的工作。
|
|
186
|
+
|
|
187
|
+
**输出:** `outputs/summary-<日期>.md`(可选)
|
|
188
|
+
|
|
189
|
+
### 优先级规则
|
|
190
|
+
|
|
191
|
+
处理信息时,应用以下优先级:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
alignment.md > brief.md / prd.md > assets/* > 现状
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**重要:** 当任何阶段发生变更时,需要传播变更到:
|
|
198
|
+
|
|
199
|
+
1. `1-spec.md`
|
|
200
|
+
2. `2-plan.md` / `3-tasks.md`
|
|
201
|
+
3. `acceptance.md`(如果存在)
|
|
202
|
+
|
|
203
|
+
### 测试
|
|
204
|
+
|
|
205
|
+
运行测试套件:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# 所有测试
|
|
209
|
+
npm test
|
|
210
|
+
|
|
211
|
+
# 监听模式
|
|
212
|
+
npm run test:watch
|
|
213
|
+
|
|
214
|
+
# 覆盖率报告
|
|
215
|
+
npm run test:coverage
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 构建
|
|
219
|
+
|
|
220
|
+
构建项目用于生产:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npm run build
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
编译后的文件将在 `dist/` 目录中。
|
|
227
|
+
|
|
228
|
+
### 贡献
|
|
229
|
+
|
|
230
|
+
欢迎贡献!请遵循以下指南:
|
|
231
|
+
|
|
232
|
+
1. Fork 仓库
|
|
233
|
+
2. 创建功能分支
|
|
234
|
+
3. 确保所有测试通过
|
|
235
|
+
4. 提交拉取请求
|
|
236
|
+
|
|
237
|
+
### 许可证
|
|
238
|
+
|
|
239
|
+
MIT License
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## English
|
|
244
|
+
|
|
245
|
+
A minimal extendable Spec-Driven framework. Not just for code -- for writing, research, and anything you want to get done.
|
|
246
|
+
|
|
247
|
+
### Overview
|
|
248
|
+
|
|
249
|
+
NanoSpec CLI is a lightweight command-line tool that helps you quickly initialize a Spec-Driven Development workflow project structure. It supports multiple AI tools (Cursor, qwen, iflow, cline) and provides a standardized workflow for specification, planning, execution, and acceptance.
|
|
250
|
+
|
|
251
|
+
### Features
|
|
252
|
+
|
|
253
|
+
- **Minimal & Simple**: Only 6 slash commands, CLI focuses on initialization
|
|
254
|
+
- **Ready to Use**: One-command initialization with `nanospec init`
|
|
255
|
+
- **Multi-AI Support**: Generate command files for different AI tools
|
|
256
|
+
- **Customizable**: Modify templates and add common documents for customization
|
|
257
|
+
|
|
258
|
+
### Installation
|
|
259
|
+
|
|
260
|
+
#### Global Installation
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
npm install -g nano-spec
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### Local Development
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Clone the repository
|
|
270
|
+
git clone <repository-url>
|
|
271
|
+
cd nano-spec
|
|
272
|
+
|
|
273
|
+
# Install dependencies
|
|
274
|
+
npm install
|
|
275
|
+
|
|
276
|
+
# Build the project
|
|
277
|
+
npm run build
|
|
278
|
+
|
|
279
|
+
# Link globally for testing
|
|
280
|
+
npm link
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Quick Start
|
|
284
|
+
|
|
285
|
+
1. **Initialize NanoSpec in your project**
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Initialize with default AI tool (Cursor)
|
|
289
|
+
nanospec init
|
|
290
|
+
|
|
291
|
+
# Initialize with specific AI tool
|
|
292
|
+
nanospec init --ai qwen
|
|
293
|
+
nanospec init --ai iflow
|
|
294
|
+
nanospec init --ai cline
|
|
295
|
+
|
|
296
|
+
# Force overwrite existing files
|
|
297
|
+
nanospec init --force
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
2. **Create a new task**
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Create a task with default name
|
|
304
|
+
nanospec new
|
|
305
|
+
|
|
306
|
+
# Create a task with custom name
|
|
307
|
+
nanospec new "User Authentication"
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
3. **Start the workflow**
|
|
311
|
+
|
|
312
|
+
Edit the `brief.md` file in your task directory to describe your requirements, then use the slash commands:
|
|
313
|
+
|
|
314
|
+
- `/spec.1-spec` - Write specifications
|
|
315
|
+
- `/spec.2-plan` - Create technical plan and task breakdown
|
|
316
|
+
- `/spec.3-execute` - Execute and deliver
|
|
317
|
+
- `/spec.accept` - Create acceptance test cases
|
|
318
|
+
- `/spec.align` - Align and correct deviations
|
|
319
|
+
- `/spec.summary` - Summarize and document
|
|
320
|
+
|
|
321
|
+
### Project Structure
|
|
322
|
+
|
|
323
|
+
After initialization, your project will have the following structure:
|
|
324
|
+
|
|
325
|
+
```
|
|
326
|
+
your-project/
|
|
327
|
+
├── nanospec/
|
|
328
|
+
│ ├── AGENTS.md # General rules and guidelines
|
|
329
|
+
│ ├── templates/ # Output templates
|
|
330
|
+
│ │ ├── 1-spec.md
|
|
331
|
+
│ │ ├── 2-plan.md
|
|
332
|
+
│ │ ├── 3-tasks.md
|
|
333
|
+
│ │ ├── acceptance.md
|
|
334
|
+
│ │ ├── alignment.md
|
|
335
|
+
│ │ └── summary.md
|
|
336
|
+
│ └── <task-name>/ # Task directories
|
|
337
|
+
│ ├── brief.md # Requirement description
|
|
338
|
+
│ ├── assets/ # Supporting materials
|
|
339
|
+
│ ├── alignment.md # Alignment records (optional)
|
|
340
|
+
│ └── outputs/
|
|
341
|
+
│ ├── 1-spec.md
|
|
342
|
+
│ ├── 2-plan.md
|
|
343
|
+
│ ├── 3-tasks.md
|
|
344
|
+
│ ├── acceptance.md
|
|
345
|
+
│ └── summary-*.md
|
|
346
|
+
├── .cursor/commands/ # Cursor commands (if used)
|
|
347
|
+
│ ├── spec.1-spec.md
|
|
348
|
+
│ ├── spec.2-plan.md
|
|
349
|
+
│ ├── spec.3-execute.md
|
|
350
|
+
│ ├── spec.accept.md
|
|
351
|
+
│ ├── spec.align.md
|
|
352
|
+
│ └── spec.summary.md
|
|
353
|
+
└── ... (other project files)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Commands Reference
|
|
357
|
+
|
|
358
|
+
#### nanospec init
|
|
359
|
+
|
|
360
|
+
Initialize NanoSpec project structure.
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
nanospec init [options]
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Options:**
|
|
367
|
+
|
|
368
|
+
- `--ai <tool>`: AI tool type (default: cursor)
|
|
369
|
+
- Available: cursor, qwen, iflow, cline
|
|
370
|
+
- `-f, --force`: Force overwrite existing files
|
|
371
|
+
|
|
372
|
+
#### nanospec new
|
|
373
|
+
|
|
374
|
+
Create a new task directory.
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
nanospec new [name]
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Arguments:**
|
|
381
|
+
|
|
382
|
+
- `name`: Task name (optional, default: "待命名")
|
|
383
|
+
|
|
384
|
+
### Workflow Guide
|
|
385
|
+
|
|
386
|
+
#### 1. Specification Phase
|
|
387
|
+
|
|
388
|
+
Use `/spec.1-spec` to write detailed specifications based on requirements in `brief.md` and supporting materials in `assets/`.
|
|
389
|
+
|
|
390
|
+
**Output:** `outputs/1-spec.md`
|
|
391
|
+
|
|
392
|
+
#### 2. Planning Phase
|
|
393
|
+
|
|
394
|
+
Use `/spec.2-plan` to create technical plans and task breakdowns.
|
|
395
|
+
|
|
396
|
+
**Outputs:**
|
|
397
|
+
|
|
398
|
+
- `outputs/2-plan.md` - Technical plan
|
|
399
|
+
- `outputs/3-tasks.md` - Task checklist
|
|
400
|
+
|
|
401
|
+
#### 3. Execution Phase
|
|
402
|
+
|
|
403
|
+
Use `/spec.3-execute` to execute tasks and deliver results.
|
|
404
|
+
|
|
405
|
+
**Action:** Update task completion status in `outputs/3-tasks.md`
|
|
406
|
+
|
|
407
|
+
#### 4. Acceptance Phase
|
|
408
|
+
|
|
409
|
+
Use `/spec.accept` to create acceptance test cases.
|
|
410
|
+
|
|
411
|
+
**Output:** `outputs/acceptance.md` (optional)
|
|
412
|
+
|
|
413
|
+
#### 5. Alignment Phase
|
|
414
|
+
|
|
415
|
+
Use `/spec.align` when conflicts, ambiguities, or deviations are discovered.
|
|
416
|
+
|
|
417
|
+
**Output:** `alignment.md` (created only when needed)
|
|
418
|
+
|
|
419
|
+
#### 6. Summary Phase
|
|
420
|
+
|
|
421
|
+
Use `/spec.summary` to summarize and document the completed work.
|
|
422
|
+
|
|
423
|
+
**Output:** `outputs/summary-<date>.md` (optional)
|
|
424
|
+
|
|
425
|
+
### Priority Rules
|
|
426
|
+
|
|
427
|
+
When processing information, the following priority is applied:
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
alignment.md > brief.md / prd.md > assets/* > current state
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
**Important:** When changes occur during any phase, propagate them to:
|
|
434
|
+
|
|
435
|
+
1. `1-spec.md`
|
|
436
|
+
2. `2-plan.md` / `3-tasks.md`
|
|
437
|
+
3. `acceptance.md` (if exists)
|
|
438
|
+
|
|
439
|
+
### Testing
|
|
440
|
+
|
|
441
|
+
Run the test suite:
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
# All tests
|
|
445
|
+
npm test
|
|
446
|
+
|
|
447
|
+
# Watch mode
|
|
448
|
+
npm run test:watch
|
|
449
|
+
|
|
450
|
+
# Coverage report
|
|
451
|
+
npm run test:coverage
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Building
|
|
455
|
+
|
|
456
|
+
Build the project for production:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
npm run build
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
The compiled files will be in the `dist/` directory.
|
|
463
|
+
|
|
464
|
+
### Contributing
|
|
465
|
+
|
|
466
|
+
Contributions are welcome! Please follow these guidelines:
|
|
467
|
+
|
|
468
|
+
1. Fork the repository
|
|
469
|
+
2. Create a feature branch
|
|
470
|
+
3. Ensure all tests pass
|
|
471
|
+
4. Submit a pull request
|
|
472
|
+
|
|
473
|
+
### License
|
|
474
|
+
|
|
475
|
+
MIT License
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## Local Development Guide / 本地开发指南
|
|
480
|
+
|
|
481
|
+
### Prerequisites / 前置要求
|
|
482
|
+
|
|
483
|
+
- Node.js >= 18
|
|
484
|
+
- npm or yarn
|
|
485
|
+
- Git (optional, for version control)
|
|
486
|
+
|
|
487
|
+
### Development Workflow / 开发工作流
|
|
488
|
+
|
|
489
|
+
1. **Clone and Setup / 克隆和设置**
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
git clone <repository-url>
|
|
493
|
+
cd nano-spec
|
|
494
|
+
npm install
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
2. **Development Mode / 开发模式**
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
# Run in development mode with tsx
|
|
501
|
+
# 使用 tsx 在开发模式下运行
|
|
502
|
+
npm run dev
|
|
503
|
+
|
|
504
|
+
# Run with specific commands
|
|
505
|
+
# 运行特定命令
|
|
506
|
+
npm run dev init
|
|
507
|
+
npm run dev new "My Task"
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
3. **Building / 构建**
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
# Build TypeScript to JavaScript
|
|
514
|
+
# 将 TypeScript 编译为 JavaScript
|
|
515
|
+
npm run build
|
|
516
|
+
|
|
517
|
+
# The output will be in the dist/ directory
|
|
518
|
+
# 输出将在 dist/ 目录中
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
4. **Testing / 测试**
|
|
522
|
+
|
|
523
|
+
```bash
|
|
524
|
+
# Run all tests
|
|
525
|
+
# 运行所有测试
|
|
526
|
+
npm test
|
|
527
|
+
|
|
528
|
+
# Run tests in watch mode
|
|
529
|
+
# 在监听模式下运行测试
|
|
530
|
+
npm run test:watch
|
|
531
|
+
|
|
532
|
+
# Generate coverage report
|
|
533
|
+
# 生成覆盖率报告
|
|
534
|
+
npm run test:coverage
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### Project Structure for Development / 开发项目结构
|
|
538
|
+
|
|
539
|
+
```
|
|
540
|
+
nano-spec/
|
|
541
|
+
├── src/
|
|
542
|
+
│ ├── index.ts # CLI entry point / CLI 入口点
|
|
543
|
+
│ ├── commands/
|
|
544
|
+
│ │ ├── init.ts # nanospec init command / nanospec init 命令
|
|
545
|
+
│ │ └── new.ts # nanospec new command / nanospec new 命令
|
|
546
|
+
│ ├── adapters/
|
|
547
|
+
│ │ ├── index.ts # Adapter registry / 适配器注册
|
|
548
|
+
│ │ ├── cursor.ts # Cursor adapter / Cursor 适配器
|
|
549
|
+
│ │ ├── qwen.ts # qwen adapter / qwen 适配器
|
|
550
|
+
│ │ ├── iflow.ts # iflow adapter / iflow 适配器
|
|
551
|
+
│ │ └── cline.ts # cline adapter / cline 适配器
|
|
552
|
+
│ └── templates/ # Built-in templates / 内置模板
|
|
553
|
+
│ ├── AGENTS.md
|
|
554
|
+
│ ├── commands/
|
|
555
|
+
│ │ ├── spec.1-spec.md
|
|
556
|
+
│ │ ├── spec.2-plan.md
|
|
557
|
+
│ │ ├── spec.3-execute.md
|
|
558
|
+
│ │ ├── spec.accept.md
|
|
559
|
+
│ │ ├── spec.align.md
|
|
560
|
+
│ │ └── spec.summary.md
|
|
561
|
+
│ └── outputs/
|
|
562
|
+
│ ├── 1-spec.md
|
|
563
|
+
│ ├── 2-plan.md
|
|
564
|
+
│ ├── 3-tasks.md
|
|
565
|
+
│ ├── acceptance.md
|
|
566
|
+
│ ├── alignment.md
|
|
567
|
+
│ └── summary.md
|
|
568
|
+
├── bin/
|
|
569
|
+
│ └── nanospec.js # CLI entry point / CLI 入口点
|
|
570
|
+
├── package.json
|
|
571
|
+
├── tsconfig.json
|
|
572
|
+
├── vitest.config.ts
|
|
573
|
+
└── README.md
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Adding a New AI Adapter / 添加新的 AI 适配器
|
|
577
|
+
|
|
578
|
+
1. Create adapter file in `src/adapters/` / 在 `src/adapters/` 中创建适配器文件:
|
|
579
|
+
|
|
580
|
+
```typescript
|
|
581
|
+
// src/adapters/mytool.ts
|
|
582
|
+
import {mkdirSync, cpSync} from 'fs';
|
|
583
|
+
import {join} from 'path';
|
|
584
|
+
import type {AIAdapter} from './index.js';
|
|
585
|
+
|
|
586
|
+
export const mytoolAdapter: AIAdapter = {
|
|
587
|
+
name: 'mytool',
|
|
588
|
+
commandsDir: '.mytool/commands/',
|
|
589
|
+
|
|
590
|
+
generateCommands(cwd: string, templatesDir: string): void {
|
|
591
|
+
const commandsDir = join(cwd, '.mytool', 'commands');
|
|
592
|
+
mkdirSync(commandsDir, {recursive: true});
|
|
593
|
+
|
|
594
|
+
// Copy command templates
|
|
595
|
+
// 复制命令模板
|
|
596
|
+
const commands = [
|
|
597
|
+
'spec.1-spec.md',
|
|
598
|
+
'spec.2-plan.md'
|
|
599
|
+
// ... other commands
|
|
600
|
+
];
|
|
601
|
+
|
|
602
|
+
for (const cmd of commands) {
|
|
603
|
+
const src = join(templatesDir, 'commands', cmd);
|
|
604
|
+
const dest = join(commandsDir, cmd);
|
|
605
|
+
cpSync(src, dest);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
2. Register the adapter in `src/adapters/index.ts` / 在 `src/adapters/index.ts` 中注册适配器:
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
import {mytoolAdapter} from './mytool.js';
|
|
615
|
+
|
|
616
|
+
const adapters: Record<string, AIAdapter> = {
|
|
617
|
+
cursor: cursorAdapter,
|
|
618
|
+
qwen: qwenAdapter,
|
|
619
|
+
iflow: iflowAdapter,
|
|
620
|
+
cline: clineAdapter,
|
|
621
|
+
mytool: mytoolAdapter // Add new adapter / 添加新适配器
|
|
622
|
+
};
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
3. Add tests for the new adapter / 为新适配器添加测试
|
|
626
|
+
|
|
627
|
+
4. Run tests to ensure everything works / 运行测试确保一切正常
|
|
628
|
+
|
|
629
|
+
### Customizing Templates / 自定义模板
|
|
630
|
+
|
|
631
|
+
You can customize the templates by modifying files in `src/templates/`:
|
|
632
|
+
你可以通过修改 `src/templates/` 中的文件来自定义模板:
|
|
633
|
+
|
|
634
|
+
- **AGENTS.md**: General rules and guidelines / 通用规则和指南
|
|
635
|
+
- **commands/**: Slash command definitions / 斜杠命令定义
|
|
636
|
+
- **outputs/**: Output document templates / 输出文档模板
|
|
637
|
+
|
|
638
|
+
After modifying templates, rebuild the project:
|
|
639
|
+
修改模板后,重新构建项目:
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
npm run build
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
647
|
+
## Support / 支持
|
|
648
|
+
|
|
649
|
+
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/xxih/nano-spec).
|
|
650
|
+
|
|
651
|
+
如有问题、疑问或贡献,请访问 [GitHub 仓库](https://github.com/xxih/nano-spec)。
|
package/bin/nanospec.js
ADDED