dexterm-cli 0.1.5 → 0.1.7

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 (379) hide show
  1. package/dist/packages/agents/src/index.js +2 -0
  2. package/dist/packages/agents/src/schema.js +22 -1
  3. package/dist/packages/agents/src/spectator.js +54 -0
  4. package/dist/packages/agents/src/story.js +532 -0
  5. package/dist/packages/agents/src/tiers.js +28 -2
  6. package/dist/packages/agents/src/tools.js +31 -2
  7. package/dist/packages/autotrade/assets/exit-profile.schema.json +492 -0
  8. package/dist/packages/autotrade/assets/profiles/moonbag.json +46 -0
  9. package/dist/packages/autotrade/assets/profiles/runner.json +88 -0
  10. package/dist/packages/autotrade/assets/profiles/scalp.json +88 -0
  11. package/dist/packages/autotrade/assets/profiles/swing.json +88 -0
  12. package/dist/packages/autotrade/assets/strategies/moonbag.json +101 -0
  13. package/dist/packages/autotrade/assets/strategies/runner.json +101 -0
  14. package/dist/packages/autotrade/assets/strategies/sample-dip-ladder.json +188 -0
  15. package/dist/packages/autotrade/assets/strategies/scalp.json +98 -0
  16. package/dist/packages/autotrade/assets/strategies/swing.json +97 -0
  17. package/dist/packages/autotrade/assets/strategies/yolo.json +157 -0
  18. package/dist/packages/autotrade/assets/tapes/yolo-rehearsal.json +1 -0
  19. package/dist/packages/autotrade/src/account.js +74 -0
  20. package/dist/packages/autotrade/src/backtest.js +357 -0
  21. package/dist/packages/autotrade/src/basis-text.js +32 -0
  22. package/dist/packages/autotrade/src/chat/approvals.js +484 -0
  23. package/dist/packages/autotrade/src/chat/audit.js +140 -0
  24. package/dist/packages/autotrade/src/chat/config.js +93 -0
  25. package/dist/packages/autotrade/src/chat/connector.js +24 -0
  26. package/dist/packages/autotrade/src/chat/control.js +103 -0
  27. package/dist/packages/autotrade/src/chat/fake.js +100 -0
  28. package/dist/packages/autotrade/src/chat/format.js +71 -0
  29. package/dist/packages/autotrade/src/chat/hub.js +187 -0
  30. package/dist/packages/autotrade/src/chat/index.js +18 -0
  31. package/dist/packages/autotrade/src/chat/notify.js +292 -0
  32. package/dist/packages/autotrade/src/chat/pairing.js +46 -0
  33. package/dist/packages/autotrade/src/chat/redact.js +48 -0
  34. package/dist/packages/autotrade/src/chat/secrets.js +99 -0
  35. package/dist/packages/autotrade/src/chat/service.js +248 -0
  36. package/dist/packages/autotrade/src/chat/telegram.js +290 -0
  37. package/dist/packages/autotrade/src/desk-executor.js +188 -0
  38. package/dist/packages/autotrade/src/engine.js +387 -0
  39. package/dist/packages/autotrade/src/execution-port.js +97 -0
  40. package/dist/packages/autotrade/src/fleet-config.js +169 -0
  41. package/dist/packages/autotrade/src/fleet-control.js +276 -0
  42. package/dist/packages/autotrade/src/fleet.js +639 -0
  43. package/dist/packages/autotrade/src/index.js +53 -0
  44. package/dist/packages/autotrade/src/ledger.js +108 -0
  45. package/dist/packages/autotrade/src/live-source.js +182 -0
  46. package/dist/packages/autotrade/src/monitor-daemon.js +715 -0
  47. package/dist/packages/autotrade/src/monitor.js +190 -0
  48. package/dist/packages/autotrade/src/ollama-sessions.js +137 -0
  49. package/dist/packages/autotrade/src/paper-accounts.js +72 -0
  50. package/dist/packages/autotrade/src/replay.js +198 -0
  51. package/dist/packages/autotrade/src/runner-config.js +99 -0
  52. package/dist/packages/autotrade/src/runner.js +872 -0
  53. package/dist/packages/autotrade/src/safety.js +243 -0
  54. package/dist/packages/autotrade/src/session.js +269 -0
  55. package/dist/packages/autotrade/src/sessions.js +503 -0
  56. package/dist/packages/autotrade/src/store.js +250 -0
  57. package/dist/packages/autotrade/src/strategy.js +256 -0
  58. package/dist/packages/autotrade/src/trade-ledger.js +241 -0
  59. package/dist/packages/autotrade/src/yolo.js +140 -0
  60. package/dist/packages/cli/assets/claude/analyst-system.md +4 -4
  61. package/dist/packages/cli/assets/claude/plugin/skills/REGISTRY.json +1 -1
  62. package/dist/packages/cli/assets/claude/plugin/skills/larp-check/SKILL.md +15 -8
  63. package/dist/packages/cli/assets/claude/plugin/skills/token-dossier/SKILL.md +1 -1
  64. package/dist/packages/cli/src/agent-cmd.js +6 -4
  65. package/dist/packages/cli/src/agent-spectator.js +17 -1
  66. package/dist/packages/cli/src/ai-cmd.js +412 -0
  67. package/dist/packages/cli/src/analyst/backend.js +105 -15
  68. package/dist/packages/cli/src/analyst/codex.js +14 -9
  69. package/dist/packages/cli/src/analyst/larp-gauge.js +60 -0
  70. package/dist/packages/cli/src/analyst/ollama.js +263 -0
  71. package/dist/packages/cli/src/analyst/session.js +17 -3
  72. package/dist/packages/cli/src/app-help-gen.js +51 -15
  73. package/dist/packages/cli/src/autotrade-cmd/audit.js +57 -0
  74. package/dist/packages/cli/src/autotrade-cmd/backtest.js +199 -0
  75. package/dist/packages/cli/src/autotrade-cmd/flatten.js +64 -0
  76. package/dist/packages/cli/src/autotrade-cmd/fleet.js +397 -0
  77. package/dist/packages/cli/src/autotrade-cmd/requests.js +79 -0
  78. package/dist/packages/cli/src/autotrade-cmd/run.js +413 -0
  79. package/dist/packages/cli/src/autotrade-cmd/stop.js +76 -0
  80. package/dist/packages/cli/src/autotrade-cmd/strategies.js +198 -0
  81. package/dist/packages/cli/src/autotrade-cmd/strategy-control.js +174 -0
  82. package/dist/packages/cli/src/autotrade-cmd/telegram-host.js +101 -0
  83. package/dist/packages/cli/src/autotrade-cmd.js +168 -0
  84. package/dist/packages/cli/src/backtest-cmd.js +13 -2
  85. package/dist/packages/cli/src/display.js +208 -23
  86. package/dist/packages/cli/src/doctor.js +62 -3
  87. package/dist/packages/cli/src/export.js +10 -2
  88. package/dist/packages/cli/src/index.js +1 -1
  89. package/dist/packages/cli/src/ledger-cmd.js +288 -0
  90. package/dist/packages/cli/src/live/chart-fills.js +46 -0
  91. package/dist/packages/cli/src/live/dev-history.js +31 -15
  92. package/dist/packages/cli/src/live/index.js +28 -90
  93. package/dist/packages/cli/src/live/screens/newpairs-live.js +1 -1
  94. package/dist/packages/cli/src/live/screens/token-live.js +48 -15
  95. package/dist/packages/cli/src/live/screens/watchlist-live.js +1 -1
  96. package/dist/packages/cli/src/live/trade.js +30 -453
  97. package/dist/packages/cli/src/live/watchlist.js +1 -1
  98. package/dist/packages/cli/src/main.js +290 -199
  99. package/dist/packages/cli/src/mcp-cmd.js +7 -1
  100. package/dist/packages/cli/src/mcp-follow.js +103 -6
  101. package/dist/packages/cli/src/plan-cmd.js +15 -5
  102. package/dist/packages/cli/src/pnl-app.js +31 -21
  103. package/dist/packages/cli/src/pnl-card.js +158 -21
  104. package/dist/packages/cli/src/popup.js +38 -6
  105. package/dist/packages/cli/src/record-cmd.js +141 -20
  106. package/dist/packages/cli/src/scan/ui.js +7 -1
  107. package/dist/packages/cli/src/screens/agent-hud.js +773 -0
  108. package/dist/packages/cli/src/screens/analyst-session.js +11 -4
  109. package/dist/packages/cli/src/screens/analyst.js +3 -2
  110. package/dist/packages/cli/src/screens/autotrade-keys.js +169 -0
  111. package/dist/packages/cli/src/screens/autotrade-proposals.js +123 -0
  112. package/dist/packages/cli/src/screens/autotrade-screen.js +725 -0
  113. package/dist/packages/cli/src/screens/autotrade-ui.js +640 -0
  114. package/dist/packages/cli/src/screens/autotrade-worker.js +89 -0
  115. package/dist/packages/cli/src/screens/brain.js +634 -0
  116. package/dist/packages/cli/src/screens/newpairs.js +1 -1
  117. package/dist/packages/cli/src/screens/overlay.js +5 -2
  118. package/dist/packages/cli/src/screens/plans.js +5 -17
  119. package/dist/packages/cli/src/screens/pnl-chip.js +144 -0
  120. package/dist/packages/cli/src/screens/positions.js +6 -28
  121. package/dist/packages/cli/src/screens/screener.js +1 -0
  122. package/dist/packages/cli/src/screens/ticket.js +38 -205
  123. package/dist/packages/cli/src/screens/token.js +18 -9
  124. package/dist/packages/cli/src/screens/trending.js +1 -1
  125. package/dist/packages/cli/src/state.js +88 -18
  126. package/dist/packages/cli/src/telegram-cmd.js +451 -0
  127. package/dist/packages/cli/src/trade.js +3 -128
  128. package/dist/packages/cli/src/version.js +1 -1
  129. package/dist/packages/cli/src/wallet-cmd.js +39 -340
  130. package/dist/packages/cli/src/wallet-command.js +8 -11
  131. package/dist/packages/cli/src/widgets.js +0 -12
  132. package/dist/packages/custom/src/config.js +20 -2
  133. package/dist/packages/custom/src/schema.js +41 -10
  134. package/dist/packages/custom/src/workspace.js +3 -3
  135. package/dist/packages/data/src/basis.js +191 -0
  136. package/dist/packages/data/src/detail.js +53 -2
  137. package/dist/packages/data/src/index.js +2 -14
  138. package/dist/packages/data/src/larp/score.js +220 -0
  139. package/dist/packages/data/src/larp/x-account.js +316 -0
  140. package/dist/packages/data/src/store.js +14 -5
  141. package/dist/packages/data/src/trade/agent/paper-desk.js +300 -23
  142. package/dist/packages/data/src/trade/agent/rendezvous.js +3 -2
  143. package/dist/packages/data/src/trade/bridge.js +4 -102
  144. package/dist/packages/data/src/trade/ledger/export.js +101 -0
  145. package/dist/packages/data/src/trade/ledger/file.js +135 -0
  146. package/dist/packages/data/src/trade/ledger/fold.js +191 -0
  147. package/dist/packages/data/src/trade/ledger/index.js +9 -0
  148. package/dist/packages/data/src/trade/ledger/schema.js +83 -0
  149. package/dist/packages/data/src/trade/ledger/sources.js +307 -0
  150. package/dist/packages/data/src/trade/ledger/stats.js +123 -0
  151. package/dist/packages/data/src/trade/ledger/tags.js +116 -0
  152. package/dist/packages/data/src/trade/ledger/view.js +51 -0
  153. package/dist/packages/data/src/trade/plans/engine.js +7 -0
  154. package/dist/packages/data/src/trade/plans/index.js +0 -1
  155. package/dist/packages/data/src/trade/plans/mandate.js +28 -15
  156. package/dist/packages/data/src/trade/plans/service.js +4 -28
  157. package/dist/packages/mcp/assets/kb/app-help/autotrade-chat.md +48 -0
  158. package/dist/packages/mcp/assets/kb/app-help/autotrade-parallel.md +42 -0
  159. package/dist/packages/mcp/assets/kb/app-help/autotrade-runner.md +35 -0
  160. package/dist/packages/mcp/assets/kb/app-help/autotrade-stop.md +37 -0
  161. package/dist/packages/mcp/assets/kb/app-help/autotrade-strategies.md +35 -0
  162. package/dist/packages/mcp/assets/kb/app-help/autotrade-telegram.md +40 -0
  163. package/dist/packages/mcp/assets/kb/app-help/chart-trade-markers.md +42 -0
  164. package/dist/packages/mcp/assets/kb/app-help/dev-history.md +1 -1
  165. package/dist/packages/mcp/assets/kb/app-help/larp-check.md +5 -1
  166. package/dist/packages/mcp/assets/kb/app-help/link-a-wallet.md +4 -10
  167. package/dist/packages/mcp/assets/kb/app-help/live-trading.md +38 -0
  168. package/dist/packages/mcp/assets/kb/app-help/live-yolo.md +34 -0
  169. package/dist/packages/mcp/assets/kb/app-help/order-plans.md +1 -1
  170. package/dist/packages/mcp/assets/kb/app-help/price-or-marketcap.md +5 -2
  171. package/dist/packages/mcp/assets/kb/app-help/scan-mode.md +1 -1
  172. package/dist/packages/mcp/assets/kb/app-help/screen-analyst.md +3 -0
  173. package/dist/packages/mcp/assets/kb/app-help/screen-autotrade.md +217 -0
  174. package/dist/packages/mcp/assets/kb/app-help/screen-kol.md +3 -0
  175. package/dist/packages/mcp/assets/kb/app-help/screen-newpairs.md +3 -0
  176. package/dist/packages/mcp/assets/kb/app-help/screen-positions.md +3 -0
  177. package/dist/packages/mcp/assets/kb/app-help/screen-screener.md +3 -0
  178. package/dist/packages/mcp/assets/kb/app-help/screen-token.md +6 -0
  179. package/dist/packages/mcp/assets/kb/app-help/screen-trending.md +3 -0
  180. package/dist/packages/mcp/assets/kb/app-help/screen-watchlist.md +3 -0
  181. package/dist/packages/mcp/assets/kb/app-help/spectate-an-agent.md +2 -1
  182. package/dist/packages/mcp/assets/kb/app-help/standing-mandates.md +1 -1
  183. package/dist/packages/mcp/assets/kb/app-help/trade-ledger.md +54 -0
  184. package/dist/packages/mcp/assets/kb/app-help/use-local-model.md +38 -0
  185. package/dist/packages/mcp/assets/kb/docs/docs-agents-agent-paper-trading.md +7 -3
  186. package/dist/packages/mcp/assets/kb/docs/docs-agents-reading-your-trade-ledger.md +31 -0
  187. package/dist/packages/mcp/assets/kb/docs/docs-agents-untrusted-by-default.md +1 -1
  188. package/dist/packages/mcp/assets/kb/docs/docs-analyst-if-claude-is-missing.md +1 -1
  189. package/dist/packages/mcp/assets/kb/docs/docs-analyst-starting-a-run.md +2 -0
  190. package/dist/packages/mcp/assets/kb/docs/docs-analyst-use-a-local-model-instead.md +27 -0
  191. package/dist/packages/mcp/assets/kb/docs/docs-analyst-what-it-sees.md +2 -0
  192. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-backtests-and-their-limits.md +56 -0
  193. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-change-a-strategy-by-chat.md +49 -0
  194. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-checking-the-record-of-a-run.md +28 -0
  195. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-comparing-them.md +41 -0
  196. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-exits-and-wakes.md +76 -0
  197. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-how-a-stop-reaches-the-runner.md +32 -0
  198. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-on-the-q-screen.md +37 -0
  199. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-one-strategy-or-all-of-them.md +35 -0
  200. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-paper-accounts.md +50 -0
  201. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-presets.md +37 -0
  202. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-running-it-all-day.md +31 -0
  203. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-sessions-and-their-limits.md +31 -0
  204. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-several-strategies-at-once.md +33 -0
  205. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-stopping-it.md +35 -0
  206. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-strategies-and-presets.md +34 -0
  207. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-the-autotrade-json-file.md +48 -0
  208. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-the-heartbeat.md +27 -0
  209. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-the-run-file-and-the-heartbeat.md +34 -0
  210. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-the-runner-and-candidate-sessions.md +45 -0
  211. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-what-each-session-shows-first.md +31 -0
  212. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-what-it-costs-claude-usage-per-session.md +58 -0
  213. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-what-it-is-paper-self-directed.md +43 -0
  214. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-what-it-will-not-do.md +31 -0
  215. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-which-account-day-caps-and-the-usage-guard.md +44 -0
  216. package/dist/packages/mcp/assets/kb/docs/docs-autotrade-your-strategies.md +37 -0
  217. package/dist/packages/mcp/assets/kb/docs/docs-autotrade.md +22 -0
  218. package/dist/packages/mcp/assets/kb/docs/docs-beginners-before-any-experimental-trading.md +2 -2
  219. package/dist/packages/mcp/assets/kb/docs/docs-beginners.md +1 -1
  220. package/dist/packages/mcp/assets/kb/docs/docs-configuration-chart-markers.md +30 -0
  221. package/dist/packages/mcp/assets/kb/docs/docs-configuration-chart-y-axis.md +32 -0
  222. package/dist/packages/mcp/assets/kb/docs/docs-configuration-environment-variables.md +4 -1
  223. package/dist/packages/mcp/assets/kb/docs/docs-configuration-files-on-disk.md +1 -0
  224. package/dist/packages/mcp/assets/kb/docs/docs-configuration-headless-recorder-dexterm-record.md +3 -1
  225. package/dist/packages/mcp/assets/kb/docs/docs-configuration-price-display-mode.md +9 -7
  226. package/dist/packages/mcp/assets/kb/docs/docs-copy-trading-stage-2-the-one-key-mirror-ticket-a-proposal.md +1 -1
  227. package/dist/packages/mcp/assets/kb/docs/docs-copy-trading-stage-3-capped-auto-mirror-default-off-less.md +1 -1
  228. package/dist/packages/mcp/assets/kb/docs/docs-copy-trading-what-is-proven-what-is-not.md +1 -1
  229. package/dist/packages/mcp/assets/kb/docs/docs-copy-trading.md +1 -1
  230. package/dist/packages/mcp/assets/kb/docs/docs-data-sources-recorded-history-and-retention.md +36 -0
  231. package/dist/packages/mcp/assets/kb/docs/docs-data-sources-sources.md +1 -0
  232. package/dist/packages/mcp/assets/kb/docs/docs-getting-started-first-run.md +1 -1
  233. package/dist/packages/mcp/assets/kb/docs/docs-getting-started-install.md +3 -3
  234. package/dist/packages/mcp/assets/kb/docs/docs-getting-started-requirements.md +1 -1
  235. package/dist/packages/mcp/assets/kb/docs/docs-getting-started-running-the-tests.md +1 -1
  236. package/dist/packages/mcp/assets/kb/docs/docs-getting-started.md +1 -1
  237. package/dist/packages/mcp/assets/kb/docs/docs-larp-measured-accuracy.md +1 -0
  238. package/dist/packages/mcp/assets/kb/docs/docs-larp-the-larp-score.md +60 -0
  239. package/dist/packages/mcp/assets/kb/docs/docs-larp-the-verdict.md +0 -2
  240. package/dist/packages/mcp/assets/kb/docs/docs-larp-what-it-looks-at.md +4 -1
  241. package/dist/packages/mcp/assets/kb/docs/docs-larp.md +1 -1
  242. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-changed-in-0-1-7.md +26 -0
  243. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-stopping.md +28 -0
  244. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-the-short-version.md +34 -0
  245. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-using-a-trading-bot-with-dexterm.md +33 -0
  246. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-what-dexterm-does-not-do.md +30 -0
  247. package/dist/packages/mcp/assets/kb/docs/docs-live-trading-what-dexterm-does.md +29 -0
  248. package/dist/packages/mcp/assets/kb/docs/docs-live-trading.md +23 -0
  249. package/dist/packages/mcp/assets/kb/docs/docs-ollama-another-machine.md +28 -0
  250. package/dist/packages/mcp/assets/kb/docs/docs-ollama-autotrade-on-a-local-model.md +29 -0
  251. package/dist/packages/mcp/assets/kb/docs/docs-ollama-check-your-model-dexterm-ai-probe.md +38 -0
  252. package/dist/packages/mcp/assets/kb/docs/docs-ollama-how-we-checked.md +27 -0
  253. package/dist/packages/mcp/assets/kb/docs/docs-ollama-models-without-tool-calling.md +32 -0
  254. package/dist/packages/mcp/assets/kb/docs/docs-ollama-pick-the-engine-globally-or-per-surface.md +43 -0
  255. package/dist/packages/mcp/assets/kb/docs/docs-ollama-restriction-profiles.md +35 -0
  256. package/dist/packages/mcp/assets/kb/docs/docs-ollama-set-it-up-in-two-minutes.md +39 -0
  257. package/dist/packages/mcp/assets/kb/docs/docs-ollama-troubleshooting.md +35 -0
  258. package/dist/packages/mcp/assets/kb/docs/docs-ollama-what-runs-on-a-local-model.md +39 -0
  259. package/dist/packages/mcp/assets/kb/docs/docs-ollama-what-stays-outside-the-model.md +36 -0
  260. package/dist/packages/mcp/assets/kb/docs/docs-ollama-which-model.md +38 -0
  261. package/dist/packages/mcp/assets/kb/docs/docs-ollama-your-own-agent-on-the-local-model.md +28 -0
  262. package/dist/packages/mcp/assets/kb/docs/docs-ollama.md +28 -0
  263. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-letting-an-agent-paper-trade-experimental.md +3 -4
  264. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-link-a-wallet-read-only.md +30 -0
  265. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-order-plans-and-standing-mandates.md +4 -13
  266. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-panic.md +4 -7
  267. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-paper-only-mandates.md +40 -0
  268. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-pnl-cards.md +7 -7
  269. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-safety-model.md +34 -0
  270. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-ticket.md +3 -4
  271. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-trade-ledger.md +42 -0
  272. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-wallet.md +4 -5
  273. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-trade-moments.md +4 -5
  274. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading.md +4 -5
  275. package/dist/packages/mcp/assets/kb/docs/docs-popup-chart-buy-and-sell-markers.md +37 -0
  276. package/dist/packages/mcp/assets/kb/docs/docs-popup-chart-market-cap-axis.md +1 -1
  277. package/dist/packages/mcp/assets/kb/docs/docs-popup-chart-what-it-shows.md +3 -1
  278. package/dist/packages/mcp/assets/kb/docs/docs-scan-the-read.md +2 -0
  279. package/dist/packages/mcp/assets/kb/docs/docs-screens-autotrade-paper.md +26 -0
  280. package/dist/packages/mcp/assets/kb/docs/docs-screens-dev-history.md +10 -7
  281. package/dist/packages/mcp/assets/kb/docs/docs-screens-order-plans.md +1 -1
  282. package/dist/packages/mcp/assets/kb/docs/docs-screens-token-screen.md +2 -0
  283. package/dist/packages/mcp/assets/kb/docs/docs-spectator-follow-over-mcp-in-the-running-terminal.md +1 -1
  284. package/dist/packages/mcp/assets/kb/docs/docs-spectator-limits.md +2 -0
  285. package/dist/packages/mcp/assets/kb/docs/docs-spectator-the-agent-hud-spectator-v2.md +58 -0
  286. package/dist/packages/mcp/assets/kb/docs/docs-spectator-the-brain-view-and-the-pnl-chip.md +46 -0
  287. package/dist/packages/mcp/assets/kb/docs/docs-spectator-the-three-surfaces.md +1 -1
  288. package/dist/packages/mcp/assets/kb/docs/docs-spectator.md +1 -1
  289. package/dist/packages/mcp/assets/kb/docs/docs-telegram-approve-one-tap-entries.md +50 -0
  290. package/dist/packages/mcp/assets/kb/docs/docs-telegram-control-the-commands.md +43 -0
  291. package/dist/packages/mcp/assets/kb/docs/docs-telegram-if-something-goes-wrong.md +30 -0
  292. package/dist/packages/mcp/assets/kb/docs/docs-telegram-notify-what-reaches-your-phone.md +41 -0
  293. package/dist/packages/mcp/assets/kb/docs/docs-telegram-set-it-up.md +47 -0
  294. package/dist/packages/mcp/assets/kb/docs/docs-telegram-the-record.md +26 -0
  295. package/dist/packages/mcp/assets/kb/docs/docs-telegram-what-it-is.md +33 -0
  296. package/dist/packages/mcp/assets/kb/docs/docs-telegram-what-it-will-not-do.md +31 -0
  297. package/dist/packages/mcp/assets/kb/docs/docs-telegram.md +23 -0
  298. package/dist/packages/mcp/assets/kb/docs/docs-troubleshooting-common-questions.md +1 -1
  299. package/dist/packages/mcp/assets/kb/docs/docs-troubleshooting-doctor-lines.md +4 -0
  300. package/dist/packages/mcp/assets/kb/docs/docs-voice-linux-and-windows.md +1 -1
  301. package/dist/packages/mcp/assets/kb/docs/docs-voice.md +1 -1
  302. package/dist/packages/mcp/assets/kb/docs/docs-yolo-1-replay-it-on-your-own-history.md +42 -0
  303. package/dist/packages/mcp/assets/kb/docs/docs-yolo-2-run-it-on-paper.md +34 -0
  304. package/dist/packages/mcp/assets/kb/docs/docs-yolo-3-watch-it-and-stop-it.md +32 -0
  305. package/dist/packages/mcp/assets/kb/docs/docs-yolo-the-rules.md +37 -0
  306. package/dist/packages/mcp/assets/kb/docs/docs-yolo-what-it-is.md +34 -0
  307. package/dist/packages/mcp/assets/kb/docs/docs-yolo-what-it-will-not-do.md +31 -0
  308. package/dist/packages/mcp/assets/kb/docs/docs-yolo.md +26 -0
  309. package/dist/packages/mcp/assets/kb/entries/autotrade.md +38 -0
  310. package/dist/packages/mcp/src/app-help.js +1 -1
  311. package/dist/packages/mcp/src/autotrade-tools.js +944 -0
  312. package/dist/packages/mcp/src/backtest-requests.js +71 -0
  313. package/dist/packages/mcp/src/engine/config.js +159 -0
  314. package/dist/packages/mcp/src/engine/index.js +10 -0
  315. package/dist/packages/mcp/src/engine/loop.js +101 -0
  316. package/dist/packages/mcp/src/engine/mcp-client.js +123 -0
  317. package/dist/packages/mcp/src/engine/ollama.js +258 -0
  318. package/dist/packages/mcp/src/engine/probe.js +110 -0
  319. package/dist/packages/mcp/src/engine/reason.js +35 -0
  320. package/dist/packages/mcp/src/engine/restrictions.js +111 -0
  321. package/dist/packages/mcp/src/index.js +7 -1
  322. package/dist/packages/mcp/src/ledger-tools.js +346 -0
  323. package/dist/packages/mcp/src/paper-agent.js +5 -2
  324. package/dist/packages/mcp/src/server.js +285 -36
  325. package/dist/packages/mcp/src/spectator-sink.js +85 -0
  326. package/dist/packages/packs/src/backtest.js +3 -1
  327. package/dist/packages/packs/src/index.js +1 -0
  328. package/dist/packages/packs/src/larp-score-backtest.js +119 -0
  329. package/dist/packages/popup/src/pages/chart-lib.js +169 -35
  330. package/dist/packages/popup/src/pages/chart.css +18 -0
  331. package/dist/packages/popup/src/pages/chart.html +6 -1
  332. package/dist/packages/popup/src/pages/chart.js +136 -10
  333. package/dist/packages/popup/src/pages/spectator.css +45 -0
  334. package/dist/packages/popup/src/pages/spectator.html +1 -0
  335. package/dist/packages/popup/src/pages/spectator.js +69 -0
  336. package/dist/packages/popup/src/protocol.js +4 -0
  337. package/dist/packages/popup/src/server.js +9 -1
  338. package/dist/packages/recorder/src/dev-history.js +7 -3
  339. package/dist/packages/recorder/src/index.js +2 -0
  340. package/dist/packages/recorder/src/recorder.js +63 -6
  341. package/dist/packages/recorder/src/retention.js +100 -0
  342. package/dist/packages/recorder/src/schema.js +34 -1
  343. package/dist/packages/recorder/src/ticks.js +237 -0
  344. package/dist/packages/tui/src/canvas.js +7 -0
  345. package/dist/packages/tui/src/fmt.js +53 -0
  346. package/dist/packages/tui/src/index.js +1 -0
  347. package/dist/packages/tui/src/keymap.js +25 -1
  348. package/dist/packages/tui/src/markers.js +219 -0
  349. package/dist/packages/tui/src/widgets.js +158 -6
  350. package/package.json +2 -1
  351. package/dist/packages/data/src/trade/caps.js +0 -323
  352. package/dist/packages/data/src/trade/executor.js +0 -933
  353. package/dist/packages/data/src/trade/plans/executor-live.js +0 -220
  354. package/dist/packages/data/src/trade/rpc-exec.js +0 -229
  355. package/dist/packages/data/src/trade/signer/client.js +0 -197
  356. package/dist/packages/data/src/trade/signer/fast-wallet.js +0 -154
  357. package/dist/packages/data/src/trade/signer/host.js +0 -97
  358. package/dist/packages/data/src/trade/signer/main.js +0 -121
  359. package/dist/packages/data/src/trade/signer/probe-builder.js +0 -85
  360. package/dist/packages/data/src/trade/signer/protocol.js +0 -92
  361. package/dist/packages/data/src/trade/signer/service.js +0 -400
  362. package/dist/packages/data/src/trade/signer/sol-usd-feed.js +0 -98
  363. package/dist/packages/data/src/trade/sol-usd.js +0 -86
  364. package/dist/packages/data/src/trade/swap-build.js +0 -108
  365. package/dist/packages/data/src/trade/token-delta.js +0 -201
  366. package/dist/packages/data/vendor/solana-web3/LICENSE +0 -20
  367. package/dist/packages/data/vendor/solana-web3/NOTICE.md +0 -13
  368. package/dist/packages/data/vendor/solana-web3/index.iife.min.js +0 -20
  369. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-a-live-ticket.md +0 -42
  370. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-before-you-press-size-vs-caps.md +0 -34
  371. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-devnet-signer-mainnet-token.md +0 -35
  372. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-jupiter-rate-limits.md +0 -33
  373. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-link-a-wallet.md +0 -32
  374. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-live-trading-devnet-first.md +0 -30
  375. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-mainnet.md +0 -31
  376. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-live-fire-path-devnet-the-fast-wallet.md +0 -41
  377. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-the-signer-process.md +0 -34
  378. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-what-the-live-path-keeps.md +0 -37
  379. package/dist/packages/mcp/assets/kb/docs/docs-paper-trading-your-first-live-trade.md +0 -41
