@osdlc/typed-git 0.6.0 → 0.7.1

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.
package/dist/client.js CHANGED
@@ -1,27 +1,27 @@
1
1
  /**
2
- * `@osdlc/typed-git/client` — the git clients and their seams, without the
3
- * git-reference parsers and the checkout walks.
2
+ * `@osdlc/typed-git/client`: the git clients, their backend and runner
3
+ * types, without the git-reference parsers and the checkout walks.
4
4
  *
5
5
  * The package entry minus two groups. The first is `parseGitUrl`,
6
6
  * `gitSshUrl`, `parseRepoRef` and their types, which pull in
7
7
  * `hosted-git-info`. The second is the checkout walks: `checkoutRoot`,
8
8
  * `discoverCheckouts`, `scanForCheckouts`, their types and their defaults. A
9
- * consumer that only drives git — a runner discovery pass, a guard script —
9
+ * consumer that only runs git, such as a runner discovery pass or a check script,
10
10
  * imports from here and keeps `hosted-git-info` off its module graph. It stays
11
11
  * in `dependencies` either way, so this is a bundle saving, not an install
12
12
  * one.
13
13
  *
14
14
  * The package entry is defined as this module plus the URL exports, so there
15
- * is one definition of the surface rather than two lists to keep in step.
15
+ * is one list of exports rather than two to keep in step.
16
16
  */
17
17
  export { Git } from "./sync.js";
18
18
  export { AsyncGit } from "./async.js";
19
19
  export { parseRemoteUrl } from "./remote-url.js";
20
20
  export { cliBackend, partialBackend, UnsupportedRequest, } from "./backend.js";
21
- export { classifyGitFailure } from "./failure.js";
21
+ export { classifyGitFailure, describeGitFailure, } from "./failure.js";
22
22
  export {} from "./outcome.js";
23
23
  export { forceWithLeaseArg, parseRefRows, REF_FORMAT, } from "./verbs.js";
24
- // The subprocess seam is re-exported so a caller wiring a runner or catching
24
+ // The command-seam exports are re-exported so a caller wiring a runner or catching
25
25
  // a failure needs one import, not two. `@osdlc/command-seam` is the package
26
26
  // that owns these; it is usable on its own, without a git client.
27
27
  export { asAsync, CommandFailed, runChecked, runCheckedAsync, spawnRunner, spawnRunnerAsync, } from '@osdlc/command-seam';
package/dist/failure.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * {@link GitFailure}: a failed git call, classified. The `git.try.*` door
3
- * returns it as the error of a `Result`; its `cause` is the `CommandFailed`
4
- * it was read from.
2
+ * {@link GitFailure}: a failed git call, classified. `git.try.*` returns it
3
+ * as the error of a `Result`. Its `cause` is the `CommandFailed` it was read
4
+ * from.
5
5
  *
6
- * The git-specific kinds come from git's stderr, matched in English. Git
7
- * translates its messages under a non-English locale; those fall through to the
8
- * subprocess layer's kind, so an unrecognised failure is still an `exit` with
9
- * git's first stderr line as its message, never a wrong git kind.
6
+ * The git-specific kinds come from git's stderr, matched in English. Under a
7
+ * non-English locale git translates its messages. Those keep command-seam's
8
+ * kind, so an unrecognised failure is still an `exit` with git's first stderr
9
+ * line as its message, never a wrong git kind.
10
10
  */
11
11
  import { type CommandFailed, type CommandFailureKind } from '@osdlc/command-seam';
12
12
  import { type Failure } from '@osdlc/result';
