claude-code-workflow 6.3.42 → 6.3.44

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.
Files changed (87) hide show
  1. package/.claude/agents/tdd-developer.md +530 -0
  2. package/.claude/commands/issue/discover-by-prompt.md +5 -1
  3. package/.claude/commands/issue/discover.md +472 -468
  4. package/.claude/commands/issue/execute.md +580 -581
  5. package/.claude/commands/issue/new.md +417 -413
  6. package/.claude/commands/issue/plan.md +11 -13
  7. package/.claude/commands/issue/queue.md +445 -441
  8. package/.claude/commands/task/breakdown.md +207 -203
  9. package/.claude/commands/task/replan.md +440 -436
  10. package/.claude/commands/workflow/action-plan-verify.md +485 -447
  11. package/.claude/commands/workflow/brainstorm/artifacts.md +457 -453
  12. package/.claude/commands/workflow/brainstorm/auto-parallel.md +5 -1
  13. package/.claude/commands/workflow/brainstorm/synthesis.md +402 -398
  14. package/.claude/commands/workflow/clean.md +67 -35
  15. package/.claude/commands/workflow/debug-with-file.md +670 -666
  16. package/.claude/commands/workflow/debug.md +331 -327
  17. package/.claude/commands/workflow/develop-with-file.md +5 -1
  18. package/.claude/commands/workflow/execute.md +546 -498
  19. package/.claude/commands/workflow/lite-execute.md +44 -26
  20. package/.claude/commands/workflow/lite-fix.md +780 -730
  21. package/.claude/commands/workflow/lite-lite-lite.md +5 -1
  22. package/.claude/commands/workflow/lite-plan.md +87 -39
  23. package/.claude/commands/workflow/multi-cli-plan.md +572 -568
  24. package/.claude/commands/workflow/plan-verify.md +527 -0
  25. package/.claude/commands/workflow/plan.md +555 -551
  26. package/.claude/commands/workflow/replan.md +572 -515
  27. package/.claude/commands/workflow/review-fix.md +608 -610
  28. package/.claude/commands/workflow/session/complete.md +37 -14
  29. package/.claude/commands/workflow/session/solidify.md +303 -299
  30. package/.claude/commands/workflow/tdd-plan.md +630 -597
  31. package/.claude/commands/workflow/tdd-verify.md +391 -206
  32. package/.claude/commands/workflow/tools/conflict-resolution.md +24 -12
  33. package/.claude/commands/workflow/tools/task-generate-agent.md +583 -563
  34. package/.claude/commands/workflow/tools/task-generate-tdd.md +749 -517
  35. package/.claude/commands/workflow/ui-design/animation-extract.md +1154 -1150
  36. package/.claude/commands/workflow/ui-design/layout-extract.md +792 -788
  37. package/.claude/commands/workflow/ui-design/style-extract.md +777 -773
  38. package/.claude/skills/ccw/command.json +4 -4
  39. package/.claude/skills/ccw-coordinator/README.md +45 -0
  40. package/.claude/skills/ccw-coordinator/SKILL.md +320 -0
  41. package/.claude/skills/ccw-coordinator/phases/actions/action-abort.md +9 -0
  42. package/.claude/skills/ccw-coordinator/phases/actions/action-command-build.md +40 -0
  43. package/.claude/skills/ccw-coordinator/phases/actions/action-command-execute.md +124 -0
  44. package/.claude/skills/ccw-coordinator/phases/actions/action-command-selection.md +48 -0
  45. package/.claude/skills/ccw-coordinator/phases/actions/action-complete.md +25 -0
  46. package/.claude/skills/ccw-coordinator/phases/actions/action-init.md +26 -0
  47. package/.claude/skills/ccw-coordinator/phases/orchestrator.md +59 -0
  48. package/.claude/skills/ccw-coordinator/phases/state-schema.md +66 -0
  49. package/.claude/skills/ccw-coordinator/skill-config.json +66 -0
  50. package/.claude/skills/ccw-coordinator/specs/command-library.md +169 -0
  51. package/.claude/skills/ccw-coordinator/specs/specs.md +362 -0
  52. package/.claude/skills/ccw-coordinator/tools/README.md +95 -0
  53. package/.claude/skills/ccw-coordinator/tools/chain-validate.cjs +320 -0
  54. package/.claude/skills/ccw-coordinator/tools/command-registry.cjs +255 -0
  55. package/.claude/skills/ccw-help/command.json +5 -5
  56. package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -337
  57. package/.claude/workflows/cli-templates/prompts/workflow-impl-plan-template.txt +1 -1
  58. package/.codex/skills/parallel-dev-cycle/README.md +19 -16
  59. package/.codex/skills/parallel-dev-cycle/phases/agents/code-developer.md +90 -5
  60. package/.codex/skills/parallel-dev-cycle/phases/agents/requirements-analyst.md +89 -4
  61. package/.codex/skills/parallel-dev-cycle/phases/orchestrator.md +696 -696
  62. package/.codex/skills/parallel-dev-cycle/phases/state-schema.md +436 -436
  63. package/.codex/skills/parallel-dev-cycle/skill.md +194 -0
  64. package/.codex/skills/parallel-dev-cycle/specs/communication-optimization.md +423 -423
  65. package/.codex/skills/parallel-dev-cycle/specs/coordination-protocol.md +31 -16
  66. package/.codex/skills/parallel-dev-cycle/specs/versioning-strategy.md +74 -73
  67. package/ccw/dist/commands/issue.d.ts +4 -0
  68. package/ccw/dist/commands/issue.d.ts.map +1 -1
  69. package/ccw/dist/commands/issue.js +73 -6
  70. package/ccw/dist/commands/issue.js.map +1 -1
  71. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  72. package/ccw/dist/core/routes/cli-routes.js +32 -28
  73. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  74. package/ccw/dist/tools/claude-cli-tools.d.ts +10 -0
  75. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  76. package/ccw/dist/tools/claude-cli-tools.js +45 -0
  77. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  78. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  79. package/ccw/dist/tools/codex-lens.js +38 -11
  80. package/ccw/dist/tools/codex-lens.js.map +1 -1
  81. package/ccw/src/commands/issue.ts +84 -6
  82. package/ccw/src/core/routes/cli-routes.ts +30 -25
  83. package/ccw/src/templates/dashboard-js/views/help.js +1 -1
  84. package/ccw/src/tools/claude-cli-tools.ts +50 -0
  85. package/ccw/src/tools/codex-lens.ts +40 -11
  86. package/package.json +1 -1
  87. package/.codex/skills/parallel-dev-cycle/SKILL.md +0 -513
