speccrew 0.6.11 → 0.6.13

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.
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * reindex-modules.js - 确定性脚本,用更新后的 exclude_dirs 对已有 features JSON 重新提取 module
3
+ * reindex-modules.js - Deterministic script to re-extract module names from existing features JSON with updated exclude_dirs
4
4
  *
5
- * 调用方式:
5
+ * Usage:
6
6
  * node reindex-modules.js --featuresFile "path/to/features-backend-system.json" --projectRoot "d:\dev\ruoyi-vue-pro"
7
7
  *
8
- * 可选参数:
9
- * --platformType "backend" - 如果不提供,从 features JSON platformType 字段读取
10
- * --techIdentifier "spring" - 如果不提供,尝试从 features JSON 推断(如 techStack 数组)
11
- * --excludeDirs "controller,admin,api,service" - 如果不提供,从 tech-stack-mappings.json 加载
8
+ * Optional parameters:
9
+ * --platformType "backend" - If not provided, read from features JSON's platformType field
10
+ * --techIdentifier "spring" - If not provided, try to infer from features JSON (e.g., techStack array)
11
+ * --excludeDirs "controller,admin,api,service" - If not provided, load from tech-stack-mappings.json
12
12
  */
13
13
 
14
14
  const fs = require('fs');
15
15
  const path = require('path');
16
16
 
17
- // === 工具函数(从 generate-inventory.js 复用) ===
17
+ // === Utility functions (reused from generate-inventory.js) ===
18
18
 
