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,189 +0,0 @@
1
- # .collaboration 系統配置
2
-
3
- # ============================================================================
4
- # ID 生成器配置
5
- # ============================================================================
6
- id_generator:
7
- # 前綴(向下相容)
8
- prefix: "TASK_"
9
-
10
- # 時間戳字元數(Base32 編碼)
11
- # 6 chars = 48 bits = ~8900 年
12
- time_chars: 6
13
-
14
- # 隨機字元數(Base32 編碼)
15
- # 4 chars = 20 bits = 1,048,576 組合/毫秒
16
- random_chars: 4
17
-
18
- # 編碼方式
19
- encoding: "base32" # Crockford Base32
20
-
21
- # ============================================================================
22
- # 鎖定機制配置
23
- # ============================================================================
24
- locking:
25
- # 是否啟用鎖定
26
- enabled: true
27
-
28
- # 鎖定過期時間(小時)
29
- timeout_hours: 1
30
-
31
- # 是否自動釋放過期鎖定
32
- auto_release: true
33
-
34
- # 鎖定目錄
35
- locks_dir: "dev/tasks/locks"
36
-
37
- # ============================================================================
38
- # 索引系統配置
39
- # ============================================================================
40
- indexing:
41
- # 是否啟用索引
42
- enabled: true
43
-
44
- # Git merge 後是否自動重建索引
45
- auto_rebuild: true
46
-
47
- # 索引格式(JSONL)
48
- format: "jsonl"
49
-
50
- # 索引類型
51
- types:
52
- - by-status # 按狀態索引
53
- - by-user # 按用戶索引
54
- - by-priority # 按優先級索引
55
-
56
- # 索引目錄
57
- index_dir: "dev/tasks/index"
58
-
59
- # ============================================================================
60
- # Git Hooks 配置
61
- # ============================================================================
62
- git_hooks:
63
- # 是否啟用 Git Hooks
64
- enabled: true
65
-
66
- # Post-merge hook(合併後自動重建索引)
67
- post_merge:
68
- enabled: true
69
- command: "node .collaboration/core/index-manager.js rebuild"
70
-
71
- # Pre-commit hook(提交前檢查鎖定)
72
- pre_commit:
73
- enabled: true
74
- command: "node .collaboration/hooks/pre-commit.js"
75
-
76
- # ============================================================================
77
- # 用戶配置
78
- # ============================================================================
79
- users:
80
- # 預設顯示格式
81
- default_display: "username" # username | email | full_name
82
-
83
- # 是否需要 Git user.name/user.email 配置
84
- require_git_config: true
85
-
86
- # 任務檔案存儲目錄
87
- task_storage:
88
- users_dir: "dev/tasks/db/users" # 用戶專屬任務
89
- shared_dir: "dev/tasks/db/shared" # 共享任務
90
-
91
- # ============================================================================
92
- # 任務系統配置
93
- # ============================================================================
94
- tasks:
95
- # 預設狀態
96
- default_status: "pending"
97
-
98
- # 預設優先級
99
- default_priority: "P2"
100
-
101
- # 狀態列表
102
- statuses:
103
- - pending
104
- - in_progress
105
- - completed
106
- - blocked
107
- - cancelled
108
-
109
- # 優先級列表
110
- priorities:
111
- - P0 # 緊急
112
- - P1 # 高
113
- - P2 # 中
114
- - P3 # 低
115
-
116
- # ============================================================================
117
- # API 配置
118
- # ============================================================================
119
- api:
120
- # API 版本
121
- version: "2.0.0"
122
-
123
- # 資料來源優先級
124
- data_sources:
125
- - new_system # dev/tasks/db/ (最高優先級)
126
- - old_queue # dev/pipeline/TASK_QUEUE.json
127
- - completed_tasks # .memory/COMPLETED_TASKS.json
128
-
129
- # 舊系統檔案路徑
130
- old_system:
131
- queue_file: "dev/pipeline/TASK_QUEUE.json"
132
- completed_file: ".memory/COMPLETED_TASKS.json"
133
-
134
- # 是否相容舊系統格式
135
- legacy_compatibility: true
136
-
137
- # ============================================================================
138
- # Dashboard 整合配置
139
- # ============================================================================
140
- dashboard:
141
- # 是否啟用 Dashboard 整合
142
- enabled: true
143
-
144
- # Dashboard 使用的 API 端點
145
- api_endpoint: ".collaboration/core/task-api.js"
146
-
147
- # 是否包含已完成任務
148
- include_completed: true
149
-
150
- # 輸出格式(相容 TASK_QUEUE.json)
151
- output_format: "task_queue_compatible"
152
-
153
- # ============================================================================
154
- # 衝突解決配置
155
- # ============================================================================
156
- conflict_resolution:
157
- # 策略: version(版本號)| timestamp(時間戳)| manual(手動)
158
- strategy: "version"
159
-
160
- # 是否自動解決衝突
161
- auto_resolve: false
162
-
163
- # 手動解決時的編輯器
164
- editor: "code" # code | vim | nano | notepad
165
-
166
- # ============================================================================
167
- # 效能配置
168
- # ============================================================================
169
- performance:
170
- # 索引重建時的批次大小
171
- rebuild_batch_size: 100
172
-
173
- # 快取配置
174
- cache:
175
- enabled: false # 未來功能
176
- ttl_seconds: 300
177
-
178
- # ============================================================================
179
- # 日誌配置
180
- # ============================================================================
181
- logging:
182
- # 日誌級別: debug | info | warn | error
183
- level: "info"
184
-
185
- # 是否輸出到檔案
186
- to_file: false
187
-
188
- # 日誌目錄
189
- log_dir: ".collaboration/logs"
@@ -1,461 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * conflict-resolver.js
4
- * 任務版本衝突解決工具
5
- *
6
- * 功能:
7
- * - 版本號衝突偵測 (_version 欄位)
8
- * - 時間戳比較 (last_modified_by.timestamp)
9
- * - 自動合併策略 (collaborators 欄位)
10
- * - 手動解決介面 (CLI 互動)
11
- * - Git 衝突標記解析
12
- *
13
- * 使用方式:
14
- * const { ConflictResolver } = require('./conflict-resolver.js');
15
- * const resolver = new ConflictResolver();
16
- *
17
- * // 偵測版本衝突
18
- * const conflict = resolver.detectConflict(taskA, taskB);
19
- *
20
- * // 自動解決衝突
21
- * const resolved = await resolver.autoResolve(taskA, taskB);
22
- *
23
- * // 手動解決介面
24
- * const result = await resolver.manualResolve(taskA, taskB);
25
- */
26
-
27
- const fs = require('fs').promises;
28
- const path = require('path');
29
- const readline = require('readline');
30
-
31
- // 配置
32
- const CONFIG = {
33
- VERSION_FIELD: '_version',
34
- TIMESTAMP_FIELD: 'last_modified_by.timestamp',
35
- AUTO_MERGE_FIELDS: ['collaborators', 'keywords', 'dependencies.optional'],
36
- GIT_CONFLICT_MARKERS: {
37
- ours: '<<<<<<< HEAD',
38
- separator: '=======',
39
- theirs: '>>>>>>> ',
40
- }
41
- };
42
-
43
- /**
44
- * 版本衝突類型
45
- */
46
- const ConflictType = {
47
- NO_CONFLICT: 'no_conflict',
48
- VERSION_MISMATCH: 'version_mismatch',
49
- TIMESTAMP_CONFLICT: 'timestamp_conflict',
50
- GIT_CONFLICT: 'git_conflict',
51
- FIELD_CONFLICT: 'field_conflict',
52
- };
53
-
54
- /**
55
- * 解決策略
56
- */
57
- const ResolutionStrategy = {
58
- KEEP_OURS: 'keep_ours', // 保留我們的版本
59
- KEEP_THEIRS: 'keep_theirs', // 保留他們的版本
60
- AUTO_MERGE: 'auto_merge', // 自動合併
61
- MANUAL: 'manual', // 手動選擇
62
- };
63
-
64
- class ConflictResolver {
65
- constructor(config = {}) {
66
- this.config = { ...CONFIG, ...config };
67
- }
68
-
69
- /**
70
- * 偵測兩個任務版本之間的衝突
71
- * @param {Object} ours - 我們的版本
72
- * @param {Object} theirs - 他們的版本
73
- * @returns {Object} - 衝突資訊 { hasConflict, type, details }
74
- */
75
- detectConflict(ours, theirs) {
76
- if (!ours || !theirs) {
77
- throw new Error('detectConflict: 必須提供兩個版本');
78
- }
79
-
80
- if (ours.id !== theirs.id) {
81
- throw new Error('detectConflict: 任務 ID 不匹配');
82
- }
83
-
84
- const result = {
85
- hasConflict: false,
86
- type: ConflictType.NO_CONFLICT,
87
- details: {},
88
- };
89
-
90
- // 1. 檢查版本號(最高優先級)
91
- const ourVersion = ours._version || 1;
92
- const theirVersion = theirs._version || 1;
93
-
94
- if (ourVersion !== theirVersion) {
95
- result.hasConflict = true;
96
- result.type = ConflictType.VERSION_MISMATCH;
97
- result.details.versionMismatch = {
98
- ours: ourVersion,
99
- theirs: theirVersion,
100
- };
101
- return result; // 立即返回,優先級最高
102
- }
103
-
104
- // 2. 檢查欄位差異(第二優先級)
105
- const fieldDiffs = this._compareFields(ours, theirs);
106
- if (fieldDiffs.length > 0) {
107
- result.hasConflict = true;
108
- result.type = ConflictType.FIELD_CONFLICT;
109
- result.details.fieldConflicts = fieldDiffs;
110
-
111
- // 檢查是否為同時修改(時間戳非常接近)
112
- const ourTimestamp = this._getTimestamp(ours);
113
- const theirTimestamp = this._getTimestamp(theirs);
114
-
115
- if (ourTimestamp && theirTimestamp) {
116
- const ourTime = new Date(ourTimestamp).getTime();
117
- const theirTime = new Date(theirTimestamp).getTime();
118
-
119
- if (Math.abs(ourTime - theirTime) < 1000) {
120
- // 1 秒內的修改視為同時修改,升級為時間戳衝突
121
- result.type = ConflictType.TIMESTAMP_CONFLICT;
122
- result.details.timestampConflict = {
123
- ours: ourTimestamp,
124
- theirs: theirTimestamp,
125
- diff: Math.abs(ourTime - theirTime),
126
- };
127
- }
128
- }
129
- }
130
-
131
- return result;
132
- }
133
-
134
- /**
135
- * 自動解決衝突
136
- * @param {Object} ours - 我們的版本
137
- * @param {Object} theirs - 他們的版本
138
- * @param {String} strategy - 解決策略
139
- * @returns {Object} - 解決後的任務物件
140
- */
141
- autoResolve(ours, theirs, strategy = ResolutionStrategy.AUTO_MERGE) {
142
- const conflict = this.detectConflict(ours, theirs);
143
-
144
- if (!conflict.hasConflict) {
145
- return ours; // 無衝突,保留原版本
146
- }
147
-
148
- switch (strategy) {
149
- case ResolutionStrategy.KEEP_OURS:
150
- return this._resolveKeepOurs(ours, theirs);
151
-
152
- case ResolutionStrategy.KEEP_THEIRS:
153
- return this._resolveKeepTheirs(ours, theirs);
154
-
155
- case ResolutionStrategy.AUTO_MERGE:
156
- return this._resolveAutoMerge(ours, theirs, conflict);
157
-
158
- default:
159
- throw new Error(`未知的解決策略: ${strategy}`);
160
- }
161
- }
162
-
163
- /**
164
- * 手動解決介面(CLI)
165
- * @param {Object} ours - 我們的版本
166
- * @param {Object} theirs - 他們的版本
167
- * @returns {Promise<Object>} - 解決後的任務物件
168
- */
169
- async manualResolve(ours, theirs) {
170
- const conflict = this.detectConflict(ours, theirs);
171
-
172
- if (!conflict.hasConflict) {
173
- console.log('✅ 無衝突,保留當前版本');
174
- return ours;
175
- }
176
-
177
- console.log('\n⚠️ 偵測到版本衝突:\n');
178
- console.log(`任務 ID: ${ours.id}`);
179
- console.log(`衝突類型: ${conflict.type}`);
180
- console.log('\n衝突詳情:');
181
- console.log(JSON.stringify(conflict.details, null, 2));
182
-
183
- console.log('\n請選擇解決方式:');
184
- console.log('1. 保留我們的版本 (Keep Ours)');
185
- console.log('2. 保留他們的版本 (Keep Theirs)');
186
- console.log('3. 自動合併 (Auto Merge)');
187
- console.log('4. 取消');
188
-
189
- const choice = await this._getUserChoice(['1', '2', '3', '4']);
190
-
191
- switch (choice) {
192
- case '1':
193
- console.log('✅ 保留我們的版本');
194
- return this._resolveKeepOurs(ours, theirs);
195
-
196
- case '2':
197
- console.log('✅ 保留他們的版本');
198
- return this._resolveKeepTheirs(ours, theirs);
199
-
200
- case '3':
201
- console.log('✅ 自動合併');
202
- return this._resolveAutoMerge(ours, theirs, conflict);
203
-
204
- case '4':
205
- console.log('❌ 已取消');
206
- throw new Error('用戶取消解決衝突');
207
-
208
- default:
209
- throw new Error('無效的選擇');
210
- }
211
- }
212
-
213
- /**
214
- * 解析 Git 衝突標記
215
- * @param {String} content - 包含 Git 衝突標記的文件內容
216
- * @returns {Object} - { ours, theirs }
217
- */
218
- parseGitConflict(content) {
219
- const markers = this.config.GIT_CONFLICT_MARKERS;
220
- const oursStart = content.indexOf(markers.ours);
221
- const separator = content.indexOf(markers.separator);
222
- const theirsEnd = content.indexOf(markers.theirs);
223
-
224
- if (oursStart === -1 || separator === -1 || theirsEnd === -1) {
225
- throw new Error('未找到 Git 衝突標記');
226
- }
227
-
228
- const oursContent = content
229
- .substring(oursStart + markers.ours.length, separator)
230
- .trim();
231
- const theirsContent = content
232
- .substring(separator + markers.separator.length, theirsEnd)
233
- .trim();
234
-
235
- try {
236
- return {
237
- ours: JSON.parse(oursContent),
238
- theirs: JSON.parse(theirsContent),
239
- };
240
- } catch (error) {
241
- throw new Error(`解析 Git 衝突內容失敗: ${error.message}`);
242
- }
243
- }
244
-
245
- // ============================================================================
246
- // 私有方法
247
- // ============================================================================
248
-
249
- /**
250
- * 取得時間戳
251
- */
252
- _getTimestamp(task) {
253
- return task.last_modified_by?.timestamp || task.updated_at || null;
254
- }
255
-
256
- /**
257
- * 比較欄位差異
258
- */
259
- _compareFields(ours, theirs) {
260
- const diffs = [];
261
- const allKeys = new Set([...Object.keys(ours), ...Object.keys(theirs)]);
262
-
263
- for (const key of allKeys) {
264
- if (key === '_version' || key === 'last_modified_by') {
265
- continue; // 跳過已檢查的欄位
266
- }
267
-
268
- const ourValue = ours[key];
269
- const theirValue = theirs[key];
270
-
271
- if (JSON.stringify(ourValue) !== JSON.stringify(theirValue)) {
272
- diffs.push({
273
- field: key,
274
- ours: ourValue,
275
- theirs: theirValue,
276
- });
277
- }
278
- }
279
-
280
- return diffs;
281
- }
282
-
283
- /**
284
- * 解決策略: 保留我們的版本
285
- */
286
- _resolveKeepOurs(ours, theirs) {
287
- return {
288
- ...ours,
289
- _version: (ours._version || 1) + 1, // 版本遞增
290
- last_modified_by: {
291
- name: 'ConflictResolver',
292
- agent_id: 'conflict_resolver',
293
- role: 'system',
294
- timestamp: new Date().toISOString(),
295
- resolution: 'keep_ours',
296
- },
297
- };
298
- }
299
-
300
- /**
301
- * 解決策略: 保留他們的版本
302
- */
303
- _resolveKeepTheirs(ours, theirs) {
304
- return {
305
- ...theirs,
306
- _version: (theirs._version || 1) + 1, // 版本遞增
307
- last_modified_by: {
308
- name: 'ConflictResolver',
309
- agent_id: 'conflict_resolver',
310
- role: 'system',
311
- timestamp: new Date().toISOString(),
312
- resolution: 'keep_theirs',
313
- },
314
- };
315
- }
316
-
317
- /**
318
- * 解決策略: 自動合併
319
- */
320
- _resolveAutoMerge(ours, theirs, conflict) {
321
- const merged = { ...ours };
322
-
323
- // 1. 版本號取最大值 + 1
324
- merged._version = Math.max(ours._version || 1, theirs._version || 1) + 1;
325
-
326
- // 2. 時間戳使用較新的
327
- const ourTime = new Date(this._getTimestamp(ours)).getTime();
328
- const theirTime = new Date(this._getTimestamp(theirs)).getTime();
329
-
330
- if (theirTime > ourTime) {
331
- merged.last_modified_by = theirs.last_modified_by;
332
- }
333
-
334
- // 3. 合併 collaborators(使用 Set 去重)
335
- if (ours.collaborators || theirs.collaborators) {
336
- const collaboratorsSet = new Set([
337
- ...(ours.collaborators || []),
338
- ...(theirs.collaborators || []),
339
- ]);
340
- merged.collaborators = Array.from(collaboratorsSet);
341
- }
342
-
343
- // 4. 合併 keywords
344
- if (ours.keywords || theirs.keywords) {
345
- const keywordsSet = new Set([
346
- ...(ours.keywords || []),
347
- ...(theirs.keywords || []),
348
- ]);
349
- merged.keywords = Array.from(keywordsSet);
350
- }
351
-
352
- // 5. 合併 dependencies.optional
353
- if (ours.dependencies?.optional || theirs.dependencies?.optional) {
354
- const optionalSet = new Set([
355
- ...(ours.dependencies?.optional || []),
356
- ...(theirs.dependencies?.optional || []),
357
- ]);
358
- merged.dependencies = merged.dependencies || {};
359
- merged.dependencies.optional = Array.from(optionalSet);
360
- }
361
-
362
- // 6. 記錄合併資訊
363
- merged.last_modified_by = {
364
- name: 'ConflictResolver',
365
- agent_id: 'conflict_resolver',
366
- role: 'system',
367
- timestamp: new Date().toISOString(),
368
- resolution: 'auto_merge',
369
- mergedFrom: {
370
- ours: this._getTimestamp(ours),
371
- theirs: this._getTimestamp(theirs),
372
- },
373
- };
374
-
375
- return merged;
376
- }
377
-
378
- /**
379
- * CLI 用戶輸入
380
- */
381
- async _getUserChoice(validChoices) {
382
- const rl = readline.createInterface({
383
- input: process.stdin,
384
- output: process.stdout,
385
- });
386
-
387
- return new Promise((resolve) => {
388
- const ask = () => {
389
- rl.question('\n請輸入選項 (1-4): ', (answer) => {
390
- if (validChoices.includes(answer.trim())) {
391
- rl.close();
392
- resolve(answer.trim());
393
- } else {
394
- console.log('❌ 無效的選項,請重新輸入');
395
- ask();
396
- }
397
- });
398
- };
399
- ask();
400
- });
401
- }
402
- }
403
-
404
- // ============================================================================
405
- // CLI 介面
406
- // ============================================================================
407
-
408
- /**
409
- * CLI 執行入口
410
- */
411
- async function main() {
412
- const args = process.argv.slice(2);
413
-
414
- if (args.length < 2) {
415
- console.error('用法: node conflict-resolver.js <file1> <file2>');
416
- console.error('範例: node conflict-resolver.js task_ours.json task_theirs.json');
417
- process.exit(1);
418
- }
419
-
420
- const [file1, file2] = args;
421
-
422
- try {
423
- // 讀取兩個版本
424
- const ours = JSON.parse(await fs.readFile(file1, 'utf8'));
425
- const theirs = JSON.parse(await fs.readFile(file2, 'utf8'));
426
-
427
- // 解決衝突
428
- const resolver = new ConflictResolver();
429
- const resolved = await resolver.manualResolve(ours, theirs);
430
-
431
- // 輸出結果
432
- console.log('\n✅ 衝突已解決:\n');
433
- console.log(JSON.stringify(resolved, null, 2));
434
-
435
- // 詢問是否寫入文件
436
- const shouldSave = await resolver._getUserChoice(['y', 'n']);
437
- if (shouldSave === 'y') {
438
- const outputFile = file1.replace('.json', '_resolved.json');
439
- await fs.writeFile(outputFile, JSON.stringify(resolved, null, 2), 'utf8');
440
- console.log(`\n✅ 已寫入: ${outputFile}`);
441
- }
442
- } catch (error) {
443
- console.error(`❌ 錯誤: ${error.message}`);
444
- process.exit(1);
445
- }
446
- }
447
-
448
- // 判斷是否直接執行(非 require)
449
- if (require.main === module) {
450
- main();
451
- }
452
-
453
- // ============================================================================
454
- // 匯出
455
- // ============================================================================
456
-
457
- module.exports = {
458
- ConflictResolver,
459
- ConflictType,
460
- ResolutionStrategy,
461
- };