crysk 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/package.json +3 -2
  3. package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
  4. package/src/asset-manifest.ts +11 -0
  5. package/src/assets.ts +1 -1
  6. package/src/ci/credential-refresh.ts +524 -0
  7. package/src/ci/crysk-secrets.ts +20 -6
  8. package/src/ci/force-comment.ts +14 -1
  9. package/src/ci/gates.ts +64 -21
  10. package/src/ci/outcome.ts +165 -15
  11. package/src/ci/platform-estimate.ts +111 -0
  12. package/src/ci/platform-trace.ts +30 -0
  13. package/src/ci/platform.ts +183 -5
  14. package/src/ci/reporter.ts +14 -4
  15. package/src/ci/setup.ts +96 -6
  16. package/src/ci/trace-bundle.ts +231 -27
  17. package/src/ci/trace-transcripts.ts +65 -0
  18. package/src/ci/trigger.ts +20 -4
  19. package/src/commands/ci-setup.ts +12 -3
  20. package/src/commands/doctor.ts +25 -23
  21. package/src/diversity/identity.ts +11 -1
  22. package/src/diversity/pipeline-integration.ts +19 -6
  23. package/src/doctor.ts +133 -4
  24. package/src/execution/contracts.ts +15 -3
  25. package/src/harness/materiality-judge.ts +153 -0
  26. package/src/harness/pipeline-plan.ts +133 -0
  27. package/src/harness/replay-rows.ts +172 -0
  28. package/src/harness/route-runner.ts +288 -0
  29. package/src/harness/single-step.ts +153 -0
  30. package/src/index.ts +1 -1
  31. package/src/model/catalog.ts +10 -7
  32. package/src/model/model-name.ts +14 -0
  33. package/src/model/profiles/claude.ts +34 -0
  34. package/src/model/profiles/openai.ts +44 -0
  35. package/src/model/profiles.ts +213 -0
  36. package/src/model/routing.ts +155 -50
  37. package/src/pr/ci-admission-gate.ts +2 -0
  38. package/src/pr/discovery.ts +18 -0
  39. package/src/pr/plan.ts +41 -2
  40. package/src/pr/review-pr.ts +43 -6
  41. package/src/pr/target.ts +67 -15
  42. package/src/production-runtime.ts +100 -13
  43. package/src/review/pipeline.ts +193 -58
  44. package/src/review/preflight.ts +91 -9
  45. package/src/review/prompt-set.ts +68 -0
  46. package/src/review/report.ts +4 -0
  47. package/src/review/review.ts +21 -11
  48. package/src/review/route-preflight.ts +117 -67
  49. package/src/review/run.ts +50 -4
  50. package/src/security/credential-broker.ts +21 -9
  51. package/src/security/oauth-providers.ts +101 -0
  52. package/src/transport-registry.ts +33 -0
  53. package/src/transports/opencode-sdk.ts +33 -1
  54. package/src/ui/config-edit.ts +9 -0
  55. package/src/ui/config.ts +1 -0
  56. package/src/ui/menu.ts +9 -2
  57. package/src/ui/plan.ts +8 -3
  58. package/src/updater.ts +21 -13
  59. package/src/wizard.ts +23 -0
@@ -2,6 +2,7 @@ import type { BucketScope } from "../execution/bucket-id";
2
2
  import { deriveBucketId } from "../execution/bucket-id";
3
3
  import type {
4
4
  AsyncEventSink,
5
+ OpenCodeFailureCredential,
5
6
  ProviderCapabilityReport,
6
7
  ProviderEvent,
7
8
  ProviderEventBase,
@@ -409,6 +410,12 @@ export interface OpenCodeSdkTransportOptions {
409
410
  readonly provider: string;
410
411
  };
411
412
  readonly defaultRoute?: ResolvedModelRoute;
413
+ // S7: the CRYSK_OPENCODE_* secret this transport's route runs on, named by the
414
+ // registry factory from the route's provider and credential kind (the transport
415
+ // holds neither credential nor kind). Stamped on every failed outcome as
416
+ // `failureCredential`, so a CI fix names the secret to replace or top up. Absent
417
+ // for a free route, an unknown kind, or a provider no secret name can carry.
418
+ readonly failureCredential?: OpenCodeFailureCredential;
412
419
  }