@@ -99,6 +99,8 @@ const SCREENS = [
99
99
  blurb: 'What is trending in the space — narratives and movers aggregated from the feed.' },
100
100
  { screen: 'kol', title: 'The KOL lists screen', feature: 'kol-lists', tools: [],
101
101
  blurb: 'Key-opinion-leader wallet lists and their activity (official/authorized sources only).' },
102
+ { screen: 'autotrade', title: 'The autotrade (paper) screen', feature: 'autotrade-strategies', tools: ['strategy_list', 'autotrade_status'],
103
+ blurb: 'Press `Q` anywhere for AUTOTRADE, paper only. tab cycles five views: STRATEGIES (the presets and your own files with mode, version, hash and the last backtest), EDITOR (one form in six sections: entry, exits, risk, sizing, agent, execution; every change re-validates, errors show inline with their path, the screen filter is checked by the screener\'s own parser and its error column is marked; `s` saves only a valid draft as a new version, `u` undoes), COMPARE (two marked strategies side by side, changed fields first, both backtested on the same tape), BACKTEST (the report with attribution, an equity sparkline, clamps, refusals and the limits box; `w` runs a sweep whose verdict comes from coins it never tuned on) and RUNNER (the paper runner\'s heartbeat, halt reason, candidates, sessions, positions and ledger tail). Presets are read-only: `d` makes your own copy. Nothing on this screen switches a strategy to live, arms a mandate or touches a wallet. A strategy edit the analyst proposed in chat shows as a card: `o` opens its diff, `y` applies it, and a LOOSER edit (any risk number less safe) needs a second `y` on the less-safe popup.' },
102
104
  ];
