vouchington-tooling 0.87.1 → 1.0.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 +1 -8
- package/dist/agent-blackboard/feedback-journal-audit.mjs +14 -6
- package/dist/agent-blackboard/feedback-journal-sandbox.d.mts +4 -2
- package/dist/agent-blackboard/feedback-journal-sandbox.mjs +14 -6
- package/dist/agent-blackboard/snapshot-cleanup-receipt.d.mts +2 -2
- package/dist/agent-blackboard/snapshot-cleanup-receipt.mjs +20 -12
- package/dist/agent-blackboard/snapshot-partition-cleanup.d.mts +1 -0
- package/dist/agent-blackboard/snapshot-partition-cleanup.mjs +3 -0
- package/dist/agent-blackboard/snapshot-partitions.mjs +1 -1
- package/dist/agent-blackboard/snapshot-types.d.mts +8 -0
- package/dist/audit-journal/audit-block.d.mts +2 -0
- package/dist/audit-journal/audit-block.mjs +13 -8
- package/dist/audit-journal/ci-failures.d.mts +6 -2
- package/dist/audit-journal/ci-failures.mjs +12 -6
- package/dist/audit-journal/journal.d.mts +2 -0
- package/dist/audit-journal/journal.mjs +18 -3
- package/dist/audit-journal/scope.d.mts +25 -0
- package/dist/audit-journal/scope.mjs +47 -0
- package/dist/audit-journal/types.d.mts +3 -0
- package/dist/cli/index.mjs +0 -6
- package/dist/cli/parse-forwarded-commands.d.mts +1 -1
- package/dist/cli/parse-forwarded-commands.mjs +0 -2
- package/dist/cli/parse.d.mts +1 -7
- package/dist/cli/parse.mjs +0 -1
- package/dist/cli/script-paths.mjs +0 -1
- package/dist/cli/usage-text.d.mts +1 -1
- package/dist/cli/usage-text.mjs +0 -6
- package/dist/gh-cli/exec.d.mts +8 -2
- package/dist/gh-cli/exec.mjs +3 -3
- package/dist/gha-review-payload/index.d.mts +0 -2
- package/dist/gha-review-payload/index.mjs +0 -1
- package/dist/index.d.mts +2 -8
- package/dist/index.mjs +1 -4
- package/dist/mcp-server/dispatch.mjs +1 -1
- package/dist/mcp-server/handlers-pr.mjs +1 -1
- package/dist/mcp-server/handlers-snapshot-cleanup.mjs +8 -0
- package/dist/mcp-server/handlers-snapshot-partition.mjs +6 -1
- package/dist/mcp-server/install-info.d.mts +2 -2
- package/dist/mcp-server/install-info.mjs +10 -6
- package/dist/mcp-server/pr-diff-size.d.mts +16 -0
- package/dist/mcp-server/pr-diff-size.mjs +49 -0
- package/dist/mcp-server/pr-live.d.mts +3 -0
- package/dist/mcp-server/pr-live.mjs +8 -2
- package/dist/mcp-server/pr-prepare.mjs +20 -12
- package/dist/mcp-server/server.mjs +2 -1
- package/dist/mcp-server/snapshot-recovery.d.mts +8 -0
- package/dist/mcp-server/snapshot-recovery.mjs +76 -0
- package/dist/mcp-server/snapshot-registry.d.mts +3 -1
- package/dist/mcp-server/snapshot-registry.mjs +3 -1
- package/dist/mcp-server/tools-pr.mjs +2 -1
- package/dist/mcp-server/tools.mjs +16 -5
- package/dist/mcp-server/worktree.mjs +4 -1
- package/docs/mcp-server.md +43 -10
- package/package.json +1 -16
- package/scripts/__pycache__/run_bounded_process.cpython-314.pyc +0 -0
- package/skills/agent-workflow/SKILL.md +7 -1
- package/skills/dependabot/SKILL.md +4 -3
- package/skills/final-review/references/orchestrator.md +3 -3
- package/skills/manifest.json +25 -33
- package/skills/planning/SKILL.md +3 -0
- package/skills/retrospective/SKILL.md +2 -1
- package/skills/review-ci-logs/SKILL.md +2 -0
- package/skills/stacked-prs/SKILL.md +8 -2
- package/skills/stacked-prs/references/drain.md +3 -1
- package/skills/triage-loop/SKILL.md +125 -21
- package/skills/triage-loop/references/shepherd.md +45 -0
- package/skills/triage-prs/SKILL.md +15 -18
- package/skills/triage-prs/references/rubric.md +2 -2
- package/skills/triage-sweep/SKILL.md +40 -12
- package/dist/gha-check-run/cli.d.mts +0 -2
- package/dist/gha-check-run/cli.mjs +0 -81
- package/dist/gha-check-run/github.d.mts +0 -30
- package/dist/gha-check-run/github.mjs +0 -63
- package/dist/gha-check-run/index.d.mts +0 -2
- package/dist/gha-check-run/index.mjs +0 -2
- package/dist/gha-claude-post-review/index.d.mts +0 -3
- package/dist/gha-claude-post-review/index.mjs +0 -2
- package/dist/gha-post-review/claude-token.d.mts +0 -25
- package/dist/gha-post-review/claude-token.mjs +0 -109
- package/dist/gha-post-review/cli.d.mts +0 -1
- package/dist/gha-post-review/cli.mjs +0 -22
- package/dist/gha-post-review/github.d.mts +0 -13
- package/dist/gha-post-review/github.mjs +0 -58
- package/dist/gha-post-review/index.d.mts +0 -13
- package/dist/gha-post-review/index.mjs +0 -8
- package/dist/gha-post-review/post.d.mts +0 -24
- package/dist/gha-post-review/post.mjs +0 -39
- package/dist/gha-post-review/pull-io.d.mts +0 -13
- package/dist/gha-post-review/pull-io.mjs +0 -88
- package/dist/gha-post-review/token.d.mts +0 -9
- package/dist/gha-post-review/token.mjs +0 -21
- package/dist/gha-review-payload/cli.d.mts +0 -1
- package/dist/gha-review-payload/cli.mjs +0 -24
- package/dist/gha-review-payload/file.d.mts +0 -7
- package/dist/gha-review-payload/file.mjs +0 -62
- package/scripts/gha/materialize-pr-context.sh +0 -123
- package/skills/ready-and-shepherd/SKILL.md +0 -110
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export declare const CLAUDE_OIDC_AUDIENCE = "claude-code-github-action";
|
|
2
|
-
export declare const CLAUDE_APP_TOKEN_EXCHANGE_URL = "https://api.anthropic.com/api/github/github-app-token-exchange";
|
|
3
|
-
export declare const CLAUDE_POSTER_PERMISSIONS: {
|
|
4
|
-
readonly contents: "read";
|
|
5
|
-
readonly pull_requests: "write";
|
|
6
|
-
};
|
|
7
|
-
export declare const GITHUB_INSTALLATION_TOKEN_URL = "https://api.github.com/installation/token";
|
|
8
|
-
export type FetchLike = (url: string, init: RequestInit) => Promise<{
|
|
9
|
-
ok: boolean;
|
|
10
|
-
status: number;
|
|
11
|
-
json(): Promise<unknown>;
|
|
12
|
-
}>;
|
|
13
|
-
export type ClaudeTokenIo = {
|
|
14
|
-
getOidcToken(): Promise<string>;
|
|
15
|
-
fetch: FetchLike;
|
|
16
|
-
mask(token: string): void;
|
|
17
|
-
};
|
|
18
|
-
export declare function oidcTokenRequest(env: NodeJS.ProcessEnv): {
|
|
19
|
-
url: string;
|
|
20
|
-
token: string;
|
|
21
|
-
};
|
|
22
|
-
export declare function mintClaudeAppToken(io: ClaudeTokenIo): Promise<string>;
|
|
23
|
-
export declare function revokeClaudeAppToken(token: string, io: Pick<ClaudeTokenIo, 'fetch'>): Promise<void>;
|
|
24
|
-
export declare function withClaudeAppToken<T>(io: ClaudeTokenIo, fn: (token: string) => T | Promise<T>): Promise<T>;
|
|
25
|
-
export declare function createActionsClaudeTokenIo(env?: NodeJS.ProcessEnv, fetchImpl?: FetchLike): ClaudeTokenIo;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { ReviewPayloadError as PostReviewError } from "../gha-review-payload/index.mjs";
|
|
2
|
-
export const CLAUDE_OIDC_AUDIENCE = 'claude-code-github-action';
|
|
3
|
-
export const CLAUDE_APP_TOKEN_EXCHANGE_URL = 'https://api.anthropic.com/api/github/github-app-token-exchange';
|
|
4
|
-
// Anthropic rejects the exchange unless custom permissions include contents
|
|
5
|
-
// (read or write), even when the token is only used to POST /reviews.
|
|
6
|
-
export const CLAUDE_POSTER_PERMISSIONS = {
|
|
7
|
-
contents: 'read',
|
|
8
|
-
pull_requests: 'write',
|
|
9
|
-
};
|
|
10
|
-
export const GITHUB_INSTALLATION_TOKEN_URL = 'https://api.github.com/installation/token';
|
|
11
|
-
export function oidcTokenRequest(env) {
|
|
12
|
-
const base = env.ACTIONS_ID_TOKEN_REQUEST_URL;
|
|
13
|
-
const token = env.ACTIONS_ID_TOKEN_REQUEST_TOKEN;
|
|
14
|
-
if (!base || !token) {
|
|
15
|
-
throw new PostReviewError('OIDC token request env is missing.');
|
|
16
|
-
}
|
|
17
|
-
const separator = base.includes('?') ? '&' : '?';
|
|
18
|
-
return {
|
|
19
|
-
url: `${base}${separator}audience=${encodeURIComponent(CLAUDE_OIDC_AUDIENCE)}`,
|
|
20
|
-
token,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function readToken(payload) {
|
|
24
|
-
if (payload === null || typeof payload !== 'object')
|
|
25
|
-
return '';
|
|
26
|
-
// oxlint-disable-next-line no-mistakes/ts-no-const-aliases -- establish a record view after validating the untrusted response object
|
|
27
|
-
const record = payload;
|
|
28
|
-
const token = record.token ?? record.app_token ?? record.value;
|
|
29
|
-
return typeof token === 'string' ? token : '';
|
|
30
|
-
}
|
|
31
|
-
function readErrorMessage(payload) {
|
|
32
|
-
if (payload === null || typeof payload !== 'object')
|
|
33
|
-
return '';
|
|
34
|
-
// oxlint-disable-next-line no-mistakes/ts-no-const-aliases -- establish a record view after validating the untrusted response object
|
|
35
|
-
const record = payload;
|
|
36
|
-
if (typeof record.message === 'string' && record.message.length > 0)
|
|
37
|
-
return record.message;
|
|
38
|
-
const nested = record.error;
|
|
39
|
-
if (nested !== null && typeof nested === 'object') {
|
|
40
|
-
const message = nested.message;
|
|
41
|
-
if (typeof message === 'string')
|
|
42
|
-
return message;
|
|
43
|
-
}
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
function exchangeErrorMessage(status, payload) {
|
|
47
|
-
const detail = readErrorMessage(payload);
|
|
48
|
-
const suffix = detail.length > 0 ? `: ${detail}` : '';
|
|
49
|
-
return `Claude App token exchange failed (HTTP ${status})${suffix}.`;
|
|
50
|
-
}
|
|
51
|
-
export async function mintClaudeAppToken(io) {
|
|
52
|
-
const oidcToken = await io.getOidcToken();
|
|
53
|
-
const response = await io.fetch(CLAUDE_APP_TOKEN_EXCHANGE_URL, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
headers: {
|
|
56
|
-
Authorization: `Bearer ${oidcToken}`,
|
|
57
|
-
'Content-Type': 'application/json',
|
|
58
|
-
},
|
|
59
|
-
body: JSON.stringify({ permissions: CLAUDE_POSTER_PERMISSIONS }),
|
|
60
|
-
});
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
throw new PostReviewError(exchangeErrorMessage(response.status, await response.json().catch(() => null)));
|
|
63
|
-
}
|
|
64
|
-
const appToken = readToken(await response.json());
|
|
65
|
-
if (appToken.length === 0) {
|
|
66
|
-
throw new PostReviewError('Claude App token exchange returned no token.');
|
|
67
|
-
}
|
|
68
|
-
io.mask(appToken);
|
|
69
|
-
return appToken;
|
|
70
|
-
}
|
|
71
|
-
export async function revokeClaudeAppToken(token, io) {
|
|
72
|
-
await io.fetch(GITHUB_INSTALLATION_TOKEN_URL, {
|
|
73
|
-
method: 'DELETE',
|
|
74
|
-
headers: {
|
|
75
|
-
Accept: 'application/vnd.github+json',
|
|
76
|
-
Authorization: `Bearer ${token}`,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
export async function withClaudeAppToken(io, fn) {
|
|
81
|
-
const token = await mintClaudeAppToken(io);
|
|
82
|
-
try {
|
|
83
|
-
return await fn(token);
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
await revokeClaudeAppToken(token, io);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export function createActionsClaudeTokenIo(env = process.env, fetchImpl = fetch) {
|
|
90
|
-
return {
|
|
91
|
-
async getOidcToken() {
|
|
92
|
-
const request = oidcTokenRequest(env);
|
|
93
|
-
const response = await fetchImpl(request.url, {
|
|
94
|
-
headers: { Authorization: `Bearer ${request.token}` },
|
|
95
|
-
});
|
|
96
|
-
if (!response.ok) {
|
|
97
|
-
throw new PostReviewError(`OIDC token request failed (HTTP ${response.status}).`);
|
|
98
|
-
}
|
|
99
|
-
const jwt = readToken(await response.json());
|
|
100
|
-
if (jwt.length === 0)
|
|
101
|
-
throw new PostReviewError('OIDC token request returned no token.');
|
|
102
|
-
return jwt;
|
|
103
|
-
},
|
|
104
|
-
fetch: fetchImpl,
|
|
105
|
-
mask(token) {
|
|
106
|
-
process.stdout.write(`::add-mask::${token}\n`);
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runPostReviewCli(env?: NodeJS.ProcessEnv): Promise<number>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { writePostedOutput, postReviewFromEnv } from "./github.mjs";
|
|
3
|
-
export async function runPostReviewCli(env = process.env) {
|
|
4
|
-
try {
|
|
5
|
-
const result = await postReviewFromEnv(env);
|
|
6
|
-
writePostedOutput(result.posted, result.commentCount, env.GITHUB_OUTPUT);
|
|
7
|
-
return 0;
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
process.stderr.write(`Error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
11
|
-
return 1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/* v8 ignore next 12 */
|
|
15
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
16
|
-
runPostReviewCli().then((code) => {
|
|
17
|
-
process.exitCode = code;
|
|
18
|
-
}, (error) => {
|
|
19
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
20
|
-
process.exitCode = 1;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { type PostReviewResult } from './post.mts';
|
|
3
|
-
export { createGhPostReviewIo, postWithGh } from './pull-io.mts';
|
|
4
|
-
export type GhExec = (args: readonly string[], options?: {
|
|
5
|
-
input?: string;
|
|
6
|
-
env?: NodeJS.ProcessEnv;
|
|
7
|
-
}) => string;
|
|
8
|
-
export declare function createGhExec(exec?: typeof execFileSync): GhExec;
|
|
9
|
-
export declare function writePostedOutput(posted: boolean, commentCount: number, outputPath?: string | undefined): void;
|
|
10
|
-
/** @deprecated Use postReviewWithTokenFromEnv or postClaudeReviewFromEnv explicitly. */
|
|
11
|
-
export declare function postReviewFromEnv(env?: NodeJS.ProcessEnv, exec?: GhExec, claudeIo?: import("./claude-token.mts").ClaudeTokenIo): Promise<PostReviewResult>;
|
|
12
|
-
export declare function postReviewWithTokenFromEnv(env?: NodeJS.ProcessEnv, exec?: GhExec, token?: string | undefined): PostReviewResult;
|
|
13
|
-
export declare function postClaudeReviewFromEnv(env?: NodeJS.ProcessEnv, exec?: GhExec, claudeIo?: import("./claude-token.mts").ClaudeTokenIo): Promise<PostReviewResult>;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import { appendFileSync } from 'node:fs';
|
|
3
|
-
import { ghSpawnEnv } from "../gh-cli/env.mjs";
|
|
4
|
-
import { ReviewPayloadError } from "../gha-review-payload/index.mjs";
|
|
5
|
-
import { readRegularReviewPayload } from "../gha-review-payload/index.mjs";
|
|
6
|
-
import { createActionsClaudeTokenIo, withClaudeAppToken } from "./claude-token.mjs";
|
|
7
|
-
import { runPostReview } from "./post.mjs";
|
|
8
|
-
import { createGhPostReviewIo } from "./pull-io.mjs";
|
|
9
|
-
import { requireEnv, resolveReviewPostToken } from "./token.mjs";
|
|
10
|
-
export { createGhPostReviewIo, postWithGh } from "./pull-io.mjs";
|
|
11
|
-
export function createGhExec(exec = execFileSync) {
|
|
12
|
-
return (args, options) => exec('gh', [...args], {
|
|
13
|
-
encoding: 'utf8',
|
|
14
|
-
input: options?.input,
|
|
15
|
-
env: ghSpawnEnv(options?.env ?? process.env),
|
|
16
|
-
}).trim();
|
|
17
|
-
}
|
|
18
|
-
export function writePostedOutput(posted, commentCount, outputPath = process.env.GITHUB_OUTPUT) {
|
|
19
|
-
if (!outputPath)
|
|
20
|
-
return;
|
|
21
|
-
appendFileSync(outputPath, `posted=${posted ? 'true' : 'false'}\ncomment_count=${commentCount}\n`);
|
|
22
|
-
}
|
|
23
|
-
/** @deprecated Use postReviewWithTokenFromEnv or postClaudeReviewFromEnv explicitly. */
|
|
24
|
-
export async function postReviewFromEnv(env = process.env, exec = createGhExec(), claudeIo = createActionsClaudeTokenIo(env)) {
|
|
25
|
-
const token = resolveReviewPostToken(env);
|
|
26
|
-
if (token.source === 'github-token')
|
|
27
|
-
return postReviewWithTokenFromEnv(env, exec, token.token);
|
|
28
|
-
return await postClaudeReviewFromEnv(env, exec, claudeIo);
|
|
29
|
-
}
|
|
30
|
-
function createPostWithToken(env, exec) {
|
|
31
|
-
const repository = requireEnv('GITHUB_REPOSITORY', env);
|
|
32
|
-
const prNumber = requireEnv('PR_NUMBER', env);
|
|
33
|
-
const payloadPath = requireEnv('CODE_REVIEW_PAYLOAD_PATH', env);
|
|
34
|
-
const payloadBytes = readRegularReviewPayload(payloadPath, 'required');
|
|
35
|
-
const providerName = env.PROVIDER_NAME || undefined;
|
|
36
|
-
return (token) => runPostReview(payloadPath, createGhPostReviewIo({
|
|
37
|
-
repository,
|
|
38
|
-
prNumber,
|
|
39
|
-
payloadPath,
|
|
40
|
-
payloadBytes,
|
|
41
|
-
token,
|
|
42
|
-
exec,
|
|
43
|
-
expectedHeadSha: env.EXPECTED_HEAD_SHA ?? '',
|
|
44
|
-
expectedBaseSha: env.EXPECTED_BASE_SHA ?? '',
|
|
45
|
-
}), providerName);
|
|
46
|
-
}
|
|
47
|
-
function withTokenEnv(exec, env, token) {
|
|
48
|
-
const tokenEnv = { ...env, GH_TOKEN: token, GITHUB_TOKEN: token };
|
|
49
|
-
return (args, options) => exec(args, { ...options, env: { ...options?.env, ...tokenEnv } });
|
|
50
|
-
}
|
|
51
|
-
export function postReviewWithTokenFromEnv(env = process.env, exec = createGhExec(), token = env.GH_TOKEN || env.GITHUB_TOKEN) {
|
|
52
|
-
if (!token)
|
|
53
|
-
throw new ReviewPayloadError('GH_TOKEN or GITHUB_TOKEN is required.');
|
|
54
|
-
return createPostWithToken(env, withTokenEnv(exec, env, token))(token);
|
|
55
|
-
}
|
|
56
|
-
export async function postClaudeReviewFromEnv(env = process.env, exec = createGhExec(), claudeIo = createActionsClaudeTokenIo(env)) {
|
|
57
|
-
return await withClaudeAppToken(claudeIo, (token) => createPostWithToken(env, withTokenEnv(exec, env, token))(token));
|
|
58
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { MAX_COMMENTS, MAX_PAYLOAD_BYTES, PostReviewError, runPostReview } from './post.mts';
|
|
2
|
-
export type { PostResult, PostReviewIo, PullFile, ReviewComment, SanitizedReview } from './post.mts';
|
|
3
|
-
export { requireEnv, resolveReviewPostToken } from './token.mts';
|
|
4
|
-
export type { ReviewPostToken } from './token.mts';
|
|
5
|
-
/** @deprecated Import Claude helpers from vouchington-tooling/gha-claude-post-review. */
|
|
6
|
-
export { CLAUDE_APP_TOKEN_EXCHANGE_URL, CLAUDE_OIDC_AUDIENCE, CLAUDE_POSTER_PERMISSIONS, GITHUB_INSTALLATION_TOKEN_URL, createActionsClaudeTokenIo, mintClaudeAppToken, oidcTokenRequest, revokeClaudeAppToken, withClaudeAppToken, } from './claude-token.mts';
|
|
7
|
-
/** @deprecated Import Claude helpers from vouchington-tooling/gha-claude-post-review. */
|
|
8
|
-
export type { ClaudeTokenIo, FetchLike } from './claude-token.mts';
|
|
9
|
-
export { createGhExec, createGhPostReviewIo, postReviewWithTokenFromEnv, postWithGh, writePostedOutput, } from './github.mts';
|
|
10
|
-
/** @deprecated Select an explicit posting adapter. */
|
|
11
|
-
export { postClaudeReviewFromEnv, postReviewFromEnv } from './github.mts';
|
|
12
|
-
export type { GhExec } from './github.mts';
|
|
13
|
-
export { runPostReviewCli } from './cli.mts';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { MAX_COMMENTS, MAX_PAYLOAD_BYTES, PostReviewError, runPostReview } from "./post.mjs";
|
|
2
|
-
export { requireEnv, resolveReviewPostToken } from "./token.mjs";
|
|
3
|
-
/** @deprecated Import Claude helpers from vouchington-tooling/gha-claude-post-review. */
|
|
4
|
-
export { CLAUDE_APP_TOKEN_EXCHANGE_URL, CLAUDE_OIDC_AUDIENCE, CLAUDE_POSTER_PERMISSIONS, GITHUB_INSTALLATION_TOKEN_URL, createActionsClaudeTokenIo, mintClaudeAppToken, oidcTokenRequest, revokeClaudeAppToken, withClaudeAppToken, } from "./claude-token.mjs";
|
|
5
|
-
export { createGhExec, createGhPostReviewIo, postReviewWithTokenFromEnv, postWithGh, writePostedOutput, } from "./github.mjs";
|
|
6
|
-
/** @deprecated Select an explicit posting adapter. */
|
|
7
|
-
export { postClaudeReviewFromEnv, postReviewFromEnv } from "./github.mjs";
|
|
8
|
-
export { runPostReviewCli } from "./cli.mjs";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type ReviewFile, type SanitizedReview } from '../gha-review-payload/index.mts';
|
|
2
|
-
export { MAX_REVIEW_COMMENTS as MAX_COMMENTS, MAX_REVIEW_PAYLOAD_BYTES as MAX_PAYLOAD_BYTES, ReviewPayloadError as PostReviewError, type ReviewComment, type SanitizedReview, } from '../gha-review-payload/index.mts';
|
|
3
|
-
export type PullFile = ReviewFile;
|
|
4
|
-
export type PostResult = {
|
|
5
|
-
ok: boolean;
|
|
6
|
-
status: number;
|
|
7
|
-
body: string;
|
|
8
|
-
};
|
|
9
|
-
export type PostReviewIo = {
|
|
10
|
-
readFile(path: string): Buffer;
|
|
11
|
-
removeFile(path: string): void;
|
|
12
|
-
getHeadSha(): string;
|
|
13
|
-
listPullFiles(): PullFile[];
|
|
14
|
-
postReview(payload: SanitizedReview): PostResult;
|
|
15
|
-
};
|
|
16
|
-
export type PostReviewResult = {
|
|
17
|
-
posted: boolean;
|
|
18
|
-
commentCount: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Posts a validated review, optionally prefixing the body with a provider attribution line.
|
|
22
|
-
* The attribution is cosmetic (final posted text only); it never affects staged payload bytes.
|
|
23
|
-
*/
|
|
24
|
-
export declare function runPostReview(payloadPath: string, io: PostReviewIo, providerName?: string): PostReviewResult;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ReviewPayloadError, indexReviewFiles, parseReviewPayload, remapReviewComments, } from "../gha-review-payload/index.mjs";
|
|
2
|
-
export {
|
|
3
|
-
// oxlint-disable-next-line no-mistakes/ts-no-export-renaming -- preserve the package's established public compatibility name
|
|
4
|
-
MAX_REVIEW_COMMENTS as MAX_COMMENTS,
|
|
5
|
-
// oxlint-disable-next-line no-mistakes/ts-no-export-renaming -- preserve the package's established public compatibility name
|
|
6
|
-
MAX_REVIEW_PAYLOAD_BYTES as MAX_PAYLOAD_BYTES,
|
|
7
|
-
// oxlint-disable-next-line no-mistakes/ts-no-export-renaming -- preserve the package's established public compatibility name
|
|
8
|
-
ReviewPayloadError as PostReviewError, } from "../gha-review-payload/index.mjs";
|
|
9
|
-
/**
|
|
10
|
-
* Posts a validated review, optionally prefixing the body with a provider attribution line.
|
|
11
|
-
* The attribution is cosmetic (final posted text only); it never affects staged payload bytes.
|
|
12
|
-
*/
|
|
13
|
-
export function runPostReview(payloadPath, io, providerName) {
|
|
14
|
-
try {
|
|
15
|
-
const selectedHeadSha = io.getHeadSha();
|
|
16
|
-
let review = parseReviewPayload(io.readFile(payloadPath), selectedHeadSha);
|
|
17
|
-
try {
|
|
18
|
-
review = remapReviewComments(review, indexReviewFiles(io.listPullFiles()));
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
// Keep the parsed review when the PR file list is unavailable.
|
|
22
|
-
}
|
|
23
|
-
// The adapter also revalidates a pinned base; equality catches legacy live-head drift.
|
|
24
|
-
if (io.getHeadSha() !== selectedHeadSha) {
|
|
25
|
-
throw new ReviewPayloadError('PR head changed while preparing the selected review.');
|
|
26
|
-
}
|
|
27
|
-
const commentCount = review.comments.length;
|
|
28
|
-
const attributedReview = providerName
|
|
29
|
-
? { ...review, body: `**${providerName} review**\n\n${review.body}` }
|
|
30
|
-
: review;
|
|
31
|
-
const first = io.postReview(attributedReview);
|
|
32
|
-
if (first.ok)
|
|
33
|
-
return { posted: true, commentCount };
|
|
34
|
-
throw new ReviewPayloadError(`GitHub review POST failed (HTTP ${first.status}).`);
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
io.removeFile(payloadPath);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GhExec } from './github.mts';
|
|
2
|
-
import type { PostResult, PostReviewIo, SanitizedReview } from './post.mts';
|
|
3
|
-
export declare function postWithGh(repository: string, prNumber: string, payload: SanitizedReview, token: string, exec: GhExec): PostResult;
|
|
4
|
-
export declare function createGhPostReviewIo(options: {
|
|
5
|
-
repository: string;
|
|
6
|
-
prNumber: string;
|
|
7
|
-
payloadPath: string;
|
|
8
|
-
payloadBytes: Buffer;
|
|
9
|
-
token: string;
|
|
10
|
-
exec: GhExec;
|
|
11
|
-
expectedHeadSha?: string;
|
|
12
|
-
expectedBaseSha?: string;
|
|
13
|
-
}): PostReviewIo;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { rmSync } from 'node:fs';
|
|
2
|
-
import { parseReviewFilesJson, ReviewPayloadError } from "../gha-review-payload/index.mjs";
|
|
3
|
-
export function postWithGh(repository, prNumber, payload, token, exec) {
|
|
4
|
-
try {
|
|
5
|
-
exec(['api', '--method', 'POST', `repos/${repository}/pulls/${prNumber}/reviews`, '--input', '-'], {
|
|
6
|
-
input: JSON.stringify(payload),
|
|
7
|
-
env: { ...process.env, GH_TOKEN: token, GITHUB_TOKEN: token },
|
|
8
|
-
});
|
|
9
|
-
return { ok: true, status: 201, body: '' };
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
// oxlint-disable-next-line no-mistakes/ts-no-const-aliases -- isolate the process-error shape assertion at the catch boundary
|
|
13
|
-
const err = error;
|
|
14
|
-
const text = `${err.stdout ?? ''}${err.stderr ?? ''}${err.message ?? ''}`;
|
|
15
|
-
const status = Number(/HTTP\s+(\d{3})/u.exec(text)?.[1] ?? 0);
|
|
16
|
-
return { ok: false, status, body: text };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function readPullState(repository, prNumber, exec) {
|
|
20
|
-
let lastError;
|
|
21
|
-
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
|
22
|
-
try {
|
|
23
|
-
return exec([
|
|
24
|
-
'api',
|
|
25
|
-
`repos/${repository}/pulls/${prNumber}`,
|
|
26
|
-
'--jq',
|
|
27
|
-
'[.head.sha, .base.sha, .draft, .state] | @tsv',
|
|
28
|
-
]).split('\t');
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
lastError = error;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
throw lastError;
|
|
35
|
-
}
|
|
36
|
-
export function createGhPostReviewIo(options) {
|
|
37
|
-
const { repository, prNumber, payloadBytes, token, exec, expectedHeadSha, expectedBaseSha } = options;
|
|
38
|
-
return {
|
|
39
|
-
readFile() {
|
|
40
|
-
return payloadBytes;
|
|
41
|
-
},
|
|
42
|
-
removeFile(path) {
|
|
43
|
-
rmSync(path, { force: true });
|
|
44
|
-
},
|
|
45
|
-
getHeadSha() {
|
|
46
|
-
if (!/^[1-9][0-9]*$/u.test(prNumber)) {
|
|
47
|
-
throw new ReviewPayloadError('PR_NUMBER must be a positive integer.');
|
|
48
|
-
}
|
|
49
|
-
if (Boolean(expectedHeadSha) !== Boolean(expectedBaseSha)) {
|
|
50
|
-
throw new ReviewPayloadError('EXPECTED_HEAD_SHA and EXPECTED_BASE_SHA must be provided together.');
|
|
51
|
-
}
|
|
52
|
-
if (expectedHeadSha && !/^[0-9a-f]{40}$/u.test(expectedHeadSha)) {
|
|
53
|
-
throw new ReviewPayloadError('EXPECTED_HEAD_SHA must be a full lowercase commit SHA.');
|
|
54
|
-
}
|
|
55
|
-
if (expectedBaseSha && !/^[0-9a-f]{40}$/u.test(expectedBaseSha)) {
|
|
56
|
-
throw new ReviewPayloadError('EXPECTED_BASE_SHA must be a full lowercase commit SHA.');
|
|
57
|
-
}
|
|
58
|
-
const state = readPullState(repository, prNumber, exec);
|
|
59
|
-
const [headSha = '', baseSha = '', draft = '', pullState = ''] = state;
|
|
60
|
-
if (!/^[0-9a-f]{40}$/u.test(headSha)) {
|
|
61
|
-
throw new ReviewPayloadError(`Could not resolve PR head SHA (got "${headSha}").`);
|
|
62
|
-
}
|
|
63
|
-
if (!/^[0-9a-f]{40}$/u.test(baseSha)) {
|
|
64
|
-
throw new ReviewPayloadError(`Could not resolve PR base SHA (got "${baseSha}").`);
|
|
65
|
-
}
|
|
66
|
-
if (draft !== 'false') {
|
|
67
|
-
throw new ReviewPayloadError('Pull request became a draft before posting the review.');
|
|
68
|
-
}
|
|
69
|
-
if (pullState !== 'open') {
|
|
70
|
-
throw new ReviewPayloadError('Pull request closed before posting the review.');
|
|
71
|
-
}
|
|
72
|
-
if (expectedHeadSha && headSha !== expectedHeadSha) {
|
|
73
|
-
throw new ReviewPayloadError('PR head changed before posting the selected review.');
|
|
74
|
-
}
|
|
75
|
-
if (expectedBaseSha && baseSha !== expectedBaseSha) {
|
|
76
|
-
throw new ReviewPayloadError('PR base changed before posting the selected review.');
|
|
77
|
-
}
|
|
78
|
-
// Preserve the orchestrator-selected revision as the review commit_id after equality checks.
|
|
79
|
-
return expectedHeadSha || headSha;
|
|
80
|
-
},
|
|
81
|
-
listPullFiles() {
|
|
82
|
-
return parseReviewFilesJson(exec(['api', '--paginate', `repos/${repository}/pulls/${prNumber}/files?per_page=100`]));
|
|
83
|
-
},
|
|
84
|
-
postReview(payload) {
|
|
85
|
-
return postWithGh(repository, prNumber, payload, token, exec);
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type ReviewPostToken = {
|
|
2
|
-
source: 'github-token';
|
|
3
|
-
token: string;
|
|
4
|
-
} | {
|
|
5
|
-
source: 'claude-app';
|
|
6
|
-
};
|
|
7
|
-
/** @deprecated Select an explicit posting adapter instead of the legacy token-source router. */
|
|
8
|
-
export declare function resolveReviewPostToken(env?: NodeJS.ProcessEnv): ReviewPostToken;
|
|
9
|
-
export declare function requireEnv(name: string, env?: NodeJS.ProcessEnv): string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ReviewPayloadError } from "../gha-review-payload/index.mjs";
|
|
2
|
-
/** @deprecated Select an explicit posting adapter instead of the legacy token-source router. */
|
|
3
|
-
export function resolveReviewPostToken(env = process.env) {
|
|
4
|
-
const source = env.CODE_REVIEW_TOKEN_SOURCE || 'claude-app';
|
|
5
|
-
if (source === 'github-token') {
|
|
6
|
-
const token = env.GH_TOKEN || env.GITHUB_TOKEN;
|
|
7
|
-
if (!token)
|
|
8
|
-
throw new ReviewPayloadError('GH_TOKEN or GITHUB_TOKEN is required.');
|
|
9
|
-
return { source, token };
|
|
10
|
-
}
|
|
11
|
-
if (source !== 'claude-app') {
|
|
12
|
-
throw new ReviewPayloadError(`Unknown CODE_REVIEW_TOKEN_SOURCE "${source}".`);
|
|
13
|
-
}
|
|
14
|
-
return { source: 'claude-app' };
|
|
15
|
-
}
|
|
16
|
-
export function requireEnv(name, env = process.env) {
|
|
17
|
-
const value = env[name];
|
|
18
|
-
if (!value)
|
|
19
|
-
throw new ReviewPayloadError(`${name} is required.`);
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function runStageReviewPayloadCli(args: readonly string[]): number;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { ReviewPayloadError } from "./payload.mjs";
|
|
3
|
-
import { stageReviewPayload, writeStagedOutput } from "./file.mjs";
|
|
4
|
-
export function runStageReviewPayloadCli(args) {
|
|
5
|
-
try {
|
|
6
|
-
const [requirement, source, destination] = args;
|
|
7
|
-
if (requirement !== 'optional' && requirement !== 'required') {
|
|
8
|
-
throw new ReviewPayloadError('payload requirement must be optional or required.');
|
|
9
|
-
}
|
|
10
|
-
if (!source || !destination || args.length !== 3) {
|
|
11
|
-
throw new ReviewPayloadError('Usage: vouchington stage-review-payload optional|required <source> <destination>');
|
|
12
|
-
}
|
|
13
|
-
writeStagedOutput('staged', stageReviewPayload(source, destination, requirement) ? 'true' : 'false');
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
18
|
-
return 1;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/* v8 ignore next 3 */
|
|
22
|
-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
23
|
-
process.exitCode = runStageReviewPayloadCli(process.argv.slice(2));
|
|
24
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type PayloadRequirement = 'optional' | 'required';
|
|
2
|
-
/** Reads a bounded regular file through an O_NOFOLLOW descriptor. */
|
|
3
|
-
export declare function readRegularReviewPayload(source: string, requirement: PayloadRequirement): Buffer | undefined;
|
|
4
|
-
/** Replaces a private staging directory and writes a 0600 payload from descriptor-read bytes. */
|
|
5
|
-
export declare function stageReviewPayload(source: string, destinationDirectory: string, requirement: PayloadRequirement): string | undefined;
|
|
6
|
-
/** Writes a single output value for a caller that exposes GitHub Actions outputs. */
|
|
7
|
-
export declare function writeStagedOutput(name: string, value: string, outputPath?: string | undefined): void;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { appendFileSync, chmodSync, closeSync, constants, fstatSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
2
|
-
import { basename, join } from 'node:path';
|
|
3
|
-
import { MAX_REVIEW_PAYLOAD_BYTES, ReviewPayloadError } from "./payload.mjs";
|
|
4
|
-
/** Reads a bounded regular file through an O_NOFOLLOW descriptor. */
|
|
5
|
-
export function readRegularReviewPayload(source, requirement) {
|
|
6
|
-
let descriptor;
|
|
7
|
-
try {
|
|
8
|
-
descriptor = openSync(source, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
const code = error.code;
|
|
12
|
-
if (code === 'ENOENT' && requirement === 'optional')
|
|
13
|
-
return undefined;
|
|
14
|
-
if (code === 'ENOENT')
|
|
15
|
-
throw new ReviewPayloadError('Review payload is required.');
|
|
16
|
-
if (code === 'ELOOP') {
|
|
17
|
-
throw new ReviewPayloadError('Review payload must be a regular non-symlink file.');
|
|
18
|
-
}
|
|
19
|
-
throw error;
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const stat = fstatSync(descriptor);
|
|
23
|
-
if (!stat.isFile()) {
|
|
24
|
-
throw new ReviewPayloadError('Review payload must be a regular non-symlink file.');
|
|
25
|
-
}
|
|
26
|
-
if (stat.size === 0 || stat.size > MAX_REVIEW_PAYLOAD_BYTES) {
|
|
27
|
-
throw new ReviewPayloadError(`Review payload must be 1..${MAX_REVIEW_PAYLOAD_BYTES} bytes.`);
|
|
28
|
-
}
|
|
29
|
-
const bytes = readFileSync(descriptor);
|
|
30
|
-
if (bytes.length === 0 || bytes.length > MAX_REVIEW_PAYLOAD_BYTES) {
|
|
31
|
-
throw new ReviewPayloadError(`Review payload must be 1..${MAX_REVIEW_PAYLOAD_BYTES} bytes.`);
|
|
32
|
-
}
|
|
33
|
-
return bytes;
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
closeSync(descriptor);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/** Replaces a private staging directory and writes a 0600 payload from descriptor-read bytes. */
|
|
40
|
-
export function stageReviewPayload(source, destinationDirectory, requirement) {
|
|
41
|
-
rmSync(destinationDirectory, { force: true, recursive: true });
|
|
42
|
-
const bytes = readRegularReviewPayload(source, requirement);
|
|
43
|
-
if (!bytes)
|
|
44
|
-
return undefined;
|
|
45
|
-
mkdirSync(destinationDirectory, { recursive: true, mode: 0o700 });
|
|
46
|
-
const destination = join(destinationDirectory, basename(source));
|
|
47
|
-
writeFileSync(destination, bytes, { flag: 'wx', mode: 0o600 });
|
|
48
|
-
chmodSync(destination, 0o600);
|
|
49
|
-
return destination;
|
|
50
|
-
}
|
|
51
|
-
/** Writes a single output value for a caller that exposes GitHub Actions outputs. */
|
|
52
|
-
export function writeStagedOutput(name, value, outputPath = process.env.GITHUB_OUTPUT) {
|
|
53
|
-
if (!outputPath)
|
|
54
|
-
throw new ReviewPayloadError('GITHUB_OUTPUT is required.');
|
|
55
|
-
if (!/^[A-Za-z_][A-Za-z0-9_-]*$/u.test(name)) {
|
|
56
|
-
throw new ReviewPayloadError('Output name must contain only letters, numbers, underscores, and hyphens.');
|
|
57
|
-
}
|
|
58
|
-
if (/[\r\n]/u.test(value)) {
|
|
59
|
-
throw new ReviewPayloadError('Output value must not contain CR or LF characters.');
|
|
60
|
-
}
|
|
61
|
-
appendFileSync(outputPath, `${name}=${value}\n`);
|
|
62
|
-
}
|