vouchington-tooling 0.58.0 → 0.59.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 (74) hide show
  1. package/README.md +21 -0
  2. package/dist/agent-issue-labels/ensure-labels.d.mts +1 -1
  3. package/dist/agent-issue-labels/ensure-labels.mjs +1 -1
  4. package/dist/browser-session-runner/tail-queue.d.mts +1 -1
  5. package/dist/browser-session-runner/tail-queue.mjs +1 -1
  6. package/dist/cli/commands/gitleaks-directory-scan.d.mts +4 -0
  7. package/dist/cli/commands/gitleaks-directory-scan.mjs +9 -0
  8. package/dist/cli/commands/transient-retry.d.mts +13 -0
  9. package/dist/cli/commands/transient-retry.mjs +68 -0
  10. package/dist/cli/index.mjs +8 -53
  11. package/dist/cli/parse-forwarded-commands.d.mts +6 -0
  12. package/dist/cli/parse-forwarded-commands.mjs +4 -0
  13. package/dist/cli/parse.d.mts +6 -0
  14. package/dist/cli/script-paths.d.mts +5 -0
  15. package/dist/cli/script-paths.mjs +48 -0
  16. package/dist/cli/usage.d.mts +1 -1
  17. package/dist/cli/usage.mjs +7 -0
  18. package/dist/dead-code/baseline.d.mts +19 -0
  19. package/dist/dead-code/baseline.mjs +124 -0
  20. package/dist/dead-code/child-command.d.mts +6 -0
  21. package/dist/dead-code/child-command.mjs +107 -0
  22. package/dist/dead-code/cli.d.mts +5 -0
  23. package/dist/dead-code/cli.mjs +71 -0
  24. package/dist/dead-code/entry-roots.d.mts +7 -0
  25. package/dist/dead-code/entry-roots.mjs +43 -0
  26. package/dist/dead-code/fixture-deadline.test-helpers.d.mts +1 -0
  27. package/dist/dead-code/fixture-deadline.test-helpers.mjs +9 -0
  28. package/dist/dead-code/gate.d.mts +29 -0
  29. package/dist/dead-code/gate.mjs +33 -0
  30. package/dist/dead-code/gate.test-helpers.d.mts +14 -0
  31. package/dist/dead-code/gate.test-helpers.mjs +35 -0
  32. package/dist/dead-code/index.d.mts +9 -0
  33. package/dist/dead-code/index.mjs +7 -0
  34. package/dist/dead-code/scan.d.mts +11 -0
  35. package/dist/dead-code/scan.mjs +37 -0
  36. package/dist/dead-code/tracked-snapshot.d.mts +2 -0
  37. package/dist/dead-code/tracked-snapshot.mjs +72 -0
  38. package/dist/markdown/details-scope.d.mts +1 -1
  39. package/dist/markdown/details-scope.mjs +1 -1
  40. package/dist/transient-retry/attempts.d.mts +1 -1
  41. package/dist/transient-retry/attempts.mjs +1 -1
  42. package/dist/transient-retry/decision-evaluator.d.mts +3 -3
  43. package/dist/transient-retry/gh-api.d.mts +30 -0
  44. package/dist/transient-retry/gh-api.mjs +68 -0
  45. package/dist/transient-retry/github-actions-log.d.mts +7 -0
  46. package/dist/transient-retry/github-actions-log.mjs +33 -0
  47. package/dist/transient-retry/index.d.mts +15 -0
  48. package/dist/transient-retry/index.mjs +8 -0
  49. package/dist/transient-retry/log-stream.d.mts +12 -0
  50. package/dist/transient-retry/log-stream.mjs +39 -0
  51. package/dist/transient-retry/log-window.d.mts +18 -0
  52. package/dist/transient-retry/log-window.mjs +94 -0
  53. package/dist/transient-retry/rerun.d.mts +23 -0
  54. package/dist/transient-retry/rerun.mjs +68 -0
  55. package/dist/transient-retry/run-context-annotations.d.mts +7 -0
  56. package/dist/transient-retry/run-context-annotations.mjs +44 -0
  57. package/dist/transient-retry/run-context-jobs.d.mts +20 -0
  58. package/dist/transient-retry/run-context-jobs.mjs +54 -0
  59. package/dist/transient-retry/run-context-logs.d.mts +12 -0
  60. package/dist/transient-retry/run-context-logs.mjs +86 -0
  61. package/dist/transient-retry/run-context-rule-attempts.d.mts +14 -0
  62. package/dist/transient-retry/run-context-rule-attempts.mjs +65 -0
  63. package/dist/transient-retry/run-context-types.d.mts +49 -0
  64. package/dist/transient-retry/run-context-types.mjs +3 -0
  65. package/dist/transient-retry/run-context.d.mts +9 -0
  66. package/dist/transient-retry/run-context.mjs +25 -0
  67. package/dist/transient-retry/run-context.test-helpers.d.mts +16 -0
  68. package/dist/transient-retry/run-context.test-helpers.mjs +56 -0
  69. package/dist/transient-retry/types.d.mts +8 -7
  70. package/dist/vitest-diagnostics/vitest-worker-exit-diagnostics-reporter.mjs +1 -1
  71. package/dist/workflow-secrets-drift/gh.d.mts +1 -1
  72. package/dist/workflow-secrets-drift/gh.mjs +1 -1
  73. package/package.json +6 -1
  74. package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
package/README.md CHANGED
@@ -86,6 +86,7 @@ vouchington harness-assert-gates HARNESS_DISPATCH_ENABLED HARNESS_SHEPHERD_ENABL
86
86
  echo '[{"login":"octocat","type":"User"}]' | vouchington gha-collaborator-trust owner/repo --allow-bot github-actions[bot]
87
87
  vouchington nuget-central-version trusted.props candidate.props metadata.json out.props
88
88
  vouchington verify-workflow-secrets --repo owner/name --inventory .github/workflows/workflow-secrets-inventory.mts
89
+ vouchington dead-code --baseline dead-code-baseline.json --config .jscpd.json --update
89
90
  vouchington swift-semantic-equal BASE HEAD App.swift
90
91
  vouchington post-review
91
92
  vouchington stage-review-payload optional|required <source> <destination>
@@ -250,6 +251,25 @@ The script also deletes `.cache` directories and the direct `.cache`, `.vite`, a
250
251
  directories inside `node_modules`. It needs `flock` or `lockf` and holds
251
252
  `.local/reset-worktree.lock` for the run.
252
253
 