@@ -12,19 +12,26 @@ The coordination protocol enables four parallel agents (RA, EP, CD, VAS) to comm
12
12
 
13
13
  **Location**: `.workflow/.cycle/{cycleId}.json`
14
14
 
15
- All agents read from and write to the unified state file:
15
+ **Access Pattern**:
16
+ - **Agents**: READ ONLY - check dependencies and status
17
+ - **Orchestrator**: READ-WRITE - updates state after each phase
16
18
 
17
19
  ```javascript
18
- // Every agent: Read fresh state at action start
20
+ // Every agent: Read state to check dependencies
19
21
  const state = JSON.parse(Read(`.workflow/.cycle/${cycleId}.json`))
22
+ const canProceed = checkDependencies(state)
20
23
 
21
- // Every agent: Write updated state at action end
22
- Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
24
+ // Agent outputs PHASE_RESULT (reports to orchestrator, NOT writes directly)
25
+ console.log("PHASE_RESULT: ...")
26
+
27
+ // Only Orchestrator writes to state file after receiving PHASE_RESULT
28
+ // Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(updatedState, null, 2))
23
29
  ```
24
30
 
25
31
  **Protocol**:
26
- - Read-Update-Write pattern (no lock needed, orchestrator serializes)
27
- - Timestamp all updates with ISO8601 format
32
+ - Only orchestrator writes to state file (no concurrent writes, no lock needed)
33
+ - Agents read state to understand dependencies
34
+ - Timestamp all orchestrator updates with ISO8601 format
28
35
  - Never delete existing data, only append
29
36
 
30
37
  ### 2. Progress Markdown Files (Async Log)
@@ -33,18 +40,18 @@ Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
33
40
 
34
41
  Each agent writes progress to dedicated markdown files:
35
42
 