103
105
  /** The screen keys that get an overview entry (for the drift test's forward key-coverage check). */
104
106
  export const SCREENS_DOCUMENTED = SCREENS.map((s) => s.screen);
@@ -158,21 +160,24 @@ const TOPICS = [
158
160
  { id: 'open-chart-popup', title: 'Open the chart popup', screen: 'token', tags: ['chart', 'popup', 'candles', 'window', 'dock', 'graph'],
159
161
  actions: [{ action: 'popup.chart', screen: 'token' }], feature: 'popup-chart',
160
162
  body: 'Press `C` on the token screen to open the docked chart popup (a native window, or your browser as fallback). It is fed only by the terminal\'s caches over one loopback WebSocket and never sees your keys. The analyst can open or close it for you.' },
163
+ { id: 'chart-trade-markers', title: 'See your buys and sells on the chart (B / S markers)', screen: 'token', tags: ['markers', 'marker', 'buy', 'sell', 'bought', 'sold', 'fills', 'fill', 'entry', 'exit', 'trades', 'chart', 'avg', 'average', 'paper', 'live', 'arrows'],
164
+ commands: ['display'], feature: 'chart-trade-markers',
165
+ body: 'Every fill of the open coin from your paper ledger (your own and an agent\'s PAPER trades) and the live ledger (confirmed real swaps) is marked on the token screen\'s chart and the chart popup, on every timeframe: `B` for a buy and `S` for a sell, at the fill\'s time and price. Hollow `△ ▽` = PAPER, solid `▲ ▼` = live, so it reads without colour too. Each partial sell gets its own marker (several in one bar show a count), a dashed `avg` line marks the average entry while the position is open, and a closed round trip gets a faint wash from entry to exit. A fill outside the candles on screen is not moved: the chart says how many are off-chart. In the popup, hover a marker for its time, price, size and ledger; `k` or the **MARKERS** button turns them off or on for both charts (saved as `display.chartMarkers`; also `dexterm display markers on|off`). Display only: no marker can arm, size, sign or confirm anything, and nothing is fetched to draw them.' },
161
166
  { id: 'switch-theme', title: 'Switch the theme', screen: 'all', tags: ['theme', 'themes', 'colour', 'colours', 'color', 'colors', 'look', 'cyberspace', 'midnight', 'ember', 'paper'],
162
167
  actions: [{ action: 'theme.next' }], commands: ['theme'], flags: ['--theme'], feature: 'themes-keymaps',
163
168
  body: 'Press `t` to cycle themes (cyberspace → midnight → ember → paper). `dexterm theme list|show|init|check` manages your own themes in `~/.dexterm/themes/`; a shared theme cannot hide a warning or swap buy/sell colours (a contrast + hue guard). The analyst can propose a theme change you confirm with a keypress.' },
164
169
  { id: 'calm-mode', title: 'Turn on calm mode (effects off)', screen: 'all', tags: ['calm', 'effects', 'rain', 'glitch', 'quiet', 'still', 'intensity'],
165
170
  flags: ['--calm', '--intensity'], feature: 'look',
166
171
  body: 'Press `c` to toggle calm mode: rain, glitch, blink and scanlines off, back to the last intensity when pressed again. Start calm with `--calm` (or `DEXTERM_CALM=1`); `--intensity normal|fever|off` picks a tier. The analyst can toggle calm for you.' },
167
- { id: 'price-or-marketcap', title: 'Show price or market cap', screen: 'all', tags: ['price', 'mcap', 'marketcap', 'market', 'display', 'usd', 'cap'],
168
- actions: [{ action: 'display.priceMode' }], commands: ['display'], flags: ['--price-mode'], feature: 'price-display-mode',
169
- body: 'Press `$` to flip every price between USD price and MARKET CAP (screener, watchlist, new pairs, token, both charts, order-plan levels). Saved as `display.priceMode`; also `dexterm display price|mcap` or `--price-mode`. A coin with no known supply stays on price and says so. The analyst can set this for you.' },
172
+ { id: 'price-or-marketcap', title: 'Market cap or price (market cap is the default)', screen: 'all', tags: ['price', 'mcap', 'marketcap', 'market', 'display', 'usd', 'cap', 'basis'],
173
+ actions: [{ action: 'display.priceMode' }], commands: ['display'], flags: ['--price-mode', '--price', '--mcap'], feature: 'price-display-mode',
174
+ body: 'Market cap is the default basis: every screen, the CLI text, the chat assistant and the autotrade agents show and talk about a coin in market cap (entered at $69.7K, exited at $264.9K, 3.8x). Press `$` (or type `/display price` in the chat box, `/display mcap` to go back) to switch to USD price and back. Saved as `display.priceMode`; also `dexterm display mcap|price`. For one run: `--price` / `--mcap` on any command, `--price-mode`, or `DEXTERM_PRICE_BASIS=price`. Market cap = price × a known supply (the source\'s cap ÷ price, recorded FDV ÷ price, or pump.fun\'s 1B); a coin with no known supply shows its price marked ᵖ and says so. JSON keeps both `price` and `mcap`. The charts have their own axis setting (`A`). The analyst can propose this for you.' },
170
175
  { id: 'scan-mode', title: 'Use AI scan mode', screen: 'all', tags: ['scan', 'watcher', 'observe', 'auto', 'ai', 'monitor'],
171
176
  actions: [{ action: 'scan.toggle' }, { action: 'scan.resume' }], flags: ['--scan'], feature: 'scan',
172
- body: 'Scan mode is an observe-only AI watcher (off by default, zero extra requests). Toggle it with `Z` (or `/scan on|off` on the screener line, or `--scan` at launch); `R` resumes a paused scan. It can only surface findings, never take a UI action or trade (structurally observe-only). The analyst can turn it on or off for you.' },
173
- { id: 'larp-check', title: 'Run the LARP check (is the product real?)', screen: 'token', tags: ['larp', 'fake', 'real', 'legit', 'website', 'product', 'domain', 'github', 'vet'],
174
- tools: ['larp_check', 'get_links', 'fetch_page', 'check_domain', 'check_github'], feature: 'larp-check',
175
- body: 'The LARP check vets whether a real product exists (website, domain age, GitHub) read-only — it is not a price call. Ask the analyst "is <coin> a larp?" (skill `larp-check`), or an agent can call the `larp_check` MCP tool. A grade is a risk flag, never a certificate; it never recommends buy/sell.' },
177
+ body: 'Scan mode is an observe-only AI watcher (off by default, zero extra requests). Toggle it with `Z` (or `/scan on|off` on the screener line, or `--scan` at launch); `R` resumes a paused scan. It can only surface findings, never take a UI action or trade (structurally observe-only). While it is on, the token screen\'s analyst panel shows its brain view: the scan log (locks, refreshes, releases, blocked actions) with the read streaming under it, the vetting checklist and the data strip. While it runs and you hold a paper or live position, a PnL chip shows it on the band under the header of every screen and on the chart popup; display only. The analyst can turn it on or off for you.' },
178
+ { id: 'larp-check', title: 'Run the LARP check (is the product real?)', screen: 'token', tags: ['larp', 'fake', 'real', 'legit', 'website', 'product', 'domain', 'github', 'vet', 'score', 'x', 'twitter'],
179
+ tools: ['larp_check', 'get_links', 'fetch_page', 'check_domain', 'check_github', 'check_x'], feature: 'larp-check',
180
+ body: 'The LARP check vets whether a real product exists (website, domain age, GitHub, the X account) read-only — it is not a price call. Ask the analyst "is <coin> a larp?" (skill `larp-check`), or an agent can call the `larp_check` MCP tool. It returns a 0-100 LARP score: the sum of named flags with their points (low under 25, medium 25-49, high 50+), plus a list of what could not be read, which widens the range instead of lowering the score. A score is a summary of flags, never a certificate; it never recommends buy/sell.' },
176
181
  { id: 'rug-check', title: 'Check if a coin is a rug', screen: 'token', tags: ['rug', 'safe', 'honeypot', 'scam', 'risk', 'check', 'authority', 'mint'],
177
182
  actions: [{ action: 'analyst.toggle' }], tools: ['analyze_token', 'get_dossier', 'rugcheck'], feature: 'analyst',
178
183
  body: 'Press `a` to run a rug-check on the selected coin: authorities, token program, LP, holder concentration, creator history and tape, with a p(rug) from the H1 heuristic (a ranking, not a calibrated probability). The verdict is WATCH / SPECULATIVE / AVOID. Facts come only from tools; it is not financial advice.' },