413
420
 
414
421
  const MARKER_ABORT_UNCONFIRMED =
@@ -708,6 +715,9 @@ export class OpenCodeSdkTransport implements ProviderTransport {
708
715
  // attempted.
709
716
  readonly credentialProjection = "server-lifetime" as const;
710
717
  readonly defaultRoute?: ResolvedModelRoute;
718
+ // Public and readonly for the same reason as usageBillingMode below: the factory
719
+ // derives it, and reading it is how a test observes that derivation.
720
+ readonly failureCredential?: OpenCodeFailureCredential;
711
721
  private readonly client: OpenCodeClientLike;
712
722
  private readonly stallDeadlineMs: number;
713
723
  private readonly abortConfirmMs: number;
@@ -739,6 +749,7 @@ export class OpenCodeSdkTransport implements ProviderTransport {
739
749
  };
740
750
  this.cancellationSemantics = "provider-proof";
741
751
  this.defaultRoute = options.defaultRoute;
752
+ this.failureCredential = options.failureCredential;
742
753
  this.client = options.client;
743
754
  this.stallDeadlineMs = options.stallDeadlineMs ?? DEFAULT_STALL_DEADLINE_MS;
744
755
  this.abortConfirmMs = options.abortConfirmMs ?? SDK_ABORT_CONFIRM_MS;
@@ -878,7 +889,9 @@ export class OpenCodeSdkTransport implements ProviderTransport {
878
889
  request: TransportRequest,
879
890
  context: { readonly signal: AbortSignal; readonly events: AsyncEventSink },
880
891
  ): Promise<TransportOutcome> {
881
- const outcome = await this.executeAttempt(request, context);
892
+ const outcome = this.withFailureCredential(
893
+ await this.executeAttempt(request, context),
894
+ );
882
895
  try {
883
896
  const diagnosticEvidence = this.client.takeEvidence?.(
884
897
  request.sessionId,
@@ -890,6 +903,15 @@ export class OpenCodeSdkTransport implements ProviderTransport {
890
903
  }
891
904
  }
892
905
 
906
+ // The secret only on a failed attempt, like the Claude transport: it is what the fix
907
+ // names, and a success or a cancellation has nothing to fix.
908
+ private withFailureCredential(outcome: TransportOutcome): TransportOutcome {
909
+ return outcome.completion === "failed" &&
910
+ this.failureCredential !== undefined
911
+ ? { ...outcome, failureCredential: this.failureCredential }
912
+ : outcome;
913
+ }
914
+
893
915
  private async executeAttempt(
894
916
  request: TransportRequest,
895
917
  context: { readonly signal: AbortSignal; readonly events: AsyncEventSink },
@@ -2255,6 +2277,16 @@ export class OpenCodeSdkTransport implements ProviderTransport {
2255
2277
  ) {
2256
2278
  return "model_unavailable";
2257
2279
  }
2280
+ // S7, same slot rule: a 401 is the provider refusing the credential, whatever its
2281
+ // words (OpenAI's "Incorrect API key provided" matches none of the auth patterns
2282
+ // above). auth_invalid is terminal like runtime_unavailable, so the retry policy is
2283
+ // unchanged; the cause lets the PR name the secret to replace (CRYSK-CRED-REJECTED).
2284
+ if (
2285
+ witness.includes(MARKER_PROVIDER_REFUSAL) &&
2286
+ providerRefusalStatus(witness) === "401"
2287
+ ) {
2288
+ return "auth_invalid";
2289
+ }
2258
2290
  if (witness.includes(MARKER_PROVIDER_REFUSAL)) {
2259
2291
  return providerRefusalRetries(witness) === true
2260
2292
  ? "network_transient"
@@ -1,12 +1,14 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
+ import { profileIdProblem } from "#model/profiles";
4
5
  import {
5
6
  mergeConfig,
6
7
  parseGlobalConfig,
7
8
  parseLocalConfig,
8
9
  } from "#review/preflight";
9
10
  import { resolveHomeDir, resolveRepoDir } from "../brand-paths";
11
+ import { redactConfigValue } from "../security/redact";
10
12
  import { bold, box, cyan, dim, sanitizeText, yellow } from "./primitives";
11
13
  import type { KeyReader } from "./select";
12
14
 
@@ -628,6 +630,13 @@ export async function setConfigValue(input: {
628
630
  // Gone (L6 item 1): writing it would plant the very key the parser now
629
631
  // refuses. Say where the summary model lives instead.
630
632
  throw new Error(SUMMARY_MODEL_GONE);
633
+ } else if (input.key === "profile") {
634
+ const value = input.value.trim();
635
+ const problem = profileIdProblem(value);
636
+ if (problem !== undefined) {
637
+ throw new Error(`${problem} (got "${redactConfigValue(value)}")`);
638
+ }
639
+ currentPerson.profile = value;
631
640
  } else if (input.key === "agents_dir") {
632
641
  currentPerson.agents_dir = input.value.trim();
633
642
  } else if (input.key === "scout") {
package/src/ui/config.ts CHANGED
@@ -168,6 +168,7 @@ export function configRows(
168
168
  ),
169
169
  models: modelsCell(effective.models, sources.models),
170
170
  credentials: credentialsCell(effective.credentials, sources.credentials),
171
+ profile: cell(effective.profile, sources.profile),
171
172
  max_verification_steps: cell(
172
173
  effective.max_verification_steps?.toString(),
173
174
  sources.max_verification_steps,
package/src/ui/menu.ts CHANGED
@@ -6,7 +6,7 @@ import { DEFAULT_SIZE_GATE } from "#review/size-gate";
6
6
  import { listActiveRuns } from "#store/activity";
7
7
  import { DEFAULT_DAILY_CAP } from "#watch/preflight";
8
8
  import { resolveHomeDir, resolveRepoDir } from "../brand-paths";
9
- import { runDoctor } from "../doctor";
9
+ import { loadDoctorRouting, runDoctor } from "../doctor";
10
10
  import {
11
11
  getMenuOptions,
12
12
  type MenuItem,
@@ -157,7 +157,14 @@ export async function gatherMenuStatus(
157
157
 
158
158
  let doctorStatus: MenuStatusInfo["doctorStatus"];
159
159
  try {
160
- const report = await runDoctor({ home, cwd });
160
+ // The person's profile decides whether the Claude CLI is required
161
+ // (openai-profile S6), as `crysk doctor` reads it.
162
+ const routing = await loadDoctorRouting({ home, repoRoot: cwd });
163
+ const report = await runDoctor({
164
+ home,
165
+ cwd,
166
+ claudeRequired: routing.claudeRequired,
167
+ });
161
168
  doctorStatus = report.overall;
162
169
  } catch {
163
170
  // Ignore
package/src/ui/plan.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { existsSync } from "node:fs";
8
8
  import path from "node:path";
9
+ import type { PlatformEstimateBasis } from "#ci/platform-estimate";
9
10
  import type { EffectiveConfig } from "#config/config";
10
11
  import { exclusionLines } from "#git/git";
11
12
  import { isFullCommitId } from "#git/refs";
@@ -492,7 +493,7 @@ export function freeRouteEstimateText(estimate: {
492
493
  // byte-identical. The band never reads $0 – $0 here: estimateCost clamps the
493
494
  // hunter seats (report.ts), so a free route is "not billed", never a zero estimate.
494
495
  export function planEstimateLine(input: {
495
- estimate: { low: number; high: number };
496
+ estimate: { low: number; high: number; platform?: PlatformEstimateBasis };
496
497
  hunterCount: number;
497
498
  summarizer: boolean;
498
499
  freeRoute?: FreeRouteBilling;
@@ -505,9 +506,13 @@ export function planEstimateLine(input: {
505
506
  if (billing === "free") {
506
507
  return `estimate: ${freeRouteEstimateText(input.estimate)}`;
507
508
  }
509
+ // The platform's range is not the band, so the line says where it came from
510
+ // instead of the agent count the band is built on (cryskai/platform#12).
508
511
  const line =
509
- `estimate ${low} – ${high} (${input.hunterCount} hunter(s) + refuter ` +
510
- `${input.summarizer ? "+ summarizer" : "+ summarizer disabled"})`;
512
+ input.estimate.platform === undefined
513
+ ? `estimate ${low} – ${high} (${input.hunterCount} hunter(s) + refuter ` +
514
+ `${input.summarizer ? "+ summarizer" : "+ summarizer disabled"})`
515
+ : `estimate ${low} – ${high} (platform: ${input.estimate.platform})`;
511
516
  return billing === "mixed" ? `${line} ${FREE_STEPS_NOTE}` : line;
512
517
  }
513
518
 
package/src/updater.ts CHANGED
@@ -24,9 +24,10 @@ import { type AssetMode, resolveEngineAssets, selfInvocation } from "./assets";
24
24
  import { BIN_NAME, LEGACY_BIN_NAME } from "./brand";
25
25
  import { LEGACY_HOME_DIR_NAME, resolveHomeDir } from "./brand-paths";
26
26
  import { loadGlobalConfigLayer } from "./config/config";
27
- import { runDoctor } from "./doctor";
27
+ import { loadDoctorRouting, runDoctor } from "./doctor";
28
28
  import { prheroLayout } from "./home-preflight";
29
- import { type ModelsConfig, modelsNeedOpenCode } from "./model/model-name";
29
+ import { type ModelsConfig, routingNeedsOpenCode } from "./model/model-name";
30
+ import { resolveProfile } from "./model/profiles";
30
31
  import {
31
32
  readInstalledOpenCodeSdkVersion,
32
33
  SUPPORTED_OPENCODE_SDK_VERSION,
@@ -54,7 +55,7 @@ export function detectInstallMethod(
54
55
  ): InstallMethod {
55
56
  const home = options.home ?? os.homedir();
56
57
  const execPath = options.execPath ?? process.execPath;
57
- const version = options.version ?? "0.5.0";
58
+ const version = options.version ?? "0.6.0";
58
59
  const exists = options.exists ?? existsSync;
59
60
 
60
61
  const isSource =
@@ -656,14 +657,15 @@ export function spawnOpenCodeSdkInstaller(
656
657
  });
657
658
  }
658
659
 
659
- // The person file's `models`, the only layer that may hold them. A person
660
- // file that no longer parses (a removed `routing` key) throws here, and the
661
- // reconcile step records that message instead of crashing.
662
- async function readReconcileModels(
663
- home: string,
664
- ): Promise<ModelsConfig | undefined> {
660
+ // The person file's `models` and `profile`, the only layer that may hold them.
661
+ // A person file that no longer parses (a removed `routing` key) throws here,
662
+ // and the reconcile step records that message instead of crashing.
663
+ async function readReconcileModels(home: string): Promise<{
664
+ models: ModelsConfig | undefined;
665
+ profile: string | undefined;
666
+ }> {
665
667
  const loaded = await loadGlobalConfigLayer(home);
666
- return loaded.layer?.models;
668
+ return { models: loaded.layer?.models, profile: loaded.layer?.profile };
667
669
  }
668
670
 
669
671
  async function ensureOpenCodeSdkInstalled(options: {
@@ -673,8 +675,8 @@ async function ensureOpenCodeSdkInstalled(options: {
673
675
  which?: (bin: string) => string | null;
674
676
  spawnInstaller?: (argv: readonly string[]) => Promise<OpenCodeSdkSpawnResult>;
675
677
  }): Promise<void> {
676
- const models = await readReconcileModels(options.home);
677
- if (!modelsNeedOpenCode(models)) return;
678
+ const { models, profile } = await readReconcileModels(options.home);
679
+ if (!routingNeedsOpenCode(models, resolveProfile(profile))) return;
678
680
  // Install and the version check share this home. The no-arg reader uses
679
681
  // os.homedir(), which is a different tree whenever reconcile was given one.
680
682
  const nodeModulesDir = prheroLayout(options.home).nodeModulesDir;
@@ -823,7 +825,13 @@ export async function reconcileUpgrade(
823
825
  }
824
826
  } else {
825
827
  try {
826
- const doc = await runDoctor({ home });
828
+ // The person's profile decides whether the Claude CLI is required
829
+ // (openai-profile S6), as `crysk doctor` reads it.
830
+ const routing = await loadDoctorRouting({ home });
831
+ const doc = await runDoctor({
832
+ home,
833
+ claudeRequired: routing.claudeRequired,
834
+ });
827
835
  if (doc.overall === "blocking") {
828
836
  errors.push("Doctor check found blocking issues");
829
837
  }
package/src/wizard.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
+ import type { ModelsConfig } from "#model/model-name";
5
+ import type { ModelProfile } from "#model/profiles";
4
6
  import {
5
7
  GOTCHAS_PLACEHOLDER_MARKER,
6
8
  initConfigTemplate,
@@ -16,6 +18,7 @@ import {
16
18
  } from "./agent-env";
17
19
  import { resolveEngineAssets, selfInvocation } from "./assets";
18
20
  import { REPO_DIR_NAME, resolveHomeDir, resolveRepoDir } from "./brand-paths";
21
+ import { loadDoctorRouting } from "./doctor";
19
22
  import type {
20
23
  ExactBindingCapabilityReport,
21
24
  RunnerBackend,
@@ -341,6 +344,22 @@ function authProjectionDetail(
341
344
  return ` (auth projection: ${ready ? "ready" : "unavailable"})`;
342
345
  }
343
346
 
347
+ // The routing the wizard's binding probe resolves, read like `crysk doctor`
348
+ // reads it. A config that fails to load keeps the fallback profile with
349
+ // Claude required, which is what the probe did before profiles existed.
350
+ async function wizardDoctorRouting(home: string): Promise<{
351
+ claudeRequired: boolean;
352
+ models?: ModelsConfig;
353
+ profile: ModelProfile;
354
+ }> {
355
+ const routing = await loadDoctorRouting({ home });
356
+ return {
357
+ claudeRequired: routing.claudeRequired,
358
+ ...(routing.models === undefined ? {} : { models: routing.models }),
359
+ profile: routing.profile,
360
+ };
361
+ }
362
+
344
363
  export const WIZARD_STEPS: readonly WizardStepDescriptor[] = [
345
364
  // Step 1: System tools
346
365
  {
@@ -372,6 +391,10 @@ export const WIZARD_STEPS: readonly WizardStepDescriptor[] = [
372
391
  ? await deps.probeExactBinding()
373
392
  : await collectDoctorExactBindingReports({
374
393
  workspaceRoot,
394
+ // What the person's config routes, as `crysk doctor` probes it
395
+ // (openai-profile S6): a profile with no Claude step is not
396
+ // probed on a Claude binding it never opens.
397
+ ...(await wizardDoctorRouting(deps.home ?? os.homedir())),
375
398
  authorityDeps: {
376
399
  existsFn: deps.exists ?? deps.checkToolsOptions?.exists,
377
400
  },