36
- | Agent | Files |
37
- |-------|-------|
38
- | RA | requirements.md, edge-cases.md, changes.log |
39
- | EP | exploration.md, architecture.md, plan.json |
40
- | CD | implementation.md, code-changes.log, issues.md |
41
- | VAS | validation.md, test-results.json, coverage.md, summary.md |
43
+ | Agent | Main Documents (Rewrite) | Logs (Append-Only) |
44
+ |-------|--------------------------|-------------------|
45
+ | RA | requirements.md | changes.log |
46
+ | EP | exploration.md, architecture.md, plan.json | changes.log |
47
+ | CD | implementation.md, issues.md | changes.log, debug-log.ndjson |
48
+ | VAS | validation.md, summary.md, test-results.json | changes.log |
42
49
 
43
50
  **Protocol**:
44
- - Append-only pattern (no overwrites)
45
- - Version each document independently
51
+ - **Main documents**: Complete rewrite per iteration, archived to `history/`
52
+ - **Log files**: Append-only (changes.log, debug-log.ndjson) - never delete
53
+ - **Version synchronization**: All main documents share same version (e.g., all v1.1.0 in iteration 2)
46
54
  - Include timestamp on each update
47
- - Maintain backward compatibility
48
55
 
49
56
  ### 3. Orchestrator send_input (Synchronous)
50
57
 
@@ -198,6 +205,8 @@ PHASE_DETAILS:
198
205
 
199
206
  ## Dependency Resolution
200
207
 
208
+ **Execution Model**: All four agents are spawned in parallel, but execution blocks based on dependencies. Orchestrator manages dependency resolution via shared state.
209
+
201
210
  ### Build Order (Default)
202
211
 
203
212
  ```
@@ -206,6 +215,12 @@ RA (Requirements) → EP (Planning) → CD (Development) → VAS (Validation)
206
215
  Block EP Block CD Block VAS Block completion
207
216
  ```
208
217
 
218
+ **Explanation**:
219
+ - All agents spawned simultaneously
220
+ - Each agent checks dependencies in shared state before proceeding
221
+ - Blocked agents wait for dependency completion
222
+ - Orchestrator uses `send_input` to notify dependent agents when ready
223
+
209
224
  ### Parallel Opportunities
210
225
 
211
226
  Some phases can run in parallel:
@@ -384,7 +399,7 @@ console.log(state.coordination.feedback_log)
384
399
  tail .workflow/.cycle/cycle-xxx.progress/ra/changes.log
385
400
 
386
401
  # Check CD changes
387
- grep "TASK-001" .workflow/.cycle/cycle-xxx.progress/cd/code-changes.log
402
+ grep "TASK-001" .workflow/.cycle/cycle-xxx.progress/cd/changes.log
388
403
 
389
404
  # Check coordination timeline
390
405
  tail -50 .workflow/.cycle/cycle-xxx.progress/coordination/feedback.md
@@ -1,50 +1,51 @@
1
1
  # Document Versioning Strategy
2
2
 
3
- 文档版本管理策略:重新创建 vs 增量更新
3
+ Document version management strategy: Complete Rewrite + Archive History
4
4
 
5
- ## 推荐方案:重新创建 + 归档历史
5
+ ## Recommended Approach: Complete Rewrite + Archive History
6
6
 
7
- 每次迭代,**完全重写**主文档,旧版本自动归档到 `history/` 目录。
7
+ For each iteration, **completely rewrite** the main document, and automatically archive the old version to the `history/` directory.
8
8
 
9
- ### 文件结构
9
+ ### File Structure
10
10
 