@@ -186,9 +191,12 @@ const TOPICS = [
186
191
  { id: 'use-codex-analyst', title: 'Run the analyst on Codex instead of Claude', screen: 'all', tags: ['codex', 'openai', 'chatgpt', 'engine', 'analyst', 'claude', 'switch', 'backend'],
187
192
  flags: ['--analyst-engine'], feature: 'analyst',
188
193
  body: 'The analyst can run on your own Codex CLI login instead of Claude (0.1.5). Pick it with `--analyst-engine codex`, `DEXTERM_ANALYST_ENGINE=codex`, `"analyst": {"engine": "codex"}` in `~/.dexterm/config.json`, or type `/engine codex` in the chat box (new conversations; `/engine` alone shows the engine and what is installed). The default `auto` uses claude when it is installed, else codex. dexterm stores no credentials: your `codex login` does the work. The Codex run is locked read-only: only the read-only dexterm tools (plus the UI actions the session allows, none in scan mode), no shell, no file edits, no web search, no other MCP server; a turn that tries anything else is stopped. `dexterm doctor` shows a Codex CLI line (installed, version, logged in). Codex is also supported as an MCP client: `dexterm mcp install codex`.' },
194
+ { id: 'use-local-model', title: 'Run dexterm\'s AI on a free local model (Ollama)', screen: 'all', tags: ['ollama', 'local', 'model', 'free', 'offline', 'engine', 'llama', 'qwen', 'restrictions', 'privacy'],
195
+ commands: ['ai', 'ask'], flags: ['--analyst-engine'], feature: 'analyst',
196
+ body: 'dexterm\'s AI can run on a free model on your own machine through Ollama: no login, no key, $0 per answer, and it talks only to http://127.0.0.1:11434 by default. Set it up in two minutes: install Ollama (https://ollama.com/download), `ollama pull qwen3:8b`, `dexterm ai engine ollama`, `dexterm ai model qwen3:8b`, then `dexterm doctor` (the Ollama line should pass). In the chat box `/engine ollama` switches new conversations, `/engine claude` switches back; `--analyst-engine ollama` and `DEXTERM_ANALYST_ENGINE=ollama` work too, and `dexterm ai engine ollama --surface autotrade` picks one surface. The local engine uses the same dexterm tools and the same firewalled context as Claude. What it may do is your restriction profile: `observe` (analyse only), `propose` (the default for a new setup: UI actions, a PAPER ticket you confirm, strategy proposals you apply), `paper` (adds paper autotrade sessions and agent paper trading in a mandate you armed: `dexterm ai restrictions paper`), `full` (only after `dexterm ai engine ollama --full` and typing ENABLE FULL, for one model). Caps, the kill switch, mandate tiers, live gating and Telegram buttons are enforced outside the model for every engine. `dexterm ai probe --json` checks tool calling, context and decision formatting; a model without tools answers from the dossier dexterm fetches and says so. Paper autotrade on it: `dexterm autotrade run <strategy> --paper --engine ollama`. Headless: `dexterm ask "question"`, `dexterm ai agent "goal"`. Docs: https://dexterm.xyz/docs/ollama/' },
189
197
  { id: 'dev-history', title: 'Check if a coin\'s creator rugged before (dev history)', screen: 'token', tags: ['dev', 'deployer', 'creator', 'serial', 'rugger', 'rugged', 'history', 'launches'],
190
198
  tools: ['dev_history', 'get_dev_history'], feature: 'token-intel',
191
- body: 'The token screen\'s ON-CHAIN panel shows the creator\'s recorded track record (0.1.5): `Dev rugs (recorded)` (rugs out of labelled prior launches, with the sample n), `Dev launches seen`, `Dev sold its bag` (median minutes to the dev\'s exit) and `Dev linked` (funder or cluster from the wallet-intel scan). It comes from dexterm\'s own local history recorder (keyless creator links + code-only outcome labels), so it says `unknown` when there is no record; it is a risk flag from observed history, never a certificate. Alert on it with the rule field `devrugs`, e.g. `when devrugs >= 2 then alert(warn, "new coin from a wallet that rugged before") scope newpairs`. Agents and the analyst use the `dev_history` MCP tool.' },
199
+ body: 'The token screen\'s ON-CHAIN panel shows the creator\'s recorded track record (0.1.5): `Dev rugs` (rugs out of labelled prior launches, e.g. `2/3 · n=3 · rec 7d`), `Dev launches` (`n=3 · rec 2h · dev:jup`: which feed named the creator), `Dev sold bag` (median minutes to the dev\'s exit, `med 20m · n=3 · rec 1d`), `Dev linked` (funder or cluster from the wallet-intel scan, with the scan\'s age) and `Linked dev rugs` (rugs by other wallets in that cluster). Every value names its source (`rec` = the recorder, `scan` = the wallet-intel scan), its sample (n=) and the age of its newest datum. It comes from dexterm\'s own local history recorder (keyless creator links + code-only outcome labels), so it says `unknown` when there is no record; it is a risk flag from observed history, never a certificate. Alert on it with the rule field `devrugs`, e.g. `when devrugs >= 2 then alert(warn, "new coin from a wallet that rugged before") scope newpairs`. Agents and the analyst use the `dev_history` MCP tool.' },
192
200
  { id: 'configure-rpc-key', title: 'Configure a Helius / RPC key for holders', screen: 'all', tags: ['helius', 'rpc', 'key', 'holders', 'free', 'api', 'ranked'],
193
201
  feature: 'keyless',
194
202
  body: 'dexterm is free-forever and keyless by default. The one real keyless gap is the ranked top-holder list: add a free RPC key for it. Save a Helius key ONLY at `~/.dexterm/helius.key` (mode 600, never a repo or command line), or set `DEXTERM_RPC_URL` to any read-only RPC. `dexterm doctor` prints the exact command. Without a key the holders panel shows count + top-10% via Jupiter.' },
