@localsummer/incspec 0.2.4 → 0.2.6

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
@@ -33,7 +33,7 @@ AI 编程助手在处理复杂前端代码库时常常力不从心,因为 API
33
33
  - **依赖追踪**:6 维度分析 UI 依赖(API、Store、Types 等)。
34
34
  - **增量设计**:7 模块蓝图指导实现。
35
35
  - **无缝迭代**:将完成的工作合并为新基线,开启下一轮循环。
36
- - **历史可追溯**:归档按年月和模块组织,便于回顾历史决策。
36
+ - **历史可追溯**:归档按年月和工作流名称组织,便于回顾历史决策。
37
37
  - 兼容你已有的 AI 工具:Cursor、Claude Code 及任何 AGENTS.md 兼容助手。
38
38
 
39
39
  ## IncSpec 对比一览
@@ -360,8 +360,8 @@ $ incspec archive -y # 归档所有工作流产出,跳过确认
360
360
  ### 为什么需要归档?
361
361
 
362
362
  - **保持工作区整洁**:避免多轮迭代的文件混杂在一起。
363
- - **历史可追溯**:按年月和模块组织,便于回顾历史决策。
364
- - **迭代边界清晰**:每轮归档后,`baselines/`、`requirements/`、`increments/` 目录重新开始。
363
+ - **历史可追溯**:按年月和工作流名称组织,便于回顾历史决策。
364
+ - **迭代边界清晰**:每轮归档后,当前工作流产出从 `baselines/`、`requirements/`、`increments/` 移出,便于下一轮重新生成。
365
365
 
366
366
  ### 归档时机
367
367
 
@@ -375,7 +375,8 @@ $ incspec archive -y # 归档所有工作流产出,跳过确认
375
375
 
376
376
  ```bash
377
377
  # 归档整个工作流(推荐)
378
- incspec archive --workflow # 交互式确认
378
+ incspec archive # 交互式确认(默认归档当前工作流)
379
+ incspec archive --workflow # 显式指定归档当前工作流
379
380
  incspec archive -y # 跳过确认,直接归档
380
381
 
381
382
  # 归档指定文件
@@ -391,26 +392,25 @@ incspec list archives # 仅列出归档文件
391
392
 
392
393
  ### 归档后的目录结构
393
394
 
394
- 归档命令按年月和模块自动组织文件:
395
+ 归档命令按年月和工作流名称组织文件(文件直接放在工作流目录下):
395
396
 
396
397
  ```
397
398
  incspec/
398
399
  ├── archives/
399
400
  │ └── 2024-12/ # 按年月组织
400
- │ └── home-search-filter/ # 按工作流模块分组
401
- │ ├── baselines/
402
- ├── home-baseline-v1.md # 初始基线
403
- │ └── home-baseline-v2.md # 合并后的新基线
404
- │ ├── requirements/
405
- │ ├── structured-requirements.md
406
- │ │ └── ui-dependencies.md
407
- │ └── increments/
408
- └── search-filter-increment-v1.md
409
- ├── baselines/ # 归档后已清空,准备下一轮
410
- ├── requirements/ # 归档后已清空
411
- └── increments/ # 归档后已清空
401
+ │ └── home-search-filter/ # 工作流名称
402
+ │ ├── home-baseline-v1.md
403
+ │ ├── structured-requirements.md
404
+ ├── ui-dependencies.md
405
+ │ ├── search-filter-increment-v1.md
406
+ └── home-baseline-v2.md
407
+ ├── baselines/ # 当前工作流产出默认已移动
408
+ ├── requirements/ # 当前工作流产出默认已移动
409
+ └── increments/ # 当前工作流产出默认已移动
412
410
  ```
413
411
 
412
+ 说明:若单文件归档且没有当前工作流,文件会直接进入 `archives/YYYY-MM/`。
413
+
414
414
  ### 归档工作流示意
415
415
 
416
416
  ```