19
19
  function normalizePath(filePath) {
20
20
  if (!filePath) return '';
@@ -32,7 +32,7 @@ function parseArrayParam(value) {
32
32
  return trimmed.split(',').map(s => s.trim()).filter(Boolean);
33
33
  }
34
34
 
35
- // Java/Kotlin 标准源码路径前缀
35
+ // Java/Kotlin standard source path prefixes
36
36
  const STANDARD_SOURCE_PREFIXES = [
37
37
  'src/main/java',
38
38
  'src/main/kotlin',
@@ -77,7 +77,7 @@ function getModuleName(dirPath, excludeDirs, fallbackModuleName) {
77
77
  return '_root';
78
78
  }
79
79
 
80
- // === 辅助函数 ===
80
+ // === Helper functions ===
81
81
 
82
82
  function parseArgs(argv) {
83
83
  const args = {};
@@ -113,10 +113,10 @@ function findProjectRoot(startPath) {
113
113
  function loadExcludeDirs(projectRoot, platformType, techIdentifier, featuresData) {
114
114
  console.log(`Loading exclude_dirs: platformType="${platformType}", techIdentifier="${techIdentifier || '(auto)'}"`);
115
115
 
116
- // 尝试推断 techIdentifier
116
+ // Try to infer techIdentifier
117
117
  if (!techIdentifier) {
118
118
  const techStack = featuresData.techStack || [];
119
- // 常见映射
119
+ // Common mappings
120
120
  const techMap = {
121
121
  'spring': 'spring', 'spring-boot': 'spring', 'java': 'spring',
122
122
  'vue': 'vue', 'vue3': 'vue', 'vue2': 'vue',
@@ -147,7 +147,7 @@ function loadExcludeDirs(projectRoot, platformType, techIdentifier, featuresData
147
147
  // Get fallback dirs for this platformType
148
148
  const fallback = FALLBACK_EXCLUDE_DIRS[platformType] || [];
149
149
 
150
- // 查找 tech-stack-mappings.json
150
+ // Find tech-stack-mappings.json
151
151
  const configPaths = [
152
152
  path.join(projectRoot, 'speccrew-workspace', 'docs', 'configs', 'tech-stack-mappings.json'),
153
153
  path.join(projectRoot, 'docs', 'configs', 'tech-stack-mappings.json'),
@@ -207,25 +207,25 @@ function loadExcludeDirs(projectRoot, platformType, techIdentifier, featuresData
207
207
  }
208
208
 
209
209
  function extractPlatformId(featuresData) {
210
- // 从第一个 feature documentPath 提取 platformId
211
- // 格式: "speccrew-workspace/knowledges/bizs/{platformId}/..."
210
+ // Extract platformId from first feature's documentPath
211
+ // Format: "speccrew-workspace/knowledges/bizs/{platformId}/..."
212
212
  for (const feature of (featuresData.features || [])) {
213
213
  if (feature.documentPath) {
214
214
  const match = normalizePath(feature.documentPath).match(/knowledges\/bizs\/([^/]+)\//);
215
215
  if (match) return match[1];
216
216
  }
217
217
  }
218
- // 如果无法提取,用 platformType-platformSubtype 构建
218
+ // If unable to extract, build from platformType-platformSubtype
219
219
  if (featuresData.platformType && featuresData.platformSubtype) {
220
220
  return `${featuresData.platformType}-${featuresData.platformSubtype}`;
221
221
  }
222
222
  return null;
223
223
  }
224
224
 
225
- // === 主逻辑 ===
225
+ // === Main logic ===
226
226
 
227
227
  function main() {
228
- // 1. 解析命令行参数
228
+ // 1. Parse command line arguments
229
229
  const args = parseArgs(process.argv.slice(2));
230
230
  const featuresFile = args.featuresFile;
231
231
 
@@ -234,7 +234,7 @@ function main() {
234
234
  process.exit(1);
235
235
  }
236
236
 
237
- // 2. 读取 features JSON
237
+ // 2. Read features JSON
238
238
  let featuresData;
239
239
  try {
240
240
  featuresData = JSON.parse(fs.readFileSync(featuresFile, 'utf8'));
@@ -250,16 +250,16 @@ function main() {
250
250
  const inventorySourcePath = normalizePath(featuresData.sourcePath || '');
251
251
  const platformType = args.platformType || featuresData.platformType || '';
252
252
 
253
- // 3. 加载 exclude_dirs
253
+ // 3. Load exclude_dirs
254
254
  let excludeDirs = [];
255
255
  let stripModulePrefixes = [];
256
256
  if (args.excludeDirs) {
257
257
  excludeDirs = parseArrayParam(args.excludeDirs);
258
258
  } else {
259
- // tech-stack-mappings.json 加载,按优先级确定 techIdentifier
260
- // 1. 命令行参数 --techIdentifier
261
- // 2. features JSON 中的 techIdentifier
262
- // 3. features JSON 中的 platformSubtype (兼容旧数据)
259
+ // Load from tech-stack-mappings.json, determine techIdentifier by priority:
260
+ // 1. Command line parameter --techIdentifier
261
+ // 2. techIdentifier in features JSON
262
+ // 3. platformSubtype in features JSON (backward compatibility)
263
263
  const techId = args.techIdentifier || featuresData.techIdentifier || featuresData.platformSubtype;
264
264
  const config = loadExcludeDirs(projectRoot, platformType, techId, featuresData);
265
265
  excludeDirs = config.excludeDirs;
@@ -274,29 +274,29 @@ function main() {
274
274
  console.log(`Exclude dirs (${excludeDirs.length}): ${excludeDirs.join(', ')}`);
275
275
  console.log(`Total features: ${featuresData.features.length}`);
276
276
 
277
- // 4. 重新计算每个 feature module
277
+ // 4. Recalculate module for each feature
278
278
  const modulesBefore = [...new Set(featuresData.features.map(f => f.module))].sort();
279
279
  let reclassifiedCount = 0;
280
280
 
281
- // features JSON 获取 platformId(用于重建 documentPath
282
- // platformId 格式: "{platformType}-{platformSubtype}"
283
- // 从现有 documentPath 提取: "speccrew-workspace/knowledges/bizs/{platformId}/..."
281
+ // Get platformId from features JSON (for rebuilding documentPath)
282
+ // platformId format: "{platformType}-{platformSubtype}"
283
+ // Extract from existing documentPath: "speccrew-workspace/knowledges/bizs/{platformId}/..."
284
284
  const platformId = extractPlatformId(featuresData);
285
285
 
286
286
  featuresData.features.forEach(feature => {
287
- // 计算 feature 源文件相对于 inventorySourcePath 的路径
287
+ // Calculate feature source file path relative to inventorySourcePath
288
288
  let relativePath = normalizePath(feature.sourcePath || '');
289
289
 
290
- // 如果 feature.sourcePath 是绝对路径或相对于项目根,需要去掉 inventorySourcePath 前缀
290
+ // If feature.sourcePath is absolute or relative to project root, remove inventorySourcePath prefix
291
291
  if (inventorySourcePath && relativePath.startsWith(inventorySourcePath)) {
292
292
  relativePath = relativePath.slice(inventorySourcePath.length);
293
293
  if (relativePath.startsWith('/')) relativePath = relativePath.slice(1);
294
294
  }
295
- // 也可能 inventorySourcePath 只是部分匹配
295
+ // inventorySourcePath may only partially match
296
296
  else if (inventorySourcePath) {
297
297
  const invParts = inventorySourcePath.split('/');
298
298
  const relParts = relativePath.split('/');
299
- // 找到重叠部分
299
+ // Find overlapping part
300
300
  let startIdx = 0;
301
301
  for (let i = 0; i < relParts.length; i++) {
302
302
  if (relParts.slice(i, i + invParts.length).join('/') === inventorySourcePath) {
@@ -309,14 +309,14 @@ function main() {
309
309
  }
310
310
  }
311
311
 
312
- // 取目录部分(去掉文件名)
312
+ // Get directory part (remove filename)
313
313
  const dirPath = path.dirname(relativePath).replace(/\\/g, '/');
314
314
 
315
- // getModuleName 重新提取模块名
315
+ // Re-extract module name using getModuleName
316
316
  const fallback = feature.module || '_root';
317
317
  let newModule = getModuleName(dirPath, excludeDirs, fallback);
318
318
 
319
- // 应用 strip_module_prefixes 前缀去除
319
+ // Apply strip_module_prefixes prefix removal
320
320
  for (const prefix of stripModulePrefixes) {
321
321
  if (newModule.startsWith(prefix)) {
322
322
  newModule = newModule.substring(prefix.length);
@@ -328,21 +328,21 @@ function main() {
328
328
  reclassifiedCount++;
329
329
  feature.module = newModule;
330
330
 
331
- // 重建 documentPath(使用 fileName 而非 feature.id,避免文件名过长)
331
+ // Rebuild documentPath (use fileName instead of feature.id to avoid long filenames)
332
332
  if (platformId) {
333
333
  feature.documentPath = `speccrew-workspace/knowledges/bizs/${platformId}/${newModule}/${feature.fileName}.md`;
334
334
  }
335
335
  }
336
336
  });
337
337
 
338
- // 5. 更新 modules 数组
338
+ // 5. Update modules array
339
339
  const modulesAfter = [...new Set(featuresData.features.map(f => f.module))].sort();
340
340
  featuresData.modules = modulesAfter;
341
341
 
342
- // 6. 写回文件
342
+ // 6. Write back to file
343
343
  fs.writeFileSync(featuresFile, JSON.stringify(featuresData, null, 2), 'utf8');
344
344
 
345
- // 7. 输出结果
345
+ // 7. Output results
346
346
  const result = {
347
347
  status: 'success',
348
348
  modules_before: modulesBefore,
@@ -59,20 +59,22 @@ Stage 1: Platform Detection
59
59
  └─ Read techs-manifest.json → Identify platforms & tech stacks
60
60
 
61
61
  Stage 2: Tech Doc Generation (PARALLEL)
62
- └─ Dispatch techs-generate workers per platform
63
- └─ After each generate worker completesdispatch quality check worker
62
+ └─ Prepare task plans for techs-generate workers per platform
63
+ └─ After generate workers completeprepare quality check worker task plans
64
64
  └─ Monitor completion markers
65
65
 
66
66
  Stage 2.5: Completion Verification
67
67
  └─ Step A: Scan completion markers
68
68
  └─ Step B: Verify output integrity
69
- └─ Step C: Update dispatch progress
69
+ └─ Step C: Update progress status
70
70
 
71
71
  Stage 3: Root Index Generation
72
72
  └─ Generate techs/README.md root index
73
73
  └─ Cross-platform consistency check
74
74
  ```
75
75
 
76
+ > **NOTE**: All worker dispatch operations are handled by the calling Agent (Team Leader). This Skill only prepares task plans and monitors completion markers.
77
+
76
78
  ## Workflow Overview
77
79
 
78
80
  ```mermaid
@@ -90,10 +92,14 @@ flowchart TB
90
92
  **Step 1a: Read Configuration**
91
93
  - Read `speccrew-workspace/docs/configs/platform-mapping.json` for standardized platform mapping rules
92
94
 
93
- **Step 1b: Invoke Worker**
94
- - Invoke 1 Worker Agent (`speccrew-task-worker.md`) with skill `speccrew-knowledge-techs-init/SKILL.md`
95
- - Task: Analyze project structure, detect technology platforms
96
- - Parameters to pass to skill:
95
+ **Step 1b: Prepare Task Plan**
96
+
97
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
98
+
99
+ Prepare the following task for the calling Agent to dispatch:
100
+ - **Skill**: `speccrew-knowledge-techs-init/SKILL.md`
101
+ - **Task**: Analyze project structure, detect technology platforms
102
+ - **Parameters**:
97
103
  - `source_path`: Source code directory path
98
104
  - `output_path`: Output directory (default: `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/`)
99
105
  - `language`: User's language — **REQUIRED**
@@ -108,11 +114,13 @@ See [Platform Status Tracking Fields](#platform-status-tracking-fields) for stat
108
114
  ---
109
115
 
110
116
  > **⚠️ MANDATORY RULES FOR PARALLEL EXECUTION (Stage 2)**:
111
- > 1. ALL platform workers MUST be dispatched in PARALLEL — sequential execution is FORBIDDEN
117
+ > 1. ALL platform task plans should be prepared for parallel dispatch by the calling Agent — sequential execution is NOT recommended
112
118
  > 2. Each platform worker runs independently via techs-generate Skill
113
119
  > 3. Monitor completion via marker files in each platform directory
114
120
  > 4. Failed workers can be retried independently
115
121
  > 5. Do NOT proceed to Stage 2.5 until ALL workers have completed or failed
122
+ >
123
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares task plans.
116
124
 
117
125
  ## Stage 2: Generate Platform Documents (Parallel)
118
126
 
@@ -120,21 +128,27 @@ See [Platform Status Tracking Fields](#platform-status-tracking-fields) for stat
120
128
 
121
129
  **Action**:
122
130
  - Read `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/techs-manifest.json`
123
- - For each platform in `platforms` array, invoke 2 Worker Agents in PARALLEL:
124
- - Worker 1: `speccrew-knowledge-techs-generate-conventions/SKILL.md` (ALL platforms)
125
- - Worker 2: `speccrew-knowledge-techs-generate-ui-style/SKILL.md` (frontend platforms ONLY: web, mobile, desktop)
126
- - Parameters to pass to each skill:
127
- - `platform_id`: Platform identifier from manifest
128
- - `platform_type`: Platform type (web, mobile, backend, desktop)
129
- - `framework`: Primary framework
130
- - `source_path`: Platform source directory
131
- - `config_files`: List of configuration file paths (conventions worker only)
132
- - `convention_files`: List of convention file paths (conventions worker only)
133
- - `output_path`: Output directory for platform docs (e.g., `speccrew-workspace/knowledges/techs/{platform_id}/`)
134
- - `completed_dir`: Directory for Worker output markers (e.g., `speccrew-workspace/knowledges/techs/.sync-status/`)
135
- - `language`: User's language — **REQUIRED**
136
131
 
137
- When launching each platform Worker, the Workers will output:
132
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
133
+
134
+ **Prepare Task Plans for Each Platform**:
135
+
136
+ For each platform in `platforms` array, prepare tasks for parallel execution:
137
+ - **Task 1**: `speccrew-knowledge-techs-generate-conventions/SKILL.md` (ALL platforms)
138
+ - **Task 2**: `speccrew-knowledge-techs-generate-ui-style/SKILL.md` (frontend platforms ONLY: web, mobile, desktop)
139
+
140
+ **Parameters for each skill**:
141
+ - `platform_id`: Platform identifier from manifest
142
+ - `platform_type`: Platform type (web, mobile, backend, desktop)
143
+ - `framework`: Primary framework
144
+ - `source_path`: Platform source directory
145
+ - `config_files`: List of configuration file paths (conventions worker only)
146
+ - `convention_files`: List of convention file paths (conventions worker only)
147
+ - `output_path`: Output directory for platform docs (e.g., `speccrew-workspace/knowledges/techs/{platform_id}/`)
148
+ - `completed_dir`: Directory for Worker output markers (e.g., `speccrew-workspace/knowledges/techs/.sync-status/`)
149
+ - `language`: User's language — **REQUIRED**
150
+
151
+ **Expected Worker Output Markers**:
138
152
  - `{completed_dir}/{platform_id}.done-conventions.json` — conventions worker completion marker
139
153
  - `{completed_dir}/{platform_id}.done-ui-style.json` — ui-style worker completion marker (frontend only)
140
154
  - `{completed_dir}/{platform_id}.analysis-conventions.json` — conventions coverage report
@@ -150,9 +164,11 @@ When launching each platform Worker, the Workers will output:
150
164
  - IF platform.platform_type IN ["web", "mobile", "desktop"]: SET `platform.workers.ui_style.status = "processing"`
151
165
  - WRITE manifest to techs-manifest.json
152
166
 
153
- **Step 2b: Launch Conventions Worker (ALL Platforms)**
167
+ **Step 2b: Prepare Conventions Worker Task Plans (ALL Platforms)**
168
+
169
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
154
170
 
155
- For each platform, invoke `speccrew-task-worker` with:
171
+ For each platform, prepare a task with:
156
172
  - skill_path: `speccrew-knowledge-techs-generate-conventions/SKILL.md`
157
173
  - context:
158
174
  - platform_id: platform.platform_id
@@ -165,10 +181,12 @@ For each platform, invoke `speccrew-task-worker` with:
165
181
  - completed_dir: completed_dir
166
182
  - language: language
167
183
 
168
- **Step 2c: Launch UI-Style Worker (Frontend Platforms ONLY)**
184
+ **Step 2c: Prepare UI-Style Worker Task Plans (Frontend Platforms ONLY)**
185
+
186
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
169
187
 
170
188
  IF platform.platform_type IN ["web", "mobile", "desktop"]:
171
- 1. Invoke `speccrew-task-worker` with:
189
+ 1. Prepare a task with:
172
190
  - skill_path: `speccrew-knowledge-techs-generate-ui-style/SKILL.md`
173
191
  - context:
174
192
  - platform_id: platform.platform_id
@@ -179,13 +197,20 @@ IF platform.platform_type IN ["web", "mobile", "desktop"]:
179
197
  - completed_dir: completed_dir
180
198
  - language: language
181
199
 
182
- **Step 2d: Wait for All Workers**
183
- - WAIT_ALL workers complete
200
+ **Step 2d: Completion Marker Monitoring**
201
+
202
+ > **NOTE**: Worker dispatch and wait operations are handled by the calling Agent (Team Leader). This Skill only monitors completion markers.
203
+
204
+ The calling Agent should:
205
+ - Monitor for `{platform_id}.done-conventions.json` markers
206
+ - Monitor for `{platform_id}.done-ui-style.json` markers (frontend platforms)
184
207
  - Both workers run in PARALLEL for the same platform
185
208
 
186
- **Step 2e: Launch Quality Check Workers PARALLEL per Completed Generate Worker**
209
+ **Step 2e: Prepare Quality Check Worker Task Plans**
210
+
211
+ > **NOTE**: Quality worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
187
212
 
188
- After each `speccrew-knowledge-techs-generate` worker completes (writes `.done-conventions.json` marker), immediately dispatch the corresponding quality check worker:
213
+ After each `speccrew-knowledge-techs-generate` worker completes (writes `.done-conventions.json` or `.done-ui-style.json` marker), the calling Agent should dispatch the corresponding quality check worker.
189
214
 
190
215
  | Generate Worker | Quality Worker | Input |
191
216
  |-----------------|----------------|-------|
@@ -206,12 +231,25 @@ After each `speccrew-knowledge-techs-generate` worker completes (writes `.done-c
206
231
  }
207
232
  ```
208
233
 
209
- **Execution sequence**:
210
- 1. Scan `completed_dir` for new `.done-conventions.json` and `.done-ui-style.json` files
211
- 2. For each completed generate worker, prepare corresponding quality worker task
212
- 3. Launch ALL quality workers for the current batch in PARALLEL
213
- 4. Wait for ALL quality workers to complete
214
- 5. Each quality worker writes `.quality-done.json` marker to `completed_dir`
234
+ **Quality Worker Completion Marker**:
235
+
236
+ Each quality worker writes a `.quality-done.json` marker to `completed_dir` upon completion:
237
+
238
+ ```json
239
+ {
240
+ "platform_id": "web-vue",
241
+ "worker_type": "quality",
242
+ "status": "completed",
243
+ "quality_score": 85,
244
+ "issues_found": 2,
245
+ "completed_at": "2024-01-15T11:00:00Z"
246
+ }
247
+ ```
248
+
249
+ **Expected Completion Markers after Stage 2**:
250
+ 1. `{platform_id}.done-conventions.json` — conventions worker marker
251
+ 2. `{platform_id}.done-ui-style.json` — ui-style worker marker (frontend only)
252
+ 3. `{platform_id}.quality-done.json` — quality worker marker
215
253
 
216
254
  > **Stage 2 Completion Condition**: ALL generate workers AND ALL quality check workers completed (`.done-*.json` and `.quality-done.json` markers present) before proceeding to Stage 2.5
217
255
 
@@ -585,8 +623,12 @@ Write to `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/stage2-s
585
623
 
586
624
  **Action**:
587
625
  - Read `speccrew-workspace/knowledges/base/sync-state/knowledge-techs/techs-manifest.json`
588
- - Invoke 1 Worker Agent (`speccrew-task-worker.md`) with skill `speccrew-knowledge-techs-index/SKILL.md`
589
- - Parameters to pass to skill:
626
+
627
+ > **NOTE**: Worker dispatch is handled by the calling Agent (Team Leader). This Skill only prepares the task plan and parameters.
628
+
629
+ **Prepare Task Plan**:
630
+ - **Skill**: `speccrew-knowledge-techs-index/SKILL.md`
631
+ - **Parameters**:
590
632
  - `manifest_path`: Path to techs-manifest.json
591
633
  - `techs_base_path`: Base path for techs documentation (e.g., `speccrew-workspace/knowledges/techs/`)
592
634
  - `output_path`: Output path for root INDEX.md (e.g., `speccrew-workspace/knowledges/techs/`)
@@ -638,17 +680,19 @@ THRESHOLD: warnings > 5 → flag for manual review
638
680
 
639
681
  ## Execution Flow
640
682
 
683
+ > **NOTE**: All worker dispatch and wait operations are handled by the calling Agent (Team Leader). This Skill only prepares task plans and monitors completion markers.
684
+
641
685
  ```
642
686
  1. Run Stage 1 (Platform Detection)
643
- └─ Wait for completion
687
+ └─ Prepare task plan → Monitor completion
644
688
 
645
689
  2. Run Stage 2 (Tech Doc Generation)
646
690
  ├─ Read techs-manifest.json
647
- ├─ Launch ALL platform Workers in parallel
648
- └─ Wait for ALL Workers → generate stage2-status.json
691
+ ├─ Prepare ALL platform task plans for parallel dispatch
692
+ └─ Monitor completion markers → generate stage2-status.json
649
693
 
650
694
  3. Run Stage 3 (Root Index)
651
- └─ Wait for completion → generate stage3-status.json
695
+ └─ Prepare task plan → Monitor completion → generate stage3-status.json
652
696
  ```
653
697
 
654
698
  ---