ref0-git 0.2.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 +17 -11
  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 +28 -10
  90. package/app/apps/github/src/palette/rows.tsx +93 -40
  91. package/app/apps/github/src/palette/server.ts +10 -7
  92. package/app/apps/github/src/palette/targets.ts +1 -0
  93. package/app/apps/github/src/policy.ts +137 -61
  94. package/app/apps/github/src/private-repos.ts +5 -5
  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 -120
  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 +26 -5
  174. package/dist/cli/helpers.mjs +168 -35
  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 +70 -13
  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 +4 -3
  193. package/dist/init/detect.mjs +4 -4
  194. package/dist/init/files.mjs +121 -9
  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 +3 -5
  201. package/dist/init/node-app.mjs +3 -3
  202. package/dist/init/node.mjs +41 -42
  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 +64 -48
  208. package/dist/init/vercel.mjs +37 -36
  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
@@ -1,5 +1,6 @@
1
1
  import { stopMs } from "./child.mjs";
2
2
  import * as Effect from "effect/Effect";
3
+ import * as Data from "effect/Data";
3
4
  import * as Stream from "effect/Stream";
4
5
  import * as ChildProcess from "effect/process/ChildProcess";
5
6
  import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
@@ -7,10 +8,29 @@ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
7
8
  const notRun = {
8
9
  status: null,
9
10
  stdout: "",
10
- stderr: ""
11
+ stderr: "",
12
+ overflowed: false
13
+ };
14
+ const overflowed = {
15
+ ...notRun,
16
+ overflowed: true
11
17
  };
12
18
  /** A stream's bytes as text. */
13
19
  const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
20
+ var StdoutOverflow = class extends Data.TaggedError("StdoutOverflow") {};
21
+ /** A stream's bytes as text, failing as soon as they pass `most`, which stops the reading. */
22
+ const textUpTo = (stream, most) => Stream.runFoldEffect(stream, () => ({
23
+ chunks: [],
24
+ size: 0
25
+ }), (read, chunk) => {
26
+ const size = read.size + chunk.length;
27
+ if (size > most) return Effect.fail(new StdoutOverflow());
28
+ read.chunks.push(chunk);
29
+ return Effect.succeed({
30
+ chunks: read.chunks,
31
+ size
32
+ });
33
+ }).pipe(Effect.map(({ chunks }) => new TextDecoder().decode(Buffer.concat(chunks))));
14
34
  /**
15
35
  * `git <args>` in `cwd`, given `input` on its stdin, with its stdout kept. Its stderr is kept too,
16
36
  * so Git's own messages stay out of the CLI's streams and a caller says what failed in its own
@@ -19,7 +39,7 @@ const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
19
39
  * group of its own, which is ended with it, so nothing it starts outlives it, unless `keepStarted`
20
40
  * and git exits 0: then what it started, as `cache`'s daemon, keeps running.
21
41
  */
