kenaz 0.3.17 → 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 (316) 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/hooks/synapse-first-investigation.js +15 -0
  7. package/core/.claude/skills/architect_agent/SKILL.md +11 -92
  8. package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
  9. package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
  10. package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
  11. package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
  12. package/core/.claude/skills/designer/SKILL.md +3 -6
  13. package/core/.claude/skills/dev_agent/SKILL.md +30 -491
  14. package/core/.claude/skills/developer/SKILL.md +3 -6
  15. package/core/.claude/skills/feature_agent/SKILL.md +3 -17
  16. package/core/.claude/skills/product_manager/SKILL.md +29 -1064
  17. package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
  18. package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
  19. package/core/.claude/skills/sre_agent/SKILL.md +3 -6
  20. package/core/.collaboration/README.md +2 -3
  21. package/core/.collaboration/core/task-api.js +5 -138
  22. package/core/.collaboration/docs/CLI.md +0 -2
  23. package/core/.failure/INDEX.yaml +6 -40
  24. package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
  25. package/core/.failure/tools/README.md +9 -227
  26. package/core/.formation/bifrost/exec.js +29 -4
  27. package/core/.formation/bifrost/launch.js +1 -6
  28. package/core/.formation/bifrost/launch.test.js +1 -1
  29. package/core/.formation/bifrost/provider-launch.js +18 -11
  30. package/core/.formation/bifrost/provider-launch.test.js +26 -2
  31. package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
  32. package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
  33. package/core/.formation/tools/__tests__/dispatch-cwd-project.test.js +42 -0
  34. package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
  35. package/core/.formation/tools/__tests__/subagent-executor.test.js +3 -2
  36. package/core/.formation/tools/dispatch.js +15 -2
  37. package/core/.formation/tools/loader.js +17 -140
  38. package/core/.formation/tools/post-complete.js +0 -31
  39. package/core/.rule/INDEX.yaml +0 -18
  40. package/core/.rule/general/agent-workflow.yaml +14 -164
  41. package/core/.rule/general/project-self-containment.yaml +8 -19
  42. package/core/.rule/general/rust-verify-target.yaml +6 -5
  43. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  44. package/core/.specialist/Amelia/capability.yaml +12 -12
  45. package/core/.specialist/Amelia/workflow.yaml +2 -2
  46. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  47. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  48. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  49. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  50. package/core/.specialist/Ansuz/core.yaml +6 -108
  51. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  52. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  53. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  54. package/core/.specialist/Ansuz/rule.yaml +0 -1
  55. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  56. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  57. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  58. package/core/.specialist/tools/prompt-files.test.js +1 -0
  59. package/core/.specialist/tools/task-bridge.js +1 -66
  60. package/core/.system/README.md +11 -552
  61. package/core/.system/collaboration/README.md +10 -174
  62. package/core/CLAUDE.md +1 -6
  63. package/core/KENAZ_CORE_VERSION +1 -1
  64. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  65. package/core/dev/scripts/run-rust-tests.js +30 -46
  66. package/core/dev/scripts/run-rust-tests.test.js +17 -0
  67. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  68. package/core/dev/scripts/verify-target-dir.js +6 -6
  69. package/core/plugins/kenaz/INVENTORY.md +8 -8
  70. package/core/plugins/kenaz/commands/architect.md +1 -2
  71. package/core/plugins/kenaz/commands/spec.md +1 -1
  72. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  73. package/core/plugins/kenaz/guidance.md +1 -1
  74. package/core/plugins/kenaz/scripts/sync.js +1 -1
  75. package/core/plugins/kenaz/scripts/ygg.js +6 -0
  76. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  77. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  78. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  79. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  80. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  81. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  82. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  83. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  84. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  85. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  86. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  87. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  88. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  89. package/package.json +6 -6
  90. package/core/.claude/commands/archive.md +0 -24
  91. package/core/.claude/commands/init.md +0 -112
  92. package/core/.claude/commands/legacy_dev.md +0 -18
  93. package/core/.claude/commands/product-review.md +0 -131
  94. package/core/.claude/commands/strategy.md +0 -141
  95. package/core/.claude/commands/sunny.md +0 -1
  96. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  97. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  98. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  99. package/core/.claude/hooks/_substrate-paths.js +0 -95
  100. package/core/.claude/hooks/context-check.js +0 -51
  101. package/core/.claude/hooks/fatigue-check.js +0 -52
  102. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  103. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  104. package/core/.claude/hooks/handoff-staleness.js +0 -197
  105. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  106. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  107. package/core/.claude/hooks/lease-release.js +0 -119
  108. package/core/.claude/hooks/lease-touch.js +0 -96
  109. package/core/.claude/hooks/reflex-feedback.js +0 -5
  110. package/core/.claude/hooks/session-init.ps1 +0 -49
  111. package/core/.claude/hooks/sound-event.js +0 -70
  112. package/core/.claude/hooks/sound-event.sh +0 -37
  113. package/core/.claude/hooks/stream-delta.js +0 -169
  114. package/core/.claude/no-hooks.settings.json +0 -3
  115. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  116. package/core/.claude/skills/sunny/SKILL.md +0 -74
  117. package/core/.collaboration/cli/commands/assign.js +0 -39
  118. package/core/.collaboration/cli/commands/claim.js +0 -33
  119. package/core/.collaboration/cli/commands/complete.js +0 -44
  120. package/core/.collaboration/cli/commands/create.js +0 -110
  121. package/core/.collaboration/cli/commands/get.js +0 -83
  122. package/core/.collaboration/cli/commands/index.js +0 -52
  123. package/core/.collaboration/cli/commands/list.js +0 -51
  124. package/core/.collaboration/cli/commands/lock.js +0 -45
  125. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  126. package/core/.collaboration/cli/commands/search.js +0 -61
  127. package/core/.collaboration/cli/commands/stats.js +0 -61
  128. package/core/.collaboration/cli/commands/transfer.js +0 -41
  129. package/core/.collaboration/cli/commands/unlock.js +0 -48
  130. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  131. package/core/.collaboration/cli/formatters/index.js +0 -7
  132. package/core/.collaboration/cli/task-cli.js +0 -46
  133. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  134. package/core/.collaboration/cli/utils/git-user.js +0 -25
  135. package/core/.collaboration/cli/utils/index.js +0 -9
  136. package/core/.collaboration/cli/utils/output.js +0 -10
  137. package/core/.collaboration/config/default.yaml +0 -189
  138. package/core/.collaboration/core/conflict-resolver.js +0 -461
  139. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  140. package/core/.collaboration/core/migrate-legacy.js +0 -260
  141. package/core/.collaboration/docs/API.md +0 -787
  142. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  143. package/core/.collaboration/docs/FAQ.md +0 -695
  144. package/core/.collaboration/docs/MIGRATION.md +0 -804
  145. package/core/.collaboration/docs/examples/README.md +0 -320
  146. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  147. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  148. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  149. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  150. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  151. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  152. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  153. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  154. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  155. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  156. package/core/.failure/pipeline/README.md +0 -95
  157. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  158. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  159. package/core/.failure/tools/check_failures.ps1 +0 -387
  160. package/core/.failure/tools/log_failure.ps1 +0 -474
  161. package/core/.formation/.episode-input.json +0 -10
  162. package/core/.formation/.merge-lock +0 -1
  163. package/core/.formation/lead.yaml +0 -118
  164. package/core/.formation/legacy.bak/designer.yaml +0 -57
  165. package/core/.formation/legacy.bak/pm.yaml +0 -57
  166. package/core/.formation/legacy.bak/qa.yaml +0 -57
  167. package/core/.formation/legacy.bak/review.yaml +0 -62
  168. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  169. package/core/.formation/legacy.bak/sre.yaml +0 -57
  170. package/core/.formation/role-map.yaml +0 -274
  171. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  172. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  173. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  174. package/core/.formation/roles/backend/role.yaml +0 -93
  175. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  176. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  177. package/core/.formation/roles/designer/role.yaml +0 -66
  178. package/core/.formation/roles/developer/role.yaml +0 -75
  179. package/core/.formation/roles/frontend/role.yaml +0 -134
  180. package/core/.formation/roles/incident_response/role.yaml +0 -89
  181. package/core/.formation/roles/qa/role.yaml +0 -89
  182. package/core/.formation/roles/security/role.yaml +0 -87
  183. package/core/.formation/roles/sre/role.yaml +0 -66
  184. package/core/.formation/skills/coordinator.yaml +0 -52
  185. package/core/.formation/solo/diagnosis.yaml +0 -78
  186. package/core/.formation/solo/strategy.yaml +0 -121
  187. package/core/.formation/tests/hello.txt +0 -2
  188. package/core/.formation/tools/coordinator.js +0 -350
  189. package/core/.formation/tools/jev-correction.js +0 -214
  190. package/core/.formation/tools/jev-correction.test.js +0 -178
  191. package/core/.formation/tools/log-reader.js +0 -232
  192. package/core/.formation/tools/revert-daemon-state.js +0 -162
  193. package/core/.formation/tools/test-drift.js +0 -148
  194. package/core/.formation/unit/heimdall.yaml +0 -96
  195. package/core/.formation/unit/plan.yaml +0 -67
  196. package/core/.formation/unit/think.yaml +0 -58
  197. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  198. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  199. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  200. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  201. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  202. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  203. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  204. package/core/.kenaz/runes_TASK_1428.json +0 -57
  205. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  206. package/core/.kenaz/tmp_props.json +0 -1
  207. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  208. package/core/.rule/MECHANIZED.md +0 -61
  209. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  210. package/core/.rule/general/pipeline.yaml +0 -246
  211. package/core/.rule/general/sunny-access-control.yaml +0 -60
  212. package/core/.rule/general/system-invariants.yaml +0 -231
  213. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  214. package/core/.rule/pipeline/auto-update.yaml +0 -282
  215. package/core/.rule/pipeline/task-execution.yaml +0 -365
  216. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  217. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  218. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  219. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  220. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  221. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  222. package/core/.specialist/tools/jev-optional-context.js +0 -107
  223. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  224. package/core/.specialist/tools/memory-action-log.js +0 -839
  225. package/core/.specialist/tools/phase-gate.js +0 -3534
  226. package/core/.specialist/tools/phase-gate.test.js +0 -85
  227. package/core/.specialist/tools/precompute-runner.js +0 -444
  228. package/core/.specialist/tools/rule-engine.js +0 -621
  229. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  230. package/core/.synapse/memory-shared.json.sync +0 -1
  231. package/core/.system/agent-skills/README.md +0 -724
  232. package/core/.system/cli-tools/README.md +0 -724
  233. package/core/.system/cortex/MODULES.md +0 -1046
  234. package/core/.system/dashboard/FRONTEND.md +0 -812
  235. package/core/.system/dashboard/README.md +0 -737
  236. package/core/.system/failure/README.md +0 -723
  237. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  238. package/core/.system/formation/POST_COMPLETE.md +0 -602
  239. package/core/.system/formation/README.md +0 -1094
  240. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  241. package/core/.system/kenaz/README.md +0 -787
  242. package/core/.system/memory/README.md +0 -719
  243. package/core/.system/pipeline/README.md +0 -712
  244. package/core/.system/rule/README.md +0 -794
  245. package/core/.system/sunny/README.md +0 -476
  246. package/core/.system/sunny/RULES.json +0 -89
  247. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  248. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  249. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  250. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  251. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  252. package/core/.system/sunny/teammates/README.md +0 -107
  253. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  254. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  255. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  256. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  257. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  258. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  259. package/core/.system/sunny/tools.json +0 -101
  260. package/core/dev/scripts/cleanup-queue.js +0 -184
  261. package/core/dev/scripts/cleanup_queue.js +0 -86
  262. package/core/dev/scripts/legacy/README.md +0 -39
  263. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  264. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  265. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  266. package/core/dev/scripts/matrix/README.md +0 -310
  267. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  268. package/core/dev/scripts/matrix/package.json +0 -55
  269. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  270. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  271. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  272. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  273. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  274. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  275. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  276. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  277. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  278. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  279. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  280. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  281. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  282. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  283. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  284. package/core/dev/scripts/matrix/src/index.ts +0 -62
  285. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  286. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  287. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  288. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  289. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  290. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  291. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  292. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  293. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  294. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  295. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  296. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  297. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  298. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  299. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  300. package/core/dev/scripts/matrix/types/index.js +0 -8
  301. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  302. package/core/dev/scripts/matrix/types/index.ts +0 -124
  303. package/core/dev/scripts/memory-usage-report.js +0 -152
  304. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  305. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  306. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  307. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  308. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  309. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  310. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  311. package/core/dev/scripts/validate_pipeline.js +0 -197
  312. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  313. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  314. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  315. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  316. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,596 +0,0 @@