@@ -216,6 +224,34 @@ const TOPICS = [
216
224
  { id: 'backtest', title: 'Backtest the rug model or skills', screen: 'all', tags: ['backtest', 'eval', 'accuracy', 'model', 'metrics', 'history'],
217
225
  commands: ['backtest'], tools: ['rug_backtest'], feature: 'skill-backtest',
218
226
  body: '`dexterm backtest --subject heuristic|skills|larp|pack_verdicts` scores a subject against the recorder\'s outcome-labelled history and prints honest metrics (precision/recall, Brier vs base rate, AUC, calibration) with leakage checks. With no labelled outcomes it says so and prints no metrics rather than fabricating any.' },
227
+ { id: 'autotrade-strategies', title: 'Autotrade strategies on paper (dexterm autotrade)', screen: 'all', tags: ['autotrade', 'strategy', 'strategies', 'preset', 'presets', 'moonbag', 'scalp', 'swing', 'sweep', 'held-out'],
228
+ commands: ['autotrade'], feature: 'autotrade-strategies',
229
+ body: '`dexterm autotrade list|validate|new|import|remove|journal` manages strategy files in ~/.dexterm/strategies (one validated JSON file each, every change in an append-only journal); the presets scalp, swing, runner, moonbag, sample-dip-ladder and yolo (HIGH RISK, see the yolo entry) are read-only, copy one with `dexterm autotrade new <id> --from <preset>`. `dexterm autotrade backtest <id>` replays a strategy over your recorded history with modelled fills and always prints the limits of the data (`--every-candidate`, `--recall 5,10` for tail strategies); `dexterm autotrade sweep <id>` tunes on older coins and checks once on the newest 30% it never saw, with no gain wording unless both halves have 20+ trades and the held-out net is positive. Paper only: a strategy cannot hold a key, wallet or signer section, and a copy in mode live does not run (dexterm holds no key and places no live order). Not financial advice. Full docs: https://dexterm.xyz/docs/autotrade/' },
230
+ { id: 'autotrade-runner', title: 'The autotrade paper runner and candidate sessions (dexterm autotrade run)', screen: 'all', tags: ['autotrade', 'runner', 'run', 'candidate', 'session', 'sessions', 'agent', 'replay', 'ledger', 'runner.json'],
231
+ commands: ['autotrade'], feature: 'autotrade-runner',
232
+ body: '`dexterm autotrade run <id|file> --paper` runs one strategy on paper, headless, one runner per machine: the screener feeds it the same live data as the app (every 10 s, candidate and held coins every 5 s), and each coin that matches gets one session on your own Claude login with the full picture first, then only what changed. Your agent answers with a typed decision (enter, wait, skip, hold, exit, tighten, reprofile); every size is clamped by your strategy and the exits run on their own. At most 2 sessions at once, $0.50 per session and the day caps in ~/.dexterm/autotrade/runner.json (which Claude account, sessions and spend per day, a usage guard). Every step goes to ~/.dexterm/autotrade/runs/<run>.jsonl, hash-chained. `--replay FILE` paces a recorded tape instead of live data; `--stub` uses a scripted agent with no Claude cost. Paper only: a run never signs or touches a wallet, and there is no `--live` (dexterm holds no key and places no live order). Not financial advice. Full docs: https://dexterm.xyz/docs/autotrade/#the-runner-and-candidate-sessions' },
233
+ { id: 'live-trading', title: 'Live trading: dexterm holds no key; a Telegram trading bot of your choice trades', screen: 'all', tags: ['live', 'trading', 'real', 'money', 'telegram', 'bot', 'key', 'wallet', 'custody', 'signer', 'mainnet'],
234
+ commands: ['telegram', 'wallet', 'live'], feature: 'live-trading',
235
+ body: 'dexterm never holds a key and never signs or sends a transaction: there is no trading wallet, no signer and no live order in dexterm. Live trading happens in a Telegram trading bot of your choice, which holds its own wallet; you act in that bot. dexterm\'s part is the Telegram connector to your OWN bot (`dexterm telegram setup`): alerts, signals and run control for your paper runs. dexterm 0.1.7 does not place orders in a trading bot for you. Paper trading (the ticket, paper accounts, paper autotrade) is local. `dexterm wallet link` keeps a Phantom public key for display only. Not financial advice. Full docs: https://dexterm.xyz/docs/live-trading/' },
236
+ { id: 'live-yolo', title: 'The full-port yolo strategy on paper: replay and a paper run (HIGH RISK)', screen: 'all', tags: ['yolo', 'full', 'port', 'all-in', 'high', 'risk', 'preset', 'replay', 'paper'],
237
+ commands: ['autotrade'], feature: 'yolo-preset',
238
+ body: 'HIGH RISK, PAPER only; not financial advice. The `yolo` preset enters one young pair at a time on an early 5-minute push after the holder-safety gates (LP burned or locked, no mint or freeze authority, a LARP score of 49 or less checked live before a coin becomes a candidate, liquidity of $25K or more), takes the cost back at about 2x, lets the rest ride on a loose 50% trail, exits at once on a liquidity pull, a dev sell or dead volume, has a -50% stop and a 45-minute time stop, and never buys the same coin twice. On paper it caps an entry at 25% like every strategy. `dexterm autotrade yolo-replay yolo` measures every entry at full port over your recorded history (rugs, the loss spread, how often it zeroed the wallet); `dexterm autotrade run yolo --paper` runs it on paper (`--replay builtin:yolo-rehearsal --stub` for a short fixture run; next to other strategies, or on a shared paper account, through `autotrade.json` and `dexterm autotrade run --all --paper`). Stop: `dexterm autotrade stop`, /kill in Telegram, Ctrl-C. dexterm places no live order. Full docs: https://dexterm.xyz/docs/yolo/' },
239
+ { id: 'autotrade-stop', title: 'Stop, flatten or audit the autotrade paper runner (dexterm autotrade stop|flatten|audit)', screen: 'all', tags: ['autotrade', 'stop', 'kill', 'halt', 'flatten', 'sell', 'pause', 'panic', 'audit', 'verify', 'ledger', 'resume'],
240
+ commands: ['autotrade'], feature: 'autotrade-runner',
241
+ body: '`dexterm autotrade stop` is a soft stop of the paper runner: no new entries, every session closed, pending orders dropped, and the mechanical exits (stops, take-profits, trails, rug exits) keep running until nothing is held; then the runner ends. `dexterm autotrade flatten` stops it and sells every paper position at its next tick (a coin that cannot sell is retried every tick); it asks for y on a real terminal, or takes --yes. On the AUTOTRADE screen (`Q`): `!` stops, `p` pauses or resumes new entries, `f` then y flattens. A stop is final for that run. `dexterm wallet panic` is the harder switch: the runner reads it every step, a new run will not start while it is on, and only `dexterm wallet resume` on a real terminal lifts it. `dexterm autotrade audit --verify` recomputes the hash chain of every run file in ~/.dexterm/autotrade/runs/ and names the first edited, missing or reordered line. Paper only; your agent cannot stop, resume or flatten anything. Not financial advice. Full docs: https://dexterm.xyz/docs/autotrade/#stopping-it' },
242
+ { id: 'autotrade-parallel', title: 'Run several autotrade strategies at once on paper (dexterm autotrade run --all)', screen: 'all', tags: ['autotrade', 'parallel', 'several', 'multiple', 'strategies', 'compare', 'side', 'forward', 'test', 'bankroll', 'fleet', 'autotrade.json'],
243
+ commands: ['autotrade'], tools: ['autotrade_parallel_list', 'autotrade_parallel_compare', 'autotrade_parallel_start', 'autotrade_parallel_stop'], feature: 'autotrade-parallel',
244
+ body: '`dexterm autotrade run --all --paper` runs every strategy listed in ~/.dexterm/autotrade/autotrade.json at the same time on one data feed, to forward-test several ideas side by side. Each entry has an `id`, a `preset` (a shipped preset or your own strategy) or an absolute `file`, a `bankroll` in USD or SOL, optional `caps` that can only tighten it, and `enabled`. Each strategy gets its own paper book, run file, loss limits and breaker, sessions and model spend budget; a breaker or a stop on one never stops another. The screener fetches once for all of them, and the `global` limits (sessions open at once, model spend and sessions per day, one check of how busy the computer is) count across all of them. `dexterm autotrade status --all` and the runner view on the AUTOTRADE screen (`Q`) compare them: P/L, win rate with the closed count, rug exits and exposure, missed runners, spend per entry. `dexterm autotrade stop|flatten|pause|resume` act on every strategy; add `--strategy ID` to act on one, and `dexterm autotrade start ID` starts a listed one that is not running. An MCP agent can list and compare them and start or stop one listed strategy, never add one or change a size or a cap. Paper only: live is refused. Not financial advice. Full docs: https://dexterm.xyz/docs/autotrade/#several-strategies-at-once' },
245
+ { id: 'autotrade-telegram', title: 'Your own Telegram bot for the autotrade runner: notify, control, one-tap approvals (dexterm telegram)', screen: 'all', tags: ['telegram', 'bot', 'phone', 'mobile', 'notify', 'notifications', 'approve', 'approval', 'approvals', 'pair', 'pairing', 'kill', 'pause', 'remote', 'botfather'],
246
+ commands: ['telegram'], feature: 'autotrade-telegram',
247
+ body: 'Create a bot with @BotFather, then run `dexterm telegram setup`: paste the token at the hidden prompt (never as an argument), dexterm checks it and keeps it in your keychain (or the system keyring, or a 0600 file), then shows a 6-digit code; send `/pair <code>` to your bot from your own private chat and confirm the account it shows (@username and id) with `y` on your computer. Pairing is refused while a webhook or another program polls the bot. Only that account in that chat is answered. `dexterm autotrade run <id> --paper` then starts the bot by itself (`--no-telegram` keeps it off): entries, exits, PnL cards, halts and a daily summary reach your phone; `/status`, `/positions`, `/pause`, `/resume` (a pause only), `/kill`, `/flatten` and `/use` (each after a confirm button, `/use` only to an equal-or-tighter strategy; a change it cannot rank counts as looser) and `/approvals on` work from chat, which can make things safer and never less safe. With `entry.decide: "agent+approve"` or approvals on, every entry is a card with [Approve] [Half size] [Skip]: only a button approves, once, for that proposal, your account and your private chat; the price and your limits are checked again at the tap; no answer is a skip. Typed messages are never trades. `dexterm telegram status|test|audit --verify|revoke`. Nothing is hosted; paper only; never send keys or seed phrases in chat. Not financial advice. Full docs: https://dexterm.xyz/docs/telegram/' },
248
+ { id: 'autotrade-chat', title: 'Change an autotrade strategy by chat (paper)', screen: 'autotrade', tags: ['autotrade', 'strategy', 'chat', 'analyst', 'proposal', 'tune', 'change', 'diff', 'looser', 'less', 'safe'],
249
+ actions: [{ action: 'analyst.toggle' }, { action: 'autotrade.proposal', screen: 'autotrade' }],
250
+ tools: ['strategy_list', 'strategy_get', 'strategy_validate', 'strategy_propose_edit', 'strategy_propose_new', 'strategy_backtest', 'autotrade_status'], feature: 'autotrade-chat',
251
+ body: 'Ask the analyst to change one of your strategies ("make my swing exit faster"). It can only PROPOSE: the change arrives as a card on the AUTOTRADE screen (`Q`) with the field lines that change, the validation result and TIGHTER, NEUTRAL or LOOSER. `o` opens the card, `y` applies it as a new version (journaled with who proposed it), `n` dismisses it. When any risk number gets less safe (bigger size or exposure, more loss, a stop or safety gate removed) the edit is LOOSER and needs a second `y` on the less-safe popup. The mode, the book, the daily session budget and the exit-liquidity floor are yours only: the analyst cannot change them. It can backtest a proposal next to the current version on your recorded history (up to 14 days, read-only). Paper only.' },
252
+ { id: 'trade-ledger', title: 'See every trade in one ledger: win rate, profiles, exit reasons, strategy versions (dexterm ledger)', screen: 'all', tags: ['ledger', 'journal', 'trades', 'history', 'results', 'stats', 'win', 'rate', 'drawdown', 'profile', 'exit', 'reason', 'compare', 'export', 'csv', 'equity', 'mfe', 'mae'],
253
+ commands: ['ledger'], tools: ['ledger_trades', 'ledger_positions', 'ledger_summary', 'ledger_equity', 'ledger_compare', 'candidate_dossier', 'outcomes_lookup', 'trading_status', 'telegram_status', 'backtest_requests'], feature: 'trade-ledger',
254
+ body: '`dexterm ledger trades` lists every round trip dexterm booked, from the paper ticket, the agent paper desk and autotrade runs, newest first: strategy version, the exit profile and entry reason it was opened with (marked * when not declared with the fill), the exit reason, size and % of book, entry and exit market cap, P/L, hold and MFE/MAE. `positions` shows the open ones. `summary` gives the win rate with its 95% interval, P/L, profit factor, drawdown and rug rate by profile, exit reason, strategy, source and mode; `equity` the realized equity curve; `compare` strategy versions side by side (for strategies run in parallel); `export csv|json|parquet-lite [--out FILE]`; `card <tradeId>` a PnL card from a row. Filters: --source, --mode paper|devnet|live, --strategy id[@version], --profile, --exit, --mint, --run, --days, --status. Reads never write; `dexterm ledger sync` appends to ~/.dexterm/ledger/trades.jsonl (sha256-chained) and `dexterm ledger verify` names the first edited line. Agents read the same rows with the read-only ledger_* tools; `trading_status` and `telegram_status` show settings and state, never a key, address, exact balance, bot token or chat id. A backtest an agent asks for (backtest_request) only runs when you run it: `dexterm autotrade requests`. PAPER rows are simulated; filter by --mode before comparing. Not financial advice. Full docs: https://dexterm.xyz/docs/paper-trading/#the-trade-ledger' },
219
255
  { id: 'coin-images', title: 'Turn coin images on or off', screen: 'all', tags: ['images', 'image', 'pictures', 'icons', 'logos', 'off'],
220
256
  flags: ['--no-images'], feature: 'coin-images',
221
257
  body: 'Coin pictures render as real pixels in image-capable terminals (kitty/iTerm2/sixel) and as block art everywhere else. Turn them off with `--no-images` (or `DEXTERM_IMAGES=0`, or `enabled:false` in `~/.dexterm/images.json`). `dexterm doctor` has a Coin images line that says which path you get.' },
@@ -233,8 +269,8 @@ const TOPICS = [
233
269
  commands: ['agent'], feature: 'mcp',
234
270
  body: '`dexterm agent add|list|rotate|remove|tier|pause|resume|kick|audit|packs` manages your bring-your-own-agent registry and the loopback bus; `dexterm agent serve` runs a standalone bus on fixtures and `connect` attaches one. Every agent is untrusted and read-only: it can never sign, arm, raise a cap, touch keys or change network settings.' },
235
271
  { id: 'spectate-an-agent', title: 'Watch an agent drive dexterm (dexterm spectate)', screen: 'all', tags: ['spectate', 'spectator', 'watch', 'agent', 'cook', 'observe', 'replay', 'stream', 'record', 'mcp', 'follow'],
236
- commands: ['spectate'], flags: ['--replay', '--spectate-mcp'], feature: 'spectator',
237
- body: 'Watch an agent work. For an agent on the loopback bus, `dexterm agent serve --spectator-popup` opens the AGENT ACTIVITY window, `--spectate` starts the read-only, token-gated, loopback stream, and `--record FILE` saves a redacted session. For an agent connected over MCP (`dexterm mcp install`), run the app with `dexterm --spectate-mcp`: the running terminal then follows the agent — a navigation call moves the screen, a status line shows `agent <name>: opened <coin>`, ctrl+p pauses, ctrl+k stops and any key you press takes control. `dexterm spectate --replay FILE` replays a saved session step by step and `dexterm spectate --info` shows the live stream endpoint. Every shared copy is redacted — a tool name, refusal, agent line or navigation can never leak a wallet or key — and a spectator can only watch, never act. Full docs: https://dexterm.xyz/docs/spectator/' },
272
+ commands: ['spectate'], flags: ['--replay', '--spectate-mcp', '--spectate-thoughts'], feature: 'spectator',
273
+ body: 'Watch an agent work. For an agent on the loopback bus, `dexterm agent serve --spectator-popup` opens the AGENT ACTIVITY window, `--spectate` starts the read-only, token-gated, loopback stream, and `--record FILE` saves a redacted session. For an agent connected over MCP (`dexterm mcp install`), run the app with `dexterm --spectate-mcp`: the running terminal follows the agent and an agent dock appears under the screen — a phase rail (SCANNING > VETTING > SIZING > EXECUTING > HOLDING > EXITING) with a heartbeat, the call timeline with result chips, the rows it scans glow and a cursor marks the coin it opens, a vetting card fills its checks and LARP evidence, and a PAPER trade shows its ticket, the fill, a live position with the mark PnL and a result card. `--spectate-thoughts FILE` streams the agent\'s own words into a thought ribbon from a JSONL file it writes (for example `claude -p --output-format stream-json`); display only. PAPER is always on screen; ctrl+p pauses, ctrl+k kills (a hard stop) and any key you press takes control; calm mode drops the motion. While the agent is active, the token screen\'s analyst panel is its BRAIN VIEW: the reasoning stream with phase tags (or dexterm\'s narration when there is no thoughts feed), the vetting checklist with the app\'s numbers and pass/warn/fail/pending, a data strip, the PAPER plan and position, and the session\'s decision log with a simulated scoreboard. While it holds a PAPER position, a PnL chip shows coin, PnL, entry to mark, peak, drawdown, time held and the take-profit it said, on every terminal screen (in the dock, or on the band under the header on terminals under 24 rows) and on the chart popup; display only. `dexterm spectate --replay FILE` replays a saved session step by step and `dexterm spectate --info` shows the live stream endpoint. Every shared copy is redacted — a tool name, refusal, agent line or navigation can never leak a wallet or key — and a spectator can only watch, never act. Full docs: https://dexterm.xyz/docs/spectator/' },
238
274
  { id: 'recorder-history', title: 'Work with the history recorder (dexterm recorder)', screen: 'all', tags: ['recorder', 'record', 'history', 'stats', 'label', 'prune', 'outcomes', 'database', 'session', 'capture', 'data'],
239
275
  commands: ['recorder'], flags: ['--record', '--no-recorder'], feature: 'recorder',
240
276
  body: '`dexterm recorder stats|label|prune|export` works with the local history recorder\'s tables (the outcome-labelled data the rug model and backtests learn from). No network. Recording is on by default; `--no-recorder` disables it for a run and `--record FILE` captures a data session to a file for replay.' },
