@armanckeser/downstream 0.0.0-stage → 0.1.0

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 (367) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -2
  3. package/SKILL.md +150 -0
  4. package/bin/downstream.mjs +19 -0
  5. package/dist/cli/downstream.js +543 -0
  6. package/dist/domain/agent.js +3 -0
  7. package/dist/domain/approval.js +190 -0
  8. package/dist/domain/delivery.js +21 -0
  9. package/dist/domain/home.js +1 -0
  10. package/dist/domain/inbox.js +245 -0
  11. package/dist/domain/model.js +180 -0
  12. package/dist/domain/next-move.js +34 -0
  13. package/dist/domain/pr-detail.js +45 -0
  14. package/dist/server/actions.js +564 -0
  15. package/dist/server/agent-host.js +230 -0
  16. package/dist/server/analyze/git.js +161 -0
  17. package/dist/server/analyze/graph.js +403 -0
  18. package/dist/server/analyze/py-graph.js +141 -0
  19. package/dist/server/analyze/py.js +346 -0
  20. package/dist/server/analyze/ts-decls.js +299 -0
  21. package/dist/server/analyze/ts-project.js +212 -0
  22. package/dist/server/gh.js +51 -0
  23. package/dist/server/github.js +264 -0
  24. package/dist/server/home-store.js +127 -0
  25. package/dist/server/home.js +325 -0
  26. package/dist/server/install.js +12 -0
  27. package/dist/server/main.js +228 -0
  28. package/dist/server/prompts.js +32 -0
  29. package/dist/server/publish.js +136 -0
  30. package/dist/server/repos.js +164 -0
  31. package/dist/server/stale.js +50 -0
  32. package/dist/server/store.js +269 -0
  33. package/dist/server/workspace.js +251 -0
  34. package/package.json +63 -4
  35. package/web/dist/assets/abap-CLvhMVsD.js +1 -0
  36. package/web/dist/assets/actionscript-3-Cs6JJXT5.js +1 -0
  37. package/web/dist/assets/ada-X3Y2mlq2.js +1 -0
  38. package/web/dist/assets/ahk-DwADkxyd.js +1 -0
  39. package/web/dist/assets/ahk2-_6rzW9BS.js +1 -0
  40. package/web/dist/assets/andromeeda-vGVdxbeo.js +1 -0
  41. package/web/dist/assets/angular-html-iITFzleb.js +1 -0
  42. package/web/dist/assets/angular-ts-qNGaWUZr.js +1 -0
  43. package/web/dist/assets/apache-U0d_L8uA.js +1 -0
  44. package/web/dist/assets/apex-KFGFyKwG.js +1 -0
  45. package/web/dist/assets/apl-DAcxbtpZ.js +1 -0
  46. package/web/dist/assets/applescript-CCn79oCD.js +1 -0
  47. package/web/dist/assets/ara-4CJ0cIlV.js +1 -0
  48. package/web/dist/assets/asciidoc-SCjQUq34.js +1 -0
  49. package/web/dist/assets/asm-Cmm7eHzH.js +1 -0
  50. package/web/dist/assets/astro-CxPQu5s8.js +1 -0
  51. package/web/dist/assets/aurora-x-CDeNXAV0.js +1 -0
  52. package/web/dist/assets/awk-BWXHIvNe.js +1 -0
  53. package/web/dist/assets/ayu-dark-DluEY0Gj.js +1 -0
  54. package/web/dist/assets/ayu-light-C3h-C4tm.js +1 -0
  55. package/web/dist/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  56. package/web/dist/assets/ballerina-B7ZEbQpA.js +1 -0
  57. package/web/dist/assets/bat-qdxAdBWQ.js +1 -0
  58. package/web/dist/assets/beancount-C2IN4Vk8.js +1 -0
  59. package/web/dist/assets/berry-DKpUyyne.js +1 -0
  60. package/web/dist/assets/bibtex-Ci_nEsc7.js +1 -0
  61. package/web/dist/assets/bicep-CUHmPFLl.js +1 -0
  62. package/web/dist/assets/bird2-CYIUgYqB.js +1 -0
  63. package/web/dist/assets/blade-DJrnOqL4.js +1 -0
  64. package/web/dist/assets/bsl-_VjlB9mv.js +1 -0
  65. package/web/dist/assets/c-DJLzn8qa.js +1 -0
  66. package/web/dist/assets/c3-D0apG41V.js +1 -0
  67. package/web/dist/assets/cadence-CQ2zXKGN.js +1 -0
  68. package/web/dist/assets/cairo-DLTphjLi.js +1 -0
  69. package/web/dist/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
  70. package/web/dist/assets/catppuccin-latte-CtsyrtPq.js +1 -0
  71. package/web/dist/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
  72. package/web/dist/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
  73. package/web/dist/assets/chapel-BHYX99F3.js +1 -0
  74. package/web/dist/assets/clarity-CtfBBspg.js +1 -0
  75. package/web/dist/assets/clojure-DqKBuwfJ.js +1 -0
  76. package/web/dist/assets/cmake-Bj61d0ZC.js +1 -0
  77. package/web/dist/assets/cobol-C_LDam8n.js +1 -0
  78. package/web/dist/assets/codeowners-C8r90Shi.js +1 -0
  79. package/web/dist/assets/codeql-oeQT6MSM.js +1 -0
  80. package/web/dist/assets/coffee-CcuifkxZ.js +1 -0
  81. package/web/dist/assets/common-lisp-Cv5bFMCO.js +1 -0
  82. package/web/dist/assets/coq-CGaSfhwR.js +1 -0
  83. package/web/dist/assets/cpp-E7p80IG9.js +1 -0
  84. package/web/dist/assets/crystal-iYHODIir.js +1 -0
  85. package/web/dist/assets/csharp-dmMxLVLW.js +1 -0
  86. package/web/dist/assets/css-Bk6njqO4.js +1 -0
  87. package/web/dist/assets/csv-Dx-8-gkx.js +1 -0
  88. package/web/dist/assets/cue-CE9AQfxI.js +1 -0
  89. package/web/dist/assets/cypher-ClKdZ_lG.js +1 -0
  90. package/web/dist/assets/d-qD-0Kul2.js +1 -0
  91. package/web/dist/assets/dark-plus-Cs2F2srj.js +1 -0
  92. package/web/dist/assets/dart-CHZY9Xhz.js +1 -0
  93. package/web/dist/assets/dax-BkyTk9wS.js +1 -0
  94. package/web/dist/assets/desktop-Dlh5hvp9.js +1 -0
  95. package/web/dist/assets/diff-woXpYk--.js +1 -0
  96. package/web/dist/assets/docker-IyjqRm3v.js +1 -0
  97. package/web/dist/assets/dotenv-CuH5my32.js +1 -0
  98. package/web/dist/assets/dracula-BHWKrbxM.js +1 -0
  99. package/web/dist/assets/dracula-soft-5eyTD99u.js +1 -0
  100. package/web/dist/assets/dream-maker-DW3nJb8Q.js +1 -0
  101. package/web/dist/assets/edge-Ct7_SkpN.js +1 -0
  102. package/web/dist/assets/elixir-YTzSQL2h.js +1 -0
  103. package/web/dist/assets/elm-bNkwlHr8.js +1 -0
  104. package/web/dist/assets/emacs-lisp-DR2vtWaj.js +1 -0
  105. package/web/dist/assets/erb-uFBspDdG.js +1 -0
  106. package/web/dist/assets/erlang-Cphh6RMH.js +1 -0
  107. package/web/dist/assets/everforest-dark-sB-x3p7T.js +1 -0
  108. package/web/dist/assets/everforest-light-Df2xbC6M.js +1 -0
  109. package/web/dist/assets/fennel-DQxkIbk2.js +1 -0
  110. package/web/dist/assets/fish-BJitypiv.js +1 -0
  111. package/web/dist/assets/fluent-C03EYrpw.js +1 -0
  112. package/web/dist/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
  113. package/web/dist/assets/fortran-free-form-CYNrtFtB.js +1 -0
  114. package/web/dist/assets/fsharp-D13ZGOAj.js +1 -0
  115. package/web/dist/assets/gdresource-xMC7jr7x.js +1 -0
  116. package/web/dist/assets/gdscript-DYvRD3hg.js +1 -0
  117. package/web/dist/assets/gdshader-CBce3t8t.js +1 -0
  118. package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  119. package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  120. package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  121. package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  122. package/web/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  123. package/web/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  124. package/web/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  125. package/web/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  126. package/web/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  127. package/web/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  128. package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  129. package/web/dist/assets/genie-CV2tkWYe.js +1 -0
  130. package/web/dist/assets/gherkin-DExj1W_8.js +1 -0
  131. package/web/dist/assets/git-commit-BSykSTBG.js +1 -0
  132. package/web/dist/assets/git-rebase-CSzaMu4k.js +1 -0
  133. package/web/dist/assets/github-dark-C-LZuMrd.js +1 -0
  134. package/web/dist/assets/github-dark-default-DXG-b-1a.js +1 -0
  135. package/web/dist/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  136. package/web/dist/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  137. package/web/dist/assets/github-light-EUqPIrTm.js +1 -0
  138. package/web/dist/assets/github-light-default-BXViO-2h.js +1 -0
  139. package/web/dist/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  140. package/web/dist/assets/gleam-CSRkHgEL.js +1 -0
  141. package/web/dist/assets/glimmer-js-WrpQIag3.js +1 -0
  142. package/web/dist/assets/glimmer-ts-BkR7s81M.js +1 -0
  143. package/web/dist/assets/glsl-r6ahr8UN.js +1 -0
  144. package/web/dist/assets/gn-CAXYAgV-.js +1 -0
  145. package/web/dist/assets/gnuplot-7GGW24-e.js +1 -0
  146. package/web/dist/assets/go-rLFTqkRN.js +1 -0
  147. package/web/dist/assets/graphql-vcFzEvUM.js +1 -0
  148. package/web/dist/assets/groovy-CacY0gHj.js +1 -0
  149. package/web/dist/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  150. package/web/dist/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  151. package/web/dist/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  152. package/web/dist/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  153. package/web/dist/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  154. package/web/dist/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  155. package/web/dist/assets/hack-DV1TStQR.js +1 -0
  156. package/web/dist/assets/haml-BzEpEFnM.js +1 -0
  157. package/web/dist/assets/handlebars-Bw2ai2tn.js +1 -0
  158. package/web/dist/assets/haskell-D8IpX4py.js +1 -0
  159. package/web/dist/assets/haxe-C8oCnwJJ.js +1 -0
  160. package/web/dist/assets/hcl-Dh228itO.js +1 -0
  161. package/web/dist/assets/hjson-CxZEssPk.js +1 -0
  162. package/web/dist/assets/hlsl-Cvrh5tZx.js +1 -0
  163. package/web/dist/assets/horizon-CE9ld1lL.js +1 -0
  164. package/web/dist/assets/horizon-bright-DSNQnXHK.js +1 -0
  165. package/web/dist/assets/houston-CsvMBhTu.js +1 -0
  166. package/web/dist/assets/html-CVWJgEI4.js +1 -0
  167. package/web/dist/assets/html-derivative-kTFEcoss.js +1 -0
  168. package/web/dist/assets/http-DXC6PGgt.js +1 -0
  169. package/web/dist/assets/hurl-Bpd8P_ef.js +1 -0
  170. package/web/dist/assets/hxml-Dcm88srW.js +1 -0
  171. package/web/dist/assets/hy-CZbG8q4J.js +1 -0
  172. package/web/dist/assets/imba-DsUTQ-LC.js +1 -0
  173. package/web/dist/assets/index-DpYMsPxu.js +1673 -0
  174. package/web/dist/assets/index-Zh-Bd2u6.css +2 -0
  175. package/web/dist/assets/ini-B5eOa1yu.js +1 -0
  176. package/web/dist/assets/java-Bsmh9nXE.js +1 -0
  177. package/web/dist/assets/javascript-CeyaFN_P.js +1 -0
  178. package/web/dist/assets/jinja-BuqTDofy.js +1 -0
  179. package/web/dist/assets/jison-BYfmmaBZ.js +1 -0
  180. package/web/dist/assets/json-Bhl6cDM_.js +1 -0
  181. package/web/dist/assets/json5-BR5RXkoi.js +1 -0
  182. package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
  183. package/web/dist/assets/jsonl-CmCQp5Yx.js +1 -0
  184. package/web/dist/assets/jsonnet-CJTPZ8u_.js +1 -0
  185. package/web/dist/assets/jssm-DXw9l8Rf.js +1 -0
  186. package/web/dist/assets/jsx-BSUHjwDX.js +1 -0
  187. package/web/dist/assets/julia-CWrNF0wf.js +1 -0
  188. package/web/dist/assets/just-wLw7gWsD.js +1 -0
  189. package/web/dist/assets/kanagawa-dragon-Bozd7klA.js +1 -0
  190. package/web/dist/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
  191. package/web/dist/assets/kanagawa-wave-BML5mF2J.js +1 -0
  192. package/web/dist/assets/kdl-CsD5j6eV.js +1 -0
  193. package/web/dist/assets/kotlin-DhhofPvG.js +1 -0
  194. package/web/dist/assets/kusto-C7mF5XQf.js +1 -0
  195. package/web/dist/assets/laserwave-C_8bwKvT.js +1 -0
  196. package/web/dist/assets/latex-DyWaeH0P.js +1 -0
  197. package/web/dist/assets/lean-CewbzKMR.js +1 -0
  198. package/web/dist/assets/less-DVTAwKKz.js +1 -0
  199. package/web/dist/assets/light-plus-DVQuIRkW.js +1 -0
  200. package/web/dist/assets/liquid-DeCc5Rg2.js +1 -0
  201. package/web/dist/assets/llvm-DqHOMS-s.js +1 -0
  202. package/web/dist/assets/log-BNLmms1o.js +1 -0
  203. package/web/dist/assets/logo-Cluzi2Zq.js +1 -0
  204. package/web/dist/assets/lua-Ba-NltBp.js +1 -0
  205. package/web/dist/assets/luau-VGWVLoqX.js +1 -0
  206. package/web/dist/assets/make-Dixweg8N.js +1 -0
  207. package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
  208. package/web/dist/assets/marko-DGb2HMVj.js +1 -0
  209. package/web/dist/assets/material-theme-Bm3Qr25_.js +1 -0
  210. package/web/dist/assets/material-theme-darker-2IIEA8gg.js +1 -0
  211. package/web/dist/assets/material-theme-lighter-uhdI0v04.js +1 -0
  212. package/web/dist/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  213. package/web/dist/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  214. package/web/dist/assets/matlab-D7qyCx1q.js +1 -0
  215. package/web/dist/assets/mdc-CL7bhRQ-.js +1 -0
  216. package/web/dist/assets/mdx-DQZ5AkYe.js +1 -0
  217. package/web/dist/assets/mermaid-BxpfTIzt.js +1 -0
  218. package/web/dist/assets/min-dark-BSWPekZh.js +1 -0
  219. package/web/dist/assets/min-light-DDpmG2fV.js +1 -0
  220. package/web/dist/assets/mipsasm-BMqwQI7S.js +1 -0
  221. package/web/dist/assets/mojo-fg40_ntQ.js +1 -0
  222. package/web/dist/assets/monokai-BscAjiQZ.js +1 -0
  223. package/web/dist/assets/moonbit-D9W784E_.js +1 -0
  224. package/web/dist/assets/move-BYnGhZoM.js +1 -0
  225. package/web/dist/assets/narrat-_X_XdTYD.js +1 -0
  226. package/web/dist/assets/nextflow-CSgcYZcx.js +1 -0
  227. package/web/dist/assets/nextflow-groovy-D7IRt6Pp.js +1 -0
  228. package/web/dist/assets/nginx-CbyuJibN.js +1 -0
  229. package/web/dist/assets/night-owl-DhmEMT88.js +1 -0
  230. package/web/dist/assets/night-owl-light-eJ-hLW7d.js +1 -0
  231. package/web/dist/assets/nim-C7LemgDR.js +1 -0
  232. package/web/dist/assets/nix-IvuFDN5E.js +1 -0
  233. package/web/dist/assets/nord-Cb4Vim4T.js +1 -0
  234. package/web/dist/assets/nsis-CjNLYCLg.js +1 -0
  235. package/web/dist/assets/nushell--0fT3PI1.js +1 -0
  236. package/web/dist/assets/objective-c-D1A_Heim.js +1 -0
  237. package/web/dist/assets/objective-cpp-BsSzOQcm.js +1 -0
  238. package/web/dist/assets/ocaml-O90oeIOV.js +1 -0
  239. package/web/dist/assets/odin-B1RWQWA5.js +1 -0
  240. package/web/dist/assets/one-dark-pro-C6YyR8OD.js +1 -0
  241. package/web/dist/assets/one-light-D7Lr4KcI.js +1 -0
  242. package/web/dist/assets/openscad-BUDT5pXO.js +1 -0
  243. package/web/dist/assets/org-wrbLazmP.js +1 -0
  244. package/web/dist/assets/pascal-4ZHwLPI5.js +1 -0
  245. package/web/dist/assets/perl-DarHXyEu.js +1 -0
  246. package/web/dist/assets/php--54M0-pj.js +1 -0
  247. package/web/dist/assets/pierre-dark-CpLgRqie.js +1 -0
  248. package/web/dist/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
  249. package/web/dist/assets/pierre-dark-soft-kZQmAZld.js +1 -0
  250. package/web/dist/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
  251. package/web/dist/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
  252. package/web/dist/assets/pierre-light-CoaEpmwp.js +1 -0
  253. package/web/dist/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
  254. package/web/dist/assets/pierre-light-soft-lWLdNTOI.js +1 -0
  255. package/web/dist/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
  256. package/web/dist/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
  257. package/web/dist/assets/pkl-ot-7Btpt.js +1 -0
  258. package/web/dist/assets/plastic-DQwYfKfQ.js +1 -0
  259. package/web/dist/assets/plsql-DGHpHOYJ.js +1 -0
  260. package/web/dist/assets/po-BiJDBrnU.js +1 -0
  261. package/web/dist/assets/poimandres-DRFjx7u4.js +1 -0
  262. package/web/dist/assets/polar-C7UOKdEL.js +1 -0
  263. package/web/dist/assets/postcss-BXeXVLqQ.js +1 -0
  264. package/web/dist/assets/powerquery-DNMTfnFr.js +1 -0
  265. package/web/dist/assets/powershell-QtSnmXcu.js +1 -0
  266. package/web/dist/assets/prisma-DMgNhnYS.js +1 -0
  267. package/web/dist/assets/prolog-iXnhIJG7.js +1 -0
  268. package/web/dist/assets/proto-DB4EqR-F.js +1 -0
  269. package/web/dist/assets/pug-CFrC1rDC.js +1 -0
  270. package/web/dist/assets/puppet-CDv2pdJW.js +1 -0
  271. package/web/dist/assets/purescript-9MfHhQsQ.js +1 -0
  272. package/web/dist/assets/python-gzcpVVnB.js +1 -0
  273. package/web/dist/assets/qml-Go4B46qX.js +1 -0
  274. package/web/dist/assets/qmldir-DCQb3MpD.js +1 -0
  275. package/web/dist/assets/qss-Fe1Jh2GI.js +1 -0
  276. package/web/dist/assets/r-Bpu17F3f.js +1 -0
  277. package/web/dist/assets/racket-DcIDlBhZ.js +1 -0
  278. package/web/dist/assets/raku-B3gFvitq.js +1 -0
  279. package/web/dist/assets/razor-CeZTEIIg.js +1 -0
  280. package/web/dist/assets/rbs-C0MpOrj4.js +1 -0
  281. package/web/dist/assets/red-CYlAq2b0.js +1 -0
  282. package/web/dist/assets/reg-CRGYupPL.js +1 -0
  283. package/web/dist/assets/regexp-D4K6CiTG.js +1 -0
  284. package/web/dist/assets/rel-BtDbiS_P.js +1 -0
  285. package/web/dist/assets/riscv-Ckw8ddFX.js +1 -0
  286. package/web/dist/assets/ron-VUp2lXgN.js +1 -0
  287. package/web/dist/assets/rose-pine-aMsaMD1D.js +1 -0
  288. package/web/dist/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
  289. package/web/dist/assets/rose-pine-moon-DO-qXg-I.js +1 -0
  290. package/web/dist/assets/rosmsg-CAekHB0j.js +1 -0
  291. package/web/dist/assets/rst-Dy2Bl1Fg.js +1 -0
  292. package/web/dist/assets/ruby-CNqr2Wuz.js +1 -0
  293. package/web/dist/assets/rust-DpiIf5JO.js +1 -0
  294. package/web/dist/assets/sas-B6MsvXFb.js +1 -0
  295. package/web/dist/assets/sass-DXrisJhu.js +1 -0
  296. package/web/dist/assets/scala-BiFt_7mu.js +1 -0
  297. package/web/dist/assets/scheme-DQCgrYNe.js +1 -0
  298. package/web/dist/assets/scss-CHuFWGi8.js +1 -0
  299. package/web/dist/assets/sdbl-bTVj8UrX.js +1 -0
  300. package/web/dist/assets/shaderlab-TOUzSsQk.js +1 -0
  301. package/web/dist/assets/shellscript-EEdMjEbs.js +1 -0
  302. package/web/dist/assets/shellsession-U_I5Q2cJ.js +1 -0
  303. package/web/dist/assets/slack-dark-DnToyrRv.js +1 -0
  304. package/web/dist/assets/slack-ochin-B2OO5cIa.js +1 -0
  305. package/web/dist/assets/smalltalk-BHpQb5nM.js +1 -0
  306. package/web/dist/assets/smithy-Dgaz7aur.js +1 -0
  307. package/web/dist/assets/snazzy-light-4G7pJPwS.js +1 -0
  308. package/web/dist/assets/solarized-dark-b97czJOk.js +1 -0
  309. package/web/dist/assets/solarized-light-DFPxpIYQ.js +1 -0
  310. package/web/dist/assets/solidity-Bj7E1mRn.js +1 -0
  311. package/web/dist/assets/soy-BnCBZkG3.js +1 -0
  312. package/web/dist/assets/sparql-D_iOobhT.js +1 -0
  313. package/web/dist/assets/splunk-BC2Px7Mm.js +1 -0
  314. package/web/dist/assets/sql-5dStcFSw.js +1 -0
  315. package/web/dist/assets/ssh-config-BgfXC-Er.js +1 -0
  316. package/web/dist/assets/stata-B5iSQdtS.js +1 -0
  317. package/web/dist/assets/stylus-B6D30XZt.js +1 -0
  318. package/web/dist/assets/surrealql-D4K5msa4.js +1 -0
  319. package/web/dist/assets/svelte-Dn-_7BgE.js +1 -0
  320. package/web/dist/assets/swift-CyEgAFGc.js +1 -0
  321. package/web/dist/assets/synthwave-84-nFMaYfgc.js +1 -0
  322. package/web/dist/assets/system-verilog-Dh5ihWbf.js +1 -0
  323. package/web/dist/assets/systemd-BxMlprV5.js +1 -0
  324. package/web/dist/assets/talonscript-CohzipZa.js +1 -0
  325. package/web/dist/assets/tasl-DMoTqEGO.js +1 -0
  326. package/web/dist/assets/tcl-CZd0xW_V.js +1 -0
  327. package/web/dist/assets/templ-BTe8yLW8.js +1 -0
  328. package/web/dist/assets/terraform-DswuEJGm.js +1 -0
  329. package/web/dist/assets/tex-BBG77enc.js +1 -0
  330. package/web/dist/assets/tokyo-night-oM2G3aXe.js +1 -0
  331. package/web/dist/assets/toml-CcmNWLt0.js +1 -0
  332. package/web/dist/assets/ts-tags-BzJXXnMD.js +1 -0
  333. package/web/dist/assets/tsv-sltzmVWM.js +1 -0
  334. package/web/dist/assets/tsx-Cj2inrAP.js +1 -0
  335. package/web/dist/assets/turtle-ByJddavk.js +1 -0
  336. package/web/dist/assets/twig-BH3HU2q4.js +1 -0
  337. package/web/dist/assets/typescript-DpDozqSz.js +1 -0
  338. package/web/dist/assets/typespec-BGhR2SqG.js +1 -0
  339. package/web/dist/assets/typst-GHzvrUad.js +1 -0
  340. package/web/dist/assets/v-DBj4K9d_.js +1 -0
  341. package/web/dist/assets/vala-zf12oZj6.js +1 -0
  342. package/web/dist/assets/vb-DOwzaHZ0.js +1 -0
  343. package/web/dist/assets/verilog-B2gwz-sJ.js +1 -0
  344. package/web/dist/assets/vesper-DdrHHSXu.js +1 -0
  345. package/web/dist/assets/vhdl-BroJfC0k.js +1 -0
  346. package/web/dist/assets/viml-DvXPmvsu.js +1 -0
  347. package/web/dist/assets/vitesse-black-fwtXNY1n.js +1 -0
  348. package/web/dist/assets/vitesse-dark-BZCL-v6S.js +1 -0
  349. package/web/dist/assets/vitesse-light-VbXTXTou.js +1 -0
  350. package/web/dist/assets/vue-CqkncxvB.js +1 -0
  351. package/web/dist/assets/vue-html-DrD64fqb.js +1 -0
  352. package/web/dist/assets/vue-vine-BJy37wv2.js +1 -0
  353. package/web/dist/assets/vyper-CgoNMtux.js +1 -0
  354. package/web/dist/assets/wasm-BnjxR4X6.js +1 -0
  355. package/web/dist/assets/wasm-ByWQv1Qj.js +1 -0
  356. package/web/dist/assets/wenyan-C8pVoKbM.js +1 -0
  357. package/web/dist/assets/wgsl-BsKzXJz4.js +1 -0
  358. package/web/dist/assets/wikitext-ClFFjSW2.js +1 -0
  359. package/web/dist/assets/wit-DdvCle-K.js +1 -0
  360. package/web/dist/assets/wolfram-DLL8P-h_.js +1 -0
  361. package/web/dist/assets/xml-CtXDvb3g.js +1 -0
  362. package/web/dist/assets/xsl-9J2XPEqv.js +1 -0
  363. package/web/dist/assets/yaml-CKsrpaXo.js +1 -0
  364. package/web/dist/assets/zenscript-BnlCZFoB.js +1 -0
  365. package/web/dist/assets/zig-CMLA9XwU.js +1 -0
  366. package/web/dist/favicon.svg +1 -0
  367. package/web/dist/index.html +15 -0
