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,86 +0,0 @@
1
- // cleanup_queue.js
2
- // 清理 TASK_QUEUE.json 中的已完成任務
3
- // 只保留 pending/in_progress/blocked 狀態的任務
4
-
5
- const fs = require('fs');
6
- const path = require('path');
7
-
8
- const queuePath = path.join(__dirname, '..', 'pipeline', 'TASK_QUEUE.json');
9
-
10
- try {
11
- console.log('🔧 開始清理 TASK_QUEUE.json...\n');
12
-
13
- // 讀取並移除 BOM(如果存在)
14
- let content = fs.readFileSync(queuePath, 'utf8');
15
- let hadBOM = false;
16
- if (content.charCodeAt(0) === 0xFEFF) {
17
- content = content.slice(1);
18
- hadBOM = true;
19
- console.log('⚠️ 檢測到 BOM,已移除');
20
- }
21
-
22
- // 解析 JSON
23
- const data = JSON.parse(content);
24
-
25
- // 記錄清理前狀態
26
- const beforeCount = data.tasks.length;
27
- const completedCount = data.tasks.filter(t => t.status === 'completed').length;
28
- const cancelledCount = data.tasks.filter(t => t.status === 'cancelled').length;
29
-
30
- console.log(`📊 清理前統計:`);
31
- console.log(` 總任務數: ${beforeCount}`);
32
- console.log(` 已完成: ${completedCount}`);
33
- console.log(` 已取消: ${cancelledCount}`);
34
- console.log(` 待處理: ${data.tasks.filter(t => t.status === 'pending').length}`);
35
- console.log(` 執行中: ${data.tasks.filter(t => t.status === 'in_progress').length}`);
36
- console.log(` 已阻塞: ${data.tasks.filter(t => t.status === 'blocked').length}\n`);
37
-
38
- // 只保留 pending/in_progress/blocked 任務
39
- data.tasks = data.tasks.filter(t =>
40
- ['pending', 'in_progress', 'blocked'].includes(t.status)
41
- );
42
-
43
- // 重新計算統計數據(當前佇列制)
44
- data.statistics = {
45
- total: data.tasks.length,
46
- pending: data.tasks.filter(t => t.status === 'pending').length,
47
- in_progress: data.tasks.filter(t => t.status === 'in_progress').length,
48
- blocked: data.tasks.filter(t => t.status === 'blocked').length,
49
- completed: 0, // 當前佇列中沒有已完成任務
50
- cancelled: 0 // 當前佇列中沒有已取消任務
51
- };
52
-
53
- // 更新時間戳
54
- data.last_updated = new Date().toISOString();
55
-
56
- // 寫回文件(無 BOM)
57
- fs.writeFileSync(queuePath, JSON.stringify(data, null, 2), 'utf8');
58
-
59
- console.log(`✅ 清理完成!\n`);
60
- console.log(`📊 清理後統計:`);
61
- console.log(` 總任務數: ${data.statistics.total}`);
62
- console.log(` 待處理: ${data.statistics.pending}`);
63
- console.log(` 執行中: ${data.statistics.in_progress}`);
64
- console.log(` 已阻塞: ${data.statistics.blocked}`);
65
- console.log(` 已完成: ${data.statistics.completed}`);
66
- console.log(` 已取消: ${data.statistics.cancelled}\n`);
67
-
68
- if (hadBOM) {
69
- console.log('🔧 已移除 BOM 編碼問題');
70
- }
71
-
72
- console.log(`🗑️ 已移除 ${completedCount + cancelledCount} 個已完成/已取消任務`);
73
-
74
- // 驗證結果
75
- const stillHasCompleted = data.tasks.some(t => t.status === 'completed' || t.status === 'cancelled');
76
- if (stillHasCompleted) {
77
- console.error('\n❌ 錯誤:佇列中仍有已完成/已取消任務!');
78
- process.exit(1);
79
- }
80
-
81
- console.log('\n✅ 驗證通過:佇列已清理乾淨');
82
-
83
- } catch (error) {
84
- console.error('\n❌ 清理失敗:', error.message);
85
- process.exit(1);
86
- }
@@ -1,39 +0,0 @@
1
- # Legacy Scripts
2
-
3
- This directory contains deprecated scripts that have been replaced by Rust implementations.
4
-
5
- ## Archived Scripts
6
-
7
- ### dev_agent_scheduler.ps1.bak
8
- - **Original Location**: `dev/scripts/dev_agent_scheduler.ps1`
9
- - **Archived Date**: 2026-02-05
10
- - **Replacement**: Rust Self-Enhancement Scheduler module
11
- - **New Location**: `dashboard/src-tauri/src/cmd_modules/self_enhancement/`
12
-
13
- **Reason for deprecation:**
14
- 1. The PowerShell script required external process spawning from Tauri, which had reliability issues on Windows
15
- 2. Cross-platform compatibility was limited
16
- 3. The Rust implementation provides better integration with the Tauri event system
17
- 4. Real-time status updates and proper state management through the dashboard UI
18
-
19
- **How to use the new system:**
20
- - Via Dashboard: Quick Actions > Self-Enhancement Card
21
- - Via Tauri Commands: `start_self_enhancement`, `stop_self_enhancement`, `get_self_enhancement_status`
22
-
23
- ### multi_agent_scheduler.ps1.bak
24
- - **Original Location**: `dev/scripts/multi_agent_scheduler.ps1`
25
- - **Archived Date**: 2026-02-03
26
- - **Replacement**: Rust Multi-Agent Scheduler module
27
- - **New Location**: `dashboard/src-tauri/src/cmd_modules/scheduler/`
28
-
29
- ## Rollback Instructions
30
-
31
- If you need to use the legacy PowerShell scripts:
32
-
33
- 1. Copy the `.bak` file back to its original location (remove `.bak` extension)
34
- 2. Run the script directly via PowerShell:
35
- ```powershell
36
- .\dev\scripts\dev_agent_scheduler.ps1 -InitialDelaySeconds 30 -IntervalMinutes 20
37
- ```
38
-
39
- Note: The legacy scripts are kept for reference and emergency rollback only. They are no longer maintained.
@@ -1,536 +0,0 @@
1
- # ============================================================
2
- # Dev Agent Scheduler - Self-Enhancement Mode
3
- # ============================================================
4
- # 自我增強迭代模式:
5
- # 1. 執行 /dev 完成開發任務
6
- # 2. 當沒有 pending tasks 時,呼叫 /產品檢視 分析專案
7
- # 3. 根據分析結果決定繼續迭代或結束
8
- # ============================================================
9
-
10
- param(
11
- [int]$InitialDelaySeconds = 30,
12
- [int]$IntervalMinutes = 20,
13
- [int]$EarlyFinishDelaySeconds = 30,
14
- [int]$TotalRuns = 16,
15
- [int]$MaxEnhancementCycles = 3, # 最大自我增強循環次數
16
- [string]$WorkingDirectory, # 工作目錄
17
- [switch]$nopause # 從 Tauri 調用時使用(跳過暫停)
18
- )
19
-
20
- # Helper function to normalize Windows extended path format (\\?\)
21
- function Get-NormalizedPath {
22
- param([string]$Path)
23
- if ($Path -and $Path.StartsWith("\\?\")) {
24
- return $Path.Substring(4)
25
- }
26
- return $Path
27
- }
28
-
29
- # Use KENAZ_PROJECT_PATH env var if WorkingDirectory not specified
30
- if (-not $WorkingDirectory) {
31
- if ($env:KENAZ_PROJECT_PATH) {
32
- $WorkingDirectory = $env:KENAZ_PROJECT_PATH
33
- } else {
34
- $WorkingDirectory = (Get-Location).Path
35
- }
36
- }
37
-
38
- # Normalize WorkingDirectory to handle \\?\ prefix from Tauri
39
- $WorkingDirectory = Get-NormalizedPath $WorkingDirectory
40
-
41
- # Config
42
- $LogFile = Join-Path $WorkingDirectory "dev\pipeline\logs\scheduler_$(Get-Date -Format 'yyyy-MM-dd').log"
43
- $StatusFile = Join-Path $WorkingDirectory "dev\pipeline\SELF_ENHANCEMENT_STATUS.json"
44
-
45
- # Ensure log directory exists
46
- $LogDir = Split-Path $LogFile -Parent
47
- if (-not (Test-Path $LogDir)) {
48
- New-Item -ItemType Directory -Path $LogDir -Force | Out-Null
49
- }
50
-
51
- function Write-Log {
52
- param([string]$Message, [switch]$NoConsole)
53
- $Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
54
- $LogMessage = "[$Timestamp] $Message"
55
- if (-not $NoConsole) {
56
- Write-Host $LogMessage
57
- }
58
- Add-Content -Path $LogFile -Value $LogMessage -Encoding UTF8
59
- }
60
-
61
- function Get-ProgressInfo {
62
- $ProgressFile = Join-Path $WorkingDirectory "dev\pipeline\PROGRESS.md"
63
-
64
- $info = @{
65
- HasPendingTasks = $false
66
- CurrentTask = $null
67
- NextTask = $null
68
- Completed = 0
69
- Total = 0
70
- Pending = 0
71
- InProgress = 0
72
- }
73
-
74
- if (-not (Test-Path $ProgressFile)) {
75
- $info.HasPendingTasks = $true
76
- return $info
77
- }
78
-
79
- try {
80
- $Content = Get-Content $ProgressFile -Raw -Encoding UTF8
81
-
82
- # Count from statistics section
83
- $lines = $Content -split "`n"
84
- foreach ($line in $lines) {
85
- # 分開處理 Total 匹配,避免 -or 導致 $Matches 混亂
86
- if ($line -match "Total.*?:\s*(\d+)") {
87
- $info.Total = [int]$Matches[1]
88
- }
89
- elseif (($line -match "task") -and ($line -match ":\s*(\d+)\s*$")) {
90
- $info.Total = [int]$Matches[1]
91
- }
92
-
93
- # 分開處理完成數匹配
94
- if (($line -match "complet" -or $line -match "done") -and ($line -match "(\d+)\s*\(\d+%\)")) {
95
- $info.Completed = [int]$Matches[1]
96
- }
97
- }
98
-
99
- # Check tasks directory for pending count
100
- $tasksDir = Join-Path $WorkingDirectory "dev\pipeline\tasks"
101
- if (Test-Path $tasksDir) {
102
- $taskFiles = Get-ChildItem -Path $tasksDir -Filter "TASK_*.md" -ErrorAction SilentlyContinue
103
- $info.Pending = $taskFiles.Count
104
- if ($info.Pending -gt 0) {
105
- $info.HasPendingTasks = $true
106
-
107
- $firstTask = $taskFiles | Sort-Object Name | Select-Object -First 1
108
- if ($firstTask) {
109
- $taskId = $firstTask.BaseName -replace '_.*$', ''
110
- $taskName = $firstTask.BaseName -replace '^TASK_\d+_', '' -replace '_', ' '
111
- $info.NextTask = "${taskId}: $taskName"
112
- }
113
- }
114
- }
115
-
116
- # Check completed directory
117
- $completedDir = Join-Path $WorkingDirectory "dev\pipeline\completed"
118
- if (Test-Path $completedDir) {
119
- $completedFiles = Get-ChildItem -Path $completedDir -Filter "TASK_*.md" -ErrorAction SilentlyContinue
120
- $info.Completed = $completedFiles.Count
121
- }
122
-
123
- if ($info.Total -eq 0) {
124
- $info.Total = $info.Pending + $info.Completed + $info.InProgress
125
- }
126
-
127
- # Check for status markers in table format
128
- if ($Content -match "\|\s*pending\s*\|") {
129
- $info.HasPendingTasks = $true
130
- }
131
- if ($Content -match "\|\s*in_progress\s*\|") {
132
- $info.HasPendingTasks = $true
133
- $info.InProgress = 1
134
- }
135
-
136
- if ($Content -match "\|\s*P[0-2]\s*\|\s*(TASK_\d+)\s*\|([^|]+)\|\s*pending\s*\|") {
137
- $info.NextTask = "$($Matches[1]): $($Matches[2].Trim())"
138
- }
139
-
140
- } catch {
141
- Write-Log "Error reading PROGRESS.md: $_"
142
- $info.HasPendingTasks = $true
143
- }
144
-
145
- return $info
146
- }
147
-
148
- function Show-ProgressStatus {
149
- $info = Get-ProgressInfo
150
-
151
- Write-Host ""
152
- Write-Host "------------------------------------------------------------"
153
- Write-Host " Progress: $($info.Completed) / $($info.Total) completed ($($info.Pending) pending)"
154
-
155
- if ($info.CurrentTask) {
156
- Write-Host " Current: $($info.CurrentTask)" -ForegroundColor Yellow
157
- }
158
- if ($info.NextTask) {
159
- Write-Host " Next: $($info.NextTask)" -ForegroundColor Cyan
160
- }
161
- Write-Host "------------------------------------------------------------"
162
- Write-Host ""
163
-
164
- return $info
165
- }
166
-
167
- function Test-HasPendingTasks {
168
- $info = Get-ProgressInfo
169
- return $info.HasPendingTasks
170
- }
171
-
172
- function Invoke-DevAgent {
173
- param(
174
- [int]$RunNumber,
175
- [int]$TimeoutMinutes = 60
176
- )
177
-
178
- Write-Log "=========================================="
179
- Write-Log "Starting Dev Agent (Run $RunNumber / $TotalRuns)"
180
- Write-Log "=========================================="
181
-
182
- try {
183
- Push-Location $WorkingDirectory
184
-
185
- $Command = "claude"
186
- $Arguments = "--dangerously-skip-permissions /dev"
187
- Write-Log "Command: $Command $Arguments"
188
-
189
- # 使用 Start-Process 配合超時機制
190
- $pinfo = New-Object System.Diagnostics.ProcessStartInfo
191
- $pinfo.FileName = $Command
192
- $pinfo.Arguments = $Arguments
193
- $pinfo.RedirectStandardOutput = $true
194
- $pinfo.RedirectStandardError = $true
195
- $pinfo.UseShellExecute = $false
196
- $pinfo.WorkingDirectory = $WorkingDirectory
197
-
198
- $process = New-Object System.Diagnostics.Process
199
- $process.StartInfo = $pinfo
200
- $process.Start() | Out-Null
201
-
202
- $TimeoutMs = $TimeoutMinutes * 60 * 1000
203
- $completed = $process.WaitForExit($TimeoutMs)
204
-
205
- if (-not $completed) {
206
- Write-Log "WARNING: Command timed out after $TimeoutMinutes minutes. Killing process..."
207
- $process.Kill()
208
- Write-Log "Process killed due to timeout"
209
- } else {
210
- $stdout = $process.StandardOutput.ReadToEnd()
211
- $stderr = $process.StandardError.ReadToEnd()
212
-
213
- if ($stdout) {
214
- Write-Log "Output: $($stdout.Substring(0, [Math]::Min(500, $stdout.Length)))..." -NoConsole
215
- }
216
- if ($stderr) {
217
- Write-Log "Stderr: $stderr"
218
- }
219
- Write-Log "Execution completed with exit code: $($process.ExitCode)"
220
- }
221
-
222
- } catch {
223
- Write-Log "Error: $_"
224
- } finally {
225
- Pop-Location
226
- }
227
-
228
- Write-Log "Run $RunNumber finished"
229
- Write-Log ""
230
- }
231
-
232
- function Invoke-ProductReview {
233
- param(
234
- [int]$TimeoutMinutes = 30
235
- )
236
-
237
- Write-Log "=========================================="
238
- Write-Log "Starting Product Review (Self-Enhancement)"
239
- Write-Log "=========================================="
240
-
241
- try {
242
- Push-Location $WorkingDirectory
243
-
244
- # 備份舊的狀態文件而非直接刪除
245
- if (Test-Path $StatusFile) {
246
- $backupFile = "${StatusFile}.bak"
247
- Move-Item $StatusFile $backupFile -Force
248
- Write-Log "Backed up previous status file"
249
- }
250
-
251
- # 使用英文指令避免 PowerShell 編碼問題
252
- $Command = "claude"
253
- $Arguments = '--dangerously-skip-permissions /product-review'
254
- Write-Log "Command: $Command $Arguments"
255
-
256
- # 使用 Start-Process 配合超時機制
257
- $pinfo = New-Object System.Diagnostics.ProcessStartInfo
258
- $pinfo.FileName = $Command
259
- $pinfo.Arguments = $Arguments
260
- $pinfo.RedirectStandardOutput = $true
261
- $pinfo.RedirectStandardError = $true
262
- $pinfo.UseShellExecute = $false
263
- $pinfo.WorkingDirectory = $WorkingDirectory
264
- $pinfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
265
- $pinfo.StandardErrorEncoding = [System.Text.Encoding]::UTF8
266
-
267
- $process = New-Object System.Diagnostics.Process
268
- $process.StartInfo = $pinfo
269
- $process.Start() | Out-Null
270
-
271
- $TimeoutMs = $TimeoutMinutes * 60 * 1000
272
- $completed = $process.WaitForExit($TimeoutMs)
273
-
274
- if (-not $completed) {
275
- Write-Log "WARNING: Product Review timed out after $TimeoutMinutes minutes. Killing process..."
276
- $process.Kill()
277
- Write-Log "Process killed due to timeout"
278
-
279
- # 如果超時,恢復備份的狀態文件
280
- $backupFile = "${StatusFile}.bak"
281
- if (Test-Path $backupFile) {
282
- Move-Item $backupFile $StatusFile -Force
283
- Write-Log "Restored previous status file due to timeout"
284
- }
285
- } else {
286
- $stdout = $process.StandardOutput.ReadToEnd()
287
- $stderr = $process.StandardError.ReadToEnd()
288
-
289
- if ($stdout) {
290
- Write-Log "Output: $($stdout.Substring(0, [Math]::Min(500, $stdout.Length)))..." -NoConsole
291
- }
292
- if ($stderr) {
293
- Write-Log "Stderr: $stderr"
294
- }
295
- Write-Log "Product Review completed with exit code: $($process.ExitCode)"
296
- }
297
-
298
- } catch {
299
- Write-Log "Error in Product Review: $_"
300
-
301
- # 發生錯誤時恢復備份
302
- $backupFile = "${StatusFile}.bak"
303
- if (Test-Path $backupFile) {
304
- Move-Item $backupFile $StatusFile -Force
305
- Write-Log "Restored previous status file due to error"
306
- }
307
- } finally {
308
- Pop-Location
309
- }
310
- }
311
-
312
- function Get-EnhancementStatus {
313
- if (-not (Test-Path $StatusFile)) {
314
- return @{
315
- Status = "unknown"
316
- Decision = "Status file not found"
317
- }
318
- }
319
-
320
- try {
321
- $Content = Get-Content $StatusFile -Raw -Encoding UTF8
322
- $Json = $Content | ConvertFrom-Json
323
- return @{
324
- Status = $Json.status
325
- Decision = $Json.decision
326
- Reason = $Json.reason
327
- NewTasks = $Json.new_tasks
328
- }
329
- } catch {
330
- Write-Log "Error reading status file: $_"
331
- return @{
332
- Status = "error"
333
- Decision = "Failed to parse status file"
334
- }
335
- }
336
- }
337
-
338
- # ============================================================
339
- # Main
340
- # ============================================================
341
-
342
- Clear-Host
343
- Write-Host ""
344
- Write-Host "============================================================"
345
- Write-Host " Dev Agent Scheduler - Self-Enhancement Mode"
346
- Write-Host "============================================================"
347
- Write-Host " Initial Delay: $InitialDelaySeconds seconds"
348
- Write-Host " Interval: $IntervalMinutes minutes (or ${EarlyFinishDelaySeconds}s if finished early)"
349
- Write-Host " Total Runs: $TotalRuns"
350
- Write-Host " Max Enhancement Cycles: $MaxEnhancementCycles"
351
- Write-Host " Working Dir: $WorkingDirectory"
352
- Write-Host "============================================================"
353
- Write-Host ""
354
-
355
- Write-Log "Scheduler started (Self-Enhancement Mode)"
356
- Write-Log "Config: InitialDelay=${InitialDelaySeconds}s, Interval=${IntervalMinutes}min, MaxCycles=$MaxEnhancementCycles"
357
-
358
- # Execute schedule with self-enhancement
359
- $RunCount = 0
360
- $EnhancementCycle = 0
361
- $StoppedEarly = $false
362
- $ProjectComplete = $false
363
- $global:HasSuggestions = $false # 是否有優化建議
364
- $IntervalSeconds = $IntervalMinutes * 60
365
- $LastRunStart = Get-Date # 初始化以避免未定義變數錯誤
366
-
367
- while ($RunCount -lt $TotalRuns -and -not $ProjectComplete) {
368
- $RunCount++
369
-
370
- # Check if there are pending tasks before waiting
371
- $progressInfo = Show-ProgressStatus
372
-
373
- if (-not $progressInfo.HasPendingTasks) {
374
- # ============================================================
375
- # 自我增強模式:沒有 pending tasks,執行產品檢視
376
- # ============================================================
377
-
378
- if ($EnhancementCycle -ge $MaxEnhancementCycles) {
379
- Write-Log "=========================================="
380
- Write-Log "Max enhancement cycles ($MaxEnhancementCycles) reached!"
381
- Write-Log "Stopping to prevent infinite loop."
382
- Write-Log "=========================================="
383
- $StoppedEarly = $true
384
- break
385
- }
386
-
387
- $EnhancementCycle++
388
- Write-Host ""
389
- Write-Host "============================================================" -ForegroundColor Magenta
390
- Write-Host " Self-Enhancement Cycle $EnhancementCycle / $MaxEnhancementCycles" -ForegroundColor Magenta
391
- Write-Host " No pending tasks - Running Product Review..." -ForegroundColor Magenta
392
- Write-Host "============================================================" -ForegroundColor Magenta
393
- Write-Host ""
394
-
395
- Write-Log "Self-Enhancement Cycle ${EnhancementCycle} - Running Product Review"
396
-
397
- Invoke-ProductReview
398
-
399
- # 檢查決策結果
400
- $enhancementStatus = Get-EnhancementStatus
401
-
402
- Write-Host ""
403
- Write-Host "------------------------------------------------------------"
404
- $statusColor = switch ($enhancementStatus.Status) {
405
- "complete" { "Green" }
406
- "complete_with_suggestions" { "Cyan" }
407
- default { "Yellow" }
408
- }
409
- Write-Host " Enhancement Decision: $($enhancementStatus.Status)" -ForegroundColor $statusColor
410
- Write-Host " Reason: $($enhancementStatus.Decision)"
411
- if ($enhancementStatus.NewTasks) {
412
- Write-Host " New Tasks: $($enhancementStatus.NewTasks -join ', ')" -ForegroundColor Cyan
413
- }
414
- Write-Host "------------------------------------------------------------"
415
- Write-Host ""
416
-
417
- if ($enhancementStatus.Status -eq "complete") {
418
- Write-Log "=========================================="
419
- Write-Log "PROJECT COMPLETE!"
420
- Write-Log "Decision: $($enhancementStatus.Decision)"
421
- Write-Log "Reason: $($enhancementStatus.Reason)"
422
- Write-Log "=========================================="
423
- $ProjectComplete = $true
424
- break
425
- }
426
-
427
- if ($enhancementStatus.Status -eq "complete_with_suggestions") {
428
- Write-Log "=========================================="
429
- Write-Log "PROJECT COMPLETE (with optimization suggestions)"
430
- Write-Log "Decision: $($enhancementStatus.Decision)"
431
- Write-Log "Reason: $($enhancementStatus.Reason)"
432
- Write-Log "Check SELF_ENHANCEMENT_STATUS.json for suggestions"
433
- Write-Log "=========================================="
434
- $ProjectComplete = $true
435
- $global:HasSuggestions = $true
436
- break
437
- }
438
-
439
- if ($enhancementStatus.Status -eq "continue") {
440
- Write-Log "Enhancement added new tasks. Continuing development..."
441
- # 重新檢查 pending tasks
442
- $progressInfo = Get-ProgressInfo
443
- if (-not $progressInfo.HasPendingTasks) {
444
- Write-Log "Warning: Status says continue but no new tasks found. Stopping."
445
- $StoppedEarly = $true
446
- break
447
- }
448
- } else {
449
- Write-Log "Unknown enhancement status: $($enhancementStatus.Status). Stopping."
450
- $StoppedEarly = $true
451
- break
452
- }
453
- }
454
-
455
- # Determine wait time
456
- if ($RunCount -eq 1) {
457
- $WaitSeconds = $InitialDelaySeconds
458
- } else {
459
- $ElapsedSeconds = ((Get-Date) - $LastRunStart).TotalSeconds
460
-
461
- if ($ElapsedSeconds -lt $IntervalSeconds) {
462
- $WaitSeconds = $EarlyFinishDelaySeconds
463
- Write-Log "Previous run finished early, waiting ${EarlyFinishDelaySeconds}s"
464
- } else {
465
- $WaitSeconds = 0
466
- }
467
- }
468
-
469
- if ($WaitSeconds -gt 0) {
470
- $TargetTime = (Get-Date).AddSeconds($WaitSeconds)
471
- Write-Host ""
472
- Write-Host "Waiting... Next run (${RunCount}/${TotalRuns}): $($TargetTime.ToString('HH:mm:ss')) ($WaitSeconds seconds)"
473
- Write-Host "Press Ctrl+C to cancel"
474
- Write-Host ""
475
-
476
- while ((Get-Date) -lt $TargetTime) {
477
- $Remaining = ($TargetTime - (Get-Date)).TotalSeconds
478
- $Minutes = [math]::Floor($Remaining / 60)
479
- $Seconds = [math]::Floor($Remaining % 60)
480
- Write-Host -NoNewline "`r Remaining: $($Minutes.ToString('00')):$($Seconds.ToString('00')) "
481
- Start-Sleep -Seconds 1
482
- }
483
- Write-Host ""
484
- }
485
-
486
- $LastRunStart = Get-Date
487
-
488
- # Log current task info
489
- $taskInfo = Get-ProgressInfo
490
- if ($taskInfo.NextTask) {
491
- Write-Log "Target task: $($taskInfo.NextTask)"
492
- }
493
-
494
- Invoke-DevAgent -RunNumber $RunCount
495
-
496
- # Check again after execution
497
- if (-not (Test-HasPendingTasks)) {
498
- Write-Log "All current tasks completed. Will check for enhancement..."
499
- # 讓下一個循環處理自我增強
500
- continue
501
- }
502
- }
503
-
504
- # ============================================================
505
- # 結束摘要
506
- # ============================================================
507
-
508
- Write-Host ""
509
- Write-Host "============================================================"
510
- if ($ProjectComplete -and $global:HasSuggestions) {
511
- Write-Host " PROJECT COMPLETE (with suggestions)" -ForegroundColor Cyan
512
- Write-Host " All PRODUCT_SPEC requirements fulfilled." -ForegroundColor Green
513
- Write-Host " AI has optimization suggestions for review." -ForegroundColor Yellow
514
- Write-Host " See: dev/pipeline/SELF_ENHANCEMENT_STATUS.json" -ForegroundColor Yellow
515
- } elseif ($ProjectComplete) {
516
- Write-Host " PROJECT COMPLETE!" -ForegroundColor Green
517
- Write-Host " All PRODUCT_SPEC requirements fulfilled." -ForegroundColor Green
518
- } elseif ($StoppedEarly) {
519
- Write-Host " Scheduler Stopped Early" -ForegroundColor Yellow
520
- } else {
521
- Write-Host " Schedule Completed" -ForegroundColor Cyan
522
- }
523
- Write-Host "------------------------------------------------------------"
524
- Write-Host " Total Dev Runs: $RunCount"
525
- Write-Host " Enhancement Cycles: $EnhancementCycle"
526
- Write-Host " Log file: $LogFile"
527
- Write-Host "============================================================"
528
- Write-Host ""
529
-
530
- Write-Log "=========================================="
531
- Write-Log "Scheduler finished"
532
- Write-Log "Total Dev Runs: $RunCount, Enhancement Cycles: $EnhancementCycle"
533
- Write-Log "Project Complete: $ProjectComplete"
534
- Write-Log "=========================================="
535
-
536
- Write-Host "Scheduler finished"