@@ -259,15 +295,15 @@ const TOPICS = [
259
295
  { id: 'share-packs', title: 'Share or install packs (dexterm pack)', screen: 'all', tags: ['pack', 'packs', 'share', 'install', 'export', 'sign', 'trust', 'lock', 'bundle'],
260
296
  commands: ['pack'], feature: 'packs',
261
297
  body: '`dexterm pack list|verify|add|remove|export|lock|sign|trust|signers|keymap|widget` shares themes, keymaps, rules and widgets as plain files with a sha256 lock and an optional ssh signature. A pack never runs code: widgets land disabled, unsigned rules load disabled, and a keymap merges only on the explicit command.' },
262
- { id: 'link-a-wallet', title: 'Link a wallet for trading (dexterm wallet)', screen: 'all', tags: ['wallet', 'link', 'unlink', 'phantom', 'connect', 'pubkey', 'caps', 'trade'],
263
- commands: ['wallet'], flags: ['--mainnet', '--max-usd', '--daily-usd', '--max-sol-out', '--max-slippage-bps', '--trade-rpc', '--no-live'], feature: 'trading',
264
- body: '`dexterm wallet link|unlink|status` links a Phantom wallet through a loopback bridge — your keys NEVER enter dexterm, only the public key is stored — and shows the link and the signer-side trade caps. dexterm is non-custodial: it builds and simulates transactions, your own wallet signs. The signer-side caps (`--max-usd`, `--daily-usd`, `--max-sol-out`, `--max-slippage-bps`) and the RPC (`--trade-rpc`) bound every trade and live on the signer; `--mainnet` opts in to mainnet and `--no-live` keeps it paper-only. The analyst can never link, unlink, sign, arm or change a cap.' },
298
+ { id: 'link-a-wallet', title: 'Link a wallet to show its public key (dexterm wallet)', screen: 'all', tags: ['wallet', 'link', 'unlink', 'phantom', 'connect', 'pubkey', 'panic', 'resume'],
299
+ commands: ['wallet'], flags: ['--no-live'], feature: 'trading',
300
+ body: '`dexterm wallet link|unlink|status` links a Phantom wallet through a loopback bridge (Phantom signs a MESSAGE, never a transaction): your keys NEVER enter dexterm, only the public key is stored, for display. dexterm holds no key and never signs or sends a transaction; trading in dexterm is paper, and live trading happens in the Telegram trading bot of your choice. `dexterm wallet panic` halts autotrade runs and the paper agent desk at once; only `dexterm wallet resume`, a keypress on a real terminal, clears it. `--no-live` (0.1.6) is accepted and changes nothing. The analyst can never link, unlink or resume.' },
265
301
  { id: 'order-plans', title: 'Set conditional order plans (dexterm plan)', screen: 'all', tags: ['plan', 'plans', 'order', 'conditional', 'take-profit', 'stop', 'trigger', 'arm'],
266
302
  commands: ['plan'], feature: 'order-plans',
267
- body: '`dexterm plan list|add|remove|arm|disarm` sets conditional order plans (e.g. take-profit / stop levels). Voice and agents can only PROPOSE a plan; ARMING one needs your physical keypress, and the caps and panic-stop stay signer-side. Nothing here lets a model sign or raise a cap.' },
303
+ body: '`dexterm plan list|add|remove|arm|disarm` sets conditional order plans (e.g. take-profit / stop levels). Voice and agents can only PROPOSE a plan; ARMING one needs your physical keypress, and plans fill on PAPER (dexterm places no live order). Nothing here lets a model sign or raise a cap.' },
268
304
  { id: 'standing-mandates', title: 'Set a standing mandate (dexterm mandate)', screen: 'all', tags: ['mandate', 'mandates', 'standing', 'rule', 'budget', 'auto', 'arm', 'cap'],
269
305
  commands: ['mandate'], feature: 'order-plans',
270
- body: '`dexterm mandate list|add|remove|arm|disarm` sets a standing mandate — a longer-lived conditional rule bounded by a budget. As with plans, a model may only PROPOSE; arming needs your physical keypress and the signer-side caps bound it. The analyst can never arm a mandate or change its caps.' },
306
+ body: '`dexterm mandate list|add|remove|arm|disarm` sets a standing mandate — a longer-lived conditional rule bounded by a budget. As with plans, a model may only PROPOSE; arming needs your physical keypress and its caps bound it; fills are PAPER. The analyst can never arm a mandate or change its caps.' },
271
307
  { id: 'follow-a-wallet', title: 'Copy / follow a wallet (dexterm follow)', screen: 'all', tags: ['follow', 'copy', 'mirror', 'wallet', 'trader', 'track', 'unfollow', 'list'],
272
308
  commands: ['follow'], feature: 'copy-trading',
273
309
  body: '`dexterm follow list|add|remove` is the copy-trading follow list: local, self-directed and read-only. When a followed wallet trades, dexterm can surface a one-key MIRROR TICKET you confirm yourself — it never auto-trades, never signs, and the analyst can never add a follow or confirm a mirror.' },
