kenaz 0.3.18 → 0.3.20

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 (329) 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__/arms.test.js +41 -0
  30. package/core/.formation/tools/__tests__/diagnose-bug.test.js +10 -0
  31. package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
  32. package/core/.formation/tools/arms.js +48 -0
  33. package/core/.formation/tools/dispatch.js +24 -15
  34. package/core/.formation/tools/kenaz-stats.js +32 -8
  35. package/core/.formation/tools/kenaz-stats.test.js +15 -2
  36. package/core/.formation/tools/loader.js +17 -140
  37. package/core/.formation/tools/post-complete.js +0 -31
  38. package/core/.formation/tools/prompt.js +16 -1
  39. package/core/.formation/tools/prompt.test.js +20 -0
  40. package/core/.rule/INDEX.yaml +0 -18
  41. package/core/.rule/general/agent-workflow.yaml +14 -164
  42. package/core/.rule/general/project-self-containment.yaml +8 -19
  43. package/core/.rule/general/rust-verify-target.yaml +6 -5
  44. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  45. package/core/.specialist/Amelia/capability.yaml +12 -12
  46. package/core/.specialist/Amelia/workflow.yaml +2 -2
  47. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  48. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  49. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  50. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  51. package/core/.specialist/Ansuz/core.yaml +6 -108
  52. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  53. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  54. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  55. package/core/.specialist/Ansuz/rule.yaml +0 -1
  56. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  57. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  58. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  59. package/core/.specialist/tools/ansuz-boot-fast.js +7 -4
  60. package/core/.specialist/tools/ansuz-boot-fast.test.js +10 -3
  61. package/core/.specialist/tools/prompt-files.test.js +1 -0
  62. package/core/.specialist/tools/task-bridge.js +1 -66
  63. package/core/.system/README.md +11 -552
  64. package/core/.system/collaboration/README.md +10 -174
  65. package/core/CLAUDE.md +1 -6
  66. package/core/KENAZ_CORE_VERSION +1 -1
  67. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  68. package/core/dev/scripts/peer-identity-e2e.js +402 -0
  69. package/core/dev/scripts/peer-identity-e2e.md +47 -0
  70. package/core/dev/scripts/relay-admin.js +94 -0
  71. package/core/dev/scripts/relay-admin.test.js +131 -0
  72. package/core/dev/scripts/run-rust-tests.js +9 -45
  73. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  74. package/core/dev/scripts/verify-target-dir.js +6 -6
  75. package/core/plugins/kenaz/INVENTORY.md +8 -8
  76. package/core/plugins/kenaz/README.md +10 -0
  77. package/core/plugins/kenaz/commands/architect.md +1 -2
  78. package/core/plugins/kenaz/commands/spec.md +1 -1
  79. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  80. package/core/plugins/kenaz/guidance.md +1 -1
  81. package/core/plugins/kenaz/hooks/kenaz-hook.js +2 -1
  82. package/core/plugins/kenaz/hooks/sdk-gate.js +9 -0
  83. package/core/plugins/kenaz/scripts/kenaz.test.js +15 -3
  84. package/core/plugins/kenaz/scripts/sync.js +1 -1
  85. package/core/plugins/kenaz/scripts/ygg.js +8 -0
  86. package/core/plugins/kenaz/scripts/ygg.test.js +72 -0
  87. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  88. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  89. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  90. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  91. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  92. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  93. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  94. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  95. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  96. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  97. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  98. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  99. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  100. package/core/plugins/kenaz-peer/hooks/register.test.ts +32 -0
  101. package/core/plugins/kenaz-peer/hooks/register.ts +9 -0
  102. package/package.json +6 -6
  103. package/core/.claude/commands/archive.md +0 -24
  104. package/core/.claude/commands/init.md +0 -112
  105. package/core/.claude/commands/legacy_dev.md +0 -18
  106. package/core/.claude/commands/product-review.md +0 -131
  107. package/core/.claude/commands/strategy.md +0 -141
  108. package/core/.claude/commands/sunny.md +0 -1
  109. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  110. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  111. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  112. package/core/.claude/hooks/_substrate-paths.js +0 -95
  113. package/core/.claude/hooks/context-check.js +0 -51
  114. package/core/.claude/hooks/fatigue-check.js +0 -52
  115. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  116. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  117. package/core/.claude/hooks/handoff-staleness.js +0 -197
  118. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  119. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  120. package/core/.claude/hooks/lease-release.js +0 -119
  121. package/core/.claude/hooks/lease-touch.js +0 -96
  122. package/core/.claude/hooks/reflex-feedback.js +0 -5
  123. package/core/.claude/hooks/session-init.ps1 +0 -49
  124. package/core/.claude/hooks/sound-event.js +0 -70
  125. package/core/.claude/hooks/sound-event.sh +0 -37
  126. package/core/.claude/hooks/stream-delta.js +0 -169
  127. package/core/.claude/no-hooks.settings.json +0 -3
  128. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  129. package/core/.claude/skills/sunny/SKILL.md +0 -74
  130. package/core/.collaboration/cli/commands/assign.js +0 -39
  131. package/core/.collaboration/cli/commands/claim.js +0 -33
  132. package/core/.collaboration/cli/commands/complete.js +0 -44
  133. package/core/.collaboration/cli/commands/create.js +0 -110
  134. package/core/.collaboration/cli/commands/get.js +0 -83
  135. package/core/.collaboration/cli/commands/index.js +0 -52
  136. package/core/.collaboration/cli/commands/list.js +0 -51
  137. package/core/.collaboration/cli/commands/lock.js +0 -45
  138. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  139. package/core/.collaboration/cli/commands/search.js +0 -61
  140. package/core/.collaboration/cli/commands/stats.js +0 -61
  141. package/core/.collaboration/cli/commands/transfer.js +0 -41
  142. package/core/.collaboration/cli/commands/unlock.js +0 -48
  143. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  144. package/core/.collaboration/cli/formatters/index.js +0 -7
  145. package/core/.collaboration/cli/task-cli.js +0 -46
  146. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  147. package/core/.collaboration/cli/utils/git-user.js +0 -25
  148. package/core/.collaboration/cli/utils/index.js +0 -9
  149. package/core/.collaboration/cli/utils/output.js +0 -10
  150. package/core/.collaboration/config/default.yaml +0 -189
  151. package/core/.collaboration/core/conflict-resolver.js +0 -461
  152. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  153. package/core/.collaboration/core/migrate-legacy.js +0 -260
  154. package/core/.collaboration/docs/API.md +0 -787
  155. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  156. package/core/.collaboration/docs/FAQ.md +0 -695
  157. package/core/.collaboration/docs/MIGRATION.md +0 -804
  158. package/core/.collaboration/docs/examples/README.md +0 -320
  159. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  160. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  161. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  162. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  163. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  164. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  165. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  166. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  167. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  168. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  169. package/core/.failure/pipeline/README.md +0 -95
  170. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  171. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  172. package/core/.failure/tools/check_failures.ps1 +0 -387
  173. package/core/.failure/tools/log_failure.ps1 +0 -474
  174. package/core/.formation/.episode-input.json +0 -10
  175. package/core/.formation/.merge-lock +0 -1
  176. package/core/.formation/lead.yaml +0 -118
  177. package/core/.formation/legacy.bak/designer.yaml +0 -57
  178. package/core/.formation/legacy.bak/pm.yaml +0 -57
  179. package/core/.formation/legacy.bak/qa.yaml +0 -57
  180. package/core/.formation/legacy.bak/review.yaml +0 -62
  181. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  182. package/core/.formation/legacy.bak/sre.yaml +0 -57
  183. package/core/.formation/role-map.yaml +0 -274
  184. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  185. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  186. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  187. package/core/.formation/roles/backend/role.yaml +0 -93
  188. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  189. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  190. package/core/.formation/roles/designer/role.yaml +0 -66
  191. package/core/.formation/roles/developer/role.yaml +0 -75
  192. package/core/.formation/roles/frontend/role.yaml +0 -134
  193. package/core/.formation/roles/incident_response/role.yaml +0 -89
  194. package/core/.formation/roles/qa/role.yaml +0 -89
  195. package/core/.formation/roles/security/role.yaml +0 -87
  196. package/core/.formation/roles/sre/role.yaml +0 -66
  197. package/core/.formation/skills/coordinator.yaml +0 -52
  198. package/core/.formation/solo/diagnosis.yaml +0 -78
  199. package/core/.formation/solo/strategy.yaml +0 -121
  200. package/core/.formation/tests/hello.txt +0 -2
  201. package/core/.formation/tools/coordinator.js +0 -350
  202. package/core/.formation/tools/jev-correction.js +0 -214
  203. package/core/.formation/tools/jev-correction.test.js +0 -178
  204. package/core/.formation/tools/log-reader.js +0 -232
  205. package/core/.formation/tools/revert-daemon-state.js +0 -162
  206. package/core/.formation/tools/test-drift.js +0 -148
  207. package/core/.formation/unit/heimdall.yaml +0 -96
  208. package/core/.formation/unit/plan.yaml +0 -67
  209. package/core/.formation/unit/think.yaml +0 -58
  210. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  211. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  212. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  213. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  214. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  215. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  216. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  217. package/core/.kenaz/runes_TASK_1428.json +0 -57
  218. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  219. package/core/.kenaz/tmp_props.json +0 -1
  220. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  221. package/core/.rule/MECHANIZED.md +0 -61
  222. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  223. package/core/.rule/general/pipeline.yaml +0 -246
  224. package/core/.rule/general/sunny-access-control.yaml +0 -60
  225. package/core/.rule/general/system-invariants.yaml +0 -231
  226. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  227. package/core/.rule/pipeline/auto-update.yaml +0 -282
  228. package/core/.rule/pipeline/task-execution.yaml +0 -365
  229. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  230. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  231. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  232. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  233. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  234. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  235. package/core/.specialist/tools/jev-optional-context.js +0 -107
  236. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  237. package/core/.specialist/tools/memory-action-log.js +0 -839
  238. package/core/.specialist/tools/phase-gate.js +0 -3534
  239. package/core/.specialist/tools/phase-gate.test.js +0 -85
  240. package/core/.specialist/tools/precompute-runner.js +0 -444
  241. package/core/.specialist/tools/rule-engine.js +0 -621
  242. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  243. package/core/.synapse/memory-shared.json.sync +0 -1
  244. package/core/.system/agent-skills/README.md +0 -724
  245. package/core/.system/cli-tools/README.md +0 -724
  246. package/core/.system/cortex/MODULES.md +0 -1046
  247. package/core/.system/dashboard/FRONTEND.md +0 -812
  248. package/core/.system/dashboard/README.md +0 -737
  249. package/core/.system/failure/README.md +0 -723
  250. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  251. package/core/.system/formation/POST_COMPLETE.md +0 -602
  252. package/core/.system/formation/README.md +0 -1094
  253. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  254. package/core/.system/kenaz/README.md +0 -787
  255. package/core/.system/memory/README.md +0 -719
  256. package/core/.system/pipeline/README.md +0 -712
  257. package/core/.system/rule/README.md +0 -794
  258. package/core/.system/sunny/README.md +0 -476
  259. package/core/.system/sunny/RULES.json +0 -89
  260. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  261. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  262. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  263. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  264. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  265. package/core/.system/sunny/teammates/README.md +0 -107
  266. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  267. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  268. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  269. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  270. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  271. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  272. package/core/.system/sunny/tools.json +0 -101
  273. package/core/dev/scripts/cleanup-queue.js +0 -184
  274. package/core/dev/scripts/cleanup_queue.js +0 -86
  275. package/core/dev/scripts/legacy/README.md +0 -39
  276. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  277. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  278. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  279. package/core/dev/scripts/matrix/README.md +0 -310
  280. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  281. package/core/dev/scripts/matrix/package.json +0 -55
  282. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  283. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  284. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  285. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  286. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  287. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  288. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  289. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  290. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  291. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  292. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  293. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  294. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  295. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  296. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  297. package/core/dev/scripts/matrix/src/index.ts +0 -62
  298. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  299. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  300. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  301. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  302. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  303. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  304. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  305. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  306. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  307. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  308. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  309. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  310. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  311. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  312. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  313. package/core/dev/scripts/matrix/types/index.js +0 -8
  314. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  315. package/core/dev/scripts/matrix/types/index.ts +0 -124
  316. package/core/dev/scripts/memory-usage-report.js +0 -152
  317. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  318. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  319. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  320. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  321. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  322. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  323. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  324. package/core/dev/scripts/validate_pipeline.js +0 -197
  325. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  326. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  327. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  328. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  329. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,602 +0,0 @@
