vouchington-tooling 0.57.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.
- package/README.md +26 -0
- package/dist/agent-issue-labels/ensure-labels.d.mts +17 -0
- package/dist/agent-issue-labels/ensure-labels.mjs +55 -0
- package/dist/agent-issue-labels/index.d.mts +5 -0
- package/dist/agent-issue-labels/index.mjs +3 -0
- package/dist/agent-issue-labels/label-policy.d.mts +21 -0
- package/dist/agent-issue-labels/label-policy.mjs +67 -0
- package/dist/agent-issue-labels/labels-from-paths.d.mts +9 -0
- package/dist/agent-issue-labels/labels-from-paths.mjs +54 -0
- package/dist/browser-session-runner/tail-queue.d.mts +1 -1
- package/dist/browser-session-runner/tail-queue.mjs +1 -1
- package/dist/cli/commands/agent-issue-labels.d.mts +2 -0
- package/dist/cli/commands/agent-issue-labels.mjs +17 -0
- package/dist/cli/commands/gitleaks-directory-scan.d.mts +4 -0
- package/dist/cli/commands/gitleaks-directory-scan.mjs +9 -0
- package/dist/cli/commands/transient-retry.d.mts +13 -0
- package/dist/cli/commands/transient-retry.mjs +68 -0
- package/dist/cli/index.mjs +14 -53
- package/dist/cli/parse-agent-issue-labels.d.mts +19 -0
- package/dist/cli/parse-agent-issue-labels.mjs +70 -0
- package/dist/cli/parse-forwarded-commands.d.mts +9 -0
- package/dist/cli/parse-forwarded-commands.mjs +6 -0
- package/dist/cli/parse.d.mts +11 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/script-paths.d.mts +5 -0
- package/dist/cli/script-paths.mjs +48 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +12 -0
- package/dist/dead-code/baseline.d.mts +19 -0
- package/dist/dead-code/baseline.mjs +124 -0
- package/dist/dead-code/child-command.d.mts +6 -0
- package/dist/dead-code/child-command.mjs +107 -0
- package/dist/dead-code/cli.d.mts +5 -0
- package/dist/dead-code/cli.mjs +71 -0
- package/dist/dead-code/entry-roots.d.mts +7 -0
- package/dist/dead-code/entry-roots.mjs +43 -0
- package/dist/dead-code/fixture-deadline.test-helpers.d.mts +1 -0
- package/dist/dead-code/fixture-deadline.test-helpers.mjs +9 -0
- package/dist/dead-code/gate.d.mts +29 -0
- package/dist/dead-code/gate.mjs +33 -0
- package/dist/dead-code/gate.test-helpers.d.mts +14 -0
- package/dist/dead-code/gate.test-helpers.mjs +35 -0
- package/dist/dead-code/index.d.mts +9 -0
- package/dist/dead-code/index.mjs +7 -0
- package/dist/dead-code/scan.d.mts +11 -0
- package/dist/dead-code/scan.mjs +37 -0
- package/dist/dead-code/tracked-snapshot.d.mts +2 -0
- package/dist/dead-code/tracked-snapshot.mjs +72 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/markdown/details-scope.d.mts +1 -1
- package/dist/markdown/details-scope.mjs +1 -1
- package/dist/transient-retry/attempts.d.mts +1 -1
- package/dist/transient-retry/attempts.mjs +1 -1
- package/dist/transient-retry/decision-evaluator.d.mts +3 -3
- package/dist/transient-retry/gh-api.d.mts +30 -0
- package/dist/transient-retry/gh-api.mjs +68 -0
- package/dist/transient-retry/github-actions-log.d.mts +7 -0
- package/dist/transient-retry/github-actions-log.mjs +33 -0
- package/dist/transient-retry/index.d.mts +15 -0
- package/dist/transient-retry/index.mjs +8 -0
- package/dist/transient-retry/log-stream.d.mts +12 -0
- package/dist/transient-retry/log-stream.mjs +39 -0
- package/dist/transient-retry/log-window.d.mts +18 -0
- package/dist/transient-retry/log-window.mjs +94 -0
- package/dist/transient-retry/rerun.d.mts +23 -0
- package/dist/transient-retry/rerun.mjs +68 -0
- package/dist/transient-retry/run-context-annotations.d.mts +7 -0
- package/dist/transient-retry/run-context-annotations.mjs +44 -0
- package/dist/transient-retry/run-context-jobs.d.mts +20 -0
- package/dist/transient-retry/run-context-jobs.mjs +54 -0
- package/dist/transient-retry/run-context-logs.d.mts +12 -0
- package/dist/transient-retry/run-context-logs.mjs +86 -0
- package/dist/transient-retry/run-context-rule-attempts.d.mts +14 -0
- package/dist/transient-retry/run-context-rule-attempts.mjs +65 -0
- package/dist/transient-retry/run-context-types.d.mts +49 -0
- package/dist/transient-retry/run-context-types.mjs +3 -0
- package/dist/transient-retry/run-context.d.mts +9 -0
- package/dist/transient-retry/run-context.mjs +25 -0
- package/dist/transient-retry/run-context.test-helpers.d.mts +16 -0
- package/dist/transient-retry/run-context.test-helpers.mjs +56 -0
- package/dist/transient-retry/types.d.mts +8 -7
- package/dist/vitest-diagnostics/vitest-worker-exit-diagnostics-reporter.mjs +1 -1
- package/dist/workflow-secrets-drift/cli.d.mts +10 -0
- package/dist/workflow-secrets-drift/cli.mjs +73 -0
- package/dist/workflow-secrets-drift/collect.d.mts +10 -0
- package/dist/workflow-secrets-drift/collect.mjs +70 -0
- package/dist/workflow-secrets-drift/drift.d.mts +22 -0
- package/dist/workflow-secrets-drift/drift.mjs +49 -0
- package/dist/workflow-secrets-drift/gh-parse.d.mts +5 -0
- package/dist/workflow-secrets-drift/gh-parse.mjs +41 -0
- package/dist/workflow-secrets-drift/gh.d.mts +4 -0
- package/dist/workflow-secrets-drift/gh.mjs +51 -0
- package/dist/workflow-secrets-drift/index.d.mts +11 -0
- package/dist/workflow-secrets-drift/index.mjs +6 -0
- package/dist/workflow-secrets-drift/inventory.d.mts +10 -0
- package/dist/workflow-secrets-drift/inventory.mjs +78 -0
- package/dist/workflow-secrets-drift/scopes.d.mts +12 -0
- package/dist/workflow-secrets-drift/scopes.mjs +56 -0
- package/dist/workflow-secrets-drift/settle.d.mts +3 -0
- package/dist/workflow-secrets-drift/settle.mjs +19 -0
- package/dist/workflow-secrets-drift/types.d.mts +33 -0
- package/dist/workflow-secrets-drift/types.mjs +1 -0
- package/package.json +16 -1
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ vouchington allocate-browser-safe-ports 2 --policy ./policy.json --forbidden-por
|
|
|
55
55
|
vouchington diagnose-port-collision --ports "2200 2216"
|
|
56
56
|
vouchington prepare-trivy-db
|
|
57
57
|
vouchington gha-artifacts-cleanup run --run-id 123 --keep-pattern 'plan-*' --delete-pattern 'coverage-*'
|
|
58
|
+
vouchington agent-issue-labels labels-from-paths --labeler .github/labeler.yml src/a.ts
|
|
59
|
+
vouchington agent-issue-labels ensure-labels --policy-file labels.json --repo owner/name bug
|
|
58
60
|
vouchington http-origin --field cdn_origin https://images.example.com
|
|
59
61
|
vouchington vitest-blob-manifest <suite> [reports-directory]
|
|
60
62
|
vouchington vitest-report-attempt write <directory> <suite>
|
|
@@ -83,6 +85,8 @@ vouchington harness-admission-lane 4
|
|
|
83
85
|
vouchington harness-assert-gates HARNESS_DISPATCH_ENABLED HARNESS_SHEPHERD_ENABLED
|
|
84
86
|
echo '[{"login":"octocat","type":"User"}]' | vouchington gha-collaborator-trust owner/repo --allow-bot github-actions[bot]
|
|
85
87
|
vouchington nuget-central-version trusted.props candidate.props metadata.json out.props
|
|
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
|
|
86
90
|
vouchington swift-semantic-equal BASE HEAD App.swift
|
|
87
91
|
vouchington post-review
|
|
88
92
|
vouchington stage-review-payload optional|required <source> <destination>
|
|
@@ -247,6 +251,25 @@ The script also deletes `.cache` directories and the direct `.cache`, `.vite`, a
|
|
|
247
251
|
directories inside `node_modules`. It needs `flock` or `lockf` and holds
|
|
248
252
|
`.local/reset-worktree.lock` for the run.
|
|
249
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
|
+
|
|
250
273
|
## Reclaiming finished worktrees
|
|
251
274
|
|
|
252
275
|
`vouchington worktree reclaim [--yes] [--json]` removes git worktrees whose work is done. It is a
|
|
@@ -306,6 +329,7 @@ import {
|
|
|
306
329
|
writeSelectedFilesOutput,
|
|
307
330
|
} from 'vouchington-tooling/gha-selected-files'
|
|
308
331
|
import { createArtifactClassifier, runCleanup } from 'vouchington-tooling/gha-artifacts-cleanup'
|
|
332
|
+
import { ensureLabels, labelsFromPaths } from 'vouchington-tooling/agent-issue-labels'
|
|
309
333
|
import { validateOptionalHttpOrigin } from 'vouchington-tooling/http-origin'
|
|
310
334
|
import { boundPendingLine, splitCompleteLines } from 'vouchington-tooling/process-line-buffer'
|
|
311
335
|
import {
|
|
@@ -365,6 +389,8 @@ import { runGitleaksDirectoryScan } from 'vouchington-tooling/gitleaks-directory
|
|
|
365
389
|
import { runAstGrepExamples } from 'vouchington-tooling/ast-grep-examples'
|
|
366
390
|
import { astGrepPackPaths } from 'vouchington-tooling/ast-grep-pack'
|
|
367
391
|
import { validateNugetUpdate } from 'vouchington-tooling/nuget-central-version'
|
|
392
|
+
import { runVerifyWorkflowSecretsCli } from 'vouchington-tooling/workflow-secrets-drift'
|
|
393
|
+
import { runDeadCodeGate } from 'vouchington-tooling/dead-code'
|
|
368
394
|
import { normalizeSwiftSource } from 'vouchington-tooling/swift-semantic-equal'
|
|
369
395
|
import { parseUniqueSwiftBinaryTargetChecksum } from 'vouchington-tooling/swift-source-offset'
|
|
370
396
|
import { validateResolvedPinDelta } from 'vouchington-tooling/swift-resolved-pin-delta'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RunTextCommand } from '../gh-cli/index.mts';
|
|
2
|
+
import { type LabelPolicy } from './label-policy.mts';
|
|
3
|
+
export type EnsureLabelsOptions = {
|
|
4
|
+
labels: readonly string[];
|
|
5
|
+
/** `owner/name`; defaults to the repository `gh` resolves from the working directory. */
|
|
6
|
+
repo?: string;
|
|
7
|
+
policy?: LabelPolicy;
|
|
8
|
+
/** Rewrite metadata of labels that already exist (otherwise they are left untouched). */
|
|
9
|
+
update?: boolean;
|
|
10
|
+
run?: RunTextCommand;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates missing repository labels through `gh` (or force-updates all with `update`). Every label
|
|
14
|
+
* is validated against the policy before `gh` is called. A create that fails because the label
|
|
15
|
+
* appeared concurrently is accepted. Returns the labels in the requested order.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ensureLabels(options: EnsureLabelsOptions): Promise<string[]>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { runGh } from "../gh-cli/index.mjs";
|
|
2
|
+
import { DEFAULT_LABEL_POLICY, labelMetadata } from "./label-policy.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Creates missing repository labels through `gh` (or force-updates all with `update`). Every label
|
|
5
|
+
* is validated against the policy before `gh` is called. A create that fails because the label
|
|
6
|
+
* appeared concurrently is accepted. Returns the labels in the requested order.
|
|
7
|
+
*/
|
|
8
|
+
export async function ensureLabels(options) {
|
|
9
|
+
const { labels, repo, update = false, run = runGh, policy = DEFAULT_LABEL_POLICY } = options;
|
|
10
|
+
if (labels.length === 0)
|
|
11
|
+
throw new Error('at least one label is required');
|
|
12
|
+
const metadata = labels.map((label) => labelMetadata(label, policy));
|
|
13
|
+
const base = repo ? `repos/${repo}/labels` : 'repos/{owner}/{repo}/labels';
|
|
14
|
+
const listed = await run([
|
|
15
|
+
'api',
|
|
16
|
+
'--paginate',
|
|
17
|
+
'--slurp',
|
|
18
|
+
'-X',
|
|
19
|
+
'GET',
|
|
20
|
+
base,
|
|
21
|
+
'-F',
|
|
22
|
+
'per_page=100',
|
|
23
|
+
]);
|
|
24
|
+
const existing = new Set(JSON.parse(listed).flat().map(({ name }) => name));
|
|
25
|
+
for (const [index, label] of labels.entries()) {
|
|
26
|
+
if (!update && existing.has(label))
|
|
27
|
+
continue;
|
|
28
|
+
const { color, description } = metadata[index];
|
|
29
|
+
try {
|
|
30
|
+
await run([
|
|
31
|
+
'label',
|
|
32
|
+
'create',
|
|
33
|
+
label,
|
|
34
|
+
'--color',
|
|
35
|
+
color,
|
|
36
|
+
'--description',
|
|
37
|
+
description,
|
|
38
|
+
...(update ? ['--force'] : []),
|
|
39
|
+
...(repo ? ['--repo', repo] : []),
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (update)
|
|
44
|
+
throw error;
|
|
45
|
+
try {
|
|
46
|
+
await run(['api', `${base}/${encodeURIComponent(label)}`, '--silent']);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
existing.add(label);
|
|
53
|
+
}
|
|
54
|
+
return [...labels];
|
|
55
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DEFAULT_LABELER_PATH, labelsFromPaths } from './labels-from-paths.mts';
|
|
2
|
+
export { ensureLabels } from './ensure-labels.mts';
|
|
3
|
+
export type { EnsureLabelsOptions } from './ensure-labels.mts';
|
|
4
|
+
export { DEFAULT_LABEL_POLICY, labelMetadata, parseLabelPolicy, readLabelPolicyFile, } from './label-policy.mts';
|
|
5
|
+
export type { LabelMetadata, LabelPolicy } from './label-policy.mts';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type LabelMetadata = {
|
|
2
|
+
color: string;
|
|
3
|
+
description: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* How label names map to GitHub label metadata. `labels` holds explicit entries; any other name
|
|
7
|
+
* gets `defaultColor` and `defaultDescription` (`{name}` is replaced by the label name). A name
|
|
8
|
+
* starting with one of `strictPrefixes` must have an explicit entry, or it is rejected.
|
|
9
|
+
*/
|
|
10
|
+
export type LabelPolicy = {
|
|
11
|
+
labels: Readonly<Record<string, LabelMetadata>>;
|
|
12
|
+
defaultColor: string;
|
|
13
|
+
defaultDescription: string;
|
|
14
|
+
strictPrefixes: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
export declare const DEFAULT_LABEL_POLICY: LabelPolicy;
|
|
17
|
+
/** Validates a parsed JSON label policy; omitted fields fall back to `DEFAULT_LABEL_POLICY`. */
|
|
18
|
+
export declare function parseLabelPolicy(input: unknown): LabelPolicy;
|
|
19
|
+
export declare function readLabelPolicyFile(path: string): LabelPolicy;
|
|
20
|
+
/** Resolves a label's color and description, throwing for an unlisted strict-prefix label. */
|
|
21
|
+
export declare function labelMetadata(name: string, policy?: LabelPolicy): LabelMetadata;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
export const DEFAULT_LABEL_POLICY = {
|
|
3
|
+
labels: {},
|
|
4
|
+
defaultColor: 'EDEDED',
|
|
5
|
+
defaultDescription: 'Repository issue classification: {name}.',
|
|
6
|
+
strictPrefixes: [],
|
|
7
|
+
};
|
|
8
|
+
function isRecord(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
function text(value, field) {
|
|
12
|
+
if (typeof value !== 'string' || value === '') {
|
|
13
|
+
throw new Error(`${field} must be a non-empty string`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function parseEntries(input) {
|
|
18
|
+
if (input === undefined)
|
|
19
|
+
return {};
|
|
20
|
+
if (!isRecord(input))
|
|
21
|
+
throw new Error('labels must be an object');
|
|
22
|
+
const labels = {};
|
|
23
|
+
for (const [name, entry] of Object.entries(input)) {
|
|
24
|
+
if (!isRecord(entry))
|
|
25
|
+
throw new Error(`labels.${name} must be an object`);
|
|
26
|
+
labels[name] = {
|
|
27
|
+
color: text(entry.color, `labels.${name}.color`),
|
|
28
|
+
description: text(entry.description, `labels.${name}.description`),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return labels;
|
|
32
|
+
}
|
|
33
|
+
/** Validates a parsed JSON label policy; omitted fields fall back to `DEFAULT_LABEL_POLICY`. */
|
|
34
|
+
export function parseLabelPolicy(input) {
|
|
35
|
+
if (!isRecord(input))
|
|
36
|
+
throw new Error('label policy must be a JSON object');
|
|
37
|
+
const prefixes = input.strictPrefixes ?? [];
|
|
38
|
+
if (!Array.isArray(prefixes) || prefixes.some((prefix) => typeof prefix !== 'string')) {
|
|
39
|
+
throw new Error('strictPrefixes must be an array of strings');
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
labels: parseEntries(input.labels),
|
|
43
|
+
defaultColor: input.defaultColor === undefined
|
|
44
|
+
? DEFAULT_LABEL_POLICY.defaultColor
|
|
45
|
+
: text(input.defaultColor, 'defaultColor'),
|
|
46
|
+
defaultDescription: input.defaultDescription === undefined
|
|
47
|
+
? DEFAULT_LABEL_POLICY.defaultDescription
|
|
48
|
+
: text(input.defaultDescription, 'defaultDescription'),
|
|
49
|
+
strictPrefixes: prefixes,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function readLabelPolicyFile(path) {
|
|
53
|
+
return parseLabelPolicy(JSON.parse(readFileSync(path, 'utf8')));
|
|
54
|
+
}
|
|
55
|
+
/** Resolves a label's color and description, throwing for an unlisted strict-prefix label. */
|
|
56
|
+
export function labelMetadata(name, policy = DEFAULT_LABEL_POLICY) {
|
|
57
|
+
const explicit = Object.hasOwn(policy.labels, name) ? policy.labels[name] : undefined;
|
|
58
|
+
if (explicit)
|
|
59
|
+
return explicit;
|
|
60
|
+
const prefix = policy.strictPrefixes.find((candidate) => name.startsWith(candidate));
|
|
61
|
+
if (prefix !== undefined)
|
|
62
|
+
throw new Error(`unsupported ${prefix} label: ${name}`);
|
|
63
|
+
return {
|
|
64
|
+
color: policy.defaultColor,
|
|
65
|
+
description: policy.defaultDescription.replaceAll('{name}', name),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The conventional labeler config location, relative to the repository root. */
|
|
2
|
+
export declare const DEFAULT_LABELER_PATH = ".github/labeler.yml";
|
|
3
|
+
/**
|
|
4
|
+
* Maps changed paths to the labels an `actions/labeler` v5 config (`changed-files` with plain or
|
|
5
|
+
* `any-glob-to-any-file` entries) would apply, matching dotfiles like the real labeler. A missing
|
|
6
|
+
* config yields no labels; an unparseable or non-mapping config throws with its path.
|
|
7
|
+
* Labels are returned once each, in config order.
|
|
8
|
+
*/
|
|
9
|
+
export declare function labelsFromPaths(paths: string[], labelerPath: string): Promise<string[]>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { parse as load } from 'yaml';
|
|
3
|
+
import picomatch from 'picomatch';
|
|
4
|
+
/** The conventional labeler config location, relative to the repository root. */
|
|
5
|
+
export const DEFAULT_LABELER_PATH = '.github/labeler.yml';
|
|
6
|
+
async function readLabeler(labelerPath) {
|
|
7
|
+
let raw;
|
|
8
|
+
try {
|
|
9
|
+
raw = await readFile(labelerPath, 'utf8');
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error.code === 'ENOENT')
|
|
13
|
+
return {};
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = load(raw);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error(`invalid labeler config ${labelerPath}: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
24
|
+
throw new Error(`invalid labeler config ${labelerPath}: top level must be a mapping`);
|
|
25
|
+
}
|
|
26
|
+
return parsed;
|
|
27
|
+
}
|
|
28
|
+
function entryGlobs(entry) {
|
|
29
|
+
if (typeof entry === 'string')
|
|
30
|
+
return [entry];
|
|
31
|
+
const globs = entry['any-glob-to-any-file'];
|
|
32
|
+
return Array.isArray(globs) ? globs : [globs];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Maps changed paths to the labels an `actions/labeler` v5 config (`changed-files` with plain or
|
|
36
|
+
* `any-glob-to-any-file` entries) would apply, matching dotfiles like the real labeler. A missing
|
|
37
|
+
* config yields no labels; an unparseable or non-mapping config throws with its path.
|
|
38
|
+
* Labels are returned once each, in config order.
|
|
39
|
+
*/
|
|
40
|
+
export async function labelsFromPaths(paths, labelerPath) {
|
|
41
|
+
const labeler = await readLabeler(labelerPath);
|
|
42
|
+
const matched = [];
|
|
43
|
+
for (const [label, rules] of Object.entries(labeler)) {
|
|
44
|
+
if (!Array.isArray(rules))
|
|
45
|
+
continue;
|
|
46
|
+
const hit = rules.some((rule) => (rule['changed-files'] ?? []).some((entry) => {
|
|
47
|
+
const isMatch = picomatch(entryGlobs(entry), { dot: true });
|
|
48
|
+
return paths.some((path) => isMatch(path));
|
|
49
|
+
}));
|
|
50
|
+
if (hit)
|
|
51
|
+
matched.push(label);
|
|
52
|
+
}
|
|
53
|
+
return matched;
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { DEFAULT_LABELER_PATH, ensureLabels, labelsFromPaths, readLabelPolicyFile, } from "../../agent-issue-labels/index.mjs";
|
|
3
|
+
export async function runAgentIssueLabels(parsed, cwd = process.cwd()) {
|
|
4
|
+
const labels = parsed.subcommand === 'labels-from-paths'
|
|
5
|
+
? await labelsFromPaths(parsed.paths, resolve(cwd, parsed.labeler ?? DEFAULT_LABELER_PATH))
|
|
6
|
+
: await ensureLabels({
|
|
7
|
+
labels: parsed.labels,
|
|
8
|
+
update: parsed.update,
|
|
9
|
+
...(parsed.repo === undefined ? {} : { repo: parsed.repo }),
|
|
10
|
+
...(parsed.policyFile === undefined
|
|
11
|
+
? {}
|
|
12
|
+
: { policy: readLabelPolicyFile(resolve(cwd, parsed.policyFile)) }),
|
|
13
|
+
});
|
|
14
|
+
for (const label of labels)
|
|
15
|
+
process.stdout.write(`${label}\n`);
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/cli/index.mjs
CHANGED
|
@@ -5,13 +5,17 @@ import { pathToFileURL } from 'node:url';
|
|
|
5
5
|
import { runPostReviewCli } from "../gha-post-review/cli.mjs";
|
|
6
6
|
import { runStageReviewPayloadCli } from "../gha-review-payload/cli.mjs";
|
|
7
7
|
import { runSwiftSemanticEqualCli } from "../swift-semantic-equal/cli.mjs";
|
|
8
|
+
import { runAgentIssueLabels } from "./commands/agent-issue-labels.mjs";
|
|
8
9
|
import { runGhaArtifactsCleanup } from "./commands/gha-artifacts-cleanup.mjs";
|
|
9
10
|
import { runGhaRuntimeAudit } from "./commands/gha-runtime-audit.mjs";
|
|
11
|
+
import { runGitleaksDirectoryScanCommand } from "./commands/gitleaks-directory-scan.mjs";
|
|
10
12
|
import { runHttpOrigin } from "./commands/http-origin.mjs";
|
|
11
13
|
import { runPnpmInstallCli } from "./commands/pnpm-install.mjs";
|
|
12
14
|
import { runRunnerPortPolicy } from "./commands/runner-port-policy.mjs";
|
|
13
15
|
import { runScript } from "./commands/spawn-script.mjs";
|
|
14
16
|
import { runNugetCentralVersionCommand } from "./commands/nuget-central-version.mjs";
|
|
17
|
+
import { runDeadCodeCli } from "../dead-code/cli.mjs";
|
|
18
|
+
import { runVerifyWorkflowSecretsCli } from "../workflow-secrets-drift/cli.mjs";
|
|
15
19
|
import { runVitestBlobManifestCommand } from "./commands/vitest-blob-manifest.mjs";
|
|
16
20
|
import { runVitestReportAttemptCommand } from "./commands/vitest-report-attempt.mjs";
|
|
17
21
|
import { runPrepareVitestReportsCommand } from "./commands/prepare-vitest-reports.mjs";
|
|
@@ -30,57 +34,10 @@ import { runAstGrepPackCommand } from "./commands/ast-grep-pack.mjs";
|
|
|
30
34
|
import { runGhaWorkspacePolicy } from "./commands/gha-workspace-policy.mjs";
|
|
31
35
|
import { readInstalledVersion } from "./installed-version.mjs";
|
|
32
36
|
import { parseCli } from "./parse.mjs";
|
|
37
|
+
import { SCRIPT_PATHS } from "./script-paths.mjs";
|
|
33
38
|
import { runStoryCoverageLazy } from "./story-coverage-lazy.mjs";
|
|
34
39
|
import { packageScriptPath } from "./script-path.mjs";
|
|
35
40
|
import { commandUsage, printUsage } from "./usage.mjs";
|
|
36
|
-
const SCRIPT_PATHS = {
|
|
37
|
-
'gha-output': { command: 'bash', path: 'scripts/gha/write-github-multiline-output.sh' },
|
|
38
|
-
'gha-needs-results': { command: 'bash', path: 'scripts/gha/check-needs-results.sh' },
|
|
39
|
-
'download-with-diagnostics': {
|
|
40
|
-
command: 'bash',
|
|
41
|
-
path: 'scripts/gha/download-with-diagnostics.sh',
|
|
42
|
-
},
|
|
43
|
-
'download-optional-run-artifacts': {
|
|
44
|
-
command: 'bash',
|
|
45
|
-
path: 'scripts/gha/download-optional-run-artifacts.sh',
|
|
46
|
-
},
|
|
47
|
-
'host-pressure-diagnostics': {
|
|
48
|
-
command: 'bash',
|
|
49
|
-
path: 'scripts/gha/host-pressure-diagnostics.sh',
|
|
50
|
-
},
|
|
51
|
-
'allocate-browser-safe-ports': {
|
|
52
|
-
command: 'python3',
|
|
53
|
-
path: 'scripts/allocate-browser-safe-ports.py',
|
|
54
|
-
},
|
|
55
|
-
'diagnose-port-collision': {
|
|
56
|
-
command: 'bash',
|
|
57
|
-
path: 'scripts/gha/diagnose-port-collision.sh',
|
|
58
|
-
},
|
|
59
|
-
'prepare-trivy-db': { command: 'bash', path: 'scripts/gha/prepare-trivy-db.sh' },
|
|
60
|
-
'check-cache-size': { command: 'bash', path: 'scripts/gha/check-cache-size.sh' },
|
|
61
|
-
'make-shard-matrix': { command: 'bash', path: 'scripts/gha/make-shard-matrix.sh' },
|
|
62
|
-
'load-runner-env': { command: 'bash', path: 'scripts/gha/load-runner-env.sh' },
|
|
63
|
-
'clean-workspace': { command: 'bash', path: 'scripts/gha/clean-workspace.sh' },
|
|
64
|
-
'install-github-release': { command: 'bash', path: 'scripts/gha/install-github-release.sh' },
|
|
65
|
-
'run-with-timeout': { command: 'bash', path: 'scripts/gha/run-with-timeout.sh' },
|
|
66
|
-
'lint-links': { command: 'bash', path: 'scripts/gha/lint-links.sh' },
|
|
67
|
-
'materialize-pr-context': { command: 'bash', path: 'scripts/gha/materialize-pr-context.sh' },
|
|
68
|
-
'wait-for-apt-locks': { command: 'bash', path: 'scripts/gha/wait-for-apt-locks.sh' },
|
|
69
|
-
'install-playwright-chromium-arm64': {
|
|
70
|
-
command: 'bash',
|
|
71
|
-
path: 'scripts/gha/install-playwright-chromium-arm64.sh',
|
|
72
|
-
},
|
|
73
|
-
'ghcr-package-retention': { command: 'bash', path: 'scripts/gha/ghcr-package-retention.sh' },
|
|
74
|
-
'harness-admission-lane': {
|
|
75
|
-
command: 'bash',
|
|
76
|
-
path: 'scripts/gha/harness-admission-lane.sh',
|
|
77
|
-
},
|
|
78
|
-
'harness-assert-gates': { command: 'bash', path: 'scripts/gha/harness-assert-gates.sh' },
|
|
79
|
-
'gha-collaborator-trust': {
|
|
80
|
-
command: 'bash',
|
|
81
|
-
path: 'scripts/gha/gha-collaborator-trust.sh',
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
41
|
export function runCli(argv = process.argv) {
|
|
85
42
|
const parsed = parseCli(argv);
|
|
86
43
|
switch (parsed.kind) {
|
|
@@ -119,6 +76,10 @@ export function runCli(argv = process.argv) {
|
|
|
119
76
|
return runPrepareVitestReportsCommand(parsed.args);
|
|
120
77
|
case 'nuget-central-version':
|
|
121
78
|
return runNugetCentralVersionCommand(parsed.args);
|
|
79
|
+
case 'verify-workflow-secrets':
|
|
80
|
+
return runVerifyWorkflowSecretsCli(parsed.args);
|
|
81
|
+
case 'dead-code':
|
|
82
|
+
return runDeadCodeCli(parsed.args);
|
|
122
83
|
case 'swift-semantic-equal':
|
|
123
84
|
return runSwiftSemanticEqualCli(parsed.args);
|
|
124
85
|
case 'post-review':
|
|
@@ -129,6 +90,8 @@ export function runCli(argv = process.argv) {
|
|
|
129
90
|
return runHttpOrigin(parsed.field, parsed.value);
|
|
130
91
|
case 'gha-artifacts-cleanup':
|
|
131
92
|
return runGhaArtifactsCleanup(parsed);
|
|
93
|
+
case 'agent-issue-labels':
|
|
94
|
+
return runAgentIssueLabels(parsed);
|
|
132
95
|
case 'story-coverage':
|
|
133
96
|
return runStoryCoverageLazy(parsed);
|
|
134
97
|
case 'retrospective-transcript':
|
|
@@ -141,6 +104,8 @@ export function runCli(argv = process.argv) {
|
|
|
141
104
|
return runAgentBlackboardCommand(parsed.args);
|
|
142
105
|
case 'mcp':
|
|
143
106
|
return runMcpCommand(parsed.args);
|
|
107
|
+
case 'transient-retry':
|
|
108
|
+
return import("./commands/transient-retry.mjs").then((command) => command.runTransientRetryCommand(parsed.args));
|
|
144
109
|
case 'worktree':
|
|
145
110
|
return runWorktreeCommand(parsed.args);
|
|
146
111
|
case 'require-up-to-date':
|
|
@@ -148,11 +113,7 @@ export function runCli(argv = process.argv) {
|
|
|
148
113
|
case 'fresh-base':
|
|
149
114
|
return runFreshBase(parsed);
|
|
150
115
|
case 'gitleaks-directory-scan':
|
|
151
|
-
return
|
|
152
|
-
'--config',
|
|
153
|
-
parsed.config,
|
|
154
|
-
...(parsed.directory === undefined ? [] : ['--root', parsed.directory]),
|
|
155
|
-
]);
|
|
116
|
+
return runGitleaksDirectoryScanCommand(parsed);
|
|
156
117
|
case 'ast-grep-examples':
|
|
157
118
|
return runAstGrepExamplesCommand(parsed);
|
|
158
119
|
case 'ast-grep-pack':
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ParsedAgentIssueLabels = {
|
|
2
|
+
kind: 'agent-issue-labels';
|
|
3
|
+
subcommand: 'labels-from-paths';
|
|
4
|
+
labeler?: string;
|
|
5
|
+
paths: string[];
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'agent-issue-labels';
|
|
8
|
+
subcommand: 'ensure-labels';
|
|
9
|
+
repo?: string;
|
|
10
|
+
policyFile?: string;
|
|
11
|
+
update: boolean;
|
|
12
|
+
labels: string[];
|
|
13
|
+
};
|
|
14
|
+
type Failure = {
|
|
15
|
+
kind: 'error';
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function parseAgentIssueLabels(args: readonly string[]): ParsedAgentIssueLabels | Failure;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const PREFIX = 'agent-issue-labels';
|
|
2
|
+
/** Reads the value after `flag`, rejecting a missing value or another flag. */
|
|
3
|
+
function takeValue(args, index, flag) {
|
|
4
|
+
const value = args[index + 1];
|
|
5
|
+
if (value === undefined || value.startsWith('--')) {
|
|
6
|
+
return { kind: 'error', message: `${PREFIX}: ${flag} requires a value` };
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
export function parseAgentIssueLabels(args) {
|
|
11
|
+
const [subcommand, ...rest] = args;
|
|
12
|
+
if (subcommand !== 'labels-from-paths' && subcommand !== 'ensure-labels') {
|
|
13
|
+
return {
|
|
14
|
+
kind: 'error',
|
|
15
|
+
message: subcommand === undefined
|
|
16
|
+
? `${PREFIX} requires labels-from-paths or ensure-labels`
|
|
17
|
+
: `unknown ${PREFIX} subcommand: ${subcommand}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const positional = [];
|
|
21
|
+
const values = new Map();
|
|
22
|
+
let update = false;
|
|
23
|
+
const allowed = subcommand === 'ensure-labels' ? ['--repo', '--policy-file'] : ['--labeler'];
|
|
24
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
25
|
+
const arg = rest[index];
|
|
26
|
+
if (arg === '--update' && subcommand === 'ensure-labels') {
|
|
27
|
+
if (update)
|
|
28
|
+
return { kind: 'error', message: `${PREFIX}: --update may be specified only once` };
|
|
29
|
+
update = true;
|
|
30
|
+
}
|
|
31
|
+
else if (allowed.includes(arg)) {
|
|
32
|
+
if (values.has(arg)) {
|
|
33
|
+
return { kind: 'error', message: `${PREFIX}: ${arg} may be specified only once` };
|
|
34
|
+
}
|
|
35
|
+
const value = takeValue(rest, index, arg);
|
|
36
|
+
if (typeof value !== 'string')
|
|
37
|
+
return value;
|
|
38
|
+
values.set(arg, value);
|
|
39
|
+
index += 1;
|
|
40
|
+
}
|
|
41
|
+
else if (arg.startsWith('--')) {
|
|
42
|
+
return { kind: 'error', message: `unknown ${PREFIX} option: ${arg}` };
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
positional.push(arg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (subcommand === 'labels-from-paths') {
|
|
49
|
+
const labeler = values.get('--labeler');
|
|
50
|
+
return {
|
|
51
|
+
kind: 'agent-issue-labels',
|
|
52
|
+
subcommand,
|
|
53
|
+
paths: positional,
|
|
54
|
+
...(labeler === undefined ? {} : { labeler }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (positional.length === 0) {
|
|
58
|
+
return { kind: 'error', message: `${PREFIX} ensure-labels requires at least one label` };
|
|
59
|
+
}
|
|
60
|
+
const repo = values.get('--repo');
|
|
61
|
+
const policyFile = values.get('--policy-file');
|
|
62
|
+
return {
|
|
63
|
+
kind: 'agent-issue-labels',
|
|
64
|
+
subcommand,
|
|
65
|
+
update,
|
|
66
|
+
labels: positional,
|
|
67
|
+
...(repo === undefined ? {} : { repo }),
|
|
68
|
+
...(policyFile === undefined ? {} : { policyFile }),
|
|
69
|
+
};
|
|
70
|
+
}
|