kenaz 0.3.18 → 0.3.19

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 (308) hide show
  1. package/core/.claude/commands/agent-worker.md +1 -1
  2. package/core/.claude/commands/architect.md +1 -2
  3. package/core/.claude/commands/spec.md +1 -1
  4. package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
  5. package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
  6. package/core/.claude/skills/architect_agent/SKILL.md +11 -92
  7. package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
  8. package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
  9. package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
  10. package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
  11. package/core/.claude/skills/designer/SKILL.md +3 -6
  12. package/core/.claude/skills/dev_agent/SKILL.md +30 -491
  13. package/core/.claude/skills/developer/SKILL.md +3 -6
  14. package/core/.claude/skills/feature_agent/SKILL.md +3 -17
  15. package/core/.claude/skills/product_manager/SKILL.md +29 -1064
  16. package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
  17. package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
  18. package/core/.claude/skills/sre_agent/SKILL.md +3 -6
  19. package/core/.collaboration/README.md +2 -3
  20. package/core/.collaboration/core/task-api.js +5 -138
  21. package/core/.collaboration/docs/CLI.md +0 -2
  22. package/core/.failure/INDEX.yaml +6 -40
  23. package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
  24. package/core/.failure/tools/README.md +9 -227
  25. package/core/.formation/bifrost/launch.js +1 -6
  26. package/core/.formation/bifrost/launch.test.js +1 -1
  27. package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
  28. package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
  29. package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
  30. package/core/.formation/tools/dispatch.js +1 -1
  31. package/core/.formation/tools/loader.js +17 -140
  32. package/core/.formation/tools/post-complete.js +0 -31
  33. package/core/.rule/INDEX.yaml +0 -18
  34. package/core/.rule/general/agent-workflow.yaml +14 -164
  35. package/core/.rule/general/project-self-containment.yaml +8 -19
  36. package/core/.rule/general/rust-verify-target.yaml +6 -5
  37. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  38. package/core/.specialist/Amelia/capability.yaml +12 -12
  39. package/core/.specialist/Amelia/workflow.yaml +2 -2
  40. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  41. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  42. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  43. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  44. package/core/.specialist/Ansuz/core.yaml +6 -108
  45. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  46. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  47. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  48. package/core/.specialist/Ansuz/rule.yaml +0 -1
  49. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  50. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  51. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  52. package/core/.specialist/tools/prompt-files.test.js +1 -0
  53. package/core/.specialist/tools/task-bridge.js +1 -66
  54. package/core/.system/README.md +11 -552
  55. package/core/.system/collaboration/README.md +10 -174
  56. package/core/CLAUDE.md +1 -6
  57. package/core/KENAZ_CORE_VERSION +1 -1
  58. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  59. package/core/dev/scripts/run-rust-tests.js +9 -45
  60. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  61. package/core/dev/scripts/verify-target-dir.js +6 -6
  62. package/core/plugins/kenaz/INVENTORY.md +8 -8
  63. package/core/plugins/kenaz/commands/architect.md +1 -2
  64. package/core/plugins/kenaz/commands/spec.md +1 -1
  65. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  66. package/core/plugins/kenaz/guidance.md +1 -1
  67. package/core/plugins/kenaz/scripts/sync.js +1 -1
  68. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  69. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  70. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  71. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  72. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  73. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  74. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  75. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  76. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  77. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  78. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  79. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  80. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  81. package/package.json +6 -6
  82. package/core/.claude/commands/archive.md +0 -24
  83. package/core/.claude/commands/init.md +0 -112
  84. package/core/.claude/commands/legacy_dev.md +0 -18
  85. package/core/.claude/commands/product-review.md +0 -131
  86. package/core/.claude/commands/strategy.md +0 -141
  87. package/core/.claude/commands/sunny.md +0 -1
  88. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  89. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  90. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  91. package/core/.claude/hooks/_substrate-paths.js +0 -95
  92. package/core/.claude/hooks/context-check.js +0 -51
  93. package/core/.claude/hooks/fatigue-check.js +0 -52
  94. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  95. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  96. package/core/.claude/hooks/handoff-staleness.js +0 -197
  97. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  98. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  99. package/core/.claude/hooks/lease-release.js +0 -119
  100. package/core/.claude/hooks/lease-touch.js +0 -96
  101. package/core/.claude/hooks/reflex-feedback.js +0 -5
  102. package/core/.claude/hooks/session-init.ps1 +0 -49
  103. package/core/.claude/hooks/sound-event.js +0 -70
  104. package/core/.claude/hooks/sound-event.sh +0 -37
  105. package/core/.claude/hooks/stream-delta.js +0 -169
  106. package/core/.claude/no-hooks.settings.json +0 -3
  107. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  108. package/core/.claude/skills/sunny/SKILL.md +0 -74
  109. package/core/.collaboration/cli/commands/assign.js +0 -39
  110. package/core/.collaboration/cli/commands/claim.js +0 -33
  111. package/core/.collaboration/cli/commands/complete.js +0 -44
  112. package/core/.collaboration/cli/commands/create.js +0 -110
  113. package/core/.collaboration/cli/commands/get.js +0 -83
  114. package/core/.collaboration/cli/commands/index.js +0 -52
  115. package/core/.collaboration/cli/commands/list.js +0 -51
  116. package/core/.collaboration/cli/commands/lock.js +0 -45
  117. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  118. package/core/.collaboration/cli/commands/search.js +0 -61
  119. package/core/.collaboration/cli/commands/stats.js +0 -61
  120. package/core/.collaboration/cli/commands/transfer.js +0 -41
  121. package/core/.collaboration/cli/commands/unlock.js +0 -48
  122. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  123. package/core/.collaboration/cli/formatters/index.js +0 -7
  124. package/core/.collaboration/cli/task-cli.js +0 -46
  125. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  126. package/core/.collaboration/cli/utils/git-user.js +0 -25
  127. package/core/.collaboration/cli/utils/index.js +0 -9
  128. package/core/.collaboration/cli/utils/output.js +0 -10
  129. package/core/.collaboration/config/default.yaml +0 -189
  130. package/core/.collaboration/core/conflict-resolver.js +0 -461
  131. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  132. package/core/.collaboration/core/migrate-legacy.js +0 -260
  133. package/core/.collaboration/docs/API.md +0 -787
  134. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  135. package/core/.collaboration/docs/FAQ.md +0 -695
  136. package/core/.collaboration/docs/MIGRATION.md +0 -804
  137. package/core/.collaboration/docs/examples/README.md +0 -320
  138. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  139. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  140. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  141. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  142. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  143. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  144. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  145. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  146. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  147. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  148. package/core/.failure/pipeline/README.md +0 -95
  149. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  150. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  151. package/core/.failure/tools/check_failures.ps1 +0 -387
  152. package/core/.failure/tools/log_failure.ps1 +0 -474
  153. package/core/.formation/.episode-input.json +0 -10
  154. package/core/.formation/.merge-lock +0 -1
  155. package/core/.formation/lead.yaml +0 -118
  156. package/core/.formation/legacy.bak/designer.yaml +0 -57
  157. package/core/.formation/legacy.bak/pm.yaml +0 -57
  158. package/core/.formation/legacy.bak/qa.yaml +0 -57
  159. package/core/.formation/legacy.bak/review.yaml +0 -62
  160. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  161. package/core/.formation/legacy.bak/sre.yaml +0 -57
  162. package/core/.formation/role-map.yaml +0 -274
  163. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  164. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  165. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  166. package/core/.formation/roles/backend/role.yaml +0 -93
  167. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  168. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  169. package/core/.formation/roles/designer/role.yaml +0 -66
  170. package/core/.formation/roles/developer/role.yaml +0 -75
  171. package/core/.formation/roles/frontend/role.yaml +0 -134
  172. package/core/.formation/roles/incident_response/role.yaml +0 -89
  173. package/core/.formation/roles/qa/role.yaml +0 -89
  174. package/core/.formation/roles/security/role.yaml +0 -87
  175. package/core/.formation/roles/sre/role.yaml +0 -66
  176. package/core/.formation/skills/coordinator.yaml +0 -52
  177. package/core/.formation/solo/diagnosis.yaml +0 -78
  178. package/core/.formation/solo/strategy.yaml +0 -121
  179. package/core/.formation/tests/hello.txt +0 -2
  180. package/core/.formation/tools/coordinator.js +0 -350
  181. package/core/.formation/tools/jev-correction.js +0 -214
  182. package/core/.formation/tools/jev-correction.test.js +0 -178
  183. package/core/.formation/tools/log-reader.js +0 -232
  184. package/core/.formation/tools/revert-daemon-state.js +0 -162
  185. package/core/.formation/tools/test-drift.js +0 -148
  186. package/core/.formation/unit/heimdall.yaml +0 -96
  187. package/core/.formation/unit/plan.yaml +0 -67
  188. package/core/.formation/unit/think.yaml +0 -58
  189. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  190. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  191. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  192. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  193. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  194. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  195. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  196. package/core/.kenaz/runes_TASK_1428.json +0 -57
  197. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  198. package/core/.kenaz/tmp_props.json +0 -1
  199. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  200. package/core/.rule/MECHANIZED.md +0 -61
  201. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  202. package/core/.rule/general/pipeline.yaml +0 -246
  203. package/core/.rule/general/sunny-access-control.yaml +0 -60
  204. package/core/.rule/general/system-invariants.yaml +0 -231
  205. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  206. package/core/.rule/pipeline/auto-update.yaml +0 -282
  207. package/core/.rule/pipeline/task-execution.yaml +0 -365
  208. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  209. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  210. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  211. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  212. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  213. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  214. package/core/.specialist/tools/jev-optional-context.js +0 -107
  215. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  216. package/core/.specialist/tools/memory-action-log.js +0 -839
  217. package/core/.specialist/tools/phase-gate.js +0 -3534
  218. package/core/.specialist/tools/phase-gate.test.js +0 -85
  219. package/core/.specialist/tools/precompute-runner.js +0 -444
  220. package/core/.specialist/tools/rule-engine.js +0 -621
  221. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  222. package/core/.synapse/memory-shared.json.sync +0 -1
  223. package/core/.system/agent-skills/README.md +0 -724
  224. package/core/.system/cli-tools/README.md +0 -724
  225. package/core/.system/cortex/MODULES.md +0 -1046
  226. package/core/.system/dashboard/FRONTEND.md +0 -812
  227. package/core/.system/dashboard/README.md +0 -737
  228. package/core/.system/failure/README.md +0 -723
  229. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  230. package/core/.system/formation/POST_COMPLETE.md +0 -602
  231. package/core/.system/formation/README.md +0 -1094
  232. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  233. package/core/.system/kenaz/README.md +0 -787
  234. package/core/.system/memory/README.md +0 -719
  235. package/core/.system/pipeline/README.md +0 -712
  236. package/core/.system/rule/README.md +0 -794
  237. package/core/.system/sunny/README.md +0 -476
  238. package/core/.system/sunny/RULES.json +0 -89
  239. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  240. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  241. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  242. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  243. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  244. package/core/.system/sunny/teammates/README.md +0 -107
  245. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  246. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  247. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  248. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  249. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  250. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  251. package/core/.system/sunny/tools.json +0 -101
  252. package/core/dev/scripts/cleanup-queue.js +0 -184
  253. package/core/dev/scripts/cleanup_queue.js +0 -86
  254. package/core/dev/scripts/legacy/README.md +0 -39
  255. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  256. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  257. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  258. package/core/dev/scripts/matrix/README.md +0 -310
  259. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  260. package/core/dev/scripts/matrix/package.json +0 -55
  261. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  262. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  263. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  264. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  265. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  266. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  267. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  268. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  269. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  270. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  271. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  272. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  273. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  274. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  275. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  276. package/core/dev/scripts/matrix/src/index.ts +0 -62
  277. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  278. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  279. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  280. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  281. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  282. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  283. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  284. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  285. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  286. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  287. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  288. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  289. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  290. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  291. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  292. package/core/dev/scripts/matrix/types/index.js +0 -8
  293. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  294. package/core/dev/scripts/matrix/types/index.ts +0 -124
  295. package/core/dev/scripts/memory-usage-report.js +0 -152
  296. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  297. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  298. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  299. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  300. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  301. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  302. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  303. package/core/dev/scripts/validate_pipeline.js +0 -197
  304. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  305. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  306. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  307. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  308. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,787 +0,0 @@