1
- # Formation Post-Complete - 任務完成後自動化
2
-
3
- > **[RETIRED CALLERS 2026-10, TASK_2401/2402/2403]** 文中的 legacy-scheduler.js / headless.js 呼叫端已移除,僅留作歷史參考;post-complete.js 本身仍存在。現行派工:`node .formation/tools/dispatch.js --skill=do --task=TASK_XXX --dispatch-mode=subagent`。
4
-
5
- > **專案位置**: `.formation/tools/post-complete.js`
6
- > **系統類型**: Formation Lead 專用工具
7
- > **適用場景**: 任務完成後的自動 Archive + Git 分支管理
8
-
9
- ---
10
-
11
- ## 📋 系統概述
12
-
13
- **Post-Complete** 是 Formation Legacy Scheduler 的核心模組,負責**任務完成後的所有自動化處理**。它是 **Formation Lead 獨享的職責**,subagent 禁止執行 git 操作(Rule 5),確保 git 歷史乾淨、統一管理。
14
-
15
- ### 核心理念
16
-
17
- **「Formation Lead = Scheduler + Post-Complete」**
18
-
19
- ```
20
- Subagent 職責: 完成任務內容(檔案修改、程式碼實作)
21
- ↓
22
- task-api.js complete {task_id}
23
- ↓
24
- Lead 職責: post-complete.js --task={task_id}
25
- ↓
26
- Archive(清理舊任務)+ Git(分支管理)
27
- ```
28
-
29
- **Rule 5(HEADLESS_PREFIX)**:
30
- ```
31
- 禁止執行任何 git 操作(commit、branch、merge、push)。
32
- Git 由 Formation Lead 統一管理。
33
- ```
34
-
35
- 這條規則確保:
36
- - ❌ Subagent 不會建立混亂的 commit 歷史
37
- - ✅ 所有 commit 由 Lead 統一格式化(Co-Authored-By: Claude)
38
- - ✅ 分支管理統一、可預測
39
-
40
- ---
41
-
42
- ## 🎯 兩大核心職責
43
-
44
- ### 1. Archive 清理(雙系統)
45
-
46
- **問題**:已完成任務積累過多,影響 Dashboard 效能、task-api 掃描速度
47
-
48
- **解決方案**:超過 `N` 個已完成任務時,自動將最舊的移到 `archived/` 目錄
49
-
50
- **雙系統支援**:
51
- - **新系統**:`.collaboration/tasks/done/` → `.collaboration/tasks/archived/`
52
- - **舊系統**:`dev/pipeline/completed/` → `dev/pipeline/archived/`
53
-
54
- **規則**:
55
- - 預設保留最新 **10 個**任務(可配置)
56
- - 超過數量時,將最舊的(TASK_ID 最小)移到 `archived/`
57
- - `archived/` 目錄**不被 task-api 和 Dashboard 掃描**(完全隱藏)
58
-
59
- ---
60
-
61
- ### 2. Git 分支管理
62
-
63
- **問題**:統一 git 工作流程,避免 subagent 各自建立 commit 導致混亂
64
-
65
- **解決方案**:由 Formation Lead 統一執行以下流程:
66
-
67
- ```
68
- 1. 建立 task/task_xxx branch ← 從當前分支分岔
69
- 2. Stage + commit 所有變更 ← Co-Authored-By: Claude
70
- 3. 切換/建立用戶分支(git user name,如 {git_user})
71
- 4. Merge task branch 到用戶分支(--no-ff)
72
- 5. 留在用戶分支 ← 用戶手動 merge 到 main
73
- ```
74
-
75
- **Git Flow 圖示**:
76
- ```
77
- ┌─ task/task_205 (commit here)
78
- │
79
- main ─── commits ───┴─ {git_user} (merge here) ─── ...
80
- ↑
81
- Lead 停在這裡
82
- ↓
83
- 用戶手動 merge 到 main
84
- ```
85
-
86
- **為什麼不直接 merge 到 main?**
87
- - 保留用戶對 main 的控制權(可在 merge 前 review)
88
- - 避免自動化工具污染 main 分支
89
- - 用戶分支作為緩衝層,可隨時回退
90
-
91
- ---
92
-
93
- ## ⚙️ 配置參數
94
-
95
- ```javascript
96
- const CONFIG = {
97
- // 新系統 (.collaboration)
98
- COLLAB_DONE_DIR: '.collaboration/tasks/done',
99
- COLLAB_ARCHIVED_DIR: '.collaboration/tasks/archived',
100
-
101
- // 舊系統 (dev/pipeline)
102
- LEGACY_COMPLETED_DIR: 'dev/pipeline/completed',
103
- LEGACY_ARCHIVED_DIR: 'dev/pipeline/archived',
104
-
105
- // Archive 保留數量
106
- DEFAULT_KEEP: 10,
107
- };
108
- ```
109
-
110
- **可在 CLI 覆蓋**:
111
- ```bash
112
- node .formation/tools/post-complete.js --task=TASK_XXX --keep=15
113
- ```
114
-
115
- ---
116
-
117
- ## 🔧 核心功能
118
-
119
- ### 1. Archive 清理
120
-
121
- #### archiveDir(doneDir, archivedDir, keep, dryRun)
122
-
123
- **流程**:
124
- 1. 掃描 `doneDir`,找出所有 `TASK_*.yaml` 檔案
125
- 2. 按 TASK_ID 數字排序(TASK_134 < TASK_135 < ...)
126
- 3. 保留最新 `keep` 個,其餘移到 `archivedDir`
127
- 4. 返回統計資訊:`{ archived: [], kept: [], total }`
128
-
129
- **範例**:
130
- ```javascript
131
- // done/ 目錄有 15 個任務,keep=10
132
- const result = archiveDir('.collaboration/tasks/done', '.collaboration/tasks/archived', 10, false);
133
-
134
- // result = {
135
- // archived: ['TASK_134.yaml', 'TASK_135.yaml', ..., 'TASK_138.yaml'], // 5 個舊任務
136
- // kept: ['TASK_139.yaml', ..., 'TASK_148.yaml'], // 10 個新任務
137
- // total: 15
138
- // }
139
- ```
140
-
141
- #### archiveCheck({ keep, dryRun })
142
-
143
- **雙系統統一介面**:
144
- ```javascript
145
- const result = archiveCheck({ keep: 10, dryRun: false });
146
-
147
- // result = {
148
- // collab: { archived: [...], kept: [...], total: 8 },
149
- // legacy: { archived: [...], kept: [...], total: 12 }
150
- // }
151
- ```
152
-
153
- **輸出範例**:
154
- ```
155
- ── Archive Check ──
156
- ✅ [新系統] done: 8/10 — no archive needed
157
- 📦 [舊系統] Archived 2 tasks (12 → 10):
158
- → TASK_134_api_refactor.yaml
159
- → TASK_135_ui_update.yaml
160
- ```
161
-
162
- ---
163
-
164
- ### 2. Git 分支管理
165
-
166
- #### gitBranchAndMerge({ taskId, message, dryRun })
167
-
168
- **完整流程**:
169
-
170
- ```javascript
171
- const result = gitBranchAndMerge({
172
- taskId: 'TASK_205',
173
- message: '[TASK_205] Custom commit message', // 可選
174
- dryRun: false
175
- });
176
-
177
- // result = {
178
- // taskBranch: 'task/task_205',
179
- // userBranch: '{git_user}',
180
- // originalBranch: '{git_user}',
181
- // committed: true,
182
- // merged: true
183
- // }
184
- ```
185
-
186
- **詳細步驟**:
187
-
188
- #### Step 0: 檢查是否有變更
189
-
190
- ```javascript
191
- if (!hasChanges()) {
192
- console.log('⚠️ No changes to commit');
193
- return result;
194
- }
195
- ```
196
-
197
- 如果 `git status --porcelain` 是空的,直接返回(避免建立空 commit)。
198
-
199
- #### Step 0.5: Stash 未追蹤的髒檔案
200
-
201
- **問題**:某些檔案(如 `.cortex/db/chroma.sqlite3`)可能被 `.gitignore` 排除,但尚未提交,會阻止 `git checkout`。
202
-
203
- **解決方案**:
204
- ```javascript
205
- const stashed = git('stash push -u -m "post-complete: auto-stash before checkout"', { throws: false });
206
- const didStash = stashed !== null && !stashed.includes('No local changes');
207
- ```
208
-
209
- 稍後在新分支上 `git stash pop` 恢復。
210
-
211
- #### Step 1: 建立 task branch
212
-
213
- ```javascript
214
- const taskBranch = `task/${taskId.toLowerCase()}`; // e.g. "task/task_205"
215
-
216
- if (branchExists(taskBranch)) {
217
- git(`checkout ${taskBranch}`);
218
- } else {
219
- git(`checkout -b ${taskBranch}`);
220
- }
221
- ```
222
-
223
- 如果 branch 已存在(如重新執行),直接切換;否則建立新分支。
224
-
225
- #### Step 1.5: 恢復 Stash
226
-
227
- ```javascript
228
- if (didStash) {
229
- git('stash pop', { throws: false });
230
- }
231
- ```
232
-
233
- #### Step 2: Stage + Commit(安全模式)
234
-
235
- **呼叫 `gitAddSafe()`**:
236
-
237
- ```javascript
238
- gitAddSafe(); // 處理 Windows 保留檔名 + 重試機制
239
- execSync(`git commit -m "${commitMsg}\n\nCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"`);
240
- ```
241
-
242
- **Commit Message 格式**:
243
- ```
244
- [TASK_205] task completed
245
-
246
- Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
247
- ```
248
-
249
- 如果 commit 失敗(如沒有實際變更),回到原分支並返回。
250
-
251
- #### Step 3: 切換/建立用戶分支
252
-
253
- ```javascript
254
- const gitUser = getGitUser(); // 從 git config user.email 取得(如 "{git_user}@example.com" → "{git_user}")
255
- const userBranch = gitUser;
256
-
257
- if (branchExists(userBranch)) {
258
- git(`checkout ${userBranch}`);
259
- } else {
260
- // 從 main 建立用戶分支
261
- const baseBranch = branchExists('main') ? 'main' : originalBranch;
262
- git(`checkout -b ${userBranch} ${baseBranch}`);
263
- }
264
- ```
265
-
266
- 用戶分支命名規則:**git user.email 的 @ 前部分**(如 `{git_user}`)
267
-
268
- #### Step 4: Merge task branch 到用戶分支
269
-
270
- ```javascript
271
- git(`merge ${taskBranch} --no-ff -m "Merge ${taskBranch} into ${userBranch}"`);
272
- ```
273
-
274
- 使用 `--no-ff`(no fast-forward)確保產生 merge commit,保留分支歷史。
275
-
276
- **如果有 merge conflict**:
277
- ```javascript
278
- catch (e) {
279
- git('merge --abort', { throws: false });
280
- git(`checkout ${originalBranch}`, { throws: false });
281
- return result; // merged: false
282
- }
283
- ```
284
-
285
- 自動 abort merge,回到原分支,通知用戶手動解決。
286
-
287
- #### Step 5: 留在用戶分支
288
-
289
- ```javascript
290
- console.log(`📌 Now on branch: ${userBranch}`);
291
- console.log(`👉 Review changes, then: git checkout main && git merge ${userBranch}`);
292
- ```
293
-
294
- **不自動 merge 到 main**,讓用戶保留控制權。
295
-
296
- ---
297
-
298
- ### 3. Git 安全工具:gitAddSafe()
299
-
300
- **問題 1:Windows 保留檔名**
301
- - Windows 禁止建立檔名為 `nul`, `con`, `prn`, `aux`, `com1`~`com9`, `lpt1`~`lpt9` 的檔案
302
- - 但某些工具可能意外產生這些空檔(如 `nul.txt`),導致 `git add` 失敗
303
-
304
- **解決方案**:
305
- ```javascript
306
- const WINDOWS_RESERVED = new Set([
307
- 'nul', 'con', 'prn', 'aux',
308
- ...Array.from({ length: 9 }, (_, i) => `com${i + 1}`),
309
- ...Array.from({ length: 9 }, (_, i) => `lpt${i + 1}`),
310
- ]);
311
-
312
- // 掃描專案根目錄
313
- const entries = fs.readdirSync(ROOT);
314
- for (const entry of entries) {
315
- const base = entry.toLowerCase().replace(/\.[^.]*$/, ''); // 移除副檔名
316
- if (WINDOWS_RESERVED.has(base)) {
317
- fs.unlinkSync(fullPath); // 直接刪除
318
- }
319
- }
320
- ```
321
-
322
- **問題 2:SQLite journal 暫存檔**
323
- - Chromadb 使用 SQLite,會產生 `chroma.sqlite3-journal` 暫存檔
324
- - 這些檔案在 `git add` 時可能**被 SQLite 刪除**,導致 `fatal: pathspec 'xxx-journal' did not match any files`
325
-
326
- **解決方案**:重試機制
327
- ```javascript
328
- const MAX_RETRIES = 3;
329
- for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
330
- const result = git('add -A', { throws: false });
331
- if (result !== null) return; // success
332
-
333
- // 失敗,等 500ms 讓暫存檔消失
334
- const wait = Date.now() + 500;
335
- while (Date.now() < wait) { /* busy wait */ }
336
- }
337
-
338
- // 最後一次用 throws: true
339
- git('add -A');
340
- ```
341
-
342
- ---
343
-
344
- ## 🚀 使用方式
345
-
346
- ### 1. CLI 手動呼叫
347
-
348
- ```bash
349
- # 完整流程(archive + git)
350
- node .formation/tools/post-complete.js --task=TASK_205
351
-
352
- # 自訂 commit message
353
- node .formation/tools/post-complete.js --task=TASK_205 --message "[TASK_205] Custom message"
354
-
355
- # 調整保留數量
356
- node .formation/tools/post-complete.js --task=TASK_205 --keep=15
357
-
358
- # 只做 archive(跳過 git)
359
- node .formation/tools/post-complete.js --skip-git
360
-
361
- # 只做 git(跳過 archive)
362
- node .formation/tools/post-complete.js --task=TASK_205 --skip-archive
363
-
364
- # Dry run(模擬執行,不修改檔案/git)
365
- node .formation/tools/post-complete.js --task=TASK_205 --dry-run
366
- ```
367
-
368
- ### 2. JavaScript API(由 Scheduler 自動呼叫)
369
-
370
- ```javascript
371
- const { postComplete } = require('./.formation/tools/post-complete');
372
-
373
- // 由 legacy-scheduler.js 自動呼叫
374
- postComplete({ taskId: 'TASK_205' });
375
-
376
- // 自訂參數
377
- postComplete({
378
- taskId: 'TASK_205',
379
- keep: 15,
380
- skipArchive: false,
381
- skipGit: false,
382
- message: '[TASK_205] Custom commit message'
383
- });
384
- ```
385
-
386
- ---
387
-
388
- ## 🔁 與 Legacy Scheduler 整合
389
-
390
- ### Scheduler 工作流程
391
-
392
- ```javascript
393
- // legacy-scheduler.js 的 runDevAgent 函數
394
-
395
- if (task.agentType === 'lead') {
396
- // Lead-only 任務:Scheduler 自己處理
397
- postComplete({ taskId: task.taskId, message: task.commitMessage });
398
- execSync(`node .collaboration/core/task-api.js complete ${task.taskId}`);
399
- } else {
400
- // 一般任務:派給 subagent
401
- // 1. 調度 Formation Legacy Skill subagent
402
- runWithFormation(task, skillName, config, logger);
403
-
404
- // 2. Subagent 完成任務移動(task-api.js complete)
405
- // (由 subagent 自行執行)
406
-
407
- // 3. Scheduler 執行 post-complete
408
- postComplete({ taskId: task.taskId });
409
- }
410
- ```
411
-
412
- ### 觸發時機
413
-
414
- **自動觸發**(Scheduler):
415
- - 每個任務完成後(subagent 執行 `task-api.js complete` 後)
416
- - Scheduler 自動呼叫 `postComplete({ taskId })`
417
-
418
- **手動觸發**(CLI):
419
- - 用戶手動執行 `node .formation/tools/post-complete.js --task=TASK_XXX`
420
- - 適用於補救(如 subagent 完成但 post-complete 失敗)
421
-
422
- ---
423
-
424
- ## 📊 輸出範例
425
-
426
- ### 成功執行(Archive + Git)
427
-
428
- ```
429
- ⚔️ Post-Complete: TASK_205
430
- Keep: 10 | Archive: true | Git: true | DryRun: false
431
-
432
- ── Archive Check ──
433
- ✅ [新系統] done: 8/10 — no archive needed
434
- 📦 [舊系統] Archived 2 tasks (12 → 10):
435
- → TASK_134_api_refactor.yaml
436
- → TASK_135_ui_update.yaml
437
-
438
- ── Git Branch & Merge ──
439
- ✅ Committed on task/task_205
440
- ✅ Merged task/task_205 → {git_user}
441
- 📌 Now on branch: {git_user}
442
- 👉 Review changes, then: git checkout main && git merge {git_user}
443
-
444
- ── Summary ──
445
- Archive [新]: 0 archived, 8 kept
446
- Archive [舊]: 2 archived, 10 kept
447
- Git: branch=task/task_205 committed=true merged=true
448
- 👉 On branch: {git_user} — merge to main when ready
449
- ```
450
-
451
- ### Dry Run(模擬執行)
452
-
453
- ```
454
- ⚔️ Post-Complete: TASK_205
455
- Keep: 10 | Archive: true | Git: true | DryRun: true
456
-
457
- ── Archive Check ──
458
- [DRY RUN] Would archive 2 tasks from legacy/completed/
459
-
460
- ── Git Branch & Merge ──
461
- [DRY RUN] Would create branch: task/task_205
462
- [DRY RUN] Would commit: [TASK_205] task completed
463
- [DRY RUN] Would merge to: {git_user}
464
-
465
- ── Summary ──
466
- (Dry run - no changes made)
467
- ```
468
-
469
- ### 無變更(Nothing to commit)
470
-
471
- ```
472
- ⚔️ Post-Complete: TASK_205
473
- Keep: 10 | Archive: true | Git: true | DryRun: false
474
-
475
- ── Archive Check ──
476
- ✅ [新系統] done: 8/10 — no archive needed
477
- ✅ [舊系統] completed: 10/10 — no archive needed
478
-
479
- ── Git Branch & Merge ──
480
- ⚠️ No changes to commit
481
-
482
- ── Summary ──
483
- Archive [新]: 0 archived, 8 kept
484
- Archive [舊]: 0 archived, 10 kept
485
- Git: branch=task/task_205 committed=false merged=false
486
- ```
487
-
488
- ### Merge Conflict(衝突)
489
-
490
- ```
491
- ⚔️ Post-Complete: TASK_205
492
- Keep: 10 | Archive: true | Git: true | DryRun: false
493
-
494
- ── Archive Check ──
495
- ✅ [新系統] done: 8/10 — no archive needed
496
- ✅ [舊系統] completed: 10/10 — no archive needed
497
-
498
- ── Git Branch & Merge ──
499
- ✅ Committed on task/task_205
500
- ❌ Merge conflict! Resolve manually.
501
-
502
- ── Summary ──
503
- Archive [新]: 0 archived, 8 kept
504
- Archive [舊]: 0 archived, 10 kept
505
- Git: branch=task/task_205 committed=true merged=false
506
- 👉 Resolve conflict manually, then retry
507
- ```
508
-
509
- ---
510
-
511
- ## 🛡️ 安全性與錯誤處理
512
-
513
- ### 1. Git Stash(防止 checkout 失敗)
514
-
515
- **問題**:`.gitignore` 排除的髒檔案(如 `.cortex/db/chroma.sqlite3`)會阻止 `git checkout`。
516
-
517
- **解決方案**:
518
- ```javascript
519
- // 0.5. Stash untracked dirty files
520
- git('stash push -u -m "post-complete: auto-stash before checkout"');
521
- // ... checkout to task branch ...
522
- git('stash pop'); // 恢復
523
- ```
524
-
525
- ### 2. Windows 保留檔名清理
526
-
527
- **問題**:`nul`, `con`, `prn` 等檔案會導致 `git add` 失敗。
528
-
529
- **解決方案**:掃描並刪除(`gitAddSafe()`)
530
-
531
- ### 3. SQLite Journal 重試機制
532
-
533
- **問題**:暫存檔在 `git add` 時消失,導致 `fatal: pathspec 'xxx-journal' did not match any files`。
534
-
535
- **解決方案**:最多重試 3 次,每次間隔 500ms
536
-
537
- ### 4. Merge Conflict 自動 Abort
538
-
539
- **問題**:自動 merge 可能產生衝突。
540
-
541
- **解決方案**:自動 `git merge --abort`,回到原分支,通知用戶手動解決
542
-
543
- ---
544
-
545
- ## 🔧 Lead-only 任務
546
-
547
- **特殊任務類型**:role 為 `lead` 的任務,由 Scheduler 自己處理(不派給 subagent)
548
-
549
- **範例任務定義**(`TASK_XXX.yaml`):
550
- ```yaml
551
- id: TASK_999
552
- title: "Archive 舊任務到 .memory/"
553
- role: lead # ← 關鍵:role: lead
554
- status: pending
555
- priority: P2
556
- dependencies: []
557
- scope_paths: [".collaboration/tasks/done/"]
558
- requirements:
559
- - "將 done/ 中超過 20 個的舊任務移到 archived/"
560
- acceptance_criteria:
561
- - "done/ 目錄保留最新 10 個任務"
562
- commit_message: "[TASK_999] Archive 舊任務"
563
- ```
564
-
565
- **Scheduler 執行流程**:
566
- ```javascript
567
- if (task.agentType === 'lead') {
568
- // Lead-only 任務:Scheduler 自己處理
569
- postComplete({ taskId: task.taskId, message: task.commitMessage });
570
- execSync(`node .collaboration/core/task-api.js complete ${task.taskId}`);
571
- }
572
- ```
573
-
574
- **適用場景**:
575
- - Archive 清理(單獨執行,不需要 subagent)
576
- - Git branch/merge 操作(Scheduler 專屬)
577
- - 系統維護任務(如清理 log、備份等)
578
-
579
- ---
580
-
581
- ## 🔗 相關文檔
582
-
583
- | 文檔 | 路徑 | 說明 |
584
- |------|------|------|
585
- | **Formation 系統概述** | `.system/formation/README.md` | 陣型選擇指南 |
586
- | **Legacy Scheduler** | `.formation/tools/legacy-scheduler.js` | Scheduler 實作 |
587
- | **Legacy Skills** | `.system/formation/LEGACY_SKILLS.md` | 全角色定義 |
588
- | **Headless Runner** | `.formation/tools/headless.js` | 無頭啟動器 |
589
- | **Task API** | `.collaboration/core/task-api.js` | 任務管理 API |
590
-
591
- ---
592
-
593
- ## 📝 版本歷史
594
-
595
- - **v1.0** (2026-02-18): 初始版本,支援雙系統 Archive + Git 分支管理
596
- - **v1.1** (2026-02-19): 新增 gitAddSafe(Windows 保留檔名 + SQLite journal 重試)
597
- - **v1.2** (2026-02-20): 新增 Git Stash 機制(防止 checkout 失敗)
598
-
599
- ---
600
-
601
- **維護者**: Developer Team
602
- **相關任務**: TASK_218