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,119 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * lease-release.js -- Session lease release (Multi-Ansuz M0, TASK_1757)
4
- * Piggybacked onto Stop + SessionEnd hook chains in .claude/settings.json.
5
- * Releases the session lease so peers see this stream as gone.
6
- *
7
- * TASK_1763 (BUG-1 + BUG-2 fix):
8
- * BUG-2: Resolve own lease via per-session mapping (hmap_<convId>.json) keyed by
9
- * conversation id (transcript_path basename), not stdin session_id which rotates
10
- * on compact/resume.
11
- *
12
- * TASK_1763 AMEND (SessionEnd correctness):
13
- * Release paths:
14
- * 1. SessionEnd hook (PRIMARY): fired by Claude Code harness on graceful termination
15
- * (clear | resume | logout | prompt_input_exit | bypass_permissions_disabled | other).
16
- * At this point the harness is still alive (graceful), so ppid-alive guard MUST NOT
17
- * apply here. We release unconditionally.
18
- * 2. Stop hook + ppid dead (BACKSTOP): Stop fires at end of every assistant turn.
19
- * If ppid is still alive this is a turn-end event -- skip release.
20
- * If ppid is dead this is an unhandled session termination -- release.
21
- * 3. Heartbeat staleness (CRASH BACKSTOP): handled by stream-lease.js GC; not here.
22
- *
23
- * TASK_1766 (BUG-8 fix): use shared _session-identity.js helper for convId resolution.
24
- * resolveOwnBinding(convId) -> hmap -> scratch (NOT current_stream, single-slot bug).
25
- * Headless child sessions (no transcript_path) -> convId=null -> no-op (BUG-10 guard).
26
- *
27
- * Graceful degradation: missing stdin, missing mapping, or missing lease -> no-op.
28
- * MUST be absolutely silent on any error. MUST NOT break the prompt path.
29
- */
30
- 'use strict';
31
- try {
32
- var fs = require('fs');
33
- var path = require('path');
34
- var cp = require('child_process');
35
- var d = process.env.CLAUDE_PROJECT_DIR || process.cwd();
36
-
37
- // Resolve stream-lease.js path via KENAZ_SOURCE_DIR or walk-up
38
- var kenazSrc = process.env.KENAZ_SOURCE_DIR;
39
- var slPath = null;
40
- if (kenazSrc) { var c = path.join(kenazSrc, '.specialist/tools/stream-lease.js'); if (fs.existsSync(c)) slPath = c; }
41
- if (!slPath) { var c2 = path.join(d, '.specialist/tools/stream-lease.js'); if (fs.existsSync(c2)) slPath = c2; }
42
- if (!slPath) process.exit(0);
43
-
44
- // Resolve _session-identity.js helper
45
- var identPath = path.join(__dirname, '_session-identity.js');
46
- if (!fs.existsSync(identPath)) process.exit(0);
47
- var ident = require(identPath);
48
-
49
- // --- Step 1: Read stdin FIRST (before any guard), extract hook_event_name + transcript_path ---
50
- var hookEventName = null;
51
- var stdinData = null;
52
- var source = null;
53
- try {
54
- var stdinRaw = fs.readFileSync(0, 'utf8');
55
- stdinData = JSON.parse(stdinRaw);
56
- if (stdinData) {
57
- hookEventName = stdinData.hook_event_name ? String(stdinData.hook_event_name) : null;
58
- source = stdinData.source ? String(stdinData.source) : null;
59
- }
60
- } catch (_e) { /* stdin unavailable or non-JSON -- treat as Stop backstop path */ }
61
-
62
- // TASK_1766 (BUG-10): resolve convId via transcript_path. Headless child sessions
63
- // have no transcript_path -> convId=null -> complete no-op (cannot touch any lease).
64
- var convId = ident.resolveConvId(stdinData);
65
-
66
- // --- Step 2: Route by hook_event_name ---
67
- var isSessionEnd = (hookEventName === 'SessionEnd');
68
- // TASK_1764 (BUG-6): SessionEnd fires on resume/clear/compact -- conversation still alive.
69
- // Only release on actual session termination (logout / prompt_input_exit / bypass_permissions_disabled / other).
70
- var SKIP_SOURCES = ['resume', 'clear', 'compact'];
71
- if (isSessionEnd && source && SKIP_SOURCES.indexOf(source) !== -1) {
72
- // Conversation continues; do NOT release lease or unlink hmap.
73
- process.exit(0);
74
- }
75
-
76
- if (!isSessionEnd) {
77
- // Stop (or unknown / no stdin): apply ppid-alive guard as backstop.
78
- // If harness (ppid) is alive, this is a turn-end Stop -- skip release.
79
- // Only release when ppid is dead (unhandled termination).
80
- var ppid = process.ppid;
81
- if (ppid && ppid > 0) {
82
- try {
83
- process.kill(ppid, 0); // throws if dead
84
- // ppid alive -> turn-end Stop. Do NOT release.
85
- process.exit(0);
86
- } catch (e) {
87
- if (e.code === 'EPERM') process.exit(0); // alive, no permission -> do not release
88
- // ESRCH = dead -> fall through to release
89
- }
90
- }
91
- }
92
- // SessionEnd path: harness is alive (graceful exit in progress) -- skip ppid guard entirely.
93
-
94
- // --- Step 3: TASK_1766 BUG-8 fix: resolve own boot sid via hmap/scratch keyed by convId ---
95
- // Key = conversation id (transcript_path basename) -- stable across compact/resume.
96
- // resolveOwnBinding does NOT fall back to current_stream.json (single-slot bug).
97
- var sessionsDir = path.join(d, '.kenaz', 'specialist', 'sessions');
98
- var bootSid = null;
99
-
100
- if (convId) {
101
- var binding = ident.resolveOwnBinding(convId, sessionsDir);
102
- bootSid = binding.bootSid;
103
- }
104
-
105
- // TASK_1764 (BUG-7): If SessionEnd and no hmap/scratch mapping -> no-op.
106
- // TASK_1766 (BUG-10): headless child (convId=null) also falls here -> no-op.
107
- if (isSessionEnd && !bootSid) process.exit(0);
108
- // Fallback for Stop backstop path: no convId (no transcript_path) -> no-op.
109
- if (!bootSid) process.exit(0);
110
-
111
- // --- Step 4: Release the lease ---
112
- cp.execFileSync(process.execPath, [slPath, 'release', '--session-id='+bootSid], { timeout: 2000 });
113
-
114
- // --- Step 5: Cleanup mapping file and scratch file (best-effort) ---
115
- if (convId) {
116
- try { fs.unlinkSync(path.join(sessionsDir, 'hmap_' + convId + '.json')); } catch (_e) {}
117
- try { fs.unlinkSync(path.join(sessionsDir, 'scratch_' + convId + '.json')); } catch (_e) {}
118
- }
119
- } catch (e) { /* absolutely silent */ }
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * lease-touch.js -- Heartbeat piggyback hook (Multi-Ansuz M0, TASK_1757; M1.5, TASK_1761)
4
- * Piggybacked onto UserPromptSubmit hook chain in .claude/settings.json.
5
- * Touches the session lease to update heartbeat_at.
6
- * M1.5: On each touch, if lease.pid is dead or differs from process.ppid (harness pid),
7
- * refresh the anchor by passing --pid=<process.ppid>. Self-heals durable anchor
8
- * within one prompt of boot.
9
- * TASK_1763 (BUG-2 fix): Per-session identity via per-session hmap keyed by conversation id.
10
- * TASK_1764 AMEND: hmap key = transcript_path basename (convId), stable across compact/resume.
11
- * TASK_1766 (BUG-8 fix): First-touch bind reads scratch_<convId>.json (written by register)
12
- * instead of current_stream.json (single-slot, overwritten by last registrant).
13
- * Uses shared _session-identity.js helper: resolveConvId + resolveOwnBinding.
14
- * Headless/child sessions (no transcript_path) -> no scratch -> full no-op.
15
- * MUST be absolutely silent on any error -- hooks must never break the prompt path.
16
- */
17
- 'use strict';
18
- try {
19
- var fs = require('fs');
20
- var path = require('path');
21
- var cp = require('child_process');
22
- var d = process.env.CLAUDE_PROJECT_DIR || process.cwd();
23
-
24
- // Resolve stream-lease.js path via KENAZ_SOURCE_DIR or walk-up
25
- var slPath = null;
26
- var kenazSrc = process.env.KENAZ_SOURCE_DIR;
27
- if (kenazSrc) { var c = path.join(kenazSrc, '.specialist/tools/stream-lease.js'); if (fs.existsSync(c)) slPath = c; }
28
- if (!slPath) { var c2 = path.join(d, '.specialist/tools/stream-lease.js'); if (fs.existsSync(c2)) slPath = c2; }
29
- if (!slPath) process.exit(0);
30
-
31
- // Resolve _session-identity.js helper (same dir as this hook)
32
- var identPath = path.join(__dirname, '_session-identity.js');
33
- if (!fs.existsSync(identPath)) process.exit(0);
34
- var ident = require(identPath);
35
-
36
- // TASK_1764 AMEND + TASK_1766: resolve convId from transcript_path (stable across compact/resume).
37
- // No transcript_path (headless dispatch): full no-op -- do not touch any lease.
38
- var stdinData = null;
39
- try { stdinData = JSON.parse(fs.readFileSync(0, 'utf8')); } catch (_e) {}
40
- var convId = ident.resolveConvId(stdinData);
41
- if (!convId) process.exit(0); // headless/child -- no-op
42
-
43
- var sessionsDir = path.join(d, '.kenaz', 'specialist', 'sessions');
44
- var binding = ident.resolveOwnBinding(convId, sessionsDir);
45
- var bootSid = binding.bootSid;
46
- var bindSource = binding.source;
47
-
48
- if (!bootSid) {
49
- // No scratch and no hmap for this convId.
50
- // BUG-10 guard: foreign/headless child sessions also have no scratch -> no-op.
51
- // Do NOT fall back to current_stream.json (that is the single-slot BUG-8).
52
- process.exit(0);
53
- }
54
-
55
- // If resolved from scratch (first touch): promote to hmap for subsequent touches.
56
- if (bindSource === 'scratch') {
57
- var mappingFile = path.join(sessionsDir, 'hmap_' + convId + '.json');
58
- try {
59
- if (!fs.existsSync(sessionsDir)) fs.mkdirSync(sessionsDir, { recursive: true });
60
- fs.writeFileSync(mappingFile, JSON.stringify({
61
- conversation_id: convId,
62
- boot_sid: bootSid,
63
- bound_at: new Date().toISOString()
64
- }, null, 2), 'utf8');
65
- } catch (_e2) {}
66
- }
67
-
68
- // M1.5 (TASK_1761): determine if anchor refresh is needed.
69
- // process.ppid inside this hook = the harness pid (durable for the session lifetime).
70
- var ppid = process.ppid;
71
- var needsAnchorRefresh = false;
72
- try {
73
- var sl = require(slPath);
74
- var lease = sl.readLease(bootSid);
75
- if (lease) {
76
- var pidAlive = sl.isPidAlive(lease.pid);
77
- if (!pidAlive || lease.pid !== ppid) needsAnchorRefresh = true;
78
- }
79
- } catch (_e) { /* if readLease fails, do not refresh */ }
80
- var touchArgs = [slPath, 'touch', '--session-id='+bootSid];
81
- if (needsAnchorRefresh && ppid && ppid > 0) touchArgs.push('--pid='+ppid);
82
- // TASK_1983 (R1): CLAUDE_PROJECT_DIR (`d`, resolved above) is this hook's live
83
- // signal of which project the session is actually working in right now --
84
- // self-heals lease.project_path on every prompt (register only sets it once at boot).
85
- // TASK_2218: UNLESS this session is explicitly pinned to a different project
86
- // (/Ansuz [專案: X] or --project-path X, pinned by ansuz-session-pin.js under
87
- // this turn's REAL session_id) -- the self-heal was overwriting a pinned
88
- // session's lease.project_path with the cwd (kenaz-core) on every single
89
- // turn, which is exactly the field report's bug: the session's own lease
90
- // never reflected the project it was actually bound to.
91
- var pinnedProjectPath = null;
92
- try { pinnedProjectPath = require('./_session-pin').lookupSessionPin(d, stdinData && stdinData.session_id); } catch (_e3) {}
93
- if (pinnedProjectPath) touchArgs.push('--project-path='+pinnedProjectPath);
94
- else if (d) touchArgs.push('--project-path='+d);
95
- cp.execFileSync(process.execPath, touchArgs, { timeout: 2000 });
96
- } catch (e) { /* absolutely silent */ }
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
- // reflex-feedback.js — RETIRED (TASK_2348). The reflex system was removed (measured zero benefit).
3
- // This no-op stays so user-level ~/.claude/settings.json entries that still point here exit 0
4
- // instead of erroring; the manifest lists it under `retired`, so install-claude-hooks sweeps them.
5
- process.exit(0);
@@ -1,49 +0,0 @@
1
- # Session Start Hook - 显示 Command 选择菜单
2
- # 当新 session 启动时,提示 Claude 显示可用的 Agent 指令供用户选择
3
-
4
- param()
5
-
6
- # 读取 stdin 获取 session 信息
7
- $input = [Console]::In.ReadToEnd()
8
- $sessionInfo = $input | ConvertFrom-Json -ErrorAction SilentlyContinue
9
-
10
- # 检查是否是新启动(不是 resume)
11
- $source = $sessionInfo.source
12
- if ($source -eq "startup" -or $source -eq "clear") {
13
- # Canary is generated by session.js (buildAssembledPrompt) — not duplicated here.
14
-
15
- # 返回 additionalContext,触发 Claude 显示选择菜单
16
- $menuContext = @"
17
- [SESSION_INIT_TRIGGER]
18
- 新 session 已启动。请立即使用 AskUserQuestion 工具向用户展示 Agent 选择菜单:
19
-
20
- 可用的 Agent 指令:
21
- - /產品 - 需求分析、任务规划、PRD 撰写
22
- - /設計 - UI/UX 设计、设计规范、视觉稿
23
- - /architect - 系统架构设计
24
- - /進度 - 查看开发进度
25
- - /init - 初始化新专案
26
-
27
- 请用 AskUserQuestion 让用户选择要使用的模式,选项包括:
28
- 1. 产品需求分析 (/產品)
29
- 2. UI/UX 设计 (/設計)
30
- 3. Pipeline 开发 (/dev)
31
- 4. 系统架构设计 (/architect)
32
- 5. 自由对话(不使用特定 Agent)
33
-
34
- 用户选择后,自动调用对应的 Skill。
35
- "@
36
-
37
- $additionalContext = $menuContext
38
-
39
- $context = @{
40
- hookSpecificOutput = @{
41
- hookEventName = "SessionStart"
42
- additionalContext = $additionalContext
43
- }
44
- } | ConvertTo-Json -Depth 10 -Compress
45
-
46
- Write-Output $context
47
- }
48
-
49
- exit 0
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Sound Event Hook for Kenaz Dashboard
4
- *
5
- * Triggered by Claude Code hooks (Stop / Notification).
6
- * Reads event JSON from stdin, POSTs to Dashboard API.
7
- * Uses Node.js for reliable cross-platform (Windows/macOS/Linux) support.
8
- *
9
- * Port discovery: tries the Rust HTTP server port range (18080-8084),
10
- * then falls back to Next.js dev server (3000). This handles Docker or
11
- * other services occupying the default port.
12
- */
13
-
14
- const http = require('http');
15
-
16
- // Port candidates: Rust HTTP server range (matches lib.rs max_port_attempts=5), then Next.js dev
17
- const PORTS = process.env.KENAZ_DASHBOARD_URL
18
- ? [new URL(process.env.KENAZ_DASHBOARD_URL).port]
19
- : [18080, 8081, 8082, 8083, 8084, 3000];
20
-
21
- // Hook type passed as CLI argument: node sound-event.js Stop|Notification
22
- const hookType = process.argv[2] || 'unknown';
23
-
24
- const eventMap = {
25
- 'Stop': 'agent.stop',
26
- 'Notification': 'agent.notification',
27
- };
28
- const soundEvent = eventMap[hookType] || `agent.${hookType.toLowerCase()}`;
29
-
30
- // Consume stdin (Claude Code sends JSON, must be read to avoid broken pipe)
31
- process.stdin.resume();
32
- process.stdin.on('end', () => {
33
- const postData = JSON.stringify({ event: soundEvent });
34
- tryPost(PORTS, postData, 0);
35
- });
36
-
37
- // Safety: if stdin never closes, fire after timeout
38
- setTimeout(() => {
39
- process.stdin.emit('end');
40
- }, 100);
41
-
42
- /**
43
- * Try POSTing to each port in sequence. Stop on first success.
44
- */
45
- function tryPost(ports, postData, index) {
46
- if (index >= ports.length) {
47
- process.exit(0); // All ports failed — Dashboard not running
48
- }
49
-
50
- const port = ports[index];
51
- const url = `http://localhost:${port}/api/sound-event`;
52
-
53
- const req = http.request(url, {
54
- method: 'POST',
55
- headers: {
56
- 'Content-Type': 'application/json',
57
- 'Content-Length': Buffer.byteLength(postData),
58
- },
59
- timeout: 500,
60
- }, (res) => {
61
- // Drain response
62
- res.resume();
63
- res.on('end', () => process.exit(0));
64
- });
65
-
66
- req.on('error', () => tryPost(ports, postData, index + 1));
67
- req.on('timeout', () => { req.destroy(); tryPost(ports, postData, index + 1); });
68
- req.write(postData);
69
- req.end();
70
- }
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Sound Event Hook for Kenaz Dashboard
3
- #
4
- # Triggered by Claude Code hooks (Stop / Notification).
5
- # Reads event info from stdin, POSTs to Dashboard API,
6
- # which broadcasts via WebSocket so the frontend plays the sound.
7
- #
8
- # Non-blocking: runs curl in background so it never delays Claude Code.
9
-
10
- # Tauri HTTP server runs on 8080; Next.js dev server on 3000.
11
- DASHBOARD_URL="${KENAZ_DASHBOARD_URL:-http://localhost:8080}"
12
-
13
- # Read hook data from stdin
14
- INPUT=$(cat)
15
-
16
- # Determine event type from the hook_event_name passed by Claude Code
17
- HOOK_EVENT=$(echo "$INPUT" | grep -o '"hook_event_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"hook_event_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
18
-
19
- case "$HOOK_EVENT" in
20
- Stop)
21
- EVENT="agent.stop"
22
- ;;
23
- Notification)
24
- EVENT="agent.notification"
25
- ;;
26
- *)
27
- EVENT="agent.${HOOK_EVENT:-unknown}"
28
- ;;
29
- esac
30
-
31
- # Fire and forget — don't block Claude Code
32
- curl -s -X POST "${DASHBOARD_URL}/api/sound-event" \
33
- -H "Content-Type: application/json" \
34
- -d "{\"event\":\"${EVENT}\"}" \
35
- > /dev/null 2>&1 &
36
-
37
- exit 0
@@ -1,169 +0,0 @@
1
- // stream-delta.js -- UserPromptSubmit hook, Multi-Ansuz M3 (TASK_1760)
2
- // Zero-noise: silent when single-stream or no new other-stream [TASK_X] commits.
3
- // Budget: single git rev-parse + jsonl tail read. Target <300ms typical.
4
- // TASK_1763 (BUG-2 fix): resolve own sid via per-session mapping (hmap_<harness_sid>.json),
5
- // not the singleton current_stream.json. Reads harness session_id from hook stdin JSON.
6
- 'use strict';
7
- const fs = require('fs');
8
- const path = require('path');
9
- const { spawnSync } = require('child_process');
10
- const PROJECT_DIR = process.env.CLAUDE_PROJECT_DIR || process.cwd();
11
-
12
- function resolveSlMod() {
13
- const c = path.join(PROJECT_DIR, '.specialist', 'tools', 'stream-lease.js');
14
- return fs.existsSync(c) ? c : null;
15
- }
16
-
17
- function gitMain(dir) {
18
- const r = spawnSync('git', ['-C', dir, 'rev-parse', 'main'], { encoding: 'utf8', timeout: 5000, windowsHide: true });
19
- return r.status === 0 ? (r.stdout || '').trim() : null;
20
- }
21
-
22
- function tailLines(fp, n) {
23
- try {
24
- return fs.readFileSync(fp, 'utf8').split('\n').filter(Boolean).slice(-n);
25
- } catch (e) { return []; }
26
- }
27
-
28
- function commitsSince(dir, from) {
29
- const r = spawnSync('git', ['-C', dir, 'log', '--oneline', from + '..main'], { encoding: 'utf8', timeout: 5000, windowsHide: true });
30
- if (r.status !== 0) return [];
31
- return (r.stdout || '').trim().split('\n').filter(Boolean).reverse();
32
- }
33
-
34
- function parseTaskId(line) {
35
- const m = line.match(/TASK_(\d+)/i);
36
- return m ? 'TASK_' + m[1] : null;
37
- }
38
-
39
- function normPath(fp) {
40
- return fp.split('\\').join('/').toLowerCase();
41
- }
42
-
43
- function hasOverlap(files, scopePaths) {
44
- if (!Array.isArray(files) || !Array.isArray(scopePaths) || !scopePaths.length) return false;
45
- var nf = files.map(normPath);
46
- return scopePaths.some(function(sp) {
47
- var ns = normPath(sp);
48
- return nf.some(function(f) { return f.startsWith(ns) || ns.startsWith(f); });
49
- });
50
- }
51
-
52
- function lookupEvent(taskId) {
53
- var ep = path.join(PROJECT_DIR, '.formation', '.synapse', 'integration_events.jsonl');
54
- var lines = tailLines(ep, 50);
55
- for (var i = lines.length - 1; i >= 0; i--) {
56
- try { var ev = JSON.parse(lines[i]); if (ev.task_id === taskId) return ev; } catch (e) {}
57
- }
58
- return null;
59
- }
60
-
61
- // TASK_1766 (BUG-9 fix): resolve own boot sid via convId-keyed hmap/scratch.
62
- // Uses shared _session-identity.js helper: resolveConvId(stdinData) -> convId,
63
- // resolveOwnBinding(convId, sessionsDir) -> { bootSid, source }.
64
- // Headless child sessions have no transcript_path -> convId=null -> returns null (no-op).
65
- // Does NOT fall back to current_stream.json (single-slot BUG-8/9 root cause).
66
- function resolveOwnSid(stdinData) {
67
- var identPath = path.join(__dirname, '_session-identity.js');
68
- var ident;
69
- try { ident = require(identPath); } catch (_e) { return null; }
70
- var convId = ident.resolveConvId(stdinData);
71
- if (!convId) return null; // headless/child session -- no-op
72
- var sessionsDir = path.join(PROJECT_DIR, '.kenaz', 'specialist', 'sessions');
73
- var binding = ident.resolveOwnBinding(convId, sessionsDir);
74
- return binding.bootSid || null;
75
- }
76
-
77
- function main() {
78
- var t0 = Date.now();
79
- var slPath = resolveSlMod();
80
- if (!slPath) return;
81
- var sl; try { sl = require(slPath); } catch (e) { return; }
82
- var readAllLeases = sl.readAllLeases;
83
- var readLease = sl.readLease;
84
- var isSessionLive = sl.isSessionLive;
85
- var LEASES_DIR = sl.LEASES_DIR;
86
-
87
- // TASK_1763: read stdin once for harness session_id
88
- var stdinData = null;
89
- try { stdinData = JSON.parse(fs.readFileSync(0, 'utf8')); } catch (_e) {}
90
-
91
- var sid = resolveOwnSid(stdinData);
92
- if (!sid) return;
93
- var own = readLease(sid);
94
- if (!own) return;
95
- var others = readAllLeases().filter(function(l) { return l.session_id !== sid && isSessionLive(l); });
96
- if (!others.length) return;
97
- var cur = gitMain(PROJECT_DIR);
98
- if (!cur) return;
99
- var last = own.last_seen_main_sha || null;
100
- if (last !== cur) {
101
- try {
102
- var upd = Object.assign({}, own, { last_seen_main_sha: cur, heartbeat_at: new Date().toISOString() });
103
- fs.writeFileSync(path.join(LEASES_DIR, sid + '.json'), JSON.stringify(upd, null, 2), 'utf8');
104
- } catch (e) {}
105
- }
106
- if (!last || last === cur) return;
107
- var commits = commitsSince(PROJECT_DIR, last);
108
- if (!commits.length) return;
109
- var otherSids = {};
110
- others.forEach(function(l) { otherSids[l.session_id] = l.label || l.session_id.slice(0, 8); });
111
- var otherTasks = {};
112
- // Primary source: claim marker files (.kenaz/locks/claim_TASK_*.json)
113
- try {
114
- var locksDir = path.join(PROJECT_DIR, '.kenaz', 'locks');
115
- var lockFiles = [];
116
- try { lockFiles = fs.readdirSync(locksDir); } catch (e) {}
117
- lockFiles.forEach(function(fname) {
118
- var m = fname.match(/^claim_(TASK_\d+)\.json$/i);
119
- if (!m) return;
120
- var taskId = m[1].toUpperCase();
121
- try {
122
- var marker = JSON.parse(fs.readFileSync(path.join(locksDir, fname), 'utf8'));
123
- var ownerSid = marker.owner_session;
124
- if (ownerSid && otherSids[ownerSid]) otherTasks[taskId] = otherSids[ownerSid];
125
- } catch (e) {}
126
- });
127
- } catch (e) {}
128
- // Supplementary source: lease.claimed_tasks (union, marker takes priority)
129
- others.forEach(function(l) {
130
- var lbl = l.label || l.session_id.slice(0, 8);
131
- if (Array.isArray(l.claimed_tasks)) l.claimed_tasks.forEach(function(t) {
132
- if (!otherTasks[t]) otherTasks[t] = lbl;
133
- });
134
- });
135
- var relevant = [];
136
- commits.forEach(function(c) {
137
- var tid = parseTaskId(c);
138
- if (tid && otherTasks[tid]) relevant.push({ taskId: tid });
139
- });
140
- if (!relevant.length) return;
141
- var ownScope = Array.isArray(own.scope_leases) ? own.scope_leases : [];
142
- var seen = {}, out = [];
143
- for (var ri = 0; ri < relevant.length && out.length < 2; ri++) {
144
- var taskId = relevant[ri].taskId;
145
- if (seen[taskId]) continue;
146
- seen[taskId] = true;
147
- var ev = lookupEvent(taskId);
148
- var evFiles = ev ? (ev.files || []) : [];
149
- var overlap = hasOverlap(evFiles, ownScope);
150
- var lbl = otherTasks[taskId] || 'unknown';
151
- var ln = '[stream-delta] ' + lbl + ' merged ' + taskId + ' -> main@' + cur.slice(0, 8);
152
- if (overlap) {
153
- var of2 = evFiles.filter(function(f) {
154
- return ownScope.some(function(sp) {
155
- return normPath(f).startsWith(normPath(sp)) || normPath(sp).startsWith(normPath(f));
156
- });
157
- });
158
- ln += '; scope overlap: ' + of2.slice(0, 3).join(', ');
159
- out.push(ln);
160
- out.push(' => re-check: kenaz_lsp_references on ' + of2.slice(0, 2).join(', '));
161
- } else { out.push(ln); }
162
- }
163
- if (out.length) {
164
- process.stdout.write('\n' + out.slice(0, 2).join('\n') + '\n');
165
- }
166
- if (Date.now() - t0 > 500) process.stderr.write('[stream-delta] over budget\n');
167
- }
168
-
169
- try { main(); } catch (e) { /* never throw */ }
@@ -1,3 +0,0 @@
1
- {
2
- "disableAllHooks": true
3
- }