22
- const gitRun = Effect.fnUntraced(function* (args, options = {}) {
42
+ const gitRun = /* @__PURE__ */ Effect.fnUntraced(function* (args, options = {}) {
23
43
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
24
44
  const command = ChildProcess.make("git", args, {
25
45
  cwd: options.cwd,
@@ -33,7 +53,7 @@ const gitRun = Effect.fnUntraced(function* (args, options = {}) {
33
53
  return yield* Effect.scoped(Effect.gen(function* () {
34
54
  const child = yield* spawner.spawn(command);
35
55
  const [stdout, stderr, status] = yield* Effect.all([
36
- textOf(child.stdout),
56
+ options.stdoutMost === void 0 ? textOf(child.stdout) : textUpTo(child.stdout, options.stdoutMost),
37
57
  options.stderr === "inherit" ? Effect.succeed("") : textOf(child.stderr),
38
58
  child.exitCode
39
59
  ], { concurrency: "unbounded" });
@@ -41,8 +61,9 @@ const gitRun = Effect.fnUntraced(function* (args, options = {}) {
41
61
  return {
42
62
  status,
43
63
  stdout,
44
- stderr
64
+ stderr,
65
+ overflowed: false
45
66
  };
46
- })).pipe(Effect.catch(() => Effect.succeed(notRun)));
67
+ })).pipe(Effect.catchTag("StdoutOverflow", () => Effect.succeed(overflowed)), Effect.catch(() => Effect.succeed(notRun)));
47
68
  });
48
69
  export { gitRun };
@@ -1,51 +1,184 @@
1
+ import { failure } from "./failure.mjs";
1
2
  import { gitRun } from "./git.mjs";
2
3
  import { node } from "./node.mjs";
3
4
  import * as Effect from "effect/Effect";
4
5
  import * as FileSystem from "effect/FileSystem";
5
6
  // src/cli/helpers.ts
6
7
  /**
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: ""
8
+ * Which of Git's credential helpers `git credential approve` stores a host's token with, read from
9
+ * Git's config, never by running a helper: Git's approve stores with every `credential.helper`
10
+ * whose section matches the URL, in config order, an empty value clearing those before it. The
11
+ * match here is ref0-git's own and counts too many rather than too few: it ignores a section's
12
+ * user, port and path, and honours a clearing value only where Git surely applies it, so a drift
13
+ * from Git can only refuse a helper that was safe.
14
+ */
15
+ /**
16
+ * At most how many bytes of credential config, and how many of its entries, login reads. Past
17
+ * either it refuses: a list cut short could leave out a plain-text helper.
18
+ */
19
+ const credentialConfigBytes = 65536;
20
+ /** The helpers that keep a secret in memory or in the platform's encrypted store, never a file. */
21
+ const safeHelpers = /* @__PURE__ */ new Set([
22
+ "cache",
23
+ "osxkeychain",
24
+ "wincred",
25
+ "libsecret",
26
+ "manager",
27
+ "manager-core"
28
+ ]);
29
+ /** Git Credential Manager's names, whose store `credential.credentialStore` sets, `plaintext` among them. */
30
+ const storeSetByConfig = /* @__PURE__ */ new Set(["manager", "manager-core"]);
31
+ /** Where a config entry comes from, as a person finds it: a file's path, or `command line`. */
32
+ const originOf = (shown) => {
33
+ if (shown.startsWith("file:")) return shown.slice(5);
34
+ return shown.endsWith(":") ? shown.slice(0, -1) : shown;
35
+ };
36
+ /**
37
+ * Each entry of `git config -z --show-origin --get-regexp`'s output, which is the origin, a NUL,
38
+ * the key, then a line break and the value where there is one, and a NUL; `undefined` when the
39
+ * output isn't in that shape. Git lowercases the section and the key, never the subsection.
40
+ */
41
+ const entriesOf = (listed) => {
42
+ const fields = listed.split("\0");
43
+ if (fields.pop() !== "" || fields.length % 2 !== 0) return void 0;
44
+ const entries = [];
45
+ for (let at = 0; at < fields.length; at += 2) {
46
+ const [origin = "", item = ""] = fields.slice(at, at + 2);
47
+ const keyEnd = item.indexOf("\n");
48
+ const name = keyEnd === -1 ? item : item.slice(0, keyEnd);
49
+ if (!name.startsWith("credential.")) return void 0;
50
+ const rest = name.slice(11);
51
+ const dot = rest.lastIndexOf(".");
52
+ entries.push({
53
+ origin: originOf(origin),
54
+ section: dot === -1 ? void 0 : rest.slice(0, dot),
55
+ key: dot === -1 ? rest : rest.slice(dot + 1),
56
+ value: keyEnd === -1 ? void 0 : item.slice(keyEnd + 1)
57
+ });
58
+ }
59
+ return entries;
60
+ };
61
+ /** `text` with its `%XX` escapes decoded, or as it is where one doesn't decode. */
62
+ const decoded = (text) => {
63
+ try {
64
+ return decodeURIComponent(text);
65
+ } catch {
66
+ return text;
67
+ }
68
+ };
69
+ /**
70
+ * A host as Git's urlmatch compares it: in lower case, one trailing dot dropped, so
71
+ * `GIT.Acme.dev.` names `git.acme.dev`.
72
+ */
73
+ const gitHost = (host) => host.toLowerCase().replace(/\.$/, "");
74
+ /**
75
+ * The scheme and host a `credential.<url>` section names, either left out where it names none,
76
+ * which matches any. Git reads a full URL or a partial one, as `git.acme.dev` or `https://`; this
77
+ * reads both alike, decodes the host's `%XX` escapes and drops the user, port and path.
78
+ */
79
+ const sectionUrl = (section) => {
80
+ const schemeEnd = section.indexOf("://");
81
+ const scheme = schemeEnd > 0 ? section.slice(0, schemeEnd).toLowerCase() : void 0;
82
+ const rest = schemeEnd === -1 ? section : section.slice(schemeEnd + 3);
83
+ const authorityEnd = rest.search(/[/?#]/);
84
+ const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
85
+ const hostPort = authority.slice(authority.lastIndexOf("@") + 1);
86
+ const host = hostPort.startsWith("[") ? hostPort.slice(0, hostPort.indexOf("]") + 1) : hostPort.replace(/:[^:]*$/, "");
87
+ return {
88
+ scheme,
89
+ host: host === "" ? void 0 : gitHost(decoded(host))
90
+ };
91
+ };
92
+ /** Whether `pattern` names `host`, label by label, a `*` label standing for any one label. */
93
+ const hostMatches = (pattern, host) => {
94
+ const patterns = pattern.split(".");
95
+ const labels = host.split(".");
96
+ return patterns.length === labels.length && patterns.every((label, at) => label === "*" || label === labels[at]);
97
+ };
98
+ /** Whether Git may apply an entry of `section` to `login`'s URL: unscoped, or naming its scheme and host. */
99
+ const mayApply = (section, login) => {
100
+ if (section === void 0) return true;
101
+ const { scheme, host } = sectionUrl(section);
102
+ return (scheme === void 0 || scheme === login.scheme) && (host === void 0 || hostMatches(host, login.host));
103
+ };
104
+ /**
105
+ * Whether Git surely applies a clearing `helper =` of `section` to `login`'s URL: unscoped, or
106
+ * naming exactly its origin, with no user or path, so it can't clear a helper Git keeps.
107
+ */
108
+ const surelyApplies = (section, login) => section === void 0 || section.replace(/\/$/, "") === login.origin;
109
+ /**
110
+ * The program a helper's value runs, by the name Git's own and the platform helpers have: `cache`
111
+ * for `cache --timeout=3600`, `libsecret` for `/usr/lib/git-core/git-credential-libsecret`.
112
+ * `undefined` for a `!` command, any word a shell would read as more than a plain word, a value
113
+ * holding a tab, a line break or another control character, or a path that isn't a
114
+ * `git-credential-*` program, since ref0-git can't tell what that keeps. A path is trusted by the
115
+ * name it gives, as Git's config names it.
116
+ */
117
+ const programOf = (value) => /^(?:([A-Za-z0-9][A-Za-z0-9-]*)|\/(?:[\w.+,@%~-]+\/)*git-credential-([A-Za-z0-9-]+))(?: +[\w./=:+,@%~-]+)*(?![\s\S])/.exec(value)?.slice(1).find((name) => name !== void 0);
118
+ /**
119
+ * What a refusal names a helper `programOf` can't name by: a plain word's or a path's first word,
120
+ * without its arguments, or `a ! command` or `a shell command`, never the command itself.
121
+ */
122
+ const labelOf = (value) => {
123
+ if (value === void 0) return "(no value)";
124
+ if (value.startsWith("!")) return "a ! command";
125
+ return /^[\w./+,@%~-]+(?= |(?![\s\S]))/.exec(value)?.[0] ?? "a shell command";
126
+ };
127
+ /** The helpers approve stores `origin`'s credential with, as `entries` set them, in order. */
128
+ const helpersFor = (entries, origin) => {
129
+ const url = new URL(origin);
130
+ const login = {
131
+ scheme: url.protocol.slice(0, -1),
132
+ host: gitHost(url.hostname),
133
+ origin: url.origin
134
+ };
135
+ const applying = entries.filter((entry) => mayApply(entry.section, login));
136
+ const plaintextStore = node.process.env["GCM_CREDENTIAL_STORE"]?.toLowerCase() === "plaintext" || applying.some((entry) => entry.key === "credentialstore" && entry.value?.toLowerCase() === "plaintext");
137
+ let helpers = [];
138
+ for (const entry of applying) {
139
+ if (entry.key !== "helper") continue;
140
+ if (entry.value === "") {
141
+ if (surelyApplies(entry.section, login)) helpers = [];
142
+ continue;
143
+ }
144
+ const program = entry.value === void 0 ? void 0 : programOf(entry.value);
145
+ const safe = program !== void 0 && safeHelpers.has(program) && !(plaintextStore && storeSetByConfig.has(program));
146
+ helpers.push({
147
+ label: program ?? labelOf(entry.value),
148
+ origin: entry.origin,
149
+ plaintext: !safe
150
+ });
38
151
  }
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);
152
+ return helpers;
153
+ };
154
+ /**
155
+ * The helpers `git credential approve` stores `origin`'s credential with, as Git's config sets
156
+ * them, read by the same Git, in the same folder and environment, as approve, so an `includeIf`
157
+ * resolves alike. It refuses config it can't read, or past `credentialConfigBytes` or
158
+ * `credentialConfigEntries`.
159
+ */
160
+ const credentialHelpers = /* @__PURE__ */ Effect.fnUntraced(function* (origin) {
161
+ const listed = yield* gitRun([
162
+ "config",
163
+ "-z",
164
+ "--show-origin",
165
+ "--get-regexp",
166
+ String.raw`^credential\..*(helper|credentialstore)$`
167
+ ], { stdoutMost: credentialConfigBytes });
168
+ if (listed.overflowed) return yield* failure("credential_config_too_large", `Can't check Git's credential helpers. Its credential config passes ${credentialConfigBytes / 1024} KiB`, "Remove the credential entries you no longer use from your Git config, then sign in again");
169
+ const entries = listed.status === 1 && listed.stdout === "" ? [] : entriesOf(listed.stdout);
170
+ if (listed.status === null || listed.status > 1 || entries === void 0) return yield* failure("credential_config_unread", `Couldn't read Git's credential config: ${listed.stderr.trim().split("\n")[0] || "git config failed"}`, "Fix the config Git names, as `git config --list` shows it, then sign in again");
171
+ if (entries.length > 128) return yield* failure("credential_config_too_large", `Can't check Git's credential helpers. Its config holds more than 128 credential entries`, "Remove the credential entries you no longer use from your Git config, then sign in again");
172
+ return helpersFor(entries, origin);
173
+ });
41
174
  /** The helper to set up where none is, for this machine's platform. */
42
175
  const platformHelpers = /* @__PURE__ */ new Map([["darwin", "osxkeychain"], ["win32", "manager"]]);
43
176
  const suggestedHelper = () => platformHelpers.get(node.process.platform) ?? "libsecret";
44
177
  /** Whether `program` is on a later `git push`'s `PATH`, which lacks `npx`'s `node_modules/.bin`. */
45
- const onPath = Effect.fnUntraced(function* (program) {
178
+ const onPath = /* @__PURE__ */ Effect.fnUntraced(function* (program) {
46
179
  const fs = yield* FileSystem.FileSystem;
47
180
  const folders = (node.process.env["PATH"] ?? "").split(":").filter((folder) => folder !== "" && !folder.endsWith("/node_modules/.bin"));
48
181
  for (const folder of folders) if (yield* fs.exists(`${folder}/${program}`).pipe(Effect.orElseSucceed(() => false))) return true;
49
182
  return false;
50
183
  });
51
- export { credentialHelpers, isPlaintext, onPath, suggestedHelper };
184
+ export { credentialConfigBytes, credentialHelpers, onPath, suggestedHelper };
@@ -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));