ref0-git 0.0.0 → 0.2.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 (385) hide show
  1. package/app/apps/github/.dev.vars.example +6 -0
  2. package/app/apps/github/README.md +70 -0
  3. package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
  4. package/app/apps/github/components.json +25 -0
  5. package/app/apps/github/generated/git-rest.ts +10444 -0
  6. package/app/apps/github/generated/routeTree.gen.ts +1242 -0
  7. package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
  8. package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
  9. package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
  10. package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
  11. package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
  12. package/app/apps/github/package.json +80 -0
  13. package/app/apps/github/src/branches/branch-list.tsx +385 -0
  14. package/app/apps/github/src/branches/branches.ts +55 -0
  15. package/app/apps/github/src/clients/allowed.ts +213 -0
  16. package/app/apps/github/src/clients/at-most.ts +17 -0
  17. package/app/apps/github/src/clients/avatars.ts +410 -0
  18. package/app/apps/github/src/clients/cached.ts +65 -0
  19. package/app/apps/github/src/clients/calls.ts +160 -0
  20. package/app/apps/github/src/clients/clients.ts +82 -0
  21. package/app/apps/github/src/clients/graphql.ts +50 -0
  22. package/app/apps/github/src/clients/host-answer.ts +28 -0
  23. package/app/apps/github/src/clients/host-calls.ts +382 -0
  24. package/app/apps/github/src/clients/icon-bytes.ts +203 -0
  25. package/app/apps/github/src/clients/proxy.ts +59 -0
  26. package/app/apps/github/src/clients/session-ended.ts +18 -0
  27. package/app/apps/github/src/clients/transfers.ts +212 -0
  28. package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
  29. package/app/apps/github/src/code/code-page.tsx +147 -0
  30. package/app/apps/github/src/code/code-tree.tsx +338 -0
  31. package/app/apps/github/src/code/controls.tsx +230 -0
  32. package/app/apps/github/src/code/file-view.tsx +450 -0
  33. package/app/apps/github/src/code/files.ts +332 -0
  34. package/app/apps/github/src/code/folder-list.tsx +122 -0
  35. package/app/apps/github/src/code/go-to-file.tsx +131 -0
  36. package/app/apps/github/src/code/highlighted.tsx +58 -0
  37. package/app/apps/github/src/code/lines.ts +46 -0
  38. package/app/apps/github/src/code/load.ts +147 -0
  39. package/app/apps/github/src/code/markdown-files.ts +58 -0
  40. package/app/apps/github/src/code/places.ts +88 -0
  41. package/app/apps/github/src/code/ref-pages.ts +179 -0
  42. package/app/apps/github/src/code/ref-switcher.tsx +203 -0
  43. package/app/apps/github/src/code/refs.ts +142 -0
  44. package/app/apps/github/src/code/repo-home.tsx +240 -0
  45. package/app/apps/github/src/code/repo.ts +105 -0
  46. package/app/apps/github/src/code/saved-reads.ts +199 -0
  47. package/app/apps/github/src/code/saved.ts +110 -0
  48. package/app/apps/github/src/code/tree-fold.ts +186 -0
  49. package/app/apps/github/src/code/trees.ts +136 -0
  50. package/app/apps/github/src/components/avatar-picture.ts +53 -0
  51. package/app/apps/github/src/components/avatar-url.ts +16 -0
  52. package/app/apps/github/src/components/confirm-action.tsx +100 -0
  53. package/app/apps/github/src/components/count.tsx +24 -0
  54. package/app/apps/github/src/components/create-button.tsx +38 -0
  55. package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
  56. package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
  57. package/app/apps/github/src/components/filter.tsx +35 -0
  58. package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
  59. package/app/apps/github/src/components/item-list.tsx +65 -0
  60. package/app/apps/github/src/components/language-dot.tsx +29 -0
  61. package/app/apps/github/src/components/list-toolbar.tsx +82 -0
  62. package/app/apps/github/src/components/markdown/editor.tsx +57 -0
  63. package/app/apps/github/src/components/markdown/markdown.css +177 -0
  64. package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
  65. package/app/apps/github/src/components/owner-card.tsx +196 -0
  66. package/app/apps/github/src/components/pull-status.tsx +34 -0
  67. package/app/apps/github/src/components/recent.ts +41 -0
  68. package/app/apps/github/src/components/relative-time.tsx +78 -0
  69. package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
  70. package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
  71. package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
  72. package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
  73. package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
  74. package/app/apps/github/src/components/review-state.tsx +75 -0
  75. package/app/apps/github/src/components/route-dialog.tsx +137 -0
  76. package/app/apps/github/src/components/save-button.tsx +58 -0
  77. package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
  78. package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
  79. package/app/apps/github/src/components/shell/create-row.tsx +49 -0
  80. package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
  81. package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
  82. package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
  83. package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
  84. package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
  85. package/app/apps/github/src/components/shell/sections.ts +31 -0
  86. package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
  87. package/app/apps/github/src/components/signin/device-card.tsx +139 -0
  88. package/app/apps/github/src/components/signin/login-form.tsx +88 -0
  89. package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
  90. package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
  91. package/app/apps/github/src/components/states/live-status.tsx +42 -0
  92. package/app/apps/github/src/components/states/states.tsx +126 -0
  93. package/app/apps/github/src/components/tab-indicator.tsx +143 -0
  94. package/app/apps/github/src/components/theme-choice.tsx +108 -0
  95. package/app/apps/github/src/components/theme-provider.tsx +126 -0
  96. package/app/apps/github/src/components/tones.ts +23 -0
  97. package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
  98. package/app/apps/github/src/components/ui/alert.tsx +78 -0
  99. package/app/apps/github/src/components/ui/avatar.tsx +106 -0
  100. package/app/apps/github/src/components/ui/badge.tsx +51 -0
  101. package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
  102. package/app/apps/github/src/components/ui/button-group.tsx +87 -0
  103. package/app/apps/github/src/components/ui/button.tsx +61 -0
  104. package/app/apps/github/src/components/ui/calendar.tsx +221 -0
  105. package/app/apps/github/src/components/ui/card.tsx +102 -0
  106. package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
  107. package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
  108. package/app/apps/github/src/components/ui/combobox.tsx +304 -0
  109. package/app/apps/github/src/components/ui/command.tsx +208 -0
  110. package/app/apps/github/src/components/ui/dialog.tsx +156 -0
  111. package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
  112. package/app/apps/github/src/components/ui/empty.tsx +100 -0
  113. package/app/apps/github/src/components/ui/field.tsx +236 -0
  114. package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
  115. package/app/apps/github/src/components/ui/input-group.tsx +163 -0
  116. package/app/apps/github/src/components/ui/input.tsx +19 -0
  117. package/app/apps/github/src/components/ui/item.tsx +201 -0
  118. package/app/apps/github/src/components/ui/kbd.tsx +27 -0
  119. package/app/apps/github/src/components/ui/label.tsx +33 -0
  120. package/app/apps/github/src/components/ui/popover.tsx +87 -0
  121. package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
  122. package/app/apps/github/src/components/ui/select.tsx +198 -0
  123. package/app/apps/github/src/components/ui/separator.tsx +22 -0
  124. package/app/apps/github/src/components/ui/sheet.tsx +138 -0
  125. package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
  126. package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
  127. package/app/apps/github/src/components/ui/sonner.tsx +47 -0
  128. package/app/apps/github/src/components/ui/styles.css +242 -0
  129. package/app/apps/github/src/components/ui/table.tsx +113 -0
  130. package/app/apps/github/src/components/ui/tabs.tsx +79 -0
  131. package/app/apps/github/src/components/ui/textarea.tsx +17 -0
  132. package/app/apps/github/src/components/ui/title.ts +6 -0
  133. package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
  134. package/app/apps/github/src/components/ui/toggle.tsx +42 -0
  135. package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
  136. package/app/apps/github/src/components/user-avatar.tsx +145 -0
  137. package/app/apps/github/src/components/view-tabs.tsx +42 -0
  138. package/app/apps/github/src/context/context.ts +133 -0
  139. package/app/apps/github/src/diffs/blobs.ts +94 -0
  140. package/app/apps/github/src/diffs/diff-view.tsx +155 -0
  141. package/app/apps/github/src/diffs/files.ts +121 -0
  142. package/app/apps/github/src/diffs/hunks.tsx +454 -0
  143. package/app/apps/github/src/diffs/patch.ts +131 -0
  144. package/app/apps/github/src/diffs/rows.ts +137 -0
  145. package/app/apps/github/src/history/commit-diff.ts +54 -0
  146. package/app/apps/github/src/history/commit-list.tsx +207 -0
  147. package/app/apps/github/src/history/commit-page.tsx +147 -0
  148. package/app/apps/github/src/history/history.ts +129 -0
  149. package/app/apps/github/src/hooks/allowed.ts +31 -0
  150. package/app/apps/github/src/hooks/answers.ts +65 -0
  151. package/app/apps/github/src/hooks/avatars.ts +54 -0
  152. package/app/apps/github/src/hooks/draft.ts +38 -0
  153. package/app/apps/github/src/hooks/open-counts.ts +127 -0
  154. package/app/apps/github/src/hooks/profiles.ts +120 -0
  155. package/app/apps/github/src/hooks/repos.ts +440 -0
  156. package/app/apps/github/src/hooks/use-mobile.ts +19 -0
  157. package/app/apps/github/src/hooks/viewer.ts +39 -0
  158. package/app/apps/github/src/inbox/count.ts +70 -0
  159. package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
  160. package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
  161. package/app/apps/github/src/inbox/marks.ts +130 -0
  162. package/app/apps/github/src/inbox/release-tags.ts +65 -0
  163. package/app/apps/github/src/inbox/search.ts +97 -0
  164. package/app/apps/github/src/inbox/subjects.ts +184 -0
  165. package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
  166. package/app/apps/github/src/inbox/subscriptions.ts +189 -0
  167. package/app/apps/github/src/inbox/threads.ts +198 -0
  168. package/app/apps/github/src/issues/changes.ts +332 -0
  169. package/app/apps/github/src/issues/counts.ts +62 -0
  170. package/app/apps/github/src/issues/issue-list.tsx +682 -0
  171. package/app/apps/github/src/issues/issue-page.tsx +533 -0
  172. package/app/apps/github/src/issues/issues.ts +566 -0
  173. package/app/apps/github/src/issues/label-dialog.tsx +310 -0
  174. package/app/apps/github/src/issues/labels-page.tsx +119 -0
  175. package/app/apps/github/src/issues/new-issue.tsx +79 -0
  176. package/app/apps/github/src/issues/parts.tsx +71 -0
  177. package/app/apps/github/src/issues/picker.tsx +298 -0
  178. package/app/apps/github/src/issues/search.ts +238 -0
  179. package/app/apps/github/src/issues/sidebar.tsx +236 -0
  180. package/app/apps/github/src/lib/cn.ts +8 -0
  181. package/app/apps/github/src/lib/highlighting.ts +13 -0
  182. package/app/apps/github/src/live/follow.ts +129 -0
  183. package/app/apps/github/src/live/sse.ts +74 -0
  184. package/app/apps/github/src/live/use-follow.ts +37 -0
  185. package/app/apps/github/src/markdown/README.md +53 -0
  186. package/app/apps/github/src/markdown/allowed-html.ts +69 -0
  187. package/app/apps/github/src/markdown/context.ts +206 -0
  188. package/app/apps/github/src/markdown/images.ts +81 -0
  189. package/app/apps/github/src/markdown/lookup.ts +122 -0
  190. package/app/apps/github/src/markdown/patches.ts +299 -0
  191. package/app/apps/github/src/markdown/query.ts +25 -0
  192. package/app/apps/github/src/markdown/references.ts +158 -0
  193. package/app/apps/github/src/markdown/render.ts +103 -0
  194. package/app/apps/github/src/names/owners.ts +51 -0
  195. package/app/apps/github/src/names/repos.ts +24 -0
  196. package/app/apps/github/src/palette/palette.tsx +547 -0
  197. package/app/apps/github/src/palette/recent.ts +116 -0
  198. package/app/apps/github/src/palette/rows.tsx +455 -0
  199. package/app/apps/github/src/palette/server.ts +104 -0
  200. package/app/apps/github/src/palette/targets.ts +306 -0
  201. package/app/apps/github/src/policy.ts +600 -0
  202. package/app/apps/github/src/private-repos.ts +47 -0
  203. package/app/apps/github/src/pulls/compare-page.tsx +342 -0
  204. package/app/apps/github/src/pulls/files-tab.tsx +776 -0
  205. package/app/apps/github/src/pulls/live.ts +124 -0
  206. package/app/apps/github/src/pulls/merge-box.tsx +367 -0
  207. package/app/apps/github/src/pulls/merge-button.ts +86 -0
  208. package/app/apps/github/src/pulls/pull-list.tsx +235 -0
  209. package/app/apps/github/src/pulls/pull-page.tsx +474 -0
  210. package/app/apps/github/src/pulls/pull.ts +468 -0
  211. package/app/apps/github/src/pulls/pulls.ts +318 -0
  212. package/app/apps/github/src/pulls/review.ts +350 -0
  213. package/app/apps/github/src/pulls/search.ts +130 -0
  214. package/app/apps/github/src/queue/queue-page.tsx +405 -0
  215. package/app/apps/github/src/queue/queue.ts +231 -0
  216. package/app/apps/github/src/releases/latest-release.tsx +55 -0
  217. package/app/apps/github/src/releases/overview.tsx +30 -0
  218. package/app/apps/github/src/releases/release-form.tsx +353 -0
  219. package/app/apps/github/src/releases/release-list.tsx +173 -0
  220. package/app/apps/github/src/releases/release-view.tsx +183 -0
  221. package/app/apps/github/src/releases/releases.ts +308 -0
  222. package/app/apps/github/src/releases/tag-list.tsx +134 -0
  223. package/app/apps/github/src/router.tsx +46 -0
  224. package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
  225. package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
  226. package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
  227. package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
  228. package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
  229. package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
  230. package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
  231. package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
  232. package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
  233. package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
  234. package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
  235. package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
  236. package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
  237. package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
  238. package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
  239. package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
  240. package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
  241. package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
  242. package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
  243. package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
  244. package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
  245. package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
  246. package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
  247. package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
  248. package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
  249. package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
  250. package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
  251. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
  252. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
  253. package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
  254. package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
  255. package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
  256. package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
  257. package/app/apps/github/src/routes/$owner/index.tsx +45 -0
  258. package/app/apps/github/src/routes/-nav.tsx +293 -0
  259. package/app/apps/github/src/routes/-root-testing.ts +107 -0
  260. package/app/apps/github/src/routes/__root.tsx +225 -0
  261. package/app/apps/github/src/routes/api.auth.$.ts +18 -0
  262. package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
  263. package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
  264. package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
  265. package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
  266. package/app/apps/github/src/routes/icons/index.tsx +12 -0
  267. package/app/apps/github/src/routes/index.tsx +48 -0
  268. package/app/apps/github/src/routes/login.tsx +24 -0
  269. package/app/apps/github/src/routes/login_.code.tsx +31 -0
  270. package/app/apps/github/src/routes/new.tsx +91 -0
  271. package/app/apps/github/src/routes/notifications.tsx +20 -0
  272. package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
  273. package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
  274. package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
  275. package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
  276. package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
  277. package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
  278. package/app/apps/github/src/routes/settings.tsx +54 -0
  279. package/app/apps/github/src/routes/signup.tsx +24 -0
  280. package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
  281. package/app/apps/github/src/seed/acme.ts +498 -0
  282. package/app/apps/github/src/seed/licenses.ts +114 -0
  283. package/app/apps/github/src/seed/seed.ts +538 -0
  284. package/app/apps/github/src/server.ts +97 -0
  285. package/app/apps/github/src/settings/account-avatar.tsx +43 -0
  286. package/app/apps/github/src/settings/avatar-section.tsx +140 -0
  287. package/app/apps/github/src/settings/avatar.ts +58 -0
  288. package/app/apps/github/src/settings/general-settings.tsx +439 -0
  289. package/app/apps/github/src/settings/general.ts +73 -0
  290. package/app/apps/github/src/settings/hook-form.tsx +195 -0
  291. package/app/apps/github/src/settings/hook-list.tsx +166 -0
  292. package/app/apps/github/src/settings/hooks.ts +87 -0
  293. package/app/apps/github/src/settings/org-settings.tsx +228 -0
  294. package/app/apps/github/src/settings/orgs.ts +116 -0
  295. package/app/apps/github/src/settings/rule-list.tsx +72 -0
  296. package/app/apps/github/src/settings/rules.ts +27 -0
  297. package/app/apps/github/src/settings/settings-layout.tsx +114 -0
  298. package/app/apps/github/src/signin/approval.ts +186 -0
  299. package/app/apps/github/src/signin/auth-client.ts +127 -0
  300. package/app/apps/github/src/signin/auth.ts +753 -0
  301. package/app/apps/github/src/signin/avatars.ts +126 -0
  302. package/app/apps/github/src/signin/client-ip.ts +39 -0
  303. package/app/apps/github/src/signin/credentials.ts +26 -0
  304. package/app/apps/github/src/signin/device-code.ts +95 -0
  305. package/app/apps/github/src/signin/device-prompt.ts +125 -0
  306. package/app/apps/github/src/signin/errors.ts +135 -0
  307. package/app/apps/github/src/signin/host-session.ts +68 -0
  308. package/app/apps/github/src/signin/orgs.ts +283 -0
  309. package/app/apps/github/src/signin/owner-names.ts +183 -0
  310. package/app/apps/github/src/signin/person-lock.ts +104 -0
  311. package/app/apps/github/src/signin/seal.ts +88 -0
  312. package/app/apps/github/src/signin/seed-people.ts +92 -0
  313. package/app/apps/github/src/signin/session.ts +48 -0
  314. package/app/apps/github/src/signin/unborn.ts +110 -0
  315. package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
  316. package/app/apps/github/src/signin/viewer.ts +74 -0
  317. package/app/apps/github/src/signin/with-headers.ts +14 -0
  318. package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
  319. package/app/apps/github/src/tokens/tokens.ts +54 -0
  320. package/app/apps/github/tsconfig.json +25 -0
  321. package/app/apps/github/tsconfig.worker.json +24 -0
  322. package/app/apps/github/vite.config.ts +21 -0
  323. package/app/pnpm-workspace.yaml +216 -0
  324. package/app/tsconfig.base.json +127 -0
  325. package/dist/LICENSE +202 -0
  326. package/dist/cli/child.mjs +42 -0
  327. package/dist/cli/commands.mjs +23 -0
  328. package/dist/cli/credentials.mjs +84 -0
  329. package/dist/cli/documents.mjs +214 -0
  330. package/dist/cli/events.mjs +55 -0
  331. package/dist/cli/failure.mjs +105 -0
  332. package/dist/cli/folders.mjs +32 -0
  333. package/dist/cli/git-remote-ref0.d.mts +1 -0
  334. package/dist/cli/git-remote-ref0.mjs +29 -0
  335. package/dist/cli/git.mjs +48 -0
  336. package/dist/cli/helpers.mjs +51 -0
  337. package/dist/cli/hosts.mjs +127 -0
  338. package/dist/cli/node.mjs +15 -0
  339. package/dist/cli/output.mjs +135 -0
  340. package/dist/cli/prompt.mjs +35 -0
  341. package/dist/cli/queue.mjs +215 -0
  342. package/dist/cli/ref0-git.d.mts +1 -0
  343. package/dist/cli/ref0-git.mjs +144 -0
  344. package/dist/cli/repos.mjs +162 -0
  345. package/dist/cli/resources.mjs +131 -0
  346. package/dist/cli/run-end.mjs +57 -0
  347. package/dist/cli/runtime.mjs +50 -0
  348. package/dist/cli/setup.mjs +1410 -0
  349. package/dist/cli/sign-in.mjs +162 -0
  350. package/dist/cli/sign-ins.mjs +79 -0
  351. package/dist/cli/sqlite.mjs +28 -0
  352. package/dist/cli/tokens.mjs +141 -0
  353. package/dist/cli/vendor.mjs +123 -0
  354. package/dist/init/app.mjs +231 -0
  355. package/dist/init/astro.mjs +49 -0
  356. package/dist/init/choices.mjs +497 -0
  357. package/dist/init/cloudflare.mjs +324 -0
  358. package/dist/init/create.mjs +151 -0
  359. package/dist/init/detect.mjs +297 -0
  360. package/dist/init/files.mjs +75 -0
  361. package/dist/init/frameworks.mjs +248 -0
  362. package/dist/init/git-module.mjs +49 -0
  363. package/dist/init/github-routes.mjs +66 -0
  364. package/dist/init/jsonc.mjs +143 -0
  365. package/dist/init/metadata.mjs +48 -0
  366. package/dist/init/mounts.mjs +109 -0
  367. package/dist/init/next.mjs +205 -0
  368. package/dist/init/node-app.mjs +189 -0
  369. package/dist/init/node.mjs +458 -0
  370. package/dist/init/nuxt.mjs +115 -0
  371. package/dist/init/output.mjs +21 -0
  372. package/dist/init/plan.mjs +82 -0
  373. package/dist/init/range-major.mjs +257 -0
  374. package/dist/init/react-router.mjs +59 -0
  375. package/dist/init/routes.mjs +148 -0
  376. package/dist/init/shell.mjs +4 -0
  377. package/dist/init/stores.mjs +51 -0
  378. package/dist/init/sveltekit.mjs +139 -0
  379. package/dist/init/template.mjs +142 -0
  380. package/dist/init/templates.mjs +343 -0
  381. package/dist/init/vercel.mjs +383 -0
  382. package/dist/init/versions.mjs +32 -0
  383. package/dist/init/workspace.mjs +20 -0
  384. package/package.json +48 -6
  385. package/README.md +0 -5