11
11
  ```
12
12
  .workflow/.cycle/cycle-v1-20260122-abc123.progress/
13
13
  ├── ra/
14
- │ ├── requirements.md # v1.2.0 (当前版本,重新创建)
15
- │ ├── edge-cases.md # v1.2.0 (当前版本,重新创建)
16
- │ ├── changes.log # NDJSON 完整变更历史(append-only
14
+ │ ├── requirements.md # v1.2.0 (current version, complete rewrite)
15
+ │ ├── edge-cases.md # v1.2.0 (current version, complete rewrite)
16
+ │ ├── changes.log # NDJSON complete change history (append-only)
17
17
  │ └── history/
18
- │ ├── requirements-v1.0.0.md (归档)
19
- │ ├── requirements-v1.1.0.md (归档)
20
- │ ├── edge-cases-v1.0.0.md (归档)
21
- │ └── edge-cases-v1.1.0.md (归档)
18
+ │ ├── requirements-v1.0.0.md (archived)
19
+ │ ├── requirements-v1.1.0.md (archived)
20
+ │ ├── edge-cases-v1.0.0.md (archived)
21
+ │ └── edge-cases-v1.1.0.md (archived)
22
22
  ├── ep/
23
- │ ├── exploration.md # v1.2.0 (当前)
24
- │ ├── architecture.md # v1.2.0 (当前)
25
- │ ├── plan.json # v1.2.0 (当前)
23
+ │ ├── exploration.md # v1.2.0 (current)
24
+ │ ├── architecture.md # v1.2.0 (current)
25
+ │ ├── plan.json # v1.2.0 (current)
26
26
  │ └── history/
27
27
  │ ├── plan-v1.0.0.json
28
28
  │ └── plan-v1.1.0.json
29
29
  ├── cd/
30
- │ ├── implementation.md # v1.2.0 (当前)
31
- │ ├── code-changes.log # NDJSON 完整历史
32
- │ ├── issues.md # 当前未解决问题
30
+ │ ├── implementation.md # v1.2.0 (current)
31
+ │ ├── changes.log # NDJSON complete history
32
+ │ ├── debug-log.ndjson # Debug hypothesis tracking
33
+ │ ├── issues.md # Current unresolved issues
33
34
  │ └── history/
34
35
  │ ├── implementation-v1.0.0.md
35
36
  │ └── implementation-v1.1.0.md
36
37
  └── vas/
37
- ├── validation.md # v1.2.0 (当前)
38
- ├── test-results.json # v1.2.0 (当前)
39
- ├── summary.md # v1.2.0 (当前)
38
+ ├── validation.md # v1.2.0 (current)
39
+ ├── test-results.json # v1.2.0 (current)
40
+ ├── summary.md # v1.2.0 (current)
40
41
  └── history/
41
42
  ├── validation-v1.0.0.md
42
43
  └── test-results-v1.0.0.json
43
44
  ```
44
45
 
45
- ## 文档模板优化
46
+ ## Optimized Document Template
46
47
 
47
- ### Requirements.md (重新创建版本)
48
+ ### Requirements.md (Complete Rewrite Version)
48
49
 
49
50
  ```markdown
50
51
  # Requirements Specification - v1.2.0
@@ -162,7 +163,7 @@ Response time < 500ms for all OAuth flows.
162
163
  **Detailed History**: See `history/` directory and `changes.log`
163
164
  ```
164
165
 
165
- ### Changes.log (NDJSON - 完整历史)
166
+ ### Changes.log (NDJSON - Complete History)
166
167
 
167
168
  ```jsonl
168
169
  {"timestamp":"2026-01-22T10:00:00+08:00","iteration":1,"version":"1.0.0","action":"create","type":"requirement","id":"FR-001","description":"Initial OAuth requirement"}
@@ -173,37 +174,37 @@ Response time < 500ms for all OAuth flows.
173
174
  {"timestamp":"2026-01-23T10:05:00+08:00","iteration":3,"version":"1.2.0","action":"update","type":"requirement","id":"FR-002","description":"Added GitHub provider"}
174
175
  ```
175
176
 
176
- ## 实现流程
177
+ ## Implementation Flow
177
178
 
178
- ### Agent 工作流(RA 为例)
179
+ ### Agent Workflow (RA Example)
179
180
 
