crysk 0.7.0 → 0.8.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 +27 -23
- package/dist/SKILL-1q3658n0.md +74 -0
- package/dist/SKILL-25j4q9b8.md +143 -0
- package/dist/SKILL-4747bhne.md +143 -0
- package/dist/SKILL-4jc3sv23.md +74 -0
- package/dist/SKILL-c0492rch.md +540 -0
- package/dist/SKILL-d1nzkhhr.md +74 -0
- package/dist/SKILL-f8p7kvx0.md +143 -0
- package/dist/SKILL-gxd45g38.md +553 -0
- package/dist/SKILL-rec41991.md +66 -0
- package/dist/SKILL-zze8zj5g.md +536 -0
- package/dist/cli.js +24658 -24654
- package/dist/index.js +492 -463
- package/dist/opencode-ci-qrcv7a99.md +106 -0
- package/dist/opencode-ci-rdpcc7xc.md +106 -0
- package/dist/opencode-ci-yt0k74t0.md +106 -0
- package/dist/workflow-andv2dvm.yml +158 -0
- package/package.json +1 -1
- package/prompts/default/PROVENANCE.md +1 -0
- package/skills/crysk/SKILL.md +6 -6
- package/skills/crysk-ci-setup/SKILL.md +32 -33
- package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
- package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
- package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
- package/skills/crysk-loop/SKILL.md +37 -54
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +0 -6
- package/src/assets.ts +1 -4
- package/src/brand.ts +20 -30
- package/src/ci/gates.ts +155 -201
- package/src/ci/outcome.ts +4 -31
- package/src/ci/platform-limits.ts +135 -0
- package/src/ci/platform-report.ts +212 -126
- package/src/ci/platform.ts +28 -26
- package/src/ci/reporter.ts +25 -26
- package/src/ci/review-admission.ts +1 -2
- package/src/ci/review-levels.ts +12 -53
- package/src/ci/setup.ts +96 -66
- package/src/ci/trace-bundle.ts +11 -27
- package/src/ci/trace-transcripts.ts +4 -6
- package/src/ci/trigger.ts +3 -5
- package/src/cli.ts +6 -5
- package/src/commands/ci-setup-questions.ts +2 -55
- package/src/commands/ci-setup.ts +2 -26
- package/src/commands/triage.ts +131 -38
- package/src/commands/usage.ts +0 -1
- package/src/compare/compare.ts +3 -3
- package/src/compare/floor-test.ts +30 -201
- package/src/config/config.ts +6 -30
- package/src/diversity/accounting.ts +0 -26
- package/src/diversity/benchmark.ts +1 -17
- package/src/diversity/identity.ts +0 -14
- package/src/diversity/pipeline-integration.ts +0 -29
- package/src/doctor.ts +3 -6
- package/src/execution/claude-session-trace.ts +7 -2
- package/src/execution/contracts.ts +15 -9
- package/src/execution/harness.ts +165 -187
- package/src/execution/spend-limiter.ts +39 -131
- package/src/execution/usage-facts.ts +397 -0
- package/src/execution/usage-normalized.ts +33 -86
- package/src/harness/materiality-judge.ts +0 -5
- package/src/harness/pipeline-plan.ts +0 -3
- package/src/harness/replay-rows.ts +0 -5
- package/src/harness/route-runner.ts +2 -2
- package/src/harness/single-step.ts +3 -9
- package/src/index.ts +1 -1
- package/src/mcp/preflight.ts +2 -2
- package/src/model/catalog.ts +1 -3
- package/src/model/free-discovery.ts +11 -78
- package/src/model/model-name.ts +14 -4
- package/src/model/profiles/claude.ts +1 -2
- package/src/model/profiles/openai.ts +1 -2
- package/src/model/profiles.ts +1 -2
- package/src/model/provider-capabilities.ts +16 -55
- package/src/model/routing.ts +39 -36
- package/src/pr/admission.ts +6 -6
- package/src/pr/answered-findings.ts +8 -4
- package/src/pr/ci-publish.ts +0 -2
- package/src/pr/discovery.ts +4 -25
- package/src/pr/plan.ts +40 -121
- package/src/pr/pr-status.ts +14 -2
- package/src/pr/preflight.ts +15 -12
- package/src/pr/publish-outcome.ts +1 -19
- package/src/pr/review-pr.ts +10 -47
- package/src/pr/target.ts +76 -82
- package/src/production-runtime.ts +52 -114
- package/src/progress.ts +0 -54
- package/src/rereview/prepare.ts +4 -1
- package/src/rereview/state.ts +1 -1
- package/src/review/boundary.ts +4 -8
- package/src/review/drafts.ts +3 -3
- package/src/review/findings-conformance.ts +1 -1
- package/src/review/findings.ts +0 -4
- package/src/review/pipeline.ts +57 -395
- package/src/review/preflight.ts +162 -201
- package/src/review/prompt-set.ts +0 -2
- package/src/review/report.ts +2 -162
- package/src/review/review.ts +16 -65
- package/src/review/route-preflight.ts +3 -35
- package/src/review/run.ts +37 -73
- package/src/review/size-gate.ts +3 -3
- package/src/review/spec.ts +6 -11
- package/src/review/step-runner.ts +4 -4
- package/src/runner-authority.ts +10 -9
- package/src/security/credential-broker.ts +5 -6
- package/src/server/preflight.ts +0 -1
- package/src/server/server.ts +17 -6
- package/src/store/activity.ts +1 -2
- package/src/store/backfill-preflight.ts +0 -3
- package/src/store/backfill.ts +0 -1
- package/src/store/metrics-preflight.ts +4 -14
- package/src/store/metrics.ts +5 -5
- package/src/store/preflight.ts +0 -13
- package/src/store/store.ts +11 -12
- package/src/transport-registry.ts +6 -30
- package/src/transports/claude-code-cli.ts +149 -215
- package/src/transports/opencode-client.ts +4 -24
- package/src/transports/opencode-sdk.ts +17 -112
- package/src/triage/plain-reply.ts +37 -0
- package/src/ui/activity.ts +1 -6
- package/src/ui/config-edit.ts +14 -67
- package/src/ui/config.ts +3 -8
- package/src/ui/plan.ts +11 -198
- package/src/ui/progress.ts +3 -49
- package/src/ui/result.ts +18 -77
- package/src/ui/review-menu.ts +3 -12
- package/src/ui/select.ts +9 -79
- package/src/updater.ts +1 -1
- package/src/usage.ts +1 -7
- package/prompts/default/deep-review-parity.md +0 -152
- package/prompts/scout.md +0 -140
- package/src/ci/platform-estimate.ts +0 -111
- package/src/review/scout.ts +0 -323
|
@@ -46,8 +46,8 @@ export interface ToolCall {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// One model call of an agent loop (#511): an OpenCode attempt is dozens of
|
|
49
|
-
// these, one assistant message each, and each message records its own times
|
|
50
|
-
//
|
|
49
|
+
// these, one assistant message each, and each message records its own times
|
|
50
|
+
// and tokens. Token counts are OpenCode's disjoint leaves.
|
|
51
51
|
export interface Turn {
|
|
52
52
|
startMs?: number;
|
|
53
53
|
endMs?: number;
|
|
@@ -60,7 +60,6 @@ export interface Turn {
|
|
|
60
60
|
reasoningTokens?: number;
|
|
61
61
|
cacheReadTokens?: number;
|
|
62
62
|
cacheWriteTokens?: number;
|
|
63
|
-
costUsd?: number;
|
|
64
63
|
// What the turn answered. Content only: withoutContent drops it.
|
|
65
64
|
message?: ChatMessage;
|
|
66
65
|
}
|
|
@@ -454,8 +453,8 @@ function count(value: unknown): number | undefined {
|
|
|
454
453
|
: undefined;
|
|
455
454
|
}
|
|
456
455
|
|
|
457
|
-
// An assistant message's own record: `time.created`/`completed` in epoch ms
|
|
458
|
-
// `tokens` {input, output, reasoning, cache: {read, write}}
|
|
456
|
+
// An assistant message's own record: `time.created`/`completed` in epoch ms
|
|
457
|
+
// and `tokens` {input, output, reasoning, cache: {read, write}}.
|
|
459
458
|
// A message still being written has no `completed` time.
|
|
460
459
|
function openCodeTurn(info: Record<string, unknown>): Turn {
|
|
461
460
|
const time = isRecord(info.time) ? info.time : {};
|
|
@@ -471,7 +470,6 @@ function openCodeTurn(info: Record<string, unknown>): Turn {
|
|
|
471
470
|
["reasoningTokens", count(tokens.reasoning)],
|
|
472
471
|
["cacheReadTokens", count(cache.read)],
|
|
473
472
|
["cacheWriteTokens", count(cache.write)],
|
|
474
|
-
["costUsd", count(info.cost)],
|
|
475
473
|
];
|
|
476
474
|
const turn: Record<string, unknown> = {};
|
|
477
475
|
for (const [key, value] of leaves) if (value !== undefined) turn[key] = value;
|
package/src/ci/trigger.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// The consumer workflow calls the action on `pull_request` and
|
|
5
5
|
// `issue_comment`, and its job `if:` already drops fork pull requests and
|
|
6
|
-
// comments that do not start with `/crysk review
|
|
6
|
+
// comments that do not start with `/crysk review`. This module decides it
|
|
7
7
|
// all again anyway. A workflow is a file the consumer owns and edits, so a
|
|
8
8
|
// prefix filter there is a cost saving, never the security boundary: the
|
|
9
9
|
// command match, the commenter's permission and the credential check all
|
|
@@ -47,8 +47,7 @@ import {
|
|
|
47
47
|
parseCryskSecrets,
|
|
48
48
|
} from "./crysk-secrets";
|
|
49
49
|
|
|
50
|
-
// Commands are written in the
|
|
51
|
-
// also accept the legacy `/pr-hero` spelling for one version.
|
|
50
|
+
// Commands are written in the `/crysk` form, the only one the matchers in ../brand accept.
|
|
52
51
|
export const REVIEW_COMMAND = "/crysk review";
|
|
53
52
|
export const REVIEW_FULL_COMMAND = "/crysk review --full";
|
|
54
53
|
// The review, plus the CI adjudicator's rulings on pending dismissals (docs/github-actions.md,
|
|
@@ -257,8 +256,7 @@ export function parseReviewCommand(
|
|
|
257
256
|
|
|
258
257
|
// A comment that asks for something. Both kinds are permission-gated, so the
|
|
259
258
|
// comment kind (and not the command) decides whether the lookup runs.
|
|
260
|
-
// `text` is what the commenter typed (trimmed)
|
|
261
|
-
// command echoes the spelling they used, `/crysk` or the legacy `/pr-hero`.
|
|
259
|
+
// `text` is what the commenter typed (trimmed).
|
|
262
260
|
type CommentCommand =
|
|
263
261
|
| { kind: "review"; full: boolean; adjudicate: boolean; text: string }
|
|
264
262
|
| { kind: "override"; text: string };
|
package/src/cli.ts
CHANGED
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
HELP_TEXT,
|
|
73
73
|
parseArgs,
|
|
74
74
|
preflightAgentsDir,
|
|
75
|
+
removedFlagWarnings,
|
|
75
76
|
resolveAgentsDir,
|
|
76
77
|
} from "#review/preflight";
|
|
77
78
|
import { CliError, CliUsageError } from "./errors";
|
|
@@ -80,7 +81,6 @@ export { createRunDir, preflightAgentsDir, resolveAgentsDir };
|
|
|
80
81
|
|
|
81
82
|
import {
|
|
82
83
|
type ProductionRoutePlanResult,
|
|
83
|
-
pipelineScoutInput,
|
|
84
84
|
pipelineSummarizerInput,
|
|
85
85
|
resolveProductionRoutePlanAtConfirm,
|
|
86
86
|
resolveRoutePlanAtConfirm,
|
|
@@ -88,7 +88,6 @@ import {
|
|
|
88
88
|
|
|
89
89
|
export {
|
|
90
90
|
type ProductionRoutePlanResult,
|
|
91
|
-
pipelineScoutInput,
|
|
92
91
|
pipelineSummarizerInput,
|
|
93
92
|
resolveProductionRoutePlanAtConfirm,
|
|
94
93
|
resolveRoutePlanAtConfirm,
|
|
@@ -100,7 +99,6 @@ import { gcCommand } from "#store/gc";
|
|
|
100
99
|
import {
|
|
101
100
|
type ConfigProvenance,
|
|
102
101
|
configProvenanceOf,
|
|
103
|
-
dryRunHunterCount,
|
|
104
102
|
type PlanContext,
|
|
105
103
|
type PrPlanContext,
|
|
106
104
|
planDetails,
|
|
@@ -112,7 +110,6 @@ import {
|
|
|
112
110
|
export {
|
|
113
111
|
type ConfigProvenance,
|
|
114
112
|
configProvenanceOf,
|
|
115
|
-
dryRunHunterCount,
|
|
116
113
|
type PlanContext,
|
|
117
114
|
type PrPlanContext,
|
|
118
115
|
planDetails,
|
|
@@ -166,7 +163,6 @@ export async function main(argv: string[]): Promise<number> {
|
|
|
166
163
|
repo: ".",
|
|
167
164
|
head: DEFAULT_HEAD_REF,
|
|
168
165
|
hopBudget: DEFAULT_HOP_BUDGET,
|
|
169
|
-
scout: false,
|
|
170
166
|
full: false,
|
|
171
167
|
dryRun: false,
|
|
172
168
|
yes: false,
|
|
@@ -193,6 +189,11 @@ export async function main(argv: string[]): Promise<number> {
|
|
|
193
189
|
await reportFatalCiErrorIfInJobStep(error);
|
|
194
190
|
return 2;
|
|
195
191
|
}
|
|
192
|
+
// Flags of the removed scout stage are accepted and do nothing; each says so
|
|
193
|
+
// once, whatever the command, before anything runs.
|
|
194
|
+
for (const line of removedFlagWarnings(parsed.options)) {
|
|
195
|
+
log(`warning: ${line}`);
|
|
196
|
+
}
|
|
196
197
|
if (parsed.command === "help") {
|
|
197
198
|
log(HELP_TEXT);
|
|
198
199
|
return 0;
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
// for them when an agent runs it. The answers are plain data (CiSetupChoices);
|
|
3
3
|
// src/ci/review-levels.ts turns them into config keys and workflow inputs.
|
|
4
4
|
|
|
5
|
-
import { CI_DEFAULT_METERED_BUDGET_USD } from "#ci/gates";
|
|
6
5
|
import {
|
|
7
6
|
DEFAULT_CI_ADVISORY_WEIGHT,
|
|
8
7
|
DEFAULT_CI_BLOCKING_WEIGHT,
|
|
9
8
|
} from "#ci/review-admission";
|
|
10
9
|
import {
|
|
11
10
|
type AdvancedChoices,
|
|
12
|
-
type Billing,
|
|
13
11
|
type CiSetupChoices,
|
|
14
12
|
type CurrentSettings,
|
|
15
13
|
DEFAULT_MAX_CHANGED_LINES,
|
|
@@ -46,31 +44,18 @@ export interface SetupPrompter {
|
|
|
46
44
|
export function choicesFromFlags(
|
|
47
45
|
options: Pick<
|
|
48
46
|
CliOptions,
|
|
49
|
-
| "
|
|
50
|
-
| "ciMode"
|
|
51
|
-
| "billing"
|
|
52
|
-
| "budgetUsd"
|
|
53
|
-
| "maxChangedLines"
|
|
54
|
-
| "maxChangedFiles"
|
|
47
|
+
"reviewLevel" | "ciMode" | "maxChangedLines" | "maxChangedFiles"
|
|
55
48
|
>,
|
|
56
49
|
): CiSetupChoices | undefined {
|
|
57
50
|
const given =
|
|
58
51
|
options.reviewLevel !== undefined ||
|
|
59
52
|
options.ciMode !== undefined ||
|
|
60
|
-
options.billing !== undefined ||
|
|
61
|
-
options.budgetUsd !== undefined ||
|
|
62
53
|
options.maxChangedLines !== undefined ||
|
|
63
54
|
options.maxChangedFiles !== undefined;
|
|
64
55
|
if (!given) return undefined;
|
|
65
|
-
const billing: Billing | undefined =
|
|
66
|
-
options.billing ?? (options.budgetUsd !== undefined ? "api" : undefined);
|
|
67
56
|
return {
|
|
68
57
|
level: options.reviewLevel ?? DEFAULT_REVIEW_LEVEL,
|
|
69
58
|
mode: options.ciMode ?? "gate",
|
|
70
|
-
...(billing === undefined ? {} : { billing }),
|
|
71
|
-
...(options.budgetUsd === undefined
|
|
72
|
-
? {}
|
|
73
|
-
: { budgetUsd: options.budgetUsd }),
|
|
74
59
|
maxChangedLines: options.maxChangedLines ?? DEFAULT_MAX_CHANGED_LINES,
|
|
75
60
|
advanced:
|
|
76
61
|
options.maxChangedFiles === undefined
|
|
@@ -82,7 +67,6 @@ export function choicesFromFlags(
|
|
|
82
67
|
level: options.reviewLevel !== undefined,
|
|
83
68
|
maxChangedLines: options.maxChangedLines !== undefined,
|
|
84
69
|
mode: options.ciMode !== undefined,
|
|
85
|
-
billing: billing !== undefined,
|
|
86
70
|
},
|
|
87
71
|
};
|
|
88
72
|
}
|
|
@@ -139,7 +123,6 @@ export async function askChoices(
|
|
|
139
123
|
level: true,
|
|
140
124
|
maxChangedLines: true,
|
|
141
125
|
mode: true,
|
|
142
|
-
billing: true,
|
|
143
126
|
};
|
|
144
127
|
const cfg = current.config;
|
|
145
128
|
|
|
@@ -186,45 +169,9 @@ export async function askChoices(
|
|
|
186
169
|
current.workflow.mode ?? "gate",
|
|
187
170
|
);
|
|
188
171
|
|
|
189
|
-
choices.billing = await prompter.choose<Billing>(
|
|
190
|
-
"How will CI pay for reviews?",
|
|
191
|
-
[
|
|
192
|
-
{
|
|
193
|
-
value: "subscription",
|
|
194
|
-
label: "Claude subscription",
|
|
195
|
-
description:
|
|
196
|
-
"CRYSK_CLAUDE_OAUTH_TOKEN. Reviews spend quota, not dollars.",
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
value: "api",
|
|
200
|
-
label: "API key",
|
|
201
|
-
description:
|
|
202
|
-
"CRYSK_CLAUDE_API_KEY or an OpenCode provider's CRYSK_OPENCODE_* key. Reviews are billed per token.",
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
current.workflow.budgetUsd === undefined ? "subscription" : "api",
|
|
206
|
-
);
|
|
207
|
-
if (choices.billing === "subscription") {
|
|
208
|
-
say(
|
|
209
|
-
` No spend ceiling, and nothing to write: a subscription review spends quota, not dollars, and CI applies no ceiling while the run uses CRYSK_CLAUDE_OAUTH_TOKEN and no OpenCode model with its CRYSK_OPENCODE_* secret. A run on CRYSK_CLAUDE_API_KEY (no subscription set, or api_key first in credentials.claude) or an OpenCode model with its CRYSK_OPENCODE_* secret brings back the $${CI_DEFAULT_METERED_BUDGET_USD} ceiling.`,
|
|
210
|
-
);
|
|
211
|
-
} else {
|
|
212
|
-
choices.budgetUsd = await askValue(
|
|
213
|
-
prompter,
|
|
214
|
-
"Spend ceiling per review in USD (0 = none)",
|
|
215
|
-
current.workflow.budgetUsd ?? String(CI_DEFAULT_METERED_BUDGET_USD),
|
|
216
|
-
(raw) => {
|
|
217
|
-
const n = Number(raw);
|
|
218
|
-
return raw !== "" && Number.isFinite(n) && n >= 0 ? n : undefined;
|
|
219
|
-
},
|
|
220
|
-
say,
|
|
221
|
-
"Enter a number, 0 or more, for example 10 or 7.5.",
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
172
|
say();
|
|
226
173
|
say(
|
|
227
|
-
"Size threshold: a PR with more changed lines than this is skipped, not reviewed. It applies on any
|
|
174
|
+
"Size threshold: a PR with more changed lines than this is skipped, not reviewed. It applies on any route: without it a subscription reviews any size.",
|
|
228
175
|
);
|
|
229
176
|
choices.maxChangedLines = await askValue(
|
|
230
177
|
prompter,
|
package/src/commands/ci-setup.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
opencodeSecretToken,
|
|
8
8
|
} from "#ci/crysk-secrets";
|
|
9
9
|
import {
|
|
10
|
-
budgetInput,
|
|
11
10
|
type CiSetupChoices,
|
|
12
11
|
type CurrentSettings,
|
|
13
12
|
configPlan,
|
|
@@ -302,15 +301,6 @@ async function resolveChoices(
|
|
|
302
301
|
if (!choices.chosen.mode && current.workflow.mode !== undefined) {
|
|
303
302
|
choices.mode = current.workflow.mode;
|
|
304
303
|
}
|
|
305
|
-
const oldBudget = Number(current.workflow.budgetUsd);
|
|
306
|
-
if (
|
|
307
|
-
!choices.chosen.billing &&
|
|
308
|
-
current.workflow.budgetUsd !== undefined &&
|
|
309
|
-
Number.isFinite(oldBudget)
|
|
310
|
-
) {
|
|
311
|
-
choices.billing = "api";
|
|
312
|
-
choices.budgetUsd = oldBudget;
|
|
313
|
-
}
|
|
314
304
|
return choices;
|
|
315
305
|
}
|
|
316
306
|
|
|
@@ -380,7 +370,6 @@ export async function ciSetupCommand(
|
|
|
380
370
|
|
|
381
371
|
const current = await readCurrentSettings(repoRoot, target);
|
|
382
372
|
const choices = await resolveChoices(options, deps, current);
|
|
383
|
-
const budget = budgetInput(choices);
|
|
384
373
|
// The config first: it is the write that can refuse (an invalid existing
|
|
385
374
|
// file, a value the review parser rejects), and refusing before the workflow
|
|
386
375
|
// is written leaves the repository as it was.
|
|
@@ -403,7 +392,6 @@ export async function ciSetupCommand(
|
|
|
403
392
|
force: options.force,
|
|
404
393
|
template: {
|
|
405
394
|
mode: choices.mode,
|
|
406
|
-
...(budget === undefined ? {} : { budgetUsd: budget }),
|
|
407
395
|
// Size inputs a person set by hand in the old workflow. setup never
|
|
408
396
|
// writes them (it writes the config keys), so a refresh carries them
|
|
409
397
|
// over; the action gives a workflow input precedence over the config.
|
|
@@ -467,21 +455,9 @@ export async function ciSetupCommand(
|
|
|
467
455
|
log(`${next()} Commit ${workflowRelative} and ${repoDirName}/config.json`);
|
|
468
456
|
// The CRYSK_* names the scaffolded workflow reads (S8); gh asks for the value.
|
|
469
457
|
log(
|
|
470
|
-
`${next()} Add a repository secret:
|
|
471
|
-
choices.billing === "subscription"
|
|
472
|
-
? "CRYSK_CLAUDE_OAUTH_TOKEN (create the value with `claude setup-token`)"
|
|
473
|
-
: choices.billing === "api"
|
|
474
|
-
? "CRYSK_CLAUDE_API_KEY (or the CRYSK_OPENCODE_* key of the OpenCode provider your models use)"
|
|
475
|
-
: "CRYSK_CLAUDE_OAUTH_TOKEN (create the value with `claude setup-token`) or CRYSK_CLAUDE_API_KEY"
|
|
476
|
-
}`,
|
|
477
|
-
);
|
|
478
|
-
log(
|
|
479
|
-
` $ gh secret set ${
|
|
480
|
-
choices.billing === "api"
|
|
481
|
-
? "CRYSK_CLAUDE_API_KEY"
|
|
482
|
-
: "CRYSK_CLAUDE_OAUTH_TOKEN"
|
|
483
|
-
}`,
|
|
458
|
+
`${next()} Add a repository secret: CRYSK_CLAUDE_OAUTH_TOKEN (create the value with \`claude setup-token\`) or CRYSK_CLAUDE_API_KEY`,
|
|
484
459
|
);
|
|
460
|
+
log(" $ gh secret set CRYSK_CLAUDE_OAUTH_TOKEN");
|
|
485
461
|
if (variables.openCodeTokens.length > 0) {
|
|
486
462
|
log(
|
|
487
463
|
`${next()} Add the API key of each OpenCode provider your models in ${variables.configLabel} use:`,
|
package/src/commands/triage.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { assertRunMatchesPr } from "#ci/gates";
|
|
|
5
5
|
import { resolveRepoRoot } from "#git/git";
|
|
6
6
|
import {
|
|
7
7
|
fetchPostedFindingComments,
|
|
8
|
+
fetchPrComments,
|
|
8
9
|
fetchPrReviewComments,
|
|
9
10
|
ghCurrentBranchPr,
|
|
10
11
|
ghPrWebUrl,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
postReviewCommentReply,
|
|
15
16
|
resolveReviewThreadForComment,
|
|
16
17
|
} from "#pr/pr";
|
|
18
|
+
import { buildPrStatus } from "#pr/pr-status";
|
|
17
19
|
import { resolveCurrentPrNumber } from "#pr/preflight";
|
|
18
20
|
import { validateFindingsDocument } from "#review/findings";
|
|
19
21
|
import type { CliOptions } from "#review/preflight";
|
|
@@ -37,7 +39,7 @@ import { CliError, CliUsageError } from "../errors";
|
|
|
37
39
|
import { tryOriginRepoId } from "../home";
|
|
38
40
|
import { prheroLayout } from "../home-preflight";
|
|
39
41
|
|
|
40
|
-
// `
|
|
42
|
+
// `crysk triage reply --pr <n> [--from <run-dir>] --finding <id> ...`: the
|
|
41
43
|
// only triage verb. It posts one triage reply, records the verdict in the
|
|
42
44
|
// product store, and resolves the thread. The bare `triage --pr --from` verb
|
|
43
45
|
// that bound verdicts into comparison.json is retired: new
|
|
@@ -60,9 +62,6 @@ export async function triageCommand(options: CliOptions): Promise<number> {
|
|
|
60
62
|
if (options.pr === undefined) {
|
|
61
63
|
throw new CliUsageError("triage requires --pr <n>");
|
|
62
64
|
}
|
|
63
|
-
if (options.from === undefined) {
|
|
64
|
-
throw new CliUsageError("triage requires --from <run-dir>");
|
|
65
|
-
}
|
|
66
65
|
const prNumber =
|
|
67
66
|
options.pr === "current"
|
|
68
67
|
? resolveCurrentPrNumber(await ghCurrentBranchPr(operatorRoot))
|
|
@@ -111,20 +110,86 @@ async function outsidePullUrl(
|
|
|
111
110
|
return `${host}/${nameWithOwner}/pull/${prNumber}`;
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
|
|
113
|
+
// triage-without-skill S2: the finding a reply answers, read off the PR alone. The summary's state block
|
|
114
|
+
// names the id, the posted finding comment carries the head it was posted on, and the join is the one
|
|
115
|
+
// `crysk status --pr` makes (pr/pr-status.ts), so an agent with no run directory replies by id.
|
|
116
|
+
async function postedFindingFromPr(
|
|
117
|
+
operatorRoot: string,
|
|
118
|
+
prNumber: number,
|
|
119
|
+
findingId: string,
|
|
120
|
+
spawnFn: typeof Bun.spawn | undefined,
|
|
121
|
+
): Promise<{
|
|
122
|
+
parent: { id: number; channel: "review" | "issue" };
|
|
123
|
+
headSha: string;
|
|
124
|
+
}> {
|
|
125
|
+
const issueComments = await fetchPrComments(operatorRoot, prNumber, {
|
|
126
|
+
spawnFn,
|
|
127
|
+
});
|
|
128
|
+
const reviewComments = await fetchPrReviewComments(operatorRoot, prNumber, {
|
|
129
|
+
spawnFn,
|
|
130
|
+
});
|
|
131
|
+
const status = buildPrStatus({
|
|
132
|
+
pr: prNumber,
|
|
133
|
+
head: "",
|
|
134
|
+
nowMs: Date.now(),
|
|
135
|
+
statuses: [],
|
|
136
|
+
issueComments,
|
|
137
|
+
reviewComments,
|
|
138
|
+
adjudicatorTrust: { kind: "local" },
|
|
139
|
+
});
|
|
140
|
+
const finding = status.findings.find((row) => row.id === findingId);
|
|
141
|
+
if (finding === undefined) {
|
|
142
|
+
throw new CliUsageError(
|
|
143
|
+
`PR #${prNumber} has no posted finding ${findingId}: run ` +
|
|
144
|
+
`\`crysk status --pr ${prNumber} --json\` for its R### ids, or pass --from <run-dir> for an F### id`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (finding.comment_id === null || finding.head === null) {
|
|
148
|
+
throw new CliError(
|
|
149
|
+
`${findingId} on PR #${prNumber} has no comment thread to reply to ` +
|
|
150
|
+
"(it lives only in the summary)",
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
parent: {
|
|
155
|
+
id: finding.comment_id,
|
|
156
|
+
channel: finding.channel === "inline" ? "review" : "issue",
|
|
157
|
+
},
|
|
158
|
+
headSha: finding.head,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function readReasoning(bodyFile: string): Promise<string> {
|
|
163
|
+
const bodyPath = path.resolve(bodyFile);
|
|
164
|
+
if (!existsSync(bodyPath)) {
|
|
165
|
+
throw new CliUsageError(`--body-file not found: ${bodyPath}`);
|
|
166
|
+
}
|
|
167
|
+
const reasoning = await Bun.file(bodyPath).text();
|
|
168
|
+
if (matchMarkerPrefix(reasoning, TRIAGE_MARKER_PREFIX) !== undefined) {
|
|
169
|
+
throw new CliUsageError(
|
|
170
|
+
"--body-file must be reasoning prose only — the driver prepends the " +
|
|
171
|
+
"triage marker and badge (do not start the file with " +
|
|
172
|
+
"`<!-- crysk-triage`)",
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return reasoning;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// The posted finding a reply binds to and the head its marker names, read from a completed run
|
|
179
|
+
// directory: the finding row by id, matched to its posted comment by marker.
|
|
180
|
+
async function postedFindingFromRunDir(input: {
|
|
115
181
|
operatorRoot: string;
|
|
116
|
-
|
|
117
|
-
|
|
182
|
+
prNumber: number;
|
|
183
|
+
runDir: string;
|
|
118
184
|
findingId: string;
|
|
119
|
-
tag: TriageTag;
|
|
120
185
|
bodyFile: string;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const runDir =
|
|
186
|
+
spawnFn: typeof Bun.spawn | undefined;
|
|
187
|
+
}): Promise<{
|
|
188
|
+
parent: { id: number; channel: "review" | "issue" };
|
|
189
|
+
headSha: string;
|
|
190
|
+
reasoning: string;
|
|
191
|
+
}> {
|
|
192
|
+
const { operatorRoot, prNumber, runDir, spawnFn } = input;
|
|
128
193
|
const findingsPath = path.join(runDir, "findings.json");
|
|
129
194
|
if (!existsSync(findingsPath)) {
|
|
130
195
|
throw new CliUsageError(
|
|
@@ -142,18 +207,7 @@ export async function runTriageReplyCommand(input: {
|
|
|
142
207
|
`${findingsPath} has no finding ${input.findingId}`,
|
|
143
208
|
);
|
|
144
209
|
}
|
|
145
|
-
const
|
|
146
|
-
if (!existsSync(bodyPath)) {
|
|
147
|
-
throw new CliUsageError(`--body-file not found: ${bodyPath}`);
|
|
148
|
-
}
|
|
149
|
-
const reasoning = await Bun.file(bodyPath).text();
|
|
150
|
-
if (matchMarkerPrefix(reasoning, TRIAGE_MARKER_PREFIX) !== undefined) {
|
|
151
|
-
throw new CliUsageError(
|
|
152
|
-
"--body-file must be reasoning prose only — the driver prepends the " +
|
|
153
|
-
"triage marker and badge (do not start the file with " +
|
|
154
|
-
"`<!-- crysk-triage`)",
|
|
155
|
-
);
|
|
156
|
-
}
|
|
210
|
+
const reasoning = await readReasoning(input.bodyFile);
|
|
157
211
|
// anchor.patch first, as in post --from: the diff the finding's line is
|
|
158
212
|
// matched against must be the one inline comments anchor on.
|
|
159
213
|
const anchorPath = path.join(runDir, "anchor.patch");
|
|
@@ -174,14 +228,6 @@ export async function runTriageReplyCommand(input: {
|
|
|
174
228
|
proof_refs: finding.proof_refs,
|
|
175
229
|
diffPatch,
|
|
176
230
|
});
|
|
177
|
-
const fields: TriageMarkerFields = {
|
|
178
|
-
tag: input.tag,
|
|
179
|
-
headSha: doc.head_sha,
|
|
180
|
-
actor: "agent",
|
|
181
|
-
verdict: input.verdict,
|
|
182
|
-
issue: input.issue,
|
|
183
|
-
};
|
|
184
|
-
const body = renderTriageReplyBody(fields, reasoning);
|
|
185
231
|
const posted = await fetchPostedFindingComments(operatorRoot, prNumber, {
|
|
186
232
|
spawnFn,
|
|
187
233
|
});
|
|
@@ -208,13 +254,59 @@ export async function runTriageReplyCommand(input: {
|
|
|
208
254
|
`(ids ${match.ids.join(", ")}) — will not pick by proximity`,
|
|
209
255
|
);
|
|
210
256
|
}
|
|
211
|
-
|
|
257
|
+
return { parent: match.posted, headSha: doc.head_sha, reasoning };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export async function runTriageReplyCommand(input: {
|
|
261
|
+
operatorRoot: string;
|
|
262
|
+
pr: number;
|
|
263
|
+
// A completed run directory, or undefined to read the finding off the PR (S2).
|
|
264
|
+
from?: string;
|
|
265
|
+
findingId: string;
|
|
266
|
+
tag: TriageTag;
|
|
267
|
+
bodyFile: string;
|
|
268
|
+
verdict?: TriageVerdict;
|
|
269
|
+
issue?: number;
|
|
270
|
+
dryRun: boolean;
|
|
271
|
+
spawnFn?: typeof Bun.spawn;
|
|
272
|
+
}): Promise<number> {
|
|
273
|
+
const { operatorRoot, pr: prNumber, dryRun, spawnFn } = input;
|
|
274
|
+
const runDir =
|
|
275
|
+
input.from === undefined ? undefined : path.resolve(input.from);
|
|
276
|
+
const target =
|
|
277
|
+
runDir === undefined
|
|
278
|
+
? {
|
|
279
|
+
...(await postedFindingFromPr(
|
|
280
|
+
operatorRoot,
|
|
281
|
+
prNumber,
|
|
282
|
+
input.findingId,
|
|
283
|
+
spawnFn,
|
|
284
|
+
)),
|
|
285
|
+
reasoning: await readReasoning(input.bodyFile),
|
|
286
|
+
}
|
|
287
|
+
: await postedFindingFromRunDir({
|
|
288
|
+
operatorRoot,
|
|
289
|
+
prNumber,
|
|
290
|
+
runDir,
|
|
291
|
+
findingId: input.findingId,
|
|
292
|
+
bodyFile: input.bodyFile,
|
|
293
|
+
spawnFn,
|
|
294
|
+
});
|
|
295
|
+
const { parent, headSha, reasoning } = target;
|
|
296
|
+
const fields: TriageMarkerFields = {
|
|
297
|
+
tag: input.tag,
|
|
298
|
+
headSha,
|
|
299
|
+
actor: "agent",
|
|
300
|
+
verdict: input.verdict,
|
|
301
|
+
issue: input.issue,
|
|
302
|
+
};
|
|
303
|
+
const body = renderTriageReplyBody(fields, reasoning);
|
|
212
304
|
const reviewComments = await fetchPrReviewComments(operatorRoot, prNumber, {
|
|
213
305
|
spawnFn,
|
|
214
306
|
});
|
|
215
307
|
const already = existingTriageAtHead({
|
|
216
308
|
parentId: parent.id,
|
|
217
|
-
headSha
|
|
309
|
+
headSha,
|
|
218
310
|
replies: reviewComments,
|
|
219
311
|
});
|
|
220
312
|
const resolveDecision = decideThreadResolve({
|
|
@@ -273,7 +365,8 @@ export async function runTriageReplyCommand(input: {
|
|
|
273
365
|
// Persist triage record to canonical product store (idempotent upsert)
|
|
274
366
|
try {
|
|
275
367
|
const layout = prheroLayout(os.homedir());
|
|
276
|
-
|
|
368
|
+
// A reply read off the PR has no run to record against.
|
|
369
|
+
if (runDir !== undefined && existsSync(layout.prheroDbPath)) {
|
|
277
370
|
const repoId = await tryOriginRepoId(operatorRoot);
|
|
278
371
|
if (repoId) {
|
|
279
372
|
const db = openProductStore(layout.prheroDbPath);
|
package/src/commands/usage.ts
CHANGED
package/src/compare/compare.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Shared location rules for pr-hero findings: how a repo path is normalized and
|
|
2
2
|
// how wide the line window is when a finding is said to sit "near" a location.
|
|
3
|
-
// Re-review identity,
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// Re-review identity, the CI review-risk path set and the floor-test case gate
|
|
4
|
+
// all compare paths through `normalizePath`; the floor-test case gate uses
|
|
5
|
+
// `DEFAULT_LINE_WINDOW`.
|
|
6
6
|
//
|
|
7
7
|
// Pure: no I/O, no clock.
|
|
8
8
|
|