kenaz 0.3.18 → 0.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) 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__/m1-hmap-convid.test.js +1 -124
  30. package/core/.formation/tools/dispatch.js +1 -1
  31. package/core/.formation/tools/loader.js +17 -140
  32. package/core/.formation/tools/post-complete.js +0 -31
  33. package/core/.rule/INDEX.yaml +0 -18
  34. package/core/.rule/general/agent-workflow.yaml +14 -164
  35. package/core/.rule/general/project-self-containment.yaml +8 -19
  36. package/core/.rule/general/rust-verify-target.yaml +6 -5
  37. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  38. package/core/.specialist/Amelia/capability.yaml +12 -12
  39. package/core/.specialist/Amelia/workflow.yaml +2 -2
  40. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  41. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  42. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  43. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  44. package/core/.specialist/Ansuz/core.yaml +6 -108
  45. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  46. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  47. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  48. package/core/.specialist/Ansuz/rule.yaml +0 -1
  49. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  50. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  51. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  52. package/core/.specialist/tools/prompt-files.test.js +1 -0
  53. package/core/.specialist/tools/task-bridge.js +1 -66
  54. package/core/.system/README.md +11 -552
  55. package/core/.system/collaboration/README.md +10 -174
  56. package/core/CLAUDE.md +1 -6
  57. package/core/KENAZ_CORE_VERSION +1 -1
  58. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  59. package/core/dev/scripts/run-rust-tests.js +9 -45
  60. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  61. package/core/dev/scripts/verify-target-dir.js +6 -6
  62. package/core/plugins/kenaz/INVENTORY.md +8 -8
  63. package/core/plugins/kenaz/commands/architect.md +1 -2
  64. package/core/plugins/kenaz/commands/spec.md +1 -1
  65. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  66. package/core/plugins/kenaz/guidance.md +1 -1
  67. package/core/plugins/kenaz/scripts/sync.js +1 -1
  68. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  69. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  70. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  71. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  72. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  73. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  74. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  75. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  76. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  77. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  78. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  79. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  80. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  81. package/package.json +6 -6
  82. package/core/.claude/commands/archive.md +0 -24
  83. package/core/.claude/commands/init.md +0 -112
  84. package/core/.claude/commands/legacy_dev.md +0 -18
  85. package/core/.claude/commands/product-review.md +0 -131
  86. package/core/.claude/commands/strategy.md +0 -141
  87. package/core/.claude/commands/sunny.md +0 -1
  88. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  89. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  90. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  91. package/core/.claude/hooks/_substrate-paths.js +0 -95
  92. package/core/.claude/hooks/context-check.js +0 -51
  93. package/core/.claude/hooks/fatigue-check.js +0 -52
  94. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  95. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  96. package/core/.claude/hooks/handoff-staleness.js +0 -197
  97. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  98. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  99. package/core/.claude/hooks/lease-release.js +0 -119
  100. package/core/.claude/hooks/lease-touch.js +0 -96
  101. package/core/.claude/hooks/reflex-feedback.js +0 -5
  102. package/core/.claude/hooks/session-init.ps1 +0 -49
  103. package/core/.claude/hooks/sound-event.js +0 -70
  104. package/core/.claude/hooks/sound-event.sh +0 -37
  105. package/core/.claude/hooks/stream-delta.js +0 -169
  106. package/core/.claude/no-hooks.settings.json +0 -3
  107. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  108. package/core/.claude/skills/sunny/SKILL.md +0 -74
  109. package/core/.collaboration/cli/commands/assign.js +0 -39
  110. package/core/.collaboration/cli/commands/claim.js +0 -33
  111. package/core/.collaboration/cli/commands/complete.js +0 -44
  112. package/core/.collaboration/cli/commands/create.js +0 -110
  113. package/core/.collaboration/cli/commands/get.js +0 -83
  114. package/core/.collaboration/cli/commands/index.js +0 -52
  115. package/core/.collaboration/cli/commands/list.js +0 -51
  116. package/core/.collaboration/cli/commands/lock.js +0 -45
  117. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  118. package/core/.collaboration/cli/commands/search.js +0 -61
  119. package/core/.collaboration/cli/commands/stats.js +0 -61
  120. package/core/.collaboration/cli/commands/transfer.js +0 -41
  121. package/core/.collaboration/cli/commands/unlock.js +0 -48
  122. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  123. package/core/.collaboration/cli/formatters/index.js +0 -7
  124. package/core/.collaboration/cli/task-cli.js +0 -46
  125. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  126. package/core/.collaboration/cli/utils/git-user.js +0 -25
  127. package/core/.collaboration/cli/utils/index.js +0 -9
  128. package/core/.collaboration/cli/utils/output.js +0 -10
  129. package/core/.collaboration/config/default.yaml +0 -189
  130. package/core/.collaboration/core/conflict-resolver.js +0 -461
  131. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  132. package/core/.collaboration/core/migrate-legacy.js +0 -260
  133. package/core/.collaboration/docs/API.md +0 -787
  134. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  135. package/core/.collaboration/docs/FAQ.md +0 -695
  136. package/core/.collaboration/docs/MIGRATION.md +0 -804
  137. package/core/.collaboration/docs/examples/README.md +0 -320
  138. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  139. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  140. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  141. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  142. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  143. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  144. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  145. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  146. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  147. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  148. package/core/.failure/pipeline/README.md +0 -95
  149. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  150. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  151. package/core/.failure/tools/check_failures.ps1 +0 -387
  152. package/core/.failure/tools/log_failure.ps1 +0 -474
  153. package/core/.formation/.episode-input.json +0 -10
  154. package/core/.formation/.merge-lock +0 -1
  155. package/core/.formation/lead.yaml +0 -118
  156. package/core/.formation/legacy.bak/designer.yaml +0 -57
  157. package/core/.formation/legacy.bak/pm.yaml +0 -57
  158. package/core/.formation/legacy.bak/qa.yaml +0 -57
  159. package/core/.formation/legacy.bak/review.yaml +0 -62
  160. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  161. package/core/.formation/legacy.bak/sre.yaml +0 -57
  162. package/core/.formation/role-map.yaml +0 -274
  163. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  164. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  165. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  166. package/core/.formation/roles/backend/role.yaml +0 -93
  167. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  168. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  169. package/core/.formation/roles/designer/role.yaml +0 -66
  170. package/core/.formation/roles/developer/role.yaml +0 -75
  171. package/core/.formation/roles/frontend/role.yaml +0 -134
  172. package/core/.formation/roles/incident_response/role.yaml +0 -89
  173. package/core/.formation/roles/qa/role.yaml +0 -89
  174. package/core/.formation/roles/security/role.yaml +0 -87
  175. package/core/.formation/roles/sre/role.yaml +0 -66
  176. package/core/.formation/skills/coordinator.yaml +0 -52
  177. package/core/.formation/solo/diagnosis.yaml +0 -78
  178. package/core/.formation/solo/strategy.yaml +0 -121
  179. package/core/.formation/tests/hello.txt +0 -2
  180. package/core/.formation/tools/coordinator.js +0 -350
  181. package/core/.formation/tools/jev-correction.js +0 -214
  182. package/core/.formation/tools/jev-correction.test.js +0 -178
  183. package/core/.formation/tools/log-reader.js +0 -232
  184. package/core/.formation/tools/revert-daemon-state.js +0 -162
  185. package/core/.formation/tools/test-drift.js +0 -148
  186. package/core/.formation/unit/heimdall.yaml +0 -96
  187. package/core/.formation/unit/plan.yaml +0 -67
  188. package/core/.formation/unit/think.yaml +0 -58
  189. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  190. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  191. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  192. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  193. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  194. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  195. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  196. package/core/.kenaz/runes_TASK_1428.json +0 -57
  197. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  198. package/core/.kenaz/tmp_props.json +0 -1
  199. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  200. package/core/.rule/MECHANIZED.md +0 -61
  201. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  202. package/core/.rule/general/pipeline.yaml +0 -246
  203. package/core/.rule/general/sunny-access-control.yaml +0 -60
  204. package/core/.rule/general/system-invariants.yaml +0 -231
  205. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  206. package/core/.rule/pipeline/auto-update.yaml +0 -282
  207. package/core/.rule/pipeline/task-execution.yaml +0 -365
  208. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  209. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  210. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  211. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  212. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  213. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  214. package/core/.specialist/tools/jev-optional-context.js +0 -107
  215. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  216. package/core/.specialist/tools/memory-action-log.js +0 -839
  217. package/core/.specialist/tools/phase-gate.js +0 -3534
  218. package/core/.specialist/tools/phase-gate.test.js +0 -85
  219. package/core/.specialist/tools/precompute-runner.js +0 -444
  220. package/core/.specialist/tools/rule-engine.js +0 -621
  221. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  222. package/core/.synapse/memory-shared.json.sync +0 -1
  223. package/core/.system/agent-skills/README.md +0 -724
  224. package/core/.system/cli-tools/README.md +0 -724
  225. package/core/.system/cortex/MODULES.md +0 -1046
  226. package/core/.system/dashboard/FRONTEND.md +0 -812
  227. package/core/.system/dashboard/README.md +0 -737
  228. package/core/.system/failure/README.md +0 -723
  229. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  230. package/core/.system/formation/POST_COMPLETE.md +0 -602
  231. package/core/.system/formation/README.md +0 -1094
  232. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  233. package/core/.system/kenaz/README.md +0 -787
  234. package/core/.system/memory/README.md +0 -719
  235. package/core/.system/pipeline/README.md +0 -712
  236. package/core/.system/rule/README.md +0 -794
  237. package/core/.system/sunny/README.md +0 -476
  238. package/core/.system/sunny/RULES.json +0 -89
  239. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  240. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  241. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  242. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  243. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  244. package/core/.system/sunny/teammates/README.md +0 -107
  245. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  246. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  247. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  248. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  249. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  250. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  251. package/core/.system/sunny/tools.json +0 -101
  252. package/core/dev/scripts/cleanup-queue.js +0 -184
  253. package/core/dev/scripts/cleanup_queue.js +0 -86
  254. package/core/dev/scripts/legacy/README.md +0 -39
  255. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  256. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  257. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  258. package/core/dev/scripts/matrix/README.md +0 -310
  259. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  260. package/core/dev/scripts/matrix/package.json +0 -55
  261. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  262. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  263. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  264. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  265. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  266. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  267. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  268. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  269. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  270. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  271. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  272. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  273. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  274. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  275. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  276. package/core/dev/scripts/matrix/src/index.ts +0 -62
  277. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  278. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  279. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  280. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  281. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  282. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  283. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  284. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  285. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  286. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  287. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  288. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  289. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  290. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  291. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  292. package/core/dev/scripts/matrix/types/index.js +0 -8
  293. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  294. package/core/dev/scripts/matrix/types/index.ts +0 -124
  295. package/core/dev/scripts/memory-usage-report.js +0 -152
  296. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  297. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  298. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  299. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  300. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  301. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  302. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  303. package/core/dev/scripts/validate_pipeline.js +0 -197
  304. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  305. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  306. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  307. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  308. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,197 +0,0 @@
