@floh-solutions/pharos-cli 0.23.0 → 0.25.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 (49) hide show
  1. package/README.md +409 -5
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +23 -0
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/cli.d.ts +4 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +362 -36
  8. package/dist/cli.js.map +1 -1
  9. package/dist/commands/comment-github.d.ts +138 -0
  10. package/dist/commands/comment-github.d.ts.map +1 -0
  11. package/dist/commands/comment-github.js +427 -0
  12. package/dist/commands/comment-github.js.map +1 -0
  13. package/dist/commands/comment.d.ts.map +1 -1
  14. package/dist/commands/comment.js +114 -19
  15. package/dist/commands/comment.js.map +1 -1
  16. package/dist/commands/doctor.d.ts +71 -2
  17. package/dist/commands/doctor.d.ts.map +1 -1
  18. package/dist/commands/doctor.js +414 -8
  19. package/dist/commands/doctor.js.map +1 -1
  20. package/dist/commands/issue.d.ts +75 -0
  21. package/dist/commands/issue.d.ts.map +1 -0
  22. package/dist/commands/issue.js +2466 -0
  23. package/dist/commands/issue.js.map +1 -0
  24. package/dist/commands/setup.d.ts +6 -0
  25. package/dist/commands/setup.d.ts.map +1 -1
  26. package/dist/commands/setup.js +114 -0
  27. package/dist/commands/setup.js.map +1 -1
  28. package/dist/half-link.d.ts +157 -0
  29. package/dist/half-link.d.ts.map +1 -0
  30. package/dist/half-link.js +257 -0
  31. package/dist/half-link.js.map +1 -0
  32. package/dist/issue-scan.d.ts +383 -0
  33. package/dist/issue-scan.d.ts.map +1 -0
  34. package/dist/issue-scan.js +455 -0
  35. package/dist/issue-scan.js.map +1 -0
  36. package/dist/output.d.ts +18 -1
  37. package/dist/output.d.ts.map +1 -1
  38. package/dist/output.js +293 -0
  39. package/dist/output.js.map +1 -1
  40. package/dist/session.d.ts +101 -2
  41. package/dist/session.d.ts.map +1 -1
  42. package/dist/session.js +132 -11
  43. package/dist/session.js.map +1 -1
  44. package/dist/target.d.ts +40 -4
  45. package/dist/target.d.ts.map +1 -1
  46. package/dist/target.js +14 -3
  47. package/dist/target.js.map +1 -1
  48. package/package.json +3 -2
  49. package/skill/SKILL.md +422 -11
