mixdog 1.4.1 → 1.4.2

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 (326) hide show
  1. package/package.json +3 -2
  2. package/scripts/build-shipped-history.mjs +115 -33
  3. package/scripts/gate-local.mjs +172 -61
  4. package/scripts/lib/gate-scheduler.mjs +138 -32
  5. package/scripts/lib/gate-timing-reporter.mjs +16 -0
  6. package/scripts/lib/run-node-tests.mjs +54 -29
  7. package/scripts/lib/scoped-temp.mjs +1 -0
  8. package/scripts/lib/test-failure-records.mjs +14 -1
  9. package/scripts/lib/test-failure-summary.mjs +16 -4
  10. package/scripts/lib/test-spawn-ledger.mjs +12 -3
  11. package/scripts/pptx-kit-index.mjs +5 -6
  12. package/scripts/suite-health.mjs +110 -28
  13. package/scripts/test.mjs +9 -14
  14. package/src/agents/advisor/AGENT.md +4 -4
  15. package/src/agents/advisor/agent.json +1 -1
  16. package/src/agents/explore/AGENT.md +22 -0
  17. package/src/agents/explore/agent.json +6 -0
  18. package/src/cli.mjs +7 -0
  19. package/src/defaults/agents.json +7 -0
  20. package/src/defaults/shipped-history.json +18 -2
  21. package/src/defaults/skills/browser-use/SKILL.md +4 -1
  22. package/src/defaults/skills/code-tidy/SKILL.md +71 -102
  23. package/src/defaults/skills/code-tidy/references/agent-cleanup.md +66 -114
  24. package/src/defaults/skills/code-tidy/references/cleanup-report.md +19 -35
  25. package/src/defaults/skills/code-tidy/references/dead-code.md +3 -9
  26. package/src/defaults/skills/code-tidy/references/test-suite-slop.md +16 -27
  27. package/src/defaults/skills/computer-use/SKILL.md +12 -2
  28. package/src/defaults/skills/goal-management/SKILL.md +1 -1
  29. package/src/defaults/skills/setup/references/actions.md +12 -6
  30. package/src/defaults/skills/setup/references/surfaces.md +2 -2
  31. package/src/defaults/skills/setup-guide/SKILL.md +5 -2
  32. package/src/defaults/skills/setup-guide/model-recommendations.json +13 -0
  33. package/src/defaults/skills/skill-creator/SKILL.md +85 -190
  34. package/src/defaults/skills/skill-creator/references/design.md +70 -162
  35. package/src/defaults/skills/skill-creator/references/evaluation.md +33 -92
  36. package/src/defaults/skills/test-suite/SKILL.md +194 -0
  37. package/src/defaults/skills/test-suite/references/case-management.md +51 -0
  38. package/src/defaults/skills/test-suite/references/flaky-policy.md +39 -0
  39. package/src/defaults/skills/test-suite/references/reliability.md +49 -0
  40. package/src/defaults/skills/test-suite/references/suite-design.md +78 -0
  41. package/src/defaults/skills/test-suite/scripts/inventory.mjs +335 -0
  42. package/src/defaults/skills/visualize/SKILL.md +6 -2
  43. package/src/lib/rules-builder.cjs +6 -30
  44. package/src/rules/lead/LEAD.md +3 -3
  45. package/src/rules/shared/20-research.md +3 -6
  46. package/src/rules/shared/40-editing.md +1 -0
  47. package/src/rules/shared/60-verification.md +10 -9
  48. package/src/rules/shared/70-delivery.md +4 -3
  49. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/abort-link.mjs +5 -1
  50. package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +10 -1
  51. package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +130 -21
  52. package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +13 -0
  53. package/src/runtime/agent/orchestrator/agent-runtime/maintenance-route.mjs +4 -1
  54. package/src/runtime/agent/orchestrator/config.mjs +12 -7
  55. package/src/runtime/agent/orchestrator/context/deferred-tools.mjs +7 -7
  56. package/src/runtime/agent/orchestrator/context/role-instructions.mjs +5 -26
  57. package/src/runtime/agent/orchestrator/internal-agents.mjs +3 -14
  58. package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +122 -12
  59. package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +5 -3
  60. package/src/runtime/agent/orchestrator/mcp/client-config.mjs +13 -2
  61. package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +152 -58
  62. package/src/runtime/agent/orchestrator/mcp/client.mjs +51 -18
  63. package/src/runtime/agent/orchestrator/mcp/oauth-login.mjs +83 -52
  64. package/src/runtime/agent/orchestrator/mcp/oauth.mjs +42 -26
  65. package/src/runtime/agent/orchestrator/providers/account-pool.mjs +43 -8
  66. package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +30 -28
  67. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  68. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-credentials.mjs +31 -21
  69. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-login.mjs +3 -1
  70. package/src/runtime/agent/orchestrator/providers/antigravity-oauth-tokens.mjs +2 -2
  71. package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
  72. package/src/runtime/agent/orchestrator/providers/command-code-oauth.mjs +1 -1
  73. package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +40 -0
  74. package/src/runtime/agent/orchestrator/providers/custom-provider-keys.mjs +34 -0
  75. package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +3 -0
  76. package/src/runtime/agent/orchestrator/providers/devin-auth.mjs +14 -7
  77. package/src/runtime/agent/orchestrator/providers/devin-wire-transport.mjs +3 -2
  78. package/src/runtime/agent/orchestrator/providers/gemini-response.mjs +2 -2
  79. package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +4 -1
  80. package/src/runtime/agent/orchestrator/providers/grok-oauth-login.mjs +48 -31
  81. package/src/runtime/agent/orchestrator/providers/lib/oauth-page.mjs +0 -18
  82. package/src/runtime/agent/orchestrator/providers/lib/oauth-token-utils.mjs +138 -6
  83. package/src/runtime/agent/orchestrator/providers/mimo-oauth.mjs +1 -1
  84. package/src/runtime/agent/orchestrator/providers/model-cache.mjs +100 -33
  85. package/src/runtime/agent/orchestrator/providers/muse-code-oauth.mjs +1 -1
  86. package/src/runtime/agent/orchestrator/providers/oauth-secret-fields.fixtures.mjs +45 -0
  87. package/src/runtime/agent/orchestrator/providers/openai-oauth-login.mjs +26 -28
  88. package/src/runtime/agent/orchestrator/providers/openai-ws-stream/event-switch.mjs +3 -1
  89. package/src/runtime/agent/orchestrator/providers/openai-ws-watchdogs.mjs +1 -0
  90. package/src/runtime/agent/orchestrator/providers/opencode-go-oauth.mjs +1 -1
  91. package/src/runtime/agent/orchestrator/providers/opencode-go.mjs +3 -1
  92. package/src/runtime/agent/orchestrator/providers/registry.mjs +33 -2
  93. package/src/runtime/agent/orchestrator/providers/vertex-ai-auth.mjs +622 -0
  94. package/src/runtime/agent/orchestrator/providers/vertex-ai-maas.mjs +185 -0
  95. package/src/runtime/agent/orchestrator/providers/vertex-ai-models.mjs +445 -0
  96. package/src/runtime/agent/orchestrator/providers/vertex-ai.mjs +567 -0
  97. package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +2 -0
  98. package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +2 -1
  99. package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +3 -0
  100. package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +3 -0
  101. package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +14 -5
  102. package/src/runtime/agent/orchestrator/runtime-core/workflow-ids.mjs +1 -0
  103. package/src/runtime/agent/orchestrator/session/agent-room.d.mts +30 -5
  104. package/src/runtime/agent/orchestrator/session/agent-room.mjs +171 -37
  105. package/src/runtime/agent/orchestrator/session/cache-warm.mjs +94 -10
  106. package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +3 -3
  107. package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +10 -5
  108. package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +5 -5
  109. package/src/runtime/agent/orchestrator/session/conversation-import/turns.mjs +11 -1
  110. package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +4 -3
  111. package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +36 -6
  112. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +5 -3
  113. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +21 -2
  114. package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +2 -0
  115. package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +23 -1
  116. package/src/runtime/agent/orchestrator/session/loop/turn-limits.mjs +13 -8
  117. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +50 -28
  118. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +1 -0
  119. package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +3 -4
  120. package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +2 -0
  121. package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +7 -0
  122. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +15 -0
  123. package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -14
  124. package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +17 -14
  125. package/src/runtime/agent/orchestrator/session/manager/session-scratch-environment.mjs +70 -0
  126. package/src/runtime/agent/orchestrator/session/manager/session-tool-surface.mjs +0 -3
  127. package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +7 -3
  128. package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +47 -29
  129. package/src/runtime/agent/orchestrator/session/manager/turn-reap.mjs +125 -0
  130. package/src/runtime/agent/orchestrator/session/mixy-name.mjs +11 -5
  131. package/src/runtime/agent/orchestrator/session/restart-prefix-parity.fixture.mjs +1 -1
  132. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +243 -38
  133. package/src/runtime/agent/orchestrator/session/store-transcript-cache.mjs +163 -64
  134. package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +164 -4
  135. package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +142 -18
  136. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/completed-result.mjs +6 -2
  137. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +36 -26
  138. package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +3 -5
  139. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +58 -20
  140. package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.mjs +20 -15
  141. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +96 -20
  142. package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +59 -10
  143. package/src/runtime/agent/orchestrator/tools/graph-manifest.json +13 -13
  144. package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.mjs +99 -2
  145. package/src/runtime/agent/orchestrator/tools/lib/owned-shell-trees.mjs +2 -0
  146. package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +103 -13
  147. package/src/runtime/agent/orchestrator/tools/lib/shell-run-background/promote-job.mjs +3 -1
  148. package/src/runtime/agent/orchestrator/tools/lib/shell-run-settle.mjs +49 -15
  149. package/src/runtime/agent/orchestrator/tools/lib/shell-run-spawn.mjs +45 -27
  150. package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +34 -10
  151. package/src/runtime/agent/orchestrator/tools/lib/shell-warm-standby.mjs +2 -0
  152. package/src/runtime/agent/orchestrator/tools/lib/wait-until-fixture.mjs +26 -0
  153. package/src/runtime/agent/orchestrator/tools/shell-command.mjs +7 -2
  154. package/src/runtime/agent/orchestrator/tools/spawn-manifest.json +13 -13
  155. package/src/runtime/channels/lib/whisper-port.mjs +19 -10
  156. package/src/runtime/channels/lib/whisper-server.mjs +10 -1
  157. package/src/runtime/connectors/connector-accounts-mcp.mjs +236 -103
  158. package/src/runtime/connectors/gmail-app-password.mjs +3 -3
  159. package/src/runtime/explore/explorer.mjs +93 -0
  160. package/src/runtime/explore/tool-defs.mjs +35 -0
  161. package/src/runtime/explore/tool.mjs +123 -0
  162. package/src/runtime/memory/index.mjs +4 -0
  163. package/src/runtime/memory/lib/embedding-provider.mjs +4 -1
  164. package/src/runtime/memory/lib/embedding-worker.mjs +4 -0
  165. package/src/runtime/office/quality/assurance-structure-docx.mjs +1 -1
  166. package/src/runtime/shared/agent-route-config.mjs +17 -2
  167. package/src/runtime/shared/atomic-file.mjs +103 -2
  168. package/src/runtime/shared/background-tasks.mjs +15 -6
  169. package/src/runtime/shared/connector-accounts.mjs +5 -5
  170. package/src/runtime/shared/connector-catalog.d.mts +11 -4
  171. package/src/runtime/shared/connector-catalog.mjs +60 -52
  172. package/src/runtime/shared/custom-provider-keys.mjs +20 -0
  173. package/src/runtime/shared/file-has-data.mjs +26 -2
  174. package/src/runtime/shared/file-lock.mjs +13 -15
  175. package/src/runtime/shared/git-launch.d.mts +9 -0
  176. package/src/runtime/shared/git-launch.mjs +213 -0
  177. package/src/runtime/shared/git-runner-worker.mjs +2 -1
  178. package/src/runtime/shared/llm/cost.mjs +6 -1
  179. package/src/runtime/shared/llm/http-agent.mjs +313 -29
  180. package/src/runtime/shared/llm/model-catalog-projection.mjs +3 -2
  181. package/src/runtime/shared/llm/model-catalog.mjs +46 -6
  182. package/src/runtime/shared/llm/provider-catalog-registry.mjs +3 -0
  183. package/src/runtime/shared/llm/system-proxy.mjs +452 -0
  184. package/src/runtime/shared/provider-accounts.mjs +52 -2
  185. package/src/runtime/shared/staged-install-worker.mjs +5 -0
  186. package/src/runtime/shared/staged-update.mjs +47 -2
  187. package/src/runtime/shared/tool-surface.mjs +110 -36
  188. package/src/runtime/shared/tool-work-units.mjs +4 -0
  189. package/src/runtime/shared/turn-worktree-snapshot.mjs +414 -54
  190. package/src/runtime/shared/worktrees/activity-gate.mjs +215 -318
  191. package/src/runtime/shared/worktrees/activity-ledger-worker.mjs +56 -0
  192. package/src/runtime/shared/worktrees/activity-ledger.mjs +391 -0
  193. package/src/runtime/shared/worktrees/branch-management.mjs +9 -3
  194. package/src/runtime/shared/worktrees/git.mjs +57 -0
  195. package/src/runtime/shared/worktrees/manager.mjs +205 -137
  196. package/src/runtime/tidy/install.mjs +95 -15
  197. package/src/runtime/tidy/languages.mjs +17 -15
  198. package/src/runtime/tidy/process.mjs +7 -4
  199. package/src/runtime/tidy/resolve.mjs +19 -16
  200. package/src/runtime/tidy/runners/biome.mjs +3 -3
  201. package/src/runtime/tidy/tool.mjs +1 -1
  202. package/src/runtime/tidy/worktree.mjs +10 -6
  203. package/src/runtime/visualize-bridge/client.mjs +4 -1
  204. package/src/runtime/visualize-bridge/tool-defs.mjs +7 -2
  205. package/src/runtime/web-search/index.mjs +1 -1
  206. package/src/session-runtime/agent-task-sessions.mjs +410 -353
  207. package/src/session-runtime/boot/tools.mjs +2 -0
  208. package/src/session-runtime/bot-status.mjs +103 -103
  209. package/src/session-runtime/connector-merge-migration.mjs +18 -15
  210. package/src/session-runtime/conversation-import/discovery.mjs +159 -40
  211. package/src/session-runtime/conversation-import/service.mjs +9 -3
  212. package/src/session-runtime/handoff-attachments.mjs +1 -1
  213. package/src/session-runtime/held-requests.mjs +3 -1
  214. package/src/session-runtime/internal-tool-executor/feature-tools.mjs +2 -0
  215. package/src/session-runtime/internal-tool-executor/knowledge-tools.mjs +8 -0
  216. package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +143 -116
  217. package/src/session-runtime/lifecycle/teardown/session-close.mjs +6 -1
  218. package/src/session-runtime/lifecycle/teardown.mjs +1 -1
  219. package/src/session-runtime/mcp-glue/server-catalog.mjs +16 -10
  220. package/src/session-runtime/mcp-glue/server-input.mjs +4 -1
  221. package/src/session-runtime/mixy-heartbeat.mjs +1 -1
  222. package/src/session-runtime/provider-auth/login.mjs +2 -2
  223. package/src/session-runtime/resource-mcp-api.mjs +98 -35
  224. package/src/session-runtime/resource-mcp-connector-accounts.mjs +44 -31
  225. package/src/session-runtime/resource-mcp-secrets.mjs +28 -11
  226. package/src/session-runtime/resource-mcp-servers.mjs +5 -4
  227. package/src/session-runtime/services/agent-tool/send-flow.mjs +10 -2
  228. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-prep.mjs +8 -3
  229. package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +4 -1
  230. package/src/session-runtime/services/agent-watchdog-registry.mjs +32 -4
  231. package/src/session-runtime/services/channel-worker/daemon-spawn.mjs +2 -0
  232. package/src/session-runtime/services/daemon-candidate.mjs +4 -1
  233. package/src/session-runtime/services/memory-runtime-proxy/daemon-spawn.mjs +4 -0
  234. package/src/session-runtime/services/plugin-admin.mjs +10 -6
  235. package/src/session-runtime/services/provider-admin.mjs +281 -10
  236. package/src/session-runtime/session-turn-api.mjs +2 -0
  237. package/src/session-runtime/settings-builtin-tools-api.mjs +4 -1
  238. package/src/session-runtime/settings-system-api.mjs +1 -1
  239. package/src/session-runtime/setup-tool/agent-settings-actions.mjs +13 -3
  240. package/src/session-runtime/setup-tool/connector-widen-approval.mjs +96 -0
  241. package/src/session-runtime/setup-tool/executor.mjs +6 -2
  242. package/src/session-runtime/setup-tool/tool-defs.mjs +2 -1
  243. package/src/session-runtime/turn/agent-ops.mjs +23 -0
  244. package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +49 -11
  245. package/src/session-runtime/workflow-agents-api/agent-route.mjs +10 -1
  246. package/src/session-runtime/workspace/activity-guards.mjs +176 -0
  247. package/src/session-runtime/workspace/session-view.mjs +149 -0
  248. package/src/session-runtime/workspace/side-checkouts.mjs +203 -0
  249. package/src/session-runtime/workspace/transition-runner.mjs +188 -0
  250. package/src/session-runtime/workspace/transitions.mjs +108 -1066
  251. package/src/session-runtime/workspace/workspace-merge.mjs +132 -0
  252. package/src/session-runtime/workspace/worktree-intents.mjs +242 -0
  253. package/src/session-runtime/workspace/worktree-maintenance.mjs +80 -0
  254. package/src/session-runtime/workspace/worktree-setup.mjs +85 -0
  255. package/src/session-runtime/workspace/worktree-tool.mjs +54 -54
  256. package/src/standalone/daemon-desktop-runtime.mjs +2 -0
  257. package/src/standalone/daemon-session-control.mjs +151 -136
  258. package/src/standalone/daemon.mjs +7 -0
  259. package/src/standalone/desktop-service-registry.mjs +9 -0
  260. package/src/standalone/local-session-runtime.mjs +5 -1
  261. package/src/standalone/session-client/daemon-unavailable.mjs +3 -0
  262. package/src/standalone/session-client.mjs +5 -1
  263. package/src/standalone/session-frame-stream.mjs +83 -11
  264. package/src/standalone/session-protocol.mjs +4 -0
  265. package/src/standalone/session-service/agent-tree.mjs +45 -9
  266. package/src/standalone/session-service/projection/transcript-window.mjs +700 -64
  267. package/src/standalone/session-service/session-calls/session-views.mjs +160 -104
  268. package/src/standalone/session-service/stored-reader.mjs +127 -40
  269. package/src/tui/App.jsx +154 -164
  270. package/src/tui/app/app-view/floating-panel.jsx +3 -0
  271. package/src/tui/app/app-view/text-entry-labels.mjs +1 -0
  272. package/src/tui/app/clipboard.mjs +21 -10
  273. package/src/tui/app/prompt-handlers/use-prompt-history-nav.mjs +1 -1
  274. package/src/tui/app/prompt-handlers/use-prompt-interrupt.mjs +3 -0
  275. package/src/tui/app/prompt-submit/provider-prompts.mjs +3 -1
  276. package/src/tui/app/provider-setup/api-key-actions.mjs +31 -1
  277. package/src/tui/app/provider-setup/oauth-actions.mjs +25 -6
  278. package/src/tui/app/provider-setup-picker.mjs +20 -13
  279. package/src/tui/app/shell-layout/row-budgets.mjs +12 -10
  280. package/src/tui/app/slash-commands.mjs +1 -0
  281. package/src/tui/app/slash-dispatch/session-commands.mjs +46 -0
  282. package/src/tui/app/slash-dispatch.mjs +1 -1
  283. package/src/tui/app/use-btw-panel.mjs +29 -0
  284. package/src/tui/app/use-context-panel-refresh.mjs +31 -0
  285. package/src/tui/app/use-model-catalog-cache.mjs +13 -10
  286. package/src/tui/app/use-mouse-input.mjs +11 -0
  287. package/src/tui/app/use-onboarding-start.mjs +8 -3
  288. package/src/tui/app/use-panel-transition.mjs +10 -1
  289. package/src/tui/app/use-pasted-buffers.mjs +28 -20
  290. package/src/tui/app/use-prompt-draft-flow.mjs +7 -0
  291. package/src/tui/app/use-prompt-layout-rows.mjs +3 -3
  292. package/src/tui/app/use-prompt-queue-history.mjs +3 -2
  293. package/src/tui/app/use-selection-focus.mjs +11 -2
  294. package/src/tui/app/use-selection-geometry.mjs +18 -9
  295. package/src/tui/app/use-selection-paint.mjs +4 -4
  296. package/src/tui/app/use-selection-stitch.mjs +3 -3
  297. package/src/tui/app/use-slash-palette.mjs +62 -0
  298. package/src/tui/app/use-terminal-chrome.mjs +2 -2
  299. package/src/tui/app/use-transcript-activity.mjs +47 -32
  300. package/src/tui/app/use-transcript-follow.mjs +12 -4
  301. package/src/tui/app/use-transcript-scroll.mjs +46 -17
  302. package/src/tui/app/use-transcript-swap-reset.mjs +27 -0
  303. package/src/tui/app/use-transcript-window/geometry.mjs +19 -5
  304. package/src/tui/app/use-transcript-window/instance-state.mjs +4 -0
  305. package/src/tui/app/use-transcript-window/selection-shift.mjs +5 -1
  306. package/src/tui/app/use-transcript-window.mjs +21 -11
  307. package/src/tui/app/use-tui-ready.mjs +18 -0
  308. package/src/tui/app/use-welcome-prompt-hint.mjs +5 -0
  309. package/src/tui/app/use-workflow-tab-cycle.mjs +5 -3
  310. package/src/tui/components/Picker.jsx +27 -3
  311. package/src/tui/components/SignInUrl.jsx +68 -0
  312. package/src/tui/components/TextEntryPanel.jsx +76 -46
  313. package/src/tui/components/sign-in-url-layout.mjs +24 -0
  314. package/src/tui/dist/index.mjs +1896 -1341
  315. package/src/tui/session/goal-turn-state.mjs +6 -2
  316. package/src/tui/session/session-api/controls.mjs +4 -0
  317. package/src/tui/session/session-api/extensions.mjs +8 -0
  318. package/src/tui/session/session-api/intake/abort.mjs +2 -1
  319. package/src/tui/session/session-api/intake.mjs +2 -0
  320. package/src/tui/session/session-api/integrations.mjs +2 -2
  321. package/src/tui/session/session-api/routes-agent-definitions.mjs +1 -0
  322. package/src/tui/session/session-api/settings.mjs +2 -2
  323. package/src/tui/session/transcript-spill/spill-writer.mjs +15 -0
  324. package/src/tui/session/transcript-spill.mjs +92 -4
  325. package/src/tui/session/transcript-store.mjs +2 -0
  326. package/src/defaults/skills/skill-creator/references/source-review.md +0 -94