1
- # .collaboration 系統架構設計文檔
2
-
3
- ## 目錄
4
-
5
- 1. [概述](#概述)
6
- 2. [設計目標](#設計目標)
7
- 3. [核心架構](#核心架構)
8
- 4. [資料模型](#資料模型)
9
- 5. [工作流程](#工作流程)
10
- 6. [Git 整合](#git-整合)
11
- 7. [衝突處理](#衝突處理)
12
- 8. [效能考量](#效能考量)
13
- 9. [安全性](#安全性)
14
- 10. [未來擴展](#未來擴展)
15
-
16
- ---
17
-
18
- ## 概述
19
-
20
- `.collaboration` 是一個基於 Git 的分散式任務協作系統,專為多用戶在不同系統上透過 Git 進行任務協作而設計。系統採用**原子檔案結構 + JSONL 索引 + 時間戳鎖定**的架構,實現了無需中央伺服器的協作模式。
21
-
22
- ### 核心特性
23
-
24
- - ✅ UUID 任務 ID(TASK_ + ULID)
25
- - ✅ 原子檔案結構(一個任務一個檔案)
26
- - ✅ JSONL Append-only 索引
27
- - ✅ 時間戳鎖定機制
28
- - ✅ 樂觀鎖定(版本號衝突偵測)
29
- - ✅ 統一 API 層(相容 Dashboard)
30
- - ✅ Git Hooks 自動化
31
- - ✅ 多用戶角色追蹤
32
-
33
- ---
34
-
35
- ## 設計目標
36
-
37
- ### 1. Git 友好性 🎯
38
-
39
- **問題**:傳統任務系統使用單一 JSON 檔案,多用戶同時編輯會產生衝突。
40
-
41
- **解決方案**:
42
- - **原子檔案結構**:一個任務 = 一個檔案 → 減少衝突機率
43
- - **JSONL 索引**:Append-only 格式 → Git 自動合併
44
- - **時間戳鎖定**:Append-only 鎖定檔案 → 不覆寫
45
-
46
- **效果**:
47
- ```bash
48
- # 用戶 A 建立任務
49
- dev/tasks/db/users/zhangsan/TASK_01HQFX9K2G.json
50
-
51
- # 用戶 B 同時建立任務
52
- dev/tasks/db/users/lisi/TASK_01HQGN2P7K.json
53
-
54
- # Git merge:無衝突 ✅
55
- ```
56
-
57
- ### 2. 分散式協作 🌐
58
-
59
- **場景**:用戶不在同一系統,透過 Git 通訊。
60
-
61
- **解決方案**:
62
- - 無需中央伺服器
63
- - 樂觀鎖定(版本號)
64
- - Git 作為唯一通訊渠道
65
-
66
- **工作流程**:
67
- ```
68
- 用戶 A: 建立任務 → Git push → 用戶 B: Git pull → 認領任務
69
- ```
70
-
71
- ### 3. Dashboard 相容性 📊
72
-
73
- **需求**:Dashboard 依賴 `TASK_QUEUE.json` 格式。
74
-
75
- **解決方案**:
76
- - 統一 API 層(`task-api.js`)
77
- - 自動合併新舊系統
78
- - 輸出格式相容
79
-
80
- **API 回應**:
81
- ```json
82
- {
83
- "version": "2.0.0",
84
- "tasks": [...], // 相容舊格式
85
- "statistics": { ... },
86
- "metadata": {
87
- "sources": {
88
- "new": 10,
89
- "old": 5,
90
- "completed": 20
91
- }
92
- }
93
- }
94
- ```
95
-
96
- ### 4. 效能最佳化 ⚡
97
-
98
- **問題**:隨著任務增加,檔案掃描變慢。
99
-
100
- **解決方案**:
101
- - JSONL 索引(快速查詢)
102
- - 增量更新(不全量重建)
103
- - 未來:快取層
104
-
105
- ---
106
-
107
- ## 核心架構
108
-
109
- ### 系統分層
110
-
111
- ```
112
- ┌─────────────────────────────────────────────────┐
113
- │ CLI Layer (task-cli.js) │
114
- │ - 用戶命令介面 │
115
- └────────────────┬────────────────────────────────┘
116
- │
117
- ┌────────────────▼────────────────────────────────┐
118
- │ API Layer (task-api.js) │
119
- │ - 統一查詢介面 │
120
- │ - 整合新舊系統 │
121
- │ - Dashboard 相容 │
122
- └─────┬───────────────┬───────────────┬───────────┘
123
- │ │ │
124
- ┌─────▼─────┐ ┌──────▼──────┐ ┌─────▼──────────┐
125
- │ Index │ │ Lock │ │ ID Generator │
126
- │ Manager │ │ Manager │ │ │
127
- └─────┬─────┘ └──────┬──────┘ └────────────────┘
128
- │ │
129
- ┌─────▼───────────────▼────────────────────────────┐
130
- │ Storage Layer │
131
- │ - dev/tasks/db/ (原子檔案) │
132
- │ - dev/tasks/index/ (JSONL 索引) │
133
- │ - dev/tasks/locks/ (鎖定檔案) │
134
- └──────────────────────────────────────────────────┘
135
- ```
136
-
137
- ### 核心模組
138
-
139
- | 模組 | 檔案 | 職責 |
140
- |------|------|------|
141
- | ID Generator | `id-generator.js` | 生成 UUID (TASK_ + ULID) |
142
- | Task API | `task-api.js` | 統一查詢、CRUD 操作 |
143
- | Lock Manager | `lock-manager.js` | 任務鎖定/解鎖 |
144
- | Index Manager | `index-manager.js` | JSONL 索引管理 |
145
- | Conflict Resolver | `conflict-resolver.js` | 衝突偵測與解決 |
146
- | Task CLI | `task-cli.js` | 命令列介面 |
147
-
148
- ---
149
-
150
- ## 資料模型
151
-
152
- ### UUID 格式
153
-
154
- ```
155
- TASK_01HQFX9K2G
156
- │ │ │
157
- │ │ └─ 隨機部分(4 chars, 1M+ 組合/毫秒)
158
- │ └─────── 時間戳部分(6 chars, ~8900 年)
159
- └──────────── 前綴(向下相容)
160
- ```
161
-
162
- **編碼**: Crockford Base32(避免易混淆字元)
163
- **長度**: 15 字元
164
- **特性**: 時間排序、全域唯一
165
-
166
- ### 任務檔案結構
167
-
168
- ```json
169
- {
170
- "id": "TASK_01HQFX9K2G",
171
- "title": "實作登入功能",
172
- "description": "建立用戶登入頁面和 API",
173
- "status": "pending",
174
- "priority": "P1",
175
-
176
- "created_by": {
177
- "name": "張三",
178
- "git_user": "zhangsan",
179
- "timestamp": "2026-02-11T10:00:00+08:00"
180
- },
181
-
182
- "assigned_to": {
183
- "name": "李四",
184
- "git_user": "lisi",
185
- "timestamp": "2026-02-11T10:05:00+08:00"
186
- },
187
-
188
- "last_modified_by": {
189
- "name": "王五",
190
- "git_user": "wangwu",
191
- "timestamp": "2026-02-11T10:10:00+08:00"
192
- },
193
-
194
- "collaborators": [
195
- { "name": "趙六", "git_user": "zhaoliu" }
196
- ],
197
-
198
- "executed_by": null,
199
-
200
- "_version": 1,
201
- "_file_path": "dev/tasks/db/users/zhangsan/TASK_01HQFX9K2G.json"
202
- }
203
- ```
204
-
205
- ### JSONL 索引格式
206
-
207
- ```jsonl
208
- {"id":"TASK_01HQFX9K2G","user":"zhangsan","ts":1707628800,"v":1}
209
- {"id":"TASK_01HQGN2P7K","user":"lisi","ts":1707628900,"v":1}
210
- {"id":"TASK_01HQFX9K2G","user":"zhangsan","ts":1707629000,"v":2}
211
- ```
212
-
213
- **欄位說明**:
214
- - `id`: 任務 ID
215
- - `user`: 負責用戶
216
- - `ts`: 時間戳(Unix)
217
- - `v`: 版本號
218
-
219
- **特性**:
220
- - Append-only(只追加,不修改)
221
- - Git 友好(自動合併)
222
- - 支援去重(取最新版本)
223
-
224
- ### 鎖定檔案格式
225
-
226
- ```json
227
- {
228
- "task_id": "TASK_01HQFX9K2G",
229
- "locked_by": "@zhangsan",
230
- "locked_at": "2026-02-11T10:00:00+08:00",
231
- "expires_at": "2026-02-11T11:00:00+08:00",
232
- "_version": 1
233
- }
234
- ```
235
-
236
- **檔案名稱**: `{user}_{timestamp}.lock`
237
- **特性**:
238
- - Append-only(不覆寫)
239
- - 自動過期(1 小時)
240
- - 多用戶鎖定偵測
241
-
242
- ---
243
-
244
- ## 工作流程
245
-
246
- ### 1. 建立任務
247
-
248
- ```bash
249
- # CLI 命令
250
- node .collaboration/cli/task-cli.js create \
251
- --title "實作登入功能" \
252
- --priority P1
253
-
254
- # 內部流程
255
- ┌─────────────────────────────────────────────────┐
256
- │ 1. 生成 UUID (TASK_01HQFX9K2G) │
257
- │ 2. 取得 Git user 資訊 │
258
- │ 3. 建立任務物件 │
259
- │ 4. 寫入 dev/tasks/db/users/{user}/TASK_*.json │
260
- │ 5. 更新 JSONL 索引 │
261
- │ 6. 提示 Git 操作 │
262
- └─────────────────────────────────────────────────┘
263
-
264
- # Git 操作
265
- git add dev/tasks/db/users/zhangsan/TASK_01HQFX9K2G.json
266
- git commit -m "feat: 建立任務 TASK_01HQFX9K2G"
267
- git push origin main
268
- ```
269
-
270
- ### 2. 認領任務
271
-
272
- ```bash
273
- # 用戶 B pull 最新版本
274
- git pull origin main
275
-
276
- # 認領任務
277
- node .collaboration/cli/task-cli.js claim TASK_01HQFX9K2G
278
-
279
- # 內部流程
280
- ┌─────────────────────────────────────────────────┐
281
- │ 1. 載入任務檔案 │
282
- │ 2. 檢查鎖定狀態 │
283
- │ 3. 更新 assigned_to 欄位 │
284
- │ 4. 版本號 +1 │
285
- │ 5. 寫回任務檔案 │
286
- │ 6. 更新索引 │
287
- └─────────────────────────────────────────────────┘
288
-
289
- # Git 操作
290
- git add dev/tasks/db/users/zhangsan/TASK_01HQFX9K2G.json
291
- git commit -m "chore: 認領任務 TASK_01HQFX9K2G"
292
- git push origin main
293
- ```
294
-
295
- ### 3. 完成任務
296
-
297
- ```bash
298
- node .collaboration/cli/task-cli.js complete TASK_01HQFX9K2G
299
-
300
- # 內部流程
301
- ┌─────────────────────────────────────────────────┐
302
- │ 1. 載入任務檔案 │
303
- │ 2. 更新 status = "completed" │
304
- │ 3. 設定 executed_by 欄位 │
305
- │ 4. 版本號 +1 │
306
- │ 5. 寫回任務檔案 │
307
- │ 6. 更新索引 (by-status/completed.jsonl) │
308
- └─────────────────────────────────────────────────┘
309
- ```
310
-
311
- ---
312
-
313
- ## Git 整合
314
-
315
- ### Git Hooks
316
-
317
- #### post-merge Hook
318
-
319
- **目的**: Git merge 後自動重建索引
320
-
321
- **位置**: `.githooks/post-merge`
322
-
323
- ```bash
324
- #!/bin/bash
325
- # post-merge hook
326
-
327
- echo "Rebuilding task indexes..."
328
- node .collaboration/core/index-manager.js rebuild
329
-
330
- exit 0
331
- ```
332
-
333
- **安裝**:
334
- ```bash
335
- git config core.hooksPath .githooks
336
- ```
337
-
338
- #### pre-commit Hook
339
-
340
- **目的**: 提交前檢查鎖定衝突
341
-
342
- **位置**: `.githooks/pre-commit`
343
-
344
- ```bash
345
- #!/bin/bash
346
- # pre-commit hook
347
-
348
- node .collaboration/hooks/pre-commit.js
349
-
350
- exit $?
351
- ```
352
-
353
- ### Git 工作流程範例
354
-
355
- #### 場景:兩個用戶同時編輯不同任務
356
-
357
- ```
358
- 用戶 A:
359
- 1. git pull
360
- 2. 建立任務 A (TASK_01HQFX9K2G)
361
- 3. git push
362
-
363
- 用戶 B:
364
- 1. git pull
365
- 2. 建立任務 B (TASK_01HQGN2P7K)
366
- 3. git push
367
-
368
- 結果: ✅ 無衝突(不同檔案)
369
- ```
370
-
371
- #### 場景:兩個用戶同時編輯同一任務
372
-
373
- ```
374
- 用戶 A:
375
- 1. git pull
376
- 2. 更新任務 (version: 1 → 2)
377
- 3. git push
378
-
379
- 用戶 B:
380
- 1. git pull (稍晚)
381
- 2. 嘗試更新任務 (version: 1 → 2)
382
- 3. git push → 衝突!
383
-
384
- Git 衝突標記:
385
- <<<<<<< HEAD
386
- "_version": 2,
387
- "assigned_to": { "git_user": "zhangsan" }
388
- =======
389
- "_version": 2,
390
- "assigned_to": { "git_user": "lisi" }
391
- >>>>>>> branch
392
-
393
- 解決:
394
- node .collaboration/core/conflict-resolver.js TASK_01HQFX9K2G
395
- # 工具自動比較時間戳,選擇最新版本
396
- ```
397
-
398
- ---
399
-
400
- ## 衝突處理
401
-
402
- ### 樂觀鎖定策略
403
-
404
- **原理**: 使用版本號偵測並發修改
405
-
406
- ```javascript
407
- function detectConflict(localTask, remoteTask) {
408
- if (localTask._version !== remoteTask._version) {
409
- return {
410
- hasConflict: true,
411
- winner: localTask.last_modified_by.timestamp >
412
- remoteTask.last_modified_by.timestamp ? 'local' : 'remote'
413
- };
414
- }
415
- return { hasConflict: false };
416
- }
417
- ```
418
-
419
- ### 衝突解決流程
420
-
421
- ```
422
- 1. 偵測衝突(版本號不一致)
423
- ↓
424
- 2. 比較 last_modified_by.timestamp
425
- ↓
426
- 3. 選擇最新版本作為 winner
427
- ↓
428
- 4. 合併元數據(collaborators 合併)
429
- ↓
430
- 5. 版本號 = max(local, remote) + 1
431
- ```
432
-
433
- ### 鎖定機制
434
-
435
- **時間戳鎖定**:
436
- ```
437
- dev/tasks/locks/TASK_01HQFX9K2G/
438
- ├── zhangsan_1707628800.lock (✅ 有效)
439
- ├── lisi_1707628900.lock (❌ 過期)
440
- └── wangwu_1707629000.lock (⚠️ 衝突!)
441
- ```
442
-
443
- **檢查邏輯**:
444
- 1. 掃描任務鎖定目錄
445
- 2. 移除過期鎖定(> 1 小時)
446
- 3. 檢查是否有其他用戶的活躍鎖定
447
- 4. 如有 → 拒絕操作
448
-
449
- ---
450
-
451
- ## 效能考量
452
-
453
- ### 索引策略
454
-
455
- **問題**: 掃描所有任務檔案很慢
456
-
457
- **解決方案**: JSONL 索引
458
-
459
- ```
460
- 查詢 pending 任務:
461
- 1. 讀取 dev/tasks/index/by-status/pending.jsonl
462
- 2. 解析 JSONL(每行一個任務)
463
- 3. 去重(取最新版本)
464
- 4. 返回任務 ID 列表
465
-
466
- 時間複雜度: O(n) → O(k)
467
- 其中 k = pending 任務數量 << n = 總任務數量
468
- ```
469
-
470
- ### 增量更新
471
-
472
- **策略**: 不全量重建索引
473
-
474
- ```javascript
475
- // 建立任務時立即更新索引
476
- await indexMgr.updateTask(taskId, task);
477
-
478
- // 只在 Git merge 後才全量重建
479
- # post-merge hook: node .collaboration/core/index-manager.js rebuild
480
- ```
481
-
482
- ### 未來優化
483
-
484
- - [ ] 快取層(記憶體快取)
485
- - [ ] 壓縮索引(Gzip)
486
- - [ ] 分片索引(按日期分片)
487
-
488
- ---
489
-
490
- ## 安全性
491
-
492
- ### Git 用戶驗證
493
-
494
- ```javascript
495
- function _getGitUser() {
496
- const name = execSync('git config user.name').trim();
497
- const email = execSync('git config user.email').trim();
498
- const gitUser = email.split('@')[0];
499
-
500
- return { name, email, git_user: gitUser };
501
- }
502
- ```
503
-
504
- ### 權限控制
505
-
506
- **目前**: 無權限控制(信任 Git 用戶)
507
- **未來**: 基於角色的權限控制(RBAC)
508
-
509
- ```yaml
510
- roles:
511
- admin:
512
- - create_task
513
- - assign_task
514
- - delete_task
515
- developer:
516
- - create_task
517
- - claim_task
518
- viewer:
519
- - list_tasks
520
- ```
521
-
522
- ---
523
-
524
- ## 未來擴展
525
-
526
- ### 短期(1-3 個月)
527
-
528
- - [ ] 衝突解決工具完整實作
529
- - [ ] Git Hooks 自動化
530
- - [ ] CLI 完整測試
531
- - [ ] Dashboard 深度整合
532
-
533
- ### 中期(3-6 個月)
534
-
535
- - [ ] 快取層(Redis)
536
- - [ ] 權限控制(RBAC)
537
- - [ ] 任務範本系統
538
- - [ ] 批次操作 API
539
-
540
- ### 長期(6-12 個月)
541
-
542
- - [ ] Web UI(取代 CLI)
543
- - [ ] 實時同步(WebSocket)
544
- - [ ] 分析報表(時間追蹤、效率分析)
545
- - [ ] 多專案支援
546
-
547
- ---
548
-
549
- ## 附錄
550
-
551
- ### A. 資料夾結構
552
-
553
- ```
554
- dev/tasks/
555
- ├── db/
556
- │ ├── users/
557
- │ │ ├── zhangsan/
558
- │ │ │ ├── TASK_01HQFX9K2G.json
559
- │ │ │ └── TASK_01HQGN2P7K.json
560
- │ │ └── lisi/
561
- │ │ └── TASK_01HQHN3Q8M.json
562
- │ └── shared/
563
- │ └── TASK_01HQJP4R9N.json
564
- ├── index/
565
- │ ├── by-status/
566
- │ │ ├── pending.jsonl
567
- │ │ ├── in_progress.jsonl
568
- │ │ └── completed.jsonl
569
- │ ├── by-user/
570
- │ │ ├── zhangsan.jsonl
571
- │ │ └── lisi.jsonl
572
- │ └── by-priority/
573
- │ ├── P0.jsonl
574
- │ ├── P1.jsonl
575
- │ └── P2.jsonl
576
- └── locks/
577
- ├── TASK_01HQFX9K2G/
578
- │ └── zhangsan_1707628800.lock
579
- └── TASK_01HQGN2P7K/
580
- └── lisi_1707628900.lock
581
- ```
582
-
583
- ### B. API 參考
584
-
585
- 參見 [API.md](./API.md)
586
-
587
- ### C. CLI 指南
588
-
589
- 參見 [CLI.md](./CLI.md)
590
-
591
- ---
592
-
593
- **建立日期**: 2026-02-11
594
- **最後更新**: 2026-02-11
595
- **版本**: 1.0.0
596
- **作者**: Lead Agent