kenaz 0.3.17 → 0.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/core/.claude/commands/agent-worker.md +1 -1
  2. package/core/.claude/commands/architect.md +1 -2
  3. package/core/.claude/commands/spec.md +1 -1
  4. package/core/.claude/commands//347/224/242/345/223/201.md +1 -1
  5. package/core/.claude/hooks/__tests__/task-1977-dedupe-guard.test.js +8 -8
  6. package/core/.claude/hooks/synapse-first-investigation.js +15 -0
  7. package/core/.claude/skills/architect_agent/SKILL.md +11 -92
  8. package/core/.claude/skills/assessment_agent/SKILL.md +0 -1
  9. package/core/.claude/skills/backend_engineer/SKILL.md +3 -6
  10. package/core/.claude/skills/code_reviewer/SKILL.md +1 -1
  11. package/core/.claude/skills/code_reviewer/patterns.yaml +1 -1
  12. package/core/.claude/skills/designer/SKILL.md +3 -6
  13. package/core/.claude/skills/dev_agent/SKILL.md +30 -491
  14. package/core/.claude/skills/developer/SKILL.md +3 -6
  15. package/core/.claude/skills/feature_agent/SKILL.md +3 -17
  16. package/core/.claude/skills/product_manager/SKILL.md +29 -1064
  17. package/core/.claude/skills/qa_engineer/SKILL.md +12 -17
  18. package/core/.claude/skills/spec_optimizer/SKILL.md +25 -275
  19. package/core/.claude/skills/sre_agent/SKILL.md +3 -6
  20. package/core/.collaboration/README.md +2 -3
  21. package/core/.collaboration/core/task-api.js +5 -138
  22. package/core/.collaboration/docs/CLI.md +0 -2
  23. package/core/.failure/INDEX.yaml +6 -40
  24. package/core/.failure/agent-execution/FAIL-013-search-cwd-drift-and-case-mismatch.yaml +1 -1
  25. package/core/.failure/tools/README.md +9 -227
  26. package/core/.formation/bifrost/exec.js +29 -4
  27. package/core/.formation/bifrost/launch.js +1 -6
  28. package/core/.formation/bifrost/launch.test.js +1 -1
  29. package/core/.formation/bifrost/provider-launch.js +18 -11
  30. package/core/.formation/bifrost/provider-launch.test.js +26 -2
  31. package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
  32. package/core/.formation/bifrost/shared/ansuz-boot-policy.test.js +1 -2
  33. package/core/.formation/tools/__tests__/dispatch-cwd-project.test.js +42 -0
  34. package/core/.formation/tools/__tests__/m1-hmap-convid.test.js +1 -124
  35. package/core/.formation/tools/__tests__/subagent-executor.test.js +3 -2
  36. package/core/.formation/tools/dispatch.js +15 -2
  37. package/core/.formation/tools/loader.js +17 -140
  38. package/core/.formation/tools/post-complete.js +0 -31
  39. package/core/.rule/INDEX.yaml +0 -18
  40. package/core/.rule/general/agent-workflow.yaml +14 -164
  41. package/core/.rule/general/project-self-containment.yaml +8 -19
  42. package/core/.rule/general/rust-verify-target.yaml +6 -5
  43. package/core/.rule/general/synapse-code-intelligence.yaml +3 -3
  44. package/core/.specialist/Amelia/capability.yaml +12 -12
  45. package/core/.specialist/Amelia/workflow.yaml +2 -2
  46. package/core/.specialist/Ansuz/SYSTEM_DOC.md +20 -578
  47. package/core/.specialist/Ansuz/cognitive_principles.yaml +2 -3
  48. package/core/.specialist/Ansuz/concepts/boot_rules_summary.yaml +0 -1
  49. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +1 -2
  50. package/core/.specialist/Ansuz/core.yaml +6 -108
  51. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +0 -3
  52. package/core/.specialist/Ansuz/identity_contract.yaml +0 -1
  53. package/core/.specialist/Ansuz/knowledge.yaml +0 -4
  54. package/core/.specialist/Ansuz/rule.yaml +0 -1
  55. package/core/.specialist/Ansuz/tools/handoff-session-identity.test.js +6 -150
  56. package/core/.specialist/tests/runtime-discovery/README.md +1 -1
  57. package/core/.specialist/tools/__tests__/task-2374-usage-counter.test.js +1 -12
  58. package/core/.specialist/tools/prompt-files.test.js +1 -0
  59. package/core/.specialist/tools/task-bridge.js +1 -66
  60. package/core/.system/README.md +11 -552
  61. package/core/.system/collaboration/README.md +10 -174
  62. package/core/CLAUDE.md +1 -6
  63. package/core/KENAZ_CORE_VERSION +1 -1
  64. package/core/dev/scripts/js-yaml-resolution.test.js +1 -1
  65. package/core/dev/scripts/run-rust-tests.js +30 -46
  66. package/core/dev/scripts/run-rust-tests.test.js +17 -0
  67. package/core/dev/scripts/rust-verify-worktree.js +4 -4
  68. package/core/dev/scripts/verify-target-dir.js +6 -6
  69. package/core/plugins/kenaz/INVENTORY.md +8 -8
  70. package/core/plugins/kenaz/commands/architect.md +1 -2
  71. package/core/plugins/kenaz/commands/spec.md +1 -1
  72. package/core/plugins/kenaz/commands//347/224/242/345/223/201.md +1 -1
  73. package/core/plugins/kenaz/guidance.md +1 -1
  74. package/core/plugins/kenaz/scripts/sync.js +1 -1
  75. package/core/plugins/kenaz/scripts/ygg.js +6 -0
  76. package/core/plugins/kenaz/skills/architect_agent/SKILL.md +11 -92
  77. package/core/plugins/kenaz/skills/assessment_agent/SKILL.md +0 -1
  78. package/core/plugins/kenaz/skills/backend_engineer/SKILL.md +3 -6
  79. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +1 -1
  80. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +1 -1
  81. package/core/plugins/kenaz/skills/designer/SKILL.md +3 -6
  82. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +30 -491
  83. package/core/plugins/kenaz/skills/developer/SKILL.md +3 -6
  84. package/core/plugins/kenaz/skills/feature_agent/SKILL.md +3 -17
  85. package/core/plugins/kenaz/skills/product_manager/SKILL.md +29 -1064
  86. package/core/plugins/kenaz/skills/qa_engineer/SKILL.md +12 -17
  87. package/core/plugins/kenaz/skills/spec_optimizer/SKILL.md +25 -275
  88. package/core/plugins/kenaz/skills/sre_agent/SKILL.md +3 -6
  89. package/package.json +6 -6
  90. package/core/.claude/commands/archive.md +0 -24
  91. package/core/.claude/commands/init.md +0 -112
  92. package/core/.claude/commands/legacy_dev.md +0 -18
  93. package/core/.claude/commands/product-review.md +0 -131
  94. package/core/.claude/commands/strategy.md +0 -141
  95. package/core/.claude/commands/sunny.md +0 -1
  96. package/core/.claude/commands//347/224/242/345/223/201/346/252/242/350/246/226.md +0 -129
  97. package/core/.claude/commands//351/200/262/345/272/246.md +0 -15
  98. package/core/.claude/hooks/__tests__/substrate.test.js +0 -122
  99. package/core/.claude/hooks/_substrate-paths.js +0 -95
  100. package/core/.claude/hooks/context-check.js +0 -51
  101. package/core/.claude/hooks/fatigue-check.js +0 -52
  102. package/core/.claude/hooks/handoff-snapshot-on-commit.js +0 -154
  103. package/core/.claude/hooks/handoff-snapshot-on-question.js +0 -158
  104. package/core/.claude/hooks/handoff-staleness.js +0 -197
  105. package/core/.claude/hooks/jev-thalamus-context.js +0 -17
  106. package/core/.claude/hooks/jev-thalamus-context.test.js +0 -41
  107. package/core/.claude/hooks/lease-release.js +0 -119
  108. package/core/.claude/hooks/lease-touch.js +0 -96
  109. package/core/.claude/hooks/reflex-feedback.js +0 -5
  110. package/core/.claude/hooks/session-init.ps1 +0 -49
  111. package/core/.claude/hooks/sound-event.js +0 -70
  112. package/core/.claude/hooks/sound-event.sh +0 -37
  113. package/core/.claude/hooks/stream-delta.js +0 -169
  114. package/core/.claude/no-hooks.settings.json +0 -3
  115. package/core/.claude/skills/legacy_dev/SKILL.md +0 -202
  116. package/core/.claude/skills/sunny/SKILL.md +0 -74
  117. package/core/.collaboration/cli/commands/assign.js +0 -39
  118. package/core/.collaboration/cli/commands/claim.js +0 -33
  119. package/core/.collaboration/cli/commands/complete.js +0 -44
  120. package/core/.collaboration/cli/commands/create.js +0 -110
  121. package/core/.collaboration/cli/commands/get.js +0 -83
  122. package/core/.collaboration/cli/commands/index.js +0 -52
  123. package/core/.collaboration/cli/commands/list.js +0 -51
  124. package/core/.collaboration/cli/commands/lock.js +0 -45
  125. package/core/.collaboration/cli/commands/rebuild.js +0 -39
  126. package/core/.collaboration/cli/commands/search.js +0 -61
  127. package/core/.collaboration/cli/commands/stats.js +0 -61
  128. package/core/.collaboration/cli/commands/transfer.js +0 -41
  129. package/core/.collaboration/cli/commands/unlock.js +0 -48
  130. package/core/.collaboration/cli/formatters/help-formatter.js +0 -70
  131. package/core/.collaboration/cli/formatters/index.js +0 -7
  132. package/core/.collaboration/cli/task-cli.js +0 -46
  133. package/core/.collaboration/cli/utils/arg-parser.js +0 -74
  134. package/core/.collaboration/cli/utils/git-user.js +0 -25
  135. package/core/.collaboration/cli/utils/index.js +0 -9
  136. package/core/.collaboration/cli/utils/output.js +0 -10
  137. package/core/.collaboration/config/default.yaml +0 -189
  138. package/core/.collaboration/core/conflict-resolver.js +0 -461
  139. package/core/.collaboration/core/conflict-resolver.test.js +0 -389
  140. package/core/.collaboration/core/migrate-legacy.js +0 -260
  141. package/core/.collaboration/docs/API.md +0 -787
  142. package/core/.collaboration/docs/ARCHITECTURE.md +0 -596
  143. package/core/.collaboration/docs/FAQ.md +0 -695
  144. package/core/.collaboration/docs/MIGRATION.md +0 -804
  145. package/core/.collaboration/docs/examples/README.md +0 -320
  146. package/core/.collaboration/docs/examples/advanced-queries.js +0 -261
  147. package/core/.collaboration/docs/examples/basic-usage.js +0 -184
  148. package/core/.collaboration/docs/examples/team-workflow.js +0 -352
  149. package/core/.failure/agent-execution/FAIL-001-agent-no-output.yaml +0 -391
  150. package/core/.failure/agent-execution/FAIL-007-pm-lead-wrong-team-invocation.yaml +0 -0
  151. package/core/.failure/agent-execution/FAIL-010-phase0-poem-format-skipped.yaml +0 -28
  152. package/core/.failure/agent-execution/FAIL-010-skipping-cognitive-checkpoint-after-verification.yaml +0 -59
  153. package/core/.failure/agent-execution/FAIL-012-grep-shortcut-during-investigation.yaml +0 -85
  154. package/core/.failure/architecture/FAIL-006-python-version-compatibility.yaml +0 -445
  155. package/core/.failure/pipeline/FAIL-003-queue-pollution.yaml +0 -335
  156. package/core/.failure/pipeline/README.md +0 -95
  157. package/core/.failure/retired/FAIL-009-skipping-synapse-pulse-before-code-change.yaml +0 -49
  158. package/core/.failure/tools/USAGE_GUIDE.md +0 -323
  159. package/core/.failure/tools/check_failures.ps1 +0 -387
  160. package/core/.failure/tools/log_failure.ps1 +0 -474
  161. package/core/.formation/.episode-input.json +0 -10
  162. package/core/.formation/.merge-lock +0 -1
  163. package/core/.formation/lead.yaml +0 -118
  164. package/core/.formation/legacy.bak/designer.yaml +0 -57
  165. package/core/.formation/legacy.bak/pm.yaml +0 -57
  166. package/core/.formation/legacy.bak/qa.yaml +0 -57
  167. package/core/.formation/legacy.bak/review.yaml +0 -62
  168. package/core/.formation/legacy.bak/scheduler.yaml +0 -129
  169. package/core/.formation/legacy.bak/sre.yaml +0 -57
  170. package/core/.formation/role-map.yaml +0 -274
  171. package/core/.formation/roles/_shared/modules/code_review.yaml +0 -98
  172. package/core/.formation/roles/_shared/modules/security.yaml +0 -103
  173. package/core/.formation/roles/_shared/modules/testing.yaml +0 -14
  174. package/core/.formation/roles/backend/role.yaml +0 -93
  175. package/core/.formation/roles/code_reviewer/role.yaml +0 -102
  176. package/core/.formation/roles/database_optimizer/role.yaml +0 -107
  177. package/core/.formation/roles/designer/role.yaml +0 -66
  178. package/core/.formation/roles/developer/role.yaml +0 -75
  179. package/core/.formation/roles/frontend/role.yaml +0 -134
  180. package/core/.formation/roles/incident_response/role.yaml +0 -89
  181. package/core/.formation/roles/qa/role.yaml +0 -89
  182. package/core/.formation/roles/security/role.yaml +0 -87
  183. package/core/.formation/roles/sre/role.yaml +0 -66
  184. package/core/.formation/skills/coordinator.yaml +0 -52
  185. package/core/.formation/solo/diagnosis.yaml +0 -78
  186. package/core/.formation/solo/strategy.yaml +0 -121
  187. package/core/.formation/tests/hello.txt +0 -2
  188. package/core/.formation/tools/coordinator.js +0 -350
  189. package/core/.formation/tools/jev-correction.js +0 -214
  190. package/core/.formation/tools/jev-correction.test.js +0 -178
  191. package/core/.formation/tools/log-reader.js +0 -232
  192. package/core/.formation/tools/revert-daemon-state.js +0 -162
  193. package/core/.formation/tools/test-drift.js +0 -148
  194. package/core/.formation/unit/heimdall.yaml +0 -96
  195. package/core/.formation/unit/plan.yaml +0 -67
  196. package/core/.formation/unit/think.yaml +0 -58
  197. package/core/.kenaz/MUNINN_SNAPSHOT9_EPISODE.json +0 -32
  198. package/core/.kenaz/MUNINN_SNAPSHOT9_RUNE.json +0 -23
  199. package/core/.kenaz/MUNINN_SNAPSHOT9_SUMMARY.md +0 -89
  200. package/core/.kenaz/ash_TASK_1428-20260507.json +0 -14
  201. package/core/.kenaz/muninn_episode_write.ps1 +0 -17
  202. package/core/.kenaz/muninn_snapshot11_rune_candidates.md +0 -63
  203. package/core/.kenaz/muninn_snapshot1_rune_candidates.md +0 -49
  204. package/core/.kenaz/runes_TASK_1428.json +0 -57
  205. package/core/.kenaz/tmp_heimdall_proposal_8d3e392.json +0 -13
  206. package/core/.kenaz/tmp_props.json +0 -1
  207. package/core/.kenaz/tmp_sounddrop_t1_prompt.txt +0 -371
  208. package/core/.rule/MECHANIZED.md +0 -61
  209. package/core/.rule/general/cortex-memory-recall.yaml +0 -446
  210. package/core/.rule/general/pipeline.yaml +0 -246
  211. package/core/.rule/general/sunny-access-control.yaml +0 -60
  212. package/core/.rule/general/system-invariants.yaml +0 -231
  213. package/core/.rule/pipeline/PPL-002-completed-task-archival.yaml +0 -528
  214. package/core/.rule/pipeline/auto-update.yaml +0 -282
  215. package/core/.rule/pipeline/task-execution.yaml +0 -365
  216. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +0 -65
  217. package/core/.specialist/Ansuz/experiments/boot_ablation_replay.js +0 -197
  218. package/core/.specialist/Ansuz/tools/bootstrap-anchors.js +0 -289
  219. package/core/.specialist/Ansuz/workflow.yaml +0 -1225
  220. package/core/.specialist/experiments/rg_benchmark.js +0 -523
  221. package/core/.specialist/experiments/rg_benchmark_results.json +0 -27
  222. package/core/.specialist/tools/jev-optional-context.js +0 -107
  223. package/core/.specialist/tools/jev-optional-context.test.js +0 -152
  224. package/core/.specialist/tools/memory-action-log.js +0 -839
  225. package/core/.specialist/tools/phase-gate.js +0 -3534
  226. package/core/.specialist/tools/phase-gate.test.js +0 -85
  227. package/core/.specialist/tools/precompute-runner.js +0 -444
  228. package/core/.specialist/tools/rule-engine.js +0 -621
  229. package/core/.specialist/tools/task-bridge-jev.test.js +0 -170
  230. package/core/.synapse/memory-shared.json.sync +0 -1
  231. package/core/.system/agent-skills/README.md +0 -724
  232. package/core/.system/cli-tools/README.md +0 -724
  233. package/core/.system/cortex/MODULES.md +0 -1046
  234. package/core/.system/dashboard/FRONTEND.md +0 -812
  235. package/core/.system/dashboard/README.md +0 -737
  236. package/core/.system/failure/README.md +0 -723
  237. package/core/.system/formation/LEGACY_SKILLS.md +0 -974
  238. package/core/.system/formation/POST_COMPLETE.md +0 -602
  239. package/core/.system/formation/README.md +0 -1094
  240. package/core/.system/formation/TOOLS_REFERENCE.md +0 -1145
  241. package/core/.system/kenaz/README.md +0 -787
  242. package/core/.system/memory/README.md +0 -719
  243. package/core/.system/pipeline/README.md +0 -712
  244. package/core/.system/rule/README.md +0 -794
  245. package/core/.system/sunny/README.md +0 -476
  246. package/core/.system/sunny/RULES.json +0 -89
  247. package/core/.system/sunny/knowledge/INDEX.md +0 -37
  248. package/core/.system/sunny/knowledge/agent-teams-api.md +0 -0
  249. package/core/.system/sunny/knowledge/ansuz-specialist.md +0 -500
  250. package/core/.system/sunny/knowledge/claude-cli-spawn.md +0 -177
  251. package/core/.system/sunny/knowledge/collaboration-api.md +0 -925
  252. package/core/.system/sunny/teammates/README.md +0 -107
  253. package/core/.system/sunny/teammates/how_to_use.yaml +0 -101
  254. package/core/.system/sunny/teammates/tools/headless/launcher.js +0 -318
  255. package/core/.system/sunny/teammates/tools/powershell/launcher.js +0 -241
  256. package/core/.system/sunny/teammates/tools/powershell/start.bat +0 -50
  257. package/core/.system/sunny/teammates/tools/utils/env.js +0 -96
  258. package/core/.system/sunny/teammates/tools/utils/format-output.js +0 -329
  259. package/core/.system/sunny/tools.json +0 -101
  260. package/core/dev/scripts/cleanup-queue.js +0 -184
  261. package/core/dev/scripts/cleanup_queue.js +0 -86
  262. package/core/dev/scripts/legacy/README.md +0 -39
  263. package/core/dev/scripts/legacy/dev_agent_scheduler.ps1.bak +0 -536
  264. package/core/dev/scripts/legacy/multi_agent_scheduler.ps1.bak +0 -1978
  265. package/core/dev/scripts/matrix/CLI_README.md +0 -214
  266. package/core/dev/scripts/matrix/README.md +0 -310
  267. package/core/dev/scripts/matrix/package-lock.json +0 -4266
  268. package/core/dev/scripts/matrix/package.json +0 -55
  269. package/core/dev/scripts/matrix/src/abbreviations.ts +0 -295
  270. package/core/dev/scripts/matrix/src/cli/commands/convert.ts +0 -211
  271. package/core/dev/scripts/matrix/src/cli/commands/create.ts +0 -95
  272. package/core/dev/scripts/matrix/src/cli/commands/delete.ts +0 -102
  273. package/core/dev/scripts/matrix/src/cli/commands/list-tags.ts.wip +0 -140
  274. package/core/dev/scripts/matrix/src/cli/commands/manage-tags.ts.wip +0 -173
  275. package/core/dev/scripts/matrix/src/cli/commands/query.ts +0 -261
  276. package/core/dev/scripts/matrix/src/cli/commands/read.ts +0 -77
  277. package/core/dev/scripts/matrix/src/cli/commands/stats.ts.wip +0 -168
  278. package/core/dev/scripts/matrix/src/cli/commands/tokens.ts.wip +0 -126
  279. package/core/dev/scripts/matrix/src/cli/commands/update.ts +0 -147
  280. package/core/dev/scripts/matrix/src/cli/commands/validate.ts +0 -275
  281. package/core/dev/scripts/matrix/src/cli/index.ts +0 -350
  282. package/core/dev/scripts/matrix/src/cli/utils/file-handler.ts +0 -72
  283. package/core/dev/scripts/matrix/src/cli/utils/logger.ts +0 -65
  284. package/core/dev/scripts/matrix/src/index.ts +0 -62
  285. package/core/dev/scripts/matrix/src/indexer/tag-indexer.ts +0 -165
  286. package/core/dev/scripts/matrix/src/parser.ts +0 -281
  287. package/core/dev/scripts/matrix/src/serializer.ts +0 -151
  288. package/core/dev/scripts/matrix/src/validator.ts +0 -301
  289. package/core/dev/scripts/matrix/tests/abbreviations.test.ts +0 -122
  290. package/core/dev/scripts/matrix/tests/cli.test.ts +0 -177
  291. package/core/dev/scripts/matrix/tests/convert.test.ts +0 -143
  292. package/core/dev/scripts/matrix/tests/parser.test.ts +0 -203
  293. package/core/dev/scripts/matrix/tests/query.test.ts +0 -85
  294. package/core/dev/scripts/matrix/tests/serializer.test.ts +0 -197
  295. package/core/dev/scripts/matrix/tests/validate.test.ts +0 -141
  296. package/core/dev/scripts/matrix/tests/validator.test.ts +0 -167
  297. package/core/dev/scripts/matrix/tsconfig.json +0 -20
  298. package/core/dev/scripts/matrix/types/index.d.ts +0 -111
  299. package/core/dev/scripts/matrix/types/index.d.ts.map +0 -1
  300. package/core/dev/scripts/matrix/types/index.js +0 -8
  301. package/core/dev/scripts/matrix/types/index.js.map +0 -1
  302. package/core/dev/scripts/matrix/types/index.ts +0 -124
  303. package/core/dev/scripts/memory-usage-report.js +0 -152
  304. package/core/dev/scripts/probe/ansuz-scaffold-ablation.js +0 -579
  305. package/core/dev/scripts/probe/ansuz-scaffold-ablation.test.js +0 -244
  306. package/core/dev/scripts/probe/hook-latency-probe.js +0 -315
  307. package/core/dev/scripts/probe/hook-latency-probe.test.js +0 -105
  308. package/core/dev/scripts/probe/prediction-signal-auc.js +0 -483
  309. package/core/dev/scripts/probe/prediction-signal-auc.test.js +0 -200
  310. package/core/dev/scripts/test-pty-ws-tunnel.js +0 -229
  311. package/core/dev/scripts/validate_pipeline.js +0 -197
  312. package/core/dev/spikes/task2145-evidence-20261004/backend-log-excerpt.txt +0 -56
  313. package/core/dev/spikes/task2145-evidence-20261004/graph.shadow +0 -0
  314. package/core/dev/spikes/task2145-evidence-20261004/graph.wal +0 -0
  315. package/core/dev/spikes/task2145-evidence-20261004/graph_corrupt_suspect.marker +0 -1
  316. package/core/plugins/kenaz/commands/strategy.md +0 -141