@@ -435,23 +435,22 @@ incspec/
435
435
  ┌────────────────────────────────────────────┐
436
436
  │ 归档完成 │
437
437
  │ │
438
- │ ┌─────────────┐ ┌─────────────┐
439
- │ │ archives/ │ │ baselines/ │
440
- │ │ 2024-12/ │ │ (已清空)
441
- │ │ module/ │ │
442
- │ │ ├─baselines│ │ 准备下一轮
443
- │ │ ├─requirements 迭代
444
- │ └─increments └─────────────┘ │
445
- │ └─────────────┘ │
438
+ │ ┌─────────────┐ ┌─────────────────┐
439
+ │ │ archives/ │ │ baselines/
440
+ │ │ 2024-12/ │ │ requirements/
441
+ │ │ workflow/ │ │ increments/
442
+ │ │ ├─*.md │ │ (当前工作流产出 │
443
+ │ │ └─*.md 已移动)
444
+ │ └─────────────┘ └─────────────────┘
446
445
  └────────────────────────────────────────────┘
447
446
  ```
448
447
 
449
448
  ### 归档最佳实践
450
449
 
451
450
  1. **及时归档** - 完成一轮迭代后立即归档,避免文件堆积。
452
- 2. **使用 --workflow** - 优先归档整个工作流,确保完整性。
453
- 3. **保留新基线** - 归档时新基线会被复制(而非移动)到归档目录,同时保留在 `baselines/` 作为下一轮起点。
454
- 4. **定期清理** - 对于过期的归档,可手动删除或移至外部存储。
451
+ 2. **优先归档整个工作流** - 直接执行 `incspec archive` 或 `--workflow`,确保产出完整。
452
+ 3. **明确移动/保留策略** - 默认移动到归档目录,需保留原文件时使用 `--keep`。
453
+ 4. **保持工作流命名清晰** - 归档目录按工作流名称分组,命名清晰更易追溯。
455
454
 
456
455
  ## 回退与重置
457
456
 
@@ -488,7 +487,7 @@ your-project/
488
487
  │ │ └── feature-increment-v1.md
489
488
  │ └── archives/ # 历史归档
490
489
  │ └── 2024-12/ # 按年月组织
491
- │ └── {module}/ # 按工作流模块分组
490
+ │ └── {workflow}/ # 按工作流名称分组
492
491
  └── .cursor/
493
492
  └── commands/
494
493
  └── incspec/ # Cursor 命令
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localsummer/incspec",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "面向 AI 编程助手的增量规范驱动开发工具",
5
5
  "bin": {
6
6
  "incspec": "src/index.mjs"
@@ -87,6 +87,23 @@ export async function analyzeCommand(ctx) {
87
87
  // Ensure initialized
88
88
  const projectRoot = ensureInitialized(cwd);
89
89
 
90
+ // Handle --complete flag as independent mode (skip all interactive flows)
91
+ if (options.complete) {
92
+ const workflow = readWorkflow(projectRoot);
93
+ if (!workflow?.currentWorkflow) {
94
+ printError('没有活跃的工作流,无法标记完成。');
95
+ process.exit(1);
96
+ }
97
+ const output = typeof options.output === 'string' ? options.output : null;
98
+ if (!output) {
99
+ printError('请通过 --output 指定输出文件名。');
100
+ process.exit(1);
101
+ }
102
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, output);
103
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成: ${output}`);
104
+ return;
105
+ }
106
+
90
107
  // Handle --baseline option: use existing baseline report
91
108
  if (options.baseline) {
92
109
  const baselineFile = typeof options.baseline === 'string' ? options.baseline : '';
@@ -234,11 +251,4 @@ export async function analyzeCommand(ctx) {
234
251
  print(colorize('完成分析后,运行以下命令标记完成:', colors.dim));
235
252
  print(colorize(` incspec analyze --complete --output=${outputFile}`, colors.dim));
236
253
  print('');
237
-
238
- // Handle --complete flag
239
- if (options.complete) {
240
- const output = typeof options.output === 'string' ? options.output : outputFile;
241
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, output);
242
- printSuccess(`步骤 1 已标记为完成: ${output}`);
243
- }
244
254
  }