1
- /**
2
- * MatrixSerializer 單元測試
3
- */
4
-
5
- import { MatrixSerializer } from '../src/serializer';
6
- import type { MatrixFile } from '../types';
7
-
8
- describe('MatrixSerializer', () => {
9
- let serializer: MatrixSerializer;
10
-
11
- beforeEach(() => {
12
- serializer = new MatrixSerializer();
13
- });
14
-
15
- describe('基本序列化', () => {
16
- it('應該序列化最小有效文件', () => {
17
- const data: MatrixFile = {
18
- meta: { v: '1.0', c: 'test' },
19
- index: { tot: 0 },
20
- };
21
-
22
- const result = serializer.serialize(data);
23
-
24
- expect(result).toContain('# .matrix v1.0');
25
- expect(result).toContain('@meta |v=1.0|c=test|');
26
- expect(result).toContain('@index |tot=0|');
27
- });
28
-
29
- it('應該序列化包含所有層級的文件', () => {
30
- const data: MatrixFile = {
31
- meta: { v: '1.0', c: 'test', t: '260208' },
32
- index: { tot: 1, c: 1 },
33
- data: {
34
- records: [
35
- {
36
- id: 'T1',
37
- fields: { status: 'completed', priority: 'P0' },
38
- },
39
- ],
40
- },
41
- };
42
-
43
- const result = serializer.serialize(data);
44
-
45
- expect(result).toContain('@meta |v=1.0|c=test|t=260208|');
46
- expect(result).toContain('@index |tot=1|c=1|');
47
- expect(result).toContain('@data');
48
- expect(result).toContain('T1|st=C|p=0|');
49
- });
50
-
51
- it('應該正確序列化複雜任務記錄', () => {
52
- const data: MatrixFile = {
53
- meta: { v: '1.0', c: 'tasks' },
54
- index: { tot: 1 },
55
- data: {
56
- records: [
57
- {
58
- id: 'T121',
59
- fields: {
60
- status: 'completed',
61
- priority: 'P0',
62
- duration: '135m',
63
- created_at: '2026-02-06T14:30:00Z',
64
- description: 'API integration',
65
- dependencies: ['T120', 'T121'],
66
- },
67
- },
68
- ],
69
- },
70
- };
71
-
72
- const result = serializer.serialize(data);
73
-
74
- expect(result).toContain('T121|');
75
- expect(result).toContain('st=C');
76
- expect(result).toContain('p=0');
77
- expect(result).toContain('dur=135m');
78
- expect(result).toContain('ct=260206-1430');
79
- expect(result).toContain('desc=API integration');
80
- expect(result).toContain('dep=T120,T121');
81
- });
82
- });
83
-
84
- describe('值類型序列化', () => {
85
- it('應該正確序列化布林值', () => {
86
- const data: MatrixFile = {
87
- meta: { v: '1.0', c: 'test' },
88
- index: { active: true, enabled: false },
89
- };
90
-
91
- const result = serializer.serialize(data);
92
-
93
- expect(result).toContain('act=1');
94
- expect(result).toContain('en=0');
95
- });
96
-
97
- it('應該正確序列化數字', () => {
98
- const data: MatrixFile = {
99
- meta: { v: '1.0', c: 'test' },
100
- index: { total: 123, success_rate: 81.3 },
101
- };
102
-
103
- const result = serializer.serialize(data);
104
-
105
- expect(result).toContain('tot=123');
106
- expect(result).toContain('succ=81.3');
107
- });
108
-
109
- it('應該正確序列化列表', () => {
110
- const data: MatrixFile = {
111
- meta: { v: '1.0', c: 'test' },
112
- index: { tot: 1 },
113
- data: {
114
- records: [
115
- {
116
- id: 'T1',
117
- fields: { dependencies: ['T120', 'T121', 'T122'] },
118
- },
119
- ],
120
- },
121
- };
122
-
123
- const result = serializer.serialize(data);
124
-
125
- expect(result).toContain('dep=T120,T121,T122');
126
- });
127
-
128
- it('應該正確序列化時間戳', () => {
129
- const data: MatrixFile = {
130
- meta: { v: '1.0', c: 'test' },
131
- index: { tot: 1 },
132
- data: {
133
- records: [
134
- {
135
- id: 'T1',
136
- fields: { created_at: '2026-02-07T05:30:00Z' },
137
- },
138
- ],
139
- },
140
- };
141
-
142
- const result = serializer.serialize(data);
143
-
144
- expect(result).toContain('ct=260207-0530');
145
- });
146
- });
147
-
148
- describe('往返無損', () => {
149
- it('Parser + Serializer 應該往返無損', () => {
150
- const { MatrixParser } = require('../src/parser');
151
- const parser = new MatrixParser();
152
-
153
- const original = `# .matrix v1.0
154
- @meta |v=1.0|c=project-status|t=260207-0530|proj=KenazAI|
155
- @index |tot=123|c=100|p=15|b=8|act=1|
156
- @data
157
- gen|tot=123|c=100|p=15|b=8|succ=81.3|
158
- rec|dep=T121,T122,T123|`;
159
-
160
- const parsed = parser.parse(original);
161
- expect(parsed.success).toBe(true);
162
-
163
- const serialized = serializer.serialize(parsed.data!);
164
- const reparsed = parser.parse(serialized);
165
-
166
- expect(reparsed.success).toBe(true);
167
- expect(reparsed.data).toEqual(parsed.data);
168
- });
169
- });
170
-
171
- describe('序列化選項', () => {
172
- it('includeComment: false 不應包含註釋', () => {
173
- const serializer = new MatrixSerializer({ includeComment: false });
174
- const data: MatrixFile = {
175
- meta: { v: '1.0', c: 'test' },
176
- index: { tot: 0 },
177
- };
178
-
179
- const result = serializer.serialize(data);
180
-
181
- expect(result).not.toContain('#');
182
- expect(result).toContain('@meta');
183
- });
184
-
185
- it('應該支援自訂註釋', () => {
186
- const serializer = new MatrixSerializer({ comment: 'Custom Comment' });
187
- const data: MatrixFile = {
188
- meta: { v: '1.0', c: 'test' },
189
- index: { tot: 0 },
190
- };
191
-
192
- const result = serializer.serialize(data);
193
-
194
- expect(result).toContain('# Custom Comment');
195
- });
196
- });
197
- });
@@ -1,141 +0,0 @@
1
- /**
2
- * Validate command tests
3
- */
4
-
5
- import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
- import { validateCommand } from '../src/cli/commands/validate';
9
-
10
- describe('Validate Command', () => {
11
- const testDir = path.join(__dirname, 'temp');
12
- const testFile = path.join(testDir, 'test.matrix');
13
-
14
- beforeEach(() => {
15
- // Create temp directory
16
- if (!fs.existsSync(testDir)) {
17
- fs.mkdirSync(testDir, { recursive: true });
18
- }
19
- });
20
-
21
- afterEach(() => {
22
- // Clean up
23
- if (fs.existsSync(testFile)) {
24
- fs.unlinkSync(testFile);
25
- }
26
- const backupFile = `${testFile}.backup`;
27
- if (fs.existsSync(backupFile)) {
28
- fs.unlinkSync(backupFile);
29
- }
30
- if (fs.existsSync(testDir)) {
31
- fs.rmdirSync(testDir);
32
- }
33
- });
34
-
35
- it('should validate a valid .matrix file', async () => {
36
- const validContent = `# Valid file
37
- @meta |v=1.0|c=T|
38
- @index |tot=1|
39
- @data
40
- TASK_001|st=P|p=P0|
41
- `;
42
- fs.writeFileSync(testFile, validContent, 'utf-8');
43
-
44
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
45
- });
46
-
47
- it('should detect missing @meta', async () => {
48
- const invalidContent = `@index |tot=0|
49
- @data
50
- `;
51
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
52
-
53
- // Should not throw, but will report errors
54
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
55
- });
56
-
57
- it('should detect missing @index', async () => {
58
- const invalidContent = `@meta |v=1.0|c=T|
59
- @data
60
- `;
61
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
62
-
63
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
64
- });
65
-
66
- it('should detect invalid delimiter format', async () => {
67
- const invalidContent = `@meta v=1.0|c=T
68
- @index |tot=0|
69
- `;
70
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
71
-
72
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
73
- });
74
-
75
- it('should detect missing required fields in @meta', async () => {
76
- const invalidContent = `@meta |v=1.0|
77
- @index |tot=0|
78
- `;
79
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
80
-
81
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
82
- });
83
-
84
- it('should detect empty file', async () => {
85
- fs.writeFileSync(testFile, '', 'utf-8');
86
-
87
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
88
- });
89
-
90
- it('should detect duplicate sections', async () => {
91
- const invalidContent = `@meta |v=1.0|c=T|
92
- @meta |v=2.0|c=M|
93
- @index |tot=0|
94
- `;
95
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
96
-
97
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
98
- });
99
-
100
- it('should auto-fix empty file with --fix', async () => {
101
- fs.writeFileSync(testFile, '', 'utf-8');
102
-
103
- await validateCommand(testFile, { fix: true });
104
-
105
- // Verify file was fixed
106
- const fixedContent = fs.readFileSync(testFile, 'utf-8');
107
- expect(fixedContent).toContain('@meta');
108
- expect(fixedContent).toContain('@index');
109
-
110
- // Verify backup was created
111
- const backupFile = `${testFile}.backup`;
112
- expect(fs.existsSync(backupFile)).toBe(true);
113
- });
114
-
115
- it('should auto-fix missing @meta with --fix', async () => {
116
- const invalidContent = `@index |tot=0|
117
- `;
118
- fs.writeFileSync(testFile, invalidContent, 'utf-8');
119
-
120
- await validateCommand(testFile, { fix: true });
121
-
122
- // Verify @meta was added
123
- const fixedContent = fs.readFileSync(testFile, 'utf-8');
124
- expect(fixedContent).toContain('@meta');
125
- });
126
-
127
- it('should throw error for non-existent file', async () => {
128
- await expect(validateCommand('nonexistent.matrix', {})).rejects.toThrow();
129
- });
130
-
131
- it('should handle files with warnings (valid but with warnings)', async () => {
132
- const contentWithWarnings = `# File with potential warnings
133
- @meta |v=1.0|c=T|deprecated_field=value|
134
- @index |tot=0|
135
- `;
136
- fs.writeFileSync(testFile, contentWithWarnings, 'utf-8');
137
-
138
- // Should complete without throwing
139
- await expect(validateCommand(testFile, {})).resolves.not.toThrow();
140
- });
141
- });
@@ -1,167 +0,0 @@
1
- /**
2
- * MatrixValidator 單元測試
3
- */
4
-
5
- import { MatrixValidator } from '../src/validator';
6
-
7
- describe('MatrixValidator', () => {
8
- let validator: MatrixValidator;
9
-
10
- beforeEach(() => {
11
- validator = new MatrixValidator();
12
- });
13
-
14
- describe('基本驗證', () => {
15
- it('應該驗證有效文件', () => {
16
- const content = `# .matrix v1.0
17
- @meta |v=1.0|c=test|
18
- @index |tot=0|`;
19
-
20
- const result = validator.validate(content);
21
-
22
- expect(result.valid).toBe(true);
23
- expect(result.errors.length).toBe(0);
24
- });
25
-
26
- it('應該驗證包含所有層級的文件', () => {
27
- const content = `# .matrix v1.0
28
- @meta |v=1.0|c=test|t=260208|
29
- @index |tot=1|c=1|
30
- @data
31
- T1|st=C|p=0|`;
32
-
33
- const result = validator.validate(content);
34
-
35
- expect(result.valid).toBe(true);
36
- expect(result.errors.length).toBe(0);
37
- });
38
- });
39
-
40
- describe('錯誤檢測', () => {
41
- it('E000: 應該檢測空文件', () => {
42
- const content = '';
43
-
44
- const result = validator.validate(content);
45
-
46
- expect(result.valid).toBe(false);
47
- expect(result.errors[0].code).toBe('E000');
48
- expect(result.errors[0].message).toContain('Empty');
49
- });
50
-
51
- it('E001: 應該檢測缺少 @meta', () => {
52
- const content = `@index |tot=1|
53
- @data
54
- T1|st=C|`;
55
-
56
- const result = validator.validate(content);
57
-
58
- expect(result.valid).toBe(false);
59
- const error = result.errors.find(e => e.code === 'E001' && e.message.includes('@meta'));
60
- expect(error).toBeDefined();
61
- });
62
-
63
- it('E001: 應該檢測缺少 @index', () => {
64
- const content = `@meta |v=1.0|c=test|`;
65
-
66
- const result = validator.validate(content);
67
-
68
- expect(result.valid).toBe(false);
69
- const error = result.errors.find(e => e.code === 'E001' && e.message.includes('@index'));
70
- expect(error).toBeDefined();
71
- });
72
-
73
- it('E002: 應該檢測重複 @meta', () => {
74
- const content = `@meta |v=1.0|c=test|
75
- @meta |v=2.0|c=test2|
76
- @index |tot=1|`;
77
-
78
- const result = validator.validate(content);
79
-
80
- expect(result.valid).toBe(false);
81
- const error = result.errors.find(e => e.code === 'E002' && e.message.includes('Duplicate @meta'));
82
- expect(error).toBeDefined();
83
- });
84
-
85
- it('E002: 應該檢測順序錯誤', () => {
86
- const content = `@index |tot=1|
87
- @meta |v=1.0|c=test|`;
88
-
89
- const result = validator.validate(content);
90
-
91
- expect(result.valid).toBe(false);
92
- const error = result.errors.find(e => e.code === 'E002');
93
- expect(error).toBeDefined();
94
- });
95
-
96
- it('E003: 應該檢測缺少分隔符', () => {
97
- const content = `@meta |v=1.0|c=test
98
- @index |tot=1|`;
99
-
100
- const result = validator.validate(content);
101
-
102
- expect(result.valid).toBe(false);
103
- const error = result.errors.find(e => e.code === 'E003');
104
- expect(error).toBeDefined();
105
- });
106
-
107
- it('E004: 應該檢測欄位格式錯誤', () => {
108
- const content = `@meta |v=1.0|c=test|
109
- @index |tot=1|
110
- @data
111
- T1|st:C|`;
112
-
113
- const result = validator.validate(content);
114
-
115
- expect(result.valid).toBe(false);
116
- const error = result.errors.find(e => e.code === 'E004');
117
- expect(error).toBeDefined();
118
- });
119
-
120
- it('E005: 應該檢測缺少必要欄位', () => {
121
- const content = `@meta |v=1.0|
122
- @index |tot=1|`;
123
-
124
- const result = validator.validate(content);
125
-
126
- expect(result.valid).toBe(false);
127
- const error = result.errors.find(e => e.code === 'E005');
128
- expect(error).toBeDefined();
129
- expect(error?.message).toContain('"c"');
130
- });
131
-
132
- it('應該檢測至少 10 種語法錯誤', () => {
133
- const errorTypes = validator.getErrorTypes();
134
-
135
- expect(errorTypes.length).toBeGreaterThanOrEqual(10);
136
- expect(errorTypes).toContain('E000 - Empty file');
137
- expect(errorTypes).toContain('E001 - Missing required section (@meta or @index)');
138
- expect(errorTypes).toContain('E002 - Invalid section order or duplicate sections');
139
- expect(errorTypes).toContain('E003 - Missing delimiters (|)');
140
- expect(errorTypes).toContain('E004 - Invalid field format (should be key=value)');
141
- });
142
- });
143
-
144
- describe('友善錯誤訊息', () => {
145
- it('錯誤訊息應包含行號', () => {
146
- const content = `@index |tot=1|`;
147
-
148
- const result = validator.validate(content);
149
-
150
- expect(result.valid).toBe(false);
151
- expect(result.errors[0].line).toBeDefined();
152
- expect(result.errors[0].line).toBeGreaterThan(0);
153
- });
154
-
155
- it('錯誤訊息應包含預期與實際', () => {
156
- const content = `@meta |v=1.0|c=test
157
- @index |tot=1|`;
158
-
159
- const result = validator.validate(content);
160
-
161
- expect(result.valid).toBe(false);
162
- const error = result.errors.find(e => e.code === 'E003');
163
- expect(error?.expected).toBeDefined();
164
- expect(error?.got).toBeDefined();
165
- });
166
- });
167
- });
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
6
- "declaration": true,
7
- "declarationMap": true,
8
- "sourceMap": true,
9
- "outDir": "./dist",
10
- "rootDir": "./src",
11
- "strict": true,
12
- "esModuleInterop": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true,
16
- "moduleResolution": "node"
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist", "tests"]
20
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * .matrix 格式類型定義
3
- * @version 1.0.0
4
- * @see dev/design/matrix_format_SYNTAX_BNF.md
5
- */
6
- /**
7
- * .matrix 文件完整結構
8
- */
9
- export interface MatrixFile {
10
- meta: MetaSection;
11
- index: IndexSection;
12
- data?: DataSection;
13
- }
14
- /**
15
- * @meta 層:文件元數據
16
- */
17
- export interface MetaSection {
18
- v: string;
19
- c: string;
20
- t?: string;
21
- r?: string;
22
- proj?: string;
23
- [key: string]: string | undefined;
24
- }
25
- /**
26
- * @index 層:快速查詢索引
27
- */
28
- export interface IndexSection {
29
- [key: string]: string | number | boolean;
30
- }
31
- /**
32
- * @data 層:實際數據內容
33
- */
34
- export interface DataSection {
35
- records: DataRecord[];
36
- }
37
- /**
38
- * 單筆數據記錄
39
- */
40
- export interface DataRecord {
41
- id: string;
42
- fields: Record<string, any>;
43
- }
44
- /**
45
- * 解析結果
46
- */
47
- export interface ParseResult {
48
- success: boolean;
49
- data?: MatrixFile;
50
- error?: ParseError;
51
- }
52
- /**
53
- * 解析錯誤
54
- */
55
- export interface ParseError {
56
- code: string;
57
- message: string;
58
- line?: number;
59
- column?: number;
60
- expected?: string;
61
- got?: string;
62
- }
63
- /**
64
- * 驗證結果
65
- */
66
- export interface ValidationResult {
67
- valid: boolean;
68
- errors: ParseError[];
69
- warnings: ParseError[];
70
- }
71
- /**
72
- * 序列化選項
73
- */
74
- export interface SerializeOptions {
75
- /**
76
- * 是否美化輸出(添加換行)
77
- * @default false
78
- */
79
- pretty?: boolean;
80
- /**
81
- * 是否包含註釋行
82
- * @default true
83
- */
84
- includeComment?: boolean;
85
- /**
86
- * 註釋內容
87
- * @default ".matrix v1.0"
88
- */
89
- comment?: string;
90
- }
91
- /**
92
- * 解析選項
93
- */
94
- export interface ParseOptions {
95
- /**
96
- * 是否嚴格模式(遇到錯誤立即拋出)
97
- * @default true
98
- */
99
- strict?: boolean;
100
- /**
101
- * 是否自動修正錯誤
102
- * @default false
103
- */
104
- autoFix?: boolean;
105
- /**
106
- * 是否驗證欄位名稱
107
- * @default true
108
- */
109
- validateFields?: boolean;
110
- }
111
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /**
3
- * .matrix 格式類型定義
4
- * @version 1.0.0
5
- * @see dev/design/matrix_format_SYNTAX_BNF.md
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}