ref0-git 0.3.0 → 0.4.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 (210) hide show
  1. package/app/apps/github/.dev.vars.example +2 -1
  2. package/app/apps/github/generated/git-rest.ts +191 -25
  3. package/app/apps/github/generated/routeTree.gen.ts +21 -0
  4. package/app/apps/github/package.json +1 -1
  5. package/app/apps/github/src/branches/branch-list.tsx +8 -4
  6. package/app/apps/github/src/branches/branches.ts +10 -5
  7. package/app/apps/github/src/camo/addresses.ts +120 -0
  8. package/app/apps/github/src/camo/client.ts +125 -0
  9. package/app/apps/github/src/camo/fetch.ts +201 -0
  10. package/app/apps/github/src/camo/lookup.ts +23 -0
  11. package/app/apps/github/src/camo/node.ts +50 -0
  12. package/app/apps/github/src/camo/proxy.ts +116 -0
  13. package/app/apps/github/src/camo/sign-images.ts +307 -0
  14. package/app/apps/github/src/camo/signing.ts +80 -0
  15. package/app/apps/github/src/clients/allowed.ts +111 -18
  16. package/app/apps/github/src/clients/clients.ts +76 -61
  17. package/app/apps/github/src/clients/transport.ts +13 -0
  18. package/app/apps/github/src/code/code-tree.tsx +3 -1
  19. package/app/apps/github/src/code/file-view.tsx +15 -6
  20. package/app/apps/github/src/code/files.ts +26 -19
  21. package/app/apps/github/src/code/go-to-file.tsx +2 -1
  22. package/app/apps/github/src/code/load.ts +41 -23
  23. package/app/apps/github/src/code/markdown-files.ts +13 -2
  24. package/app/apps/github/src/code/ref-pages.ts +14 -5
  25. package/app/apps/github/src/code/ref-switcher.tsx +4 -3
  26. package/app/apps/github/src/code/refs.ts +42 -8
  27. package/app/apps/github/src/code/repo-home.tsx +6 -2
  28. package/app/apps/github/src/code/repo.ts +12 -6
  29. package/app/apps/github/src/code/saved.ts +5 -3
  30. package/app/apps/github/src/code/trees.ts +11 -9
  31. package/app/apps/github/src/components/markdown/markdown.css +6 -0
  32. package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
  33. package/app/apps/github/src/components/owner-card.tsx +3 -1
  34. package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
  35. package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
  36. package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
  37. package/app/apps/github/src/components/signin/device-card.tsx +9 -2
  38. package/app/apps/github/src/components/user-avatar.tsx +2 -1
  39. package/app/apps/github/src/context/context.ts +13 -0
  40. package/app/apps/github/src/diffs/blobs.ts +37 -14
  41. package/app/apps/github/src/diffs/diff-job.ts +53 -0
  42. package/app/apps/github/src/diffs/diff-worker.ts +6 -0
  43. package/app/apps/github/src/diffs/diffing.ts +136 -0
  44. package/app/apps/github/src/diffs/files.ts +4 -3
  45. package/app/apps/github/src/diffs/hunks.tsx +101 -53
  46. package/app/apps/github/src/diffs/patch.ts +20 -11
  47. package/app/apps/github/src/history/commit-diff.ts +10 -5
  48. package/app/apps/github/src/history/commit-list.tsx +3 -1
  49. package/app/apps/github/src/history/commit-page.tsx +4 -2
  50. package/app/apps/github/src/history/history.ts +12 -10
  51. package/app/apps/github/src/hooks/allowed.ts +9 -9
  52. package/app/apps/github/src/hooks/avatars.ts +3 -3
  53. package/app/apps/github/src/hooks/open-counts.ts +5 -4
  54. package/app/apps/github/src/hooks/profiles.ts +26 -12
  55. package/app/apps/github/src/hooks/repos.ts +78 -25
  56. package/app/apps/github/src/inbox/count.ts +30 -29
  57. package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
  58. package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
  59. package/app/apps/github/src/inbox/marks.ts +26 -15
  60. package/app/apps/github/src/inbox/release-tags.ts +7 -6
  61. package/app/apps/github/src/inbox/subjects.ts +5 -4
  62. package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
  63. package/app/apps/github/src/inbox/subscriptions.ts +95 -35
  64. package/app/apps/github/src/inbox/threads.ts +6 -6
  65. package/app/apps/github/src/issues/changes.ts +40 -16
  66. package/app/apps/github/src/issues/counts.ts +8 -5
  67. package/app/apps/github/src/issues/issue-list.tsx +20 -6
  68. package/app/apps/github/src/issues/issue-page.tsx +30 -14
  69. package/app/apps/github/src/issues/issues.ts +195 -46
  70. package/app/apps/github/src/issues/label-dialog.tsx +8 -11
  71. package/app/apps/github/src/issues/labels-page.tsx +35 -3
  72. package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
  73. package/app/apps/github/src/issues/milestones-page.tsx +269 -0
  74. package/app/apps/github/src/issues/new-issue.tsx +3 -1
  75. package/app/apps/github/src/issues/sidebar.tsx +8 -6
  76. package/app/apps/github/src/markdown/README.md +22 -17
  77. package/app/apps/github/src/markdown/context.ts +83 -10
  78. package/app/apps/github/src/markdown/images.ts +3 -2
  79. package/app/apps/github/src/markdown/lookup.ts +9 -8
  80. package/app/apps/github/src/markdown/page-budget.ts +50 -0
  81. package/app/apps/github/src/markdown/patches.ts +74 -32
  82. package/app/apps/github/src/markdown/query.ts +7 -2
  83. package/app/apps/github/src/markdown/remote.ts +106 -0
  84. package/app/apps/github/src/markdown/render.ts +101 -24
  85. package/app/apps/github/src/markdown/texts.ts +43 -0
  86. package/app/apps/github/src/markdown/words-module.d.ts +5 -0
  87. package/app/apps/github/src/markdown/words-plugin.ts +135 -0
  88. package/app/apps/github/src/names/repos.ts +1 -1
  89. package/app/apps/github/src/palette/palette.tsx +7 -4
  90. package/app/apps/github/src/palette/rows.tsx +54 -33
  91. package/app/apps/github/src/palette/server.ts +5 -5
  92. package/app/apps/github/src/palette/targets.ts +1 -0
  93. package/app/apps/github/src/policy.ts +131 -61
  94. package/app/apps/github/src/private-repos.ts +2 -2
  95. package/app/apps/github/src/pulls/compare-page.tsx +6 -3
  96. package/app/apps/github/src/pulls/files-tab.tsx +480 -214
  97. package/app/apps/github/src/pulls/held-summary.ts +178 -0
  98. package/app/apps/github/src/pulls/live.ts +6 -4
  99. package/app/apps/github/src/pulls/merge-box.tsx +17 -10
  100. package/app/apps/github/src/pulls/pull-list.tsx +6 -3
  101. package/app/apps/github/src/pulls/pull-page.tsx +19 -10
  102. package/app/apps/github/src/pulls/pull.ts +68 -40
  103. package/app/apps/github/src/pulls/pulls.ts +39 -22
  104. package/app/apps/github/src/pulls/review-drafts.ts +131 -0
  105. package/app/apps/github/src/pulls/review.ts +374 -99
  106. package/app/apps/github/src/pulls/threads.tsx +152 -0
  107. package/app/apps/github/src/queue/queue-page.tsx +15 -8
  108. package/app/apps/github/src/queue/queue.ts +35 -20
  109. package/app/apps/github/src/releases/latest-release.tsx +3 -1
  110. package/app/apps/github/src/releases/overview.tsx +4 -2
  111. package/app/apps/github/src/releases/release-form.tsx +8 -5
  112. package/app/apps/github/src/releases/release-list.tsx +8 -5
  113. package/app/apps/github/src/releases/release-view.tsx +1 -0
  114. package/app/apps/github/src/releases/releases.ts +33 -23
  115. package/app/apps/github/src/releases/tag-list.tsx +3 -1
  116. package/app/apps/github/src/router.tsx +5 -2
  117. package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
  118. package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
  119. package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
  120. package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
  121. package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
  122. package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
  123. package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
  124. package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
  125. package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
  126. package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
  127. package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
  128. package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
  129. package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
  130. package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
  131. package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
  132. package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
  133. package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
  134. package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
  135. package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
  136. package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
  137. package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
  138. package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
  139. package/app/apps/github/src/routes/-nav.tsx +10 -2
  140. package/app/apps/github/src/routes/-root-testing.ts +29 -6
  141. package/app/apps/github/src/routes/__root.tsx +9 -4
  142. package/app/apps/github/src/routes/index.tsx +3 -1
  143. package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
  144. package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
  145. package/app/apps/github/src/seed/acme.ts +1 -1
  146. package/app/apps/github/src/seed/seed.ts +199 -110
  147. package/app/apps/github/src/server.ts +24 -15
  148. package/app/apps/github/src/settings/account-avatar.tsx +4 -1
  149. package/app/apps/github/src/settings/general-settings.tsx +3 -1
  150. package/app/apps/github/src/settings/general.ts +4 -4
  151. package/app/apps/github/src/settings/hook-form.tsx +3 -1
  152. package/app/apps/github/src/settings/hook-list.tsx +5 -2
  153. package/app/apps/github/src/settings/hooks.ts +7 -7
  154. package/app/apps/github/src/settings/org-settings.tsx +3 -1
  155. package/app/apps/github/src/settings/orgs.ts +21 -11
  156. package/app/apps/github/src/settings/settings-layout.tsx +3 -1
  157. package/app/apps/github/src/signin/approval.ts +4 -3
  158. package/app/apps/github/src/signin/auth.ts +9 -2
  159. package/app/apps/github/src/signin/device-code.ts +8 -3
  160. package/app/apps/github/src/signin/device-prompt.ts +28 -3
  161. package/app/apps/github/src/signin/revoke.ts +36 -0
  162. package/app/apps/github/tsconfig.json +4 -1
  163. package/app/apps/github/vite.config.ts +8 -0
  164. package/app/pnpm-workspace.yaml +9 -5
  165. package/app/tsconfig.base.json +1 -0
  166. package/dist/cli/child.mjs +1 -1
  167. package/dist/cli/credentials.mjs +4 -4
  168. package/dist/cli/documents.mjs +32 -22
  169. package/dist/cli/events.mjs +1 -1
  170. package/dist/cli/failure.mjs +20 -7
  171. package/dist/cli/folders.mjs +2 -2
  172. package/dist/cli/git-remote-ref0.mjs +47 -22
  173. package/dist/cli/git.mjs +1 -1
  174. package/dist/cli/helpers.mjs +2 -2
  175. package/dist/cli/hosts.mjs +3 -3
  176. package/dist/cli/output.mjs +2 -2
  177. package/dist/cli/prompt.mjs +1 -1
  178. package/dist/cli/queue.mjs +7 -7
  179. package/dist/cli/ref0-git.mjs +2 -2
  180. package/dist/cli/repos.mjs +35 -18
  181. package/dist/cli/resources.mjs +5 -5
  182. package/dist/cli/retry-after.mjs +8 -0
  183. package/dist/cli/setup.mjs +172 -66
  184. package/dist/cli/sign-in.mjs +65 -23
  185. package/dist/cli/sign-ins.mjs +4 -4
  186. package/dist/cli/sqlite.mjs +2 -2
  187. package/dist/cli/tokens.mjs +3 -3
  188. package/dist/cli/vendor.mjs +1 -1
  189. package/dist/init/app.mjs +18 -20
  190. package/dist/init/choices.mjs +1 -1
  191. package/dist/init/cloudflare.mjs +15 -19
  192. package/dist/init/create.mjs +3 -2
  193. package/dist/init/detect.mjs +4 -4
  194. package/dist/init/files.mjs +120 -13
  195. package/dist/init/frameworks.mjs +16 -0
  196. package/dist/init/git-module.mjs +22 -7
  197. package/dist/init/jsonc.mjs +9 -7
  198. package/dist/init/metadata.mjs +9 -3
  199. package/dist/init/mounts.mjs +13 -10
  200. package/dist/init/next.mjs +2 -2
  201. package/dist/init/node-app.mjs +3 -3
  202. package/dist/init/node.mjs +42 -45
  203. package/dist/init/nuxt.mjs +153 -27
  204. package/dist/init/stores.mjs +14 -9
  205. package/dist/init/sveltekit.mjs +4 -2
  206. package/dist/init/template.mjs +9 -6
  207. package/dist/init/templates.mjs +63 -47
  208. package/dist/init/vercel.mjs +37 -37
  209. package/dist/init/versions.mjs +3 -3
  210. package/package.json +6 -5