180
181
  ```javascript
181
- // ==================== RA Agent 迭代流程 ====================
182
+ // ==================== RA Agent Iteration Flow ====================
182
183
 
183
- // 读取当前状态
184
+ // Read current state
184
185
  const state = JSON.parse(Read(`.workflow/.cycle/${cycleId}.json`))
185
186
  const currentVersion = state.requirements?.version || "0.0.0"
186
187
  const iteration = state.current_iteration
187
188
 
188
- // 如果是迭代(已有旧版本)
189
+ // If iteration (old version exists)
189
190
  if (currentVersion !== "0.0.0") {
190
- // 1. 归档旧版本
191
+ // 1. Archive old version
191
192
  const oldFile = `.workflow/.cycle/${cycleId}.progress/ra/requirements.md`
192
193
  const archiveFile = `.workflow/.cycle/${cycleId}.progress/ra/history/requirements-v${currentVersion}.md`
193
194
 
194
- Copy(oldFile, archiveFile) // 归档
195
+ Copy(oldFile, archiveFile) // Archive
195
196
 
196
- // 2. 读取旧版本(可选,用于理解上下文)
197
+ // 2. Read old version (optional, for context understanding)
197
198
  const oldRequirements = Read(oldFile)
198
199
 
199
- // 3. 读取变更历史
200
+ // 3. Read change history
200
201
  const changesLog = readNDJSON(`.workflow/.cycle/${cycleId}.progress/ra/changes.log`)
201
202
  }
202
203
 
203
- // 4. 生成新版本号
204
+ // 4. Generate new version number
204
205
  const newVersion = bumpVersion(currentVersion, 'minor') // 1.1.0 -> 1.2.0
205
206
 
206
- // 5. 生成新文档(完全重写)
207
+ // 5. Generate new document (complete rewrite)
207
208
  const newRequirements = generateRequirements({
208
209
  version: newVersion,
209
210
  previousVersion: currentVersion,
@@ -211,13 +212,13 @@ const newRequirements = generateRequirements({
211
212
  currentChanges: "Added MFA and GitHub provider",
212
213
  iteration: iteration,
213
214
  taskDescription: state.description,
214
- changesLog: changesLog // 用于理解历史
215
+ changesLog: changesLog // For understanding history
215
216
  })
216
217
 
217
- // 6. 写入新文档(覆盖旧的)
218
+ // 6. Write new document (overwrite old)
218
219
  Write(`.workflow/.cycle/${cycleId}.progress/ra/requirements.md`, newRequirements)
219
220
 
220
- // 7. 追加变更到 changes.log
221
+ // 7. Append change to changes.log
221
222
  appendNDJSON(`.workflow/.cycle/${cycleId}.progress/ra/changes.log`, {
222
223
  timestamp: getUtc8ISOString(),
223
224
  iteration: iteration,
@@ -228,7 +229,7 @@ appendNDJSON(`.workflow/.cycle/${cycleId}.progress/ra/changes.log`, {
228
229
  description: "Added MFA requirement"
229
230
  })
230
231
 
231
- // 8. 更新状态
232
+ // 8. Update state
232
233
  state.requirements = {
233
234
  version: newVersion,
234
235
  output_file: `.workflow/.cycle/${cycleId}.progress/ra/requirements.md`,
@@ -242,25 +243,25 @@ state.requirements = {
242
243
  Write(`.workflow/.cycle/${cycleId}.json`, JSON.stringify(state, null, 2))
243
244
  ```
244
245
 
245
- ## 优势对比
246
+ ## Advantages Comparison
246
247
 
247
- | 方面 | 增量更新 | 重新创建 + 归档 |
248
- |------|----------|----------------|
249
- | **文档简洁性** | ❌ 越来越长 | ✅ 始终简洁 |
250
- | **Agent 解析** | ❌ 需要解析历史 | ✅ 只看当前版本 |
251
- | **维护复杂度** | ❌ 高(版本标记) | ✅ 低(直接重写) |
252
- | **文件大小** | ❌ 膨胀 | ✅ 固定 |
253
- | **历史追溯** | ✅ 在主文档 | ✅ history/ + changes.log |
254
- | **人类可读** | ❌ 需要跳过历史 | ✅ 直接看当前 |
255
- | **Token 使用** | ❌ 多(读取完整历史) | ✅ 少(只读当前) |
248
+ | Aspect | Incremental Update | Complete Rewrite + Archive |
249
+ |--------|-------------------|---------------------------|
250
+ | **Document Conciseness** | ❌ Gets longer | ✅ Always concise |
251
+ | **Agent Parsing** | ❌ Must parse history | ✅ Only read current version |
252
+ | **Maintenance Complexity** | ❌ High (version marking) | ✅ Low (direct rewrite) |
253
+ | **File Size** | ❌ Bloats | ✅ Fixed |
254
+ | **History Tracking** | ✅ In main document | ✅ In history/ + changes.log |
255
+ | **Human Readability** | ❌ Must skip history | ✅ Direct current view |
256
+ | **Token Usage** | ❌ More (read complete history) | ✅ Less (only read current) |
256
257
 
257
- ## 归档策略
258
+ ## Archive Strategy
258
259
 
259
- ### 自动归档触发时机
260
+ ### Auto-Archive Trigger
260
261
 
