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,65 +0,0 @@
1
- /**
2
- * CLI Logger Utility
3
- * Provides colored console output with success/error indicators
4
- */
5
-
6
- import chalk from 'chalk';
7
-
8
- export class Logger {
9
- /**
10
- * Display success message with green checkmark
11
- */
12
- static success(message: string): void {
13
- console.log(chalk.green('✓'), message);
14
- }
15
-
16
- /**
17
- * Display error message with red cross
18
- */
19
- static error(message: string): void {
20
- console.log(chalk.red('✗'), message);
21
- }
22
-
23
- /**
24
- * Display info message
25
- */
26
- static info(message: string): void {
27
- console.log(chalk.blue('ℹ'), message);
28
- }
29
-
30
- /**
31
- * Display warning message
32
- */
33
- static warn(message: string): void {
34
- console.log(chalk.yellow('⚠'), message);
35
- }
36
-
37
- /**
38
- * Display section header
39
- */
40
- static header(message: string): void {
41
- console.log('\n' + chalk.bold.cyan(message));
42
- }
43
-
44
- /**
45
- * Display key-value pair
46
- */
47
- static field(key: string, value: any): void {
48
- console.log(chalk.gray(` ${key}:`), chalk.white(value));
49
- }
50
-
51
- /**
52
- * Display data record in formatted way
53
- */
54
- static record(id: string, fields: Record<string, any>): void {
55
- console.log(chalk.cyan(`\n ${id}`));
56
- Object.entries(fields).forEach(([key, value]) => {
57
- const displayValue = Array.isArray(value)
58
- ? value.join(', ')
59
- : typeof value === 'object'
60
- ? JSON.stringify(value)
61
- : String(value);
62
- console.log(chalk.gray(` ${key}:`), chalk.white(displayValue));
63
- });
64
- }
65
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * .matrix Parser & Serializer
3
- * @version 1.0.0
4
- * @description Core library for parsing and serializing .matrix format files
5
- */
6
-
7
- export { MatrixParser } from './parser';
8
- export { MatrixSerializer } from './serializer';
9
- export { MatrixValidator } from './validator';
10
-
11
- export * from './abbreviations';
12
-
13
- export type {
14
- MatrixFile,
15
- MetaSection,
16
- IndexSection,
17
- DataSection,
18
- DataRecord,
19
- ParseResult,
20
- ParseError,
21
- ValidationResult,
22
- SerializeOptions,
23
- ParseOptions,
24
- } from '../types';
25
-
26
- // Convenience functions
27
- import { MatrixParser } from './parser';
28
- import { MatrixSerializer } from './serializer';
29
- import { MatrixValidator } from './validator';
30
- import type { MatrixFile, ParseOptions, SerializeOptions } from '../types';
31
-
32
- /**
33
- * Parse .matrix file content
34
- * @param content .matrix file content
35
- * @param options Parse options
36
- * @returns Parse result
37
- */
38
- export function parse(content: string, options?: ParseOptions) {
39
- const parser = new MatrixParser(options);
40
- return parser.parse(content);
41
- }
42
-
43
- /**
44
- * Serialize MatrixFile to .matrix format
45
- * @param data MatrixFile object
46
- * @param options Serialize options
47
- * @returns .matrix file content
48
- */
49
- export function serialize(data: MatrixFile, options?: SerializeOptions): string {
50
- const serializer = new MatrixSerializer(options);
51
- return serializer.serialize(data);
52
- }
53
-
54
- /**
55
- * Validate .matrix file syntax
56
- * @param content .matrix file content
57
- * @returns Validation result
58
- */
59
- export function validate(content: string) {
60
- const validator = new MatrixValidator();
61
- return validator.validate(content);
62
- }
@@ -1,165 +0,0 @@
1
- /**
2
- * Tag Indexer - Build inverted index for tags
3
- * Maps tags to rule IDs for efficient tag-based queries
4
- */
5
-
6
- import type { MatrixFile, DataRecord } from '../../types';
7
- import * as fs from 'fs';
8
- import * as path from 'path';
9
-
10
- export interface TagIndex {
11
- [tag: string]: string[]; // tag -> rule_ids
12
- }
13
-
14
- export interface TagStats {
15
- tag: string;
16
- count: number;
17
- ruleIds: string[];
18
- }
19
-
20
- export class TagIndexer {
21
- private index: TagIndex = {};
22
-
23
- /**
24
- * Build index from MatrixFile
25
- */
26
- public buildIndex(matrixFile: MatrixFile): void {
27
- this.index = {};
28
-
29
- if (!matrixFile.data) return;
30
-
31
- for (const record of matrixFile.data.records) {
32
- const tags = this.extractTags(record);
33
-
34
- for (const tag of tags) {
35
- if (!this.index[tag]) {
36
- this.index[tag] = [];
37
- }
38
- this.index[tag].push(record.id);
39
- }
40
- }
41
- }
42
-
43
- /**
44
- * Extract all tags from a record
45
- * Supports: source, category, priority, domain, and custom tags
46
- */
47
- private extractTags(record: DataRecord): string[] {
48
- const tags: string[] = [];
49
- const fields = record.fields;
50
-
51
- // Source tags (e.g., "source:TASK_001")
52
- if (fields.src || fields.source) {
53
- tags.push(`source:${fields.src || fields.source}`);
54
- }
55
-
56
- // Category tags (e.g., "category:feature")
57
- if (fields.cat || fields.category) {
58
- tags.push(`category:${fields.cat || fields.category}`);
59
- }
60
-
61
- // Priority tags (e.g., "priority:P0")
62
- if (fields.p || fields.priority) {
63
- tags.push(`priority:${fields.p || fields.priority}`);
64
- }
65
-
66
- // Domain tags (e.g., "domain:auth")
67
- if (fields.dom || fields.domain) {
68
- tags.push(`domain:${fields.dom || fields.domain}`);
69
- }
70
-
71
- // Status tags (e.g., "status:completed")
72
- if (fields.st || fields.status) {
73
- tags.push(`status:${fields.st || fields.status}`);
74
- }
75
-
76
- // Custom tags (e.g., "#feature", "#bug")
77
- if (fields.tags && Array.isArray(fields.tags)) {
78
- for (const tag of fields.tags) {
79
- tags.push(tag.startsWith('#') ? tag : `#${tag}`);
80
- }
81
- }
82
-
83
- return tags;
84
- }
85
-
86
- /**
87
- * Get rule IDs by tag
88
- */
89
- public getRulesByTag(tag: string): string[] {
90
- return this.index[tag] || [];
91
- }
92
-
93
- /**
94
- * Get all tags
95
- */
96
- public getAllTags(): string[] {
97
- return Object.keys(this.index);
98
- }
99
-
100
- /**
101
- * Get tag statistics (sorted by count descending)
102
- */
103
- public getTagStats(): TagStats[] {
104
- return Object.entries(this.index)
105
- .map(([tag, ruleIds]) => ({
106
- tag,
107
- count: ruleIds.length,
108
- ruleIds,
109
- }))
110
- .sort((a, b) => b.count - a.count);
111
- }
112
-
113
- /**
114
- * Get the index
115
- */
116
- public getIndex(): TagIndex {
117
- return this.index;
118
- }
119
-
120
- /**
121
- * Save index to file
122
- */
123
- public saveToFile(filePath: string): void {
124
- const dir = path.dirname(filePath);
125
- if (!fs.existsSync(dir)) {
126
- fs.mkdirSync(dir, { recursive: true });
127
- }
128
-
129
- fs.writeFileSync(
130
- filePath,
131
- JSON.stringify(this.index, null, 2),
132
- 'utf-8'
133
- );
134
- }
135
-
136
- /**
137
- * Load index from file
138
- */
139
- public loadFromFile(filePath: string): void {
140
- if (!fs.existsSync(filePath)) {
141
- throw new Error(`Index file not found: ${filePath}`);
142
- }
143
-
144
- const content = fs.readFileSync(filePath, 'utf-8');
145
- this.index = JSON.parse(content);
146
- }
147
- }
148
-
149
- /**
150
- * Build and save tag index for a .matrix file
151
- */
152
- export function buildTagIndex(
153
- matrixFile: MatrixFile,
154
- indexPath?: string
155
- ): TagIndexer {
156
- const indexer = new TagIndexer();
157
- indexer.buildIndex(matrixFile);
158
-
159
- // Save to file if path provided
160
- if (indexPath) {
161
- indexer.saveToFile(indexPath);
162
- }
163
-
164
- return indexer;
165
- }
@@ -1,281 +0,0 @@
1
- /**
2
- * .matrix 格式解析器
3
- * @version 1.0.0
4
- */
5
-
6
- import type {
7
- MatrixFile,
8
- MetaSection,
9
- IndexSection,
10
- DataSection,
11
- DataRecord,
12
- ParseResult,
13
- ParseError,
14
- ParseOptions,
15
- } from '../types';
16
- import { expandField, decodeValue, expandTimestamp } from './abbreviations';
17
-
18
- export class MatrixParser {
19
- private options: Required<ParseOptions>;
20
-
21
- constructor(options: ParseOptions = {}) {
22
- this.options = {
23
- strict: options.strict ?? true,
24
- autoFix: options.autoFix ?? false,
25
- validateFields: options.validateFields ?? true,
26
- };
27
- }
28
-
29
- /**
30
- * 解析 .matrix 文件
31
- * @param content .matrix 文件內容
32
- * @returns 解析結果
33
- */
34
- parse(content: string): ParseResult {
35
- try {
36
- const lines = content.split(/\r?\n/).filter(line => line.trim());
37
-
38
- let currentLine = 0;
39
- let meta: MetaSection | null = null;
40
- let index: IndexSection | null = null;
41
- let data: DataSection | null = null;
42
-
43
- // 跳過註釋行
44
- while (currentLine < lines.length && lines[currentLine].trim().startsWith('#')) {
45
- currentLine++;
46
- }
47
-
48
- // 解析 @meta
49
- if (currentLine >= lines.length || !lines[currentLine].startsWith('@meta')) {
50
- return this.error('E001', 'Missing required section @meta', currentLine + 1, 1);
51
- }
52
- meta = this.parseMeta(lines[currentLine], currentLine + 1);
53
- currentLine++;
54
-
55
- // 解析 @index
56
- if (currentLine >= lines.length || !lines[currentLine].startsWith('@index')) {
57
- return this.error('E001', 'Missing required section @index', currentLine + 1, 1);
58
- }
59
- index = this.parseIndex(lines[currentLine], currentLine + 1);
60
- currentLine++;
61
-
62
- // 解析 @data (可選)
63
- if (currentLine < lines.length && lines[currentLine].startsWith('@data')) {
64
- currentLine++;
65
- data = this.parseData(lines.slice(currentLine), currentLine + 1);
66
- }
67
-
68
- const result: MatrixFile = {
69
- meta: meta!,
70
- index: index!,
71
- };
72
-
73
- if (data) {
74
- result.data = data;
75
- }
76
-
77
- return {
78
- success: true,
79
- data: result,
80
- };
81
- } catch (error) {
82
- if (this.options.strict) {
83
- throw error;
84
- }
85
- return {
86
- success: false,
87
- error: error as ParseError,
88
- };
89
- }
90
- }
91
-
92
- /**
93
- * 解析 @meta 行
94
- */
95
- private parseMeta(line: string, lineNumber: number): MetaSection {
96
- const match = line.match(/^@meta\s+\|(.+)\|$/);
97
- if (!match) {
98
- throw this.errorObj('E003', 'Invalid @meta format', lineNumber, 1, '@meta |...fields...|', line);
99
- }
100
-
101
- const fieldsStr = match[1];
102
- const fields: MetaSection = { v: '', c: '' };
103
-
104
- const fieldPairs = fieldsStr.split('|').filter(f => f.trim());
105
- for (const pair of fieldPairs) {
106
- const [key, value] = pair.split('=').map(s => s.trim());
107
- if (!key || value === undefined) {
108
- throw this.errorObj('E004', `Invalid field format: ${pair}`, lineNumber, 1);
109
- }
110
- fields[key] = value;
111
- }
112
-
113
- // 驗證必要欄位
114
- if (!fields.v || !fields.c) {
115
- throw this.errorObj('E005', '@meta must contain v (version) and c (category)', lineNumber, 1);
116
- }
117
-
118
- return fields;
119
- }
120
-
121
- /**
122
- * 解析 @index 行
123
- */
124
- private parseIndex(line: string, lineNumber: number): IndexSection {
125
- const match = line.match(/^@index\s+\|(.+)\|$/);
126
- if (!match) {
127
- throw this.errorObj('E003', 'Invalid @index format', lineNumber, 1, '@index |...fields...|', line);
128
- }
129
-
130
- const fieldsStr = match[1];
131
- const fields: IndexSection = {};
132
-
133
- const fieldPairs = fieldsStr.split('|').filter(f => f.trim());
134
- for (const pair of fieldPairs) {
135
- const [key, value] = pair.split('=').map(s => s.trim());
136
- if (!key || value === undefined) {
137
- throw this.errorObj('E004', `Invalid field format: ${pair}`, lineNumber, 1);
138
- }
139
- fields[key] = this.parseValue(value);
140
- }
141
-
142
- return fields;
143
- }
144
-
145
- /**
146
- * 解析 @data 層
147
- */
148
- private parseData(lines: string[], startLine: number): DataSection {
149
- const records: DataRecord[] = [];
150
-
151
- for (let i = 0; i < lines.length; i++) {
152
- const line = lines[i].trim();
153
- if (!line) continue;
154
-
155
- const match = line.match(/^([^|]+)\|(.+)\|$/);
156
- if (!match) {
157
- if (this.options.strict) {
158
- throw this.errorObj('E003', `Invalid data line format`, startLine + i, 1, 'id|field=value|...', line);
159
- }
160
- continue;
161
- }
162
-
163
- const id = match[1].trim();
164
- const fieldsStr = match[2];
165
-
166
- const fields: Record<string, any> = {};
167
- const fieldPairs = fieldsStr.split('|').filter(f => f.trim());
168
-
169
- for (const pair of fieldPairs) {
170
- const [key, value] = pair.split('=').map(s => s.trim());
171
- if (!key || value === undefined) {
172
- if (this.options.strict) {
173
- throw this.errorObj('E004', `Invalid field format: ${pair}`, startLine + i, 1);
174
- }
175
- continue;
176
- }
177
-
178
- // 展開欄位名
179
- const expandedKey = this.options.validateFields ? expandField(key) : key;
180
- // 解碼值
181
- fields[expandedKey] = this.parseValue(value, key);
182
- }
183
-
184
- records.push({ id, fields });
185
- }
186
-
187
- return { records };
188
- }
189
-
190
- /**
191
- * 解析值(自動判斷類型)
192
- */
193
- private parseValue(value: string, fieldKey?: string): any {
194
- // 布林值
195
- if (value === '1' || value === 'true') return true;
196
- if (value === '0' || value === 'false') return false;
197
-
198
- // 數字
199
- if (/^-?\d+(\.\d+)?$/.test(value)) {
200
- return value.includes('.') ? parseFloat(value) : parseInt(value, 10);
201
- }
202
-
203
- // 百分比
204
- if (value.endsWith('%')) {
205
- return parseFloat(value.slice(0, -1));
206
- }
207
-
208
- // 時長 (45m, 2h, 3d)
209
- if (/^\d+[smhdw]$/.test(value)) {
210
- return value;
211
- }
212
-
213
- // 時間戳 (260207-0530)
214
- if (/^\d{6}-\d{4}$/.test(value)) {
215
- return this.options.autoFix ? expandTimestamp(value) : value;
216
- }
217
-
218
- // 列表 (T120,T121)
219
- if (value.includes(',') && !value.includes(';')) {
220
- return value.split(',').map(s => s.trim());
221
- }
222
-
223
- // 任務組 (T123,st=P;T124,st=C)
224
- if (value.includes(';')) {
225
- return value.split(';').map(item => {
226
- const parts = item.split(',').map(s => s.trim());
227
- const taskId = parts[0];
228
- const subFields: Record<string, any> = {};
229
- for (let i = 1; i < parts.length; i++) {
230
- const [k, v] = parts[i].split('=');
231
- if (k && v) {
232
- subFields[k.trim()] = this.parseValue(v.trim(), k.trim());
233
- }
234
- }
235
- return { id: taskId, ...subFields };
236
- });
237
- }
238
-
239
- // 值代碼解碼
240
- if (fieldKey) {
241
- const decodedValue = decodeValue(fieldKey, value);
242
- if (decodedValue !== value) {
243
- return decodedValue;
244
- }
245
- }
246
-
247
- // 純文本
248
- return value;
249
- }
250
-
251
- /**
252
- * 建立錯誤物件
253
- */
254
- private errorObj(
255
- code: string,
256
- message: string,
257
- line?: number,
258
- column?: number,
259
- expected?: string,
260
- got?: string
261
- ): ParseError {
262
- return { code, message, line, column, expected, got };
263
- }
264
-
265
- /**
266
- * 建立錯誤結果
267
- */
268
- private error(
269
- code: string,
270
- message: string,
271
- line?: number,
272
- column?: number,
273
- expected?: string,
274
- got?: string
275
- ): ParseResult {
276
- return {
277
- success: false,
278
- error: this.errorObj(code, message, line, column, expected, got),
279
- };
280
- }
281
- }