@@ -0,0 +1,230 @@
1
+ // Claude Code sessions that Downstream runs itself, through the Agent SDK. You
2
+ // press a pull request; a session starts in its repository with a first
3
+ // message; what it says and does streams to the browser, and anything that
4
+ // isn't read-only waits for your approval there. You can move a session to
5
+ // your terminal at any time: Downstream lets go and `claude --resume` picks it up.
6
+ import { EventEmitter } from "node:events";
7
+ import { query } from "@anthropic-ai/claude-agent-sdk";
8
+ import { autoApprove, reachesOthers } from "../domain/approval.js";
9
+ import { ghEnv } from "./gh.js";
10
+ import { packageRoot } from "./install.js";
11
+ import { newId, now } from "./store.js";
12
+ const skillDir = packageRoot;
13
+ const ACTIVITY_LIMIT = 200;
14
+ class AgentSession {
15
+ view;
16
+ queue = [];
17
+ wake = null;
18
+ closed = false;
19
+ pending = new Map();
20
+ q = null;
21
+ changed;
22
+ constructor(input, changed) {
23
+ this.changed = changed;
24
+ this.view = { key: input.key, repo: input.repo, pr: input.pr, root: input.root, sessionId: input.resumeId ?? null, status: "starting", activity: [], approvals: [], error: null, resume: null };
25
+ }
26
+ start(input) {
27
+ this.send(input.prompt, false);
28
+ this.q = query({
29
+ prompt: this.input(),
30
+ options: {
31
+ cwd: input.root,
32
+ // 'user' carries the user's model gateway and their own CLAUDE.md; 'project' the repo's.
33
+ settingSources: ["user", "project", "local"],
34
+ // Auto mode: a classifier approves ordinary work, so you're asked only when it can't tell.
35
+ permissionMode: "auto",
36
+ // Runs before the classifier: anything that reaches other people comes to you, whatever it would decide.
37
+ hooks: { PreToolUse: [{ hooks: [async (hook) => outwardHook(hook)] }] },
38
+ canUseTool: (tool, toolInput, { signal, title }) => this.approve(tool, toolInput, signal, title),
39
+ // DOWNSTREAM_HOSTED: the browser is already on its way to the review; `open` shouldn't open another tab.
40
+ env: { ...ghEnv(input.account), DOWNSTREAM_HOSTED: "1" },
41
+ ...(input.resumeId ? { resume: input.resumeId } : {}),
42
+ },
43
+ });
44
+ void this.pump(this.q);
45
+ }
46
+ /** Queue a message for the agent. It reads it when its current turn ends. */
47
+ send(text, record = true) {
48
+ if (this.closed)
49
+ throw new Error("This session has ended.");
50
+ this.queue.push({ type: "user", message: { role: "user", content: text }, parent_tool_use_id: null });
51
+ if (record)
52
+ this.log({ kind: "user", text });
53
+ this.wake?.();
54
+ }
55
+ decide(approvalId, allow) {
56
+ const resolve = this.pending.get(approvalId);
57
+ if (!resolve)
58
+ return;
59
+ this.pending.delete(approvalId);
60
+ this.view.approvals = this.view.approvals.filter((a) => a.id !== approvalId);
61
+ resolve(allow ? { behavior: "allow" } : { behavior: "deny", message: "The user declined this in Downstream." });
62
+ this.setStatus(this.view.approvals.length ? "asking" : "running");
63
+ }
64
+ /** Let go of the session so a terminal can resume it; two live writers would interleave the transcript. */
65
+ async handOff() {
66
+ const id = this.view.sessionId;
67
+ if (!id)
68
+ throw new Error("The session hasn't started yet.");
69
+ for (const id of [...this.pending.keys()])
70
+ this.decide(id, false);
71
+ this.stop();
72
+ await this.q?.interrupt().catch(() => undefined);
73
+ this.q?.close();
74
+ this.view.resume = `cd ${JSON.stringify(this.view.root)} && claude --resume ${id}`;
75
+ this.setStatus("handed-off");
76
+ return this.view.resume;
77
+ }
78
+ stop() {
79
+ this.closed = true;
80
+ this.wake?.();
81
+ }
82
+ get live() {
83
+ return !this.closed;
84
+ }
85
+ async *input() {
86
+ while (!this.closed) {
87
+ if (!this.queue.length)
88
+ await new Promise((r) => (this.wake = r));
89
+ while (this.queue.length)
90
+ yield this.queue.shift();
91
+ }
92
+ }
93
+ async approve(tool, input, signal, title) {
94
+ if (autoApprove(tool, input, skillDir).allow)
95
+ return { behavior: "allow", updatedInput: input };
96
+ const approval = { id: newId("ap"), tool, title: title ?? `Claude wants to use ${tool}`, detail: describeInput(tool, input), at: now() };
97
+ // Register the answer before announcing the question: a listener may answer the moment it hears.
98
+ const answer = new Promise((resolve) => {
99
+ this.pending.set(approval.id, (r) => resolve(r.behavior === "allow" ? { ...r, updatedInput: input } : r));
100
+ });
101
+ signal.addEventListener("abort", () => this.decide(approval.id, false), { once: true });
102
+ this.view.approvals = [...this.view.approvals, approval];
103
+ this.setStatus("asking");
104
+ return answer;
105
+ }
106
+ async pump(q) {
107
+ try {
108
+ for await (const m of q)
109
+ this.onMessage(m);
110
+ if (this.view.status !== "handed-off")
111
+ this.setStatus("ended");
112
+ }
113
+ catch (e) {
114
+ if (this.view.status === "handed-off")
115
+ return;
116
+ this.view.error = e.message;
117
+ this.log({ kind: "error", text: this.view.error });
118
+ this.setStatus("failed");
119
+ }
120
+ finally {
121
+ this.closed = true;
122
+ }
123
+ }
124
+ onMessage(m) {
125
+ if (m.type === "system" && m.subtype === "init") {
126
+ this.view.sessionId = m.session_id;
127
+ this.setStatus("running");
128
+ return;
129
+ }
130
+ if (m.type === "system" && m.subtype === "session_state_changed") {
131
+ // "requires_action" is our own approval prompt, already reflected; only idle/running come from here.
132
+ if (this.view.approvals.length === 0 && m.state !== "requires_action")
133
+ this.setStatus(m.state === "idle" ? "idle" : "running");
134
+ return;
135
+ }
136
+ if (m.type === "assistant" && m.parent_tool_use_id === null) {
137
+ for (const block of m.message.content) {
138
+ if (block.type === "text" && block.text.trim())
139
+ this.log({ kind: "text", text: block.text });
140
+ if (block.type === "tool_use")
141
+ this.log({ kind: "tool", tool: block.name, summary: describeInput(block.name, block.input) });
142
+ }
143
+ return;
144
+ }
145
+ if (m.type === "result") {
146
+ if (m.subtype !== "success")
147
+ this.log({ kind: "error", text: `The turn ended early (${m.subtype}).` });
148
+ if (this.view.approvals.length === 0)
149
+ this.setStatus("idle");
150
+ }
151
+ }
152
+ log(entry) {
153
+ this.view.activity = [...this.view.activity, { ...entry, id: newId("ac"), at: now() }].slice(-ACTIVITY_LIMIT);
154
+ this.changed();
155
+ }
156
+ setStatus(status) {
157
+ if (this.view.status === status)
158
+ return;
159
+ this.view.status = status;
160
+ this.changed();
161
+ }
162
+ }
163
+ /** One line a person can read: the command, the file, the pattern. */
164
+ function describeInput(tool, input) {
165
+ const pick = (k) => (typeof input[k] === "string" ? input[k] : null);
166
+ const text = pick("command") ?? pick("file_path") ?? pick("pattern") ?? pick("url") ?? pick("query") ?? pick("description") ?? pick("prompt") ?? "";
167
+ return (text || tool).replace(new RegExp(`node "?${skillDir}/bin/downstream.mjs"?`, "g"), "downstream").slice(0, 400);
168
+ }
169
+ export class AgentHost {
170
+ sessions = new Map();
171
+ /** "changed" with the session key. */
172
+ bus = new EventEmitter();
173
+ constructor() {
174
+ this.bus.setMaxListeners(100);
175
+ }
176
+ start(input) {
177
+ const existing = this.sessions.get(input.key);
178
+ if (existing?.live)
179
+ return existing.view;
180
+ const session = new AgentSession(input, () => this.bus.emit("changed", input.key));
181
+ this.sessions.set(input.key, session);
182
+ session.start(input);
183
+ this.bus.emit("changed", input.key);
184
+ return session.view;
185
+ }
186
+ view(key) {
187
+ return this.sessions.get(key)?.view ?? null;
188
+ }
189
+ views() {
190
+ return [...this.sessions.values()].map((s) => s.view);
191
+ }
192
+ live(key) {
193
+ return this.sessions.get(key)?.live ?? false;
194
+ }
195
+ send(key, text) {
196
+ this.require(key).send(text);
197
+ }
198
+ decide(key, approvalId, allow) {
199
+ this.require(key).decide(approvalId, allow);
200
+ }
201
+ handOff(key) {
202
+ return this.require(key).handOff();
203
+ }
204
+ /**
205
+ * The user wrote in Downstream while the agent sat idle (its turn over, not in
206
+ * `downstream wait`): tell it, so a message never waits on an agent that
207
+ * stopped listening.
208
+ */
209
+ nudge(key) {
210
+ const s = this.sessions.get(key);
211
+ if (s?.live && s.view.status === "idle")
212
+ s.send("The user wrote to you in Downstream. Run `downstream wait` to read it and answer there.", false);
213
+ }
214
+ stopAll() {
215
+ for (const s of this.sessions.values())
216
+ s.stop();
217
+ }
218
+ require(key) {
219
+ const s = this.sessions.get(key);
220
+ if (!s)
221
+ throw new Error(`No agent session for ${key}.`);
222
+ return s;
223
+ }
224
+ }
225
+ function outwardHook(hook) {
226
+ if (hook.hook_event_name !== "PreToolUse")
227
+ return {};
228
+ const reason = reachesOthers(hook.tool_name, (hook.tool_input ?? {}));
229
+ return reason ? { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "ask", permissionDecisionReason: `This is ${reason}, which you approve yourself.` } } : {};
230
+ }
@@ -0,0 +1,161 @@
1
+ // Git plumbing: which files changed, which lines changed, and file contents on
2
+ // either side. "head" is either a ref or the working tree (uncommitted work
3
+ // counts, untracked files included) so an agent can review what it just wrote.
4
+ import { execFileSync } from "node:child_process";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import path from "node:path";
7
+ export const WORKTREE = "WORKTREE";
8
+ export function git(cwd, args) {
9
+ return execFileSync("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "pipe"] });
10
+ }
11
+ export function tryGit(cwd, args) {
12
+ try {
13
+ return git(cwd, args);
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
19
+ export function repoRoot(cwd) {
20
+ return git(cwd, ["rev-parse", "--show-toplevel"]).trim();
21
+ }
22
+ export function worktreeSource(root) {
23
+ return {
24
+ label: WORKTREE,
25
+ read(file) {
26
+ const abs = path.join(root, file);
27
+ return existsSync(abs) ? readFileSync(abs, "utf8") : null;
28
+ },
29
+ exists: (file) => existsSync(path.join(root, file)),
30
+ files: () => [
31
+ ...new Set([
32
+ ...git(root, ["ls-files"]).split("\n"),
33
+ ...git(root, ["ls-files", "--others", "--exclude-standard"]).split("\n"),
34
+ ]),
35
+ ].filter(Boolean),
36
+ };
37
+ }
38
+ const PRELOAD = /\.(m|c)?(t|j)sx?$|\.json$|\.pyi?$/;
39
+ /**
40
+ * Files at a commit. A type checker reads hundreds of files, and one `git show`
41
+ * each costs seconds, so source files are read up front in one `cat-file --batch`.
42
+ */
43
+ export function refSource(root, ref) {
44
+ const cache = new Map();
45
+ let blobs = null;
46
+ const tree = () => {
47
+ if (blobs)
48
+ return blobs;
49
+ blobs = new Map();
50
+ for (const line of git(root, ["ls-tree", "-r", "-l", ref]).split("\n")) {
51
+ const m = line.match(/^\d+ blob ([0-9a-f]+)\s+(\d+|-)\t(.+)$/);
52
+ if (m)
53
+ blobs.set(m[3], m[1]);
54
+ }
55
+ const wanted = [...blobs].filter(([p]) => PRELOAD.test(p) && !p.includes("node_modules/"));
56
+ if (wanted.length) {
57
+ const out = execFileSync("git", ["cat-file", "--batch"], { cwd: root, input: wanted.map(([, sha]) => sha).join("\n") + "\n", maxBuffer: 1024 * 1024 * 1024 });
58
+ let at = 0;
59
+ for (const [p] of wanted) {
60
+ const nl = out.indexOf(10, at);
61
+ const size = Number(out.subarray(at, nl).toString("utf8").split(" ")[2]);
62
+ cache.set(p, out.subarray(nl + 1, nl + 1 + size).toString("utf8"));
63
+ at = nl + 1 + size + 1;
64
+ }
65
+ }
66
+ return blobs;
67
+ };
68
+ return {
69
+ label: ref,
70
+ read(file) {
71
+ const files = tree();
72
+ if (!cache.has(file))
73
+ cache.set(file, files.has(file) ? tryGit(root, ["show", `${ref}:${file}`]) : null);
74
+ return cache.get(file) ?? null;
75
+ },
76
+ exists: (file) => tree().has(file),
77
+ files: () => [...tree().keys()],
78
+ };
79
+ }
80
+ function parseHunks(patch) {
81
+ const added = [];
82
+ const deleted = [];
83
+ for (const m of patch.matchAll(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/gm)) {
84
+ const oldStart = Number(m[1]);
85
+ const oldLen = m[2] === undefined ? 1 : Number(m[2]);
86
+ const newStart = Number(m[3]);
87
+ const newLen = m[4] === undefined ? 1 : Number(m[4]);
88
+ if (oldLen > 0)
89
+ deleted.push({ start: oldStart, end: oldStart + oldLen - 1 });
90
+ if (newLen > 0)
91
+ added.push({ start: newStart, end: newStart + newLen - 1 });
92
+ }
93
+ return { added, deleted };
94
+ }
95
+ const IGNORED = /(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|\.downstream\/)/;
96
+ export function diff(root, base, head) {
97
+ const headRef = head === WORKTREE ? "HEAD" : head;
98
+ const mergeBase = (tryGit(root, ["merge-base", base, headRef]) ?? git(root, ["rev-parse", base])).trim();
99
+ const range = head === WORKTREE ? [mergeBase] : [mergeBase, head];
100
+ const files = [];
101
+ const hunks = new Map();
102
+ const numstat = git(root, ["diff", "--numstat", "-M", ...range]);
103
+ const nameStatus = git(root, ["diff", "--name-status", "-M", ...range]);
104
+ const counts = new Map();
105
+ for (const line of numstat.split("\n").filter(Boolean)) {
106
+ const [a, d, ...rest] = line.split("\t");
107
+ const p = rest.at(-1);
108
+ counts.set(p, [Number(a) || 0, Number(d) || 0]);
109
+ }
110
+ for (const line of nameStatus.split("\n").filter(Boolean)) {
111
+ const parts = line.split("\t");
112
+ const code = parts[0][0];
113
+ const p = parts.at(-1);
114
+ if (IGNORED.test(p))
115
+ continue;
116
+ const oldPath = code === "R" ? parts[1] : code === "A" ? null : p;
117
+ const status = code === "A" ? "added" : code === "D" ? "deleted" : code === "R" ? "renamed" : "modified";
118
+ const [additions, deletions] = counts.get(p) ?? counts.get(`${parts[1]} => ${p}`) ?? [0, 0];
119
+ files.push({ path: p, oldPath, status, additions, deletions });
120
+ const patch = git(root, ["diff", "-U0", "-M", ...range, "--", ...(oldPath && oldPath !== p ? [oldPath, p] : [p])]);
121
+ hunks.set(p, parseHunks(patch));
122
+ }
123
+ if (head === WORKTREE) {
124
+ const untracked = git(root, ["ls-files", "--others", "--exclude-standard"]).split("\n").filter(Boolean);
125
+ for (const p of untracked) {
126
+ if (IGNORED.test(p) || files.some((f) => f.path === p))
127
+ continue;
128
+ const text = tryReadText(path.join(root, p));
129
+ if (text === null)
130
+ continue;
131
+ const lines = text.split("\n").length;
132
+ files.push({ path: p, oldPath: null, status: "added", additions: lines, deletions: 0 });
133
+ hunks.set(p, { added: [{ start: 1, end: lines }], deleted: [] });
134
+ }
135
+ }
136
+ return { mergeBase, files, hunks };
137
+ }
138
+ function tryReadText(abs) {
139
+ try {
140
+ const buf = readFileSync(abs);
141
+ if (buf.length > 2_000_000 || buf.includes(0))
142
+ return null;
143
+ return buf.toString("utf8");
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ }
149
+ export function inRanges(line, ranges) {
150
+ return ranges.some((r) => line >= r.start && line <= r.end);
151
+ }
152
+ export function countInRange(range, ranges) {
153
+ let n = 0;
154
+ for (const r of ranges) {
155
+ const s = Math.max(r.start, range.start);
156
+ const e = Math.min(r.end, range.end);
157
+ if (e >= s)
158
+ n += e - s + 1;
159
+ }
160
+ return n;
161
+ }