1
- # .collaboration API 參考文檔
2
-
3
- 完整的 JavaScript API 文檔,用於程式化操作 .collaboration 任務系統。
4
-
5
- ## 目錄
6
-
7
- - [安裝與設置](#安裝與設置)
8
- - [TaskAPI 類別](#taskapi-類別)
9
- - [IndexManager 類別](#indexmanager-類別)
10
- - [LockManager 類別](#lockmanager-類別)
11
- - [IDGenerator 模組](#idgenerator-模組)
12
- - [資料結構](#資料結構)
13
- - [錯誤處理](#錯誤處理)
14
-
15
- ---
16
-
17
- ## 安裝與設置
18
-
19
- ### 引入模組
20
-
21
- ```javascript
22
- const { TaskAPI } = require('./.collaboration/core/task-api.js');
23
- const { IndexManager } = require('./.collaboration/core/index-manager.js');
24
- const { LockManager } = require('./.collaboration/core/lock-manager.js');
25
- const { generateTaskID, validateTaskID } = require('./.collaboration/core/id-generator.js');
26
- ```
27
-
28
- ### 初始化 API
29
-
30
- ```javascript
31
- // 使用預設配置
32
- const api = new TaskAPI();
33
-
34
- // 自訂配置
35
- const api = new TaskAPI({
36
- newSystemDir: path.join(__dirname, 'custom/tasks/db'),
37
- oldQueueFile: path.join(__dirname, 'custom/TASK_QUEUE.json'),
38
- completedFile: path.join(__dirname, 'custom/COMPLETED_TASKS.json')
39
- });
40
- ```
41
-
42
- ---
43
-
44
- ## TaskAPI 類別
45
-
46
- 統一任務查詢和管理 API,整合新舊任務系統。
47
-
48
- ### 建構函數
49
-
50
- ```javascript
51
- new TaskAPI(config?: Object)
52
- ```
53
-
54
- **參數**:
55
- - `config.newSystemDir` (string): 新系統任務目錄,預設 `.collaboration/tasks/db`
56
- - `config.oldQueueFile` (string): 舊系統佇列文件,預設 `dev/pipeline/TASK_QUEUE.json`
57
- - `config.completedFile` (string): 已完成任務文件,預設 `.memory/COMPLETED_TASKS.json`
58
-
59
- ### 方法
60
-
61
- #### `getAllTasks(options)`
62
-
63
- 取得所有任務,合併新舊系統資料。
64
-
65
- **參數**:
66
- - `options.includeCompleted` (boolean): 是否包含已完成任務,預設 `true`
67
-
68
- **返回**: `Promise<Object>`
69
-
70
- ```javascript
71
- {
72
- version: "2.0.0",
73
- tasks: [...], // 所有任務
74
- statistics: { // 統計資料
75
- total: 10,
76
- pending: 5,
77
- in_progress: 3,
78
- completed: 2,
79
- blocked: 0
80
- },
81
- metadata: {
82
- last_updated: "2026-02-11T10:00:00Z",
83
- sources: {
84
- new: 8, // 新系統任務數
85
- old: 2, // 舊系統任務數
86
- completed: 0 // 已完成任務數
87
- }
88
- }
89
- }
90
- ```
91
-
92
- **範例**:
93
-
94
- ```javascript
95
- // 取得所有任務
96
- const allData = await api.getAllTasks();
97
- console.log(`總任務數: ${allData.statistics.total}`);
98
- console.log(`Pending: ${allData.statistics.pending}`);
99
-
100
- // 只取得未完成任務
101
- const activeTasks = await api.getAllTasks({ includeCompleted: false });
102
- ```
103
-
104
- ---
105
-
106
- #### `getTask(taskId)`
107
-
108
- 取得單個任務詳情。
109
-
110
- **參數**:
111
- - `taskId` (string): 任務 ID(如 `TASK_5KPEES80MMXH`)
112
-
113
- **返回**: `Promise<Object|null>`
114
-
115
- **拋出**:
116
- - `Error`: 如果任務 ID 格式無效
117
-
118
- **範例**:
119
-
120
- ```javascript
121
- const task = await api.getTask('TASK_5KPEES80MMXH');
122
- if (task) {
123
- console.log(`任務標題: ${task.title}`);
124
- console.log(`狀態: ${task.status}`);
125
- console.log(`來源: ${task._source}`); // 'new' | 'old' | 'completed'
126
- } else {
127
- console.log('任務不存在');
128
- }
129
- ```
130
-
131
- ---
132
-
133
- #### `createTask(taskData)`
134
-
135
- 建立新任務。
136
-
137
- **參數**:
138
- - `taskData.title` (string, required): 任務標題
139
- - `taskData.description` (string): 任務描述
140
- - `taskData.status` (string): 狀態,預設 `pending`
141
- - `taskData.priority` (string): 優先級,預設 `P2`
142
- - `taskData.created_by` (Object): 建立者資訊(可選,自動從 Git 取得)
143
- - `taskData.assigned_to` (Object): 分配對象
144
- - `taskData.collaborators` (Array): 協作者列表
145
-
146
- **返回**: `Promise<Object>` - 建立的任務
147
-
148
- **範例**:
149
-
150
- ```javascript
151
- // 簡單建立
152
- const task = await api.createTask({
153
- title: '實作登入功能',
154
- priority: 'P1'
155
- });
156
-
157
- // 完整建立
158
- const task = await api.createTask({
159
- title: '實作登入功能',
160
- description: '建立登入頁面和認證 API',
161
- priority: 'P1',
162
- status: 'pending',
163
- assigned_to: {
164
- name: '李四',
165
- git_user: 'lisi',
166
- timestamp: new Date().toISOString()
167
- },
168
- collaborators: [
169
- { name: '王五', git_user: 'wangwu' }
170
- ]
171
- });
172
-
173
- console.log(`任務已建立: ${task.id}`);
174
- console.log(`檔案路徑: ${task._file_path}`);
175
- ```
176
-
177
- ---
178
-
179
- #### `updateTask(taskId, updates)`
180
-
181
- 更新任務。
182
-
183
- **參數**:
184
- - `taskId` (string): 任務 ID
185
- - `updates` (Object): 更新資料(任何任務欄位)
186
-
187
- **返回**: `Promise<Object>` - 更新後的任務
188
-
189
- **拋出**:
190
- - `Error`: 任務不存在
191
- - `Error`: 任務被其他用戶鎖定
192
- - `Error`: 無法更新舊系統任務
193
-
194
- **範例**:
195
-
196
- ```javascript
197
- // 更新狀態
198
- const task = await api.updateTask('TASK_5KPEES80MMXH', {
199
- status: 'in_progress'
200
- });
201
-
202
- // 更新多個欄位
203
- const task = await api.updateTask('TASK_5KPEES80MMXH', {
204
- status: 'in_progress',
205
- priority: 'P0',
206
- description: '更新後的描述'
207
- });
208
-
209
- console.log(`版本號: ${task._version}`); // 自動遞增
210
- ```
211
-
212
- ---
213
-
214
- #### `deleteTask(taskId)`
215
-
216
- 刪除任務。
217
-
218
- **參數**:
219
- - `taskId` (string): 任務 ID
220
-
221
- **返回**: `Promise<boolean>` - 是否成功刪除
222
-
223
- **拋出**:
224
- - `Error`: 無法刪除舊系統任務
225
-
226
- **範例**:
227
-
228
- ```javascript
229
- const success = await api.deleteTask('TASK_5KPEES80MMXH');
230
- if (success) {
231
- console.log('任務已刪除');
232
- }
233
- ```
234
-
235
- ---
236
-
237
- #### `claimTask(taskId, gitUser?)`
238
-
239
- 認領任務(分配給自己或指定用戶)。
240
-
241
- **參數**:
242
- - `taskId` (string): 任務 ID
243
- - `gitUser` (string, optional): Git 用戶名(預設為當前用戶)
244
-
245
- **返回**: `Promise<Object>` - 更新後的任務
246
-
247
- **範例**:
248
-
249
- ```javascript
250
- // 認領給自己
251
- const task = await api.claimTask('TASK_5KPEES80MMXH');
252
- console.log(`已認領,分配給: ${task.assigned_to.git_user}`);
253
-
254
- // 認領並分配給他人
255
- const task = await api.claimTask('TASK_5KPEES80MMXH', 'lisi');
256
- ```
257
-
258
- ---
259
-
260
- #### `completeTask(taskId)`
261
-
262
- 標記任務為完成。
263
-
264
- **參數**:
265
- - `taskId` (string): 任務 ID
266
-
267
- **返回**: `Promise<Object>` - 更新後的任務
268
-
269
- **範例**:
270
-
271
- ```javascript
272
- const task = await api.completeTask('TASK_5KPEES80MMXH');
273
- console.log(`任務已完成,執行者: ${task.executed_by.name}`);
274
- console.log(`完成時間: ${task.executed_by.timestamp}`);
275
- ```
276
-
277
- ---
278
-
279
- #### `queryTasks(query)`
280
-
281
- 查詢任務(按條件過濾)。
282
-
283
- **參數**:
284
- - `query.status` (string): 按狀態過濾
285
- - `query.assigned_to` (string): 按分配對象過濾(git_user)
286
- - `query.priority` (string): 按優先級過濾
287
- - `query.created_by` (string): 按建立者過濾(git_user)
288
-
289
- **返回**: `Promise<Array>` - 符合條件的任務列表
290
-
291
- **範例**:
292
-
293
- ```javascript
294
- // 查詢所有 pending 任務
295
- const pending = await api.queryTasks({ status: 'pending' });
296
-
297
- // 查詢我的任務
298
- const myTasks = await api.queryTasks({ assigned_to: 'zhangsan' });
299
-
300
- // 查詢 P0 任務
301
- const urgent = await api.queryTasks({ priority: 'P0' });
302
-
303
- // 組合查詢
304
- const myUrgent = await api.queryTasks({
305
- assigned_to: 'zhangsan',
306
- priority: 'P0',
307
- status: 'in_progress'
308
- });
309
- ```
310
-
311
- ---
312
-
313
- ## IndexManager 類別
314
-
315
- 管理 JSONL 索引系統,提供高效的任務分類查詢。
316
-
317
- ### 方法
318
-
319
- #### `updateTask(taskId, task)`
320
-
321
- 更新任務索引。
322
-
323
- **參數**:
324
- - `taskId` (string): 任務 ID
325
- - `task` (Object): 任務資料
326
-
327
- **返回**: `Promise<void>`
328
-
329
- **範例**:
330
-
331
- ```javascript
332
- const indexMgr = new IndexManager();
333
- await indexMgr.updateTask('TASK_5KPEES80MMXH', task);
334
- ```
335
-
336
- ---
337
-
338
- #### `removeTask(taskId, task)`
339
-
340
- 從索引中移除任務。
341
-
342
- **參數**:
343
- - `taskId` (string): 任務 ID
344
- - `task` (Object): 任務資料(用於確定索引位置)
345
-
346
- **返回**: `Promise<void>`
347
-
348
- ---
349
-
350
- #### `rebuildAll()`
351
-
352
- 重建所有索引。
353
-
354
- **返回**: `Promise<Object>` - 統計資料
355
-
356
- **範例**:
357
-
358
- ```javascript
359
- const stats = await indexMgr.rebuildAll();
360
- console.log(`總任務數: ${stats.totalTasks}`);
361
- console.log(`狀態分類: ${stats.byStatus}`);
362
- console.log(`用戶分類: ${stats.byUser}`);
363
- console.log(`優先級分類: ${stats.byPriority}`);
364
- ```
365
-
366
- ---
367
-
368
- #### `getByStatus(status)`
369
-
370
- 按狀態查詢任務 ID。
371
-
372
- **參數**:
373
- - `status` (string): 狀態值(`pending`, `in_progress`, `completed`, `blocked`)
374
-
375
- **返回**: `Promise<Array<string>>` - 任務 ID 列表
376
-
377
- **範例**:
378
-
379
- ```javascript
380
- const pendingIds = await indexMgr.getByStatus('pending');
381
- console.log(`有 ${pendingIds.length} 個 pending 任務`);
382
- ```
383
-
384
- ---
385
-
386
- #### `getByUser(gitUser)`
387
-
388
- 按用戶查詢任務 ID。
389
-
390
- **參數**:
391
- - `gitUser` (string): Git 用戶名
392
-
393
- **返回**: `Promise<Array<string>>` - 任務 ID 列表
394
-
395
- ---
396
-
397
- #### `getByPriority(priority)`
398
-
399
- 按優先級查詢任務 ID。
400
-
401
- **參數**:
402
- - `priority` (string): 優先級(`P0`, `P1`, `P2`, `P3`)
403
-
404
- **返回**: `Promise<Array<string>>` - 任務 ID 列表
405
-
406
- ---
407
-
408
- ## LockManager 類別
409
-
410
- 管理任務鎖定機制,避免並發編輯衝突。
411
-
412
- ### 方法
413
-
414
- #### `acquireLock(taskId, gitUser, ttlMinutes?)`
415
-
416
- 鎖定任務。
417
-
418
- **參數**:
419
- - `taskId` (string): 任務 ID
420
- - `gitUser` (string): Git 用戶名
421
- - `ttlMinutes` (number): 鎖定時長(分鐘),預設 60
422
-
423
- **返回**: `Promise<Object>` - 鎖定資訊
424
-
425
- **拋出**:
426
- - `Error`: 任務已被其他用戶鎖定
427
-
428
- **範例**:
429
-
430
- ```javascript
431
- const lockMgr = new LockManager();
432
-
433
- try {
434
- const lock = await lockMgr.acquireLock('TASK_5KPEES80MMXH', 'zhangsan', 30);
435
- console.log(`鎖定成功,過期時間: ${lock.expires_at}`);
436
- } catch (error) {
437
- console.error(`鎖定失敗: ${error.message}`);
438
- }
439
- ```
440
-
441
- ---
442
-
443
- #### `releaseLock(taskId, gitUser)`
444
-
445
- 釋放鎖定。
446
-
447
- **參數**:
448
- - `taskId` (string): 任務 ID
449
- - `gitUser` (string): Git 用戶名
450
-
451
- **返回**: `Promise<boolean>` - 是否成功釋放
452
-
453
- **範例**:
454
-
455
- ```javascript
456
- const success = await lockMgr.releaseLock('TASK_5KPEES80MMXH', 'zhangsan');
457
- if (success) {
458
- console.log('鎖定已釋放');
459
- }
460
- ```
461
-
462
- ---
463
-
464
- #### `isLocked(taskId)`
465
-
466
- 檢查任務是否被鎖定。
467
-
468
- **參數**:
469
- - `taskId` (string): 任務 ID
470
-
471
- **返回**: `Promise<boolean>`
472
-
473
- ---
474
-
475
- #### `getLockInfo(taskId)`
476
-
477
- 取得鎖定資訊。
478
-
479
- **參數**:
480
- - `taskId` (string): 任務 ID
481
-
482
- **返回**: `Promise<Object|null>` - 鎖定資訊或 null
483
-
484
- **範例**:
485
-
486
- ```javascript
487
- const lockInfo = await lockMgr.getLockInfo('TASK_5KPEES80MMXH');
488
- if (lockInfo) {
489
- console.log(`鎖定者: ${lockInfo.locked_by}`);
490
- console.log(`鎖定時間: ${lockInfo.locked_at}`);
491
- console.log(`過期時間: ${lockInfo.expires_at}`);
492
- }
493
- ```
494
-
495
- ---
496
-
497
- #### `cleanExpiredLocks()`
498
-
499
- 清理過期鎖定。
500
-
501
- **返回**: `Promise<number>` - 清理的鎖定數量
502
-
503
- ---
504
-
505
- ## IDGenerator 模組
506
-
507
- 生成唯一的任務 ID(ULID 格式)。
508
-
509
- ### 函數
510
-
511
- #### `generateTaskID()`
512
-
513
- 生成新的任務 ID。
514
-
515
- **返回**: `string` - 格式為 `TASK_XXXXXXXXXXXX`(15 字元)
516
-
517
- **特性**:
518
- - 時間部分(6 字元):可排序,精確到毫秒
519
- - 隨機部分(4 字元):確保唯一性
520
- - 編碼:Crockford Base32(避免歧義字元)
521
-
522
- **範例**:
523
-
524
- ```javascript
525
- const { generateTaskID } = require('./.collaboration/core/id-generator.js');
526
-
527
- const taskId = generateTaskID();
528
- console.log(taskId); // 輸出: TASK_5KPEES80MMXH
529
- ```
530
-
531
- ---
532
-
533
- #### `validateTaskID(taskId)`
534
-
535
- 驗證任務 ID 格式。
536
-
537
- **參數**:
538
- - `taskId` (string): 任務 ID
539
-
540
- **返回**: `boolean`
541
-
542
- **範例**:
543
-
544
- ```javascript
545
- const { validateTaskID } = require('./.collaboration/core/id-generator.js');
546
-
547
- console.log(validateTaskID('TASK_5KPEES80MMXH')); // true
548
- console.log(validateTaskID('TASK_123')); // false
549
- console.log(validateTaskID('invalid')); // false
550
- ```
551
-
552
- ---
553
-
554
- ## 資料結構
555
-
556
- ### 任務物件 (Task)
557
-
558
- ```typescript
559
- interface Task {
560
- // 核心欄位
561
- id: string; // 任務 ID(TASK_XXXXXXXXXXXX)
562
- title: string; // 標題
563
- description: string; // 描述
564
- status: 'pending' | 'in_progress' | 'completed' | 'blocked';
565
- priority: 'P0' | 'P1' | 'P2' | 'P3';
566
-
567
- // 用戶追蹤
568
- created_by: UserInfo; // 建立者
569
- assigned_to: UserInfo | null; // 分配對象
570
- last_modified_by: UserInfo; // 最後修改者
571
- collaborators: UserInfo[]; // 協作者列表
572
- executed_by: UserInfo | null; // 執行者(完成時填入)
573
-
574
- // 元數據
575
- _version: number; // 版本號(樂觀鎖定)
576
- _file_path?: string; // 檔案路徑
577
- _source?: 'new' | 'old' | 'completed'; // 資料來源
578
-
579
- // 可選欄位
580
- estimated_hours?: number; // 預估工時
581
- acceptance_criteria?: string[]; // 驗收標準
582
- scope?: string[]; // 影響範圍
583
- dependencies?: string[]; // 依賴任務
584
- tags?: string[]; // 標籤
585
- }
586
- ```
587
-
588
- ---
589
-
590
- ### 用戶資訊 (UserInfo)
591
-
592
- ```typescript
593
- interface UserInfo {
594
- name: string; // 顯示名稱
595
- git_user: string; // Git 用戶名(從 email 取得)
596
- email?: string; // Email
597
- timestamp: string; // ISO 8601 時間戳
598
- }
599
- ```
600
-
601
- ---
602
-
603
- ### 鎖定資訊 (LockInfo)
604
-
605
- ```typescript
606
- interface LockInfo {
607
- task_id: string; // 任務 ID
608
- locked_by: string; // 鎖定者(@git_user 格式)
609
- locked_at: string; // 鎖定時間(ISO 8601)
610
- expires_at: string; // 過期時間(ISO 8601)
611
- _version: number; // 版本號
612
- }
613
- ```
614
-
615
- ---
616
-
617
- ## 錯誤處理
618
-
619
- ### 常見錯誤
620
-
621
- | 錯誤訊息 | 原因 | 解決方案 |
622
- |---------|------|---------|
623
- | `無效的任務 ID: XXX` | 任務 ID 格式不正確 | 使用 `validateTaskID()` 驗證 |
624
- | `任務不存在: XXX` | 任務未找到 | 檢查任務 ID 是否正確 |
625
- | `任務被其他用戶鎖定: @user` | 任務已被鎖定 | 等待鎖定過期或聯繫鎖定者 |
626
- | `無法更新舊系統任務: XXX` | 嘗試更新 TASK_QUEUE.json 中的任務 | 遷移到新系統或使用舊系統 API |
627
- | `無法刪除舊系統任務: XXX` | 嘗試刪除舊系統任務 | 手動編輯 TASK_QUEUE.json |
628
-
629
- ### 錯誤處理範例
630
-
631
- ```javascript
632
- try {
633
- const task = await api.getTask('TASK_5KPEES80MMXH');
634
- } catch (error) {
635
- if (error.message.includes('無效的任務 ID')) {
636
- console.error('任務 ID 格式錯誤');
637
- } else if (error.message.includes('不存在')) {
638
- console.error('任務未找到');
639
- } else {
640
- console.error('未知錯誤:', error.message);
641
- }
642
- }
643
- ```
644
-
645
- ---
646
-
647
- ## 最佳實踐
648
-
649
- ### 1. 使用樂觀鎖定避免衝突
650
-
651
- ```javascript
652
- const task = await api.getTask('TASK_5KPEES80MMXH');
653
- const currentVersion = task._version;
654
-
655
- // 修改任務
656
- const updated = await api.updateTask('TASK_5KPEES80MMXH', {
657
- status: 'in_progress'
658
- });
659
-
660
- // 檢查版本號
661
- if (updated._version !== currentVersion + 1) {
662
- console.warn('任務在更新期間被其他人修改');
663
- }
664
- ```
665
-
666
- ---
667
-
668
- ### 2. 使用鎖定保護長時間操作
669
-
670
- ```javascript
671
- const lockMgr = new LockManager();
672
- const taskId = 'TASK_5KPEES80MMXH';
673
-
674
- try {
675
- // 鎖定任務(30 分鐘)
676
- await lockMgr.acquireLock(taskId, 'zhangsan', 30);
677
-
678
- // 執行長時間操作
679
- // ...
680
-
681
- // 釋放鎖定
682
- await lockMgr.releaseLock(taskId, 'zhangsan');
683
- } catch (error) {
684
- console.error('操作失敗:', error.message);
685
- }
686
- ```
687
-
688
- ---
689
-
690
- ### 3. 批量查詢優化
691
-
692
- ```javascript
693
- // ❌ 不佳:逐個查詢
694
- for (const id of taskIds) {
695
- const task = await api.getTask(id);
696
- console.log(task.title);
697
- }
698
-
699
- // ✅ 最佳:一次查詢所有任務
700
- const allData = await api.getAllTasks();
701
- const taskMap = new Map(allData.tasks.map(t => [t.id, t]));
702
-
703
- for (const id of taskIds) {
704
- const task = taskMap.get(id);
705
- if (task) console.log(task.title);
706
- }
707
- ```
708
-
709
- ---
710
-
711
- ### 4. 自動清理過期鎖定
712
-
713
- ```javascript
714
- // 定期清理(建議每小時執行一次)
715
- setInterval(async () => {
716
- const lockMgr = new LockManager();
717
- const cleaned = await lockMgr.cleanExpiredLocks();
718
- if (cleaned > 0) {
719
- console.log(`已清理 ${cleaned} 個過期鎖定`);
720
- }
721
- }, 60 * 60 * 1000); // 每小時
722
- ```
723
-
724
- ---
725
-
726
- ## 完整範例
727
-
728
- ### 任務生命週期
729
-
730
- ```javascript
731
- const { TaskAPI } = require('./.collaboration/core/task-api.js');
732
- const { LockManager } = require('./.collaboration/core/lock-manager.js');
733
-
734
- const api = new TaskAPI();
735
- const lockMgr = new LockManager();
736
-
737
- async function taskLifecycle() {
738
- // 1. 建立任務
739
- const task = await api.createTask({
740
- title: '實作登入功能',
741
- description: '建立登入頁面和認證 API',
742
- priority: 'P1'
743
- });
744
- console.log(`✅ 任務已建立: ${task.id}`);
745
-
746
- // 2. 認領任務
747
- const claimed = await api.claimTask(task.id);
748
- console.log(`✅ 任務已認領,分配給: ${claimed.assigned_to.name}`);
749
-
750
- // 3. 鎖定任務
751
- await lockMgr.acquireLock(task.id, 'zhangsan', 60);
752
- console.log(`🔒 任務已鎖定`);
753
-
754
- // 4. 執行工作
755
- await new Promise(resolve => setTimeout(resolve, 5000));
756
-
757
- // 5. 更新進度
758
- await api.updateTask(task.id, {
759
- description: '登入頁面已完成,正在開發 API'
760
- });
761
-
762
- // 6. 完成任務
763
- const completed = await api.completeTask(task.id);
764
- console.log(`✅ 任務已完成,執行者: ${completed.executed_by.name}`);
765
-
766
- // 7. 釋放鎖定
767
- await lockMgr.releaseLock(task.id, 'zhangsan');
768
- console.log(`🔓 鎖定已釋放`);
769
- }
770
-
771
- taskLifecycle().catch(console.error);
772
- ```
773
-
774
- ---
775
-
776
- ## 相關文檔
777
-
778
- - [CLI 使用指南](./CLI.md) - 命令列工具完整文檔
779
- - [遷移指南](./MIGRATION.md) - 從舊系統遷移步驟
780
- - [架構設計](./ARCHITECTURE.md) - 系統架構詳細說明
781
- - [常見問題](./FAQ.md) - 疑難排解
782
-
783
- ---
784
-
785
- **版本**: 1.0.0
786
- **最後更新**: 2026-02-11
787
- **維護者**: Developer Team