nano-spec 1.1.0 → 1.1.1

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 CHANGED
@@ -1,1435 +1,130 @@
1
1
  # NanoSpec CLI
2
2
 
3
- [English](#english) | [中文](#中文)
3
+ 轻量、可扩展的 Spec 驱动工作流工具。用统一流程把需求落成可执行任务:
4
+ `brief -> spec -> plan -> execute`。
4
5
 
5
- ---
6
-
7
- ## 中文
8
-
9
- 一个极简且可扩展的 Spec-Driven 框架。不仅适用于代码——也适用于写作、研究和任何你想完成的事情。
10
-
11
- ### 快速开始(3 分钟上手)
6
+ ## 3 分钟上手
12
7
 
13
8
  ```bash
14
- # 1. 安装
9
+ # 1) 安装
15
10
  npm install -g nano-spec
16
11
 
17
- # 2. 在你的项目中初始化(交互式选择 AI 工具)
18
- nanospec init
19
-
20
- # 3. 创建第一个任务
21
- nanospec new "用户登录功能"
22
-
23
- # 4. 编辑 brief.md 描述需求,然后使用 AI 工具中的斜杠命令:
24
- # /spec.1-spec → /spec.2-plan → /spec.3-execute
25
- ```
26
-
27
- 就这么简单!你的项目现在有了一个标准化的规格驱动开发工作流。
28
-
29
- ---
30
-
31
- ### 为什么选择 NanoSpec?
32
-
33
- **🎯 专注工作流,不绑定工具**
34
-
35
- - 支持 8 个主流 AI 工具:Cursor、Qwen、iFlow、Cline、Claude Code、GitHub Copilot、Windsurf、Kilo Code
36
- - 团队成员用不同工具,依然保持统一的协作规范
37
- - 随时切换工具,无缝衔接
38
-
39
- **📦 开箱即用,零配置**
40
-
41
- - 一条命令初始化项目结构
42
- - 内置完整工作流命令(规格 → 方案 → 执行 → 验收)
43
- - 4 个领域预设包(前端、后端、重构、文档),一键安装
44
-
45
- **🔄 支持断点续作**
46
-
47
- - 自动记录当前任务,随时中断下次继续
48
- - 多任务并行,快速切换
49
- - 对齐记录机制,确保变更一致性
50
-
51
- **⚙️ 高度可定制**
52
-
53
- - 多级配置系统(项目级 > 用户级 > 默认)
54
- - 自定义模板和命令
55
- - 通过预设包快速注入领域能力
56
-
57
- ---
58
-
59
- ### 典型使用场景
60
-
61
- **场景 1:前端团队开发新功能**
62
-
63
- ```bash
64
- # 初始化项目(选择 Cursor + GitHub Copilot)
65
- nanospec init
66
-
67
- # 安装前端预设包(包含组件/状态/交互规范)
68
- nanospec preset install frontend
69
-
70
- # 创建任务
71
- nanospec new "购物车功能"
72
-
73
- # 在 Cursor 中使用 /spec.1-spec 撰写规格
74
- # AI 会自动应用前端预设的规范
75
- ```
76
-
77
- **场景 2:后端团队重构 API**
78
-
79
- ```bash
80
- # 初始化项目(选择 Qwen)
81
- nanospec init
82
-
83
- # 安装重构预设包(包含评审/风险控制清单)
84
- nanospec preset install refactor
85
-
86
- # 创建任务
87
- nanospec new "用户 API 重构"
88
-
89
- # 使用 /spec.run 一键执行工作流
90
- # AI 会自动检查 API 设计规范和潜在风险
91
- ```
92
-
93
- **场景 3:个人写技术文档**
94
-
95
- ```bash
96
- # 初始化项目
12
+ # 2) 初始化(默认交互式选择 AI 工具)
97
13
  nanospec init
98
14
 
99
- # 安装文档预设包(包含信息架构/受众分析模板)
100
- nanospec preset install docs
101
-
102
- # 创建任务
103
- nanospec new "系统架构文档"
104
-
105
- # 使用 /spec.clarify 澄清模糊点
106
- # AI 会帮你检查信息架构是否完整
107
- ```
108
-
109
- ---
110
-
111
- ### 核心工作流
112
-
113
- NanoSpec 将工作流标准化为 6 个阶段,每个阶段都有明确的产出物:
114
-
115
- ```
116
- brief.md(需求)
117
-
118
- 1-spec.md(规格)
119
-
120
- 2-plan.md(方案) + 3-tasks.md(任务清单)
121
-
122
- 执行任务(逐项完成并勾选)
123
-
124
- acceptance.md(验收)
125
-
126
- summary.md(总结)
127
- ```
128
-
129
- **对齐机制**:任何阶段发现问题,使用 `/spec.align` 记录并跟踪关闭。
130
-
131
- ---
132
-
133
- ### CLI 命令速查
134
-
135
- | 命令 | 说明 | 示例 |
136
- | -------- | ---------------------------------- | -------------------------------------- |
137
- | `init` | 初始化项目(交互式选择 AI 工具) | `nanospec init` |
138
- | `new` | 创建新任务(自动设为当前任务) | `nanospec new "任务名"` |
139
- | `switch` | 切换当前任务(无参数时交互式选择) | `nanospec switch` |
140
- | `status` | 查看当前状态 | `nanospec status` |
141
- | `config` | 配置管理 | `nanospec config set specs_root specs` |
142
- | `preset` | 预设包管理 | `nanospec preset install frontend` |
143
- | `sync` | 同步命令到 AI 工具 | `nanospec sync --adapter cursor` |
144
-
145
- **AI 工具中的斜杠命令**:
146
-
147
- - `/spec.1-spec` - 撰写规格
148
- - `/spec.2-plan` - 创建技术方案和任务拆解
149
- - `/spec.3-execute` - 执行交付
150
- - `/spec.accept` - 创建验收用例
151
- - `/spec.align` - 对齐纠偏
152
- - `/spec.summary` - 总结沉淀
153
- - `/spec.init` - 初始化或创建任务(辅助)
154
- - `/spec.run` - 一键执行工作流(辅助)
155
- - `/spec.clarify` - 澄清规格模糊点(辅助)
156
-
157
- ---
158
-
159
- ### 配置系统
160
-
161
- NanoSpec 支持多级配置,优先级:**项目级 > 用户级 > 默认**
162
-
163
- **配置文件位置**:
164
-
165
- - 项目级:`.nanospecrc` 或 `nanospec.config.js`(项目根目录)
166
- - 用户级:`~/.nanospecrc`
167
-
168
- **常用配置项**:
169
-
170
- ```json
171
- {
172
- "specs_root": "nanospec", // 规格根目录名
173
- "cmd_prefix": "spec", // 命令前缀
174
- "default_adapter": "cursor", // 默认 AI 工具
175
- "auto_sync": true // init 时自动同步
176
- }
15
+ # 3) 创建任务
16
+ nanospec new "优化登录流程"
177
17
  ```
178
18
 
179
- **配置命令**:
180
-
181
- ```bash
182
- # 查看当前配置
183
- nanospec config
19
+ 在 AI 工具中按顺序执行:
184
20
 
185
- # 设置配置
186
- nanospec config set specs_root specs
21
+ - `/spec.1-spec`:生成规格说明
22
+ - `/spec.2-plan`:生成实施方案与任务拆解
23
+ - `/spec.3-execute`:执行任务并更新状态
187
24
 
188
- # 设置全局配置
189
- nanospec config set default_adapter qwen --global
25
+ ## 核心命令
190
26
 
191
- # 删除配置项
192
- nanospec config unset specs_root
193
- ```
27
+ | 命令 | 说明 |
28
+ |---|---|
29
+ | `nanospec init` | 初始化项目结构与命令模板 |
30
+ | `nanospec new [name]` | 创建任务目录并设为当前任务 |
31
+ | `nanospec switch [name]` | 切换当前任务 |
32
+ | `nanospec status` | 查看当前任务状态 |
33
+ | `nanospec sync [--adapter <name>]` | 同步命令到 AI 工具目录 |
34
+ | `nanospec preset list/install/uninstall` | 预设包管理 |
35
+ | `nanospec config` | 查看当前配置 |
36
+ | `nanospec config get/set/unset/list` | 读写配置(支持 `--global`) |
194
37
 
195
- ---
38
+ ## 工作流概览
196
39
 
197
- ### 预设包系统
40
+ 1. 需求:在 `brief.md` 或 `prd.md` 写清目标
41
+ 2. 规格:`/spec.1-spec`
42
+ 3. 规划:`/spec.2-plan`
43
+ 4. 执行:`/spec.3-execute`
44
+ 5. 对齐(可选):`/spec.align`
45
+ 6. 验收/总结(可选):`/spec.accept`、`/spec.summary`
198
46
 
199
- 预设包是领域特化的规则和命令模板集合,一键安装即可获得领域能力。
47
+ ## 预设包
200
48
 
201
- **内置预设**:
49
+ 内置预设:
202
50
 
203
- | 预设 | 说明 |
204
- | ---------- | ------------------------------------- |
205
- | `frontend` | 前端开发特化(组件/状态/交互规范) |
206
- | `backend` | 后端开发特化(API/数据模型/服务架构) |
207
- | `refactor` | 重构优化(评审/风险控制清单) |
208
- | `docs` | 文档写作(信息架构/受众分析模板) |
51
+ - `frontend`:前端开发
52
+ - `backend`:后端开发
53
+ - `refactor`:重构任务
54
+ - `docs`:文档写作
209
55
 
210
- **预设命令**:
56
+ 示例:
211
57
 
212
58
  ```bash
213
- # 列出所有预设
214
59
  nanospec preset list
215
-
216
- # 安装预设
217
- nanospec preset install frontend
218
-
219
- # 卸载预设
220
- nanospec preset uninstall frontend
221
- ```
222
-
223
- ---
224
-
225
- ### 项目结构
226
-
227
- 初始化后的项目结构:
228
-
229
- ```
230
- your-project/
231
- ├── nanospec/
232
- │ ├── AGENTS.md # 通用规范和指南
233
- │ └── <task-name>/ # 任务目录
234
- │ ├── brief.md # 需求描述
235
- │ ├── assets/ # 辅助素材
236
- │ ├── alignment.md # 对齐记录(可选)
237
- │ └── outputs/
238
- │ ├── 1-spec.md
239
- │ ├── 2-plan.md
240
- │ ├── 3-tasks.md
241
- │ ├── acceptance.md
242
- │ └── summary-*.md
243
- ├── .nanospec/
244
- │ ├── current-task # 当前任务指针
245
- │ └── config.json # 项目级配置(可选)
246
- ├── .cursor/commands/ # Cursor 命令(如果使用)
247
- │ ├── spec.1-spec.md
248
- │ ├── spec.2-plan.md
249
- │ └── ...
250
- └── ... (其他项目文件)
251
- ```
252
-
253
- ---
254
-
255
- ### 支持的 AI 工具
256
-
257
- NanoSpec 支持以下 AI 工具,通过适配器自动生成对应的命令文件:
258
-
259
- - ✅ Cursor
260
- - ✅ Qwen
261
- - ✅ iFlow
262
- - ✅ Cline
263
- - ✅ Claude Code
264
- - ✅ GitHub Copilot
265
- - ✅ Windsurf
266
- - ✅ Kilo Code
267
-
268
- **添加新工具**:只需在 `src/adapters/` 创建适配器,无需修改核心代码。
269
-
270
- ---
271
-
272
- ### 安装
273
-
274
- #### 全局安装
275
-
276
- ```bash
277
- npm install -g nano-spec
278
- ```
279
-
280
- #### 本地开发
281
-
282
- ```bash
283
- # 克隆仓库
284
- git clone <repository-url>
285
- cd nano-spec
286
-
287
- # 安装依赖
288
- npm install
289
-
290
- # 构建项目
291
- npm run build
292
-
293
- # 链接到全局以便测试
294
- npm link
295
- ```
296
-
297
- ---
298
-
299
- ### 常见问题
300
-
301
- **Q: 如何在不同 AI 工具之间切换?**
302
-
303
- A: 使用 `nanospec sync --adapter <工具名>` 同步命令到新的工具。
304
-
305
- **Q: 如何创建自定义预设?**
306
-
307
- A: 在 `src/presets/` 创建目录,包含 `preset.json`、`commands/` 和 `templates/`。
308
-
309
- **Q: 任务指针文件损坏了怎么办?**
310
-
311
- A: 使用 `nanospec switch` 交互式选择任务,会自动修复指针。
312
-
313
- **Q: 如何配置多人的协作规范?**
314
-
315
- A: 将 `.nanospecrc` 提交到 Git,团队成员共享统一的配置。
316
-
317
- ---
318
-
319
- ### 贡献
320
-
321
- 欢迎贡献!请遵循以下指南:
322
-
323
- 1. Fork 仓库
324
- 2. 创建功能分支
325
- 3. 确保所有测试通过(`npm test`)
326
- 4. 提交拉取请求
327
-
328
- ### 许可证
329
-
330
- MIT License
331
-
332
- ---
333
-
334
- ## English
335
-
336
- A minimal extendable Spec-Driven framework. Not just for code -- for writing, research, and anything you want to get done.
337
-
338
- ### Quick Start (3 minutes)
339
-
340
- ```bash
341
- # 1. Install
342
- npm install -g nano-spec
343
-
344
- # 2. Initialize in your project (interactive AI tool selection)
345
- nanospec init
346
-
347
- # 3. Create your first task
348
- nanospec new "User Login"
349
-
350
- # 4. Edit brief.md to describe requirements, then use slash commands in AI tools:
351
- # /spec.1-spec → /spec.2-plan → /spec.3-execute
352
- ```
353
-
354
- That's it! Your project now has a standardized spec-driven development workflow.
355
-
356
- ---
357
-
358
- ### Why NanoSpec?
359
-
360
- **🎯 Workflow-focused, Tool-agnostic**
361
-
362
- - Supports 8 mainstream AI tools: Cursor, Qwen, iFlow, Cline, Claude Code, GitHub Copilot, Windsurf, Kilo Code
363
- - Team members using different tools still maintain unified collaboration standards
364
- - Switch tools anytime, seamless transition
365
-
366
- **📦 Ready to Use, Zero Configuration**
367
-
368
- - One command to initialize project structure
369
- - Built-in complete workflow commands (spec → plan → execute → accept)
370
- - 4 domain presets (frontend, backend, refactor, docs), one-click install
371
-
372
- **🔄 Supports Resumable Work**
373
-
374
- - Auto-record current task, interrupt and continue anytime
375
- - Multi-task parallel processing, quick switching
376
- - Alignment mechanism ensures change consistency
377
-
378
- **⚙️ Highly Customizable**
379
-
380
- - Multi-level configuration system (project > user > default)
381
- - Custom templates and commands
382
- - Quickly inject domain capabilities through presets
383
-
384
- ---
385
-
386
- ### Typical Use Cases
387
-
388
- **Scenario 1: Frontend Team Developing New Features**
389
-
390
- ```bash
391
- # Initialize project (select Cursor + GitHub Copilot)
392
- nanospec init
393
-
394
- # Install frontend preset (includes component/state/interaction specs)
395
60
  nanospec preset install frontend
396
-
397
- # Create task
398
- nanospec new "Shopping Cart"
399
-
400
- # Use /spec.1-spec in Cursor to write specs
401
- # AI will automatically apply frontend preset standards
402
- ```
403
-
404
- **Scenario 2: Backend Team Refactoring APIs**
405
-
406
- ```bash
407
- # Initialize project (select Qwen)
408
- nanospec init
409
-
410
- # Install refactor preset (includes review/risk control checklist)
411
- nanospec preset install refactor
412
-
413
- # Create task
414
- nanospec new "User API Refactor"
415
-
416
- # Use /spec.run to execute workflow in one click
417
- # AI will automatically check API design standards and potential risks
418
- ```
419
-
420
- **Scenario 3: Personal Technical Documentation**
421
-
422
- ```bash
423
- # Initialize project
424
- nanospec init
425
-
426
- # Install docs preset (includes info architecture/audience analysis templates)
427
- nanospec preset install docs
428
-
429
- # Create task
430
- nanospec new "System Architecture Docs"
431
-
432
- # Use /spec.clarify to clarify ambiguous points
433
- # AI will help you check if info architecture is complete
434
- ```
435
-
436
- ---
437
-
438
- ### Core Workflow
439
-
440
- NanoSpec standardizes workflow into 6 phases, each with clear deliverables:
441
-
442
61
  ```
443
- brief.md (requirements)
444
-
445
- 1-spec.md (specification)
446
-
447
- 2-plan.md (plan) + 3-tasks.md (task list)
448
-
449
- Execute tasks (complete and check one by one)
450
-
451
- acceptance.md (acceptance)
452
-
453
- summary.md (summary)
454
- ```
455
-
456
- **Alignment Mechanism**: Use `/spec.align` to record and track closure when issues arise in any phase.
457
-
458
- ---
459
-
460
- ### CLI Commands Quick Reference
461
-
462
- | Command | Description | Example |
463
- | -------- | -------------------------------------------------- | -------------------------------------- |
464
- | `init` | Initialize project (interactive AI tool selection) | `nanospec init` |
465
- | `new` | Create new task (auto-set as current) | `nanospec new "Task Name"` |
466
- | `switch` | Switch current task (interactive if no args) | `nanospec switch` |
467
- | `status` | View current status | `nanospec status` |
468
- | `config` | Configuration management | `nanospec config set specs_root specs` |
469
- | `preset` | Preset package management | `nanospec preset install frontend` |
470
- | `sync` | Sync commands to AI tools | `nanospec sync --adapter cursor` |
471
-
472
- **Slash Commands in AI Tools**:
473
-
474
- - `/spec.1-spec` - Write specifications
475
- - `/spec.2-plan` - Create technical plan and task breakdown
476
- - `/spec.3-execute` - Execute and deliver
477
- - `/spec.accept` - Create acceptance test cases
478
- - `/spec.align` - Align and correct deviations
479
- - `/spec.summary` - Summarize and document
480
- - `/spec.init` - Initialize or create task (helper)
481
- - `/spec.run` - Execute workflow in one click (helper)
482
- - `/spec.clarify` - Clarify ambiguous points in specs (helper)
483
-
484
- ---
485
62
 
486
- ### Configuration System
63
+ ## 配置
487
64
 
488
- NanoSpec supports multi-level configuration with priority: **project > user > default**
489
-
490
- **Configuration File Locations**:
491
-
492
- - Project-level: `.nanospecrc` or `nanospec.config.js` (project root)
493
- - User-level: `~/.nanospecrc`
494
-
495
- **Common Configuration Options**:
496
-
497
- ```json
498
- {
499
- "specs_root": "nanospec", // Specs root directory name
500
- "cmd_prefix": "spec", // Command prefix
501
- "default_adapter": "cursor", // Default AI tool
502
- "auto_sync": true // Auto sync on init
503
- }
504
- ```
505
-
506
- **Configuration Commands**:
65
+ 默认配置文件在 `.nanospec/config.json`,也可使用 CLI 管理:
507
66
 
508
67
  ```bash
509
- # View current configuration
510
- nanospec config
511
-
512
- # Set configuration
513
- nanospec config set specs_root specs
514
-
515
- # Set global configuration
516
- nanospec config set default_adapter qwen --global
517
-
518
- # Remove configuration item
519
- nanospec config unset specs_root
68
+ nanospec config list
69
+ nanospec config get default_adapter
70
+ nanospec config set default_adapter codex
520
71
  ```
521
72
 
522
- ---
523
-
524
- ### Preset System
525
-
526
- Presets are domain-specific rule and command template collections, one-click install to gain domain capabilities.
527
-
528
- **Built-in Presets**:
529
-
530
- | Preset | Description |
531
- | ---------- | ------------------------------------------------------------------------ |
532
- | `frontend` | Frontend development specialization (component/state/interaction specs) |
533
- | `backend` | Backend development specialization (API/data model/service architecture) |
534
- | `refactor` | Refactoring optimization (review/risk control checklist) |
535
- | `docs` | Documentation writing (info architecture/audience analysis templates) |
536
-
537
- **Preset Commands**:
538
-
539
- ```bash
540
- # List all presets
541
- nanospec preset list
542
-
543
- # Install preset
544
- nanospec preset install frontend
545
-
546
- # Uninstall preset
547
- nanospec preset uninstall frontend
548
- ```
73
+ 常用配置项:`specs_root`、`cmd_prefix`、`default_adapter`、`template_format`、`auto_sync`。
549
74
 
550
- ---
75
+ ## 支持的 AI 工具
551
76
 
552
- ### Project Structure
77
+ - `cursor`
78
+ - `codex`
79
+ - `qwen`
80
+ - `iflow`
81
+ - `cline`
82
+ - `claude-code`
83
+ - `copilot`
84
+ - `windsurf`
85
+ - `kilo-code`
553
86
 
554
- Project structure after initialization:
87
+ ## 项目结构
555
88
 
556
- ```
557
- your-project/
558
- ├── nanospec/
559
- │ ├── AGENTS.md # General rules and guidelines
560
- │ └── <task-name>/ # Task directories
561
- │ ├── brief.md # Requirement description
562
- │ ├── assets/ # Supporting materials
563
- │ ├── alignment.md # Alignment records (optional)
564
- │ └── outputs/
565
- │ ├── 1-spec.md
566
- │ ├── 2-plan.md
567
- │ ├── 3-tasks.md
568
- │ ├── acceptance.md
569
- │ └── summary-*.md
89
+ ```text
90
+ project-root/
570
91
  ├── .nanospec/
571
- │ ├── current-task # Current task pointer
572
- └── config.json # Project-level config (optional)
573
- ├── .cursor/commands/ # Cursor commands (if used)
574
- │ ├── spec.1-spec.md
575
- │ ├── spec.2-plan.md
576
- │ └── ...
577
- └── ... (other project files)
578
- ```
579
-
580
- ---
581
-
582
- ### Supported AI Tools
583
-
584
- NanoSpec supports the following AI tools, automatically generating corresponding command files through adapters:
585
-
586
- - ✅ Cursor
587
- - ✅ Qwen
588
- - ✅ iFlow
589
- - ✅ Cline
590
- - ✅ Claude Code
591
- - ✅ GitHub Copilot
592
- - ✅ Windsurf
593
- - ✅ Kilo Code
594
-
595
- **Adding New Tools**: Just create an adapter in `src/adapters/`, no need to modify core code.
596
-
597
- ---
598
-
599
- ### Installation
600
-
601
- #### Global Installation
602
-
603
- ```bash
604
- npm install -g nano-spec
605
- ```
606
-
607
- #### Local Development
608
-
609
- ```bash
610
- # Clone repository
611
- git clone <repository-url>
612
- cd nano-spec
613
-
614
- # Install dependencies
615
- npm install
616
-
617
- # Build project
618
- npm run build
619
-
620
- # Link globally for testing
621
- npm link
622
- ```
623
-
624
- ---
625
-
626
- ### FAQ
627
-
628
- **Q: How to switch between different AI tools?**
629
-
630
- A: Use `nanospec sync --adapter <tool>` to sync commands to the new tool.
631
-
632
- **Q: How to create custom presets?**
633
-
634
- A: Create a directory in `src/presets/`, containing `preset.json`, `commands/`, and `templates/`.
635
-
636
- **Q: What if the task pointer file is corrupted?**
637
-
638
- A: Use `nanospec switch` to interactively select a task, which will automatically fix the pointer.
639
-
640
- **Q: How to configure multi-person collaboration standards?**
641
-
642
- A: Commit `.nanospecrc` to Git, team members share unified configuration.
643
-
644
- ---
645
-
646
- ### Contributing
647
-
648
- Contributions are welcome! Please follow these guidelines:
649
-
650
- 1. Fork the repository
651
- 2. Create a feature branch
652
- 3. Ensure all tests pass (`npm test`)
653
- 4. Submit a pull request
654
-
655
- ### License
656
-
657
- MIT License
658
-
659
- ### 项目结构
660
-
661
- 初始化后,你的项目将具有以下结构:
662
-
663
- ```
664
- your-project/
92
+ │ ├── AGENTS.md
93
+ ├── config.json
94
+ │ └── .current
665
95
  ├── nanospec/
666
- ├── AGENTS.md # 通用规则和指南
667
- ├── templates/ # 输出模板
668
- ├── 1-spec.md
669
- │ │ ├── 2-plan.md
670
- │ │ ├── 3-tasks.md
671
- │ │ ├── acceptance.md
672
- │ │ ├── alignment.md
673
- │ │ └── summary.md
674
- │ └── <task-name>/ # 任务目录
675
- │ ├── brief.md # 需求描述
676
- │ ├── assets/ # 辅助素材
677
- │ ├── alignment.md # 对齐记录(可选)
96
+ └── <task-name>/
97
+ ├── brief.md
98
+ ├── alignment.md
678
99
  │ └── outputs/
679
100
  │ ├── 1-spec.md
680
101
  │ ├── 2-plan.md
681
- ├── 3-tasks.md
682
- │ ├── acceptance.md
683
- │ └── summary-*.md
684
- ├── .nanospec/
685
- │ └── current-task # 当前任务指针
686
- ├── .cursor/commands/ # Cursor 命令(如果使用)
687
- │ ├── spec.1-spec.md
688
- │ ├── spec.2-plan.md
689
- │ ├── spec.3-execute.md
690
- │ ├── spec.accept.md
691
- │ ├── spec.align.md
692
- │ └── spec.summary.md
693
- ├── .nanospecrc # 项目级配置(可选)
694
- └── ... (其他项目文件)
695
- ```
696
-
697
- ### 命令参考
698
-
699
- #### nanospec init
700
-
701
- 初始化 nanospec 项目结构。
702
-
703
- ```bash
704
- nanospec init [选项]
102
+ └── 3-tasks.md
103
+ └── .<ai-tool>/commands/
705
104
  ```
706
105
 
707
- **选项:**
708
-
709
- - `--ai <tool>`:AI 工具类型(默认:cursor)
710
- - 可用:cursor, qwen, iflow, cline
711
- - `-f, --force`:强制覆盖已存在的文件
106
+ ## 常见问题
712
107
 
713
- #### nanospec new
108
+ ### `nanospec init` 后没有命令文件?
714
109
 
715
- 创建新的任务目录。
110
+ 运行:
716
111
 
717
112
  ```bash
718
- nanospec new [名称]
113
+ nanospec sync
719
114
  ```
720
115
 
721
- **参数:**
722
-
723
- - `名称`:任务名称(可选,默认:"待命名")
724
-
725
- #### nanospec switch
726
-
727
- 切换当前任务。
728
-
729
- ```bash
730
- nanospec switch [名称]
731
- ```
732
-
733
- **参数:**
734
-
735
- - `名称`:任务名称(可选,不提供时显示当前任务和可用任务列表)
736
-
737
- **说明:**
738
-
739
- - 切换任务后,所有工作流命令将默认使用当前任务
740
- - 创建新任务时会自动设置为当前任务
741
-
742
- #### nanospec status
743
-
744
- 显示当前状态。
116
+ ### 如何继续上次任务?
745
117
 
746
118
  ```bash
747
119
  nanospec status
120
+ nanospec switch
748
121
  ```
749
122
 
750
- **输出:**
751
-
752
- - 当前配置信息
753
- - 当前任务信息
754
- - 所有任务列表及进度
755
-
756
- #### nanospec preset
757
-
758
- 预设包管理。
759
-
760
- ```bash
761
- nanospec preset list # 列出所有可用预设
762
- nanospec preset install <name> # 安装预设
763
- nanospec preset uninstall <name> # 卸载预设
764
- ```
765
-
766
- **可用预设:**
767
-
768
- - `frontend` - 前端开发特化预设
769
- - `backend` - 后端开发特化预设
770
- - `refactor` - 重构优化预设
771
- - `docs` - 文档写作预设
772
-
773
- #### nanospec sync
774
-
775
- 同步命令到 AI 工具。
776
-
777
- ```bash
778
- nanospec sync [选项]
779
- ```
780
-
781
- **选项:**
782
-
783
- - `--adapter <name>`:指定 AI 工具(可选,默认同步所有工具)
784
-
785
- ### 配置系统
786
-
787
- NanoSpec 支持通过配置文件自定义行为。配置文件优先级:项目级 > 用户级 > 默认。
788
-
789
- #### 配置文件位置
790
-
791
- - **项目级**:`.nanospecrc` 或 `nanospec.config.js`(项目根目录)
792
- - **用户级**:`~/.nanospecrc`(用户主目录)
793
-
794
- #### 配置项
795
-
796
- ```json
797
- {
798
- "specs_root": "nanospec", // 规格根目录名(默认:nanospec)
799
- "cmd_prefix": "spec", // 命令前缀(默认:spec)
800
- "default_adapter": "cursor", // 默认 AI 工具(默认:cursor)
801
- "template_format": "md", // 模板格式(默认:md)
802
- "auto_sync": true // init 时自动同步(默认:true)
803
- }
804
- ```
805
-
806
- #### 配置示例
807
-
808
- **JSON 格式(.nanospecrc):**
809
-
810
- ```json
811
- {
812
- "specs_root": "specs",
813
- "default_adapter": "qwen"
814
- }
815
- ```
816
-
817
- **JavaScript 格式(nanospec.config.js):**
818
-
819
- ```javascript
820
- module.exports = {
821
- specs_root: 'specs',
822
- default_adapter: 'qwen',
823
- template_format: 'toml'
824
- };
825
- ```
826
-
827
- ### 工作流指南
828
-
829
- #### 1. 规格阶段
830
-
831
- 使用 `/spec.1-spec` 根据 `brief.md` 中的需求和 `assets/` 中的辅助材料撰写详细规格。
832
-
833
- **输出:** `outputs/1-spec.md`
834
-
835
- #### 2. 规划阶段
836
-
837
- 使用 `/spec.2-plan` 创建技术方案和任务拆解。
838
-
839
- **输出:**
840
-
841
- - `outputs/2-plan.md` - 技术方案
842
- - `outputs/3-tasks.md` - 任务清单
843
-
844
- #### 3. 执行阶段
845
-
846
- 使用 `/spec.3-execute` 执行任务并交付结果。
847
-
848
- **操作:** 更新 `outputs/3-tasks.md` 中的任务完成状态
849
-
850
- #### 4. 验收阶段
851
-
852
- 使用 `/spec.accept` 创建验收用例。
853
-
854
- **输出:** `outputs/acceptance.md`(可选)
855
-
856
- #### 5. 对齐阶段
857
-
858
- 当发现冲突、歧义或偏差时,使用 `/spec.align`。
859
-
860
- **输出:** `alignment.md`(仅在需要时创建)
861
-
862
- #### 6. 总结阶段
863
-
864
- 使用 `/spec.summary` 总结和文档化已完成的工作。
865
-
866
- **输出:** `outputs/summary-<日期>.md`(可选)
867
-
868
- ### 优先级规则
869
-
870
- 处理信息时,应用以下优先级:
871
-
872
- ```
873
- alignment.md > brief.md / prd.md > assets/* > 现状
874
- ```
875
-
876
- **重要:** 当任何阶段发生变更时,需要传播变更到:
877
-
878
- 1. `1-spec.md`
879
- 2. `2-plan.md` / `3-tasks.md`
880
- 3. `acceptance.md`(如果存在)
881
-
882
- ### 测试
883
-
884
- 运行测试套件:
885
-
886
- ```bash
887
- # 所有测试
888
- npm test
889
-
890
- # 监听模式
891
- npm run test:watch
892
-
893
- # 覆盖率报告
894
- npm run test:coverage
895
- ```
896
-
897
- ### 构建
898
-
899
- 构建项目用于生产:
900
-
901
- ```bash
902
- npm run build
903
- ```
904
-
905
- 编译后的文件将在 `dist/` 目录中。
906
-
907
- ### 贡献
908
-
909
- 欢迎贡献!请遵循以下指南:
910
-
911
- 1. Fork 仓库
912
- 2. 创建功能分支
913
- 3. 确保所有测试通过
914
- 4. 提交拉取请求
915
-
916
- ### 许可证
917
-
918
- MIT License
919
-
920
- ---
921
-
922
- ## English
923
-
924
- A minimal extendable Spec-Driven framework. Not just for code -- for writing, research, and anything you want to get done.
925
-
926
- ### Overview
927
-
928
- 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.
929
-
930
- ### Features
931
-
932
- - **Minimal & Simple**: Only 6 slash commands, CLI focuses on initialization
933
- - **Ready to Use**: One-command initialization with `nanospec init`
934
- - **Multi-AI Support**: Generate command files for different AI tools
935
- - **Customizable**: Modify templates and add common documents for customization
936
-
937
- ### Installation
938
-
939
- #### Global Installation
940
-
941
- ```bash
942
- npm install -g nano-spec
943
- ```
944
-
945
- #### Local Development
946
-
947
- ```bash
948
- # Clone the repository
949
- git clone <repository-url>
950
- cd nano-spec
951
-
952
- # Install dependencies
953
- npm install
954
-
955
- # Build the project
956
- npm run build
957
-
958
- # Link globally for testing
959
- npm link
960
- ```
961
-
962
- ### Quick Start
963
-
964
- 1. **Initialize NanoSpec in your project**
965
-
966
- ```bash
967
- # Initialize with default AI tool (Cursor)
968
- nanospec init
969
-
970
- # Initialize with specific AI tool
971
- nanospec init --ai qwen
972
- nanospec init --ai iflow
973
- nanospec init --ai cline
974
-
975
- # Force overwrite existing files
976
- nanospec init --force
977
- ```
978
-
979
- 2. **Create a new task**
980
-
981
- ```bash
982
- # Create a task with default name
983
- nanospec new
984
-
985
- # Create a task with custom name
986
- nanospec new "User Authentication"
987
- ```
988
-
989
- 3. **Start the workflow**
990
-
991
- Edit the `brief.md` file in your task directory to describe your requirements, then use the slash commands:
992
-
993
- - `/spec.1-spec` - Write specifications
994
- - `/spec.2-plan` - Create technical plan and task breakdown
995
- - `/spec.3-execute` - Execute and deliver
996
- - `/spec.accept` - Create acceptance test cases
997
- - `/spec.align` - Align and correct deviations
998
- - `/spec.summary` - Summarize and document
999
-
1000
- ### Project Structure
1001
-
1002
- After initialization, your project will have the following structure:
1003
-
1004
- ```
1005
- your-project/
1006
- ├── nanospec/
1007
- │ ├── AGENTS.md # General rules and guidelines
1008
- │ ├── templates/ # Output templates
1009
- │ │ ├── 1-spec.md
1010
- │ │ ├── 2-plan.md
1011
- │ │ ├── 3-tasks.md
1012
- │ │ ├── acceptance.md
1013
- │ │ ├── alignment.md
1014
- │ │ └── summary.md
1015
- │ └── <task-name>/ # Task directories
1016
- │ ├── brief.md # Requirement description
1017
- │ ├── assets/ # Supporting materials
1018
- │ ├── alignment.md # Alignment records (optional)
1019
- │ └── outputs/
1020
- │ ├── 1-spec.md
1021
- │ ├── 2-plan.md
1022
- │ ├── 3-tasks.md
1023
- │ ├── acceptance.md
1024
- │ └── summary-*.md
1025
- ├── .nanospec/
1026
- │ └── current-task # Current task pointer
1027
- ├── .cursor/commands/ # Cursor commands (if used)
1028
- │ ├── spec.1-spec.md
1029
- │ ├── spec.2-plan.md
1030
- │ ├── spec.3-execute.md
1031
- │ ├── spec.accept.md
1032
- │ ├── spec.align.md
1033
- │ └── spec.summary.md
1034
- ├── .nanospecrc # Project-level configuration (optional)
1035
- └── ... (other project files)
1036
- ```
1037
-
1038
- ### Commands Reference
1039
-
1040
- #### nanospec init
1041
-
1042
- Initialize NanoSpec project structure.
1043
-
1044
- ```bash
1045
- nanospec init [options]
1046
- ```
1047
-
1048
- **Options:**
1049
-
1050
- - `--ai <tool>`: AI tool type (default: cursor)
1051
- - Available: cursor, qwen, iflow, cline
1052
- - `-f, --force`: Force overwrite existing files
1053
-
1054
- #### nanospec new
1055
-
1056
- Create a new task directory.
1057
-
1058
- ```bash
1059
- nanospec new [name]
1060
- ```
1061
-
1062
- **Arguments:**
1063
-
1064
- - `name`: Task name (optional, default: "待命名")
1065
-
1066
- #### nanospec switch
1067
-
1068
- Switch current task.
1069
-
1070
- ```bash
1071
- nanospec switch [name]
1072
- ```
1073
-
1074
- **Arguments:**
1075
-
1076
- - `name`: Task name (optional, displays current task and available tasks if not provided)
1077
-
1078
- **Description:**
1079
-
1080
- - After switching tasks, all workflow commands will use the current task by default
1081
- - Creating a new task automatically sets it as the current task
1082
-
1083
- #### nanospec status
1084
-
1085
- Display current status.
1086
-
1087
- ```bash
1088
- nanospec status
1089
- ```
1090
-
1091
- **Output:**
1092
-
1093
- - Current configuration
1094
- - Current task information
1095
- - List of all tasks and their progress
1096
-
1097
- #### nanospec preset
1098
-
1099
- Preset package management.
1100
-
1101
- ```bash
1102
- nanospec preset list # List all available presets
1103
- nanospec preset install <name> # Install preset
1104
- nanospec preset uninstall <name> # Uninstall preset
1105
- ```
1106
-
1107
- **Available Presets:**
1108
-
1109
- - `frontend` - Frontend development specialization
1110
- - `backend` - Backend development specialization
1111
- - `refactor` - Refactoring optimization
1112
- - `docs` - Documentation writing
1113
-
1114
- #### nanospec sync
1115
-
1116
- Sync commands to AI tools.
1117
-
1118
- ```bash
1119
- nanospec sync [options]
1120
- ```
1121
-
1122
- **Options:**
1123
-
1124
- - `--adapter <name>`: Specify AI tool (optional, syncs all tools by default)
1125
-
1126
- ### Configuration System
1127
-
1128
- NanoSpec supports customization through configuration files. Configuration priority: project-level > user-level > default.
1129
-
1130
- #### Configuration File Locations
1131
-
1132
- - **Project-level**: `.nanospecrc` or `nanospec.config.js` (project root)
1133
- - **User-level**: `~/.nanospecrc` (user home directory)
1134
-
1135
- #### Configuration Options
1136
-
1137
- ```json
1138
- {
1139
- "specs_root": "nanospec", // Specs root directory name (default: nanospec)
1140
- "cmd_prefix": "spec", // Command prefix (default: spec)
1141
- "default_adapter": "cursor", // Default AI tool (default: cursor)
1142
- "template_format": "md", // Template format (default: md)
1143
- "auto_sync": true // Auto sync on init (default: true)
1144
- }
1145
- ```
1146
-
1147
- #### Configuration Examples
1148
-
1149
- **JSON format (.nanospecrc):**
1150
-
1151
- ```json
1152
- {
1153
- "specs_root": "specs",
1154
- "default_adapter": "qwen"
1155
- }
1156
- ```
1157
-
1158
- **JavaScript format (nanospec.config.js):**
1159
-
1160
- ```javascript
1161
- module.exports = {
1162
- specs_root: 'specs',
1163
- default_adapter: 'qwen',
1164
- template_format: 'toml'
1165
- };
1166
- ```
1167
-
1168
- ### Workflow Guide
1169
-
1170
- #### 1. Specification Phase
1171
-
1172
- Use `/spec.1-spec` to write detailed specifications based on requirements in `brief.md` and supporting materials in `assets/`.
1173
-
1174
- **Output:** `outputs/1-spec.md`
1175
-
1176
- #### 2. Planning Phase
1177
-
1178
- Use `/spec.2-plan` to create technical plans and task breakdowns.
1179
-
1180
- **Outputs:**
1181
-
1182
- - `outputs/2-plan.md` - Technical plan
1183
- - `outputs/3-tasks.md` - Task checklist
1184
-
1185
- #### 3. Execution Phase
1186
-
1187
- Use `/spec.3-execute` to execute tasks and deliver results.
1188
-
1189
- **Action:** Update task completion status in `outputs/3-tasks.md`
1190
-
1191
- #### 4. Acceptance Phase
1192
-
1193
- Use `/spec.accept` to create acceptance test cases.
1194
-
1195
- **Output:** `outputs/acceptance.md` (optional)
1196
-
1197
- #### 5. Alignment Phase
1198
-
1199
- Use `/spec.align` when conflicts, ambiguities, or deviations are discovered.
1200
-
1201
- **Output:** `alignment.md` (created only when needed)
1202
-
1203
- #### 6. Summary Phase
1204
-
1205
- Use `/spec.summary` to summarize and document the completed work.
1206
-
1207
- **Output:** `outputs/summary-<date>.md` (optional)
1208
-
1209
- ### Priority Rules
1210
-
1211
- When processing information, the following priority is applied:
1212
-
1213
- ```
1214
- alignment.md > brief.md / prd.md > assets/* > current state
1215
- ```
1216
-
1217
- **Important:** When changes occur during any phase, propagate them to:
1218
-
1219
- 1. `1-spec.md`
1220
- 2. `2-plan.md` / `3-tasks.md`
1221
- 3. `acceptance.md` (if exists)
1222
-
1223
- ### Testing
1224
-
1225
- Run the test suite:
1226
-
1227
- ```bash
1228
- # All tests
1229
- npm test
1230
-
1231
- # Watch mode
1232
- npm run test:watch
1233
-
1234
- # Coverage report
1235
- npm run test:coverage
1236
- ```
1237
-
1238
- ### Building
1239
-
1240
- Build the project for production:
1241
-
1242
- ```bash
1243
- npm run build
1244
- ```
1245
-
1246
- The compiled files will be in the `dist/` directory.
1247
-
1248
- ### Contributing
1249
-
1250
- Contributions are welcome! Please follow these guidelines:
1251
-
1252
- 1. Fork the repository
1253
- 2. Create a feature branch
1254
- 3. Ensure all tests pass
1255
- 4. Submit a pull request
1256
-
1257
- ### License
1258
-
1259
- MIT License
1260
-
1261
- ---
1262
-
1263
- ## Local Development Guide / 本地开发指南
1264
-
1265
- ### Prerequisites / 前置要求
1266
-
1267
- - Node.js >= 18
1268
- - npm or yarn
1269
- - Git (optional, for version control)
1270
-
1271
- ### Development Workflow / 开发工作流
1272
-
1273
- 1. **Clone and Setup / 克隆和设置**
1274
-
1275
- ```bash
1276
- git clone <repository-url>
1277
- cd nano-spec
1278
- npm install
1279
- ```
1280
-
1281
- 2. **Development Mode / 开发模式**
1282
-
1283
- ```bash
1284
- # Run in development mode with tsx
1285
- # 使用 tsx 在开发模式下运行
1286
- npm run dev
1287
-
1288
- # Run with specific commands
1289
- # 运行特定命令
1290
- npm run dev init
1291
- npm run dev new "My Task"
1292
- ```
1293
-
1294
- 3. **Building / 构建**
1295
-
1296
- ```bash
1297
- # Build TypeScript to JavaScript
1298
- # 将 TypeScript 编译为 JavaScript
1299
- npm run build
1300
-
1301
- # The output will be in the dist/ directory
1302
- # 输出将在 dist/ 目录中
1303
- ```
1304
-
1305
- 4. **Testing / 测试**
1306
-
1307
- ```bash
1308
- # Run all tests
1309
- # 运行所有测试
1310
- npm test
1311
-
1312
- # Run tests in watch mode
1313
- # 在监听模式下运行测试
1314
- npm run test:watch
1315
-
1316
- # Generate coverage report
1317
- # 生成覆盖率报告
1318
- npm run test:coverage
1319
- ```
1320
-
1321
- ### Project Structure for Development / 开发项目结构
1322
-
1323
- ```
1324
- nano-spec/
1325
- ├── src/
1326
- │ ├── index.ts # CLI entry point / CLI 入口点
1327
- │ ├── commands/
1328
- │ │ ├── init.ts # nanospec init command / nanospec init 命令
1329
- │ │ └── new.ts # nanospec new command / nanospec new 命令
1330
- │ ├── adapters/
1331
- │ │ ├── index.ts # Adapter registry / 适配器注册
1332
- │ │ ├── cursor.ts # Cursor adapter / Cursor 适配器
1333
- │ │ ├── qwen.ts # qwen adapter / qwen 适配器
1334
- │ │ ├── iflow.ts # iflow adapter / iflow 适配器
1335
- │ │ └── cline.ts # cline adapter / cline 适配器
1336
- │ └── templates/ # Built-in templates / 内置模板
1337
- │ ├── AGENTS.md
1338
- │ ├── commands/
1339
- │ │ ├── spec.1-spec.md
1340
- │ │ ├── spec.2-plan.md
1341
- │ │ ├── spec.3-execute.md
1342
- │ │ ├── spec.accept.md
1343
- │ │ ├── spec.align.md
1344
- │ │ └── spec.summary.md
1345
- │ └── outputs/
1346
- │ ├── 1-spec.md
1347
- │ ├── 2-plan.md
1348
- │ ├── 3-tasks.md
1349
- │ ├── acceptance.md
1350
- │ ├── alignment.md
1351
- │ └── summary.md
1352
- ├── bin/
1353
- │ └── nanospec.js # CLI entry point / CLI 入口点
1354
- ├── package.json
1355
- ├── tsconfig.json
1356
- ├── vitest.config.ts
1357
- └── README.md
1358
- ```
1359
-
1360
- ### Adding a New AI Adapter / 添加新的 AI 适配器
1361
-
1362
- 1. Create adapter file in `src/adapters/` / 在 `src/adapters/` 中创建适配器文件:
1363
-
1364
- ```typescript
1365
- // src/adapters/mytool.ts
1366
- import {mkdirSync, cpSync} from 'fs';
1367
- import {join} from 'path';
1368
- import type {AIAdapter} from './index.js';
1369
-
1370
- export const mytoolAdapter: AIAdapter = {
1371
- name: 'mytool',
1372
- commandsDir: '.mytool/commands/',
1373
-
1374
- generateCommands(cwd: string, templatesDir: string): void {
1375
- const commandsDir = join(cwd, '.mytool', 'commands');
1376
- mkdirSync(commandsDir, {recursive: true});
1377
-
1378
- // Copy command templates
1379
- // 复制命令模板
1380
- const commands = [
1381
- 'spec.1-spec.md',
1382
- 'spec.2-plan.md'
1383
- // ... other commands
1384
- ];
1385
-
1386
- for (const cmd of commands) {
1387
- const src = join(templatesDir, 'commands', cmd);
1388
- const dest = join(commandsDir, cmd);
1389
- cpSync(src, dest);
1390
- }
1391
- }
1392
- };
1393
- ```
1394
-
1395
- 2. Register the adapter in `src/adapters/index.ts` / 在 `src/adapters/index.ts` 中注册适配器:
1396
-
1397
- ```typescript
1398
- import {mytoolAdapter} from './mytool.js';
1399
-
1400
- const adapters: Record<string, AIAdapter> = {
1401
- cursor: cursorAdapter,
1402
- qwen: qwenAdapter,
1403
- iflow: iflowAdapter,
1404
- cline: clineAdapter,
1405
- mytool: mytoolAdapter // Add new adapter / 添加新适配器
1406
- };
1407
- ```
1408
-
1409
- 3. Add tests for the new adapter / 为新适配器添加测试
1410
-
1411
- 4. Run tests to ensure everything works / 运行测试确保一切正常
1412
-
1413
- ### Customizing Templates / 自定义模板
1414
-
1415
- You can customize the templates by modifying files in `src/templates/`:
1416
- 你可以通过修改 `src/templates/` 中的文件来自定义模板:
1417
-
1418
- - **AGENTS.md**: General rules and guidelines / 通用规则和指南
1419
- - **commands/**: Slash command definitions / 斜杠命令定义
1420
- - **outputs/**: Output document templates / 输出文档模板
1421
-
1422
- After modifying templates, rebuild the project:
1423
- 修改模板后,重新构建项目:
1424
-
1425
- ```bash
1426
- npm run build
1427
- ```
1428
-
1429
- ---
123
+ ## 维护者信息
1430
124
 
1431
- ## Support / 支持
125
+ - 变更记录:`CHANGELOG.md`
126
+ - 内部开发指南:`guides/README.md`
1432
127
 
1433
- For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/xxih/nano-spec).
128
+ ## License
1434
129
 
1435
- 如有问题、疑问或贡献,请访问 [GitHub 仓库](https://github.com/xxih/nano-spec)。
130
+ MIT