@@ -15,45 +15,37 @@ dependencies:
15
15
  Layers, cheapest and safest first: project formatters and linters through
16
16
  `tidy`, structural rule packs, then agent-level cleanup. Every layer preserves
17
17
  behavior and public API; this is not a bug hunt. The `tidy` schema owns action
18
- fields; this file owns scope, order, and boundaries. Verification follows the
19
- shared rule: finish all planned edits, then check once (section 5).
18
+ fields; this file owns scope, order, and boundaries.
20
19
 
21
20
  ## 1. Job and mode
22
- - Tidy owns format, lint, structure, and cleanup, not feature work. New
23
- behavior and public-API refactors are out of scope. A correctness bug found
24
- while cleaning goes under "Bugs found", never into a cleanup edit.
25
- - Never invent a formatter config. A project with Biome, Prettier,
26
- clang-format, rustfmt, gofmt, or equivalent keeps it; add or rewrite
27
- `biome.json`, `.prettierrc`, `.clang-format` and the like only when asked.
21
+ - New behavior and public-API refactors are out of scope. A correctness defect
22
+ found while cleaning is reported, never fixed in a cleanup edit.
23
+ - Never invent a formatter config; a project's own formatter stays. Add or
24
+ rewrite one only when asked.
28
25
  - Mode is `apply` unless the user asks to check, review, or "just report";