@@ -0,0 +1,57 @@
1
+ // `dexterm autotrade audit [<run>|--last] [--verify]` (task-1509 AT-7, AUTOTRADE-SPEC §6.4). PAPER ONLY. Read-only.
2
+ //
3
+ // Lists the run ledgers under $DEXTERM_HOME/autotrade/runs/, and with --verify recomputes each hash chain (every line's
4
+ // hash covers the previous hash and its own content) and checks it against the run's summary, so an edited, added,
5
+ // dropped, reordered or cut-off line is named with its event number. Exit 1 when any checked run is broken.
6
+ import { dextermHome } from '../../../custom/src/index.js';
7
+ import { auditRun, listRunIds } from '../../../autotrade/src/index.js';
8
+ import { parseArgs } from "./strategies.js";
9
+ export const AUDIT_USAGE = 'dexterm autotrade audit [<run-id>|--last] [--verify] [--json]';
10
+ function line(a, verify) {
11
+ const strat = a.strategy ? `${a.strategy.id} v${a.strategy.version}` : '?';
12
+ const state = a.running ? 'running' : a.ended ? 'ended' : 'no run_end (crashed or cut short)';
13
+ if (!verify)
14
+ return ` ${a.runId} ${strat} ${a.events} events ${state}`;
15
+ if (a.ok)
16
+ return `✓ ${a.runId} ${strat} ${a.events} events head ${a.head} ${state}${a.summary ? '' : ' (no summary)'}`;
17
+ return `✗ ${a.runId} ${strat} broken at event ${a.brokenAt}: ${a.error}`;
18
+ }
19
+ export async function auditCmd(argv, io) {
20
+ const { pos, opts } = parseArgs(argv, ['verify', 'json', 'last']);
21
+ if (pos.length > 1) {
22
+ io.stderr.write(`usage: ${AUDIT_USAGE}\n`);
23
+ return 2;
24
+ }
25
+ const home = dextermHome(io.env);
26
+ const all = listRunIds(home);
27
+ let ids = all;
28
+ if (pos[0]) {
29
+ const want = pos[0].replace(/\.jsonl$/, '');
30
+ if (!all.includes(want)) {
31
+ io.stderr.write(`dexterm autotrade audit: no run ledger ${JSON.stringify(want)} under autotrade/runs/\n`);
32
+ return 1;
33
+ }
34
+ ids = [want];
35
+ }
36
+ else if (opts.last)
37
+ ids = all.slice(-1);
38
+ const verify = !!opts.verify;
39
+ const audits = ids.map((id) => auditRun(home, id));
40
+ const broken = verify ? audits.filter((a) => !a.ok) : [];
41
+ if (opts.json) {
42
+ io.stdout.write(`${JSON.stringify({ verified: verify, runs: audits, broken: broken.length }, null, 2)}\n`);
43
+ return broken.length ? 1 : 0;
44
+ }
45
+ if (!audits.length) {
46
+ io.stdout.write('no autotrade runs yet (ledgers live in autotrade/runs/ under your dexterm home)\n');
47
+ return 0;
48
+ }
49
+ io.stdout.write(`${verify ? 'verifying' : 'runs'} (${audits.length}) · ledgers in autotrade/runs/ · paper and live runs\n`);
50
+ for (const a of audits)
51
+ io.stdout.write(`${line(a, verify)}\n`);
52
+ if (verify)
53
+ io.stdout.write(broken.length ? `${broken.length} broken ledger${broken.length === 1 ? '' : 's'}: the lines from that event on cannot be trusted\n` : 'every chain verifies\n');
54
+ else
55
+ io.stdout.write('add --verify to recompute the hash chains\n');
56
+ return broken.length ? 1 : 0;
57
+ }
@@ -0,0 +1,199 @@
1
+ // `dexterm autotrade backtest|sweep|extract` (task-1503 AT-1, AUTOTRADE-SPEC §3/§3a). PAPER, recorded data only:
2
+ // the recorder DB is opened read-only, fills are modelled, no network, no model, no keys. Mechanical entries
3
+ // (`auto`): the agent's judgement is what the runner card measures, so a backtest never spawns a session.
4
+ import { defaultDbPath } from '../../../data/src/index.js';
5
+ import { openHistoryReadOnly } from '../../../recorder/src/index.js';
6
+ import { backtest, everyCandidate, fmtIssue, loadTape, renderRecall, renderReport, renderSweep, renderYoloReplay, builtinTapePath, runnerRecall, saveTape, sweep, tapeFromDb, tapeFromDoc, yoloReplay, } from '../../../autotrade/src/index.js';
7
+ import { parseArgs, resolveStrategyArg, storeFor } from "./strategies.js";
8
+ const BOOL = ['json', 'every-candidate'];
9
+ function strategyFrom(pos, opts, io, usage, anyMode = false) {
10
+ const arg = typeof opts.strategy === 'string' ? opts.strategy : pos[0];
11
+ const r = resolveStrategyArg(arg, io);
12
+ if (!r) {
13
+ io.stderr.write(`usage: ${usage}\n`);
14
+ return null;
15
+ }
16
+ for (const w of r.warnings)
17
+ io.stderr.write(`warning ${fmtIssue(w)}\n`);
18
+ if (!r.ok) {
19
+ for (const e of r.errors)
20
+ io.stderr.write(`error ${fmtIssue(e)}\n`);
21
+ return null;
22
+ }
23
+ if (r.strategy.mode !== 'paper' && !anyMode) {
24
+ io.stderr.write(`dexterm autotrade: ${r.strategy.id} is mode "${r.strategy.mode}": autotrade runs paper only\n`);
25
+ return null;
26
+ }
27
+ return r.strategy;
28
+ }
29
+ function numOpt(opts, k, dflt) {
30
+ const v = opts[k];
31
+ const n = typeof v === 'string' ? Number(v) : NaN;
32
+ return Number.isFinite(n) ? n : dflt;
33
+ }
34
+ /**
35
+ * `dexterm autotrade yolo-replay <id|file>` (task-1532): a full-port paper replay of a strategy (a live-mode copy too:
36
+ * the replay always runs a paper copy) over recorded history, with the rugs, the loss spread and how often a run of
37
+ * entries zeroed the wallet. Read-only: recorded data, modelled fills, no network, no model, no keys.
38
+ */
39
+ export async function yoloReplayCmd(argv, io) {
40
+ const { pos, opts } = parseArgs(argv, ['json']);
41
+ const usage = 'dexterm autotrade yolo-replay <id|file> [--tape FILE | --db PATH [--days N | --since T] [--until T]] [--seed N] [--json]';
42
+ const s = strategyFrom(pos, opts, io, usage, true);
43
+ if (!s)
44
+ return 2;
45
+ const tape = tapeFrom(opts, io);
46
+ if (!tape)
47
+ return 2;
48
+ const r = await yoloReplay(s, tape, { seed: numOpt(opts, 'seed', 1) });
49
+ io.stdout.write(opts.json ? JSON.stringify(r, null, 2) + '\n' : renderYoloReplay(r) + '\n');
50
+ return 0;
51
+ }
52
+ /** `--since/--until`: epoch ms or an ISO time (pins a backtest to the exact tape window of an earlier run). */
53
+ function timeOpt(v) {
54
+ if (typeof v !== 'string')
55
+ return undefined;
56
+ const n = /^\d+$/.test(v) ? Number(v) : Date.parse(v);
57
+ return Number.isFinite(n) ? n : undefined;
58
+ }
59
+ /** The recorder DB, read-only; null when it is missing, in memory, or not a recorder DB. */
60
+ function openDb(path) {
61
+ if (path === ':memory:')
62
+ return null;
63
+ try {
64
+ return openHistoryReadOnly(path);
65
+ }
66
+ catch {
67
+ return null;
68
+ }
69
+ }
70
+ /** A tape from --tape FILE, else read-only from the recorder DB (--db, DEXTERM_DB_PATH, the default path). */
71
+ export function tapeFrom(opts, io) {
72
+ if (typeof opts.tape === 'string') {
73
+ try {
74
+ return loadTape(builtinTapePath(opts.tape));
75
+ }
76
+ catch (e) {
77
+ io.stderr.write(`dexterm autotrade: ${e.message}\n`);
78
+ return null;
79
+ }
80
+ }
81
+ const path = typeof opts.db === 'string' ? opts.db : (io.env.DEXTERM_DB_PATH || defaultDbPath(io.env));
82
+ const db = openDb(path);
83
+ if (!db) {
84
+ io.stderr.write(`dexterm autotrade: no recorded history in ${path} (run the app with the recorder on first, or pass --tape FILE)\n`);
85
+ return null;
86
+ }
87
+ try {
88
+ const days = numOpt(opts, 'days', 0);
89
+ return tapeFromDoc(tapeFromDb(db, {
90
+ since: timeOpt(opts.since) ?? (days > 0 ? Date.now() - days * 86_400_000 : undefined),
91
+ until: timeOpt(opts.until),
92
+ minPeakLiqUsd: numOpt(opts, 'min-peak-liq', 20_000),
93
+ spanHours: numOpt(opts, 'span-hours', 80),
94
+ }));
95
+ }
96
+ finally {
97
+ db.close();
98
+ }
99
+ }
100
+ export async function backtestCmd(argv, io) {
101
+ const { pos, opts } = parseArgs(argv, BOOL);
102
+ const usage = 'dexterm autotrade backtest <id|file> [--tape FILE | --db PATH] [--days N | --since T] [--until T] [--every-candidate [--unit-usd 20]] [--recall 5,10] [--json]';
103
+ const s0 = strategyFrom(pos, opts, io, usage);
104
+ if (!s0)
105
+ return 2;
106
+ const tape = tapeFrom(opts, io);
107
+ if (!tape)
108
+ return 2;
109
+ const s = opts['every-candidate'] ? everyCandidate(s0, numOpt(opts, 'unit-usd', 20)) : s0;
110
+ const { report, run } = await backtest(s, tape);
111
+ const recallAt = typeof opts.recall === 'string' ? opts.recall.split(',').map(Number).filter((x) => Number.isFinite(x) && x > 1) : [];
112
+ const recall = recallAt.length ? runnerRecall(s, tape, run, recallAt) : null;
113
+ if (!opts['every-candidate']) {
114
+ try {
115
+ storeFor(io).recordBacktest({ hash: s.hash, t: Date.now(), trades: report.trades, netUsd: report.netUsd, netPct: report.netPct, maxDrawdownPct: report.maxDrawdownPct, tape: `${report.tape.mints} coins ${report.tape.from ?? ''}..${report.tape.to ?? ''}` });
116
+ }
117
+ catch { /* the line is a convenience for `list`; never fail a backtest on it */ }
118
+ }
119
+ if (opts.json) {
120
+ io.stdout.write(JSON.stringify(recall ? { ...report, recall } : report, null, 2) + '\n');
121
+ return 0;
122
+ }
123
+ io.stdout.write(renderReport(report) + '\n');
124
+ if (opts['every-candidate'])
125
+ io.stdout.write(` every-candidate copy of ${s0.id}: each candidate entered at $${numOpt(opts, 'unit-usd', 20)} with the book caps lifted (an evaluation, not a strategy to run)\n`);
126
+ if (recall)
127
+ io.stdout.write(renderRecall(recall, s) + '\n');
128
+ io.stdout.write(' Paper only, recorded data, not financial advice. A backtest is not a forecast.\n');
129
+ return 0;
130
+ }
131
+ export async function sweepCmd(argv, io) {
132
+ const { pos, opts } = parseArgs(argv, BOOL);
133
+ const usage = 'dexterm autotrade sweep <id|file> [--tape FILE | --db PATH] [--grid JSON] [--mode grid|random] [--max N] [--seed N] [--test-frac 0.3] [--json]';
134
+ const s0 = strategyFrom(pos, opts, io, usage);
135
+ if (!s0)
136
+ return 2;
137
+ let grid;
138
+ try {
139
+ grid = typeof opts.grid === 'string' ? JSON.parse(opts.grid) : defaultGrid(s0);
140
+ if (!grid || typeof grid !== 'object' || !Object.values(grid).every((v) => Array.isArray(v) && v.every((x) => typeof x === 'number')))
141
+ throw new Error('the grid maps parameter paths to arrays of numbers');
142
+ }
143
+ catch (e) {
144
+ io.stderr.write(`dexterm autotrade: --grid: ${e.message}\n`);
145
+ return 2;
146
+ }
147
+ const tape = tapeFrom(opts, io);
148
+ if (!tape)
149
+ return 2;
150
+ const s = opts['every-candidate'] ? everyCandidate(s0, numOpt(opts, 'unit-usd', 20)) : s0;
151
+ let r;
152
+ try {
153
+ r = await sweep(s, tape, grid, { mode: opts.mode === 'random' ? 'random' : 'grid', max: numOpt(opts, 'max', 64), seed: numOpt(opts, 'seed', 1), testFrac: numOpt(opts, 'test-frac', 0.3) });
154
+ }
155
+ catch (e) {
156
+ io.stderr.write(`dexterm autotrade: ${e.message}\n`);
157
+ return 2;
158
+ }
159
+ io.stdout.write(opts.json ? JSON.stringify(r, null, 2) + '\n' : renderSweep(r) + '\n Paper only, recorded data, not financial advice.\n');
160
+ return 0;
161
+ }
162
+ /** A small default grid on the default exit profile's own knobs (only the ones the profile has). */
163
+ export function defaultGrid(s) {
164
+ const p = s.exits.profiles[s.exits.default];
165
+ const g = {};
166
+ if (p.trailingStop)
167
+ g['profile.trailingStop.trailPct'] = [15, 25, 35];
168
+ if (p.tpLadder.length)
169
+ g['profile.tpLadder.0.atPct'] = [30, 50, 80];
170
+ if (p.costRecovery)
171
+ g['profile.costRecovery.atPct'] = [60, 100, 150];
172
+ if (p.bagTrail)
173
+ g['profile.bagTrail.trailPct'] = [35, 55, 75];
174
+ if (s.sizing.mode === 'pct' && s.sizing.pct !== undefined)
175
+ g['sizing.pct'] = [s.sizing.pct / 2, s.sizing.pct].map((x) => Math.round(x * 10) / 10);
176
+ return g;
177
+ }
178
+ export function extractCmd(argv, io) {
179
+ const { opts } = parseArgs(argv);
180
+ if (typeof opts.out !== 'string') {
181
+ io.stderr.write('usage: dexterm autotrade extract --out FILE [--db PATH] [--max-mints N] [--min-peak-liq USD] [--span-hours H]\n');
182
+ return 2;
183
+ }
184
+ const path = typeof opts.db === 'string' ? opts.db : (io.env.DEXTERM_DB_PATH || defaultDbPath(io.env));
185
+ const db = openDb(path);
186
+ if (!db) {
187
+ io.stderr.write(`dexterm autotrade: no recorded history in ${path}\n`);
188
+ return 2;
189
+ }
190
+ try {
191
+ const doc = tapeFromDb(db, { maxMints: typeof opts['max-mints'] === 'string' ? Number(opts['max-mints']) : undefined, minPeakLiqUsd: numOpt(opts, 'min-peak-liq', 20_000), spanHours: numOpt(opts, 'span-hours', 80) });
192
+ saveTape(opts.out, doc);
193
+ io.stdout.write(`wrote ${opts.out}: ${doc.mints.length} coins, ${doc.mints.reduce((a, m) => a + m.rows.length, 0)} rows (recorded market data only)\n`);
194
+ return 0;
195
+ }
196
+ finally {
197
+ db.close();
198
+ }
199
+ }
@@ -0,0 +1,64 @@
1
+ // `dexterm autotrade flatten` (task-1509 AT-7, AUTOTRADE-SPEC §6.3). PAPER ONLY.
2
+ //
3
+ // A stop (no new entries, sessions closed, orders dropped), then every paper position sells at its next tick; one
4
+ // that cannot sell (a pulled pool) stays stuck and is retried every tick. The runner ends once nothing is held. It
5
+ // asks for a y keypress on a real terminal first, or takes `--yes` (selling only lowers risk; nothing here can buy,
6
+ // arm a mandate or sign). Nothing here touches a wallet, a key or the signer.
7
+ import { dextermHome } from '../../../custom/src/index.js';
8
+ import { activeRunner } from '../../../autotrade/src/index.js';
9
+ import { parseArgs } from "./strategies.js";
10
+ import { sendControl, waitArg } from "./stop.js";
11
+ export const FLATTEN_USAGE = 'dexterm autotrade flatten [--strategy ID] [--yes] [--wait SEC] [--json]';
12
+ export async function flattenCmd(argv, io, over = {}) {
13
+ const { pos, opts } = parseArgs(argv, ['json', 'yes']);
14
+ if (pos.length) {
15
+ io.stderr.write(`usage: ${FLATTEN_USAGE}\n`);
16
+ return 2;
17
+ }
18
+ const home = dextermHome(io.env);
19
+ const member = typeof opts.strategy === 'string' ? opts.strategy : null;
20
+ const r = activeRunner(home);
21
+ if (!r) {
22
+ if (opts.json)
23
+ io.stdout.write(`${JSON.stringify({ requested: false, runId: null, why: 'no autotrade runner is running' })}\n`);
24
+ else
25
+ io.stdout.write('no autotrade runner is running; nothing to flatten.\n');
26
+ return 0;
27
+ }
28
+ if (!opts.yes) {
29
+ const stdin = io.stdin;
30
+ if (!stdin || stdin.isTTY !== true) {
31
+ io.stderr.write('dexterm autotrade flatten: confirm with y on a real terminal, or pass --yes\n');
32
+ return 2;
33
+ }
34
+ io.stdout.write(member ? `flatten strategy ${member} only: stop it, then sell its paper positions at their next tick (the other strategies keep running)? y to confirm, any other key cancels… `
35
+ : `flatten run ${r.runId}: stop, then sell every paper position at its next tick (${r.positions} open)? y to confirm, any other key cancels… `);
36
+ const { ttyKeypress } = await import("../wallet-cmd.js");
37
+ const key = await ttyKeypress(stdin, over.keypressTimeoutMs ?? 30_000);
38
+ io.stdout.write('\n');
39
+ if (key !== 'y' && key !== 'Y') {
40
+ io.stdout.write('flatten cancelled; nothing was sold\n');
41
+ return 1;
42
+ }
43
+ }
44
+ // task-1529: one strategy of a parallel run; the others keep running.
45
+ if (member)
46
+ return (await import("./strategy-control.js")).memberStopCmd(io, member, 'flatten', opts);
47
+ const res = await sendControl(io, 'flatten', waitArg(opts.wait), r);
48
+ if ('error' in res) {
49
+ io.stderr.write(`dexterm autotrade flatten: ${res.error}\n`);
50
+ return 1;
51
+ }
52
+ if (opts.json) {
53
+ io.stdout.write(`${JSON.stringify(res)}\n`);
54
+ return 0;
55
+ }
56
+ io.stdout.write(`flatten ${res.already ? 'was already requested' : 'requested'} for run ${r.runId} (pid ${r.pid})\n`);
57
+ if (!res.acknowledged)
58
+ io.stdout.write('the runner has not confirmed yet: it reads the request on its next tick. Watch the Q screen, or run this again.\n');
59
+ else if (res.ended)
60
+ io.stdout.write('✓ flat: the runner sold what it held and stopped\n');
61
+ else
62
+ io.stdout.write(`✓ flattening: no new entries, sessions closed; ${res.positions} paper position${res.positions === 1 ? '' : 's'} sell${res.positions === 1 ? 's' : ''} at the next tick (a stuck one is retried every tick)\n`);
63
+ return 0;
64
+ }