@@ -1,323 +0,0 @@
1
- # Failure Logging Tools - Usage Guide
2
-
3
- ## 執行環境要求
4
-
5
- ### PowerShell 腳本執行
6
- 由於腳本包含中文字符,需要確保 PowerShell 正確支援 UTF-8 編碼。
7
-
8
- **推薦執行方式**(Windows PowerShell 或 PowerShell 7+):
9
-
10
- 1. 直接在 Windows PowerShell 中執行:
11
- ```powershell
12
- # 開啟 PowerShell(不是 Git Bash)
13
- cd D:\repo\side\ava\KenazAI
14
-
15
- # 執行腳本
16
- .\.failure\tools\log_failure.ps1 -Help
17
- .\.failure\tools\check_failures.ps1 -Help
18
- ```
19
-
20
- 2. 如果遇到執行策略限制:
21
- ```powershell
22
- # 暫時允許執行腳本
23
- Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
24
-
25
- # 或使用 -ExecutionPolicy 參數
26
- powershell -ExecutionPolicy Bypass -File ".failure/tools/log_failure.ps1" -Help
27
- ```
28
-
29
- 3. 如果遇到編碼問題(亂碼):
30
- ```powershell
31
- # PowerShell 7+ 預設 UTF-8,推薦使用
32
- pwsh -File ".failure/tools/log_failure.ps1" -Help
33
-
34
- # 或在 Windows PowerShell 5.1 中設置編碼
35
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
36
- $OutputEncoding = [System.Text.Encoding]::UTF8
37
- ```
38
-
39
- ## 工具 1: log_failure.ps1
40
-
41
- ### 功能說明
42
- 自動化建立失敗記錄文件的 PowerShell 腳本。
43
-
44
- ### 使用範例
45
-
46
- #### 1. 互動式模式(推薦)
47
- ```powershell
48
- .\.failure\tools\log_failure.ps1
49
- ```
50
-
51
- 互動式模式會逐步引導您:
52
- 1. 選擇失敗分類(agent_execution, code_quality, architecture, pipeline, data_integrity)
53
- 2. 輸入失敗標題
54
- 3. 選擇嚴重程度(critical, high, medium, low)
55
- 4. 輸入相關任務 ID(可選)
56
-
57
- #### 2. 參數化模式
58
- ```powershell
59
- # 基本用法
60
- .\.failure\tools\log_failure.ps1 `
61
- -Category "pipeline" `
62
- -Title "任務佇列損壞問題" `
63
- -Severity "high"
64
-
65
- # 包含任務 ID
66
- .\.failure\tools\log_failure.ps1 `
67
- -Category "data_integrity" `
68
- -Title "JSON BOM 編碼錯誤" `
69
- -Severity "high" `
70
- -TaskID "TASK_089"
71
- ```
72
-
73
- #### 3. 查看幫助
74
- ```powershell
75
- .\.failure\tools\log_failure.ps1 -Help
76
- ```
77
-
78
- ### 輸出結果
79
- 腳本執行後會:
80
- 1. 生成新的 FAIL-XXX ID(基於 INDEX.yaml 中的最大 ID)
81
- 2. 在對應的分類目錄下建立失敗記錄文件(YAML 格式)
82
- 3. 自動更新 INDEX.yaml 的:
83
- - `load_order` 列表
84
- - `statistics.total_failures`
85
- - `statistics.by_category`
86
- - `statistics.by_severity`
87
- - `last_updated` 時間戳
88
-
89
- ### 驗證結果
90
- ```powershell
91
- # 檢查新建立的失敗記錄
92
- Get-ChildItem .failure/*/FAIL-*.yaml | Sort-Object LastWriteTime -Descending | Select-Object -First 1
93
-
94
- # 驗證 INDEX.yaml 更新
95
- Get-Content .failure/INDEX.yaml | Select-String "FAIL-"
96
- ```
97
-
98
- ## 工具 2: check_failures.ps1
99
-
100
- ### 功能說明
101
- 檢查當前任務是否匹配已知失敗模式的腳本。
102
-
103
- ### 使用範例
104
-
105
- #### 1. 根據任務 ID 檢查
106
- ```powershell
107
- # 自動從 TASK_QUEUE.json 載入任務詳情
108
- .\.failure\tools\check_failures.ps1 -TaskID "TASK_077"
109
- ```
110
-
111
- #### 2. 根據 Agent 類型檢查
112
- ```powershell
113
- .\.failure\tools\check_failures.ps1 -AgentType "developer"
114
- ```
115
-
116
- #### 3. 根據路徑檢查
117
- ```powershell
118
- .\.failure\tools\check_failures.ps1 -ScopePath "dev/pipeline/"
119
- ```
120
-
121
- #### 4. 關鍵詞搜尋
122
- ```powershell
123
- # 單個關鍵詞
124
- .\.failure\tools\check_failures.ps1 -Keywords "JSON"
125
-
126
- # 多個關鍵詞(用逗號分隔)
127
- .\.failure\tools\check_failures.ps1 -Keywords "JSON,BOM,encoding"
128
- ```
129
-
130
- #### 5. 過濾分類和嚴重程度
131
- ```powershell
132
- # 只檢查 pipeline 分類的失敗
133
- .\.failure\tools\check_failures.ps1 -Category "pipeline"
134
-
135
- # 只檢查 critical 嚴重程度的失敗
136
- .\.failure\tools\check_failures.ps1 -Severity "critical"
137
-
138
- # 組合過濾
139
- .\.failure\tools\check_failures.ps1 `
140
- -Category "pipeline" `
141
- -Severity "high" `
142
- -AgentType "developer"
143
- ```
144
-
145
- #### 6. 查看幫助
146
- ```powershell
147
- .\.failure\tools\check_failures.ps1 -Help
148
- ```
149
-
150
- ### 輸出結果
151
- 腳本會顯示:
152
- 1. 匹配的失敗記錄數量
153
- 2. 每個失敗記錄的:
154
- - ID 和標題
155
- - 分類和嚴重程度
156
- - 預防檢查清單
157
- - 解決方案參考
158
- 3. 按嚴重程度排序(critical > high > medium > low)
159
-
160
- ## 測試驗證
161
-
162
- ### 測試場景 1:建立新失敗記錄
163
- ```powershell
164
- # 1. 執行腳本建立失敗記錄
165
- .\.failure\tools\log_failure.ps1 `
166
- -Category "pipeline" `
167
- -Title "測試失敗記錄" `
168
- -Severity "low" `
169
- -TaskID "TASK_TEST"
170
-
171
- # 2. 驗證文件已建立
172
- Test-Path .failure/pipeline/FAIL-*.yaml
173
-
174
- # 3. 驗證 INDEX.yaml 已更新
175
- $index = Get-Content .failure/INDEX.yaml -Raw
176
- $index -match "測試失敗記錄" # 應該返回 True
177
- ```
178
-
179
- ### 測試場景 2:檢查失敗模式
180
- ```powershell
181
- # 1. 檢查是否有 pipeline 相關的失敗
182
- .\.failure\tools\check_failures.ps1 -Category "pipeline"
183
-
184
- # 2. 檢查關鍵詞 "JSON" 相關的失敗
185
- .\.failure\tools\check_failures.ps1 -Keywords "JSON"
186
-
187
- # 3. 驗證輸出包含預防措施
188
- .\.failure\tools\check_failures.ps1 -Category "data_integrity" | Select-String "預防"
189
- ```
190
-
191
- ### 測試場景 3:統計數據驗證
192
- ```powershell
193
- # 讀取 INDEX.yaml 並驗證統計數據
194
- $index = Get-Content .failure/INDEX.yaml -Raw | ConvertFrom-Yaml
195
-
196
- # 驗證 total_failures 正確
197
- $totalFiles = (Get-ChildItem .failure/*/FAIL-*.yaml).Count
198
- Write-Host "Total failures in INDEX: $($index.statistics.total_failures)"
199
- Write-Host "Actual YAML files: $totalFiles"
200
-
201
- # 驗證分類統計
202
- $pipelineFiles = (Get-ChildItem .failure/pipeline/FAIL-*.yaml).Count
203
- Write-Host "Pipeline failures in INDEX: $($index.statistics.by_category.pipeline)"
204
- Write-Host "Actual pipeline YAML files: $pipelineFiles"
205
- ```
206
-
207
- **注意**:ConvertFrom-Yaml 需要安裝 powershell-yaml 模組:
208
- ```powershell
209
- Install-Module -Name powershell-yaml -Force
210
- ```
211
-
212
- ## 常見問題
213
-
214
- ### Q1: 執行腳本時顯示「無法辨識字元」或亂碼
215
- **原因**:PowerShell 預設編碼不是 UTF-8,無法正確解析中文字符。
216
-
217
- **解決方案**:
218
- ```powershell
219
- # 使用 PowerShell 7+(推薦)
220
- pwsh -File ".failure/tools/log_failure.ps1" -Help
221
-
222
- # 或在 Windows PowerShell 5.1 中設置編碼
223
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
224
- chcp 65001 # 切換到 UTF-8 代碼頁
225
- ```
226
-
227
- ### Q2: 執行策略阻止腳本運行
228
- **錯誤訊息**:「因為在此系統上禁止執行指令碼」
229
-
230
- **解決方案**:
231
- ```powershell
232
- # 方法 1:暫時繞過執行策略
233
- Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
234
-
235
- # 方法 2:使用參數執行
236
- powershell -ExecutionPolicy Bypass -File ".failure/tools/log_failure.ps1" -Help
237
- ```
238
-
239
- ### Q3: 無法找到 TASK_QUEUE.json
240
- **原因**:check_failures.ps1 依賴 `dev/pipeline/TASK_QUEUE.json`。
241
-
242
- **解決方案**:
243
- ```powershell
244
- # 確認工作目錄在專案根目錄
245
- cd D:\repo\side\ava\KenazAI
246
-
247
- # 或使用其他參數而非 -TaskID
248
- .\.failure\tools\check_failures.ps1 -Keywords "JSON"
249
- ```
250
-
251
- ### Q4: INDEX.yaml 解析失敗
252
- **原因**:YAML 格式錯誤或 BOM 問題。
253
-
254
- **解決方案**:
255
- ```bash
256
- # 檢查 BOM
257
- node .failure/tools/check_bom.js .failure/INDEX.yaml
258
-
259
- # 修復 BOM
260
- node .failure/tools/fix_json.js .failure/INDEX.yaml
261
-
262
- # 驗證 YAML 語法(需要安裝 yq)
263
- yq eval .failure/INDEX.yaml
264
- ```
265
-
266
- ## 整合到工作流程
267
-
268
- ### Agent 執行前
269
- ```powershell
270
- # 檢查相關失敗模式
271
- $taskID = "TASK_081"
272
- .\.failure\tools\check_failures.ps1 -TaskID $taskID
273
- ```
274
-
275
- ### Agent 執行失敗後
276
- ```powershell
277
- # 建立失敗記錄
278
- .\.failure\tools\log_failure.ps1 -Interactive
279
- ```
280
-
281
- ### 定期維護
282
- ```powershell
283
- # 檢視所有失敗記錄
284
- Get-ChildItem .failure/*/FAIL-*.yaml | ForEach-Object {
285
- Write-Host $_.Name -ForegroundColor Cyan
286
- Select-String -Path $_.FullName -Pattern "^# \[" | Select-Object -First 1
287
- }
288
-
289
- # 統計失敗記錄數量
290
- $stats = @{
291
- Total = (Get-ChildItem .failure/*/FAIL-*.yaml).Count
292
- AgentExecution = (Get-ChildItem .failure/agent-execution/*.yaml).Count
293
- CodeQuality = (Get-ChildItem .failure/code-quality/*.yaml).Count
294
- Architecture = (Get-ChildItem .failure/architecture/*.yaml).Count
295
- Pipeline = (Get-ChildItem .failure/pipeline/*.yaml).Count
296
- DataIntegrity = (Get-ChildItem .failure/data-integrity/*.yaml).Count
297
- }
298
- $stats | Format-Table -AutoSize
299
- ```
300
-
301
- ## 相關資源
302
-
303
- - **失敗記錄索引**: `.failure/INDEX.yaml`
304
- - **規則系統**: `.rule/INDEX.yaml`
305
- - **Agent 工作流程**: `.rule/general/agent-workflow.yaml`
306
- - **工具 README**: `.failure/tools/README.md`
307
- - **記憶系統**: `.memory/MEMORY.md`
308
-
309
- ## 下一步計劃
310
-
311
- 以下工具尚未實作(標記為「計劃中」):
312
-
313
- 1. **failure-report.ps1**:生成失敗經驗報告
314
- - 統計失敗記錄數量
315
- - 按分類和嚴重程度分組
316
- - 輸出 Markdown 報告
317
-
318
- 2. **failure-to-rule.ps1**:將失敗轉化為規則
319
- - 分析重複失敗模式
320
- - 自動生成規則文件草稿
321
- - 更新 INDEX.yaml 統計
322
-
323
- 這些工具將在後續任務中實作(見 TASK_082)。
@@ -1,387 +0,0 @@
1
- # check_failures.ps1
2
- # 檢查當前任務是否匹配已知失敗模式的腳本
3
-
4
- <#
5
- .SYNOPSIS
6
- 檢查任務是否匹配已知的失敗模式
7
-
8
- .DESCRIPTION
9
- 此腳本根據任務類型、scope_paths 或關鍵詞搜尋相關失敗記錄,
10
- 輸出預防檢查清單和解決方案參考。
11
-
12
- .PARAMETER TaskID
13
- 任務 ID(如 TASK_077),會從 TASK_QUEUE.json 載入任務詳情
14
-
15
- .PARAMETER AgentType
16
- Agent 類型(developer, backend, frontend, designer, qa, sre)
17
-
18
- .PARAMETER ScopePath
19
- 任務的 scope_paths(如 "dev/pipeline/")
20
-
21
- .PARAMETER Keywords
22
- 搜尋關鍵詞(用逗號分隔)
23
-
24
- .PARAMETER Category
25
- 失敗分類過濾(agent_execution, code_quality, architecture, pipeline, data_integrity)
26
-
27
- .PARAMETER Severity
28
- 嚴重程度過濾(critical, high, medium, low)
29
-
30
- .PARAMETER Help
31
- 顯示幫助訊息
32
-
33
- .EXAMPLE
34
- .\check_failures.ps1 -TaskID "TASK_077"
35
- 檢查特定任務的失敗模式
36
-
37
- .EXAMPLE
38
- .\check_failures.ps1 -AgentType "developer" -ScopePath "dev/pipeline/"
39
- 檢查特定類型和路徑的失敗模式
40
-
41
- .EXAMPLE
42
- .\check_failures.ps1 -Keywords "JSON,BOM,encoding"
43
- 根據關鍵詞搜尋失敗記錄
44
- #>
45
-
46
- param(
47
- [Parameter(Mandatory=$false)]
48
- [string]$TaskID,
49
-
50
- [Parameter(Mandatory=$false)]
51
- [ValidateSet("developer", "backend", "frontend", "designer", "qa", "sre", "architect")]
52
- [string]$AgentType,
53
-
54
- [Parameter(Mandatory=$false)]
55
- [string]$ScopePath,
56
-
57
- [Parameter(Mandatory=$false)]
58
- [string]$Keywords,
59
-
60
- [Parameter(Mandatory=$false)]
61
- [ValidateSet("agent_execution", "code_quality", "architecture", "pipeline", "data_integrity")]
62
- [string]$Category,
63
-
64
- [Parameter(Mandatory=$false)]
65
- [ValidateSet("critical", "high", "medium", "low")]
66
- [string]$Severity,
67
-
68
- [Parameter(Mandatory=$false)]
69
- [switch]$Help
70
- )
71
-
72
- # ============================================================
73
- # 常量定義
74
- # ============================================================
75
- $FAILURE_ROOT = Join-Path (Split-Path $PSScriptRoot -Parent) ""
76
- $INDEX_FILE = Join-Path $FAILURE_ROOT "INDEX.yaml"
77
- $TASK_QUEUE_FILE = "dev/pipeline/TASK_QUEUE.json"
78
-
79
- $CATEGORY_PATHS = @{
80
- "agent_execution" = "agent-execution"
81
- "code_quality" = "code-quality"
82
- "architecture" = "architecture"
83
- "pipeline" = "pipeline"
84
- "data_integrity" = "data-integrity"
85
- }
86
-
87
- $SEVERITY_ICONS = @{
88
- "critical" = "🔴"
89
- "high" = "🟠"
90
- "medium" = "🟡"
91
- "low" = "🟢"
92
- }
93
-
94
- # ============================================================
95
- # 函數定義
96
- # ============================================================
97
-
98
- function Show-Help {
99
- Write-Host @"
100
- 🔍 Failure Pattern Checker
101
-
102
- 使用方式:
103
- .\check_failures.ps1 -TaskID <id> # 檢查特定任務
104
- .\check_failures.ps1 -AgentType <type> # 檢查特定 Agent 類型
105
- .\check_failures.ps1 -ScopePath <path> # 檢查特定路徑
106
- .\check_failures.ps1 -Keywords <keywords> # 關鍵詞搜尋
107
-
108
- 參數:
109
- -TaskID 任務 ID(會從 TASK_QUEUE.json 載入詳情)
110
- -AgentType Agent 類型 (developer, backend, frontend, designer, qa, sre)
111
- -ScopePath 任務的 scope_paths(如 "dev/pipeline/")
112
- -Keywords 搜尋關鍵詞(用逗號分隔)
113
- -Category 失敗分類過濾
114
- -Severity 嚴重程度過濾
115
- -Help 顯示此幫助訊息
116
-
117
- 範例:
118
- .\check_failures.ps1 -TaskID "TASK_077"
119
- .\check_failures.ps1 -AgentType "developer" -ScopePath "dev/pipeline/"
120
- .\check_failures.ps1 -Keywords "JSON,BOM"
121
- .\check_failures.ps1 -Category "pipeline" -Severity "critical"
122
-
123
- 相關資源:
124
- - 失敗記錄索引: .failure/INDEX.yaml
125
- - 任務佇列: dev/pipeline/TASK_QUEUE.json
126
- "@
127
- exit 0
128
- }
129
-
130
- function Get-TaskDetails {
131
- param([string]$TaskID)
132
-
133
- if (-not (Test-Path $TASK_QUEUE_FILE)) {
134
- Write-Warning "⚠️ TASK_QUEUE.json not found, using parameters only"
135
- return $null
136
- }
137
-
138
- try {
139
- $queue = Get-Content $TASK_QUEUE_FILE -Raw | ConvertFrom-Json
140
- $task = $queue.tasks | Where-Object { $_.id -eq $TaskID }
141
-
142
- if (-not $task) {
143
- Write-Warning "⚠️ Task $TaskID not found in queue"
144
- return $null
145
- }
146
-
147
- return $task
148
- } catch {
149
- Write-Warning "⚠️ Failed to parse TASK_QUEUE.json: $_"
150
- return $null
151
- }
152
- }
153
-
154
- function Get-FailureRecords {
155
- if (-not (Test-Path $INDEX_FILE)) {
156
- Write-Error "❌ INDEX.yaml not found at: $INDEX_FILE"
157
- exit 1
158
- }
159
-
160
- $records = @()
161
-
162
- # 遍歷所有分類目錄
163
- foreach ($cat in $CATEGORY_PATHS.Keys) {
164
- $categoryDir = Join-Path $FAILURE_ROOT $CATEGORY_PATHS[$cat]
165
-
166
- if (-not (Test-Path $categoryDir)) {
167
- continue
168
- }
169
-
170
- # 讀取所有 .yaml 文件
171
- $yamlFiles = Get-ChildItem -Path $categoryDir -Filter "*.yaml" -File
172
-
173
- foreach ($file in $yamlFiles) {
174
- try {
175
- $content = Get-Content $file.FullName -Raw
176
-
177
- # 簡單解析 YAML(提取關鍵欄位)
178
- $id = if ($content -match 'id:\s*"([^"]+)"') { $matches[1] } else { "" }
179
- $category = if ($content -match 'category:\s*"([^"]+)"') { $matches[1] } else { $cat }
180
- $severity = if ($content -match 'severity:\s*"([^"]+)"') { $matches[1] } else { "unknown" }
181
- $title = if ($content -match '# \[([^\]]+)\] (.+)') { $matches[2] } else { $file.BaseName }
182
-
183
- $records += [PSCustomObject]@{
184
- ID = $id
185
- Category = $category
186
- Severity = $severity
187
- Title = $title
188
- FilePath = $file.FullName
189
- Content = $content
190
- }
191
- } catch {
192
- Write-Warning "⚠️ Failed to parse $($file.Name): $_"
193
- }
194
- }
195
- }
196
-
197
- return $records
198
- }
199
-
200
- function Test-FailureMatch {
201
- param(
202
- [object]$Record,
203
- [hashtable]$Filters
204
- )
205
-
206
- # 分類過濾
207
- if ($Filters.Category -and $Record.Category -ne $Filters.Category) {
208
- return $false
209
- }
210
-
211
- # 嚴重程度過濾
212
- if ($Filters.Severity -and $Record.Severity -ne $Filters.Severity) {
213
- return $false
214
- }
215
-
216
- # Agent 類型匹配
217
- if ($Filters.AgentType) {
218
- # 檢查失敗記錄中是否提到該 agent_type
219
- $agentMatch = $Record.Content -match $Filters.AgentType
220
- if (-not $agentMatch) {
221
- return $false
222
- }
223
- }
224
-
225
- # Scope 路徑匹配
226
- if ($Filters.ScopePath) {
227
- # 檢查失敗記錄中是否提到該路徑
228
- $pathMatch = $Record.Content -match [regex]::Escape($Filters.ScopePath)
229
- if (-not $pathMatch) {
230
- return $false
231
- }
232
- }
233
-
234
- # 關鍵詞匹配
235
- if ($Filters.Keywords) {
236
- $keywordList = $Filters.Keywords -split ','
237
- $matched = $false
238
-
239
- foreach ($keyword in $keywordList) {
240
- if ($Record.Content -match [regex]::Escape($keyword.Trim())) {
241
- $matched = $true
242
- break
243
- }
244
- }
245
-
246
- if (-not $matched) {
247
- return $false
248
- }
249
- }
250
-
251
- return $true
252
- }
253
-
254
- function Show-FailureRecord {
255
- param([object]$Record)
256
-
257
- $icon = $SEVERITY_ICONS[$Record.Severity]
258
- Write-Host "`n$icon [$($Record.ID)] $($Record.Title)" -ForegroundColor Cyan
259
- Write-Host " 分類: $($Record.Category) | 嚴重程度: $($Record.Severity)" -ForegroundColor Gray
260
-
261
- # 提取預防措施
262
- if ($Record.Content -match '## 預防措施(.+?)(?=##|$)') {
263
- $prevention = $matches[1].Trim()
264
-
265
- # 提取檢查清單
266
- if ($prevention -match '### 檢查清單(.+?)(?=###|$)') {
267
- $checklist = $matches[1].Trim()
268
- Write-Host "`n 📋 預防檢查清單:" -ForegroundColor Yellow
269
- $checklistItems = $checklist -split "`n" | Where-Object { $_ -match '- \[' }
270
- foreach ($item in $checklistItems) {
271
- Write-Host " $item" -ForegroundColor White
272
- }
273
- }
274
- }
275
-
276
- # 提取解決方案
277
- if ($Record.Content -match '## 解決方案(.+?)(?=##|$)') {
278
- $solution = $matches[1].Trim()
279
- Write-Host "`n 💡 解決方案參考:" -ForegroundColor Yellow
280
- $solutionLines = $solution -split "`n" | Select-Object -First 3
281
- foreach ($line in $solutionLines) {
282
- if ($line.Trim()) {
283
- Write-Host " $($line.Trim())" -ForegroundColor White
284
- }
285
- }
286
- Write-Host " (詳見: $($Record.FilePath))" -ForegroundColor Gray
287
- }
288
- }
289
-
290
- # ============================================================
291
- # 主程序
292
- # ============================================================
293
-
294
- if ($Help) {
295
- Show-Help
296
- }
297
-
298
- Write-Host "🔍 Failure Pattern Checker" -ForegroundColor Cyan
299
- Write-Host "=========================`n" -ForegroundColor Cyan
300
-
301
- # 如果提供了 TaskID,載入任務詳情
302
- $task = $null
303
- if ($TaskID) {
304
- Write-Host "📋 載入任務: $TaskID" -ForegroundColor Yellow
305
- $task = Get-TaskDetails -TaskID $TaskID
306
-
307
- if ($task) {
308
- Write-Host " Agent Type: $($task.agent_type)" -ForegroundColor Gray
309
- Write-Host " Scope Paths: $($task.scope_paths -join ', ')" -ForegroundColor Gray
310
-
311
- # 自動填充參數
312
- if (-not $AgentType) { $AgentType = $task.agent_type }
313
- if (-not $ScopePath -and $task.scope_paths) { $ScopePath = $task.scope_paths[0] }
314
- }
315
- }
316
-
317
- # 建立過濾器
318
- $filters = @{}
319
- if ($Category) { $filters.Category = $Category }
320
- if ($Severity) { $filters.Severity = $Severity }
321
- if ($AgentType) { $filters.AgentType = $AgentType }
322
- if ($ScopePath) { $filters.ScopePath = $ScopePath }
323
- if ($Keywords) { $filters.Keywords = $Keywords }
324
-
325
- # 顯示搜尋條件
326
- Write-Host "`n🔎 搜尋條件:" -ForegroundColor Yellow
327
- if ($filters.Count -eq 0) {
328
- Write-Host " (無過濾條件,顯示所有失敗記錄)" -ForegroundColor Gray
329
- } else {
330
- foreach ($key in $filters.Keys) {
331
- Write-Host " $key`: $($filters[$key])" -ForegroundColor Gray
332
- }
333
- }
334
-
335
- # 載入所有失敗記錄
336
- Write-Host "`n📂 載入失敗記錄..." -ForegroundColor Cyan
337
- $allRecords = Get-FailureRecords
338
- Write-Host " 找到 $($allRecords.Count) 筆失敗記錄" -ForegroundColor Gray
339
-
340
- # 過濾匹配的記錄
341
- $matchedRecords = @()
342
- foreach ($record in $allRecords) {
343
- if (Test-FailureMatch -Record $record -Filters $filters) {
344
- $matchedRecords += $record
345
- }
346
- }
347
-
348
- # 顯示結果
349
- Write-Host "`n📊 匹配結果: $($matchedRecords.Count) 筆" -ForegroundColor Green
350
-
351
- if ($matchedRecords.Count -eq 0) {
352
- Write-Host "`n✅ 未發現相關失敗模式" -ForegroundColor Green
353
- Write-Host " 建議繼續進行任務,但保持警覺" -ForegroundColor Gray
354
- exit 0
355
- }
356
-
357
- # 按嚴重程度排序
358
- $sortedRecords = $matchedRecords | Sort-Object @{Expression={
359
- switch ($_.Severity) {
360
- "critical" { 1 }
361
- "high" { 2 }
362
- "medium" { 3 }
363
- "low" { 4 }
364
- default { 5 }
365
- }
366
- }}
367
-
368
- # 顯示匹配的失敗記錄
369
- Write-Host "`n⚠️ 發現以下相關失敗模式,請注意預防:" -ForegroundColor Yellow
370
-
371
- foreach ($record in $sortedRecords) {
372
- Show-FailureRecord -Record $record
373
- }
374
-
375
- # 總結建議
376
- Write-Host "`n" + ("="*60) -ForegroundColor Cyan
377
- Write-Host "📌 建議行動:" -ForegroundColor Yellow
378
- Write-Host " 1. 仔細閱讀上述失敗記錄的預防檢查清單" -ForegroundColor White
379
- Write-Host " 2. 在執行任務前完成所有相關檢查" -ForegroundColor White
380
- Write-Host " 3. 參考解決方案避免重複失敗" -ForegroundColor White
381
- Write-Host " 4. 如遇到新的失敗模式,執行 .\log_failure.ps1 記錄" -ForegroundColor White
382
- Write-Host "`n相關資源:" -ForegroundColor Yellow
383
- Write-Host " - 規則系統: .rule/INDEX.yaml" -ForegroundColor Gray
384
- Write-Host " - Agent 工作流程: .rule/general/agent-workflow.yaml" -ForegroundColor Gray
385
- Write-Host " - 失敗記錄索引: .failure/INDEX.yaml" -ForegroundColor Gray
386
-
387
- exit 0