@@ -57,6 +57,17 @@ export async function applyCommand(ctx) {
57
57
  // Get workflow state
58
58
  const workflow = readWorkflow(projectRoot);
59
59
 
60
+ // Handle --complete flag as independent mode (skip all checks)
61
+ if (options.complete) {
62
+ if (!workflow?.currentWorkflow) {
63
+ printWarning('没有活跃的工作流,无法标记完成。');
64
+ return;
65
+ }
66
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, '代码已应用');
67
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成`);
68
+ return;
69
+ }
70
+
60
71
  if (!workflow?.currentWorkflow) {
61
72
  printWarning('没有活跃的工作流。请先运行 incspec analyze 开始新工作流。');
62
73
  return;
@@ -176,9 +187,8 @@ export async function applyCommand(ctx) {
176
187
  printInfo(`完成后运行 'incspec status' 查看进度`);
177
188
  print('');
178
189
 
179
- // Handle --complete flag
180
- if (options.complete) {
181
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, '代码已应用');
182
- printSuccess(`步骤 5 已标记为完成`);
183
- }
190
+ // Provide command to mark as complete
191
+ print(colorize('完成代码应用后,运行以下命令标记完成:', colors.dim));
192
+ print(colorize(` incspec apply --complete`, colors.dim));
193
+ print('');
184
194
  }
@@ -40,6 +40,21 @@ export async function collectDepCommand(ctx) {
40
40
  // Get workflow state
41
41
  const workflow = readWorkflow(projectRoot);
42
42
 
43
+ // Handle --complete flag as independent mode (skip all checks)
44
+ if (options.complete) {
45
+ if (!workflow?.currentWorkflow) {
46
+ printWarning('没有活跃的工作流,无法标记完成。');
47
+ return;
48
+ }
49
+ if (!isStepAllowed(STEP_NUMBER, workflow.mode)) {
50
+ printWarning('当前工作流为快速模式,步骤 3 已跳过,无需标记完成。');
51
+ return;
52
+ }
53
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, OUTPUT_FILE);
54
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成: ${OUTPUT_FILE}`);
55
+ return;
56
+ }
57
+
43
58
  if (!workflow?.currentWorkflow) {
44
59
  printWarning('没有活跃的工作流。请先运行 incspec analyze 开始新工作流。');
45
60
  return;
@@ -91,9 +106,8 @@ export async function collectDepCommand(ctx) {
91
106
  printInfo(`完成后运行 'incspec status' 查看进度`);
92
107
  print('');
93
108
 
94
- // Handle --complete flag
95
- if (options.complete) {
96
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, OUTPUT_FILE);
97
- printSuccess(`步骤 3 已标记为完成: ${OUTPUT_FILE}`);
98
- }
109
+ // Provide command to mark as complete
110
+ print(colorize('完成依赖采集后,运行以下命令标记完成:', colors.dim));
111
+ print(colorize(` incspec collect-dep --complete`, colors.dim));
112
+ print('');
99
113
  }
