@localsummer/incspec 0.3.2 → 0.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localsummer/incspec",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "面向 AI 编程助手的增量规范驱动开发工具",
5
5
  "bin": {
6
6
  "incspec": "src/index.mjs"
package/src/CLAUDE.md ADDED
@@ -0,0 +1,7 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ *No recent activity*
7
+ </claude-mem-context>
@@ -0,0 +1,14 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ ### Jan 8, 2026
7
+
8
+ | ID | Time | T | Title | Read |
9
+ |----|------|---|-------|------|
10
+ | #118 | 3:14 PM | 🔵 | 纠正对 IncSpec 工作流模式参数的错误理解 | ~113 |
11
+ | #101 | 2:43 PM | 🔵 | 完成了 IncSpec 极简模式的深度分析 | ~95 |
12
+ | #100 | " | 🔵 | 发现 IncSpec 三种工作流模式的完整实现 | ~110 |
13
+ | #99 | " | 🔵 | 发现 IncSpec 极简模式的完整实现 | ~97 |
14
+ </claude-mem-context>
@@ -13,6 +13,12 @@ import {
13
13
  } from '../lib/config.mjs';
14
14
  import { initWorkflow } from '../lib/workflow.mjs';
15
15
  import { updateProjectAgentsFile } from '../lib/agents.mjs';
16
+ import {
17
+ syncToProject,
18
+ syncToGlobal,
19
+ getSupportedIDEs,
20
+ getIDEConfig,
21
+ } from '../lib/ide-sync.mjs';
16
22
  import {
17
23
  colors,
18
24
  colorize,
@@ -22,8 +28,82 @@ import {
22
28
  printInfo,
23
29
  prompt,
24
30
  confirm,
31
+ select,
25
32
  } from '../lib/terminal.mjs';
26
33
 
34
+ /**
35
+ * Sync IDE commands helper
36
+ * @param {string} cwd - Current working directory
37
+ */
38
+ async function syncIDECommands(cwd) {
39
+ print('');
40
+ print(colorize('IDE 命令同步', colors.bold, colors.cyan));
41
+ print(colorize('─────────────', colors.dim));
42
+ print('');
43
+
44
+ // Ask which IDE to sync
45
+ const ideChoice = await select({
46
+ message: '选择要同步的 IDE',
47
+ choices: [
48
+ { name: 'Cursor', value: 'cursor' },
49
+ { name: 'Claude Code', value: 'claude' },
50
+ { name: '全部 (Cursor + Claude Code)', value: 'all' },
51
+ ]
52
+ });
53
+
54
+ // Ask for sync scope
55
+ const scopeChoice = await select({
56
+ message: '选择同步范围',
57
+ choices: [
58
+ { name: '项目级 (仅当前项目)', value: 'project' },
59
+ { name: '全局级 (所有项目)', value: 'global' },
60
+ ]
61
+ });
62
+
63
+ const isGlobal = scopeChoice === 'global';
64
+
65
+ // Determine which IDEs to sync
66
+ const idesToSync = ideChoice === 'all' ? getSupportedIDEs() : [ideChoice];
67
+ let syncCount = 0;
68
+
69
+ for (const ide of idesToSync) {
70
+ const config = getIDEConfig(ide);
71
+ try {
72
+ let count;
73
+ if (isGlobal) {
74
+ count = syncToGlobal(ide);
75
+ } else {
76
+ count = syncToProject(ide, cwd);
77
+ }
78
+
79
+ syncCount += count;
80
+ const targetDir = isGlobal ? config.globalDir : path.join(cwd, config.projectDir);
81
+ printInfo(`已同步 ${count} 个命令到 ${config.name}: ${targetDir}`);
82
+ } catch (error) {
83
+ printWarning(`同步 ${config.name} 命令失败: ${error.message}`);
84
+ }
85
+ }
86
+
87
+ print('');
88
+ printSuccess(`IDE 命令同步完成! 共同步 ${syncCount} 个命令文件`);
89
+ print('');
90
+ print(colorize('可用的 IDE 命令:', colors.bold));
91
+ print(colorize(` /incspec/inc-analyze - 步骤1: 分析代码流程`, colors.dim));
92
+ print(colorize(` /incspec/inc-collect-req - 步骤2: 收集结构化需求`, colors.dim));
93
+ print(colorize(` /incspec/inc-collect-dep - 步骤3: 采集UI依赖`, colors.dim));
94
+ print(colorize(` /incspec/inc-design - 步骤4: 增量设计`, colors.dim));
95
+ print(colorize(` /incspec/inc-apply - 步骤5: 应用代码变更`, colors.dim));
96
+ print(colorize(` /incspec/inc-merge - 步骤6: 合并到基线`, colors.dim));
97
+ print(colorize(` /incspec/inc-archive - 步骤7: 归档产出`, colors.dim));
98
+ print(colorize(` /incspec/inc-status - 查看工作流状态`, colors.dim));
99
+ print(colorize(` /incspec/inc-help - 显示帮助信息`, colors.dim));
100
+ print('');
101
+ print(colorize('下一步:', colors.bold));
102
+ print(colorize(` 1. 运行 'incspec status' 查看工作流状态`, colors.dim));
103
+ print(colorize(` 2. 使用 /incspec/inc-analyze 开始第一个工作流`, colors.dim));
104
+ print('');
105
+ }
106
+
27
107
  /**
28
108
  * Execute init command
29
109
  * @param {Object} ctx - Command context
@@ -119,9 +199,18 @@ export async function initCommand(ctx) {
119
199
  print(colorize(` AGENTS.md (项目根目录)`, colors.cyan));
120
200
  print(colorize(` └── incspec 指令块已添加`, colors.dim));
121
201
  print('');
122
- print(colorize('下一步:', colors.bold));
123
- print(colorize(` 1. 运行 'incspec status' 查看工作流状态`, colors.dim));
124
- print(colorize(` 2. 运行 'incspec sync' 同步 Cursor 命令`, colors.dim));
125
- print(colorize(` 3. 使用 /incspec/inc-analyze 开始第一个工作流`, colors.dim));
126
- print('');
202
+
203
+ // Ask user if they want to sync IDE commands
204
+ const shouldSync = await confirm('是否立即同步 IDE 命令?');
205
+
206
+ if (shouldSync) {
207
+ await syncIDECommands(cwd);
208
+ } else {
209
+ print('');
210
+ print(colorize('下一步:', colors.bold));
211
+ print(colorize(` 1. 运行 'incspec status' 查看工作流状态`, colors.dim));
212
+ print(colorize(` 2. 运行 'incspec sync' 同步 IDE 命令`, colors.dim));
213
+ print(colorize(` 3. 使用 /incspec/inc-analyze 开始第一个工作流`, colors.dim));
214
+ print('');
215
+ }
127
216
  }
@@ -0,0 +1,7 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ *No recent activity*
7
+ </claude-mem-context>
@@ -9,6 +9,7 @@ import * as path from 'path';
9
9
  import * as os from 'os';
10
10
  import { fileURLToPath } from 'url';
11
11
  import { INCSPEC_DIR } from './config.mjs';
12
+ import { MODE_CONFIG, MODE_UPGRADE_ORDER } from './mode-utils.mjs';
12
13
 
13
14
  /** Built-in templates directory */
14
15
  const TEMPLATES_DIR = fileURLToPath(new URL('../templates/commands', import.meta.url));
@@ -114,35 +115,59 @@ function getSourcePath(fileName, fallbackDirs = []) {
114
115
  }
115
116
 
116
117
  /**
117
- * Generate utility commands content
118
- * @returns {Array<{name: string, content: string}>}
118
+ * Generate mode sections for help content
119
+ * Shows all 7 workflow steps with their mode indicators
120
+ * @returns {string}
119
121
  */
120
- function generateUtilityCommands() {
121
- return [
122
- {
123
- name: 'inc-status.md',
124
- content: `---
125
- description: [incspec] 查看当前工作流状态
126
- ---
122
+ function generateModeSections() {
123
+ const lines = [];
124
+
125
+ // Step info: command, description, and which modes support it
126
+ const steps = [
127
+ { cmd: 'inc-analyze', desc: '分析代码流程,生成基线快照', modes: ['full', 'quick', 'minimal'] },
128
+ { cmd: 'inc-collect-req', desc: '收集结构化需求', modes: ['full', 'quick'] },
129
+ { cmd: 'inc-collect-dep', desc: '采集UI依赖', modes: ['full'] },
130
+ { cmd: 'inc-design', desc: '生成增量设计蓝图', modes: ['full'] },
131
+ { cmd: 'inc-apply', desc: '应用代码变更', modes: ['full', 'quick', 'minimal'] },
132
+ { cmd: 'inc-merge', desc: '合并到新基线', modes: ['full', 'quick'] },
133
+ { cmd: 'inc-archive', desc: '归档工作流产出', modes: ['full', 'quick', 'minimal'] }
134
+ ];
127
135
 
128
- # 查看工作流状态
136
+ // Generate all 7 steps with mode indicators
137
+ for (let i = 0; i < steps.length; i++) {
138
+ const step = steps[i];
139
+ const stepNum = i + 1;
129
140
 
130
- 请运行以下命令查看当前工作流状态:
141
+ let cmdLine;
142
+ if (step.modes.length === 3) {
143
+ cmdLine = `\`/incspec/${step.cmd}\``;
144
+ } else if (step.modes.includes('full') && step.modes.includes('quick')) {
145
+ cmdLine = `\`/incspec/${step.cmd}\` (完整/快速)`;
146
+ } else {
147
+ cmdLine = `\`/incspec/${step.cmd}\` (完整)`;
148
+ }
131
149
 
132
- \`\`\`bash
133
- incspec status
134
- \`\`\`
150
+ lines.push(`${stepNum}. ${cmdLine} - ${step.desc}`);
151
+ }
135
152
 
136
- 或直接读取状态文件:
153
+ return lines.join('\n');
154
+ }
137
155
 
138
- \`\`\`bash
139
- cat ${INCSPEC_DIR}/workflow.json
140
- \`\`\`
141
- `,
142
- },
143
- {
144
- name: 'inc-help.md',
145
- content: `---
156
+ /**
157
+ * Generate utility commands content
158
+ * @returns {Array<{name: string, content: string}>}
159
+ */
160
+ function generateUtilityCommands() {
161
+ // Generate help content from template
162
+ const helpTemplatePath = path.join(TEMPLATES_DIR, 'inc-help.md');
163
+ let helpContent;
164
+
165
+ if (fs.existsSync(helpTemplatePath)) {
166
+ const template = fs.readFileSync(helpTemplatePath, 'utf-8');
167
+ helpContent = template.replace('<!-- MODE_SECTIONS -->', generateModeSections());
168
+ } else {
169
+ // Fallback: generate complete content inline
170
+ helpContent = `---
146
171
  description: [incspec] 显示帮助信息
147
172
  ---
148
173
 
@@ -150,22 +175,7 @@ description: [incspec] 显示帮助信息
150
175
 
151
176
  ## 工作流步骤
152
177
 
153
- **完整模式 (7步):**
154
- 1. \`/incspec/inc-analyze\` - 分析代码流程,生成基线快照
155
- 2. \`/incspec/inc-collect-req\` - 收集结构化需求
156
- 3. \`/incspec/inc-collect-dep\` - 采集UI依赖
157
- 4. \`/incspec/inc-design\` - 生成增量设计蓝图
158
- 5. \`/incspec/inc-apply\` - 应用代码变更
159
- 6. \`/incspec/inc-merge\` - 合并到新基线
160
- 7. \`/incspec/inc-archive\` - 归档工作流产出
161
-
162
- **快速模式 (5步):**
163
- 1. \`/incspec/inc-analyze --quick\` - 分析代码流程 (快速模式)
164
- 2. \`/incspec/inc-collect-req\` - 收集结构化需求
165
- 5. \`/incspec/inc-apply\` - 应用代码变更
166
- 6. \`/incspec/inc-merge\` - 合并到新基线
167
- 7. \`/incspec/inc-archive\` - 归档工作流产出
168
-
178
+ ${generateModeSections()}
169
179
  ## 辅助命令
170
180
 
171
181
  - \`/incspec/inc-status\` - 查看当前工作流状态
@@ -193,8 +203,35 @@ ${INCSPEC_DIR}/
193
203
  ├── increments/ # 增量设计
194
204
  └── archives/ # 历史归档 (YYYY-MM/{module}/)
195
205
  \`\`\`
206
+ `;
207
+ }
208
+
209
+ return [
210
+ {
211
+ name: 'inc-status.md',
212
+ content: `---
213
+ description: [incspec] 查看当前工作流状态
214
+ ---
215
+
216
+ # 查看工作流状态
217
+
218
+ 请运行以下命令查看当前工作流状态:
219
+
220
+ \`\`\`bash
221
+ incspec status
222
+ \`\`\`
223
+
224
+ 或直接读取状态文件:
225
+
226
+ \`\`\`bash
227
+ cat ${INCSPEC_DIR}/workflow.json
228
+ \`\`\`
196
229
  `,
197
230
  },
231
+ {
232
+ name: 'inc-help.md',
233
+ content: helpContent,
234
+ },
198
235
  ];
199
236
  }
200
237
 
@@ -0,0 +1,12 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ ### Jan 8, 2026
7
+
8
+ | ID | Time | T | Title | Read |
9
+ |----|------|---|-------|------|
10
+ | #105 | 2:48 PM | 🔵 | 发现模板文件目录结构 | ~96 |
11
+ | #94 | 2:40 PM | 🔵 | 发现 IncSpec 模板文件结构 | ~62 |
12
+ </claude-mem-context>
@@ -0,0 +1,11 @@
1
+ <claude-mem-context>
2
+ # Recent Activity
3
+
4
+ <!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
5
+
6
+ ### Jan 8, 2026
7
+
8
+ | ID | Time | T | Title | Read |
9
+ |----|------|---|-------|------|
10
+ | #106 | 3:07 PM | 🔵 | 完成对 inc-help.md 写入机制的深度分析 | ~130 |
11
+ </claude-mem-context>
@@ -0,0 +1,37 @@
1
+ ---
2
+ description: [incspec] 显示帮助信息
3
+ ---
4
+
5
+ # incspec 帮助
6
+
7
+ ## 工作流步骤
8
+
9
+ <!-- MODE_SECTIONS -->
10
+
11
+ ## 辅助命令
12
+
13
+ - `/incspec/inc-status` - 查看当前工作流状态
14
+ - `/incspec/inc-help` - 显示帮助信息
15
+
16
+ ## CLI 命令
17
+
18
+ ```bash
19
+ incspec init # 初始化项目
20
+ incspec status # 查看工作流状态
21
+ incspec list # 列出规范文件
22
+ incspec validate # 验证规范完整性
23
+ incspec sync # 同步 IDE 命令
24
+ incspec help # 显示帮助
25
+ ```
26
+
27
+ ## 目录结构
28
+
29
+ ```
30
+ incspec/
31
+ ├── project.md # 项目配置
32
+ ├── workflow.json # 工作流状态
33
+ ├── baselines/ # 基线快照
34
+ ├── requirements/ # 需求文档
35
+ ├── increments/ # 增量设计
36
+ └── archives/ # 历史归档 (YYYY-MM/{module}/)
37
+ ```