@@ -0,0 +1,84 @@
1
+ import { gitRun } from "./git.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Redacted from "effect/Redacted";
4
+ import * as Data from "effect/Data";
5
+ // src/cli/credentials.ts
6
+ /**
7
+ * Git's credential protocol, as `git-remote-ref0` and `ref0-git` speak it: `git credential fill`,
8
+ * `approve` and `reject` with a URL and, to store, a credential. Git keeps the secret in its
9
+ * configured helpers, so Git and both bins share one store. Each secret goes to a child's stdin,
10
+ * never its arguments, and nothing here prints it.
11
+ */
12
+ /** Each signal a bin catches, with the status a shell gives a process it ends. */
13
+ const signals = [
14
+ ["SIGHUP", 129],
15
+ ["SIGINT", 130],
16
+ ["SIGTERM", 143]
17
+ ];
18
+ /** Whether `value` holds a character that would end a credential field or the input. */
19
+ const breaksField = (value) => /[\r\n\0]/.test(value);
20
+ /** A credential field that holds a character that would end it, which no input carries. */
21
+ var BrokenField = class extends Data.TaggedError("BrokenField") {};
22
+ /**
23
+ * `git credential <action>`'s input for `url`, and the credential when there's one. A value
24
+ * holding a newline would start a field of its own, as `host=` to store it for another host, so
25
+ * it fails as `BrokenField` rather than write it.
26
+ */
27
+ const credentialInput = (url, credential) => {
28
+ const lines = [`url=${url.href}`];
29
+ const password = credential === void 0 ? "" : Redacted.value(credential.password);
30
+ const values = credential === void 0 ? [] : [credential.username, password];
31
+ if ([url.href, ...values].some(breaksField)) return Effect.fail(new BrokenField());
32
+ if (credential !== void 0) {
33
+ lines.push(`username=${credential.username}`, `password=${password}`);
34
+ if (credential.expiresAt !== void 0) lines.push(`password_expiry_utc=${Math.floor(credential.expiresAt / 1e3)}`);
35
+ }
36
+ return Effect.succeed(`${lines.join("\n")}\n\n`);
37
+ };
38
+ /** The `name=value` fields `git credential fill` printed. */
39
+ const fieldsOf = (text) => new Map(text.split("\n").flatMap((line) => {
40
+ const at = line.indexOf("=");
41
+ return at === -1 ? [] : [[line.slice(0, at), line.slice(at + 1)]];
42
+ }));
43
+ /**
44
+ * The credential Git's helpers keep for `url`, or `undefined` when none does. With `ask`, Git may
45
+ * ask at the terminal, as it does for a push; without, it never does.
46
+ */
47
+ const fillCredential = Effect.fnUntraced(function* (url, options = {}) {
48
+ const input = yield* credentialInput(url);
49
+ const ran = yield* gitRun(options.ask === true ? ["credential", "fill"] : [
50
+ "-c",
51
+ "credential.interactive=false",
52
+ "credential",
53
+ "fill"
54
+ ], options.ask === true ? {
55
+ input,
56
+ stderr: "inherit"
57
+ } : {
58
+ input,
59
+ env: {
60
+ GIT_TERMINAL_PROMPT: "0",
61
+ GIT_ASKPASS: "",
62
+ SSH_ASKPASS: ""
63
+ }
64
+ });
65
+ const said = fieldsOf(ran.status === 0 ? ran.stdout : "");
66
+ const username = said.get("username");
67
+ const password = said.get("password");
68
+ return username === void 0 || password === void 0 || password === "" ? void 0 : {
69
+ username,
70
+ password: Redacted.make(password)
71
+ };
72
+ });
73
+ /** Stores `credential` for `url` in each of Git's helpers. */
74
+ const approveCredential = Effect.fnUntraced(function* (url, credential) {
75
+ yield* gitRun(["credential", "approve"], {
76
+ input: yield* credentialInput(url, credential),
77
+ keepStarted: true
78
+ });
79
+ });
80
+ /** Removes `credential`, or whatever is kept for `url` with none, from each of Git's helpers. */
81
+ const rejectCredential = Effect.fnUntraced(function* (url, credential) {
82
+ yield* gitRun(["credential", "reject"], { input: yield* credentialInput(url, credential) });
83
+ });
84
+ export { BrokenField, approveCredential, breaksField, fillCredential, rejectCredential, signals };
@@ -0,0 +1,214 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Schema from "effect/Schema";
3
+ import * as SchemaGetter from "effect/SchemaGetter";
4
+ import * as SchemaIssue from "effect/SchemaIssue";
5
+ // src/cli/documents.ts
6
+ /**
7
+ * The CLI's contracts: the `--json` documents it writes itself, and the inputs a person types or
8
+ * pipes in, each read through its Schema. A document's fields are in the order it prints them,
9
+ * since a Struct encodes in its own order. The REST answers `--json` prints keep REST's shape.
10
+ */
11
+ /**
12
+ * A host: its endpoint, the URL Git and its REST API answer under, as `https://git.acme.dev/git`,
13
+ * and its origin, where sign-in is served and which Git's helpers key its one token by.
14
+ */
15
+ const Host = Schema.Struct({
16
+ endpoint: Schema.String,
17
+ origin: Schema.String
18
+ });
19
+ /** A scheme, as `https://` starts a URL. */
20
+ const schemed = /^[a-z][a-z0-9+.-]*:\/\//i;
21
+ /**
22
+ * `text` as a `Host`: `https://` unless it names another scheme, as `localhost:5173` or a test's
23
+ * `http://127.0.0.1:…` does, with its path as the endpoint's, trailing slashes taken off, so a host
24
+ * at the root is its origin alone. A query, a fragment, a credential or an empty segment is none.
25
+ */
26
+ const hostIn = (text) => {
27
+ const given = schemed.test(text) ? text : `https://${text}`;
28
+ const url = URL.parse(given);
29
+ if (url === null || url.protocol !== "https:" && url.protocol !== "http:") return void 0;
30
+ if (url.username !== "" || url.password !== "" || /[?#]/.test(given)) return void 0;
31
+ const path = url.pathname.replace(/\/+$/, "");
32
+ return path.includes("//") ? void 0 : {
33
+ endpoint: `${url.origin}${path}`,
34
+ origin: url.origin
35
+ };
36
+ };
37
+ /** A host as a person names it, or as `ref0-git.host` records it: its endpoint is its encoding. */
38
+ const HostInput = Schema.String.pipe(Schema.decodeTo(Host, {
39
+ decode: SchemaGetter.transformEffect((text) => {
40
+ const host = hostIn(text);
41
+ return host === void 0 ? Effect.fail(new SchemaIssue.InvalidValue({ message: "isn't a host" }, text)) : Effect.succeed(host);
42
+ }),
43
+ encode: SchemaGetter.transform((host) => host.endpoint)
44
+ }));
45
+ /** A unit's milliseconds. */
46
+ const unitMs = /* @__PURE__ */ new Map([
47
+ ["s", 1e3],
48
+ ["m", 6e4],
49
+ ["h", 36e5],
50
+ ["d", 864e5]
51
+ ]);
52
+ const durationText = /^([1-9][0-9]{0,8})([smhd])$/;
53
+ /** A duration flag's value, as `30s`, `30m`, `12h` or `30d`, read as its milliseconds. */
54
+ const DurationInput = Schema.String.pipe(Schema.check(Schema.isPattern(durationText)), Schema.decodeTo(Schema.Int, {
55
+ decode: SchemaGetter.transform((text) => {
56
+ const [, count = "", unit = "s"] = durationText.exec(text) ?? [];
57
+ return Number(count) * (unitMs.get(unit) ?? 1e3);
58
+ }),
59
+ encode: SchemaGetter.forbidden(() => "A duration is only read")
60
+ }));
61
+ /** The token on stdin, with its one trailing newline taken off: one line, and never empty. */
62
+ const TokenInput = Schema.String.pipe(Schema.decodeTo(Schema.String.pipe(Schema.check(Schema.makeFilter((token) => token !== "" || "No token on stdin"), Schema.makeFilter((token) => !/[\r\n]/.test(token) || "The token on stdin spans more than one line"))), {
63
+ decode: SchemaGetter.transform((text) => text.replace(/\r?\n$/, "")),
64
+ encode: SchemaGetter.transform((token) => `${token}\n`)
65
+ }), Schema.decodeTo(Schema.RedactedFromValue(Schema.String)));
66
+ /** A next step's command, as its argv and as a person pastes it, with what it reads on stdin. */
67
+ const StepCommand = Schema.Struct({
68
+ line: Schema.String,
69
+ argv: Schema.Array(Schema.String),
70
+ stdin: Schema.optional(Schema.Struct({ env: Schema.String }))
71
+ });
72
+ /** A next step as the documents carry it: what it does, then its commands. */
73
+ const NextStepDocument = Schema.Struct({
74
+ says: Schema.String,
75
+ run: Schema.Array(StepCommand)
76
+ });
77
+ const Lifecycle = Schema.Literals([
78
+ "stable",
79
+ "experimental",
80
+ "beta"
81
+ ]);
82
+ /** An argument or a flag, as help lists it. */
83
+ const HelpEntry = Schema.Struct({
84
+ name: Schema.String,
85
+ description: Schema.optional(Schema.String),
86
+ required: Schema.Boolean
87
+ });
88
+ /** Help as `--help --json` prints it: the command, its arguments, flags and subcommands. */
89
+ const HelpDocument = Schema.Struct({
90
+ command: Schema.String,
91
+ description: Schema.String,
92
+ lifecycle: Lifecycle,
93
+ usage: Schema.String,
94
+ arguments: Schema.Array(HelpEntry),
95
+ flags: Schema.Array(HelpEntry),
96
+ commands: Schema.Array(Schema.Struct({
97
+ name: Schema.String,
98
+ description: Schema.String,
99
+ lifecycle: Lifecycle
100
+ }))
101
+ });
102
+ /** One check `doctor` ran, and whether it passed. */
103
+ const FindingDocument = Schema.Struct({
104
+ check: Schema.String,
105
+ ok: Schema.Boolean,
106
+ says: Schema.String,
107
+ blocks: Schema.optional(Schema.String)
108
+ });
109
+ /**
110
+ * A failed run's one document, on stderr: the `cli-design` skill's error document. Its `data` is
111
+ * what the failure carries, as a list's rows read before it, or `doctor`'s findings.
112
+ */
113
+ const FailureDocument = Schema.Struct({
114
+ status: Schema.Literals(["action_required", "error"]),
115
+ reason: Schema.String,
116
+ message: Schema.String,
117
+ nextStep: Schema.optional(NextStepDocument),
118
+ data: Schema.optional(Schema.Unknown)
119
+ });
120
+ /** A settled choice: its answer, where it came from, and why. */
121
+ const SettledDocument = Schema.Struct({
122
+ value: Schema.String,
123
+ from: Schema.Literals([
124
+ "flag",
125
+ "detected",
126
+ "recommended",
127
+ "prompt"
128
+ ]),
129
+ detectedFrom: Schema.optional(Schema.String),
130
+ because: Schema.optional(Schema.String),
131
+ moved: Schema.optional(Schema.String)
132
+ });
133
+ /** A file `init` plans, as `--json` shows it: its action, and what it writes or would. */
134
+ const PlannedFile = Schema.Struct({
135
+ path: Schema.String,
136
+ action: Schema.Literals([
137
+ "create",
138
+ "merge",
139
+ "edit",
140
+ "unchanged",
141
+ "replace",
142
+ "differs"
143
+ ]),
144
+ secrets: Schema.optional(Schema.Array(Schema.String)),
145
+ content: Schema.optional(Schema.String),
146
+ patch: Schema.optional(Schema.String),
147
+ adds: Schema.optional(Schema.Array(Schema.Struct({
148
+ at: Schema.Array(Schema.String),
149
+ raw: Schema.String
150
+ }))),
151
+ edit: Schema.optional(Schema.Struct({
152
+ anchor: Schema.String,
153
+ adds: Schema.Array(Schema.String),
154
+ swaps: Schema.Array(Schema.Struct({
155
+ from: Schema.String,
156
+ to: Schema.String
157
+ }))
158
+ }))
159
+ });
160
+ /** `init`'s receipt as `--json` prints it, and as its failures carry it. */
161
+ const InitDocument = Schema.Struct({
162
+ folder: Schema.String,
163
+ project: Schema.Literals(["new", "existing"]),
164
+ dryRun: Schema.Boolean,
165
+ moves: Schema.Array(Schema.String),
166
+ choices: Schema.Record(Schema.String, Schema.NullOr(SettledDocument)),
167
+ files: Schema.Array(PlannedFile),
168
+ manual: Schema.Array(Schema.Struct({
169
+ path: Schema.String,
170
+ why: Schema.Literals(["yours", "template_changed"]),
171
+ says: Schema.String,
172
+ lines: Schema.Array(Schema.String)
173
+ })),
174
+ needs: Schema.Array(Schema.String),
175
+ create: Schema.optional(Schema.Struct({
176
+ command: Schema.Struct({
177
+ line: Schema.String,
178
+ argv: Schema.Array(Schema.String)
179
+ }),
180
+ exit: Schema.NullOr(Schema.Number)
181
+ })),
182
+ install: Schema.Struct({
183
+ manager: Schema.String,
184
+ packages: Schema.Array(Schema.String),
185
+ ran: Schema.Boolean
186
+ }),
187
+ nextStep: NextStepDocument
188
+ });
189
+ /** `doctor`'s document when every check passed, with the step to deploy. */
190
+ const DoctorDocument = Schema.Struct({
191
+ ready: Schema.Literal(true),
192
+ findings: Schema.Array(FindingDocument),
193
+ nextStep: NextStepDocument
194
+ });
195
+ /** `doctor --verify`'s document: the scratch repo's steps on the host, and what it found left. */
196
+ const VerifyDocument = Schema.Struct({
197
+ host: Schema.String,
198
+ repo: Schema.String,
199
+ steps: Schema.Array(Schema.String),
200
+ leftovers: Schema.Array(Schema.String)
201
+ });
202
+ /** `logout`'s document: the host it signed out of, if any, and whether a token was removed. */
203
+ const LogoutDocument = Schema.Struct({
204
+ host: Schema.NullOr(Schema.String),
205
+ removed: Schema.Boolean
206
+ });
207
+ /** Each document's encoder, to its JSON text on one line. */
208
+ const helpJson = Schema.encodeSync(Schema.fromJsonString(HelpDocument));
209
+ const failureJson = Schema.encodeSync(Schema.fromJsonString(FailureDocument));
210
+ const initJson = Schema.encodeSync(Schema.fromJsonString(InitDocument));
211
+ const doctorJson = Schema.encodeSync(Schema.fromJsonString(DoctorDocument));
212
+ const verifyJson = Schema.encodeSync(Schema.fromJsonString(VerifyDocument));
213
+ const logoutJson = Schema.encodeSync(Schema.fromJsonString(LogoutDocument));
214
+ export { DoctorDocument, DurationInput, FailureDocument, FindingDocument, HelpDocument, Host, HostInput, InitDocument, LogoutDocument, NextStepDocument, TokenInput, VerifyDocument, doctorJson, failureJson, helpJson, initJson, logoutJson, verifyJson };
@@ -0,0 +1,55 @@
1
+ import { failure, refused } from "./failure.mjs";
2
+ import { hostFlag } from "./hosts.mjs";
3
+ import { printable, streamed } from "./output.mjs";
4
+ import { called, durationOf, repoArgument } from "./resources.mjs";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Option from "effect/Option";
7
+ import * as Predicate from "effect/Predicate";
8
+ import * as Command from "effect/cli/Command";
9
+ import * as Flag from "effect/cli/Flag";
10
+ // src/cli/events.ts
11
+ /**
12
+ * `events listen`: a repo's events over REST's stream, from the oldest it keeps, each one that
13
+ * matches printed as a JSON line on stdout. It ends after the first by default, after `--count`,
14
+ * or never with `--follow`; a `--timeout` that passes first fails it, reason `timeout`.
15
+ */
16
+ /** Whether `event` names `entry`: as its own, or among a candidate's. */
17
+ const namesEntry = (event, entry) => Predicate.hasProperty(event, "entry") && event.entry === entry || Predicate.hasProperty(event, "entries") && Array.isArray(event.entries) && event.entries.includes(entry);
18
+ const listen = Command.make("listen", {
19
+ repo: repoArgument,
20
+ host: hostFlag,
21
+ event: Flag.String("event").pipe(Flag.withDescription("Only these types, split by commas, as queue.entry.merged"), Flag.withMetavar("TYPE"), Flag.optional),
22
+ entry: Flag.String("entry").pipe(Flag.withDescription("Only this queue entry's events"), Flag.withMetavar("ENTRY"), Flag.optional),
23
+ count: Flag.Int("count").pipe(Flag.withDescription("End after this many events: 1 when it is left out"), Flag.withMetavar("NUMBER"), Flag.withDefault(1)),
24
+ follow: Flag.Boolean("follow").pipe(Flag.withDescription("Never end on a count: print each event until stopped"), Flag.withDefault(false)),
25
+ timeout: Flag.String("timeout").pipe(Flag.withDescription("Fail if the events have not all come by then, as 30s or 30m"), Flag.withMetavar("DURATION"), Flag.optional)
26
+ }, Effect.fnUntraced(function* (flags) {
27
+ const types = Option.map(flags.event, (list) => new Set(list.split(",").map((t) => t.trim())));
28
+ const entry = Option.getOrUndefined(flags.entry);
29
+ const within = Option.isSome(flags.timeout) ? yield* durationOf("timeout", flags.timeout.value) : void 0;
30
+ const matches = (event) => Option.match(types, {
31
+ onNone: () => true,
32
+ onSome: (set) => set.has(event.type)
33
+ }) && (entry === void 0 || namesEntry(event, entry));
34
+ const reading = Effect.gen(function* () {
35
+ const opened = yield* called(flags.host, (client, signal) => client.events.listen(flags.repo, { signal }));
36
+ const reader = yield* Effect.acquireRelease(Effect.sync(() => opened.value.getReader()), (held) => Effect.promise(() => held.cancel().catch(() => void 0)));
37
+ let left = flags.follow ? Number.POSITIVE_INFINITY : Math.max(flags.count, 1);
38
+ while (left > 0) {
39
+ const read = yield* Effect.tryPromise({
40
+ try: () => reader.read(),
41
+ catch: (error) => Predicate.hasProperty(error, "code") ? refused(error, opened.host) : failure("unreachable", `Lost ${opened.host}'s event stream`)
42
+ });
43
+ if (read.done) return yield* failure("stream_closed", `${printable(flags.repo)} was deleted before the events came`);
44
+ if (!matches(read.value)) continue;
45
+ if (!(yield* streamed(read.value))) return;
46
+ left -= 1;
47
+ }
48
+ }).pipe(Effect.scoped);
49
+ yield* within === void 0 ? reading : Effect.timeoutOrElse(reading, {
50
+ duration: within,
51
+ orElse: () => Effect.fail(failure("timeout", `No matching event came within ${Option.getOrElse(flags.timeout, () => "")}`))
52
+ });
53
+ })).pipe(Command.withDescription("Print a repo's events as JSON lines, ending after the first"));
54
+ const eventsCommand = Command.make("events").pipe(Command.withDescription("A repo's events, as they're written (experimental)"), Command.withSubcommands([listen]));
55
+ export { eventsCommand };
@@ -0,0 +1,105 @@
1
+ import { printable } from "./output.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Data from "effect/Data";
4
+ import * as Predicate from "effect/Predicate";
5
+ // src/cli/failure.ts
6
+ const exitCodes = {
7
+ usage: 2,
8
+ failed: 1,
9
+ cancelled: 130
10
+ };
11
+ var CliFailure = class extends Data.TaggedError("CliFailure") {};
12
+ /** What a cancelled run may have left, which its `Canceled` says: set by a command's clean-up. */
13
+ const cancelled = {};
14
+ /**
15
+ * What this run made and couldn't remove, or moved and couldn't put back, recorded where it
16
+ * happens and said once at the run's end, after its fiber is done: no Effect waits on stderr for
17
+ * it, so a cancel can neither hang on the warning nor skip it.
18
+ */
19
+ const leftovers = [];
20
+ /** Records `path` as left, with `error`'s words, at once: what the run did still stands. */
21
+ const leftBehind = (path, error) => Effect.sync(() => {
22
+ leftovers.push({
23
+ path,
24
+ says: `which it couldn't remove: ${error.message}`
25
+ });
26
+ });
27
+ /** Takes back what was recorded at `path`, once what it named is dealt with. */
28
+ const forget = (path) => Effect.sync(() => {
29
+ const kept = leftovers.filter((each) => each.path !== path);
30
+ leftovers.splice(0, leftovers.length, ...kept);
31
+ });
32
+ /**
33
+ * Records a destination vendor/ couldn't put back as it was: its old bytes where they're kept, or
34
+ * the tarball this run put there, with `error`'s words.
35
+ */
36
+ const notPutBack = (stranded, error) => Effect.sync(() => {
37
+ leftovers.push(stranded.kept === void 0 ? {
38
+ path: stranded.to,
39
+ says: `which it put there and couldn't take back: ${error.message}`
40
+ } : {
41
+ path: stranded.kept,
42
+ says: `the old bytes of ${stranded.to}, which it couldn't put back: ${error.message}`
43
+ });
44
+ });
45
+ const stepOf = (next) => Predicate.isString(next) ? {
46
+ says: next,
47
+ run: []
48
+ } : next;
49
+ const usageFailure = (reason, headline, next) => new CliFailure({
50
+ class: "usage",
51
+ reason,
52
+ headline,
53
+ next: stepOf(next)
54
+ });
55
+ const failure = (reason, headline, next, findings) => new CliFailure({
56
+ class: "failed",
57
+ reason,
58
+ headline,
59
+ next: stepOf(next),
60
+ findings
61
+ });
62
+ /**
63
+ * A file system's failure as the CLI's: what it was doing, then the system's own words, which name
64
+ * the path and why, as a permission refused or a disk full. It's the disk's, so it exits 1.
65
+ */
66
+ const diskFailed = (doing) => (error) => failure("disk_failed", `Couldn't ${doing}: ${printable(error.message)}`, "Check the folder's permissions and free space, then run it again");
67
+ /**
68
+ * A credential holding a line break, which Git's credential input can't carry without starting a
69
+ * field of its own, as `host=` would store it for another host.
70
+ */
71
+ const unsafeCredential = (host) => failure("unsafe_credential", `${host} answered with a name or token that holds a line break`, "Check the host, then sign in again");
72
+ /** `NOT_ALLOWED`, `MissingArgument` or `no-such-repo` as a reason: snake_case. */
73
+ const snakeCase = (code) => code.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replaceAll("-", "_").toLowerCase();
74
+ /** Each REST refusal's next step where the host gave none, by its code, for the host it's from. */
75
+ const nextSteps = {
76
+ UNAUTHENTICATED: (host) => ({
77
+ says: "Sign in again",
78
+ run: [["login", host]]
79
+ }),
80
+ NOT_ALLOWED: (host) => ({
81
+ says: "If a token can't do this, sign in with the host's own credential",
82
+ run: [[
83
+ "login",
84
+ host,
85
+ "--with-token"
86
+ ]]
87
+ })
88
+ };
89
+ /**
90
+ * A REST refusal: its message, its `context.reason` or else its code as the reason, and its hint or
91
+ * else the code's next step. Even `INVALID_ARGUMENT` refuses what was asked, so it exits 1.
92
+ */
93
+ const refused = (error, host) => {
94
+ const reason = Predicate.hasProperty(error.context, "reason") && Predicate.isString(error.context.reason) ? printable(error.context.reason) : error.code;
95
+ return failure(snakeCase(reason), error.message, error.hint ?? nextSteps[error.code]?.(host));
96
+ };
97
+ /**
98
+ * A call's answer, or its refusal as the CLI's failure. The call gets the run's abort signal, so
99
+ * a cancel stops its request.
100
+ */
101
+ const answered = (host, call) => Effect.flatMap(Effect.tryPromise({
102
+ try: call,
103
+ catch: () => failure("unreachable", `Couldn't reach ${host}`)
104
+ }), (result) => result.kind === "error" ? Effect.fail(refused(result.error, host)) : Effect.succeed(result.value));
105
+ export { CliFailure, answered, cancelled, diskFailed, exitCodes, failure, forget, leftBehind, leftovers, notPutBack, refused, snakeCase, unsafeCredential, usageFailure };
@@ -0,0 +1,32 @@
1
+ import { node } from "./node.mjs";
2
+ import * as Layer from "effect/Layer";
3
+ import * as Context from "effect/Context";
4
+ // src/cli/folders.ts
5
+ /**
6
+ * A folder as `init`'s planners read it: synchronously, as `FolderView` is, at whatever paths they
7
+ * choose, so the CLI can't read them ahead. Commands take it as a service, so a test gives them
8
+ * another; once `init/` reads through Effects, `FolderView` becomes one and this goes (D12).
9
+ */
10
+ var Folders = class extends Context.Service()("ref0-git/cli/Folders") {};
11
+ const { fs } = node;
12
+ /**
13
+ * Whether `path` under `folder` goes through a link, at any part of it: `init` reads and writes
14
+ * only the folder's own files, so a supplied repo can't point one at a file outside it.
15
+ */
16
+ const linked = (folder, path) => path.split("/").map((_, at, parts) => `${folder}/${parts.slice(0, at + 1).join("/")}`).some((each) => fs.lstatSync(each, { throwIfNoEntry: false })?.isSymbolicLink() === true);
17
+ const viewOf = (folder, userAgent) => ({
18
+ name: folder.split("/").filter(Boolean).at(-1) ?? folder,
19
+ entries: fs.existsSync(folder) ? fs.readdirSync(folder) : [],
20
+ read: (path) => {
21
+ const file = `${folder}/${path}`;
22
+ return !linked(folder, path) && fs.existsSync(file) && fs.statSync(file).isFile() ? fs.readFileSync(file, "utf8") : void 0;
23
+ },
24
+ isFolder: (path) => {
25
+ const at = `${folder}/${path}`;
26
+ return !linked(folder, path) && fs.existsSync(at) && fs.statSync(at).isDirectory();
27
+ },
28
+ userAgent
29
+ });
30
+ /** `Folders` over Node's file system. */
31
+ const layer = Layer.succeed(Folders, { view: viewOf });
32
+ export { Folders, layer };
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { approveCredential, fillCredential, rejectCredential } from "./credentials.mjs";
3
+ import { layer } from "./runtime.mjs";
4
+ import { runRemoteHelper } from "@ref0/git/remote-helper";
5
+ import * as Effect from "effect/Effect";
6
+ import * as ManagedRuntime from "effect/ManagedRuntime";
7
+ import * as Redacted from "effect/Redacted";
8
+ // src/cli/git-remote-ref0.ts
9
+ /**
10
+ * `git-remote-ref0`: the library's helper, over Git's credential helpers, its secret unwrapped
11
+ * only to hand it over. The helper takes Promises, so this bin's edge runs the credential Effects
12
+ * on one runtime (D12).
13
+ */
14
+ const runtime = ManagedRuntime.make(layer);
15
+ await runRemoteHelper({
16
+ fill: (url) => runtime.runPromise(fillCredential(url, { ask: true }).pipe(Effect.map((credential) => credential === void 0 ? void 0 : {
17
+ ...credential,
18
+ password: Redacted.value(credential.password)
19
+ }))),
20
+ approve: (url, credential) => runtime.runPromise(approveCredential(url, {
21
+ ...credential,
22
+ password: Redacted.make(credential.password)
23
+ })),
24
+ reject: (url, credential) => runtime.runPromise(rejectCredential(url, {
25
+ ...credential,
26
+ password: Redacted.make(credential.password)
27
+ }))
28
+ });
29
+ export {};
@@ -0,0 +1,48 @@
1
+ import { stopMs } from "./child.mjs";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Stream from "effect/Stream";
4
+ import * as ChildProcess from "effect/process/ChildProcess";
5
+ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
6
+ // src/cli/git.ts
7
+ const notRun = {
8
+ status: null,
9
+ stdout: "",
10
+ stderr: ""
11
+ };
12
+ /** A stream's bytes as text. */
13
+ const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
14
+ /**
15
+ * `git <args>` in `cwd`, given `input` on its stdin, with its stdout kept. Its stderr is kept too,
16
+ * so Git's own messages stay out of the CLI's streams and a caller says what failed in its own
17
+ * words, unless `stderr` is `'inherit'`, as when Git may ask at the terminal. An interrupt ends
18
+ * the child with SIGTERM, and SIGKILL if it hasn't stopped within `stopMs`. git runs in a process
19
+ * group of its own, which is ended with it, so nothing it starts outlives it, unless `keepStarted`
20
+ * and git exits 0: then what it started, as `cache`'s daemon, keeps running.
21
+ */
22
+ const gitRun = Effect.fnUntraced(function* (args, options = {}) {
23
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
24
+ const command = ChildProcess.make("git", args, {
25
+ cwd: options.cwd,
26
+ env: { ...options.env },
27
+ extendEnv: true,
28
+ stdin: Stream.make(new TextEncoder().encode(options.input ?? "")),
29
+ stdout: "pipe",
30
+ stderr: options.stderr ?? "pipe",
31
+ forceKillAfter: stopMs
32
+ });
33
+ return yield* Effect.scoped(Effect.gen(function* () {
34
+ const child = yield* spawner.spawn(command);
35
+ const [stdout, stderr, status] = yield* Effect.all([
36
+ textOf(child.stdout),
37
+ options.stderr === "inherit" ? Effect.succeed("") : textOf(child.stderr),
38
+ child.exitCode
39
+ ], { concurrency: "unbounded" });
40
+ if (options.keepStarted === true && status === 0) yield* Effect.ignore(child.unref);
41
+ return {
42
+ status,
43
+ stdout,
44
+ stderr
45
+ };
46
+ })).pipe(Effect.catch(() => Effect.succeed(notRun)));
47
+ });
48
+ export { gitRun };
@@ -0,0 +1,51 @@
1
+ import { gitRun } from "./git.mjs";
2
+ import { node } from "./node.mjs";
3
+ import * as Effect from "effect/Effect";
4
+ import * as FileSystem from "effect/FileSystem";
5
+ // src/cli/helpers.ts
6
+ /**
7
+ * Which of Git's credential helpers keep a host's secret, as Git itself chooses them: a traced
8
+ * `git credential fill` for a username no helper keeps, so Git asks every helper it would store
9
+ * with, matching each `credential.<url>` section by its own rules, wildcards and resets included.
10
+ */
11
+ /** A helper that writes the secret to a file as plain text. */
12
+ const plaintext = /* @__PURE__ */ new Set(["store"]);
13
+ /** A username no helper keeps, so a `fill` for it runs every helper and finds nothing. */
14
+ const probeUser = "ref0-git-helper-probe";
15
+ /**
16
+ * A helper's name from the command Git's trace says it ran: `git credential-store --file x get`
17
+ * is `store`, as is `/usr/lib/git-core/git-credential-store get`; any other command is itself.
18
+ */
19
+ const helperName = (ran) => {
20
+ const command = ran.replace(/ get$/, "").replaceAll(/["']/g, "");
21
+ const word = command.replace(/^git credential-/, "git-credential-").split(/\s+/)[0] ?? "";
22
+ const program = word.split("/").at(-1) ?? word;
23
+ return program.startsWith("git-credential-") ? program.slice(15) : command;
24
+ };
25
+ /** The helpers Git asks for `origin`'s credential, in order. */
26
+ const credentialHelpers = (origin) => gitRun([
27
+ "-c",
28
+ "credential.interactive=false",
29
+ "credential",
30
+ "fill"
31
+ ], {
32
+ input: `url=${origin}/\nusername=${probeUser}\n\n`,
33
+ env: {
34
+ GIT_TRACE: "1",
35
+ GIT_TERMINAL_PROMPT: "0",
36
+ GIT_ASKPASS: "",
37
+ SSH_ASKPASS: ""
38
+ }
39
+ }).pipe(Effect.map((ran) => [...ran.stderr.matchAll(/trace: run_command: '([^']*(?:'\\[!']'[^']*)* get)'$/gm)].map((match) => helperName((match[1] ?? "").replaceAll(/'\\([!'])'/g, "$1")))));
40
+ const isPlaintext = (helper) => plaintext.has(helper) || /\bgit(?:\s+|-)credential-store\b/.test(helper);
41
+ /** The helper to set up where none is, for this machine's platform. */
42
+ const platformHelpers = /* @__PURE__ */ new Map([["darwin", "osxkeychain"], ["win32", "manager"]]);
43
+ const suggestedHelper = () => platformHelpers.get(node.process.platform) ?? "libsecret";
44
+ /** Whether `program` is on a later `git push`'s `PATH`, which lacks `npx`'s `node_modules/.bin`. */
45
+ const onPath = Effect.fnUntraced(function* (program) {
46
+ const fs = yield* FileSystem.FileSystem;
47
+ const folders = (node.process.env["PATH"] ?? "").split(":").filter((folder) => folder !== "" && !folder.endsWith("/node_modules/.bin"));
48
+ for (const folder of folders) if (yield* fs.exists(`${folder}/${program}`).pipe(Effect.orElseSucceed(() => false))) return true;
49
+ return false;
50
+ });
51
+ export { credentialHelpers, isPlaintext, onPath, suggestedHelper };