package/dist/output.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AdoAuthError, AdoConcurrencyError, AdoConfigError, AdoError, AdoNetworkError, AdoNotFoundError, AdoRateLimitError, adviceFor, deletionAdvice, namesAResourcePermission, } from "@floh-solutions/ado-core";
2
+ import { GhUnavailableError, GitHubAccountError, GitHubAuthError, GitHubConfigError, GitHubError, GitHubGraphQLError, GitHubIdentityMismatchError, GitHubNetworkError, GitHubNotFoundError, GitHubRateLimitError, GitHubValidationError, IssueEditConflictError, PullRequestNotAnIssueError, UnknownLabelError, } from "@floh-solutions/gh-core";
2
3
  /**
3
4
  * The output contract.
4
5
  *
@@ -99,6 +100,20 @@ export function reportError(io, error) {
99
100
  io.stderr(JSON.stringify({ error: body }, undefined, 2));
100
101
  return code;
101
102
  }
103
+ /**
104
+ * The same classification `reportError` uses, without emitting anything.
105
+ *
106
+ * For the one shape that needs it: a verb that has **already written one half of
107
+ * something** when the second half fails. `pharos issue adopt` creates the work
108
+ * item and then comments on the issue, so a failure at the second step must
109
+ * report the first step's result rather than only the error — otherwise the work
110
+ * item exists and nothing anywhere names it. Re-classifying by hand there would
111
+ * be a second, drifting copy of this table.
112
+ */
113
+ export function failureOf(error) {
114
+ const { body, code } = describe(error);
115
+ return { kind: body["kind"] ?? "internal", code, body };
116
+ }
102
117
  function describe(error) {
103
118
  if (error instanceof CliError) {
104
119
  return {
@@ -114,6 +129,9 @@ function describe(error) {
114
129
  code: error.exitCode,
115
130
  };
116
131
  }
132
+ const github = describeGitHub(error);
133
+ if (github !== undefined)
134
+ return github;
117
135
  if (error instanceof AdoConcurrencyError) {
118
136
  return {
119
137
  body: {
@@ -206,6 +224,281 @@ function describe(error) {
206
224
  code: EXIT_FAILED,
207
225
  };
208
226
  }
227
+ /**
228
+ * The GitHub half of the same table, and the reason it is not optional.
229
+ *
230
+ * Without it every failure from `gh-core` falls through to `kind: "internal"`
231
+ * with exit 1 — so "this repository is not in repos.json" (fix the file, never
232
+ * retry), "`gh` is not installed" (fix the machine), and "you are over the
233
+ * hourly budget" (wait exactly this long and repeat) all arrive looking like one
234
+ * unexplained crash. Exit 1 additionally *invites* a retry, which is wrong for
235
+ * two of those three.
236
+ *
237
+ * Every body here carries `platform: "github"`, because on this bridge a verb
238
+ * touches two platforms in one invocation and "which side said no" is the first
239
+ * thing an agent needs. Its absence means Azure DevOps or this CLI, which is
240
+ * what it already meant.
241
+ *
242
+ * `undefined` when the error is not GitHub's, so the caller falls through.
243
+ */
244
+ function describeGitHub(error) {
245
+ /**
246
+ * The lost-update guard said no, and this is the one GitHub failure an agent
247
+ * should treat exactly as it treats {@link AdoConcurrencyError}: the work is
248
+ * still good, re-read and re-apply.
249
+ *
250
+ * `kind: "conflict"` is deliberate and it is the same word the Azure DevOps
251
+ * side uses, because the skill teaches branching on it. What differs is the
252
+ * `hint`: on Azure DevOps a rev mismatch is not proof of an edit collision, so
253
+ * the advice is "diff the fields you changed". Here it **is** proof — the
254
+ * guard compares the field's own value and nothing else moves it — so the
255
+ * advice is simply to take the newer text into account.
256
+ */
257
+ if (error instanceof IssueEditConflictError) {
258
+ return {
259
+ body: {
260
+ kind: "conflict",
261
+ platform: "github",
262
+ message: error.message,
263
+ repo: error.repo,
264
+ number: error.number,
265
+ conflicts: error.conflicts,
266
+ attribution: error.attribution,
267
+ hint: "Somebody changed the exact field you were overwriting. Re-read the issue, fold their "
268
+ + "change into yours, and edit again — passing --if-title/--if-body so the next attempt "
269
+ + "is guarded against what you just read. This is NOT the Azure DevOps rev case: a "
270
+ + "comment cannot cause it, so it is a real collision.",
271
+ },
272
+ code: EXIT_FAILED,
273
+ };
274
+ }
275
+ /**
276
+ * A label the repository does not have. Exit 3, with the rest of the
277
+ * refusals, because it is cleared by asking again more explicitly —
278
+ * `--create-label` — which is exactly what that exit code means here.
279
+ */
280
+ if (error instanceof UnknownLabelError) {
281
+ return {
282
+ body: {
283
+ kind: "refused",
284
+ platform: "github",
285
+ message: error.message,
286
+ repo: error.repo,
287
+ unknown: error.unknown,
288
+ suggestions: error.suggestions,
289
+ hint: "Fix the spelling, or pass --create-label if you really mean to add a new label to the "
290
+ + "repository. It is off by default because GitHub creates one silently.",
291
+ },
292
+ code: EXIT_REFUSED,
293
+ };
294
+ }
295
+ // A repo that is not in repos.json, an account `gh` has no token for, a
296
+ // missing `gh`: all configuration, all exit 2. Retrying is pure noise, and the
297
+ // messages `gh-core` raises already name the file or the command to run.
298
+ if (error instanceof GitHubConfigError) {
299
+ return { body: { kind: "config", platform: "github", message: error.message }, code: EXIT_USAGE };
300
+ }
301
+ if (error instanceof GitHubAccountError) {
302
+ return {
303
+ body: {
304
+ kind: "auth",
305
+ platform: "github",
306
+ message: error.message,
307
+ account: error.account,
308
+ hint: `gh holds no usable token for "${error.account}". Sign that account in with `
309
+ + `\`gh auth login\`, or fix the binding with \`pharos setup --repo <owner/name> `
310
+ + "--gh-account <login>`. `pharos doctor` reports both.",
311
+ },
312
+ code: EXIT_USAGE,
313
+ };
314
+ }
315
+ if (error instanceof GhUnavailableError) {
316
+ return {
317
+ body: {
318
+ kind: "config",
319
+ platform: "github",
320
+ message: error.message,
321
+ hint: "Install it with `pharos setup --install gh`, then `pharos doctor`.",
322
+ },
323
+ code: EXIT_USAGE,
324
+ };
325
+ }
326
+ // **A 200 from the wrong identity** — plan §2's whole reason for existing. Not
327
+ // a transport failure and not retryable: the configuration says one thing and
328
+ // the credential answered as somebody else.
329
+ if (error instanceof GitHubIdentityMismatchError) {
330
+ return {
331
+ body: {
332
+ kind: "config",
333
+ platform: "github",
334
+ message: error.message,
335
+ account: error.account,
336
+ expected: error.expected,
337
+ actual: error.actual,
338
+ hint: "The account this repository is bound to is not the one that answered. Check repos.json "
339
+ + "and confirm with `pharos doctor --verify`.",
340
+ },
341
+ code: EXIT_USAGE,
342
+ };
343
+ }
344
+ if (error instanceof PullRequestNotAnIssueError) {
345
+ return {
346
+ body: {
347
+ kind: "usage",
348
+ platform: "github",
349
+ message: error.message,
350
+ repo: error.repo,
351
+ number: error.number,
352
+ },
353
+ code: EXIT_USAGE,
354
+ };
355
+ }
356
+ if (error instanceof GitHubRateLimitError) {
357
+ return {
358
+ body: {
359
+ kind: "rateLimit",
360
+ platform: "github",
361
+ message: error.message,
362
+ status: error.status,
363
+ retryAfterMs: error.retryAfterMs,
364
+ // A primary limit is the hourly 5,000 and can be most of an hour out; a
365
+ // secondary one is a burst and clears in seconds. Same advice, wildly
366
+ // different wait, so the caller is told which it is.
367
+ primary: error.primary,
368
+ requestId: error.requestId,
369
+ hint: "Wait retryAfterMs and repeat the identical call.",
370
+ },
371
+ code: EXIT_FAILED,
372
+ };
373
+ }
374
+ if (error instanceof GitHubAuthError) {
375
+ return { body: githubBody("auth", error), code: EXIT_USAGE };
376
+ }
377
+ if (error instanceof GitHubNotFoundError) {
378
+ return {
379
+ body: {
380
+ ...githubBody("notFound", error),
381
+ // GitHub answers 404 rather than 403 for a private repository you may
382
+ // not see — confirming it existed would be the leak. So "no such issue"
383
+ // and "wrong account" are one status code, and the account is the first
384
+ // thing to check rather than the last.
385
+ hint: "On GitHub a 404 is also how \"not visible to this account\" is spelled. Check the "
386
+ + "binding with `pharos doctor --verify` before concluding the issue does not exist.",
387
+ },
388
+ code: EXIT_FAILED,
389
+ };
390
+ }
391
+ if (error instanceof GitHubValidationError) {
392
+ return {
393
+ // 422: understood and refused. Repeating it unchanged cannot work, which
394
+ // is exactly what exit 2 means here.
395
+ body: { ...githubBody("github", error), errors: error.errors },
396
+ code: EXIT_USAGE,
397
+ };
398
+ }
399
+ /**
400
+ * **A GraphQL refusal, which arrives as an HTTP 200 and so has no status to
401
+ * classify by.**
402
+ *
403
+ * `GitHubGraphQLError` is deliberately not a {@link GitHubError} (see its own
404
+ * doc), so without this arm it fell through to `kind: "internal"` — measured
405
+ * live on #827 against a bad node id. That label is actively wrong: `internal`
406
+ * means *this tool* broke, so an agent reading it goes looking for a defect
407
+ * here while GitHub is simply saying no.
408
+ *
409
+ * The split below is by **who has to act**, which is the only distinction
410
+ * worth drawing:
411
+ *
412
+ * - GitHub's own classifiers (`NOT_FOUND`, `FORBIDDEN`, `RATE_LIMITED`) are
413
+ * answers about the request, and map onto the same kinds their REST
414
+ * equivalents get. The caller acts.
415
+ * - A **query-validation** code (`undefinedField`, `argumentLiteralsIncompatible`,
416
+ * `variableMismatch` …) carries no `type` at all — GitHub puts it in
417
+ * `extensions.code`. Those mean the query this package sent is malformed,
418
+ * which is a defect in `gh-core` and not something the caller did. `internal`
419
+ * is the honest label for exactly those, and it stays.
420
+ */
421
+ if (error instanceof GitHubGraphQLError) {
422
+ const kind = GRAPHQL_KINDS[error.type ?? ""];
423
+ return {
424
+ body: {
425
+ kind: kind?.kind ?? "internal",
426
+ platform: "github",
427
+ message: error.message,
428
+ operation: error.operation,
429
+ account: error.account,
430
+ // GitHub's classifier, verbatim, so a caller can branch on something
431
+ // finer than our kinds without us having to predict which.
432
+ graphQLType: error.type ?? null,
433
+ ...(kind === undefined
434
+ ? {
435
+ hint: "GitHub accepted the request and refused the operation, and gave no classifier — "
436
+ + "which is what a malformed query looks like. This is a defect in gh-core rather "
437
+ + "than something to retry.",
438
+ }
439
+ : { hint: kind.hint }),
440
+ },
441
+ code: kind?.code ?? EXIT_FAILED,
442
+ };
443
+ }
444
+ if (error instanceof GitHubError) {
445
+ return { body: githubBody("github", error), code: EXIT_FAILED };
446
+ }
447
+ if (error instanceof GitHubNetworkError) {
448
+ return {
449
+ body: {
450
+ kind: "network",
451
+ platform: "github",
452
+ message: error.message,
453
+ method: error.method,
454
+ url: error.url,
455
+ },
456
+ code: EXIT_FAILED,
457
+ };
458
+ }
459
+ return undefined;
460
+ }
461
+ /**
462
+ * GitHub's GraphQL classifiers, mapped onto the kinds an agent already branches
463
+ * on. Anything absent from here is a query-validation code and stays
464
+ * `internal` — see the call site.
465
+ */
466
+ const GRAPHQL_KINDS = {
467
+ NOT_FOUND: {
468
+ kind: "notFound",
469
+ code: EXIT_FAILED,
470
+ hint: "The node id names nothing this account can see. On GitHub that is also how \"not visible "
471
+ + "to you\" is spelled, so check the binding before concluding it is gone. "
472
+ + "`pharos comment list <owner/name#n>` prints the current ids.",
473
+ },
474
+ FORBIDDEN: {
475
+ kind: "auth",
476
+ code: EXIT_USAGE,
477
+ hint: "The account is authenticated and not permitted to do this. Hiding and pinning need write "
478
+ + "access to the repository; `pharos comment list` reports what each comment permits in "
479
+ + "its `may` object, which is cheaper than finding out this way.",
480
+ },
481
+ RATE_LIMITED: {
482
+ kind: "rateLimit",
483
+ code: EXIT_FAILED,
484
+ hint: "GraphQL has its own hourly budget, separate from REST's 5,000. Wait and repeat the "
485
+ + "identical call.",
486
+ },
487
+ };
488
+ function githubBody(kind, error) {
489
+ return {
490
+ kind,
491
+ platform: "github",
492
+ message: error.message,
493
+ status: error.status,
494
+ method: error.method,
495
+ url: error.url,
496
+ // GitHub's handle for a request, and the only one their support accepts —
497
+ // the same role `activityId` plays on the Azure DevOps side.
498
+ requestId: error.requestId,
499
+ ...(error.documentationUrl === undefined ? {} : { documentationUrl: error.documentationUrl }),
500
+ };
501
+ }
209
502
  /**
210
503
  * An Azure DevOps failure, with **what to do about it** where that is known.
211
504
  *
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB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EAA2E;QAC3E,4CAA4C;QAC5C,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC"}
package/dist/session.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { AdoClient, WikiApi } from "@floh-solutions/ado-core";
2
+ import type { GitHubClient } from "@floh-solutions/gh-core";
2
3
  import { WriteBudget } from "./budget.js";
4
+ import { HalfLinkJournal } from "./half-link.js";
3
5
  import { type ExitCode, type Io } from "./output.js";
4
6
  /**
5
7
  * One invocation's world: the client, the budget it spends against, the wiki it
@@ -19,16 +21,87 @@ export interface SessionOptions {
19
21
  pretty: boolean;
20
22
  /** Injected by tests; production passes nothing and gets a real client. */
21
23
  client?: AdoClient | undefined;
24
+ /** Injected by tests; production passes nothing and gets one from `repos.json`. */
25
+ github?: GitHubClient | undefined;
22
26
  }
23
27
  export declare class Session {
24
28
  #private;
25
- readonly client: AdoClient;
26
- readonly wiki: WikiApi;
27
29
  readonly budget: WriteBudget;
28
30
  readonly apply: boolean;
29
31
  readonly previewOnly: boolean;
30
32
  readonly pretty: boolean;
33
+ /**
34
+ * Adoptions this machine started and did not finish — see `half-link.ts`.
35
+ *
36
+ * Built from the invocation's environment rather than reached for inside the
37
+ * command, so a run whose env names no `HOME` has no journal instead of
38
+ * quietly writing into whichever home directory the process happens to have.
39
+ */
40
+ readonly halfLinks: HalfLinkJournal;
31
41
  constructor(options: SessionOptions);
42
+ /**
43
+ * The Azure DevOps client — **resolved on first use, not in the constructor.**
44
+ *
45
+ * It was built eagerly, and that made `ADO_PAT` the price of entry to the
46
+ * whole CLI: `pharos comment list contoso/widgets#45` reads a GitHub issue
47
+ * through `gh-core` with the `gh` credential and never touches Azure DevOps,
48
+ * and it answered `{"kind":"config","message":"ADO_PAT is not set…"}` (#839).
49
+ * Somebody with `gh` signed in and no Azure DevOps PAT — a state
50
+ * `pharos doctor` reports as fine, and which the separate Keychain entries
51
+ * exist to make possible — could not use a single GitHub verb.
52
+ *
53
+ * {@link github} was made lazy for exactly this reason (#782) and this half
54
+ * was not. The fix belongs here rather than in the `comment` dispatch: any
55
+ * verb family that grows a GitHub target inherits it, and a special case in
56
+ * one command is a special case the next one has to remember.
57
+ *
58
+ * **Resolution failure is deferred, never softened.** The `AdoConfigError`
59
+ * still names the missing variable and still exits 2 — it arrives when
60
+ * something actually needs Azure DevOps, which is where it is an answer
61
+ * rather than an obstacle. See {@link approve} for the one place that
62
+ * ordering has to be forced.
63
+ */
64
+ get client(): AdoClient;
65
+ /** The wiki API, over {@link client}'s transport — and lazy for its sake. */
66
+ get wiki(): WikiApi;
67
+ /**
68
+ * The GitHub client, resolved once, from `~/.config/pharos/repos.json`.
69
+ *
70
+ * Three things about this are deliberate.
71
+ *
72
+ * **Its fetch is wrapped by the same {@link WriteBudget} the Azure DevOps
73
+ * client uses.** `--max-writes 0` promises that an invocation cannot change
74
+ * anything, and that promise is worthless if it covers one platform of a
75
+ * two-platform verb: `pharos issue adopt` posts a comment on GitHub, and a cap
76
+ * that let that through would be a cap in name only. `gh-core`'s transport
77
+ * already recognises a refusal thrown by a fetch wrapper and rethrows it
78
+ * unretried rather than reporting it as a dead socket.
79
+ *
80
+ * **It is loaded lazily, and imported dynamically.** Twenty-seven of the
81
+ * twenty-eight verbs here never touch GitHub, and `gh-core` reaches for
82
+ * `node:child_process` at import time to talk to `gh`. `doctor` does the same
83
+ * thing for the same reason.
84
+ *
85
+ * **There is no repository default.** `GitHubClient` has no current repo and
86
+ * no current account by construction (plan §2) — every call names both, and an
87
+ * unbound repository is an error naming `repos.json` rather than a guess at
88
+ * whichever `gh` account happens to be active.
89
+ */
90
+ github(): Promise<GitHubClient>;
91
+ /**
92
+ * The web address of a work item — what a person clicks, not what the API
93
+ * reads.
94
+ *
95
+ * `WorkItem.url` is the REST url and opening it in a browser gives JSON, so a
96
+ * comment on a public GitHub issue carrying it would be worse than carrying
97
+ * nothing. `_links.html.href` is what Azure DevOps itself calls the human
98
+ * address; it is only present when the read asked for links, so the composed
99
+ * form is the fallback rather than the other way round.
100
+ */
101
+ workItemUrl(item: {
102
+ id: number;
103
+ _links?: Record<string, unknown>;
104
+ }): string;
32
105
  /**
33
106
  * The wiki to act on, resolved once.
34
107
  *
@@ -53,6 +126,16 @@ export interface DestructiveAction {
53
126
  what: string;
54
127
  /** The structured version, emitted either way so a preview is machine-readable. */
55
128
  would: Record<string, unknown>;
129
+ /**
130
+ * Which platform is about to be written to. Defaults to `"ado"`.
131
+ *
132
+ * It exists so {@link approve} can put the two refusals in the right order —
133
+ * see its doc. Azure DevOps is the default because it is what all but one of
134
+ * the destructive verbs here write to, and because the failure mode of
135
+ * forgetting the flag is loud (a GitHub-only verb starts demanding a PAT,
136
+ * which is #839 and has a test) rather than silent.
137
+ */
138
+ platform?: "ado" | "github" | undefined;
56
139
  }
57
140
  /**
58
141
  * The gate in front of anything that destroys or overwrites.
@@ -71,6 +154,22 @@ export interface DestructiveAction {
71
154
  * is how a half-finished job gets reported as done (`docs/pharos-cli-plan.md`
72
155
  * §2.5). `--dry-run` exits 0 because there the preview IS the deliverable.
73
156
  *
157
+ * ## The credential is checked before the gate, and that ordering is the point
158
+ *
159
+ * {@link Session.client} resolves on first use (#839), and every arm below
160
+ * runs *before* the verb touches it. So on a machine with no `ADO_PAT`,
161
+ * `pharos comment delete 210 5` would answer "Refusing to delete comment 5 on
162
+ * #210 without --yes" — a refusal that invites a retry with `--yes` which then
163
+ * fails on the credential anyway. Two refusals, the useful one second.
164
+ *
165
+ * Touching the client here puts the credential failure back in front, exactly
166
+ * where it was when the client was eager. A `--dry-run` preview of an Azure
167
+ * DevOps write is refused for the same reason: a preview of something this
168
+ * machine cannot do is a preview of nothing.
169
+ *
170
+ * A GitHub action says so and is exempt — that is the whole bug this ordering
171
+ * has to avoid recreating.
172
+ *
74
173
  * @returns `undefined` to proceed with the write, or the exit code to return.
75
174
  */
76
175
  export declare function approve(io: Io, session: Session, action: DestructiveAction): ExitCode | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAgB,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAsC,KAAK,QAAQ,EAAE,KAAK,EAAE,EAAE,MAAM,aAAa,CAAC;AAEzF;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;IACf,gFAAgF;IAChF,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAChC;AAED,qBAAa,OAAO;;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAKb,OAAO,EAAE,cAAc;IAkBnC;;;;;;;;;OASG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvC,wEAAwE;IAClE,cAAc,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;Q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