@@ -12,7 +12,7 @@ import * as SchemaIssue from "effect/SchemaIssue";
12
12
  * A host: its endpoint, the URL Git and its REST API answer under, as `https://git.acme.dev/git`,
13
13
  * and its origin, where sign-in is served and which Git's helpers key its one token by.
14
14
  */
15
- const Host = Schema.Struct({
15
+ const Host = /* @__PURE__ */ Schema.Struct({
16
16
  endpoint: Schema.String,
17
17
  origin: Schema.String
18
18
  });
@@ -64,29 +64,29 @@ const TokenInput = Schema.String.pipe(Schema.decodeTo(Schema.String.pipe(Schema.
64
64
  encode: SchemaGetter.transform((token) => `${token}\n`)
65
65
  }), Schema.decodeTo(Schema.RedactedFromValue(Schema.String)));
66
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({
67
+ const StepCommand = /* @__PURE__ */ Schema.Struct({
68
68
  line: Schema.String,
69
69
  argv: Schema.Array(Schema.String),
70
70
  stdin: Schema.optional(Schema.Struct({ env: Schema.String }))
71
71
  });
72
72
  /** A next step as the documents carry it: what it does, then its commands. */
73
- const NextStepDocument = Schema.Struct({
73
+ const NextStepDocument = /* @__PURE__ */ Schema.Struct({
74
74
  says: Schema.String,
75
75
  run: Schema.Array(StepCommand)
76
76
  });
77
- const Lifecycle = Schema.Literals([
77
+ const Lifecycle = /* @__PURE__ */ Schema.Literals([
78
78
  "stable",
79
79
  "experimental",
80
80
  "beta"
81
81
  ]);
82
82
  /** An argument or a flag, as help lists it. */
83
- const HelpEntry = Schema.Struct({
83
+ const HelpEntry = /* @__PURE__ */ Schema.Struct({
84
84
  name: Schema.String,
85
85
  description: Schema.optional(Schema.String),
86
86
  required: Schema.Boolean
87
87
  });
88
88
  /** Help as `--help --json` prints it: the command, its arguments, flags and subcommands. */
89
- const HelpDocument = Schema.Struct({
89
+ const HelpDocument = /* @__PURE__ */ Schema.Struct({
90
90
  command: Schema.String,
91
91
  description: Schema.String,
92
92
  lifecycle: Lifecycle,
@@ -100,7 +100,7 @@ const HelpDocument = Schema.Struct({
100
100
  }))
101
101
  });
102
102
  /** One check `doctor` ran, and whether it passed. */
103
- const FindingDocument = Schema.Struct({
103
+ const FindingDocument = /* @__PURE__ */ Schema.Struct({
104
104
  check: Schema.String,
105
105
  ok: Schema.Boolean,
106
106
  says: Schema.String,
@@ -110,7 +110,7 @@ const FindingDocument = Schema.Struct({
110
110
  * A failed run's one document, on stderr: the `cli-design` skill's error document. Its `data` is
111
111
  * what the failure carries, as a list's rows read before it, or `doctor`'s findings.
112
112
  */
113
- const FailureDocument = Schema.Struct({
113
+ const FailureDocument = /* @__PURE__ */ Schema.Struct({
114
114
  status: Schema.Literals(["action_required", "error"]),
115
115
  reason: Schema.String,
116
116
  message: Schema.String,
@@ -118,7 +118,7 @@ const FailureDocument = Schema.Struct({
118
118
  data: Schema.optional(Schema.Unknown)
119
119
  });
120
120
  /** A settled choice: its answer, where it came from, and why. */
121
- const SettledDocument = Schema.Struct({
121
+ const SettledDocument = /* @__PURE__ */ Schema.Struct({
122
122
  value: Schema.String,
123
123
  from: Schema.Literals([
124
124
  "flag",
@@ -131,7 +131,7 @@ const SettledDocument = Schema.Struct({
131
131
  moved: Schema.optional(Schema.String)
132
132
  });
133
133
  /** A file `init` plans, as `--json` shows it: its action, and what it writes or would. */
134
- const PlannedFile = Schema.Struct({
134
+ const PlannedFile = /* @__PURE__ */ Schema.Struct({
135
135
  path: Schema.String,
136
136
  action: Schema.Literals([
137
137
  "create",
@@ -158,7 +158,7 @@ const PlannedFile = Schema.Struct({
158
158
  }))
159
159
  });
160
160
  /** `init`'s receipt as `--json` prints it, and as its failures carry it. */
161
- const InitDocument = Schema.Struct({
161
+ const InitDocument = /* @__PURE__ */ Schema.Struct({
162
162
  folder: Schema.String,
163
163
  project: Schema.Literals(["new", "existing"]),
164
164
  dryRun: Schema.Boolean,
@@ -187,28 +187,38 @@ const InitDocument = Schema.Struct({
187
187
  nextStep: NextStepDocument
188
188
  });
189
189
  /** `doctor`'s document when every check passed, with the step to deploy. */
190
- const DoctorDocument = Schema.Struct({
190
+ const DoctorDocument = /* @__PURE__ */ Schema.Struct({
191
191
  ready: Schema.Literal(true),
192
192
  findings: Schema.Array(FindingDocument),
193
193
  nextStep: NextStepDocument
194
194
  });
195
- /** `doctor --verify`'s document: the scratch repo's steps on the host, and what it found left. */
196
- const VerifyDocument = Schema.Struct({
195
+ /**
196
+ * `doctor --verify`'s document: the scratch repo's steps on the host, and what it found left, with
197
+ * `more` and the step that lists them all when there were more than it names, or `unlisted` with
198
+ * why the host didn't list them.
199
+ */
200
+ const VerifyDocument = /* @__PURE__ */ Schema.Struct({
197
201
  host: Schema.String,
198
202
  repo: Schema.String,
199
203
  steps: Schema.Array(Schema.String),
200
- leftovers: Schema.Array(Schema.String)
204
+ leftovers: Schema.optionalKey(Schema.Array(Schema.String)),
205
+ more: Schema.optionalKey(Schema.Literal(true)),
206
+ unlisted: Schema.optionalKey(Schema.Struct({
207
+ reason: Schema.String,
208
+ message: Schema.String
209
+ })),
210
+ nextStep: Schema.optionalKey(NextStepDocument)
201
211
  });
202
212
  /** `logout`'s document: the host it signed out of, if any, and whether a token was removed. */
203
- const LogoutDocument = Schema.Struct({
213
+ const LogoutDocument = /* @__PURE__ */ Schema.Struct({
204
214
  host: Schema.NullOr(Schema.String),
205
215
  removed: Schema.Boolean
206
216
  });
207
217
  /** 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));
218
+ const helpJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(HelpDocument));
219
+ const failureJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(FailureDocument));
220
+ const initJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(InitDocument));
221
+ const doctorJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(DoctorDocument));
222
+ const verifyJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(VerifyDocument));
223
+ const logoutJson = /* @__PURE__ */ Schema.encodeSync(Schema.fromJsonString(LogoutDocument));
214
224
  export { DoctorDocument, DurationInput, FailureDocument, FindingDocument, HelpDocument, Host, HostInput, InitDocument, LogoutDocument, NextStepDocument, TokenInput, VerifyDocument, doctorJson, failureJson, helpJson, initJson, logoutJson, verifyJson };
@@ -23,7 +23,7 @@ const listen = Command.make("listen", {
23
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
24
  follow: Flag.Boolean("follow").pipe(Flag.withDescription("Never end on a count: print each event until stopped"), Flag.withDefault(false)),
25
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) {
26
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
27
27
  const types = Option.map(flags.event, (list) => new Set(list.split(",").map((t) => t.trim())));
28
28
  const entry = Option.getOrUndefined(flags.entry);
29
29
  const within = Option.isSome(flags.timeout) ? yield* durationOf("timeout", flags.timeout.value) : void 0;
@@ -1,7 +1,8 @@
1
- import { printable } from "./output.mjs";
1
+ import { printable, say } from "./output.mjs";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Data from "effect/Data";
4
4
  import * as Predicate from "effect/Predicate";
5
+ import * as Duration from "effect/Duration";
5
6
  // src/cli/failure.ts
6
7
  const exitCodes = {
7
8
  usage: 2,
@@ -94,12 +95,24 @@ const refused = (error, host) => {
94
95
  const reason = Predicate.hasProperty(error.context, "reason") && Predicate.isString(error.context.reason) ? printable(error.context.reason) : error.code;
95
96
  return failure(snakeCase(reason), error.message, error.hint ?? nextSteps[error.code]?.(host));
96
97
  };
98
+ /** 250 ms before the first try again, doubling. */
99
+ const tooManyWritesPause = (tried) => Duration.millis(250 * 2 ** tried);
100
+ const wroteNothing = (error) => error.code === "UNAVAILABLE" && Predicate.hasProperty(error.context, "reason") && error.context.reason === "too-many-writes";
97
101
  /**
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.
102
+ * A call's answer, or its refusal as the CLI's failure, sent again on `too-many-writes` at most
103
+ * `tooManyWritesTriesMost` times, each try said on stderr. The call gets the run's abort signal,
104
+ * so a cancel stops its request.
100
105
  */
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));
106
+ const answered = (host, call) => {
107
+ const sent = Effect.tryPromise({
108
+ try: call,
109
+ catch: () => failure("unreachable", `Couldn't reach ${host}`)
110
+ });
111
+ const tried = (tries) => Effect.flatMap(sent, (result) => {
112
+ if (result.kind === "success") return Effect.succeed(result.value);
113
+ if (tries >= 3 || !wroteNothing(result.error)) return Effect.fail(refused(result.error, host));
114
+ return say(`${host} had too many writes at once. Trying again (${tries + 1} of 3)`).pipe(Effect.andThen(Effect.sleep(tooManyWritesPause(tries))), Effect.andThen(tried(tries + 1)));
115
+ });
116
+ return tried(0);
117
+ };
105
118
  export { CliFailure, answered, cancelled, diskFailed, exitCodes, failure, forget, leftBehind, leftovers, notPutBack, refused, snakeCase, unsafeCredential, usageFailure };
@@ -1,13 +1,13 @@
1
1
  import { node } from "./node.mjs";
2
- import * as Layer from "effect/Layer";
3
2
  import * as Context from "effect/Context";
3
+ import * as Layer from "effect/Layer";
4
4
  // src/cli/folders.ts
5
5
  /**
6
6
  * A folder as `init`'s planners read it: synchronously, as `FolderView` is, at whatever paths they
7
7
  * choose, so the CLI can't read them ahead. Commands take it as a service, so a test gives them
8
8
  * another; once `init/` reads through Effects, `FolderView` becomes one and this goes (D12).
9
9
  */
10
- var Folders = class extends Context.Service()("ref0-git/cli/Folders") {};
10
+ var Folders = class extends (/* @__PURE__ */ Context.Service()("ref0-git/cli/Folders")) {};
11
11
  const { fs } = node;
12
12
  /**
13
13
  * Whether `path` under `folder` goes through a link, at any part of it: `init` reads and writes
@@ -1,29 +1,54 @@
1
1
  #!/usr/bin/env node
2
- import { approveCredential, fillCredential, rejectCredential } from "./credentials.mjs";
2
+ import { approveCredential, fillCredential, rejectCredential, signals } from "./credentials.mjs";
3
+ import { node } from "./node.mjs";
3
4
  import { layer } from "./runtime.mjs";
4
- import { runRemoteHelper } from "@ref0/git/remote-helper";
5
+ import * as NodeRuntime from "@effect/platform-node-shared/NodeRuntime";
6
+ import { remoteHelper } from "@ref0/git/remote-helper";
7
+ import * as Cause from "effect/Cause";
8
+ import * as Context from "effect/Context";
5
9
  import * as Effect from "effect/Effect";
6
- import * as ManagedRuntime from "effect/ManagedRuntime";
7
- import * as Redacted from "effect/Redacted";
10
+ import * as Exit from "effect/Exit";
11
+ import * as Runtime from "effect/Runtime";
8
12
  // src/cli/git-remote-ref0.ts
9
13
  /**
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).
14
+ * `git-remote-ref0`: the library's helper, over Git's credential helpers, run by
15
+ * `NodeRuntime.runMain`. It ends 0 once Git's commands end, 128 once it has said what stopped it,
16
+ * or with a shell's status for the signal that stopped it: 129, 130 or 143. A signal interrupts
17
+ * the run, so its spool is closed and removed before the process ends.
13
18
  */
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
- });
19
+ const { process } = node;
20
+ /**
21
+ * Each of `signals` interrupts the run's fiber with its status, while the run's scope is open.
22
+ * Each listener goes before runMain's own, which interrupts with no status: a run whose
23
+ * finalizers end at once would otherwise exit within runMain's, as 130 for a SIGTERM.
24
+ */
25
+ const signalled = Effect.withFiber((fiber) => Effect.acquireRelease(Effect.sync(() => signals.map(([signal, status]) => {
26
+ const stop = () => fiber.interruptUnsafe(fiber.id, Context.make(Runtime.InterruptExitCode, status));
27
+ process.prependListener(signal, stop);
28
+ return () => process.off(signal, stop);
29
+ })), (listening) => Effect.sync(() => listening.forEach((off) => off()))));
30
+ /**
31
+ * The run's status, then the process's end, at 0 too: Git's stdin and a kept-alive socket would
32
+ * keep it running. A signal's status wins over runMain's own interrupt, which names none.
33
+ */
34
+ const ended = (exit, onExit) => {
35
+ const statuses = Exit.isFailure(exit) && Cause.hasInterruptsOnly(exit.cause) ? exit.cause.reasons.flatMap((reason) => {
36
+ const status = Context.getOrUndefined(Cause.reasonAnnotations(reason), Runtime.InterruptExitCode);
37
+ return status === void 0 ? [] : [status];
38
+ }) : [];
39
+ const exited = (status) => {
40
+ onExit(status);
41
+ process.exit(status);
42
+ };
43
+ if (statuses.length > 0) return exited(Math.max(...statuses));
44
+ Runtime.defaultTeardown(exit, exited);
45
+ };
46
+ process.stdout.on("error", () => void 0);
47
+ process.stderr.on("error", () => void 0);
48
+ const run = Effect.andThen(signalled, remoteHelper({
49
+ fill: (url) => fillCredential(url, { ask: true }),
50
+ approve: approveCredential,
51
+ reject: rejectCredential
52
+ }));
53
+ NodeRuntime.runMain(run.pipe(Effect.scoped, Effect.provide(layer)), { teardown: ended });
29
54
  export {};
package/dist/cli/git.mjs CHANGED
@@ -39,7 +39,7 @@ const textUpTo = (stream, most) => Stream.runFoldEffect(stream, () => ({
39
39
  * group of its own, which is ended with it, so nothing it starts outlives it, unless `keepStarted`
40
40
  * and git exits 0: then what it started, as `cache`'s daemon, keeps running.
41
41
  */
42
- const gitRun = Effect.fnUntraced(function* (args, options = {}) {
42
+ const gitRun = /* @__PURE__ */ Effect.fnUntraced(function* (args, options = {}) {
43
43
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
44
44
  const command = ChildProcess.make("git", args, {
45
45
  cwd: options.cwd,
@@ -157,7 +157,7 @@ const helpersFor = (entries, origin) => {
157
157
  * resolves alike. It refuses config it can't read, or past `credentialConfigBytes` or
158
158
  * `credentialConfigEntries`.
159
159
  */
160
- const credentialHelpers = Effect.fnUntraced(function* (origin) {
160
+ const credentialHelpers = /* @__PURE__ */ Effect.fnUntraced(function* (origin) {
161
161
  const listed = yield* gitRun([
162
162
  "config",
163
163
  "-z",
@@ -175,7 +175,7 @@ const credentialHelpers = Effect.fnUntraced(function* (origin) {
175
175
  const platformHelpers = /* @__PURE__ */ new Map([["darwin", "osxkeychain"], ["win32", "manager"]]);
176
176
  const suggestedHelper = () => platformHelpers.get(node.process.platform) ?? "libsecret";
177
177
  /** Whether `program` is on a later `git push`'s `PATH`, which lacks `npx`'s `node_modules/.bin`. */
178
- const onPath = Effect.fnUntraced(function* (program) {
178
+ const onPath = /* @__PURE__ */ Effect.fnUntraced(function* (program) {
179
179
  const fs = yield* FileSystem.FileSystem;
180
180
  const folders = (node.process.env["PATH"] ?? "").split(":").filter((folder) => folder !== "" && !folder.endsWith("/node_modules/.bin"));
181
181
  for (const folder of folders) if (yield* fs.exists(`${folder}/${program}`).pipe(Effect.orElseSucceed(() => false))) return true;
@@ -17,7 +17,7 @@ import { createRestClient } from "@ref0/git/rest";
17
17
  * `ref0-git.host`, and `logout` removes it.
18
18
  */
19
19
  const hostKey = "ref0-git.host";
20
- const decodeHost = Schema.decodeUnknownOption(HostInput);
20
+ const decodeHost = /* @__PURE__ */ Schema.decodeUnknownOption(HostInput);
21
21
  /** `host` as a `Host`, as `HostInput` reads it, or `undefined`. */
22
22
  const parsedHost = (host) => Option.getOrUndefined(decodeHost(host));
23
23
  /**
@@ -88,7 +88,7 @@ const hostFlag = Flag.String("host").pipe(Flag.withDescription("The host to use,
88
88
  * The host a command talks to: `--host`, else the checkout's `origin` when signed in there, named on
89
89
  * stderr, else the one signed in to. Otherwise a usage failure, whose next step is `naming`.
90
90
  */
91
- const chosenHost = Effect.fnUntraced(function* (flag, naming = "Name one with --host") {
91
+ const chosenHost = /* @__PURE__ */ Effect.fnUntraced(function* (flag, naming = "Name one with --host") {
92
92
  if (Option.isSome(flag)) return yield* hostOf(flag.value);
93
93
  const hosts = yield* signedInHosts;
94
94
  const fromCheckout = yield* checkoutHost(hosts);
@@ -104,7 +104,7 @@ const chosenHost = Effect.fnUntraced(function* (flag, naming = "Name one with --
104
104
  * A host's REST client, at its endpoint, with the token Git's helpers keep for its origin, or a
105
105
  * failure saying to sign in.
106
106
  */
107
- const remoteOf = Effect.fnUntraced(function* (chosen) {
107
+ const remoteOf = /* @__PURE__ */ Effect.fnUntraced(function* (chosen) {
108
108
  const { endpoint, origin } = chosen;
109
109
  const host = hostName(chosen);
110
110
  const credential = yield* fillCredential(new URL(`${origin}/`)).pipe(Effect.mapError(() => unsafeCredential(host)));
@@ -1,9 +1,9 @@
1
1
  import { shellWord } from "../init/shell.mjs";
2
2
  import { node, written } from "./node.mjs";
3
3
  import { secretScrubber } from "@ref0/git/remote-helper";
4
+ import * as Context from "effect/Context";
4
5
  import * as Effect from "effect/Effect";
5
6
  import * as Redacted from "effect/Redacted";
6
- import * as Context from "effect/Context";
7
7
  import * as GlobalFlag from "effect/cli/GlobalFlag";
8
8
  import * as DateTime from "effect/DateTime";
9
9
  import * as Flag from "effect/cli/Flag";
@@ -16,7 +16,7 @@ import * as Flag from "effect/cli/Flag";
16
16
  const { process } = node;
17
17
  const JsonFlag = GlobalFlag.Setting("json")({ flag: Flag.Boolean("json").pipe(Flag.withDescription("Print the host's answer as one JSON document"), Flag.withDefault(false)) });
18
18
  const NonInteractiveFlag = GlobalFlag.Setting("non-interactive")({ flag: Flag.Boolean("non-interactive").pipe(Flag.withDescription("Never prompt, and print bare IDs"), Flag.withDefault(false)) });
19
- var CliModes = class extends Context.Service()("ref0-git/CliModes") {};
19
+ var CliModes = class extends (/* @__PURE__ */ Context.Service()("ref0-git/CliModes")) {};
20
20
  /** The modes, from the flags given and the process. */
21
21
  const modesOf = (flags) => {
22
22
  const ci = (process.env["CI"] ?? "") !== "" && process.env["CI"] !== "false";
@@ -11,7 +11,7 @@ const keyed = (input, at, count) => {
11
11
  return ctrl && name === "c" ? "cancel" : name === "return" || name === "enter" ? "take" : name === "up" || name === "k" ? (at + count - 1) % count : name === "down" || name === "j" ? (at + 1) % count : at;
12
12
  };
13
13
  /** `row`'s answer, once a person takes one of `options`, which then reads as a receipt's field. */
14
- const select = Effect.fnUntraced(function* (row, question, options) {
14
+ const select = /* @__PURE__ */ Effect.fnUntraced(function* (row, question, options) {
15
15
  const terminal = yield* Terminal.Terminal;
16
16
  const erased = `\u001b[${options.length + 1}A\u001b[J`;
17
17
  yield* stderrText(shown(question, options, 0));
@@ -26,7 +26,7 @@ const add = Command.make("add", {
26
26
  key: Flag.String("key").pipe(Flag.withDescription("The entry's key, so an add sent again joins it: the source's name when it's left out"), Flag.withMetavar("KEY"), Flag.optional),
27
27
  priority: Flag.Int("priority").pipe(Flag.withDescription("Higher goes first"), Flag.withMetavar("NUMBER"), Flag.optional),
28
28
  jump: Flag.Boolean("jump").pipe(Flag.withDescription("Put it first, rebuilding the candidates behind it"), Flag.withDefault(false))
29
- }, Effect.fnUntraced(function* (flags) {
29
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
30
30
  const remote = yield* remoteFor(flags.host);
31
31
  const ask = (call) => answered(remote.host, call);
32
32
  const source = branchRef(flags.source);
@@ -75,7 +75,7 @@ const add = Command.make("add", {
75
75
  const remove = Command.make("remove", {
76
76
  entry: idArgument("ENTRY", "entry"),
77
77
  host: hostFlag
78
- }, Effect.fnUntraced(function* (flags) {
78
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
79
79
  const done = yield* called(flags.host, (client, signal) => client.queue.remove(flags.entry, { signal }));
80
80
  yield* changed(done.value, flags.entry, { done: `Removed ${printable(flags.entry)} from the queue on ${done.host}` });
81
81
  })).pipe(Command.withDescription("Take an entry out of the queue"));
@@ -92,7 +92,7 @@ const list = Command.make("list", {
92
92
  host: hostFlag,
93
93
  target: targetFlag,
94
94
  ...pageFlags
95
- }, Effect.fnUntraced(function* (flags) {
95
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
96
96
  const remote = yield* remoteFor(flags.host);
97
97
  const target = yield* targetOf(remote, flags.repo, flags.target);
98
98
  const command = (host) => [...[
@@ -119,7 +119,7 @@ const list = Command.make("list", {
119
119
  const show = Command.make("show", {
120
120
  entry: idArgument("ENTRY", "entry"),
121
121
  host: hostFlag
122
- }, Effect.fnUntraced(function* (flags) {
122
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
123
123
  const entry = (yield* called(flags.host, (client, signal) => client.queue.get(flags.entry, { signal }))).value;
124
124
  if ((yield* CliModes).json) return yield* document(entry);
125
125
  const rows = [
@@ -155,7 +155,7 @@ const hold = Command.make("hold", {
155
155
  entry: Flag.String("entry").pipe(Flag.withDescription("Hold this entry, instead of a REPO and --target"), Flag.withMetavar("ENTRY"), Flag.optional),
156
156
  target: Flag.String("target").pipe(Flag.withDescription("Hold the REPO's queue for this branch"), Flag.withMetavar("BRANCH"), Flag.optional),
157
157
  reason: Flag.String("reason").pipe(Flag.withDescription("Why, as the hold shows it"), Flag.withMetavar("TEXT"))
158
- }, Effect.fnUntraced(function* (flags) {
158
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
159
159
  const what = heldOf(flags);
160
160
  if (what === void 0) return yield* usageFailure("missing_target", "Hold a REPO with --target, or an --entry alone", {
161
161
  says: "See its help",
@@ -192,14 +192,14 @@ const hold = Command.make("hold", {
192
192
  const release = Command.make("release", {
193
193
  hold: idArgument("HOLD", "hold"),
194
194
  host: hostFlag
195
- }, Effect.fnUntraced(function* (flags) {
195
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
196
196
  const done = yield* called(flags.host, (client, signal) => client.queue.release(flags.hold, { signal }));
197
197
  yield* changed(done.value, flags.hold, { done: `Released ${printable(flags.hold)} on ${done.host}` });
198
198
  })).pipe(Command.withDescription("Release a hold"));
199
199
  const retry = Command.make("retry", {
200
200
  candidate: idArgument("CANDIDATE", "candidate"),
201
201
  host: hostFlag
202
- }, Effect.fnUntraced(function* (flags) {
202
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
203
203
  const done = yield* called(flags.host, (client, signal) => client.queue.retry(flags.candidate, { signal }));
204
204
  yield* changed(done.value, done.value.candidate, { done: `Closed ${printable(done.value.candidate)} to try its entries again, on ${done.host}` });
205
205
  })).pipe(Command.withDescription("Close a candidate and try its entries again"));
@@ -7,10 +7,10 @@ import { CliModes, flagOn, modesOf, nextDocument, nextLines, printable, secrets
7
7
  import { ref0Git } from "./commands.mjs";
8
8
  import { runControl } from "./run-end.mjs";
9
9
  import { layer } from "./runtime.mjs";
10
- import * as Effect from "effect/Effect";
11
- import * as Layer from "effect/Layer";
12
10
  import * as Cause from "effect/Cause";
11
+ import * as Effect from "effect/Effect";
13
12
  import * as Exit from "effect/Exit";
13
+ import * as Layer from "effect/Layer";
14
14
  import * as Fiber from "effect/Fiber";
15
15
  import * as Match from "effect/Match";
16
16
  import * as Option from "effect/Option";
@@ -7,6 +7,7 @@ import * as Command from "effect/cli/Command";
7
7
  import * as Flag from "effect/cli/Flag";
8
8
  import { jobStates } from "@ref0/git/rest";
9
9
  import { branchRef } from "@ref0/git";
10
+ import * as Record from "effect/Record";
10
11
  // src/cli/repos.ts
11
12
  /** `repos` and `work`: a host's repos, and a repo's saved work. */
12
13
  const create = Command.make("create", {
@@ -14,46 +15,62 @@ const create = Command.make("create", {
14
15
  host: hostFlag,
15
16
  public: Flag.Boolean("public").pipe(Flag.withDescription("Let anyone read it"), Flag.withDefault(false)),
16
17
  defaultBranch: Flag.String("default-branch").pipe(Flag.withDescription("Its default branch, the host's default when it's left out"), Flag.withMetavar("BRANCH"), Flag.optional)
17
- }, Effect.fnUntraced(function* (flags) {
18
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
18
19
  const made = yield* called(flags.host, (client, signal) => {
19
20
  const input = {
20
- id: flags.repo,
21
+ name: flags.repo,
21
22
  public: flags.public,
22
23
  signal
23
24
  };
24
25
  if (Option.isSome(flags.defaultBranch)) input.defaultBranch = branchRef(flags.defaultBranch.value);
25
26
  return client.repos.create(input);
26
27
  });
27
- yield* changed(made.value, made.value.id, {
28
- done: `Created repo ${printable(made.value.id)} on ${made.host}`,
29
- fields: [["Clone", `${made.endpoint}/${printable(made.value.id)}.git`]],
28
+ yield* changed(made.value, made.value.name, {
29
+ done: `Created repo ${printable(made.value.name)} on ${made.host}`,
30
+ fields: [["Clone", `${made.endpoint}/${printable(made.value.name)}.git`]],
30
31
  next: {
31
32
  says: "See it",
32
33
  run: [[
33
34
  "repos",
34
35
  "show",
35
- made.value.id,
36
+ made.value.name,
36
37
  "--host",
37
38
  made.host
38
39
  ]]
39
40
  }
40
41
  });
41
42
  })).pipe(Command.withDescription("Create a repo"));
43
+ /**
44
+ * `--order`'s values, in the CLI's kebab-case as a person types them, each with REST's name.
45
+ * This table is the only place the two meet: REST and `--json` keep REST's names.
46
+ */
47
+ const repoOrders = {
48
+ name: "name",
49
+ "name-descending": "nameDescending",
50
+ oldest: "oldest",
51
+ newest: "newest"
52
+ };
42
53
  const list = Command.make("list", {
43
54
  host: hostFlag,
55
+ order: Flag.Literals("order", Record.keys(repoOrders)).pipe(Flag.withDescription("The order to list them in: name, name-descending, or by when each was made, oldest or newest first (default: name)"), Flag.withMetavar("ORDER"), Flag.withDefault("name")),
44
56
  prefix: Flag.String("prefix").pipe(Flag.withDescription("Only repos whose names start with it, as acme/"), Flag.withMetavar("PREFIX"), Flag.optional),
45
57
  ...pageFlags
46
- }, Effect.fnUntraced(function* (flags) {
58
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
47
59
  const prefix = Option.getOrUndefined(flags.prefix);
48
- const command = (host) => [...[
49
- "repos",
50
- "list",
51
- "--host",
52
- host
53
- ], ...prefix === void 0 ? [] : ["--prefix", prefix]];
60
+ const command = (host) => [
61
+ ...[
62
+ "repos",
63
+ "list",
64
+ "--host",
65
+ host
66
+ ],
67
+ ...prefix === void 0 ? [] : ["--prefix", prefix],
68
+ ...flags.order === "name" ? [] : ["--order", flags.order]
69
+ ];
54
70
  const read = yield* pagesOf(flags.host, flags, command, printable, (client, page, signal) => {
55
71
  const input = {
56
72
  page,
73
+ order: repoOrders[flags.order],
57
74
  signal
58
75
  };
59
76
  if (prefix !== void 0) input.prefix = prefix;
@@ -69,24 +86,24 @@ const list = Command.make("list", {
69
86
  const show = Command.make("show", {
70
87
  repo: repoArgument,
71
88
  host: hostFlag
72
- }, Effect.fnUntraced(function* (flags) {
89
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
73
90
  const shown = yield* called(flags.host, (client, signal) => client.repos.get(flags.repo, { signal }));
74
91
  const info = shown.value;
75
92
  if ((yield* CliModes).json) return yield* document(info);
76
93
  const rows = [
77
- ["Repo", printable(info.id)],
94
+ ["Repo", printable(info.name)],
78
95
  ...info.defaultBranch === void 0 ? [] : [["Default branch", printable(info.defaultBranch)]],
79
96
  ["Visibility", info.public ? "Public" : "Private"],
80
97
  ...info.upstream === void 0 ? [] : [["Fork of", printable(info.upstream)]],
81
98
  ["Refs", String(info.stats.refs)],
82
- ["Clone", `${shown.endpoint}/${printable(info.id)}.git`]
99
+ ["Clone", `${shown.endpoint}/${printable(info.name)}.git`]
83
100
  ];
84
101
  yield* answer(rows.map((row) => field(row).trimStart()).join("\n"));
85
102
  })).pipe(Command.withDescription("Show a repo's details"));
86
103
  const remove = Command.make("delete", {
87
104
  repo: repoArgument,
88
105
  host: hostFlag
89
- }, Effect.fnUntraced(function* (flags) {
106
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
90
107
  const done = yield* called(flags.host, (client, signal) => client.repos.delete(flags.repo, { signal }));
91
108
  yield* changed(done.value, flags.repo, { done: `Deleted repo ${printable(flags.repo)} on ${done.host}` });
92
109
  })).pipe(Command.withDescription("Delete a repo, its refs and its objects"));
@@ -103,7 +120,7 @@ const workList = Command.make("list", {
103
120
  host: hostFlag,
104
121
  state: jobState,
105
122
  ...pageFlags
106
- }, Effect.fnUntraced(function* (flags) {
123
+ }, /* @__PURE__ */ Effect.fnUntraced(function* (flags) {
107
124
  const state = Option.getOrUndefined(flags.state);
108
125
  const command = (host) => [...[
109
126
  "work",
@@ -20,7 +20,7 @@ const pageFlags = {
20
20
  /** The host's client, for `--host` or the one the checkout or the one sign-in names. */
21
21
  const remoteFor = (host) => Effect.flatMap(chosenHost(host), remoteOf);
22
22
  /** The host's answer to `call`, made with its client: its refusal as the CLI's failure. */
23
- const called = Effect.fnUntraced(function* (host, call) {
23
+ const called = /* @__PURE__ */ Effect.fnUntraced(function* (host, call) {
24
24
  const remote = yield* remoteFor(host);
25
25
  const value = yield* answered(remote.host, (signal) => call(remote.client, signal));
26
26
  return {
@@ -35,7 +35,7 @@ const called = Effect.fnUntraced(function* (host, call) {
35
35
  * on stdout by `line` first, so its resume step loses none. A repeated cursor, the host's bug,
36
36
  * carries the rows read the same way, with no step, since resuming would only repeat it.
37
37
  */
38
- const pagesOf = Effect.fnUntraced(function* (from, choice, command, line, call) {
38
+ const pagesOf = /* @__PURE__ */ Effect.fnUntraced(function* (from, choice, command, line, call) {
39
39
  const remote = Option.isOption(from) ? yield* remoteFor(from) : from;
40
40
  const wanted = Option.getOrUndefined(choice.limit);
41
41
  const items = [];
@@ -98,7 +98,7 @@ const resumable = (failed, items, after, argv, wanted) => new CliFailure({
98
98
  * A list's rows: `--json`'s one document, else a line a row on stdout, an empty list said on
99
99
  * stderr, and one with more after it naming the command for the next page, with its `--limit`.
100
100
  */
101
- const listed = Effect.fnUntraced(function* (read, options) {
101
+ const listed = /* @__PURE__ */ Effect.fnUntraced(function* (read, options) {
102
102
  const listing = read.value;
103
103
  if ((yield* CliModes).json) return yield* document(listing);
104
104
  if (listing.items.length === 0) yield* say(options.none);
@@ -116,13 +116,13 @@ const listed = Effect.fnUntraced(function* (read, options) {
116
116
  * A change's outcome: `--json`'s document, else its receipt on stderr, and its bare ID on stdout
117
117
  * when stdout isn't a terminal or the run doesn't prompt, for a script to read.
118
118
  */
119
- const changed = Effect.fnUntraced(function* (value, id, shown) {
119
+ const changed = /* @__PURE__ */ Effect.fnUntraced(function* (value, id, shown) {
120
120
  const modes = yield* CliModes;
121
121
  if (modes.json) return yield* document(value);
122
122
  yield* receipt(shown);
123
123
  if (!modes.stdoutTerminal || !modes.interactive) yield* answer(printable(id));
124
124
  });
125
- const decodeDuration = Schema.decodeUnknownOption(DurationInput);
125
+ const decodeDuration = /* @__PURE__ */ Schema.decodeUnknownOption(DurationInput);
126
126
  /** A duration flag's value, as `30s`, `30m`, `12h` or `30d`, in milliseconds. */
127
127
  const durationOf = (flag, text) => Option.match(decodeDuration(text), {
128
128
  onNone: () => Effect.fail(usageFailure("invalid_duration", `--${flag} takes a number and a unit, as 30m, 12h or 30d: not '${printable(text)}'`)),
@@ -0,0 +1,8 @@
1
+ // src/cli/retry-after.ts
2
+ /**
3
+ * A `Retry-After` header's seconds, when it's RFC 9110's delay-seconds, a non-negative integer, cut
4
+ * to `mostSeconds`. An HTTP-date, a sign, a fraction, a space or anything else is `undefined`, so
5
+ * the caller waits as it would with no header.
6
+ */
7
+ const retryAfterSeconds = (header, mostSeconds) => header !== void 0 && /^\d+$/.test(header) ? Math.min(Number(header), mostSeconds) : void 0;
8
+ export { retryAfterSeconds };