29
26
  report-only stays read-only on every layer and lists what would change.
30
- - An explicit focus restricts every layer ("formatting only" excludes lint
31
- and semantic cleanup; "only dead code" excludes unrelated formatting). If
32
- the tool cannot isolate it, use targeted edits or report the limitation
33
- and ask before widening.
27
+ - An explicit focus restricts every layer. If the tool cannot isolate it, use
28
+ targeted edits or report the limitation and ask before widening.
34
29
 
35
30
  ## 2. Scope
36
31
  1. Scope comes from the user: named files, directories, a feature area
37
32
  resolved to confirmed paths, or an explicitly requested whole project. If
38
33
  absent or ambiguous, ask first. Never infer it from a diff, branch,
39
34
  commit, or recent activity.
40
- 2. Recommend (do not require, do not do it for them) that the user commit
41
- existing work before an apply run. A dirty tree means preserve those edits.
35
+ 2. Recommend (do not require) that the user commit existing work before an
36
+ apply run. A dirty tree means preserve those edits.
42
37
  3. Drop deleted, binary, generated, vendored files and lockfiles unless
43
38
  explicitly included. Consumers and covering tests may be read; editing
44
39
  them outside the scope needs approval. New non-ignored files are included.
45
40
  4. Pass the approved paths on every `scan`/`check`/`fix`; `paths:["."]` only