261
262
  ```javascript
262
263
  function shouldArchive(currentVersion, state) {
263
- // 每次版本更新时归档
264
+ // Archive on each version update
264
265
  return currentVersion !== state.requirements?.version
265
266
  }
266
267
 
@@ -269,29 +270,29 @@ function archiveOldVersion(cycleId, agent, filename, currentVersion) {
269
270
  const archiveDir = `.workflow/.cycle/${cycleId}.progress/${agent}/history`
270
271
  const archiveFile = `${archiveDir}/${filename.replace('.', `-v${currentVersion}.`)}`
271
272
 
272
- // 确保归档目录存在
273
+ // Ensure archive directory exists
273
274
  mkdir -p ${archiveDir}
274
275
 
275
- // 复制(不是移动,保持当前文件直到新版本写入)
276
+ // Copy (not move, keep current file until new version written)
276
277
  Copy(currentFile, archiveFile)
277
278
 
278
279
  console.log(`Archived ${filename} v${currentVersion} to history/`)
279
280
  }
280
281
  ```
281
282
 
282
- ### 清理策略(可选)
283
+ ### Cleanup Strategy (Optional)
283
284
 
284
- 保留最近 N 个版本,删除更老的归档:
285
+ Keep most recent N versions, delete older archives:
285
286
 
286
287
  ```javascript
287
288
  function cleanupArchives(cycleId, agent, keepVersions = 3) {
288
289
  const historyDir = `.workflow/.cycle/${cycleId}.progress/${agent}/history`
289
290
  const archives = listFiles(historyDir)
290
291
 
291
- // 按版本号排序
292
+ // Sort by version number
292
293
  archives.sort((a, b) => compareVersions(extractVersion(a), extractVersion(b)))
293
294
 
294
- // 删除最老的版本(保留最近 N 个)
295
+ // Delete oldest versions (keep most recent N)
295
296
  if (archives.length > keepVersions) {
296
297
  const toDelete = archives.slice(0, archives.length - keepVersions)
297
298
  toDelete.forEach(file => Delete(`${historyDir}/${file}`))
@@ -299,32 +300,32 @@ function cleanupArchives(cycleId, agent, keepVersions = 3) {
299
300
  }
300
301
  ```
301
302
 
302
- ## Changes.log 的重要性
303
+ ## Importance of Changes.log
303
304
 
304
- 虽然主文档重新创建,但 **changes.log (NDJSON) 永久保留完整历史**:
305
+ Although main document is completely rewritten, **changes.log (NDJSON) permanently preserves complete history**:
305
306
 
306
307
  ```bash
307
- # 查看所有变更
308
+ # View all changes
308
309
  cat .workflow/.cycle/cycle-xxx.progress/ra/changes.log | jq .
309
310
 
310
- # 查看某个需求的历史
311
+ # View history of specific requirement
311
312
  cat .workflow/.cycle/cycle-xxx.progress/ra/changes.log | jq 'select(.id=="FR-001")'
312
313
 
313
- # 按迭代查看变更
314
+ # View changes by iteration
314
315
  cat .workflow/.cycle/cycle-xxx.progress/ra/changes.log | jq 'select(.iteration==2)'
315
316
  ```
316
317
 
317
- 这样:
318
- - **主文档**: 清晰简洁(当前状态)
319
- - **Changes.log**: 完整追溯(所有历史)
320
- - **History/**: 快照备份(按需查看)
318
+ This way:
319
+ - **Main Document**: Clear and concise (current state)
320
+ - **Changes.log**: Complete traceability (all history)
321
+ - **History/**: Snapshot backups (view on demand)
321
322
 
322
- ## 推荐实施
323
+ ## Recommended Implementation
323
324
 
324
- 1. ✅ 采用"重新创建"策略
325
- 2. ✅ 主文档只保留"上一版本简要说明"
326
- 3. ✅ 自动归档到 `history/` 目录
327
- 4. ✅ Changes.log (NDJSON) 保留完整历史
328
- 5. ✅ 可选:保留最近 3-5 个历史版本
325
+ 1. ✅ Adopt "Complete Rewrite" strategy
326
+ 2. ✅ Main document only keeps "previous version summary"
327
+ 3. ✅ Auto-archive to `history/` directory
328
+ 4. ✅ Changes.log (NDJSON) preserves complete history
329
+ 5. ✅ Optional: Keep most recent 3-5 historical versions
329
330
 
330
- 这样既保持了文档简洁(Agent 友好),又保留了完整历史(审计友好)。
331
+ This approach keeps documents concise (agent-friendly) while preserving complete history (audit-friendly).
@@ -168,6 +168,10 @@ interface IssueOptions {
168
168
  limit?: number;
169
169
  labels?: string;
170
170
  }
171
+ /**
172
+ * Clear cached project root (for testing)
173
+ */
174
+ export declare function clearProjectRootCache(): void;
171
175
  export declare function readIssues(): Issue[];
