crysk 0.5.1 → 0.6.1
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 +15 -1
- package/dist/SKILL-nncgwkx7.md +553 -0
- package/dist/cli.js +6379 -5561
- package/dist/index.js +967 -467
- package/dist/workflow-ag62s87j.yml +163 -0
- package/package.json +3 -2
- package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
- package/skills/crysk-loop/SKILL.md +2 -2
- package/src/asset-manifest.ts +11 -0
- package/src/assets.ts +34 -11
- package/src/ci/credential-refresh.ts +524 -0
- package/src/ci/crysk-secrets.ts +20 -6
- package/src/ci/gates.ts +2 -24
- package/src/ci/outcome.ts +165 -15
- package/src/ci/platform.ts +205 -7
- package/src/ci/setup.ts +64 -6
- package/src/ci/trigger.ts +84 -8
- package/src/commands/ci-setup.ts +12 -3
- package/src/commands/doctor.ts +25 -23
- package/src/commands/status.ts +2 -0
- package/src/diversity/identity.ts +11 -1
- package/src/diversity/pipeline-integration.ts +19 -6
- package/src/doctor.ts +133 -4
- package/src/execution/contracts.ts +15 -3
- package/src/harness/materiality-judge.ts +153 -0
- package/src/harness/pipeline-plan.ts +133 -0
- package/src/harness/replay-rows.ts +172 -0
- package/src/harness/route-runner.ts +288 -0
- package/src/harness/single-step.ts +153 -0
- package/src/index.ts +1 -1
- package/src/model/catalog.ts +10 -7
- package/src/model/model-name.ts +14 -0
- package/src/model/profiles/claude.ts +34 -0
- package/src/model/profiles/openai.ts +44 -0
- package/src/model/profiles.ts +213 -0
- package/src/model/routing.ts +155 -50
- package/src/pr/answered-findings.ts +3 -0
- package/src/pr/ci-admission-gate.ts +1 -0
- package/src/pr/discovery.ts +1 -0
- package/src/pr/plan.ts +6 -1
- package/src/pr/pr-status.ts +18 -3
- package/src/pr/publish-outcome.ts +14 -13
- package/src/pr/review-pr.ts +49 -8
- package/src/pr/target.ts +16 -7
- package/src/production-runtime.ts +100 -13
- package/src/rereview/prepare.ts +13 -2
- package/src/review/exit-code.ts +60 -0
- package/src/review/findings.ts +3 -3
- package/src/review/pipeline.ts +193 -58
- package/src/review/preflight.ts +100 -10
- package/src/review/prompt-set.ts +73 -0
- package/src/review/review.ts +32 -13
- package/src/review/route-preflight.ts +117 -67
- package/src/review/run.ts +34 -4
- package/src/security/credential-broker.ts +21 -9
- package/src/security/oauth-providers.ts +101 -0
- package/src/transport-registry.ts +33 -0
- package/src/transports/opencode-sdk.ts +33 -1
- package/src/triage/adjudication.ts +35 -2
- package/src/ui/config-edit.ts +9 -0
- package/src/ui/config.ts +1 -0
- package/src/ui/menu.ts +9 -2
- package/src/ui/result.ts +1 -1
- package/src/updater.ts +21 -13
- package/src/watch/preflight.ts +34 -8
- package/src/watch/watch.ts +8 -4
- package/src/wizard.ts +23 -0
package/src/ci/setup.ts
CHANGED
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
CREDENTIALS_INPUT_LINE,
|
|
52
52
|
type ErrorClass,
|
|
53
53
|
MODELS_INPUT_LINE,
|
|
54
|
+
PROFILE_INPUT_LINE,
|
|
54
55
|
type SetupRecord,
|
|
55
56
|
} from "#ci/outcome";
|
|
56
57
|
import { appendGithubOutput } from "#ci/platform";
|
|
@@ -74,6 +75,7 @@ import {
|
|
|
74
75
|
parseModelName,
|
|
75
76
|
parseModelsConfig,
|
|
76
77
|
} from "#model/model-name";
|
|
78
|
+
import { MODEL_PROFILES, profileModels } from "#model/profiles";
|
|
77
79
|
import { parseGlobalConfig, parseLocalConfig } from "#review/preflight";
|
|
78
80
|
import { commandForms } from "../brand";
|
|
79
81
|
import {
|
|
@@ -281,7 +283,10 @@ ${lines}
|
|
|
281
283
|
# repository variables. Unset, every role runs the default Claude model
|
|
282
284
|
# and the subscription is tried first.
|
|
283
285
|
${MODELS_INPUT_LINE}
|
|
284
|
-
${CREDENTIALS_INPUT_LINE}
|
|
286
|
+
${CREDENTIALS_INPUT_LINE}
|
|
287
|
+
# The model profile (claude or openai) from a repository variable.
|
|
288
|
+
# Unset, the claude profile. models still wins role by role.
|
|
289
|
+
${PROFILE_INPUT_LINE}`;
|
|
285
290
|
}
|
|
286
291
|
|
|
287
292
|
export function generateCiWorkflowTemplate(
|
|
@@ -749,6 +754,9 @@ export interface MaterializeCiOpenCodeDataOptions {
|
|
|
749
754
|
// unless a platform person layer exists, which wins whole.
|
|
750
755
|
modelsInput?: string;
|
|
751
756
|
credentialsInput?: string;
|
|
757
|
+
// The `profile` input (openai-profile S6), a profile id from
|
|
758
|
+
// vars.CRYSK_PROFILE, written beside them. The platform's layer wins whole.
|
|
759
|
+
profileInput?: string;
|
|
752
760
|
home?: string;
|
|
753
761
|
env?: Readonly<Record<string, string | undefined>>;
|
|
754
762
|
// Platform mode: the person layer the Crysk platform returned (`{}` when it
|
|
@@ -796,8 +804,12 @@ const INPUT_CLASS: Record<"models" | "credentials", ErrorClass> = {
|
|
|
796
804
|
models: { kind: "config-parse", source: "models-input" },
|
|
797
805
|
credentials: { kind: "config-parse", source: "credentials-input" },
|
|
798
806
|
};
|
|
807
|
+
const PROFILE_INPUT_CLASS: ErrorClass = {
|
|
808
|
+
kind: "config-parse",
|
|
809
|
+
source: "profile-input",
|
|
810
|
+
};
|
|
799
811
|
const INPUTS_IGNORED_WARNING =
|
|
800
|
-
"The models and
|
|
812
|
+
"The models, credentials and profile inputs are ignored: this repository is connected to the Crysk platform, whose model settings apply.";
|
|
801
813
|
|
|
802
814
|
// A crysk-secrets, models or credentials input the user configured wrongly. `message` is the
|
|
803
815
|
// line stderr has always printed; `cls` and `detail` are what the record carries.
|
|
@@ -853,6 +865,30 @@ export function openCodeProvidersOfModels(models: unknown): string[] {
|
|
|
853
865
|
return [...providers].sort();
|
|
854
866
|
}
|
|
855
867
|
|
|
868
|
+
// The OpenCode providers the person layer's routing runs on (openai-profile
|
|
869
|
+
// S6): its models', plus, for the roles `models` does not set (no `default`),
|
|
870
|
+
// its `profile`'s. A profile the parser refused never reaches here.
|
|
871
|
+
export function openCodeProvidersOfPerson(person: {
|
|
872
|
+
models?: unknown;
|
|
873
|
+
profile?: unknown;
|
|
874
|
+
}): string[] {
|
|
875
|
+
const providers = new Set(openCodeProvidersOfModels(person.models));
|
|
876
|
+
const models = person.models as Record<string, unknown> | undefined;
|
|
877
|
+
const coversEveryRole = models !== undefined && models.default !== undefined;
|
|
878
|
+
const profile =
|
|
879
|
+
typeof person.profile === "string" &&
|
|
880
|
+
Object.hasOwn(MODEL_PROFILES, person.profile)
|
|
881
|
+
? MODEL_PROFILES[person.profile]
|
|
882
|
+
: undefined;
|
|
883
|
+
if (!coversEveryRole && profile !== undefined) {
|
|
884
|
+
for (const model of profileModels(profile)) {
|
|
885
|
+
const parsed = parseModelName(model);
|
|
886
|
+
if (parsed.backend === "opencode") providers.add(parsed.provider);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return [...providers].sort();
|
|
890
|
+
}
|
|
891
|
+
|
|
856
892
|
// Whether an OpenCode route this run takes bills per token (cryskai/platform#12
|
|
857
893
|
// item 5): an auth file exists AND some OpenCode provider among the run's
|
|
858
894
|
// resolved routes, any step or fallback, binds an API key, by the same rule the
|
|
@@ -953,6 +989,23 @@ function assembleOpenCodeAuth(
|
|
|
953
989
|
return { records, manifest, notices, problems };
|
|
954
990
|
}
|
|
955
991
|
|
|
992
|
+
// The `profile` input: a bare id, not JSON, checked by the person parser like
|
|
993
|
+
// the key in ~/.crysk/config.json. Returns undefined for an empty input.
|
|
994
|
+
function readProfileInput(raw: string | undefined): string | undefined {
|
|
995
|
+
if (raw === undefined || raw.trim() === "") return undefined;
|
|
996
|
+
const profile = raw.trim();
|
|
997
|
+
try {
|
|
998
|
+
parseGlobalConfig(JSON.stringify({ profile }), "the profile input");
|
|
999
|
+
} catch (error) {
|
|
1000
|
+
throw new SetupInputError(
|
|
1001
|
+
PROFILE_INPUT_CLASS,
|
|
1002
|
+
"the profile input is not a known profile (the setup step's log names the known ones)",
|
|
1003
|
+
messageOf(error),
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
return profile;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
956
1009
|
// One of the two inputs (D1), read the way the person parser reads that key in
|
|
957
1010
|
// ~/.crysk/config.json: the value is the key's own object, checked under that
|
|
958
1011
|
// key alone. Returns undefined for an empty input.
|
|
@@ -1024,9 +1077,11 @@ export async function materializeCiOpenCodeData(
|
|
|
1024
1077
|
personBody = { ...platformPerson };
|
|
1025
1078
|
// The inputs are not even read: a value the platform overrides is not this
|
|
1026
1079
|
// run's configuration, so a malformed one must not fail it.
|
|
1027
|
-
const inputGiven = [
|
|
1028
|
-
|
|
1029
|
-
|
|
1080
|
+
const inputGiven = [
|
|
1081
|
+
options.modelsInput,
|
|
1082
|
+
options.credentialsInput,
|
|
1083
|
+
options.profileInput,
|
|
1084
|
+
].some((raw) => raw !== undefined && raw.trim() !== "");
|
|
1030
1085
|
if (inputGiven) warnings.push(INPUTS_IGNORED_WARNING);
|
|
1031
1086
|
} else {
|
|
1032
1087
|
const models = readConfigInput(options.modelsInput, "models");
|
|
@@ -1034,13 +1089,15 @@ export async function materializeCiOpenCodeData(
|
|
|
1034
1089
|
options.credentialsInput,
|
|
1035
1090
|
"credentials",
|
|
1036
1091
|
);
|
|
1092
|
+
const profile = readProfileInput(options.profileInput);
|
|
1037
1093
|
personBody = {
|
|
1038
1094
|
...(models === undefined ? {} : { models }),
|
|
1039
1095
|
...(credentials === undefined ? {} : { credentials }),
|
|
1096
|
+
...(profile === undefined ? {} : { profile }),
|
|
1040
1097
|
};
|
|
1041
1098
|
}
|
|
1042
1099
|
|
|
1043
|
-
const providers =
|
|
1100
|
+
const providers = openCodeProvidersOfPerson(personBody);
|
|
1044
1101
|
const notices: string[] = [];
|
|
1045
1102
|
const assembly =
|
|
1046
1103
|
options.cryskSecrets === undefined
|
|
@@ -1226,6 +1283,7 @@ async function runCiOpenCodeSetup(deps: CiOpenCodeSetupDeps): Promise<number> {
|
|
|
1226
1283
|
env: deps.env,
|
|
1227
1284
|
modelsInput: deps.env.MODELS_INPUT ?? "",
|
|
1228
1285
|
credentialsInput: deps.env.CREDENTIALS_INPUT ?? "",
|
|
1286
|
+
profileInput: deps.env.PROFILE_INPUT ?? "",
|
|
1229
1287
|
...(platformMode ? { platformPerson: platform?.person ?? {} } : {}),
|
|
1230
1288
|
...(cryskSecrets === undefined ? {} : { cryskSecrets }),
|
|
1231
1289
|
});
|
package/src/ci/trigger.ts
CHANGED
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
// ignored comment costs seconds instead of a dependency install. A package
|
|
20
20
|
// import has no node_modules to resolve against yet, and a `#...` alias is no
|
|
21
21
|
// better: it resolves to a src module whose own imports reach packages. Keep
|
|
22
|
-
// every import here `node:` or `bun`, plus the import-free ../brand
|
|
23
|
-
// ./crysk-secrets (the CRYSK_* grammar, kept import-free for this step)
|
|
22
|
+
// every import here `node:` or `bun`, plus the import-free ../brand,
|
|
23
|
+
// ./crysk-secrets (the CRYSK_* grammar, kept import-free for this step) and the
|
|
24
|
+
// profile registry ../model/profiles.
|
|
24
25
|
|
|
25
26
|
import { randomBytes } from "node:crypto";
|
|
26
27
|
import {
|
|
@@ -33,6 +34,10 @@ import {
|
|
|
33
34
|
} from "node:fs";
|
|
34
35
|
import path from "node:path";
|
|
35
36
|
import { commandHint, isCommand, startsWithCommand } from "../brand";
|
|
37
|
+
// The profile registry: data modules with no runtime imports of their own
|
|
38
|
+
// (test/architecture/profile-registry.test.ts), so the builtins-only rule
|
|
39
|
+
// still holds.
|
|
40
|
+
import { profileRunsOnlyOnOpenCode } from "../model/profiles";
|
|
36
41
|
import {
|
|
37
42
|
type CryskSecretsParse,
|
|
38
43
|
cryskSecretsCarryCredential,
|
|
@@ -201,8 +206,20 @@ export interface CiTriggerInput {
|
|
|
201
206
|
// EVENT_COMMENT_ID when it is all digits: the comment that triggered the run,
|
|
202
207
|
// which the reaction names. Absent for any other event, or any other value.
|
|
203
208
|
commentId?: string;
|
|
209
|
+
// The command a Crysk platform dispatched (odd/tasks/platform-commands.md in the platform
|
|
210
|
+
// repo, S2-S4). A platform-managed repository has no issue_comment trigger, so the platform
|
|
211
|
+
// checks the comment and its author's permission and names the command in its token exchange
|
|
212
|
+
// (src/ci/platform.ts). Read only on a workflow_dispatch, and only from the Connect step's
|
|
213
|
+
// outputs, never from a dispatch input, which anyone with write access can set by hand.
|
|
214
|
+
platformCommand?: PlatformCommand;
|
|
204
215
|
}
|
|
205
216
|
|
|
217
|
+
export type PlatformCommand =
|
|
218
|
+
| { kind: "recheck" }
|
|
219
|
+
| { kind: "override"; actor: string; headSha: string }
|
|
220
|
+
// An override the platform named without a usable actor or head: refused, never recorded.
|
|
221
|
+
| { kind: "malformed-override" };
|
|
222
|
+
|
|
206
223
|
export type CiTriggerDecision =
|
|
207
224
|
| { kind: "review"; force: boolean; full: boolean; adjudicate: boolean }
|
|
208
225
|
// A human's override: no CLI run, $0. `actor` is the login that unlocked the gate.
|
|
@@ -429,6 +446,21 @@ export function decideCiTrigger(input: CiTriggerInput): CiTriggerDecision {
|
|
|
429
446
|
const event = classifyEvent(input);
|
|
430
447
|
if (event.kind === "ignore") return event;
|
|
431
448
|
|
|
449
|
+
// WHY no permission lookup: the platform looked up the commenter's permission before it
|
|
450
|
+
// dispatched, and the dispatch carries no comment to look one up for.
|
|
451
|
+
const platform = event.kind === "event" ? input.platformCommand : undefined;
|
|
452
|
+
if (platform?.kind === "malformed-override") {
|
|
453
|
+
return {
|
|
454
|
+
kind: "denied",
|
|
455
|
+
reason:
|
|
456
|
+
"The Crysk platform asked for an override without a valid login or head, so " +
|
|
457
|
+
"nothing was recorded.",
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
if (platform?.kind === "override") {
|
|
461
|
+
return overrideDecision({ ...input, commenterLogin: platform.actor });
|
|
462
|
+
}
|
|
463
|
+
|
|
432
464
|
if (event.kind === "comment") {
|
|
433
465
|
const verdict = commenterVerdict(input, event.command);
|
|
434
466
|
if (verdict !== undefined) return verdict;
|
|
@@ -470,12 +502,13 @@ export function decideCiTrigger(input: CiTriggerInput): CiTriggerDecision {
|
|
|
470
502
|
event.command.kind === "review" &&
|
|
471
503
|
event.command.full;
|
|
472
504
|
const commentAdjudicate =
|
|
473
|
-
event.kind === "comment" &&
|
|
474
|
-
|
|
475
|
-
|
|
505
|
+
(event.kind === "comment" &&
|
|
506
|
+
event.command.kind === "review" &&
|
|
507
|
+
event.command.adjudicate) ||
|
|
508
|
+
platform?.kind === "recheck";
|
|
476
509
|
return {
|
|
477
510
|
kind: "review",
|
|
478
|
-
force: input.forceInput || fromComment,
|
|
511
|
+
force: input.forceInput || fromComment || platform?.kind === "recheck",
|
|
479
512
|
full: input.fullInput || commentFull,
|
|
480
513
|
adjudicate: commentAdjudicate,
|
|
481
514
|
};
|
|
@@ -868,9 +901,20 @@ function lookupClass(decision: {
|
|
|
868
901
|
|
|
869
902
|
// The route the run would have used. The trigger has no models text, only
|
|
870
903
|
// whether the models in effect name OpenCode: the platform's, or else the
|
|
871
|
-
// `models` input's (action.yml's HAS_OPENCODE_ROUTING, D1).
|
|
904
|
+
// `models` input's (action.yml's HAS_OPENCODE_ROUTING, D1). With no platform
|
|
905
|
+
// answer, a `profile` input whose every route is OpenCode names OpenCode too,
|
|
906
|
+
// unless a `models` default sends every role elsewhere (STANDALONE_*).
|
|
872
907
|
function backendOf(deps: CiTriggerDeps): string {
|
|
873
|
-
|
|
908
|
+
if (deps.env.HAS_OPENCODE_ROUTING === "true") return "opencode";
|
|
909
|
+
// The platform answered (its person layer wins whole): the input is ignored.
|
|
910
|
+
if ((deps.env.PLATFORM_ROUTING_OPENCODE ?? "") !== "") return "claude";
|
|
911
|
+
if (
|
|
912
|
+
deps.env.STANDALONE_MODELS_DEFAULT !== "true" &&
|
|
913
|
+
profileRunsOnlyOnOpenCode(deps.env.STANDALONE_PROFILE)
|
|
914
|
+
) {
|
|
915
|
+
return "opencode";
|
|
916
|
+
}
|
|
917
|
+
return "claude";
|
|
874
918
|
}
|
|
875
919
|
|
|
876
920
|
// The run's PR number, or why there is none. `malformed` is kept apart from a
|
|
@@ -936,9 +980,27 @@ function readTriggerInput(
|
|
|
936
980
|
fullInput: flag("FULL_INPUT"),
|
|
937
981
|
...(runAttempt === undefined ? {} : { runAttempt }),
|
|
938
982
|
...(commentId === undefined ? {} : { commentId }),
|
|
983
|
+
...platformCommandOf(text),
|
|
939
984
|
};
|
|
940
985
|
}
|
|
941
986
|
|
|
987
|
+
// PLATFORM_COMMAND* are bound in action.yml only from the Connect step's outputs, and that step
|
|
988
|
+
// runs only on a workflow_dispatch with a dispatch id. An unknown command is no command.
|
|
989
|
+
function platformCommandOf(text: (name: string) => string): {
|
|
990
|
+
platformCommand?: PlatformCommand;
|
|
991
|
+
} {
|
|
992
|
+
if (text("EVENT_NAME") !== "workflow_dispatch") return {};
|
|
993
|
+
const command = text("PLATFORM_COMMAND");
|
|
994
|
+
if (command === "recheck") return { platformCommand: { kind: "recheck" } };
|
|
995
|
+
if (command !== "override") return {};
|
|
996
|
+
const actor = text("PLATFORM_COMMAND_ACTOR");
|
|
997
|
+
const headSha = validSha(text("PLATFORM_COMMAND_HEAD"));
|
|
998
|
+
if (!GITHUB_LOGIN.test(actor) || headSha === undefined) {
|
|
999
|
+
return { platformCommand: { kind: "malformed-override" } };
|
|
1000
|
+
}
|
|
1001
|
+
return { platformCommand: { kind: "override", actor, headSha } };
|
|
1002
|
+
}
|
|
1003
|
+
|
|
942
1004
|
// The reaction a comment earns. Best effort: it runs only on an issue_comment with an
|
|
943
1005
|
// id, and a failure prints one warning. It never changes the decision or the exit code,
|
|
944
1006
|
// because the reaction is a courtesy and the decision is the product.
|
|
@@ -1123,6 +1185,7 @@ const OVERRIDE_UNKNOWN_FORK_REFUSAL = `The override could not confirm whether th
|
|
|
1123
1185
|
// with the adjudicator's reason. The unknown answer gets its own text, as the override does.
|
|
1124
1186
|
const RECHECK_FORK_REFUSAL =
|
|
1125
1187
|
"A recheck cannot run on a fork pull request: the adjudicator needs this repository's checkout of the head";
|
|
1188
|
+
const OVERRIDE_HEAD_MOVED = `Crysk did not override the gate: the pull request has new commits since the override was asked, and an override applies to the head at the time of the comment; comment ${commandHint(OVERRIDE_COMMAND)} again.`;
|
|
1126
1189
|
const RECHECK_UNKNOWN_FORK_REFUSAL = `The recheck could not confirm whether this pull request comes from a fork, so it was refused; comment ${commandHint(RECHECK_COMMAND)} again.`;
|
|
1127
1190
|
|
|
1128
1191
|
// What the override's one lookup says. `crossRepository` is undefined when the
|
|
@@ -1389,6 +1452,19 @@ export function runCiTrigger(deps: CiTriggerDeps): number {
|
|
|
1389
1452
|
react(deps, base, "-1");
|
|
1390
1453
|
return 0;
|
|
1391
1454
|
}
|
|
1455
|
+
// WHY refused when the head moved: an override applies to the head at the time of the
|
|
1456
|
+
// comment. On a comment event the job resolves the head moments later; a platform dispatch
|
|
1457
|
+
// can start minutes later, so it carries the head the platform saw and must still match.
|
|
1458
|
+
const asked =
|
|
1459
|
+
input.platformCommand?.kind === "override"
|
|
1460
|
+
? input.platformCommand.headSha
|
|
1461
|
+
: undefined;
|
|
1462
|
+
if (asked !== undefined && answer.head !== asked) {
|
|
1463
|
+
writeRecord(deps, run, { decision: "denied", params: {} });
|
|
1464
|
+
deps.appendOutput(formatTriggerOutputs(NO_RUN));
|
|
1465
|
+
deps.stdout(workflowCommand("notice", OVERRIDE_HEAD_MOVED));
|
|
1466
|
+
return 0;
|
|
1467
|
+
}
|
|
1392
1468
|
react(deps, base, "eyes");
|
|
1393
1469
|
// WHY the no-head path is kept: a same-repository answer with no usable sha
|
|
1394
1470
|
// still posts, and the publisher's comment says no status could be set.
|
package/src/commands/ci-setup.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
appendIgnorePatterns,
|
|
20
20
|
ignorePatternsError,
|
|
21
21
|
OPENCODE_PROVIDERS_VARIABLE,
|
|
22
|
-
|
|
22
|
+
openCodeProvidersOfPerson,
|
|
23
23
|
runCiSetup,
|
|
24
24
|
writeRepoReviewConfig,
|
|
25
25
|
} from "#ci/setup";
|
|
@@ -186,6 +186,8 @@ interface WorkflowVariables {
|
|
|
186
186
|
readonly configLabel: string;
|
|
187
187
|
readonly hasModels: boolean;
|
|
188
188
|
readonly hasCredentials: boolean;
|
|
189
|
+
// The person's `profile` (openai-profile S6), set as vars.CRYSK_PROFILE.
|
|
190
|
+
readonly profile?: string;
|
|
189
191
|
// The OpenCode providers the models name, as secret tokens (DEEPSEEK), sorted.
|
|
190
192
|
readonly openCodeTokens: readonly string[];
|
|
191
193
|
}
|
|
@@ -202,8 +204,9 @@ async function readWorkflowVariables(
|
|
|
202
204
|
? `~/${path.relative(home, filePath)}`
|
|
203
205
|
: filePath;
|
|
204
206
|
// The judge is skipped and every fallback counts, the providers the setup step
|
|
205
|
-
// builds the auth file for (
|
|
206
|
-
|
|
207
|
+
// builds the auth file for (openCodeProvidersOfPerson): the models', and the
|
|
208
|
+
// profile's for the roles models does not set.
|
|
209
|
+
const providers = openCodeProvidersOfPerson(layer ?? {});
|
|
207
210
|
const unnamed = providers.filter(
|
|
208
211
|
(provider) => opencodeSecretToken(provider) === undefined,
|
|
209
212
|
);
|
|
@@ -229,6 +232,7 @@ async function readWorkflowVariables(
|
|
|
229
232
|
variables: {
|
|
230
233
|
configLabel,
|
|
231
234
|
hasModels: layer?.models !== undefined,
|
|
235
|
+
...(layer?.profile === undefined ? {} : { profile: layer.profile }),
|
|
232
236
|
hasCredentials: layer?.credentials !== undefined,
|
|
233
237
|
openCodeTokens,
|
|
234
238
|
},
|
|
@@ -247,6 +251,11 @@ export function workflowVariableCommands(
|
|
|
247
251
|
`$ gh variable set CRYSK_MODELS --body "$(jq -c .models ${variables.configLabel})"`,
|
|
248
252
|
);
|
|
249
253
|
}
|
|
254
|
+
if (variables.profile !== undefined) {
|
|
255
|
+
commands.push(
|
|
256
|
+
`$ gh variable set CRYSK_PROFILE --body ${variables.profile}`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
250
259
|
if (variables.hasCredentials) {
|
|
251
260
|
commands.push(
|
|
252
261
|
`$ gh variable set CRYSK_CREDENTIALS --body "$(jq -c .credentials ${variables.configLabel})"`,
|
package/src/commands/doctor.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { resolveOptionalRepoRoot } from "#config/config";
|
|
3
|
+
import { routingNeedsOpenCode } from "#model/model-name";
|
|
4
4
|
import type { CliOptions } from "#review/preflight";
|
|
5
5
|
import { styleEnabled, terminalWidth } from "#ui/primitives";
|
|
6
6
|
import {
|
|
7
7
|
type DoctorCheckItem,
|
|
8
8
|
type DoctorReport,
|
|
9
9
|
evaluateDoctorReport,
|
|
10
|
+
loadDoctorRouting,
|
|
10
11
|
openCodeRoutingSdkCheck,
|
|
11
12
|
renderDoctorReport,
|
|
12
13
|
runDoctor,
|
|
@@ -38,41 +39,41 @@ export async function runDoctorCommand(input: {
|
|
|
38
39
|
// the loader share. Tests pass a version without resolving a package.
|
|
39
40
|
readSdkVersion?: () => Promise<string | undefined>;
|
|
40
41
|
}): Promise<{ report: DoctorReport; lines: string[] }> {
|
|
41
|
-
|
|
42
|
+
// Required unless the configuration loads and proves otherwise: a config
|
|
43
|
+
// that fails to load must not quietly excuse a missing Claude CLI.
|
|
44
|
+
const routing = await loadDoctorRouting({
|
|
45
|
+
home: input.home,
|
|
46
|
+
repoRoot: input.repoRoot,
|
|
47
|
+
configFlag: input.configFlag,
|
|
48
|
+
});
|
|
49
|
+
const { models, profile, claudeRequired } = routing;
|
|
42
50
|
let configCheck: DoctorCheckItem | undefined;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
51
|
+
if (routing.error !== undefined) {
|
|
52
|
+
configCheck = {
|
|
53
|
+
name: "config",
|
|
54
|
+
severity: "blocking",
|
|
55
|
+
message: `configuration failed to load: ${routing.error}`,
|
|
56
|
+
};
|
|
57
|
+
} else if (routing.warnings.length > 0) {
|
|
50
58
|
// A config that loads with warnings works today and will not after the
|
|
51
59
|
// key it uses is removed: degraded, with the warning as its message.
|
|
52
|
-
if (loaded.warnings.length > 0) {
|
|
53
|
-
configCheck = {
|
|
54
|
-
name: "config",
|
|
55
|
-
severity: "degraded",
|
|
56
|
-
message: loaded.warnings.join("\n"),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
} catch (error) {
|
|
60
60
|
configCheck = {
|
|
61
61
|
name: "config",
|
|
62
|
-
severity: "
|
|
63
|
-
message:
|
|
64
|
-
error instanceof Error ? error.message : String(error)
|
|
65
|
-
}`,
|
|
62
|
+
severity: "degraded",
|
|
63
|
+
message: routing.warnings.join("\n"),
|
|
66
64
|
};
|
|
67
65
|
}
|
|
68
66
|
const runDoctorFn = input.runDoctorFn ?? runDoctor;
|
|
69
67
|
const doctorReport = await runDoctorFn({
|
|
70
68
|
repoRoot: input.repoRoot,
|
|
71
69
|
cwd: input.repoRoot,
|
|
70
|
+
claudeRequired,
|
|
72
71
|
probeExactBindings: () =>
|
|
73
72
|
collectDoctorExactBindingReports({
|
|
74
73
|
workspaceRoot: input.workspaceRoot,
|
|
75
74
|
models,
|
|
75
|
+
claudeRequired,
|
|
76
|
+
profile,
|
|
76
77
|
}),
|
|
77
78
|
});
|
|
78
79
|
// Same home the command was given. The no-arg reader uses os.homedir().
|
|
@@ -82,9 +83,10 @@ export async function runDoctorCommand(input: {
|
|
|
82
83
|
readInstalledOpenCodeSdkVersion({
|
|
83
84
|
nodeModulesDir: prheroLayout(input.home).nodeModulesDir,
|
|
84
85
|
}));
|
|
85
|
-
const sdkCheck =
|
|
86
|
+
const sdkCheck = routingNeedsOpenCode(models, profile)
|
|
86
87
|
? openCodeRoutingSdkCheck({
|
|
87
88
|
models,
|
|
89
|
+
profile,
|
|
88
90
|
sdkVersion: await readSdkVersion(),
|
|
89
91
|
})
|
|
90
92
|
: undefined;
|
package/src/commands/status.ts
CHANGED
|
@@ -125,6 +125,8 @@ export async function runStatusCommand(input: {
|
|
|
125
125
|
statuses,
|
|
126
126
|
issueComments,
|
|
127
127
|
reviewComments,
|
|
128
|
+
// A developer's machine never learns the platform's login (src/triage/adjudication.ts).
|
|
129
|
+
adjudicatorTrust: { kind: "local" },
|
|
128
130
|
});
|
|
129
131
|
consecutivePollErrors = 0;
|
|
130
132
|
} catch (err) {
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { modelNameFromAlias } from "#model/model-name";
|
|
3
3
|
import {
|
|
4
4
|
agentStepKey,
|
|
5
|
+
type ResolvedModelRoute,
|
|
5
6
|
type ResolvedStepRoute,
|
|
6
7
|
resolveStepRoute,
|
|
7
8
|
} from "#model/routing";
|
|
@@ -26,6 +27,11 @@ export interface DiversityLeg {
|
|
|
26
27
|
readonly logicalModel: string;
|
|
27
28
|
readonly model: string;
|
|
28
29
|
readonly routeFingerprint: string;
|
|
30
|
+
// The route the leg resolved to, the one its routeFingerprint names. Not
|
|
31
|
+
// part of the plan payload (the fingerprint already is), so legIds and the
|
|
32
|
+
// plan fingerprint stay what they were. Provenance reads it when a step
|
|
33
|
+
// carries no executed route (S2).
|
|
34
|
+
readonly route: ResolvedModelRoute;
|
|
29
35
|
readonly executionKey: string;
|
|
30
36
|
readonly stepKey: string;
|
|
31
37
|
}
|
|
@@ -130,7 +136,10 @@ export function buildDiversityPlan(
|
|
|
130
136
|
const specialty = resolveSpecialty(agent);
|
|
131
137
|
for (const model of models) {
|
|
132
138
|
// A leg's model is internal: a bare alias or a full model name. Its
|
|
133
|
-
// own model
|
|
139
|
+
// own model is the step's spec model, which outranks `models`, the
|
|
140
|
+
// frontmatter and the profile in resolveStepChoices; only `--model`
|
|
141
|
+
// outranks it, and it is passed. So this is the route the run plan
|
|
142
|
+
// gives the leg's step, which assertDiversityLegRoutes checks (S2).
|
|
134
143
|
const parsed = { canonical: modelNameFromAlias(model).raw };
|
|
135
144
|
const provisionalKey = diversityLegAgentKey(
|
|
136
145
|
agent.key,
|
|
@@ -158,6 +167,7 @@ export function buildDiversityPlan(
|
|
|
158
167
|
logicalModel: model,
|
|
159
168
|
model: parsed.canonical,
|
|
160
169
|
routeFingerprint: stepRoute.routeFingerprint,
|
|
170
|
+
route: stepRoute.route,
|
|
161
171
|
executionKey,
|
|
162
172
|
stepKey,
|
|
163
173
|
});
|
|
@@ -245,6 +245,24 @@ export function recordDiversityHunterFailure(
|
|
|
245
245
|
return appendAttempt(ledger, attempt);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
// The route an observation names. A step carries no executed route only on
|
|
249
|
+
// the no-plan path, which runs every step on the Claude CLI, so the leg's own
|
|
250
|
+
// resolved route stands in when it is a Claude one. A non-Claude leg there has
|
|
251
|
+
// no observed execution to name, and labelling it Anthropic (as this did
|
|
252
|
+
// before S2) or with a route nobody ran would both be false: refuse.
|
|
253
|
+
function provenanceRoute(
|
|
254
|
+
leg: DiversityLeg,
|
|
255
|
+
executedRoute: ResolvedModelRoute | undefined,
|
|
256
|
+
): ResolvedModelRoute {
|
|
257
|
+
if (executedRoute !== undefined) return executedRoute;
|
|
258
|
+
if (leg.route.backend !== "claude-code") {
|
|
259
|
+
throw new DiversityAdmissionError(
|
|
260
|
+
`no executed route for ${leg.route.backend} leg ${leg.legId}`,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
return leg.route;
|
|
264
|
+
}
|
|
265
|
+
|
|
248
266
|
export function recordDiversityHunterResult(
|
|
249
267
|
ledger: DiversityLedger,
|
|
250
268
|
plan: DiversityPlan,
|
|
@@ -290,12 +308,7 @@ export function recordDiversityHunterResult(
|
|
|
290
308
|
}
|
|
291
309
|
if (result.status !== "ok") return next;
|
|
292
310
|
const terminalAttemptId = `${resolvedLeg.legId}-a${totalAttempts}`;
|
|
293
|
-
const routeProvenance
|
|
294
|
-
backend: "claude-code",
|
|
295
|
-
provider: "anthropic",
|
|
296
|
-
modelFamily: resolvedLeg.model.split("/")[0] ?? "unknown",
|
|
297
|
-
modelSnapshot: resolvedLeg.model,
|
|
298
|
-
};
|
|
311
|
+
const routeProvenance = provenanceRoute(resolvedLeg, executedRoute);
|
|
299
312
|
const output = result.output as { findings?: DraftFinding[] } | undefined;
|
|
300
313
|
const findings = output?.findings ?? [];
|
|
301
314
|
for (const [index, finding] of findings.entries()) {
|