254
+ ## Rerunning known-transient workflow failures
255
+
256
+ `vouchington transient-retry --rules <module> [--repo owner/name] [--token-env NAME] [--dry-run]
257
+ <run-id>` fetches a failed GitHub Actions run, evaluates the rules your module exports, and runs
258
+ `gh run rerun` only when a rule asks for a rerun. The engine ships no rules: the module exports
259
+ `rules` (an array of `WorkflowRetryRule`) and optionally `limits`. It exits 0 when a rerun was
260
+ requested (or would be, with `--dry-run`), 2 when none is warranted, and 1 on error. The repository
261
+ comes from `--repo`, `GITHUB_REPOSITORY`, or the checkout; `--token-env` names the variable that
262
+ holds the token, which is passed to `gh` as `GH_TOKEN`.
263
+
264
+ Rules receive a `WorkflowRunContext`: job names, conclusions and steps, plus failed-job logs and
265
+ annotations that are fetched only when a rule reads them. Logs may contain secrets, so they are
266
+ streamed and never buffered whole: each job keeps a head window and a tail window
267
+ (`limits.headBytes`, `limits.tailBytes`), reading stops at `limits.maxReadBytes`, and the run keeps
268
+ at most `limits.totalBytes` in all. A log that cannot be read is reported through
269
+ `failedJobLogFetchFailures` with empty text. Only job names and the decision are printed. The same
270
+ pieces are exported from `vouchington-tooling/transient-retry` (`rerunKnownTransient`,
271
+ `buildWorkflowRunContext`, `createGhApi`).
272
+
253
273
  ## Reclaiming finished worktrees
254
274
 
255
275
  `vouchington worktree reclaim [--yes] [--json]` removes git worktrees whose work is done. It is a
@@ -370,6 +390,7 @@ import { runAstGrepExamples } from 'vouchington-tooling/ast-grep-examples'
370
390
  import { astGrepPackPaths } from 'vouchington-tooling/ast-grep-pack'
371
391
  import { validateNugetUpdate } from 'vouchington-tooling/nuget-central-version'
372
392
  import { runVerifyWorkflowSecretsCli } from 'vouchington-tooling/workflow-secrets-drift'
393
+ import { runDeadCodeGate } from 'vouchington-tooling/dead-code'
373
394
  import { normalizeSwiftSource } from 'vouchington-tooling/swift-semantic-equal'
374
395
  import { parseUniqueSwiftBinaryTargetChecksum } from 'vouchington-tooling/swift-source-offset'
375
396
  import { validateResolvedPinDelta } from 'vouchington-tooling/swift-resolved-pin-delta'
@@ -1,4 +1,4 @@
1
- import { type RunTextCommand } from '../gh-cli/exec.mts';
1
+ import { type RunTextCommand } from '../gh-cli/index.mts';
2
2
  import { type LabelPolicy } from './label-policy.mts';