172
176
  export declare function writeIssues(issues: Issue[]): void;
173
177
  export declare function readSolutions(issueId: string): Solution[];
@@ -1 +1 @@
1
- {"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/commands/issue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,GAAG,eAAe,GAAG,WAAW,CAAC;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,W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CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAWD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AA4LD,wBAAgB,UAAU,IAAI,KAAK,EAAE,CAWpC;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAMjD;AAiID,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,EAAE,CAWzD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAM3E;AA+FD,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAUxD;AAqQD,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAsE7C;AA84DD,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAwHf"}
@@ -26,6 +26,25 @@ process.stdout.on('error', (err) => {
26
26
  });
27
27
  const ISSUES_DIR = '.workflow/issues';
28
28
  // ============ Storage Layer (JSONL) ============
29
+ /**
30
+ * Cached project root to avoid repeated git command execution
31
+ */
32
+ let cachedProjectRoot = null;
33
+ /**
34
+ * Clear cached project root (for testing)
35
+ */
36
+ export function clearProjectRootCache() {
37
+ cachedProjectRoot = null;
38
+ }
39
+ /**
40
+ * Debug logging helper (enabled via CCW_DEBUG=true)
41
+ */
42
+ const DEBUG = process.env.CCW_DEBUG === 'true';
43
+ function debugLog(msg) {
44
+ if (DEBUG) {
45
+ console.log(`[ccw:worktree] ${msg}`);
46
+ }
47
+ }
29
48
  /**
30
49
  * Normalize path for comparison (handles Windows case sensitivity)
31
50
  */