46
41
  for an explicitly requested whole project.
47
- 5. Too large to review in one pass (whole project, many directories):
48
- partition by directory or responsibility so every source unit gets the
49
- ladder and every survivor the lenses; hundreds of files per partition is
50
- the usual failure. Work through all partitions without pausing for input.
51
- Keep the partition list and candidate list across turns.
52
- 6. Read per-rule and per-directory counts first, then page only relevant
53
- rows with `tidy action:'results'` filters; never treat unreviewed in-scope
54
- results as clean. Real engine truncation, timeouts, or scope leakage mark
55
- that partition **unfinished**, not clean. Blocked checks stop dependent
56
- edits only.
42
+ 5. For large scopes, review bounded partitions once. Preserve their
43
+ completion state; report blocked partitions without restarting completed
44
+ work.
45
+ 6. Read per-rule and per-directory counts first, then page only relevant rows
46
+ with `tidy action:'results'` filters. Truncation, timeouts, or scope
47
+ leakage mark that partition **unfinished**, not clean. Blocked checks stop
48
+ dependent edits only.
57
49
 
58
50
  ## 3. Deterministic layers
59
51
  1. `tidy action:'scan'` first (languages, engines used/missing,
@@ -61,109 +53,86 @@ shared rule: finish all planned edits, then check once (section 5).
61
53
  2. Downloads are automatic under the default `auto` policy. Only when
62
54
  `tidy.downloads` is `ask` does a result carry `needsApproval`: ask once,
63
55
  listing engines and bytes, then re-call with `approveDownloads:true`.
64
- 3. Engines run only through `tidy` and are never installed by hand
65
- (rustfmt, gofmt, dart, swift, zig, mix, dotnet: report `installHint`). An
66
- ad-hoc `npx <engine>`, global binary, or package script is not
67
- verification and may report a false clean. An engine `tidy` cannot resolve
68
- leaves its check blocked, never clean.
69
- 4. Plan with `fix` without `apply:true`; no separate `check` first. The dry
70
- run is diagnostics and candidate files, not a frozen patch; apply
71
- recalculates. `structural:true` (default) also runs ordinary engines;
72
- `structural:false` disables structural rules only, not engine lint fixes.
73
- For a restricted focus, do not use a combined apply that touches unrelated
74
- code.
75
- 5. Apply with `apply:true` once the plan for the scope is settled, then review
76
- the actual changes. Skip apply when the dry run proposes nothing.
77
- Rules without a fix (`no-empty-catch`, `no-nested-ternary`, `no-any-cast`,
78
- `no-boolean-literal-compare`, `no-debug-statement`, `todo-marker`) are
79
- diagnostics for the agent layer. Keep the engine pass a distinct change
56
+ 3. Engines run only through `tidy` and are never installed by hand; report
57
+ `installHint`. An ad-hoc `npx <engine>`, global binary, or package script
58
+ is not verification. An engine `tidy` cannot resolve leaves its check
59
+ blocked, never clean.
60
+ 4. Plan with `fix` without `apply:true`. The dry run is diagnostics and
61
+ candidate files, not a frozen patch. `structural:false` disables
62
+ structural rules only. For a restricted focus, avoid a combined apply that
63
+ touches unrelated code.
64
+ 5. Apply with `apply:true` once the plan is settled, then review the actual
65
+ changes; skip it when the dry run proposes nothing. Rules without a fix
66
+ are diagnostics for the agent layer. Keep the engine pass a distinct change
80
67
  set from semantic edits. On engine or structural failure, truncation, or a
81
68
  rejected edit, stop affected writes; a partial result is not success.
82
69
 
83
70
  ## 4. Agent-level cleanup
84
71
  Read `references/agent-cleanup.md` (ladder, lenses, slop, risk tiers); also
85
72
  `references/test-suite-slop.md` when tests are in scope, and
86
- `references/cleanup-report.md` for recording and the closing report.
73
+ `references/cleanup-report.md` for the report.
87
74
 
88
- 1. **Pin behavior (read-only).** Search the tests for source-text guards
89
- (shapes in `agent-cleanup.md`) before extracting or moving anything. A file
90
- whose touched behavior no test covers gets the narrowest regression test
91
- that pins it, or only SAFE changes. Prose files have no behavior to pin.
92
- 2. **Ladder, then lenses.** Run the deletion ladder on every selected source
93
- unit, then the four lenses on the survivors. Engine diagnostics point at
94
- units; they do not define coverage. A partition reviewed only where an
95
- engine flagged is unfinished. Each finding has a path+symbol location,
96
- cost, action, confidence, and risk tier; drop findings without evidence.
97
- Use history only when code, contracts, and tests leave intent unclear;
98
- unresolved intent blocks deletion.
75
+ 1. **Pin behavior (read-only).** Find the source-text guards a planned move
76
+ can affect (procedure in `agent-cleanup.md`). A unit whose touched behavior
77
+ no test covers gets only SAFE changes; report it instead of adding tests.
78
+ 2. **Ladder, then lenses.** Run the deletion ladder on each selected source
79
+ unit, then the lenses on the survivors. Engine diagnostics point at units;
80
+ they do not define coverage. Findings need path+symbol evidence; drop the
81
+ rest. Use history only when code, contracts, and tests leave intent
82
+ unclear; unresolved intent blocks deletion.
99
83
  3. **Apply by tier.** SAFE as one batch; CAREFUL one source unit at a time,
100
- each finished and wired into its callers (never leave a new module nothing
101
- imports); RISKY is reported, never auto-applied. Order within a tier:
102
- comments, dead code, defensive code, duplication, complexity, abstraction,
103
- performance. Dead code follows `references/dead-code.md`.
104
- 4. **Stop rules.** Three failed attempts on one file: stop and escalate with
105
- what was tried. A deeper fix larger than the cleanup: report it as its own
106
- task. Principles cannot pick between two rewrites: apply neither, record
107
- both.
84
+ each wired into its callers (never leave a new module nothing imports);
85
+ RISKY is reported with its evidence and applied only after the user
86
+ approves that item. Dead code follows
87
+ `references/dead-code.md`.
88
+ 4. **Stop rules.** Follow the shared verification budget. Report correctness
89
+ defects and changes beyond cleanup scope; do not fix them here. When
90
+ principles cannot pick between two rewrites, apply neither and record both.
108
91
 
109
- Structural signals are leads, not candidates: file > 1,000 lines, function
110
- > 50 lines or nesting > 3 (under ~100 lines, act only on a named symptom:
111
- duplication, a defect, demonstrated difficulty of change), duplicated small
112
- helpers (consolidate only when intent matches), history comments (remove only
113
- if no protected content is lost), underscore-prefixed names exported across
114
- modules (rename is RISKY). Do not improve names, control flow, or types
115
- beyond the ladder, lenses, and these signals. A confirmed
92
+ Structural signals (file > 1,000 lines, function > 50 lines or nesting > 3,
93
+ duplicated small helpers, history comments, exported underscore names) are
94
+ leads, not candidates: act only on a named symptom. Do not improve names,
95
+ control flow, or types beyond the ladder and lenses. A confirmed
116
96
  responsibility-based split that preserves behavior and entry points is
117
- CAREFUL; an extracted unit takes only the values it reads. Moving a whole
118
- body elsewhere or cutting it into numbered chunks resolves nothing.
97
+ CAREFUL; moving a whole body elsewhere or cutting it into numbered chunks
98
+ resolves nothing.
119
99
 
120
- ## 5. Check once, then fix
121
- After every planned edit in the assigned scope is done, run the project's
122
- documented tests/typecheck covering the touched behavior and `tidy check` on
123
- the scope, once, in parallel. No check, build, lint, test, or formatter run
124
- before that. If it fails, read the full logs, finish the fixes, and rerun only
125
- the failed or invalidated checks. A failure on code you did not touch is
126
- pre-existing: report it separately. A broken runner leaves its scope
127
- unverified: say so. Skipped or failed checks never count as passed.
100
+ ## 5. Verify
101
+ Use the shared evidence budget. Run scoped `tidy check`; select behavioral
102
+ checks and typechecking only where the edits can invalidate their contracts.
103
+ Reuse valid passes. Attribute failures from evidence, not from whether the
104
+ failing file was edited. A broken runner leaves its scope unverified; say so.
105
+ Skipped or failed checks never count as passed.
128
106
 
129
107
  If checks fail and cannot be fixed, undo only this run's edits with targeted
130
108
  patches, preserving prior or concurrent work. Never use `git checkout`,
131
109
  `reset`, `restore`, or `stash` as rollback; if the edits cannot be separated
132
110
  safely, leave them and report the blocker.
133
111
 
134
- New findings from the final `tidy check` (e.g. imports orphaned by removals)
135
- are fixed once if SAFE; others are reported.
136
-
137
112
  ## 6. Keep: never remove or rename
138
- - Validation and error handling at a trust boundary (user input, external
139
- API, file, network) unless an adversarial test proves the guard redundant.
140
- - Export names, API routes, CLI flags, DB columns, config keys, event names,
141
- wire strings: contracts. A rename is RISKY even when the name is bad.
113
+ - Validation and error handling at a trust boundary unless an adversarial test
114
+ proves the guard redundant.
115
+ - Contracts: export names, routes, CLI flags, DB columns, config keys, event
116
+ names, wire strings. A rename is RISKY even when the name is bad.
142
117
  - Anything on the never-dead list in `references/dead-code.md`.
143
118
  - An empty catch or ignored error that may be intentional: flag it.
144
119
  - Complexity serving a current compatibility obligation, staged migration, or
145
- vendored-code isolation (see legacy retirement in `dead-code.md`).
146
- - License, copyright, SPDX notices; compiler, linter, bundler directives;
147
- public API docs; security and compatibility explanations. Block comments
148
- that may separate tokens or carry significant line breaks are left for
149
- manual review.
120
+ vendored-code isolation.
121
+ - Tool directives, public API docs, and security or compatibility
122
+ explanations. Comments that may separate tokens or carry significant line
123
+ breaks are left for manual review.
150
124
  - The project's own idioms (`AGENTS.md`/`CLAUDE.md`/lint config) over generic
151
- ones; clarity over fewer lines; nested ternaries are flattened, never added.
125
+ ones; clarity over fewer lines.
152
126
 
153
127
  ## 7. Pitfalls
154
128
  - Missing engine: `installHint` only; continue others; that check is blocked.
155
129
  - User declines downloads: skip those engines and say so.
156
- - Structural engine unavailable (missing or outdated mixdog-graph): `check`/
157
- `fix` fail with a rebuild remedy; `scan` still works. Retry with
158
- `structural:false` for formatters/linters only; missing structural matches
159
- are never clean. A per-language rule-pack error leaves only that language
160
- unfinished.
161
- - A dead-code scanner report is a candidate list, not proof; verify per
162
- `references/dead-code.md`.
130
+ - Structural engine unavailable: `check`/`fix` fail with a rebuild remedy;
131
+ `scan` still works. Retry with `structural:false`; missing structural
132
+ matches are never clean.
133
+ - A dead-code scanner report is a candidate list, not proof.
163
134
 
164
135
  ## 8. Reporting
165
- Report once, after the last partition, using `references/cleanup-report.md`.
166
- Put everything needing the user's decision in one list at the end: RISKY
167
- findings, bugs found, unresolved intent, unfinished candidates. Do not pause
168
- between partitions except for a blocker or a required approval. No separate
169
- report file unless requested.
136
+ Report once, after the last partition, using `references/cleanup-report.md`,
137
+ with everything needing the user's decision in one list. Pause only for a
138
+ blocker or a required approval. No report file unless requested.
@@ -1,135 +1,87 @@
1
1
  # Agent-level cleanup
2
2
 
3
- Read this before the agent-level layer of `code-tidy`. It owns the deletion
4
- ladder, the lens checklists, what counts as slop, and the risk tiers. The skill
5
- body owns scope, order, approvals, and the list of things that are never
6
- removed or renamed.
3
+ Owns the deletion ladder, lenses, slop categories, and risk tiers. The skill
4
+ body owns scope, order, approvals, and the never-remove list.
7
5
 
8
6
  ## Behavior boundary
9
7
 
10
- Classify risk by evidence, not by syntax. Equivalence includes observable
11
- outputs and errors, side effects and module initialization, and any call
12
- identity, receiver, or asynchronous ordering that consumers rely on. Removing
13
- an unused binding can remove initialization; inlining a wrapper can change
14
- its call contract. Neither is SAFE merely because it looks redundant.
15
-
16
- Use current callers, contracts, and relevant tests to establish equivalence.
17
- Passing tests that do not exercise the affected behavior are not proof.
18
- An intended change to failures, returned values, compatibility, or concurrency
19
- is RISKY: report it as a separate correction or migration, not a cleanup edit.
20
-
21
- **Source-text guards.** Some tests assert on source text rather than behavior,
22
- so an extraction breaks them without touching behavior: a packaging test that
23
- reads three files as one concatenated string and enforces five `indexOf`
24
- orderings; a repo-wide audit asserting an identifier appears in no file outside
25
- two named modules; a coverage test requiring literal action names to stay in
26
- one file. Search the suite for them first (reads of source paths, ordering
27
- `indexOf` chains, identifier-absence assertions) and record what each pins;
28
- moving code across such a guard is a contract change, not a tidying.
29
-
30
- **Dependency arrays.** A hook or watcher dependency array that contradicts its
31
- own body — the body reads values the array does not key — is a defect
32
- candidate, not an idiom to preserve and report. Verify reachability at the
33
- producer: when the key can actually repeat (two publishers stamping
34
- `Date.now()` in the same millisecond drop the second update), fix it by adding
35
- the values the body reads while keeping the existing key, with a test that
36
- fails without the fix, delivered as its own change set under "Bugs found".
37
- When the producer makes repetition unreachable, leave the array and record that
38
- evidence as `kept`.
8
+ Classify risk by evidence, not syntax. Equivalence includes observable outputs
9
+ and errors, side effects and module initialization, and any call identity,
10
+ receiver, or ordering consumers rely on. Removing an unused binding can remove
11
+ initialization; inlining a wrapper can change its call contract.
12
+
13
+ Establish equivalence from current callers, contracts, and tests that exercise
14
+ the affected behavior. An intended change to failures, returned values,
15
+ compatibility, or concurrency is RISKY: report it as a separate correction.
16
+
17
+ **Source-text guards.** Some tests assert on source text rather than behavior
18
+ (file reads of source paths, `indexOf` ordering chains, identifier-absence or
19
+ literal-presence assertions), so a move breaks them without changing behavior.
20
+ Search only for guards a proposed move can affect, and record what each pins.
21
+ Moving code across such a guard is a contract change, not a tidying.
22
+
23
+ **Dependency arrays.** A suspected correctness defect is outside cleanup;
24
+ report its evidence without changing behavior.
39
25
 
40
26
  ## Deletion ladder
41
27
 
42
- Run the ladder on every selected unit (function, class, module, config knob)
43
- in scope before looking for smells. Only code that lands on the
44
- last rung goes on to the lenses.
28
+ Run on each selected unit before looking for smells; only code that lands on
29
+ the last rung goes on to the lenses.
45
30
 
46
- | Rung | Question | Typical win |
31
+ | Rung | Question | Result |
47
32
  |---|---|---|
48
- | Delete | Is there evidence the behavior is no longer needed? Check callers, requirements, flags, and compatibility obligations | remove the verified obsolete unit; retire tests only under the test-suite slop rules |
49
- | Reuse | Does a helper in this repo already do it? (`code_graph symbol_search`, `grep` for the pattern's distinctive call) | reimplementation replaced by a call |
50
- | Platform | Does the stdlib, runtime, or an already-installed dependency do it? (`URLSearchParams`, `path.relative`, `Array.prototype.at`, `pathlib`, an imported util) | hand-rolled parser/formatter/debounce replaced |
51
- | Simplify | It must exist here; make it smaller | proceeds to the lenses |
52
-
53
- A unit replaced by one platform call is a larger and safer win than any
54
- in-place cleanup; take it before analysing the unit's smells.
33
+ | Delete | Is there evidence the behavior is no longer needed (callers, requirements, flags, compatibility)? | remove the verified obsolete unit |
34
+ | Reuse | Does a repo helper already do it? | replaced by a call |
35
+ | Platform | Does the runtime, stdlib, or an installed dependency do it? | hand-rolled code replaced |
36
+ | Simplify | It must exist; make it smaller | proceeds to the lenses |
55
37
 
56
38
  ## Lenses
57
39
 
58
- Each lens judges the units in scope and may search the whole
59
- repository for evidence (an existing helper, a sibling call site); a finding
60
- without a path-plus-symbol pointer is dropped. Run every lens unless the user named a focus.
61
- Judge each selected function or class in its full context, including relevant
62
- callers and tests, even when it has no pending diff. Do not restrict review to
63
- recently edited lines or silently widen the edit scope to its consumers.
64
-
65
- **Reuse** — new code that duplicates an existing utility, constant, type
66
- guard, or pattern: hand-rolled string/path manipulation, custom env checks,
67
- ad-hoc validation, re-implemented parsing. Name the existing thing and where it
68
- lives. Before flagging a new dependency import, check `package.json` /
69
- `pyproject.toml` for a library already installed that covers it.
70
-
71
- **Quality** — redundant state (values derivable from existing state, caches
72
- that need not exist); parameter sprawl (a parameter bolted on where the
73
- function should be restructured, a boolean parameter that selects between two
74
- behaviors — split the function instead); copy-paste-with-variation; leaky
75
- abstractions; stringly-typed code where a constant, enum, or registry exists;
76
- slop patterns from the table below.
77
-
78
- **Efficiency** — redundant computation, repeated file reads, duplicate API
79
- calls, N+1 access; independent operations run sequentially; heavy work on
80
- startup or per-request paths; existence pre-checks instead of doing the
81
- operation and handling the error; unbounded growth, missing cleanup,
82
- listener/handle leaks; closures capturing a whole scope for long-lived
83
- objects; whole-file reads where a slice would do. Only apply an efficiency
84
- change whose behavioral equivalence is obvious; never restructure an
85
- algorithm with subtle correctness implications without a test that pins it.
86
-
87
- **Altitude** — a fix applied too shallowly: a caller-specific branch added to
88
- a generic path (`if (caller === X)`, a magic-value escape hatch); a symptom
89
- patched at one call site while siblings keep the same flaw; a workaround
90
- stacked on a workaround; a wrapper added to avoid touching the thing that
91
- needs changing; a flag introduced to route around a broken default. Name
92
- the mechanism the change is dodging and the deeper fix. When the deeper fix
93
- is larger than the cleanup, report it as its own task instead of doing it
94
- here.
40
+ Use the lenses to identify supported improvements within scope; stop
41
+ investigating a candidate when its disposition is established. Each lens may
42
+ search the whole repository for evidence; a finding without a path+symbol
43
+ pointer is dropped. Judge units in full context, not only recently edited
44
+ lines, and never widen the edit scope to consumers. Skip lenses the user's
45
+ focus excludes.
46
+
47
+ - **Reuse** — new code duplicating an existing utility, constant, guard, or
48
+ installed library. Name the existing thing.
49
+ - **Quality** — redundant or derivable state, parameter sprawl (a boolean
50
+ selecting between behaviors), copy-paste-with-variation, leaky abstractions,
51
+ stringly-typed code where a constant or registry exists, slop below.
52
+ - **Efficiency** — redundant work, repeated reads, N+1 access, needless
53
+ sequencing, leaks, existence pre-checks instead of handling the error. Apply
54
+ only when equivalence is obvious; otherwise report it.
55
+ - **Altitude** — a fix applied too shallowly: a caller-specific branch in a
56
+ generic path, a symptom patched at one site, a workaround on a workaround.
57
+ Name the deeper fix; when it exceeds the cleanup, report it as its own task.
95
58
 
96
59
  ## Slop categories
97
60
 
98
61
  | Category | Flag | Keep | Fix |
99
62
  |---|---|---|---|
100
- | Obvious comments | restating the code, section dividers, commented-out code, vague TODOs, narration of the change or of the caller | WHY comments (business rule, workaround, invariant), ticket links, regex/algorithm notes, BDD markers, license/attribution notices, tool directives, public API docs | delete only with high confidence; preserve token boundaries and significant line breaks |
101
- | Over-defensive code | null checks on guaranteed values, try/catch around code that cannot throw, type checks on statically typed params, defaults for required params, validation duplicated inside a boundary, broad catch-all | I/O error handling, nullable DB fields, a top-level catch-all that logs and rethrows | remove only when a test proves the guard redundant; changing which errors are caught or propagated is RISKY |
102
- | Fake resilience | a fallback that turns a missing input or a failed call into a plausible value (`?? 0`, an empty-object default, a stub record); a catch that only rethrows the same error; a catch that logs without the error and continues | a default the caller's contract names, a retry or degraded mode the docs describe | remove only proven redundant behavior; replacing a default with a failure or changing the error contract is a separate RISKY correction |
103
- | Excessive complexity | nesting > 3, nested ternaries, 4+ predicates in one condition, > 5 positional params, functions > 50 lines doing several things, clever one-liners, a 4+ branch ladder comparing one value against constants, a hand-rolled loop the language has an idiom for (`for i in range(len(xs))`, an index loop over a collection, `count() > 0` for "any") | a hot path that intentionally uses a dense idiom | guard clauses, early returns, explicit if/else, an options object, a lookup table, the language's own idiom, extract by responsibility |
104
- | Needless abstraction | pass-through wrappers, single-use helpers, speculative indirection, one-implementer interfaces that add no seam, factories that only call a constructor | abstractions that give a real seam (tests, multiple implementers, framework boundary) | inline only after verifying the behavior boundary above |
105
- | Boundary violations | wrong-layer imports, import cycles between modules, business logic in a handler, one module reading another's private state, side effects in a pure-named function | short-circuits already established as a pattern here | move to the owning layer; break a cycle by moving the shared piece out; flag when unsure |
106
- | Dead code | unused imports/locals/private functions, unreachable branches, stale feature flags, debug leftovers, code removed but still referenced | whatever the dead-code procedure lists as never dead | remove through the dead-code procedure linked from the skill |
107
- | Duplication | copy-pasted branches with trivial differences, two helpers doing the same thing, repeated literal sequences, one exported type or interface redeclared in several files | incidental similarity between things that serve different intents and may diverge | consolidate only when intents match |
108
- | Type escapes | `as any`, `@ts-ignore`, `# type: ignore` without reason, a lint or compiler warning suppressed without one (`eslint-disable`, `# noqa`, `#pragma warning disable`), `object`/`Any` annotations where a union or Protocol fits, a value re-coerced to the type it already has (`String(s)` on a `string`) | an escape or suppression whose comment names the upstream bug it works around | narrow with a guard, a precise type, or `unknown` plus a check; drop a coercion the type already guarantees; fix the warning or record why it is silenced |
109
- | Hardcoded config | environment-specific URLs and endpoints, provider/account/project ids, absolute paths and path strings spliced with `/`, a literal branch for one caller or one environment, unnamed numeric thresholds | test fixtures, documentation examples, a literal the contract itself fixes (wire strings, protocol constants) | read it through the project's existing config or env accessor; name the literal. A credential in source is a bug — report it, never merely relocate it |
110
- | Placeholder naming | numbered or filler names on new code (`data2`, `helper1`, `tmp`, `handleStuff`, a `Manager` holding two functions) | names the project's own idioms establish | rename locals after their intent; an exported rename is a contract change, so RISKY |
111
- | Oversized modules | files past the skill's 1,000-line review threshold or mixing responsibilities | a cohesive module or script with no useful responsibility boundary | split confirmed independent responsibilities; never `utils`/`helpers`/`common`/`part2` dump files |
63
+ | Comments | restating the code, step narration, history or changelog notes, dividers, commented-out code, a comment the code contradicts, a TODO with no owner or issue | a non-obvious why (external constraint, invariant, tradeoff), directives, public API docs, issue links | delete or correct; a "do not change" comment gets a proposed test or type that enforces it, applied only with approval |
64
+ | Over-defensive code | checks on guaranteed values, try/catch around code that cannot throw, duplicated validation | I/O handling, trust boundaries, a logging top-level catch | remove only when a test proves the guard redundant; changing which errors propagate is RISKY |
65
+ | Fake resilience | a fallback turning missing input or failure into a plausible value; a catch that only rethrows or swallows | a default the contract names, documented retry or degraded mode | remove only proven redundant behavior; changing the error contract is RISKY |
66
+ | Excessive complexity | deep nesting, nested ternaries, long conditions, many params, clever one-liners, hand-rolled loops with an idiom | a deliberately dense hot path | guard clauses, early returns, lookup table, options object, extract by responsibility |
67
+ | Needless abstraction | pass-through wrappers, single-use helpers, speculative indirection | a real seam (tests, multiple implementers, framework boundary) | inline after the behavior boundary check |
68
+ | Boundary violations | wrong-layer imports, cycles, logic in handlers, reading another module's private state | an established pattern | move to the owning layer; flag when unsure |
69
+ | Dead code | unused imports/locals/private functions, unreachable branches, debug leftovers | the never-dead list | follow `dead-code.md` |
70
+ | Duplication | copy-pasted branches, two helpers doing one thing, redeclared types | similarity serving different intents | consolidate only when intents match |
71
+ | Type escapes | `any`, unexplained ignores and suppressions, redundant coercions | an escape whose comment names the upstream bug | narrow with a guard or precise type; fix the warning or record why silenced |
72
+ | Hardcoded config | environment-specific URLs, ids, absolute paths, unnamed thresholds | fixtures, docs, contract-fixed literals | use the project's config accessor; name the literal. A credential in source is a defect: report it |
73
+ | Placeholder naming | `data2`, `tmp`, `handleStuff` on new code | the project's own idioms | rename locals; an exported rename is RISKY |
74
+ | Oversized modules | files past the review threshold mixing responsibilities | a cohesive module | split confirmed independent responsibilities; no `utils`/`common` dumps |
112
75
 
113
76
  ## Risk tiers
114
77
 
115
- Every finding carries one tier:
116
-
117
- | Tier | Meaning | Examples | Handling |
118
- |---|---|---|---|
119
- | SAFE | equivalence established, including initialization and parsing | verified unused binding with no initialization effects, nonsemantic comment, redundant type assertion | apply as one batch |
120
- | CAREFUL | same semantics, structure changes | rename a local, flatten a ternary, guard clause, verified wrapper inlining, extract a helper, split responsibilities while preserving entry points, consolidate duplicates, name a magic number | apply one source unit at a time (including required new modules); verified by the single final check; undo only this run's edits if it cannot be fixed |
121
- | RISKY | may change behavior or a contract | public API or export rename, route/DB column/config key rename, error-handling change, concurrency change, N+1 restructuring, altitude fix in shared infrastructure | report only, with the test coverage status; never auto-apply |
122
-
123
- Conflict resolution when lenses disagree: correctness > the user's stated
124
- focus > readability and reuse > micro-performance. When two defensible
125
- rewrites of the same region remain, apply the one that touches less code and
126
- record the alternative; when the principles cannot separate them, apply
127
- neither and record both.
128
-
129
- ## Small tidyings (CAREFUL tier)
130
-
131
- Structure-only moves the slop table does not already cover: normalize two
132
- variants of the same pattern to one form; put coupled functions next to each
133
- other; declare a variable where it is initialized; blank line between chunks
134
- that do different things; merge over-fragmented pieces back into one readable
135
- block before re-splitting. One tidying per change set.
78
+ | Tier | Meaning | Handling |
79
+ |---|---|---|
80
+ | SAFE | equivalence established, including initialization | apply as one batch |
81
+ | CAREFUL | same semantics, structure changes (local rename, guard clause, verified inlining, helper extraction, responsibility split, consolidation) | one source unit at a time, including required new modules |
82
+ | RISKY | may change behavior or a contract (public rename, error-handling or concurrency change, shared-infrastructure fix) | report with test coverage status; apply only the items the user approves |
83
+
84
+ When lenses disagree: correctness > the user's focus > readability and reuse >
85
+ micro-performance. Between two defensible rewrites, apply the one touching
86
+ less code and record the alternative; if principles cannot separate them,
87
+ apply neither.
@@ -1,43 +1,27 @@
1
- # Candidate list and report
1
+ # Report
2
2
 
3
- Findings and risk tiers come from `agent-cleanup.md`; this file owns how they
4
- are recorded and reported. Keep the list in the conversation, not a file.
3
+ Findings and tiers come from `agent-cleanup.md`. Keep the list in the
4
+ conversation, not a file. Record only findings with a path+symbol, a cost, and
5
+ an action; threshold hits are signals, not findings.
5
6
 
6
- ## Candidates
7
-
8
- One line per candidate, with a stable ID (`C-01`):
9
-
10
- ```text
11
- [ID] path · symbol → problem → cost → action | tier: SAFE/CAREFUL/RISKY | confidence: high/medium/low | status: completed/kept/unfinished
12
- ```
13
-
14
- - Register only a lens finding with a path+symbol location, a cost, and an
15
- action. A finding that cannot name its cost is a nit: drop it. Threshold
16
- hits (long files or functions, deep nesting) are signals, not candidates.
17
- - Findings sharing a root cause group under one ID, each member keeping its
18
- path and symbol. Code moved by an extraction keeps its origin ID.
19
- - Confidence is `low` when callers, contracts, and tests do not explain why
20
- the code exists; medium/low candidates stay unfinished until that question
21
- is resolved. Approval to apply does not authorize guessing.
22
- - `completed` carries evidence of what changed; `kept` carries a concrete
23
- reason (keep rule or external contract); `unfinished` carries the blocker
24
- (pending, blocked, deferred, unverified).
25
-
26
- Overall cleanup is complete only when every partition is done, the final
27
- check has passed, and every candidate is completed or kept with evidence.
28
- Otherwise report "overall partial" with the remaining paths and IDs.
7
+ Each entry carries: path · symbol, action or blocker, risk tier, evidence
8
+ (what changed, why kept, or what blocks it). Findings sharing a root cause
9
+ group together. Unresolved intent stays unfinished; approval to apply does not
10
+ authorize guessing.
29
11
 
30
12
  ## Final report
31
13
 
14
+ Include only sections that have content:
15
+
32
16
  ```text
33
17
  Scope: <paths | whole project> · Mode: report|apply · Overall: complete|partial
34
- Deterministic: engines used/missing · files changed · diagnostics remaining · structural applied/skipped
35
- Completed: [ID] path · symbol — [Lens/TIER] what changed
36
- Kept: [ID] path · symbol — reason
37
- Unfinished: [ID] path · symbol — remaining work · status · next
38
- Noticed, not applied (RISKY or out of scope): [ID] path · symbol — why · test coverage
39
- Bugs found (not fixed here): <issues>
40
- Verification: tests <result> · typecheck <result> · tidy check <remaining diagnostics> · pre-existing failures <list|none>
41
- Blocked or unverified: <check> — <reason> → <paths> (write "none" if none)
42
- Needs your decision: <RISKY findings, bugs, unresolved intent, unfinished candidates>
18
+ Deterministic: engines used/missing · files changed · diagnostics remaining
19
+ Completed / Kept / Unfinished: entries as above
20
+ Noticed, not applied (RISKY or out of scope): entries · test coverage
21
+ Defects found (not fixed here): <issues>
22
+ Verification: checks run and results · failures and established attribution · blocked or unverified checks with reason
23
+ Needs your decision: <RISKY findings, defects, unresolved intent, unfinished items>
43
24
  ```
25
+
26
+ Complete means every partition was reviewed and the required checks passed or
27
+ are reported blocked; otherwise report partial with the remaining paths.
@@ -45,8 +45,6 @@ found" and never settle it by installing the package.
45
45
  effectful initializers, and the last unused import binding can still load a
46
46
  module for registration or initialization. Preserve required initialization
47
47
  rather than deleting it with the binding.
48
- 5. Record the symbol, kind, classified usage and contract evidence, side-effect
49
- result, and proposed action in the candidate list.
50
48
 
51
49
  ## Never dead
52
50
 
@@ -79,7 +77,7 @@ evidence. Apply this procedure before classifying an old path as dead:
79
77
  4. For a verified obsolete path, inventory its callers, flags/config, tests,
80
78
  docs, files, and dependencies. Remove only approved members in the order
81
79
  below; request scope expansion before editing related files outside it.
82
- 5. Record the retirement evidence and any remaining items. A still-required path is kept with its contract; an unknown obligation
80
+ 5. A still-required path is kept with its contract; an unknown obligation
83
81
  leaves the candidate blocked, not assumed obsolete.
84
82
 
85
83
  ## Remove in order
@@ -94,9 +92,5 @@ evidence. Apply this procedure before classifying an old path as dead:
94
92
  project's own package manager.
95
93
 
96
94
  Group edits by file so one batch never touches a file another batch edits.
97
- Verification and rollback follow the skill body (section 5).
98
-
99
- ## Report
100
-
101
- Use the shared candidate list and closing report, with usage and side-effect
102
- evidence per ID.
95
+ Verification and rollback follow the skill body (section 5). Record usage and
96
+ side-effect evidence in the common report format (`cleanup-report.md`).