@@ -48,12 +48,20 @@ export interface GitFailure extends Failure<GitFailureKind> {
48
48
  /** The git failure for a failed `git` run. */
49
49
  export declare function classifyGitFailure(failed: CommandFailed): GitFailure;
50
50
  /**
51
- * What the plain door throws for a failed git call: a `FailureError` carrying
52
- * the {@link GitFailure} that {@link classifyGitFailure} reads from it, with the
53
- * `CommandFailed` as its `cause`. Anything else is returned as it is. The
54
- * classified kind (a signed-out remote, an unreachable one) is what lets a CLI
55
- * that reports a thrown failure number it, which a bare `CommandFailed` with
56
- * only command-seam's kinds cannot.
51
+ * One line for a person that names the git command: `git <verb>: <message>`,
52
+ * then the hint when there is one. The classified `message` alone does not say
53
+ * which command failed, so use this when the failure reaches a log or a status
54
+ * file without its surrounding code.
55
+ */
56
+ export declare function describeGitFailure(failure: GitFailure): string;
57
+ /**
58
+ * What the throwing methods throw for a failed git call: a `FailureError`
59
+ * carrying the {@link GitFailure} that {@link classifyGitFailure} reads from
60
+ * it, with the `CommandFailed` as its `cause`. Its `message` is
61
+ * {@link describeGitFailure}, so it names the command that failed. Any other
62
+ * value is returned unchanged. The git kind (a signed-out remote, an
63
+ * unreachable one) lets a CLI that reports a thrown failure pick an exit code
64
+ * for it. A bare `CommandFailed` has only command-seam's kinds.
57
65
  */
58
66
  export declare function gitFailureError(error: unknown): unknown;
59
67
  /**
package/dist/failure.js CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * {@link GitFailure}: a failed git call, classified. The `git.try.*` door
3
- * returns it as the error of a `Result`; its `cause` is the `CommandFailed`
4
- * it was read from.
2
+ * {@link GitFailure}: a failed git call, classified. `git.try.*` returns it
3
+ * as the error of a `Result`. Its `cause` is the `CommandFailed` it was read
4
+ * from.
5
5
  *
6
- * The git-specific kinds come from git's stderr, matched in English. Git
7
- * translates its messages under a non-English locale; those fall through to the
8
- * subprocess layer's kind, so an unrecognised failure is still an `exit` with
9
- * git's first stderr line as its message, never a wrong git kind.
6
+ * The git-specific kinds come from git's stderr, matched in English. Under a
7
+ * non-English locale git translates its messages. Those keep command-seam's
8
+ * kind, so an unrecognised failure is still an `exit` with git's first stderr
9
+ * line as its message, never a wrong git kind.
10
10
  */
11
11
  import { classifyFailure, isCommandFailed, } from '@osdlc/command-seam';
12
- import { FailureError, isFailure } from '@osdlc/result';
12
+ import { describe, FailureError, isFailure } from '@osdlc/result';
13
13
  const INSTALL_HINT = 'Install git from https://git-scm.com.';
14
14
  /** The git failure for a failed `git` run. */
15
15
  export function classifyGitFailure(failed) {
@@ -98,16 +98,45 @@ export function classifyGitFailure(failed) {
98
98
  }
99
99
  return base;
100
100
  }
101
+ /** The git verb a failure ran, past any leading `-c <k=v>` / `-C <dir>` options (other global options are expected in their `--opt=value` form); `undefined` when argv has none. */
102
+ function gitVerb(argv) {
103
+ for (let i = 0; i < argv.length; i++) {
104
+ const arg = argv[i];
105
+ if (arg === '-c' || arg === '-C')
106
+ i++;
107
+ else if (!arg.startsWith('-'))
108
+ return arg;
109
+ }
110
+ return undefined;
111
+ }
112
+ /**
113
+ * One line for a person that names the git command: `git <verb>: <message>`,
114
+ * then the hint when there is one. The classified `message` alone does not say
115
+ * which command failed, so use this when the failure reaches a log or a status
116
+ * file without its surrounding code.
117
+ */
118
+ export function describeGitFailure(failure) {
119
+ const verb = gitVerb(failure.argv);
120
+ const line = describe(failure);
121
+ return verb === undefined ? `git: ${line}` : `git ${verb}: ${line}`;
122
+ }
101
123
  /**
102
- * What the plain door throws for a failed git call: a `FailureError` carrying
103
- * the {@link GitFailure} that {@link classifyGitFailure} reads from it, with the
104
- * `CommandFailed` as its `cause`. Anything else is returned as it is. The
105
- * classified kind (a signed-out remote, an unreachable one) is what lets a CLI
106
- * that reports a thrown failure number it, which a bare `CommandFailed` with
107
- * only command-seam's kinds cannot.
124
+ * What the throwing methods throw for a failed git call: a `FailureError`
125
+ * carrying the {@link GitFailure} that {@link classifyGitFailure} reads from
126
+ * it, with the `CommandFailed` as its `cause`. Its `message` is
127
+ * {@link describeGitFailure}, so it names the command that failed. Any other
128
+ * value is returned unchanged. The git kind (a signed-out remote, an
129
+ * unreachable one) lets a CLI that reports a thrown failure pick an exit code
130
+ * for it. A bare `CommandFailed` has only command-seam's kinds.
108
131
  */
109
132
  export function gitFailureError(error) {
110
- return isCommandFailed(error) ? new FailureError(classifyGitFailure(error)) : error;
133
+ if (!isCommandFailed(error))
134
+ return error;
135
+ const failure = classifyGitFailure(error);
136
+ // FailureError's message is the bare sentence. Add the command to it.
137
+ const thrown = new FailureError(failure);
138
+ thrown.message = describeGitFailure(failure);
139
+ return thrown;
111
140
  }
112
141
  /**
113
142
  * The failure a thrown value carries, recognised by shape so two installed
package/dist/git-url.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Parse an arbitrary git repository reference (https, ssh, scp-style,
3
3
  * `owner/repo` shorthand, `github:owner/repo`, …) into its host, owner, and
4
- * project, over `hosted-git-info` — the parser npm itself uses for the same
5
- * job. Covers GitHub, GitLab, Bitbucket, and Sourcehut.
4
+ * project. It uses `hosted-git-info`, the parser npm itself uses for this.
5
+ * Covers GitHub, GitLab, Bitbucket, and Sourcehut.
6
6
  */
7
7
  /** A parsed reference to a repo on a known git host. */
8
8
  export interface GitHostInfo {
@@ -41,10 +41,10 @@ export interface RepoRef {
41
41
  * repository (a local path, an unknown host).
42
42
  *
43
43
  * {@link parseGitUrl} reads clone URLs and shorthand but refuses the web
44
- * pages people actually copy — a pull request, an issue, a file — because it
45
- * takes `/pull/12` as part of the project path. So an http(s) input that
46
- * fails to parse is retried with its path cut to `/<owner>/<repo>`: the
47
- * coordinate survives whatever page it was copied from.
44
+ * pages people often copy, such as a pull request, an issue or a file, because
45
+ * it takes `/pull/12` as part of the project path. So an http(s) input that
46
+ * fails to parse is retried with its path cut to `/<owner>/<repo>`. The owner
47
+ * and repo are then found whatever page the URL came from.
48
48
  *
49
49
  * `protocol` decides the clone URL only for an input that carries none
50
50
  * (`owner/repo`, `github:owner/repo`); an explicit `https://…` or `git@…:`
package/dist/git-url.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Parse an arbitrary git repository reference (https, ssh, scp-style,
3
3
  * `owner/repo` shorthand, `github:owner/repo`, …) into its host, owner, and
4
- * project, over `hosted-git-info` — the parser npm itself uses for the same
5
- * job. Covers GitHub, GitLab, Bitbucket, and Sourcehut.
4
+ * project. It uses `hosted-git-info`, the parser npm itself uses for this.
5
+ * Covers GitHub, GitLab, Bitbucket, and Sourcehut.
6
6
  */
7
7
  // The ambient declaration must travel with this file: a consumer that pulls
8
8
  // git-url.ts in transitively compiles it under its tsconfig, which does not
@@ -34,10 +34,10 @@ const HTTP_INPUT = /^https?:\/\//i;
34
34
  * repository (a local path, an unknown host).
35
35
  *
36
36
  * {@link parseGitUrl} reads clone URLs and shorthand but refuses the web
37
- * pages people actually copy — a pull request, an issue, a file — because it
38
- * takes `/pull/12` as part of the project path. So an http(s) input that
39
- * fails to parse is retried with its path cut to `/<owner>/<repo>`: the
40
- * coordinate survives whatever page it was copied from.
37
+ * pages people often copy, such as a pull request, an issue or a file, because
38
+ * it takes `/pull/12` as part of the project path. So an http(s) input that
39
+ * fails to parse is retried with its path cut to `/<owner>/<repo>`. The owner
40
+ * and repo are then found whatever page the URL came from.
41
41
  *
42
42
  * `protocol` decides the clone URL only for an input that carries none
43
43
  * (`owner/repo`, `github:owner/repo`); an explicit `https://…` or `git@…:`
package/dist/index.d.ts CHANGED
@@ -2,29 +2,30 @@
2
2
  * `@osdlc/typed-git` — a typed git client for TypeScript, in a synchronous
3
3
  * and an awaitable form.
4
4
  *
5
- * Two clients, one surface:
5
+ * Two clients with the same methods:
6
6
  *
7
- * - {@link Git} is synchronous and always shells out. Sequential git
8
- * one-shots gain nothing from being awaited, and staying sync keeps a
9
- * caller's call graph uncolored. It takes a `CommandRunner`, so tests
10
- * inject a fake.
11
- * - {@link AsyncGit} is awaitable and takes a {@link GitBackend} — a seam
12
- * over *what performs git*, not over how a process is spawned. The
13
- * default backend runs the CLI; any other implementation drives the same
14
- * client unchanged.
7
+ * - {@link Git} is synchronous and always runs the `git` CLI. Git calls run
8
+ * one after another gain nothing from being awaited, and a sync client
9
+ * does not force its callers to be async. It takes a `CommandRunner`, so
10
+ * tests can pass a fake.
11
+ * - {@link AsyncGit} is awaitable and takes a {@link GitBackend}, which
12
+ * replaces what performs git, not how a process is spawned. The default
13
+ * backend runs the CLI. Any other implementation works with the same
14
+ * client.
15
15
  *
16
- * One contract, both clients: **declared absence returns a value; everything
17
- * else throws; `try` inspects; `raw` bypasses.** Each verb names the exit
18
- * codes that mean "not there" for it — an unset config key, a ref that does
19
- * not resolve — and those return `null` / `[]` / `false`. Every other non-zero
20
- * exit throws the classified failure, so "git broke" is distinct from "nothing there".
21
- * `git.try.*` is the door for callers that must tolerate failure; `git.soft.*`
22
- * for those whose fallback is the verb's own absence value.
16
+ * Both clients follow one contract. A declared absence returns a value,
17
+ * everything else throws, `try` returns the failure instead of throwing, and
18
+ * `raw` skips the checks. Each verb names the exit codes that mean "not
19
+ * there" for it, such as an unset config key or a ref that does not resolve,
20
+ * and those return `null` / `[]` / `false`. Every other non-zero exit throws
21
+ * the classified failure, so "git broke" is distinct from "nothing there".
22
+ * `git.try.*` is for callers that must tolerate failure. `git.soft.*` is for
23
+ * callers whose fallback is the verb's own absence value.
23
24
  *
24
25
  * The verb table in `./verbs.ts` is the single definition of every argv,
25
26
  * every absence code and every parser, so the two clients cannot drift apart.
26
- * The one exception is `remoteOwnerRepo`, a composite of `remoteGetUrl` plus
27
- * `parseRemoteUrl` written in each client.
27
+ * The one exception is `remoteOwnerRepo`, which calls `remoteGetUrl` and then
28
+ * `parseRemoteUrl`, and is written in each client.
28
29
  *
29
30
  * Subpath exports: `./client` is everything here except the git-reference
30
31
  * parsers and the checkout walks (and so without `hosted-git-info` on the
package/dist/index.js CHANGED
@@ -2,29 +2,30 @@
2
2
  * `@osdlc/typed-git` — a typed git client for TypeScript, in a synchronous
3
3
  * and an awaitable form.
4
4
  *
5
- * Two clients, one surface:
5
+ * Two clients with the same methods:
6
6
  *
7
- * - {@link Git} is synchronous and always shells out. Sequential git
8
- * one-shots gain nothing from being awaited, and staying sync keeps a
9
- * caller's call graph uncolored. It takes a `CommandRunner`, so tests
10
- * inject a fake.
11
- * - {@link AsyncGit} is awaitable and takes a {@link GitBackend} — a seam
12
- * over *what performs git*, not over how a process is spawned. The
13
- * default backend runs the CLI; any other implementation drives the same
14
- * client unchanged.
7
+ * - {@link Git} is synchronous and always runs the `git` CLI. Git calls run
8
+ * one after another gain nothing from being awaited, and a sync client
9
+ * does not force its callers to be async. It takes a `CommandRunner`, so
10
+ * tests can pass a fake.
11
+ * - {@link AsyncGit} is awaitable and takes a {@link GitBackend}, which
12
+ * replaces what performs git, not how a process is spawned. The default
13
+ * backend runs the CLI. Any other implementation works with the same
14
+ * client.
15
15
  *
16
- * One contract, both clients: **declared absence returns a value; everything
17
- * else throws; `try` inspects; `raw` bypasses.** Each verb names the exit
18
- * codes that mean "not there" for it — an unset config key, a ref that does
19
- * not resolve — and those return `null` / `[]` / `false`. Every other non-zero
20
- * exit throws the classified failure, so "git broke" is distinct from "nothing there".
21
- * `git.try.*` is the door for callers that must tolerate failure; `git.soft.*`
22
- * for those whose fallback is the verb's own absence value.
16
+ * Both clients follow one contract. A declared absence returns a value,
17
+ * everything else throws, `try` returns the failure instead of throwing, and
18
+ * `raw` skips the checks. Each verb names the exit codes that mean "not
19
+ * there" for it, such as an unset config key or a ref that does not resolve,
20
+ * and those return `null` / `[]` / `false`. Every other non-zero exit throws
21
+ * the classified failure, so "git broke" is distinct from "nothing there".
22
+ * `git.try.*` is for callers that must tolerate failure. `git.soft.*` is for
23
+ * callers whose fallback is the verb's own absence value.
23
24
  *
24
25
  * The verb table in `./verbs.ts` is the single definition of every argv,
25
26
  * every absence code and every parser, so the two clients cannot drift apart.
26
- * The one exception is `remoteOwnerRepo`, a composite of `remoteGetUrl` plus
27
- * `parseRemoteUrl` written in each client.
27
+ * The one exception is `remoteOwnerRepo`, which calls `remoteGetUrl` and then
28
+ * `parseRemoteUrl`, and is written in each client.
28
29
  *
29
30
  * Subpath exports: `./client` is everything here except the git-reference
30
31
  * parsers and the checkout walks (and so without `hosted-git-info` on the
package/dist/outcome.d.ts CHANGED
@@ -1,16 +1,18 @@
1
1
  /**
2
- * The inspection door — `git.try.*`, and the `Result<T, GitFailure>` it returns.
2
+ * `git.try.*` and `git.soft.*`, and the `Result<T, GitFailure>` that `try`
3
+ * returns.
3
4
  *
4
- * For callers that genuinely tolerate failure: a hook that must never break a
5
- * commit, a status endpoint that must always answer. `try` is a facade over
6
- * the whole client rather than a per-verb option, so a new verb costs nothing
7
- * here. Two rules make it honest:
5
+ * `try` is for callers that must tolerate failure: a hook that must never
6
+ * break a commit, a status endpoint that must always answer. It wraps the
7
+ * whole client rather than being a per-verb option, so a new verb needs no
8
+ * code here. Two rules apply:
8
9
  *
9
- * - It catches a thrown git failure (the `FailureError` the plain door throws,
10
- * or a bare `CommandFailed`, both recognised by shape so two installed copies
11
- * of command-seam or result agree) and nothing else, and returns the
12
- * {@link GitFailure}, whose `cause` is the `CommandFailed`. A `TypeError`
13
- * from a programmer mistake propagates; this is not a blanket catch.
10
+ * - It catches a thrown git failure and nothing else. That is the
11
+ * `FailureError` the throwing methods raise, or a bare `CommandFailed`.
12
+ * Both are recognised by shape, so two installed copies of command-seam or
13
+ * result agree. It returns the {@link GitFailure}, whose `cause` is the
14
+ * `CommandFailed`. A `TypeError` from a programmer mistake still
15
+ * propagates.
14
16
  * - A declared absence is `{ ok: true }`. `git.try.configGet("no.such.key")`
15
17
  * is `{ ok: true, value: null }`, because absence is an answer, not a
16
18
  * failure.
@@ -18,12 +20,11 @@
18
20
  import { type Result } from '@osdlc/result';
19
21
  import { type GitFailure } from './failure.ts';
20
22
  /**
21
- * The methods `try` mirrors: everything but the escape hatches, the
22
- * re-rooting helper, and `try` itself. `raw` already returns a
23
- * `CommandResult` and never throws; `rawChecked` is the deliberate throwing
24
- * door; `at(cwd)` returns a fresh client that has its own `.try`. The types
25
- * omit them, but the runtime proxy wraps every function property, these
26
- * included.
23
+ * The methods `try` mirrors: everything except `raw`, `rawChecked`, `at`,
24
+ * and `try` itself. `raw` already returns a `CommandResult` and never throws.
25
+ * `rawChecked` exists to throw. `at(cwd)` returns a new client that has its
26
+ * own `.try`. The types leave them out, but the runtime proxy wraps every
27
+ * function property, these included.
27
28
  */
28
29
  type Triable<C> = Omit<C, 'raw' | 'rawChecked' | 'at' | 'try' | 'soft' | 'cwd'>;
29
30
  /** Every synchronous client method, returning a `Result<T, GitFailure>`. */
@@ -43,15 +44,15 @@ export declare function triedAsync<C extends object>(client: C): TriedAsync<C>;
43
44
  * a nullable, `false` for a boolean. A verb returning anything else (a
44
45
  * record, a `Set`, free text) has no absence value, so it has no soft form.
45
46
  *
46
- * Mind the boolean kind: `false` is the answer for "could not ask" too, so
47
- * `soft.isDirty` reads a broken repo as clean and `soft.branchExists` as
48
- * "no such branch". Do not gate a destructive action on a `false` from `soft`;
49
- * use `try` there.
47
+ * Take care with booleans. `false` is also the answer for "could not ask", so
48
+ * `soft.isDirty` reads a broken repo as clean and `soft.branchExists` reads it
49
+ * as "no such branch". Do not base a destructive action on a `false` from
50
+ * `soft`. Use `try` there.
50
51
  */
51
52
  type SoftKind<R> = R extends readonly unknown[] ? 'empty' : null extends R ? 'null' : R extends boolean ? 'false' : never;
52
53
  type Unwrap<R> = R extends Promise<infer U> ? U : R;
53
54
  /**
54
- * Methods left out of the soft door although their return type has an absence
55
+ * Methods left out of `soft` although their return type has an absence
55
56
  * value. `configRemoveSection` is a mutation, and no mutation has a soft form.
56
57
  */
57
58
  type NoSoftForm = 'configRemoveSection';
@@ -61,20 +62,21 @@ export type SoftKinds<C> = {
61
62
  };
62
63
  /**
63
64
  * Every client method that has an absence value, returning that value
64
- * instead of throwing `CommandFailed`. One type for both clients: an
65
+ * instead of throwing the classified failure. One type for both clients: an
65
66
  * awaitable method already returns a `Promise`.
66
67
  */
67
68
  export type Soft<C> = {
68
- [K in keyof SoftKinds<C>]: Triable<C>[K] extends (...a: infer A) => infer R ? (...a: A) => R : never;
69
+ [K in keyof SoftKinds<C>]: Triable<C>[K & keyof Triable<C>] extends (...a: infer A) => infer R ? (...a: A) => R : never;
69
70
  };
70
71
  /**
71
- * The soft door's table type: which absence value each softable verb falls back
72
- * to. Typed against the client so a new list/nullable/boolean verb is a
73
- * compile error here until it is declared, and so a wrong entry cannot
74
- * compile; `Git` and `AsyncGit` read this one table, so they cannot drift.
72
+ * The type of the `soft` table: which absence value each verb with a soft form
73
+ * falls back to. It is typed against the client, so a new list, nullable or
74
+ * boolean verb is a compile error until it is added, and a wrong entry does
75
+ * not compile. `Git` and `AsyncGit` read the same table, so they cannot
76
+ * differ.
75
77
  */
76
78
  export type SoftTable = Record<string, 'empty' | 'null' | 'false'>;
77
- /** A table that must name exactly the softable methods of `C`, each with the right kind. */
79
+ /** A table that must name exactly the methods of `C` that have a soft form, each with the right kind. */
78
80
  export type SoftTableFor<C> = SoftKinds<C>;
79
81
  /** Wrap a synchronous client so a failed call returns the verb's absence value. */
80
82
  export declare function softSync<C extends object>(client: C, table: SoftTable): Soft<C>;
package/dist/outcome.js CHANGED
@@ -1,23 +1,25 @@
1
1
  /**
2
- * The inspection door — `git.try.*`, and the `Result<T, GitFailure>` it returns.
2
+ * `git.try.*` and `git.soft.*`, and the `Result<T, GitFailure>` that `try`
3
+ * returns.
3
4
  *
4
- * For callers that genuinely tolerate failure: a hook that must never break a
5
- * commit, a status endpoint that must always answer. `try` is a facade over
6
- * the whole client rather than a per-verb option, so a new verb costs nothing
7
- * here. Two rules make it honest:
5
+ * `try` is for callers that must tolerate failure: a hook that must never
6
+ * break a commit, a status endpoint that must always answer. It wraps the
7
+ * whole client rather than being a per-verb option, so a new verb needs no
8
+ * code here. Two rules apply:
8
9
  *
9
- * - It catches a thrown git failure (the `FailureError` the plain door throws,
10
- * or a bare `CommandFailed`, both recognised by shape so two installed copies
11
- * of command-seam or result agree) and nothing else, and returns the
12
- * {@link GitFailure}, whose `cause` is the `CommandFailed`. A `TypeError`
13
- * from a programmer mistake propagates; this is not a blanket catch.
10
+ * - It catches a thrown git failure and nothing else. That is the
11
+ * `FailureError` the throwing methods raise, or a bare `CommandFailed`.
12
+ * Both are recognised by shape, so two installed copies of command-seam or
13
+ * result agree. It returns the {@link GitFailure}, whose `cause` is the
14
+ * `CommandFailed`. A `TypeError` from a programmer mistake still
15
+ * propagates.
14
16
  * - A declared absence is `{ ok: true }`. `git.try.configGet("no.such.key")`
15
17
  * is `{ ok: true, value: null }`, because absence is an answer, not a
16
18
  * failure.
17
19
  */
18
20
  import { err, ok } from '@osdlc/result';
19
21
  import { thrownGitFailure } from "./failure.js";
20
- /** `CommandFailed` becomes a classified failure; anything else stays a throw. */
22
+ /** A thrown git failure becomes an `err`; anything else is thrown again. */
21
23
  function asFailure(error) {
22
24
  const failure = thrownGitFailure(error);
23
25
  if (failure !== null)
@@ -26,15 +28,15 @@ function asFailure(error) {
26
28
  }
27
29
  /**
28
30
  * A `Proxy` rather than a generated object: it mirrors whatever the client
29
- * has, including composed methods like `isDirty` that call through the gated
30
- * ones, without a per-verb entry to keep in step. Methods are invoked on the
31
+ * has, including methods like `isDirty` that call other verbs, with no
32
+ * per-verb entry to keep in step. Methods are invoked on the
31
33
  * client itself, not on the proxy, so private state stays reachable.
32
34
  */
33
35
  function facade(client, wrap) {
34
36
  return new Proxy(client, {
35
37
  get(target, prop) {
36
38
  // Read from the target, not the proxy: a getter (`try` itself) must run
37
- // against the real client rather than recursing through the facade.
39
+ // against the real client rather than recursing through the proxy.
38
40
  const value = Reflect.get(target, prop);
39
41
  if (typeof value !== 'function')
40
42
  return value;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Host-agnostic reading of a git remote URL into its coordinate.
3
3
  *
4
- * `parseGitUrl` (git-url.ts) is over `hosted-git-info`, which only knows a
5
- * fixed allowlist of hosts and answers null for a self-hosted Forgejo or
6
- * Gitea. A remote read out of a checkout's own config is always a clone URL
7
- * (scp-style or `scheme://`), so this parses that shape for ANY host and
8
- * needs no dependency — which is why it, not `parseGitUrl`, backs
9
- * `Git.remoteOwnerRepo` and stays on the `./client` entry.
4
+ * `parseGitUrl` (git-url.ts) is built on `hosted-git-info`, which knows only a
5
+ * fixed list of hosts and answers null for a self-hosted Forgejo or Gitea. A
6
+ * remote read from a checkout's own config is always a clone URL (scp-style or
7
+ * `scheme://`), so this parses that shape for any host and needs no
8
+ * dependency. That is why `Git.remoteOwnerRepo` uses it rather than
9
+ * `parseGitUrl`, and why it is on the `./client` entry.
10
10
  */
11
11
  /** A remote clone URL split into where it lives and what it names. */
12
12
  export interface RemoteCoordinate {
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Host-agnostic reading of a git remote URL into its coordinate.
3
3
  *
4
- * `parseGitUrl` (git-url.ts) is over `hosted-git-info`, which only knows a
5
- * fixed allowlist of hosts and answers null for a self-hosted Forgejo or
6
- * Gitea. A remote read out of a checkout's own config is always a clone URL
7
- * (scp-style or `scheme://`), so this parses that shape for ANY host and
8
- * needs no dependency — which is why it, not `parseGitUrl`, backs
9
- * `Git.remoteOwnerRepo` and stays on the `./client` entry.
4
+ * `parseGitUrl` (git-url.ts) is built on `hosted-git-info`, which knows only a
5
+ * fixed list of hosts and answers null for a self-hosted Forgejo or Gitea. A
6
+ * remote read from a checkout's own config is always a clone URL (scp-style or
7
+ * `scheme://`), so this parses that shape for any host and needs no
8
+ * dependency. That is why `Git.remoteOwnerRepo` uses it rather than
9
+ * `parseGitUrl`, and why it is on the `./client` entry.
10
10
  */
11
11
  /**
12
12
  * Parses `git@host:owner/repo.git` (scp-style) and
package/dist/soft.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * The soft door's table — the one place that says which verbs have a
3
- * tolerant form and what they fall back to.
2
+ * The `soft` table: the one place that says which verbs have a `git.soft.*`
3
+ * form and what each falls back to.
4
4
  *
5
- * Typed against `Git` and `AsyncGit` both, so adding a list-, nullable- or
6
- * boolean-returning verb to either client is a compile error here until it
7
- * is declared, and the two clients cannot grow different soft doors.
5
+ * It is typed against both `Git` and `AsyncGit`. Adding a verb that returns
6
+ * a list, a nullable or a boolean to either client is a compile error here
7
+ * until it is added, so the two clients cannot have different `soft` methods.
8
8
  * Mutations have no soft form, so `configRemoveSection` is not here.
9
9
  */
10
10
  export declare const SOFT_TABLE: {
package/dist/soft.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * The soft door's table — the one place that says which verbs have a
3
- * tolerant form and what they fall back to.
2
+ * The `soft` table: the one place that says which verbs have a `git.soft.*`
3
+ * form and what each falls back to.
4
4
  *
5
- * Typed against `Git` and `AsyncGit` both, so adding a list-, nullable- or
6
- * boolean-returning verb to either client is a compile error here until it
7
- * is declared, and the two clients cannot grow different soft doors.
5
+ * It is typed against both `Git` and `AsyncGit`. Adding a verb that returns
6
+ * a list, a nullable or a boolean to either client is a compile error here
7
+ * until it is added, so the two clients cannot have different `soft` methods.
8
8
  * Mutations have no soft form, so `configRemoveSection` is not here.
9
9
  */
10
10
  export const SOFT_TABLE = {