@@ -63,7 +82,29 @@ function resolveMainRepoFromGitFile(gitFilePath) {
63
82
  * This ensures .workflow/issues/ is always accessed from the main repo.
64
83
  */
65
84
  function getProjectRoot() {
66
- // First, try to detect if we're in a git worktree using git commands
85
+ // Return cached result if available
86
+ if (cachedProjectRoot) {
87
+ debugLog(`Using cached project root: ${cachedProjectRoot}`);
88
+ return cachedProjectRoot;
89
+ }
90
+ debugLog(`Detecting project root from cwd: ${process.cwd()}`);
91
+ // Priority 1: Check CCW_MAIN_REPO environment variable
92
+ const envMainRepo = process.env.CCW_MAIN_REPO;
93
+ if (envMainRepo) {
94
+ debugLog(`Found CCW_MAIN_REPO env: ${envMainRepo}`);
95
+ const hasWorkflow = existsSync(join(envMainRepo, '.workflow'));
96
+ const hasGit = existsSync(join(envMainRepo, '.git'));
97
+ if (hasWorkflow || hasGit) {
98
+ debugLog(`CCW_MAIN_REPO validated (workflow=${hasWorkflow}, git=${hasGit})`);
99
+ cachedProjectRoot = envMainRepo;
100
+ return envMainRepo;
101
+ }
102
+ else {
103
+ console.warn('[ccw] CCW_MAIN_REPO is set but path is invalid (no .workflow or .git)');
104
+ console.warn(`[ccw] Path: ${envMainRepo}`);
105
+ }
106
+ }
107
+ // Priority 2: Try to detect if we're in a git worktree using git commands
67
108
  try {
68
109
  // Get the common git directory (points to main repo's .git)
69
110
  const gitCommonDir = execSync('git rev-parse --git-common-dir', {
@@ -77,6 +118,8 @@ function getProjectRoot() {
77
118
  stdio: ['pipe', 'pipe', 'pipe'],
78
119
  timeout: EXEC_TIMEOUTS.GIT_QUICK,
79
120
  }).trim();
121
+ debugLog(`Git common dir: ${gitCommonDir}`);
122
+ debugLog(`Git dir: ${gitDir}`);
80
123
  // Normalize paths for comparison (Windows case insensitive)
81
124
  const normalizedCommon = normalizePath(gitCommonDir);
82
125
  const normalizedGit = normalizePath(gitDir);
@@ -86,8 +129,11 @@ function getProjectRoot() {
86
129
  const absoluteCommonDir = resolve(process.cwd(), gitCommonDir);
87
130
  // .git directory's parent is the repo root
88
131
  const mainRepoRoot = resolve(absoluteCommonDir, '..');
132
+ debugLog(`Detected worktree, main repo: ${mainRepoRoot}`);
89
133
  // Verify .workflow or .git exists in main repo
90
134
  if (existsSync(join(mainRepoRoot, '.workflow')) || existsSync(join(mainRepoRoot, '.git'))) {
135
+ debugLog(`Main repo validated, returning: ${mainRepoRoot}`);
136
+ cachedProjectRoot = mainRepoRoot;
91
137
  return mainRepoRoot;
92
138
  }
93
139
  }
@@ -96,9 +142,10 @@ function getProjectRoot() {
96
142
  if (isExecTimeoutError(err)) {
97
143
  console.warn(`[issue] git rev-parse timed out after ${EXEC_TIMEOUTS.GIT_QUICK}ms; falling back to filesystem detection`);
98
144
  }
145
+ debugLog(`Git command failed, falling back to filesystem detection`);
99
146
  // Git command failed - fall through to manual detection
100
147
  }
101
- // Standard detection with worktree file support: walk up to find .workflow or .git
148
+ // Priority 3: Standard detection with worktree file support: walk up to find .workflow or .git
102
149
  let dir = process.cwd();
103
150
  while (dir !== resolve(dir, '..')) {
104
151
  const gitPath = join(dir, '.git');
@@ -109,22 +156,42 @@ function getProjectRoot() {
109
156
  if (gitStat.isFile()) {
110
157
  // .git is a file - this is a worktree, try to resolve main repo
111
158
  const mainRepo = resolveMainRepoFromGitFile(gitPath);
112
- if (mainRepo && existsSync(join(mainRepo, '.workflow'))) {
113
- return mainRepo;
159
+ debugLog(`Parsed .git file, main repo: ${mainRepo}`);
160
+ if (mainRepo) {
161
+ // Verify main repo has .git directory (always true for main repo)
162
+ // Don't require .workflow - it may not exist yet in a new repo
163
+ const hasGit = existsSync(join(mainRepo, '.git'));
164
+ const hasWorkflow = existsSync(join(mainRepo, '.workflow'));
165
+ if (hasGit || hasWorkflow) {
166
+ if (!hasWorkflow) {
167
+ console.warn('[ccw] Worktree detected but main repo has no .workflow directory');
168
+ console.warn(`[ccw] Main repo: ${mainRepo}`);
169
+ console.warn('[ccw] Issue commands may fail until .workflow is created');
170
+ console.warn('[ccw] Set CCW_MAIN_REPO environment variable to override detection');
171
+ }
172
+ debugLog(`Main repo validated via .git file (git=${hasGit}, workflow=${hasWorkflow})`);
173
+ cachedProjectRoot = mainRepo;
174
+ return mainRepo;
175
+ }
114
176
  }
115
- // If main repo doesn't have .workflow, fall back to current worktree
116
177
  }
117
178
  }
118
179
  catch {
119
180
  // stat failed, continue with normal logic
181
+ debugLog(`Failed to stat ${gitPath}, continuing`);
120
182
  }
121
183
  }
122
184
  if (existsSync(join(dir, '.workflow')) || existsSync(gitPath)) {
185
+ debugLog(`Found project root at: ${dir}`);
186
+ cachedProjectRoot = dir;
123
187
  return dir;
124
188
  }
125
189
  dir = resolve(dir, '..');
126
190
  }
127
- return process.cwd();
191
+ debugLog(`No project root found, using cwd: ${process.cwd()}`);
192
+ const fallback = process.cwd();
193
+ cachedProjectRoot = fallback;
194
+ return fallback;
128
195
  }
129
196
  function getIssuesDir() {
130
197
  return join(getProjectRoot(), ISSUES_DIR);