3
3
  export type EnsureLabelsOptions = {
4
4
  labels: readonly string[];
@@ -1,4 +1,4 @@
1
- import { runGh } from "../gh-cli/exec.mjs";
1
+ import { runGh } from "../gh-cli/index.mjs";
2
2
  import { DEFAULT_LABEL_POLICY, labelMetadata } from "./label-policy.mjs";
3
3
  /**
4
4
  * Creates missing repository labels through `gh` (or force-updates all with `update`). Every label
@@ -1,7 +1,7 @@
1
1
  export declare class TailQueue {
2
- readonly maxBytes: number;
3
2
  readonly chunks: Buffer[];
4
3
  bytes: number;
4
+ readonly maxBytes: number;
5
5
  constructor(maxBytes: number);
6
6
  append(text: string): void;
7
7
  toBuffer(): Buffer;
@@ -1,7 +1,7 @@
1
1
  export class TailQueue {
2
- maxBytes;
3
2
  chunks = [];
4
3
  bytes = 0;
4
+ maxBytes;
5
5
  constructor(maxBytes) {
6
6
  this.maxBytes = maxBytes;
7
7
  }
@@ -0,0 +1,4 @@
1
+ export declare function runGitleaksDirectoryScanCommand(parsed: {
2
+ config: string;
3
+ directory?: string | undefined;
4
+ }): number | Promise<number>;
@@ -0,0 +1,9 @@
1
+ import { packageScriptPath } from "../script-path.mjs";
2
+ import { runScript } from "./spawn-script.mjs";
3
+ export function runGitleaksDirectoryScanCommand(parsed) {
4
+ return runScript('bash', packageScriptPath('scripts/gitleaks-directory-scan.sh'), [
5
+ '--config',
6
+ parsed.config,
7
+ ...(parsed.directory === undefined ? [] : ['--root', parsed.directory]),
8
+ ]);
9
+ }
@@ -0,0 +1,13 @@
1
+ import type { LogLimits } from '../../transient-retry/log-window.mts';
2
+ interface RulesModule {
3
+ rules?: unknown;
4
+ limits?: Partial<LogLimits>;
5
+ }
6
+ type LoadModule = (specifier: string) => Promise<RulesModule>;
7
+ /**
8
+ * `vouchington transient-retry --rules <module> [--repo owner/name] [--token-env NAME] [--dry-run]
9
+ * <run-id>`. The module must export `rules` (an array of retry rules) and may export `limits`.
10
+ * Exits 0 when a rerun was requested, 2 when none is warranted, 1 on error.
11
+ */
12
+ export declare function runTransientRetryCommand(args: readonly string[], env?: NodeJS.ProcessEnv, load?: LoadModule): Promise<number>;
13
+ export {};
@@ -0,0 +1,68 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { resolve } from 'node:path';
10
+ import { pathToFileURL } from 'node:url';
11
+ import { parseArgs } from 'node:util';
12
+ import { createGhApi, createGhRunner } from "../../transient-retry/gh-api.mjs";
13
+ import { createGhLogStreamer } from "../../transient-retry/log-stream.mjs";
14
+ import { rerunKnownTransient } from "../../transient-retry/rerun.mjs";
15
+ import { commandUsage } from "../usage.mjs";
16
+ const loadModule = (specifier) => import(__rewriteRelativeImportExtension(specifier));
17
+ /**
18
+ * `vouchington transient-retry --rules <module> [--repo owner/name] [--token-env NAME] [--dry-run]
19
+ * <run-id>`. The module must export `rules` (an array of retry rules) and may export `limits`.
20
+ * Exits 0 when a rerun was requested, 2 when none is warranted, 1 on error.
21
+ */
22
+ export async function runTransientRetryCommand(args, env = process.env, load = loadModule) {
23
+ let parsed;
24
+ try {
25
+ parsed = parse(args);
26
+ }
27
+ catch (error) {
28
+ process.stderr.write(`vouchington: ${error.message}\n${commandUsage('transient-retry')}`);
29
+ return 2;
30
+ }
31
+ const { values, positionals } = parsed;
32
+ const [runId, extra] = positionals;
33
+ if (values.rules === undefined || runId === undefined || extra !== undefined) {
34
+ process.stderr.write(`vouchington: expected --rules <module> and one run id\n${commandUsage('transient-retry')}`);
35
+ return 2;
36
+ }
37
+ const repository = values.repo ?? env.GITHUB_REPOSITORY;
38
+ try {
39
+ const module = await load(pathToFileURL(resolve(values.rules)).href);
40
+ if (!Array.isArray(module.rules))
41
+ throw new Error('rules module must export a `rules` array');
42
+ return await rerunKnownTransient({
43
+ api: createGhApi({ run: createGhRunner(values['token-env']) }),
44
+ streamLog: createGhLogStreamer(values['token-env']),
45
+ dryRun: values['dry-run'],
46
+ rules: module.rules,
47
+ runId,
48
+ ...(module.limits === undefined ? {} : { limits: module.limits }),
49
+ ...(repository === undefined ? {} : { repository }),
50
+ });
51
+ }
52
+ catch (error) {
53
+ process.stderr.write(`vouchington: ${error instanceof Error ? error.message : String(error)}\n`);
54
+ return 1;
55
+ }
56
+ }
57
+ function parse(args) {
58
+ return parseArgs({
59
+ args: [...args],
60
+ allowPositionals: true,
61
+ options: {
62
+ 'dry-run': { type: 'boolean', default: false },
63
+ repo: { type: 'string' },
64
+ rules: { type: 'string' },
65
+ 'token-env': { type: 'string' },
66
+ },
67
+ });
68
+ }
@@ -8,11 +8,13 @@ import { runSwiftSemanticEqualCli } from "../swift-semantic-equal/cli.mjs";
8
8
  import { runAgentIssueLabels } from "./commands/agent-issue-labels.mjs";
9
9
  import { runGhaArtifactsCleanup } from "./commands/gha-artifacts-cleanup.mjs";
10
10
  import { runGhaRuntimeAudit } from "./commands/gha-runtime-audit.mjs";
11
+ import { runGitleaksDirectoryScanCommand } from "./commands/gitleaks-directory-scan.mjs";
11
12
  import { runHttpOrigin } from "./commands/http-origin.mjs";
12
13
  import { runPnpmInstallCli } from "./commands/pnpm-install.mjs";
13
14
  import { runRunnerPortPolicy } from "./commands/runner-port-policy.mjs";
14
15
  import { runScript } from "./commands/spawn-script.mjs";
15
16
  import { runNugetCentralVersionCommand } from "./commands/nuget-central-version.mjs";
17
+ import { runDeadCodeCli } from "../dead-code/cli.mjs";
16
18
  import { runVerifyWorkflowSecretsCli } from "../workflow-secrets-drift/cli.mjs";
17
19
  import { runVitestBlobManifestCommand } from "./commands/vitest-blob-manifest.mjs";
18
20
  import { runVitestReportAttemptCommand } from "./commands/vitest-report-attempt.mjs";
@@ -32,57 +34,10 @@ import { runAstGrepPackCommand } from "./commands/ast-grep-pack.mjs";
32
34
  import { runGhaWorkspacePolicy } from "./commands/gha-workspace-policy.mjs";
33
35
  import { readInstalledVersion } from "./installed-version.mjs";
34
36
  import { parseCli } from "./parse.mjs";
37
+ import { SCRIPT_PATHS } from "./script-paths.mjs";
35
38
  import { runStoryCoverageLazy } from "./story-coverage-lazy.mjs";
36
39
  import { packageScriptPath } from "./script-path.mjs";
37
40
  import { commandUsage, printUsage } from "./usage.mjs";
38
- const SCRIPT_PATHS = {
39
- 'gha-output': { command: 'bash', path: 'scripts/gha/write-github-multiline-output.sh' },
40
- 'gha-needs-results': { command: 'bash', path: 'scripts/gha/check-needs-results.sh' },
41
- 'download-with-diagnostics': {
42
- command: 'bash',
43
- path: 'scripts/gha/download-with-diagnostics.sh',
44
- },
45
- 'download-optional-run-artifacts': {
46
- command: 'bash',
47
- path: 'scripts/gha/download-optional-run-artifacts.sh',
48
- },
49
- 'host-pressure-diagnostics': {
50
- command: 'bash',
51
- path: 'scripts/gha/host-pressure-diagnostics.sh',
52
- },
53
- 'allocate-browser-safe-ports': {
54
- command: 'python3',
55
- path: 'scripts/allocate-browser-safe-ports.py',
56
- },
57
- 'diagnose-port-collision': {
58
- command: 'bash',
59
- path: 'scripts/gha/diagnose-port-collision.sh',
60
- },
61
- 'prepare-trivy-db': { command: 'bash', path: 'scripts/gha/prepare-trivy-db.sh' },
62
- 'check-cache-size': { command: 'bash', path: 'scripts/gha/check-cache-size.sh' },
63
- 'make-shard-matrix': { command: 'bash', path: 'scripts/gha/make-shard-matrix.sh' },
64
- 'load-runner-env': { command: 'bash', path: 'scripts/gha/load-runner-env.sh' },
65
- 'clean-workspace': { command: 'bash', path: 'scripts/gha/clean-workspace.sh' },
66
- 'install-github-release': { command: 'bash', path: 'scripts/gha/install-github-release.sh' },
67
- 'run-with-timeout': { command: 'bash', path: 'scripts/gha/run-with-timeout.sh' },
68
- 'lint-links': { command: 'bash', path: 'scripts/gha/lint-links.sh' },
69
- 'materialize-pr-context': { command: 'bash', path: 'scripts/gha/materialize-pr-context.sh' },
70
- 'wait-for-apt-locks': { command: 'bash', path: 'scripts/gha/wait-for-apt-locks.sh' },
71
- 'install-playwright-chromium-arm64': {
72
- command: 'bash',
73
- path: 'scripts/gha/install-playwright-chromium-arm64.sh',
74
- },
75
- 'ghcr-package-retention': { command: 'bash', path: 'scripts/gha/ghcr-package-retention.sh' },
76
- 'harness-admission-lane': {
77
- command: 'bash',
78
- path: 'scripts/gha/harness-admission-lane.sh',
79
- },
80
- 'harness-assert-gates': { command: 'bash', path: 'scripts/gha/harness-assert-gates.sh' },
81
- 'gha-collaborator-trust': {
82
- command: 'bash',
83
- path: 'scripts/gha/gha-collaborator-trust.sh',
84
- },
85
- };
86
41
  export function runCli(argv = process.argv) {
87
42
  const parsed = parseCli(argv);
88
43
  switch (parsed.kind) {
@@ -123,6 +78,8 @@ export function runCli(argv = process.argv) {
123
78
  return runNugetCentralVersionCommand(parsed.args);
124
79
  case 'verify-workflow-secrets':
125
80
  return runVerifyWorkflowSecretsCli(parsed.args);
81
+ case 'dead-code':
82
+ return runDeadCodeCli(parsed.args);
126
83
  case 'swift-semantic-equal':
127
84
  return runSwiftSemanticEqualCli(parsed.args);
128
85
  case 'post-review':
@@ -147,6 +104,8 @@ export function runCli(argv = process.argv) {
147
104
  return runAgentBlackboardCommand(parsed.args);
148
105
  case 'mcp':
149
106
  return runMcpCommand(parsed.args);
107
+ case 'transient-retry':
108
+ return import("./commands/transient-retry.mjs").then((command) => command.runTransientRetryCommand(parsed.args));
150
109
  case 'worktree':
151
110
  return runWorktreeCommand(parsed.args);
152
111
  case 'require-up-to-date':
@@ -154,11 +113,7 @@ export function runCli(argv = process.argv) {
154
113
  case 'fresh-base':
155
114
  return runFreshBase(parsed);
156
115
  case 'gitleaks-directory-scan':
157
- return runScript('bash', packageScriptPath('scripts/gitleaks-directory-scan.sh'), [
158
- '--config',
159
- parsed.config,
160
- ...(parsed.directory === undefined ? [] : ['--root', parsed.directory]),
161
- ]);
116
+ return runGitleaksDirectoryScanCommand(parsed);
162
117
  case 'ast-grep-examples':
163
118
  return runAstGrepExamplesCommand(parsed);
164
119
  case 'ast-grep-pack':
@@ -22,6 +22,9 @@ type ForwardedCommand = {
22
22
  } | {
23
23
  kind: 'verify-workflow-secrets';
24
24
  args: string[];
25
+ } | {
26
+ kind: 'dead-code';
27
+ args: string[];
25
28
  } | {
26
29
  kind: 'swift-semantic-equal';
27
30
  args: string[];
@@ -46,6 +49,9 @@ type ForwardedCommand = {
46
49
  } | {
47
50
  kind: 'worktree';
48
51
  args: string[];
52
+ } | {
53
+ kind: 'transient-retry';
54
+ args: string[];
49
55
  };
50
56
  export declare function parseForwardedCommand(command: string | undefined, args: string[]): ForwardedCommand | undefined;
51
57
  export {};
@@ -15,6 +15,8 @@ export function parseForwardedCommand(command, args) {
15
15
  return { kind: 'nuget-central-version', args };
16
16
  if (command === 'verify-workflow-secrets')
17
17
  return { kind: 'verify-workflow-secrets', args };
18
+ if (command === 'dead-code')
19
+ return { kind: 'dead-code', args };
18
20
  if (command === 'swift-semantic-equal')
19
21
  return { kind: 'swift-semantic-equal', args };
20
22
  if (command === 'post-review')
@@ -31,5 +33,7 @@ export function parseForwardedCommand(command, args) {
31
33
  return { kind: 'mcp', args };
32
34
  if (command === 'worktree')
33
35
  return { kind: 'worktree', args };
36
+ if (command === 'transient-retry')
37
+ return { kind: 'transient-retry', args };
34
38
  return undefined;
35
39
  }
@@ -44,6 +44,9 @@ export type ParsedCli = {
44
44
  } | {
45
45
  kind: 'verify-workflow-secrets';
46
46
  args: string[];
47
+ } | {
48
+ kind: 'dead-code';
49
+ args: string[];
47
50
  } | {
48
51
  kind: 'swift-semantic-equal';
49
52
  args: string[];
@@ -77,6 +80,9 @@ export type ParsedCli = {
77
80
  } | {
78
81
  kind: 'worktree';
79
82
  args: string[];
83
+ } | {
84
+ kind: 'transient-retry';
85
+ args: string[];
80
86
  } | {
81
87
  kind: 'require-up-to-date';
82
88
  remote: string;
@@ -0,0 +1,5 @@
1
+ import type { ScriptCommand } from './parse.mts';
2
+ export declare const SCRIPT_PATHS: Record<ScriptCommand, {
3
+ command: string;
4
+ path: string;
5
+ }>;
@@ -0,0 +1,48 @@
1
+ export const SCRIPT_PATHS = {
2
+ 'gha-output': { command: 'bash', path: 'scripts/gha/write-github-multiline-output.sh' },
3
+ 'gha-needs-results': { command: 'bash', path: 'scripts/gha/check-needs-results.sh' },
4
+ 'download-with-diagnostics': {
5
+ command: 'bash',
6
+ path: 'scripts/gha/download-with-diagnostics.sh',
7
+ },
8
+ 'download-optional-run-artifacts': {
9
+ command: 'bash',
10
+ path: 'scripts/gha/download-optional-run-artifacts.sh',
11
+ },
12
+ 'host-pressure-diagnostics': {
13
+ command: 'bash',
14
+ path: 'scripts/gha/host-pressure-diagnostics.sh',
15
+ },
16
+ 'allocate-browser-safe-ports': {
17
+ command: 'python3',
18
+ path: 'scripts/allocate-browser-safe-ports.py',
19
+ },
20
+ 'diagnose-port-collision': {
21
+ command: 'bash',
22
+ path: 'scripts/gha/diagnose-port-collision.sh',
23
+ },
24
+ 'prepare-trivy-db': { command: 'bash', path: 'scripts/gha/prepare-trivy-db.sh' },
25
+ 'check-cache-size': { command: 'bash', path: 'scripts/gha/check-cache-size.sh' },
26
+ 'make-shard-matrix': { command: 'bash', path: 'scripts/gha/make-shard-matrix.sh' },
27
+ 'load-runner-env': { command: 'bash', path: 'scripts/gha/load-runner-env.sh' },
28
+ 'clean-workspace': { command: 'bash', path: 'scripts/gha/clean-workspace.sh' },
29
+ 'install-github-release': { command: 'bash', path: 'scripts/gha/install-github-release.sh' },
30
+ 'run-with-timeout': { command: 'bash', path: 'scripts/gha/run-with-timeout.sh' },
31
+ 'lint-links': { command: 'bash', path: 'scripts/gha/lint-links.sh' },
32
+ 'materialize-pr-context': { command: 'bash', path: 'scripts/gha/materialize-pr-context.sh' },
33
+ 'wait-for-apt-locks': { command: 'bash', path: 'scripts/gha/wait-for-apt-locks.sh' },
34
+ 'install-playwright-chromium-arm64': {
35
+ command: 'bash',
36
+ path: 'scripts/gha/install-playwright-chromium-arm64.sh',
37
+ },
38
+ 'ghcr-package-retention': { command: 'bash', path: 'scripts/gha/ghcr-package-retention.sh' },
39
+ 'harness-admission-lane': {
40
+ command: 'bash',
41
+ path: 'scripts/gha/harness-admission-lane.sh',
42
+ },
43
+ 'harness-assert-gates': { command: 'bash', path: 'scripts/gha/harness-assert-gates.sh' },
44
+ 'gha-collaborator-trust': {
45
+ command: 'bash',
46
+ path: 'scripts/gha/gha-collaborator-trust.sh',
47
+ },
48
+ };
@@ -1,4 +1,4 @@
1
- export declare const USAGE = "Usage: vouchington <command> [options]\n\nCommands:\n runner-port-policy Print or validate a runner port policy\n with-host-lock Run a command under a host-wide lock\n host-storage Check free space on caller-supplied paths\n gha-runtime-audit Audit successful GitHub Actions job runtimes\n require-up-to-date Require HEAD to include a fetched remote branch\n fresh-base Classify the worktree against a remote base branch\n gitleaks-directory-scan Scan a directory with Gitleaks\n ast-grep-examples Run AST-grep rule examples\n ast-grep-pack Print shipped unconditional AST-grep pack paths as JSON\n gha-workspace-policy Check GitHub Actions workspace safety policy\n gha-output Write a collision-safe multiline GITHUB_OUTPUT record\n gha-needs-results Fail if required GitHub Actions job results failed\n download-with-diagnostics Download a URL and report HTTP status on failure\n download-optional-run-artifacts Download optional artifacts from the current run\n host-pressure-diagnostics Print a bounded host memory/OOM/PSI snapshot\n allocate-browser-safe-ports Allocate Fetch-safe localhost ports\n diagnose-port-collision Capture bounded localhost port diagnostics\n prepare-trivy-db Download the Trivy vulnerability database\n gha-artifacts-cleanup Delete classified GitHub Actions artifacts\n agent-issue-labels Map changed paths to labels; create missing repository labels\n http-origin Validate an optional HTTP(S) origin\n vitest-blob-manifest Stamp a vitest-blob-manifest:v1 identity file\n vitest-report-attempt Write or read a Vitest report-attempt marker\n prepare-vitest-reports Validate and select Vitest report JSON files\n pnpm-install Install a pnpm workspace with retry and release-age fail-fast\n check-cache-size Measure a path and decide whether to save a GHA cache\n make-shard-matrix Emit a [1..N] GitHub Actions shard matrix\n load-runner-env Overlay a runner env file onto GITHUB_ENV with injection guards\n clean-workspace Reset a persistent-runner workspace with a fork-PR trust gate\n install-github-release Download a checksum-verified GitHub Release binary\n run-with-timeout Run a command with GNU timeout or a Perl fallback\n lint-links Two-pass lychee: internal links fail, external warn\n materialize-pr-context Dump PR title/body/files/diff/comments and #N crawl\n wait-for-apt-locks Wait until apt/dpkg lock files are free\n install-playwright-chromium-arm64 Install Playwright Chromium from browsers.json\n ghcr-package-retention Delete old GHCR package versions (KEEP_MIN or --main-history)\n harness-admission-lane Compute a GITHUB_RUN_ID admission lane for fleet fan-out\n harness-assert-gates Fail if any named HARNESS_*_ENABLED gate is enabled\n gha-collaborator-trust Classify authors as write-access collaborators or not\n nuget-central-version Validate a Directory.Packages.props PackageVersion delta\n verify-workflow-secrets Check a secret inventory against live repository and environment secrets\n swift-semantic-equal Compare Swift sources ignoring comments and whitespace\n post-review Post one COMMENT review from a staged payload file\n stage-review-payload Validate a review payload file into a staging directory\n retrospective-transcript Format facts from Claude-compatible, Codex, or Grok transcripts\n link-skill Link one packaged skill into an explicit consumer directory\n retrospective-facts Gather immutable facts for a retrospective\n agent-blackboard Probe an Agent Blackboard deployment, classify distill sessions, manage snapshots\n mcp Serve the agent-blackboard journal tools over stdio (MCP)\n worktree Reclaim finished git worktrees (dry run unless --yes)\n story-coverage Check component exports are imported by stories\n\nOptions:\n -h, --help Show this help\n -v, --version Print the package version\n\nrunner-port-policy\n (no args) Print the shipped policy as JSON\n --file <path> Validate and print a policy file\n --reserved <port> Print true if the port is reserved\n\nwith-host-lock\n --name <family>\n [--slots <n>]\n --timeout-seconds <n>\n [--command-timeout-seconds <n>]\n [--failure-diagnostics <absolute-script>]\n [--on-acquire-timeout fail|run-unlocked]\n -- <command> [args...]\n\nhost-storage --path <path> [--path <path>...] [--minimum-free-bytes <bytes>] [--pnpm-store] [--docker-root] [--docker-desktop-path <path>] [--discovery-timeout-ms <ms>]\n\ngha-runtime-audit\n [--repository owner/name] Default GITHUB_REPOSITORY\n [--branch main]\n [--median-threshold-floor <seconds>] Off unless set. Must be below the ceiling\n [--median-threshold-ceiling <seconds>] Default 360. Flags a five-sample median above this\n --pr-workflow <name|/regex/> Repeatable\n --push-workflow <name|/regex/> Repeatable\n\nrequire-up-to-date --remote <name> --branch <name>\nfresh-base [--remote <name>] [--branch <name>] [--skip-fetch]\ngitleaks-directory-scan --config <path> [--directory <path>]\nast-grep-examples --rules <directory> --config <path>\nast-grep-pack\ngha-workspace-policy [--root <directory>] [--workflow-directory <directory>] [--action-directory <directory>]\n\ngha-output <name>\ngha-needs-results [label]\ndownload-with-diagnostics <url> <destination> [-- curl-args...]\ndownload-optional-run-artifacts (--name <name>... | --pattern <pattern>) --dir <directory>\nhost-pressure-diagnostics\nallocate-browser-safe-ports <count> [--policy path] [--forbidden-ports path]\ndiagnose-port-collision [--ports \"2200 2216\"] [--output-dir PATH]\nprepare-trivy-db\ngha-artifacts-cleanup run --run-id <id> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\ngha-artifacts-cleanup sweep --older-than-hours <n> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\nagent-issue-labels labels-from-paths [--labeler <path>] <path>...\nagent-issue-labels ensure-labels [--repo owner/name] [--policy-file json] [--update] <label>...\nhttp-origin [--field NAME] [value]\nvitest-blob-manifest <suite> [reports-directory]\nvitest-report-attempt <write DIRECTORY SUITE|read ROOT>\nprepare-vitest-reports [primary-directory] [fallback-directory] [output-directory]\npnpm-install --runner-lifecycle persistent|ephemeral|ephemeral-full --install-scripts true|false\ncheck-cache-size <path> <max-bytes> <label>\nmake-shard-matrix <total>\nload-runner-env\nclean-workspace\ninstall-github-release --repo owner/name --version X --asset 'name-{platform}.tar.gz' --bin name [--tag-prefix PREFIX] [--expected-sha256 SHA256] [--no-checksum] [--checksums-asset NAME] [--version-flag FLAG] [--bin-dir DIR]\nrun-with-timeout <timeout-seconds> <kill-after-seconds> <command...>\nlint-links [--offline] [--config PATH] [--glob PATTERN] [files...]\nmaterialize-pr-context\nwait-for-apt-locks\ninstall-playwright-chromium-arm64 [name:archive...]\nghcr-package-retention [--main-history] [--apply|--dry-run] [<url-encoded-package>...]\nharness-admission-lane <lanes>\nharness-assert-gates <gate>...\ngha-collaborator-trust <owner/repo> [--allow-bot <login>]... < authors.json\nnuget-central-version <trusted-props> <candidate-props> <metadata-json> <output-props>\nverify-workflow-secrets [--repo OWNER/NAME] [--confirm NAME,...] [--inventory MODULE] [--export NAME] [--branch NAME]\nswift-semantic-equal <base> <head> <file.swift>\npost-review\nstage-review-payload optional|required <source> <destination>\nretrospective-transcript [--session-id ID] [--jsonl PATH] [--projects-dir PATH] [--codex-sessions-dir PATH] [--grok-sessions-dir PATH]\nlink-skill <name> --source-root <skills-dir> --target-root <consumer-skills-dir> Link a packaged or repository-local skill\nretrospective-facts (--pr NUMBER | --branch NAME | --no-pr) [--repo OWNER/NAME] [--raw]\nagent-blackboard probe\nagent-blackboard session-start [--skip-env NAME] [--setup-hint TEXT] [--docs-path PATH] [--restore-hint TEXT] [--timeout-ms N] (SessionStart hook; payload on stdin)\nagent-blackboard distill classify <partition.jsonl> --retro-cutoff ISO8601 --session-cutoff ISO8601\nagent-blackboard snapshot partition --snapshot PATH --checksum SHA256 --counts '{\"sessions\":N,\"entries\":N,\"records\":N,\"bytes\":N}'\nagent-blackboard snapshot cleanup [--snapshot PATH] [--partition-directory PATH --receipt JSON]\nmcp\n (no args) Serve journal_append, journal_entries, outbox_status, outbox_flush,\n session_ensure, retrospective_check, retrospective_save,\n pr_validate, pr_create, pr_update,\n snapshot_export, snapshot_cleanup, and session_archive over stdio.\n Needs the optional @modelcontextprotocol/sdk peer (and zod).\n Launch it from inside the repository's git worktree.\n\nworktree reclaim [--yes] [--json]\n Dry run by default. Removes clean, fully pushed worktrees whose same-repository PR for the\n branch is merged or closed at exactly HEAD, using git worktree remove (never forced).\n Skips the main checkout, the current worktree, and locked, bare or detached worktrees.\n\nstory-coverage --root <dir> --component-root <rel> --story-root <rel> --source-extension <ext> --component-extension <ext> --marker <regex> --story-pattern <regex> [--alias <prefix>=<path>] [--exclusions <json>] [--exclusions-label <text>]\n";
1
+ export declare const USAGE = "Usage: vouchington <command> [options]\n\nCommands:\n runner-port-policy Print or validate a runner port policy\n with-host-lock Run a command under a host-wide lock\n host-storage Check free space on caller-supplied paths\n gha-runtime-audit Audit successful GitHub Actions job runtimes\n require-up-to-date Require HEAD to include a fetched remote branch\n fresh-base Classify the worktree against a remote base branch\n gitleaks-directory-scan Scan a directory with Gitleaks\n ast-grep-examples Run AST-grep rule examples\n ast-grep-pack Print shipped unconditional AST-grep pack paths as JSON\n gha-workspace-policy Check GitHub Actions workspace safety policy\n gha-output Write a collision-safe multiline GITHUB_OUTPUT record\n gha-needs-results Fail if required GitHub Actions job results failed\n download-with-diagnostics Download a URL and report HTTP status on failure\n download-optional-run-artifacts Download optional artifacts from the current run\n host-pressure-diagnostics Print a bounded host memory/OOM/PSI snapshot\n allocate-browser-safe-ports Allocate Fetch-safe localhost ports\n diagnose-port-collision Capture bounded localhost port diagnostics\n prepare-trivy-db Download the Trivy vulnerability database\n gha-artifacts-cleanup Delete classified GitHub Actions artifacts\n agent-issue-labels Map changed paths to labels; create missing repository labels\n http-origin Validate an optional HTTP(S) origin\n vitest-blob-manifest Stamp a vitest-blob-manifest:v1 identity file\n vitest-report-attempt Write or read a Vitest report-attempt marker\n prepare-vitest-reports Validate and select Vitest report JSON files\n pnpm-install Install a pnpm workspace with retry and release-age fail-fast\n check-cache-size Measure a path and decide whether to save a GHA cache\n make-shard-matrix Emit a [1..N] GitHub Actions shard matrix\n load-runner-env Overlay a runner env file onto GITHUB_ENV with injection guards\n clean-workspace Reset a persistent-runner workspace with a fork-PR trust gate\n install-github-release Download a checksum-verified GitHub Release binary\n run-with-timeout Run a command with GNU timeout or a Perl fallback\n lint-links Two-pass lychee: internal links fail, external warn\n materialize-pr-context Dump PR title/body/files/diff/comments and #N crawl\n wait-for-apt-locks Wait until apt/dpkg lock files are free\n install-playwright-chromium-arm64 Install Playwright Chromium from browsers.json\n ghcr-package-retention Delete old GHCR package versions (KEEP_MIN or --main-history)\n harness-admission-lane Compute a GITHUB_RUN_ID admission lane for fleet fan-out\n harness-assert-gates Fail if any named HARNESS_*_ENABLED gate is enabled\n gha-collaborator-trust Classify authors as write-access collaborators or not\n nuget-central-version Validate a Directory.Packages.props PackageVersion delta\n verify-workflow-secrets Check a secret inventory against live repository and environment secrets\n dead-code Gate unused code against a committed jscpd baseline\n swift-semantic-equal Compare Swift sources ignoring comments and whitespace\n post-review Post one COMMENT review from a staged payload file\n stage-review-payload Validate a review payload file into a staging directory\n retrospective-transcript Format facts from Claude-compatible, Codex, or Grok transcripts\n link-skill Link one packaged skill into an explicit consumer directory\n retrospective-facts Gather immutable facts for a retrospective\n agent-blackboard Probe an Agent Blackboard deployment, classify distill sessions, manage snapshots\n mcp Serve the agent-blackboard journal tools over stdio (MCP)\n worktree Reclaim finished git worktrees (dry run unless --yes)\n story-coverage Check component exports are imported by stories\n transient-retry Rerun a failed GitHub Actions run when an injected rule matches\n\nOptions:\n -h, --help Show this help\n -v, --version Print the package version\n\nrunner-port-policy\n (no args) Print the shipped policy as JSON\n --file <path> Validate and print a policy file\n --reserved <port> Print true if the port is reserved\n\nwith-host-lock\n --name <family>\n [--slots <n>]\n --timeout-seconds <n>\n [--command-timeout-seconds <n>]\n [--failure-diagnostics <absolute-script>]\n [--on-acquire-timeout fail|run-unlocked]\n -- <command> [args...]\n\nhost-storage --path <path> [--path <path>...] [--minimum-free-bytes <bytes>] [--pnpm-store] [--docker-root] [--docker-desktop-path <path>] [--discovery-timeout-ms <ms>]\n\ngha-runtime-audit\n [--repository owner/name] Default GITHUB_REPOSITORY\n [--branch main]\n [--median-threshold-floor <seconds>] Off unless set. Must be below the ceiling\n [--median-threshold-ceiling <seconds>] Default 360. Flags a five-sample median above this\n --pr-workflow <name|/regex/> Repeatable\n --push-workflow <name|/regex/> Repeatable\n\nrequire-up-to-date --remote <name> --branch <name>\nfresh-base [--remote <name>] [--branch <name>] [--skip-fetch]\ngitleaks-directory-scan --config <path> [--directory <path>]\nast-grep-examples --rules <directory> --config <path>\nast-grep-pack\ngha-workspace-policy [--root <directory>] [--workflow-directory <directory>] [--action-directory <directory>]\n\ngha-output <name>\ngha-needs-results [label]\ndownload-with-diagnostics <url> <destination> [-- curl-args...]\ndownload-optional-run-artifacts (--name <name>... | --pattern <pattern>) --dir <directory>\nhost-pressure-diagnostics\nallocate-browser-safe-ports <count> [--policy path] [--forbidden-ports path]\ndiagnose-port-collision [--ports \"2200 2216\"] [--output-dir PATH]\nprepare-trivy-db\ngha-artifacts-cleanup run --run-id <id> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\ngha-artifacts-cleanup sweep --older-than-hours <n> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\nagent-issue-labels labels-from-paths [--labeler <path>] <path>...\nagent-issue-labels ensure-labels [--repo owner/name] [--policy-file json] [--update] <label>...\nhttp-origin [--field NAME] [value]\nvitest-blob-manifest <suite> [reports-directory]\nvitest-report-attempt <write DIRECTORY SUITE|read ROOT>\nprepare-vitest-reports [primary-directory] [fallback-directory] [output-directory]\npnpm-install --runner-lifecycle persistent|ephemeral|ephemeral-full --install-scripts true|false\ncheck-cache-size <path> <max-bytes> <label>\nmake-shard-matrix <total>\nload-runner-env\nclean-workspace\ninstall-github-release --repo owner/name --version X --asset 'name-{platform}.tar.gz' --bin name [--tag-prefix PREFIX] [--expected-sha256 SHA256] [--no-checksum] [--checksums-asset NAME] [--version-flag FLAG] [--bin-dir DIR]\nrun-with-timeout <timeout-seconds> <kill-after-seconds> <command...>\nlint-links [--offline] [--config PATH] [--glob PATTERN] [files...]\nmaterialize-pr-context\nwait-for-apt-locks\ninstall-playwright-chromium-arm64 [name:archive...]\nghcr-package-retention [--main-history] [--apply|--dry-run] [<url-encoded-package>...]\nharness-admission-lane <lanes>\nharness-assert-gates <gate>...\ngha-collaborator-trust <owner/repo> [--allow-bot <login>]... < authors.json\nnuget-central-version <trusted-props> <candidate-props> <metadata-json> <output-props>\nverify-workflow-secrets [--repo OWNER/NAME] [--confirm NAME,...] [--inventory MODULE] [--export NAME] [--branch NAME]\ndead-code --baseline PATH [--seed|--update] [--config PATH] [--binary PATH] [--repo-root PATH] [--entry GLOB]... [--snapshot-ignore GLOB]... [--exclude GLOB]...\nswift-semantic-equal <base> <head> <file.swift>\npost-review\nstage-review-payload optional|required <source> <destination>\nretrospective-transcript [--session-id ID] [--jsonl PATH] [--projects-dir PATH] [--codex-sessions-dir PATH] [--grok-sessions-dir PATH]\nlink-skill <name> --source-root <skills-dir> --target-root <consumer-skills-dir> Link a packaged or repository-local skill\nretrospective-facts (--pr NUMBER | --branch NAME | --no-pr) [--repo OWNER/NAME] [--raw]\nagent-blackboard probe\nagent-blackboard session-start [--skip-env NAME] [--setup-hint TEXT] [--docs-path PATH] [--restore-hint TEXT] [--timeout-ms N] (SessionStart hook; payload on stdin)\nagent-blackboard distill classify <partition.jsonl> --retro-cutoff ISO8601 --session-cutoff ISO8601\nagent-blackboard snapshot partition --snapshot PATH --checksum SHA256 --counts '{\"sessions\":N,\"entries\":N,\"records\":N,\"bytes\":N}'\nagent-blackboard snapshot cleanup [--snapshot PATH] [--partition-directory PATH --receipt JSON]\nmcp\n (no args) Serve journal_append, journal_entries, outbox_status, outbox_flush,\n session_ensure, retrospective_check, retrospective_save,\n pr_validate, pr_create, pr_update,\n snapshot_export, snapshot_cleanup, and session_archive over stdio.\n Needs the optional @modelcontextprotocol/sdk peer (and zod).\n Launch it from inside the repository's git worktree.\n\nworktree reclaim [--yes] [--json]\n Dry run by default. Removes clean, fully pushed worktrees whose same-repository PR for the\n branch is merged or closed at exactly HEAD, using git worktree remove (never forced).\n Skips the main checkout, the current worktree, and locked, bare or detached worktrees.\n\ntransient-retry --rules <module> [--repo owner/name] [--token-env NAME] [--dry-run] <run-id>\n Loads a module exporting \"rules\" (and optionally \"limits\"), evaluates them against the failed run,\n and reruns only on a match. Exits 0 on rerun, 2 when none is warranted, 1 on error.\n\nstory-coverage --root <dir> --component-root <rel> --story-root <rel> --source-extension <ext> --component-extension <ext> --marker <regex> --story-pattern <regex> [--alias <prefix>=<path>] [--exclusions <json>] [--exclusions-label <text>]\n";
2
2
  export declare function printUsage(stream?: NodeJS.WritableStream): void;
3
3
  export declare function commandNames(usage?: string): string[];
4
4
  export declare function commandUsage(command: string, usage?: string): string;
@@ -42,6 +42,7 @@ Commands:
42
42
  gha-collaborator-trust Classify authors as write-access collaborators or not
43
43
  nuget-central-version Validate a Directory.Packages.props PackageVersion delta
44
44
  verify-workflow-secrets Check a secret inventory against live repository and environment secrets
45
+ dead-code Gate unused code against a committed jscpd baseline
45
46
  swift-semantic-equal Compare Swift sources ignoring comments and whitespace
46
47
  post-review Post one COMMENT review from a staged payload file
47
48
  stage-review-payload Validate a review payload file into a staging directory
@@ -52,6 +53,7 @@ Commands:
52
53
  mcp Serve the agent-blackboard journal tools over stdio (MCP)
53
54
  worktree Reclaim finished git worktrees (dry run unless --yes)
54
55
  story-coverage Check component exports are imported by stories
56
+ transient-retry Rerun a failed GitHub Actions run when an injected rule matches
55
57
 
56
58
  Options:
57
59
  -h, --help Show this help
@@ -121,6 +123,7 @@ harness-assert-gates <gate>...
121
123
  gha-collaborator-trust <owner/repo> [--allow-bot <login>]... < authors.json
122
124
  nuget-central-version <trusted-props> <candidate-props> <metadata-json> <output-props>
123
125
  verify-workflow-secrets [--repo OWNER/NAME] [--confirm NAME,...] [--inventory MODULE] [--export NAME] [--branch NAME]
126
+ dead-code --baseline PATH [--seed|--update] [--config PATH] [--binary PATH] [--repo-root PATH] [--entry GLOB]... [--snapshot-ignore GLOB]... [--exclude GLOB]...
124
127
  swift-semantic-equal <base> <head> <file.swift>
125
128
  post-review
126
129
  stage-review-payload optional|required <source> <destination>
@@ -145,6 +148,10 @@ worktree reclaim [--yes] [--json]
145
148
  branch is merged or closed at exactly HEAD, using git worktree remove (never forced).
146
149
  Skips the main checkout, the current worktree, and locked, bare or detached worktrees.
147
150
 
151
+ transient-retry --rules <module> [--repo owner/name] [--token-env NAME] [--dry-run] <run-id>
152
+ Loads a module exporting "rules" (and optionally "limits"), evaluates them against the failed run,
153
+ and reruns only on a match. Exits 0 on rerun, 2 when none is warranted, 1 on error.
154
+
148
155
  story-coverage --root <dir> --component-root <rel> --story-root <rel> --source-extension <ext> --component-extension <ext> --marker <regex> --story-pattern <regex> [--alias <prefix>=<path>] [--exclusions <json>] [--exclusions-label <text>]
149
156
  `;
150
157
  export function printUsage(stream = process.stdout) {
@@ -0,0 +1,19 @@
1
+ export type FindingIdentity = {
2
+ category: string;
3
+ path: string;
4
+ parent: string;
5
+ name: string;
6
+ symbolKind: string;
7
+ };
8
+ export type BaselineRow = FindingIdentity & {
9
+ count: number;
10
+ };
11
+ export declare function rowsFromReport(value: unknown, include?: (finding: FindingIdentity, raw: Record<string, unknown>) => boolean): BaselineRow[];
12
+ export declare function parseBaseline(value: unknown): BaselineRow[];
13
+ export declare function compareRows(current: readonly BaselineRow[], baseline: readonly BaselineRow[]): {
14
+ added: BaselineRow[];
15
+ stale: BaselineRow[];
16
+ };
17
+ export declare function readBaseline(path: string): Promise<BaselineRow[]>;
18
+ export declare function writeBaseline(path: string, rows: readonly BaselineRow[]): Promise<void>;
19
+ export declare function reconcileBaseline(path: string, current: readonly BaselineRow[], operation: 'check' | 'seed' | 'update'): Promise<number>;
@@ -0,0 +1,124 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile, writeFile } from 'node:fs/promises';
3
+ const categories = new Set([
4
+ 'unused-file',
5
+ 'unused-export',
6
+ 'unused-symbol',
7
+ 'unused-import',
8
+ 'unused-member',
9
+ ]);
10
+ function record(value) {
11
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
12
+ throw new Error('Expected a JSON object');
13
+ }
14
+ return value;
15
+ }
16
+ function requiredString(value, field) {
17
+ if (typeof value !== 'string')
18
+ throw new Error(`Expected ${field} to be a string`);
19
+ return value;
20
+ }
21
+ function identity(value) {
22
+ const row = record(value);
23
+ const category = requiredString(row['category'], 'category');
24
+ const path = requiredString(row['path'], 'path');
25
+ const parent = requiredString(row['parent'] ?? '', 'parent');
26
+ const name = requiredString(row['name'], 'name');
27
+ const symbolKind = requiredString(row['symbolKind'] ?? '', 'symbolKind');
28
+ if (!categories.has(category))
29
+ throw new Error(`Unknown dead-code category: ${category}`);
30
+ if (!path || path.startsWith('/') || path.includes('\\') || path.split('/').includes('..')) {
31
+ throw new Error(`Invalid report path: ${path}`);
32
+ }
33
+ return { category, path, parent, name, symbolKind };
34
+ }
35
+ function key(row) {
36
+ return JSON.stringify([row.category, row.path, row.parent, row.name, row.symbolKind]);
37
+ }
38
+ function sortedRows(rows) {
39
+ return rows.toSorted((a, b) => key(a).localeCompare(key(b), 'en'));
40
+ }
41
+ export function rowsFromReport(value, include = () => true) {
42
+ const report = record(value);
43
+ const statistics = record(report['statistics']);
44
+ if (!Number.isInteger(statistics['files']) || statistics['files'] <= 0) {
45
+ throw new Error('Dead-code scan analyzed no files');
46
+ }
47
+ if (statistics['unparsed'] !== 0) {
48
+ throw new Error(`Dead-code scan has unparsed files: ${String(statistics['unparsed'])}`);
49
+ }
50
+ if (!Array.isArray(report['findings']))
51
+ throw new Error('Dead-code report has no findings array');
52
+ const counts = new Map();
53
+ for (const value of report['findings']) {
54
+ const found = identity(value);
55
+ if (!include(found, record(value)))
56
+ continue;
57
+ const id = key(found);
58
+ const existing = counts.get(id);
59
+ counts.set(id, { ...found, count: (existing?.count ?? 0) + 1 });
60
+ }
61
+ return sortedRows([...counts.values()]);
62
+ }
63
+ export function parseBaseline(value) {
64
+ const baseline = record(value);
65
+ if (baseline['version'] !== 1 || !Array.isArray(baseline['findings'])) {
66
+ throw new Error('Invalid dead-code baseline version or findings array');
67
+ }
68
+ const rows = baseline['findings'].map((value) => {
69
+ const item = record(value);
70
+ const found = identity(item);
71
+ if (!Number.isInteger(item['count']) || item['count'] < 1) {
72
+ throw new Error(`Invalid dead-code baseline count for ${key(found)}`);
73
+ }
74
+ return { ...found, count: item['count'] };
75
+ });
76
+ const sorted = sortedRows(rows);
77
+ if (rows.some((row, index) => key(row) !== key(sorted[index]))) {
78
+ throw new Error('Dead-code baseline is not sorted');
79
+ }
80
+ if (new Set(rows.map(key)).size !== rows.length) {
81
+ throw new Error('Dead-code baseline has duplicate identities');
82
+ }
83
+ return rows;
84
+ }
85
+ export function compareRows(current, baseline) {
86
+ const oldCounts = new Map(baseline.map((row) => [key(row), row.count]));
87
+ const newCounts = new Map(current.map((row) => [key(row), row.count]));
88
+ const added = current.filter((row) => row.count > (oldCounts.get(key(row)) ?? 0));
89
+ const stale = baseline.filter((row) => row.count > (newCounts.get(key(row)) ?? 0));
90
+ return { added, stale };
91
+ }
92
+ export async function readBaseline(path) {
93
+ return parseBaseline(JSON.parse(await readFile(path, 'utf8')));
94
+ }
95
+ export async function writeBaseline(path, rows) {
96
+ await writeFile(path, `${JSON.stringify({ version: 1, findings: sortedRows(rows) }, null, 2)}\n`);
97
+ }
98
+ function describe(rows) {
99
+ const shown = rows.slice(0, 12).map((row) => {
100
+ const symbol = row.name ? ` ${row.parent ? `${row.parent}.` : ''}${row.name}` : '';
101
+ return ` ${row.category} ${row.path}${symbol} (${row.count})`;
102
+ });
103
+ if (rows.length > shown.length)
104
+ shown.push(` …and ${rows.length - shown.length} more identities`);
105
+ return shown.join('\n');
106
+ }
107
+ export async function reconcileBaseline(path, current, operation) {
108
+ if (operation === 'seed') {
109
+ if (existsSync(path))
110
+ throw new Error('Initial baseline already exists');
111
+ await writeBaseline(path, current);
112
+ return 0;
113
+ }
114
+ const previous = await readBaseline(path);
115
+ const { added, stale } = compareRows(current, previous);
116
+ if (added.length > 0)
117
+ throw new Error(`New dead-code findings:\n${describe(added)}`);
118
+ if (operation === 'check' && stale.length > 0) {
119
+ throw new Error(`Stale dead-code baseline findings:\n${describe(stale)}`);
120
+ }
121
+ if (operation === 'update' && stale.length > 0)
122
+ await writeBaseline(path, current);
123
+ return stale.length;
124
+ }
@@ -0,0 +1,6 @@
1
+ export declare class ChildCommandCleanupError extends AggregateError {
2
+ readonly processGroupId: number;
3
+ readonly completion: Promise<Error | null>;
4
+ constructor(processGroupId: number, completion: Promise<Error | null>, errors: unknown[]);
5
+ }
6
+ export declare function runChildCommand(file: string, args: string[], cwd: string, remaining?: () => number): Promise<void>;