@@ -40,6 +40,24 @@ export async function collectReqCommand(ctx) {
40
40
  // Get workflow state
41
41
  const workflow = readWorkflow(projectRoot);
42
42
 
43
+ // Handle --complete flag as independent mode (skip all checks)
44
+ if (options.complete) {
45
+ if (!workflow?.currentWorkflow) {
46
+ printWarning('没有活跃的工作流,无法标记完成。');
47
+ return;
48
+ }
49
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, OUTPUT_FILE);
50
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成: ${OUTPUT_FILE}`);
51
+
52
+ // Quick mode hint
53
+ if (isQuickMode(workflow)) {
54
+ print('');
55
+ printInfo('快速模式: 跳过步骤 3、4,直接进入步骤 5');
56
+ print(colorize(" 运行 'incspec apply' 继续", colors.cyan));
57
+ }
58
+ return;
59
+ }
60
+
43
61
  if (!workflow?.currentWorkflow) {
44
62
  printWarning('没有活跃的工作流。请先运行 incspec analyze 开始新工作流。');
45
63
  return;
@@ -81,16 +99,8 @@ export async function collectReqCommand(ctx) {
81
99
  printInfo(`完成后运行 'incspec status' 查看进度`);
82
100
  print('');
83
101
 
84
- // Handle --complete flag
85
- if (options.complete) {
86
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, OUTPUT_FILE);
87
- printSuccess(`步骤 2 已标记为完成: ${OUTPUT_FILE}`);
88
-
89
- // Quick mode hint
90
- if (isQuickMode(workflow)) {
91
- print('');
92
- printInfo('快速模式: 跳过步骤 3、4,直接进入步骤 5');
93
- print(colorize(" 运行 'incspec apply' 继续", colors.cyan));
94
- }
95
- }
102
+ // Provide command to mark as complete
103
+ print(colorize('完成需求收集后,运行以下命令标记完成:', colors.dim));
104
+ print(colorize(` incspec collect-req --complete`, colors.dim));
105
+ print('');
96
106
  }
@@ -42,6 +42,26 @@ export async function designCommand(ctx) {
42
42
  // Get workflow state
43
43
  const workflow = readWorkflow(projectRoot);
44
44
 
45
+ // Handle --complete flag as independent mode (skip all checks)
46
+ if (options.complete) {
47
+ if (!workflow?.currentWorkflow) {
48
+ printWarning('没有活跃的工作流,无法标记完成。');
49
+ return;
50
+ }
51
+ if (!isStepAllowed(STEP_NUMBER, workflow.mode)) {
52
+ printWarning('当前工作流为快速模式,步骤 4 已跳过,无需标记完成。');
53
+ return;
54
+ }
55
+ const output = typeof options.output === 'string' ? options.output : null;
56
+ if (!output) {
57
+ printWarning('请通过 --output 指定输出文件名。');
58
+ return;
59
+ }
60
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, output);
61
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成: ${output}`);
62
+ return;
63
+ }
64
+
45
65
  if (!workflow?.currentWorkflow) {
46
66
  printWarning('没有活跃的工作流。请先运行 incspec analyze 开始新工作流。');
47
67
  return;
@@ -132,10 +152,8 @@ export async function designCommand(ctx) {
132
152
  printInfo(`完成后运行 'incspec status' 查看进度`);
133
153
  print('');
134
154
 
135
- // Handle --complete flag
136
- if (options.complete) {
137
- const output = typeof options.output === 'string' ? options.output : outputFile;
138
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, output);
139
- printSuccess(`步骤 4 已标记为完成: ${output}`);
140
- }
155
+ // Provide command to mark as complete
156
+ print(colorize('完成增量设计后,运行以下命令标记完成:', colors.dim));
157
+ print(colorize(` incspec design --complete --output=${outputFile}`, colors.dim));
158
+ print('');
141
159
  }
@@ -55,6 +55,22 @@ export async function mergeCommand(ctx) {
55
55
  // Get workflow state
56
56
  const workflow = readWorkflow(projectRoot);
57
57
 
58
+ // Handle --complete flag as independent mode (skip all checks)
59
+ if (options.complete) {
60
+ if (!workflow?.currentWorkflow) {
61
+ printWarning('没有活跃的工作流,无法标记完成。');
62
+ return;
63
+ }
64
+ const output = typeof options.output === 'string' ? options.output : null;
65
+ if (!output) {
66
+ printWarning('请通过 --output 指定输出文件名。');
67
+ return;
68
+ }
69
+ updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, output);
70
+ printSuccess(`步骤 ${STEP_NUMBER} 已标记为完成: ${output}`);
71
+ return;
72
+ }
73
+
58
74
  if (!workflow?.currentWorkflow) {
59
75
  printWarning('没有活跃的工作流。请先运行 incspec analyze 开始新工作流。');
60
76
  return;
@@ -163,9 +179,8 @@ export async function mergeCommand(ctx) {
163
179
  printInfo(`完成后运行 'incspec status' 查看进度`);
164
180
  print('');
165
181
 
166
- // Handle --complete flag
167
- if (options.complete) {
168
- updateStep(projectRoot, STEP_NUMBER, STATUS.COMPLETED, outputFile);
169
- printSuccess(`步骤 6 已标记为完成: ${outputFile}`);
170
- }
182
+ // Provide command to mark as complete
183
+ print(colorize('完成基线合并后,运行以下命令标记完成:', colors.dim));
184
+ print(colorize(` incspec merge --complete --output=${outputFile}`, colors.dim));
185
+ print('');
171
186
  }
@@ -109,7 +109,7 @@ AI 编码助手使用 IncSpec 进行增量规格驱动开发的操作指南。
109
109
 
110
110
  **命令**: `incspec archive [--yes] [<file>] [--keep]`
111
111
 
112
- **目的**: 将已完成的工作流产出归档到 `incspec/archives/YYYY-MM/{module}/`
112
+ **目的**: 将已完成的工作流产出归档到 `incspec/archives/YYYY-MM/{workflow}/`
113
113
 
114
114
  **验证**: 归档前执行 `incspec validate` 确保项目健康。归档操作本身会验证文件移动正确性。
115
115
 
@@ -123,7 +123,7 @@ incspec/
123
123
  ├── baselines/ # 基线快照 (版本控制)
124
124
  ├── requirements/ # 需求与依赖
125
125
  ├── increments/ # 增量设计 (版本控制)
126
- └── archives/ # 历史归档 (按月/模块)
126
+ └── archives/ # 历史归档 (按月/工作流)
127
127
  ```
128
128
 
129
129
  ## 编号系统
@@ -30,7 +30,7 @@ incspec archive --workflow --yes
30
30
 
31
31
  # 角色定位
32
32
 
33
- 你是 incspec 工作流归档助手。你的职责是帮助用户将已完成的规范文件(baselines、increments、requirements)归档到 archives 目录(按 `YYYY-MM/{module}/` 结构组织),并在本工作流所有产出归档完成后记录到工作流历史中。
33
+ 你是 incspec 工作流归档助手。你的职责是帮助用户将已完成的规范文件(baselines、increments、requirements)归档到 archives 目录(按 `YYYY-MM/{workflow}/` 结构组织),并在本工作流所有产出归档完成后记录到工作流历史中。
34
34
 
35
35
  # 核心目标
36
36
 
@@ -130,12 +130,12 @@ incspec archive --workflow --yes
130
130
  ### 4.1 检查归档目录
131
131
 
132
132
  ```bash
133
- # 查看归档目录结构: archives/YYYY-MM/{module}/
133
+ # 查看归档目录结构: archives/YYYY-MM/{workflow}/
134
134
  ls -la incspec/archives/
135
135
  ls -la incspec/archives/2025-12/ # 当月目录
136
136
  ```
137
137
 
138
- 确认文件已复制/移动到归档目录(按年月和工作流模块分组)。
138
+ 确认文件已复制/移动到归档目录(按年月和工作流名称分组)。
139
139
 
140
140
  ### 4.2 检查工作流历史
141
141
 
@@ -170,7 +170,7 @@ incspec validate
170
170
  🔍 验证结果: 通过
171
171
  ```
172
172
 
173
- 注意:归档目录结构为 `archives/YYYY-MM/{module}/`,其中 `{module}` 为当前工作流名称。
173
+ 注意:归档目录结构为 `archives/YYYY-MM/{workflow}/`,其中 `{workflow}` 为当前工作流名称;若单文件归档且无工作流,则归档到 `archives/YYYY-MM/`。
174
174
 
175
175
  # 特殊情况处理
176
176