crysk 0.6.0 → 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/dist/index.js CHANGED
@@ -191,6 +191,147 @@ var init_anthropic = __esm(() => {
191
191
  };
192
192
  });
193
193
 
194
+ // src/model/profiles/claude.ts
195
+ var CLAUDE_PROFILE;
196
+ var init_claude = __esm(() => {
197
+ CLAUDE_PROFILE = Object.freeze({
198
+ id: "claude",
199
+ roles: Object.freeze({
200
+ hunter: Object.freeze({ model: "claude:sonnet-latest", effort: "xhigh" }),
201
+ refuter: Object.freeze({ model: "claude:opus-latest", effort: "high" }),
202
+ consolidate: Object.freeze({
203
+ model: "claude:sonnet-latest",
204
+ effort: "high"
205
+ }),
206
+ scout: Object.freeze({ model: "claude:sonnet-latest", effort: "high" }),
207
+ summary: Object.freeze({ model: "claude:haiku-latest", effort: "high" }),
208
+ judge: Object.freeze({ model: "claude:sonnet-latest", effort: "high" })
209
+ }),
210
+ measured: Object.freeze({
211
+ judgeModels: Object.freeze(["claude:sonnet-latest", "claude:opus-latest"])
212
+ })
213
+ });
214
+ });
215
+
216
+ // src/model/profiles/openai.ts
217
+ var OPENAI_PROFILE;
218
+ var init_openai = __esm(() => {
219
+ OPENAI_PROFILE = Object.freeze({
220
+ id: "openai",
221
+ roles: Object.freeze({
222
+ hunter: Object.freeze({
223
+ model: "opencode:openai/gpt-6.1-terra",
224
+ effort: "xhigh"
225
+ }),
226
+ refuter: Object.freeze({
227
+ model: "opencode:openai/gpt-6.1-sol",
228
+ effort: "high"
229
+ }),
230
+ consolidate: Object.freeze({
231
+ model: "opencode:openai/gpt-6.1-terra",
232
+ effort: "high"
233
+ }),
234
+ scout: Object.freeze({ model: "opencode:openai/gpt-6.1-terra" }),
235
+ summary: Object.freeze({ model: "opencode:openai/gpt-6-luna" }),
236
+ judge: Object.freeze({ model: "opencode:openai/gpt-6.1-terra" })
237
+ }),
238
+ judgeModels: Object.freeze([
239
+ "opencode:openai/gpt-6.1-terra",
240
+ "claude:sonnet-latest",
241
+ "claude:opus-latest"
242
+ ])
243
+ });
244
+ });
245
+
246
+ // src/model/profiles.ts
247
+ function modelProfile(id) {
248
+ const profile = MODEL_PROFILES[id];
249
+ if (profile === undefined) {
250
+ throw new Error(`unknown model profile "${id}": known profiles are ${Object.keys(MODEL_PROFILES).join(", ")}`);
251
+ }
252
+ return profile;
253
+ }
254
+ function resolveProfile(id) {
255
+ return id === undefined ? FALLBACK_PROFILE : modelProfile(id);
256
+ }
257
+ function profileIdProblem(value) {
258
+ const known = `profile must be one of ${Object.keys(MODEL_PROFILES).join(", ")}`;
259
+ if (typeof value !== "string")
260
+ return known;
261
+ return Object.hasOwn(MODEL_PROFILES, value) ? undefined : known;
262
+ }
263
+ function profileRoute(profile, role) {
264
+ if (role.startsWith("hunter.")) {
265
+ const key = role.slice("hunter.".length);
266
+ const own = profile.hunters?.[key] ?? profile.roles.hunter;
267
+ if (own !== undefined)
268
+ return own;
269
+ return FALLBACK_PROFILE.hunters?.[key] ?? fallbackRoute("hunter");
270
+ }
271
+ if (!isProfileRole(role)) {
272
+ throw new Error(`no profile role "${role}"`);
273
+ }
274
+ return profile.roles[role] ?? fallbackRoute(role);
275
+ }
276
+ function profileRoleEffort(profile, role) {
277
+ const own = profileRoute(profile, role).effort;
278
+ if (own !== undefined)
279
+ return own;
280
+ const fallback = profileRoute(FALLBACK_PROFILE, role).effort;
281
+ if (fallback === undefined) {
282
+ throw new Error(`${FALLBACK_PROFILE.id} profile lacks an effort for ${role}`);
283
+ }
284
+ return fallback;
285
+ }
286
+ function profileModels(profile) {
287
+ return [
288
+ ...PROFILE_ROLES.map((role) => profileRoute(profile, role).model),
289
+ ...Object.values(profile.hunters ?? {}).map((route) => route.model)
290
+ ];
291
+ }
292
+ function profileJudgeModels(profile) {
293
+ const own = profile.measured?.judgeModels ?? profile.judgeModels;
294
+ if (own !== undefined)
295
+ return own;
296
+ const fallback = FALLBACK_PROFILE.measured?.judgeModels;
297
+ if (fallback === undefined) {
298
+ throw new Error(`${FALLBACK_PROFILE.id} profile lacks judgeModels`);
299
+ }
300
+ return fallback;
301
+ }
302
+ function isProfileRole(role) {
303
+ return PROFILE_ROLES.includes(role);
304
+ }
305
+ function fallbackRoute(role) {
306
+ const route = FALLBACK_PROFILE.roles[role];
307
+ if (route === undefined) {
308
+ throw new Error(`${FALLBACK_PROFILE.id} profile lacks ${role}`);
309
+ }
310
+ return route;
311
+ }
312
+ function profileModelAlias(model) {
313
+ const match = /^claude:([a-z]+)-latest$/.exec(model);
314
+ return match?.[1] ?? model;
315
+ }
316
+ var PROFILE_ROLES, MODEL_PROFILES, FALLBACK_PROFILE_ID = "claude", FALLBACK_PROFILE;
317
+ var init_profiles = __esm(() => {
318
+ init_claude();
319
+ init_openai();
320
+ PROFILE_ROLES = [
321
+ "hunter",
322
+ "refuter",
323
+ "consolidate",
324
+ "scout",
325
+ "summary",
326
+ "judge"
327
+ ];
328
+ MODEL_PROFILES = Object.freeze({
329
+ [CLAUDE_PROFILE.id]: CLAUDE_PROFILE,
330
+ [OPENAI_PROFILE.id]: OPENAI_PROFILE
331
+ });
332
+ FALLBACK_PROFILE = modelProfile(FALLBACK_PROFILE_ID);
333
+ });
334
+
194
335
  // src/model/catalog.ts
195
336
  function assertNonEmptyString(value, label) {
196
337
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -238,6 +379,7 @@ function defaultEffortForRole(role) {
238
379
  var PROVIDER_CATALOGS, MODEL_CATALOG, aliasIndex, REQUIRED_ALIASES, EFFORT_LEVELS, ROLE_EFFORT;
239
380
  var init_catalog = __esm(() => {
240
381
  init_anthropic();
382
+ init_profiles();
241
383
  PROVIDER_CATALOGS = {
242
384
  anthropic: normalizeProviderCatalog(anthropic_default)
243
385
  };
@@ -272,10 +414,10 @@ var init_catalog = __esm(() => {
272
414
  }
273
415
  EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
274
416
  ROLE_EFFORT = Object.freeze({
275
- hunter: "xhigh",
276
- refuter: "high",
277
- summarizer: "high",
278
- scout: "high",
417
+ hunter: profileRoleEffort(FALLBACK_PROFILE, "hunter"),
418
+ refuter: profileRoleEffort(FALLBACK_PROFILE, "refuter"),
419
+ summarizer: profileRoleEffort(FALLBACK_PROFILE, "summary"),
420
+ scout: profileRoleEffort(FALLBACK_PROFILE, "scout"),
279
421
  verifier: "high",
280
422
  other: "high"
281
423
  });
@@ -478,10 +620,18 @@ function modelsNeedOpenCode(models) {
478
620
  return false;
479
621
  return Object.values(models).some((list) => list.some((entry) => modelEntry(entry).name.startsWith(OPENCODE_PREFIX)));
480
622
  }
623
+ function routingNeedsOpenCode(models, profile) {
624
+ if (modelsNeedOpenCode(models))
625
+ return true;
626
+ if (models?.default !== undefined)
627
+ return false;
628
+ return profileModels(profile).some((model) => model.startsWith(OPENCODE_PREFIX));
629
+ }
481
630
  var ModelNameError, CLAUDE_PREFIX = "claude:", OPENCODE_PREFIX = "opencode:", LATEST_SUFFIX = "-latest", CLAUDE_ID_RE, OPENCODE_RE, OPENCODE_EFFORT_RE, CLAUDE_FORMS = "claude:sonnet-latest, claude:opus-latest, claude:haiku-latest, claude:fable-latest or a full claude-* model name", OPENCODE_FORM = "opencode:<provider>/<model>", FIXED_MODEL_ROLES, HUNTER_ROLE_PREFIX = "hunter.", HUNTER_KEY_RE, MAX_MODELS_PER_ROLE = 3, ENTRY_KEYS, ENTRY_FORM = '{"model": "<name>", "effort": "<level>"}', ULTRACODE = "ultracode", JUDGE_NO_EFFORT = "the materiality judge runs at the effort it was measured at, so models.judge takes model names only", ROLE_LIST = "default, hunter.<key>, consolidate, scout, judge, refuter, summary";
482
631
  var init_model_name = __esm(() => {
483
632
  init_redact();
484
633
  init_catalog();
634
+ init_profiles();
485
635
  ModelNameError = class ModelNameError extends Error {
486
636
  };
487
637
  CLAUDE_ID_RE = /^claude-[a-z0-9.-]+$/;
@@ -579,6 +729,12 @@ function resolveStepChoices(input) {
579
729
  { name: toModelName(input.frontmatterModel, "prompt", input.stepKey) }
580
730
  ];
581
731
  }
732
+ if (input.profileModel !== undefined) {
733
+ const name = toModelName(input.profileModel, "profile", input.stepKey);
734
+ return [
735
+ name.backend === "opencode" && input.profileEffort !== undefined ? { name, effort: input.profileEffort } : { name }
736
+ ];
737
+ }
582
738
  throw new ModelRoutingError(`agent ${input.stepKey} has no model and no override given`);
583
739
  }
584
740
  function resolveStepModels(input) {
@@ -658,37 +814,47 @@ function assertHunterRolesExist(models, agents) {
658
814
  throw new InvalidModelError(`models.${role} names no hunter in this review: its hunters are ${hunters.join(", ")}`);
659
815
  }
660
816
  }
661
- function judgeModelChoice(models) {
662
- const listed = (models?.judge ?? [`claude:${MATERIALITY_JUDGE_MODEL}-latest`]).map((entry) => modelEntry(entry).name);
663
- const usable = listed.filter((name) => MEASURED_JUDGE_MODELS.includes(name));
817
+ function judgeModelChoice(models, profile = FALLBACK_PROFILE) {
818
+ const listed = (models?.judge ?? [profileRoute(profile, "judge").model]).map((entry) => modelEntry(entry).name);
819
+ const measured = profileJudgeModels(profile);
820
+ const usable = listed.filter((name) => measured.includes(name));
664
821
  return {
665
822
  ...usable.length === 0 ? {} : { model: usable[0] },
666
- dropped: listed.filter((name) => !MEASURED_JUDGE_MODELS.includes(name))
823
+ dropped: listed.filter((name) => !measured.includes(name))
667
824
  };
668
825
  }
669
- function resolveMaterialityJudgeRoute(models) {
670
- const { model } = judgeModelChoice(models);
826
+ function resolveMaterialityJudgeRoute(models, profile = FALLBACK_PROFILE) {
827
+ const { model } = judgeModelChoice(models, profile);
671
828
  if (model === undefined)
672
829
  return;
673
830
  return stepRouteFor(MATERIALITY_STEP_KEY, "other", {
674
831
  name: parseModelName(model)
675
832
  });
676
833
  }
677
- function isMeasuredJudgeRoute(route) {
678
- return route.backend === "claude-code" && route.provider === "anthropic" && (route.modelSnapshot === "sonnet" || route.modelSnapshot === "opus");
834
+ function isMeasuredJudgeRoute(route, profile = FALLBACK_PROFILE) {
835
+ return profileJudgeModels(profile).some((name) => {
836
+ const measured = resolveModelRoute(name);
837
+ return route.backend === measured.backend && route.provider === measured.provider && route.modelSnapshot === measured.modelSnapshot;
838
+ });
679
839
  }
680
840
  function buildResolvedRoutePlan(input) {
681
841
  assertHunterRolesExist(input.models, input.agents);
842
+ const profile = input.profile ?? FALLBACK_PROFILE;
843
+ const profileSeat = (role) => {
844
+ const { model, effort } = profileRoute(profile, role);
845
+ return effort === undefined ? { profileModel: model } : { profileModel: model, profileEffort: effort };
846
+ };
682
847
  const stepRoutes = [];
683
848
  for (const agent of input.agents) {
684
849
  const modelRole = agentModelRole(agent);
850
+ const prompt = input.bundledAgents === true ? modelRole === undefined ? {} : profileSeat(modelRole) : { frontmatterModel: input.frontmatterModel?.(agent.key) };
685
851
  stepRoutes.push(resolveStepRoute({
686
852
  stepKey: agentStepKey(agent),
687
853
  role: agent.role,
688
854
  ...modelRole === undefined ? {} : { modelRole },
689
855
  cliModel: input.cliModel,
690
856
  specModel: agent.model,
691
- frontmatterModel: input.frontmatterModel?.(agent.key),
857
+ ...prompt,
692
858
  models: input.models
693
859
  }));
694
860
  }
@@ -699,7 +865,7 @@ function buildResolvedRoutePlan(input) {
699
865
  modelRole: "summary",
700
866
  cliModel: input.cliModel,
701
867
  specModel: input.summarizer.model,
702
- frontmatterModel: input.summarizer.frontmatterModel,
868
+ ...input.summarizer.bundled === true ? profileSeat("summary") : { frontmatterModel: input.summarizer.frontmatterModel },
703
869
  models: input.models
704
870
  }));
705
871
  }
@@ -709,7 +875,10 @@ function buildResolvedRoutePlan(input) {
709
875
  role: "scout",
710
876
  modelRole: "scout",
711
877
  cliModel: input.cliModel ?? input.scout.model,
712
- frontmatterModel: input.scout.frontmatterModel ?? input.scout.defaultModel,
878
+ ...input.scout.bundled === true ? {} : {
879
+ frontmatterModel: input.scout.frontmatterModel ?? input.scout.defaultModel
880
+ },
881
+ ...profileSeat("scout"),
713
882
  models: input.models
714
883
  }));
715
884
  }
@@ -719,31 +888,33 @@ function buildResolvedRoutePlan(input) {
719
888
  role: "other",
720
889
  modelRole: "consolidate",
721
890
  cliModel: input.consolidate.model ?? input.cliModel,
722
- frontmatterModel: input.consolidate.frontmatterModel ?? input.consolidate.defaultModel,
891
+ ...input.consolidate.bundled === true ? {} : {
892
+ frontmatterModel: input.consolidate.frontmatterModel ?? input.consolidate.defaultModel
893
+ },
894
+ ...profileSeat("consolidate"),
723
895
  models: input.models
724
896
  }));
725
897
  }
726
898
  if (input.materiality) {
727
- const judge = resolveMaterialityJudgeRoute(input.models);
728
- const hasClaudeStep = stepRoutes.some((s) => s.route.backend === "claude-code");
729
- if (judge !== undefined && (input.models?.judge !== undefined || hasClaudeStep)) {
899
+ const judge = resolveMaterialityJudgeRoute(input.models, profile);
900
+ const sharesCredential = judge !== undefined && stepRoutes.some((s) => s.route.backend === judge.route.backend && s.route.provider === judge.route.provider);
901
+ if (judge !== undefined && (input.models?.judge !== undefined || sharesCredential)) {
730
902
  stepRoutes.push(judge);
731
903
  }
732
904
  }
733
905
  return createResolvedRoutePlan(stepRoutes);
734
906
  }
735
- var ModelRoutingError, InvalidModelError, NEW_FORM_PREFIXES, MATERIALITY_STEP_KEY = "materiality", MATERIALITY_JUDGE_MODEL = "sonnet", MEASURED_JUDGE_MODELS;
907
+ var ModelRoutingError, InvalidModelError, NEW_FORM_PREFIXES, MATERIALITY_STEP_KEY = "materiality", MATERIALITY_JUDGE_MODEL, MEASURED_JUDGE_MODELS;
736
908
  var init_routing = __esm(() => {
737
909
  init_model_name();
910
+ init_profiles();
738
911
  ModelRoutingError = class ModelRoutingError extends Error {
739
912
  };
740
913
  InvalidModelError = class InvalidModelError extends ModelRoutingError {
741
914
  };
742
915
  NEW_FORM_PREFIXES = ["claude:", "opencode:"];
743
- MEASURED_JUDGE_MODELS = [
744
- "claude:sonnet-latest",
745
- "claude:opus-latest"
746
- ];
916
+ MATERIALITY_JUDGE_MODEL = profileModelAlias(profileRoute(FALLBACK_PROFILE, "judge").model);
917
+ MEASURED_JUDGE_MODELS = profileJudgeModels(FALLBACK_PROFILE);
747
918
  });
748
919
 
749
920
  // src/compare/materiality.ts
@@ -1543,8 +1714,16 @@ function safeProviderName(value) {
1543
1714
  function safeModelName(value) {
1544
1715
  return typeof value === "string" && MODEL_NAME_PATTERN.test(value) ? value : undefined;
1545
1716
  }
1717
+ function isOpenCodeCredential(value) {
1718
+ return OPENCODE_FAILURE_CREDENTIAL_RE.test(value);
1719
+ }
1546
1720
  function knownFailureCredential(value) {
1547
- return typeof value === "string" && Object.hasOwn(FAILURE_CREDENTIAL_LOOKUP, value) ? value : undefined;
1721
+ if (typeof value !== "string")
1722
+ return;
1723
+ if (Object.hasOwn(FAILURE_CREDENTIAL_LOOKUP, value)) {
1724
+ return value;
1725
+ }
1726
+ return isOpenCodeCredential(value) ? value : undefined;
1548
1727
  }
1549
1728
  function safeFailureDetail(value) {
1550
1729
  return typeof value === "string" && value.trim() === value && value.length <= FAILURE_DETAIL_MAX && FAILURE_DETAIL_PATTERN.test(value) ? value : undefined;
@@ -1581,7 +1760,7 @@ function parseCliClass(value) {
1581
1760
  return value.check === "no-credential" ? { kind: "trigger", check: "no-credential" } : undefined;
1582
1761
  }
1583
1762
  if (value.kind === "credential") {
1584
- if (value.failureClass === "missing_provider_record" || value.failureClass === "missing_subscription_record") {
1763
+ if (value.failureClass === "missing_provider_record" || value.failureClass === "missing_subscription_record" || value.failureClass === "subscription_expiring") {
1585
1764
  return { kind: "credential", failureClass: value.failureClass };
1586
1765
  }
1587
1766
  return;
@@ -1792,7 +1971,7 @@ function parseOutcomeCode(body) {
1792
1971
  const code = `CRYSK-${heading[1]}`;
1793
1972
  return ERROR_CODES.includes(code) ? code : null;
1794
1973
  }
1795
- var ERROR_CODES, CLI_RECORD_FILE = "cli.json", PENDING_AT_FILE = "pending-at", RUN_DIR_FILE = "run-dir", STATUS_DESCRIPTION_MAX = 140, TRANSPORT_CAUSE_LOOKUP, PROVIDER_NAME_PATTERN, MODEL_NAME_PATTERN, FAILURE_CREDENTIAL_LOOKUP, FAILURE_DETAIL_MAX = 160, FAILURE_DETAIL_PATTERN, RECORD_PARAM_KEYS, CLI_OUTCOMES, CLI_SKIPS, CLI_HEAD_PATTERN, ENGINE_DEFECT_ISSUE = 'gh issue create -R cryskai/crysk --title "CRYSK-ENGINE-DEFECT {detail}" --body "{runUrl}"', RERUN_FAILED = "$ gh run rerun {runId} --failed", REVIEW_AGAIN = '$ gh pr comment {pr} --body "/crysk review"', LEGACY_REVIEW_NOTE = "On a workflow set up before the rename, comment `/pr-hero review` instead.", OPENCODE_API_KEY_SECRET = "$ gh secret set CRYSK_OPENCODE_<PROVIDER>_API_KEY", OPENCODE_PROVIDER_TOKEN_NOTE = "<PROVIDER> is the provider id uppercased with `-` and `.` as `_` (`deepseek` is DEEPSEEK).", OPENAI_OAUTH_SECRET = "$ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH", CRED_STORE_WHY = "the credential store does not hold what this route needs", CLAUDE_SUBSCRIPTION_FIXES, OPENCODE_SUBSCRIPTION_FIXES, CRYSK_SECRETS_FIXES, EMPTY_SLOT_DETAIL = "CRYSK_OPENCODE__API_KEY has a value but no provider: an unused OpenCode slot must be empty", EMPTY_SLOT_FIXES, UNSUPPORTED_OAUTH_DETAIL_RE, MODEL_NOT_SERVED, PROVIDER_REFUSED_WHY = "the provider's safety system declined this input", UNCLASSIFIED_FIXES, UNCLASSIFIED_FIX = "re-run the failed jobs with `gh run rerun {runId} --failed`", GITHUB_TOKEN_INPUT, CLAUDE_CREDENTIAL_FIXES, OPENCODE_CREDENTIAL_FIXES, MODELS_INPUT_LINE, CREDENTIALS_INPUT_LINE, REMOVED_INPUT_FIXES, PROVIDER_LIMITED, CREDENTIAL_UNUSABLE_ENV, RUNTIME_LOCAL, GITHUB_SERVER, ERROR_CATALOG, OUTCOME_MARKER_PREFIX;
1974
+ var ERROR_CODES, CLI_RECORD_FILE = "cli.json", PENDING_AT_FILE = "pending-at", RUN_DIR_FILE = "run-dir", STATUS_DESCRIPTION_MAX = 140, TRANSPORT_CAUSE_LOOKUP, PROVIDER_NAME_PATTERN, MODEL_NAME_PATTERN, FAILURE_CREDENTIAL_LOOKUP, OPENCODE_FAILURE_CREDENTIAL_RE, FAILURE_DETAIL_MAX = 160, FAILURE_DETAIL_PATTERN, RECORD_PARAM_KEYS, CLI_OUTCOMES, CLI_SKIPS, CLI_HEAD_PATTERN, ENGINE_DEFECT_ISSUE = 'gh issue create -R cryskai/crysk --title "CRYSK-ENGINE-DEFECT {detail}" --body "{runUrl}"', RERUN_FAILED = "$ gh run rerun {runId} --failed", REVIEW_AGAIN = '$ gh pr comment {pr} --body "/crysk review"', LEGACY_REVIEW_NOTE = "On a workflow set up before the rename, comment `/pr-hero review` instead.", OPENCODE_API_KEY_SECRET = "$ gh secret set CRYSK_OPENCODE_<PROVIDER>_API_KEY", OPENCODE_PROVIDER_TOKEN_NOTE = "<PROVIDER> is the provider id uppercased with `-` and `.` as `_` (`deepseek` is DEEPSEEK).", OPENAI_OAUTH_SECRET = "$ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH", CRED_STORE_WHY = "the credential store does not hold what this route needs", CLAUDE_SUBSCRIPTION_FIXES, OPENAI_API_KEY_INSTEAD = "Or bill per token: set CRYSK_OPENCODE_OPENAI_API_KEY and stop passing {secret} in the crysk-secrets input (the subscription is used while it is passed):", OPENCODE_SUBSCRIPTION_FIXES, CRYSK_SECRETS_FIXES, EMPTY_SLOT_DETAIL = "CRYSK_OPENCODE__API_KEY has a value but no provider: an unused OpenCode slot must be empty", EMPTY_SLOT_FIXES, UNSUPPORTED_OAUTH_DETAIL_RE, MODEL_NOT_SERVED, PROVIDER_REFUSED_WHY = "the provider's safety system declined this input", UNCLASSIFIED_FIXES, UNCLASSIFIED_FIX = "re-run the failed jobs with `gh run rerun {runId} --failed`", GITHUB_TOKEN_INPUT, CLAUDE_CREDENTIAL_FIXES, OPENCODE_CREDENTIAL_FIXES, MODELS_INPUT_LINE, PROFILE_INPUT_LINE, CREDENTIALS_INPUT_LINE, REMOVED_INPUT_FIXES, PROVIDER_LIMITED, CREDENTIAL_UNUSABLE_ENV, RUNTIME_LOCAL, GITHUB_SERVER, ERROR_CATALOG, OUTCOME_MARKER_PREFIX;
1796
1975
  var init_outcome = __esm(() => {
1797
1976
  init_brand();
1798
1977
  ERROR_CODES = [
@@ -1843,6 +2022,7 @@ var init_outcome = __esm(() => {
1843
2022
  ANTHROPIC_AUTH_TOKEN: true,
1844
2023
  CLAUDE_CODE_OAUTH_TOKEN: true
1845
2024
  };
2025
+ OPENCODE_FAILURE_CREDENTIAL_RE = /^CRYSK_OPENCODE_([A-Z0-9]+(?:_[A-Z0-9]+)*)_(API_KEY|OAUTH)$/;
1846
2026
  FAILURE_DETAIL_PATTERN = /^[^\u0000-\u001f\u007f]+$/;
1847
2027
  RECORD_PARAM_KEYS = [
1848
2028
  "backend",
@@ -1934,6 +2114,7 @@ var init_outcome = __esm(() => {
1934
2114
  "$ gh run rerun {runId}"
1935
2115
  ];
1936
2116
  MODELS_INPUT_LINE = "models: $" + "{{ vars.CRYSK_MODELS }}";
2117
+ PROFILE_INPUT_LINE = "profile: $" + "{{ vars.CRYSK_PROFILE }}";
1937
2118
  CREDENTIALS_INPUT_LINE = "credentials: $" + "{{ vars.CRYSK_CREDENTIALS }}";
1938
2119
  REMOVED_INPUT_FIXES = [
1939
2120
  "Set the CRYSK_* secret that replaces each old credential input:",
@@ -2006,6 +2187,16 @@ var init_outcome = __esm(() => {
2006
2187
  fixes: (params) => isOpencodeRoute(params) ? OPENCODE_SUBSCRIPTION_FIXES : CLAUDE_SUBSCRIPTION_FIXES,
2007
2188
  annotationFix: (params) => isOpencodeRoute(params) ? "run `opencode auth login` and choose ChatGPT for provider `openai`, then set CRYSK_OPENCODE_OPENAI_OAUTH from its record, or set CRYSK_OPENCODE_OPENAI_API_KEY to bill per token" : "log in again with `claude setup-token` and set `CRYSK_CLAUDE_OAUTH_TOKEN` (`gh secret set CRYSK_CLAUDE_OAUTH_TOKEN`)"
2008
2189
  },
2190
+ subscription_expiring: {
2191
+ what: "The {provider} subscription login for {step} expires before the review would finish",
2192
+ why: "A review never renews a subscription login whose provider rotates its refresh token: renewing it inside the run would spend the stored login and lose the new one with the run's copy",
2193
+ fixes: [
2194
+ "On a repository connected to Crysk, the platform renews the login before it expires. If it did not, reconnect the provider in the Crysk dashboard.",
2195
+ "On a workflow you manage yourself, run `opencode auth login` again and set the `CRYSK_OPENCODE_<PROVIDER>_OAUTH` secret from its new record: the secret is a snapshot, and nothing renews it for you.",
2196
+ "Locally, run any `opencode` request once (it renews your login in place), or `opencode auth login` again."
2197
+ ],
2198
+ annotationFix: "reconnect {provider} in the Crysk dashboard, or on a self-managed workflow run `opencode auth login` and set its `_OAUTH` secret again"
2199
+ },
2009
2200
  malformed_payload: {
2010
2201
  what: "The credential store is not usable: {detail}",
2011
2202
  why: CRED_STORE_WHY,
@@ -2049,6 +2240,31 @@ var init_outcome = __esm(() => {
2049
2240
  ],
2050
2241
  annotationFix: "log in again with `claude setup-token` and set `{secret}` (`gh secret set {secret}`)"
2051
2242
  },
2243
+ opencode_api_key: {
2244
+ why: "the provider refused the API key in that secret: it is invalid, expired or revoked",
2245
+ fixes: [
2246
+ "Create a new key with the provider and set it:",
2247
+ "$ gh secret set {secret}",
2248
+ "Then ask for a new review:",
2249
+ REVIEW_AGAIN,
2250
+ LEGACY_REVIEW_NOTE
2251
+ ],
2252
+ annotationFix: "create a new key with the provider and run `gh secret set {secret}`"
2253
+ },
2254
+ opencode_oauth: {
2255
+ why: "the ChatGPT login recorded in that secret is expired or revoked",
2256
+ fixes: [
2257
+ "Log in again with `opencode auth login` and choose ChatGPT, then set the provider's record, base64 on one line (on macOS, drop -w0):",
2258
+ "$ opencode auth login",
2259
+ OPENAI_OAUTH_SECRET,
2260
+ OPENAI_API_KEY_INSTEAD,
2261
+ "$ gh secret set CRYSK_OPENCODE_OPENAI_API_KEY",
2262
+ "Then ask for a new review:",
2263
+ REVIEW_AGAIN,
2264
+ LEGACY_REVIEW_NOTE
2265
+ ],
2266
+ annotationFix: "log in again with `opencode auth login`, choose ChatGPT and set {secret} from its record, or set CRYSK_OPENCODE_OPENAI_API_KEY and stop passing {secret} to bill per token"
2267
+ },
2052
2268
  default: {
2053
2269
  why: "it is expired, revoked, or a short-lived /login session token",
2054
2270
  fixes: [
@@ -2125,6 +2341,18 @@ var init_outcome = __esm(() => {
2125
2341
  "$ gh run rerun {runId}"
2126
2342
  ],
2127
2343
  annotationFix: "fix the credentials JSON ({detail}) and set it again with `gh variable set CRYSK_CREDENTIALS`, the variable the workflow passes as `vars.CRYSK_CREDENTIALS`"
2344
+ },
2345
+ "profile-input": {
2346
+ what: "The profile input is invalid: {detail}",
2347
+ why: "Crysk refuses to guess which models the review should run",
2348
+ fixes: [
2349
+ "Set the variable to a known profile, for example:",
2350
+ "$ gh variable set CRYSK_PROFILE --body openai",
2351
+ `The workflow passes it as \`${PROFILE_INPUT_LINE}\`.`,
2352
+ "Then re-run the workflow:",
2353
+ "$ gh run rerun {runId}"
2354
+ ],
2355
+ annotationFix: "set a known profile ({detail}) with `gh variable set CRYSK_PROFILE`, the variable the workflow passes as `vars.CRYSK_PROFILE`"
2128
2356
  }
2129
2357
  }
2130
2358
  },
@@ -2281,6 +2509,30 @@ var init_outcome = __esm(() => {
2281
2509
  "$ gh secret set CRYSK_CLAUDE_API_KEY"
2282
2510
  ],
2283
2511
  annotationFix: "re-run after the limit resets, or set CRYSK_CLAUDE_API_KEY and put api_key first in `credentials.claude` to bill per token"
2512
+ },
2513
+ opencode_api_key: {
2514
+ what: "the account behind {secret} reached a rate limit or quota",
2515
+ why: "the provider refuses requests on this key until the limit resets or the account has credit again, so an immediate retry would fail the same way",
2516
+ fixes: [
2517
+ "Wait for the limit to reset, or add credit or raise the quota on the provider account behind the key, then ask for a new review:",
2518
+ REVIEW_AGAIN,
2519
+ LEGACY_REVIEW_NOTE,
2520
+ "Or set a key from an account that has quota:",
2521
+ "$ gh secret set {secret}"
2522
+ ],
2523
+ annotationFix: "wait for the limit to reset or add credit to the provider account behind {secret}, or set another key with `gh secret set {secret}`"
2524
+ },
2525
+ opencode_oauth: {
2526
+ what: "the ChatGPT subscription behind {secret} reached its usage limit",
2527
+ why: "the subscription refuses requests until its usage window resets, so an immediate retry would fail the same way",
2528
+ fixes: [
2529
+ "Re-run after the limit resets:",
2530
+ REVIEW_AGAIN,
2531
+ LEGACY_REVIEW_NOTE,
2532
+ OPENAI_API_KEY_INSTEAD,
2533
+ "$ gh secret set CRYSK_OPENCODE_OPENAI_API_KEY"
2534
+ ],
2535
+ annotationFix: "re-run after the limit resets, or set CRYSK_OPENCODE_OPENAI_API_KEY and stop passing {secret} to bill per token"
2284
2536
  }
2285
2537
  }
2286
2538
  },
@@ -2420,12 +2672,17 @@ function opencodeSecretToken(providerId) {
2420
2672
  return;
2421
2673
  return providerId.toUpperCase().replace(/[.-]/g, "_");
2422
2674
  }
2423
- function chooseOpenCodeSecret(providerId, names) {
2675
+ function opencodeSecretName(providerId, kind) {
2424
2676
  const token = opencodeSecretToken(providerId);
2425
2677
  if (token === undefined)
2426
2678
  return;
2427
- const apiKey = `CRYSK_OPENCODE_${token}_API_KEY`;
2428
- const oauth = `CRYSK_OPENCODE_${token}_OAUTH`;
2679
+ return kind === "api_key" ? `CRYSK_OPENCODE_${token}_API_KEY` : `CRYSK_OPENCODE_${token}_OAUTH`;
2680
+ }
2681
+ function chooseOpenCodeSecret(providerId, names) {
2682
+ const apiKey = opencodeSecretName(providerId, "api_key");
2683
+ const oauth = opencodeSecretName(providerId, "oauth");
2684
+ if (apiKey === undefined || oauth === undefined)
2685
+ return;
2429
2686
  const hasApiKey = names.includes(apiKey);
2430
2687
  if (names.includes(oauth)) {
2431
2688
  if (providerId !== OPENCODE_OAUTH_SECRET_PROVIDER) {
@@ -2487,9 +2744,10 @@ function writeRecordAtomically(dir, name, text, fs) {
2487
2744
  throw error;
2488
2745
  }
2489
2746
  }
2490
- var REVIEW_COMMAND = "/crysk review", REVIEW_FULL_COMMAND = "/crysk review --full", RECHECK_COMMAND = "/crysk recheck", OVERRIDE_COMMAND = "/crysk override", STOP_COMMAND = "/crysk stop", TRIGGER_PERMISSIONS, REMOVED_INPUT_REPLACEMENT, CLAUDE_SESSION_FILES, NODE_FS, RECORD_TEMP_SUFFIX = ".tmp", OVERRIDE_FORK_REFUSAL, OVERRIDE_UNKNOWN_FORK_REFUSAL, RECHECK_UNKNOWN_FORK_REFUSAL;
2747
+ var REVIEW_COMMAND = "/crysk review", REVIEW_FULL_COMMAND = "/crysk review --full", RECHECK_COMMAND = "/crysk recheck", OVERRIDE_COMMAND = "/crysk override", STOP_COMMAND = "/crysk stop", TRIGGER_PERMISSIONS, REMOVED_INPUT_REPLACEMENT, CLAUDE_SESSION_FILES, NODE_FS, RECORD_TEMP_SUFFIX = ".tmp", OVERRIDE_FORK_REFUSAL, OVERRIDE_UNKNOWN_FORK_REFUSAL, OVERRIDE_HEAD_MOVED, RECHECK_UNKNOWN_FORK_REFUSAL;
2491
2748
  var init_trigger = __esm(async () => {
2492
2749
  init_brand();
2750
+ init_profiles();
2493
2751
  init_crysk_secrets();
2494
2752
  TRIGGER_PERMISSIONS = new Set(["admin", "write"]);
2495
2753
  REMOVED_INPUT_REPLACEMENT = {
@@ -2517,6 +2775,7 @@ var init_trigger = __esm(async () => {
2517
2775
  };
2518
2776
  OVERRIDE_FORK_REFUSAL = `An override is refused on a pull request from a fork: its head can change after the comment, so the override would not be bound to the code you saw. Review the fork with ${commandHint(REVIEW_COMMAND)} and merge it with your repository's own rules.`;
2519
2777
  OVERRIDE_UNKNOWN_FORK_REFUSAL = `The override could not confirm whether this pull request comes from a fork, so it was refused; comment ${commandHint(OVERRIDE_COMMAND)} again.`;
2778
+ 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.`;
2520
2779
  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.`;
2521
2780
  if (false) {}
2522
2781
  });
@@ -2568,43 +2827,366 @@ var init_post_floor = __esm(() => {
2568
2827
  ];
2569
2828
  });
2570
2829
 
2571
- // src/security/published-text.ts
2572
- function isSecretValue(name, separator, raw) {
2573
- const quoted = raw.startsWith('"') || raw.startsWith("'");
2574
- const value = quoted ? raw.slice(1, -1) : raw;
2575
- if (value.length < 6 || /^[\d_,.]+$/.test(value) || value.includes("$")) {
2576
- return false;
2830
+ // prompts/consolidate.md
2831
+ var consolidate_default = "./consolidate-ac0mnfyj.md";
2832
+ var init_consolidate = () => {};
2833
+
2834
+ // prompts/default/deep-review-logic.md
2835
+ var deep_review_logic_default = "./deep-review-logic-a6b1gczf.md";
2836
+ var init_deep_review_logic = () => {};
2837
+
2838
+ // prompts/default/deep-review-parity.md
2839
+ var deep_review_parity_default = "./deep-review-parity-0ec904db.md";
2840
+ var init_deep_review_parity = () => {};
2841
+
2842
+ // prompts/default/deep-review-reliability.md
2843
+ var deep_review_reliability_default = "./deep-review-reliability-qyakbjb9.md";
2844
+ var init_deep_review_reliability = () => {};
2845
+
2846
+ // prompts/default/deep-review-resilience.md
2847
+ var deep_review_resilience_default = "./deep-review-resilience-3tz8y26e.md";
2848
+ var init_deep_review_resilience = () => {};
2849
+
2850
+ // prompts/default/review-refuter.md
2851
+ var review_refuter_default = "./review-refuter-btpgnkcd.md";
2852
+ var init_review_refuter = () => {};
2853
+
2854
+ // prompts/materiality.md
2855
+ var materiality_default = "./materiality-f1qwnvg1.md";
2856
+ var init_materiality2 = () => {};
2857
+
2858
+ // prompts/scout.md
2859
+ var scout_default = "./scout-yvp153q7.md";
2860
+ var init_scout = () => {};
2861
+
2862
+ // prompts/summarizer.md
2863
+ var summarizer_default = "./summarizer-zca44nxa.md";
2864
+ var init_summarizer = () => {};
2865
+
2866
+ // skills/crysk/SKILL.md
2867
+ var SKILL_default = "./SKILL-xpf6kmdw.md";
2868
+ var init_SKILL = () => {};
2869
+
2870
+ // skills/crysk-ci-setup/assets/admission-config.example.json
2871
+ var admission_config_example_default = "./admission-config.example-a9vqmmad.json";
2872
+ var init_admission_config_example = () => {};
2873
+
2874
+ // skills/crysk-ci-setup/assets/workflow.yml
2875
+ var workflow_default = "./workflow-ag62s87j.yml";
2876
+ var init_workflow = () => {};
2877
+
2878
+ // skills/crysk-ci-setup/references/ci-admission.md
2879
+ var ci_admission_default = "./ci-admission-0ken6ehx.md";
2880
+ var init_ci_admission = () => {};
2881
+
2882
+ // skills/crysk-ci-setup/references/opencode-ci.md
2883
+ var opencode_ci_default = "./opencode-ci-ac5zksdn.md";
2884
+ var init_opencode_ci = () => {};
2885
+
2886
+ // skills/crysk-ci-setup/SKILL.md
2887
+ var SKILL_default2 = "./SKILL-k4k0zn1w.md";
2888
+ var init_SKILL2 = () => {};
2889
+
2890
+ // skills/crysk-loop/adjudicator.md
2891
+ var adjudicator_default = "./adjudicator-dtg2axnh.md";
2892
+ var init_adjudicator = () => {};
2893
+
2894
+ // skills/crysk-loop/SKILL.md
2895
+ var SKILL_default3 = "./SKILL-nncgwkx7.md";
2896
+ var init_SKILL3 = () => {};
2897
+
2898
+ // skills/crysk-pr/SKILL.md
2899
+ var SKILL_default4 = "./SKILL-qaqsbygw.md";
2900
+ var init_SKILL4 = () => {};
2901
+
2902
+ // src/asset-manifest.ts
2903
+ var BUNDLED_AGENT_FILES, PROFILE_PROMPT_FILES, CONSOLIDATE_PROMPT_PATH, MATERIALITY_PROMPT_PATH, SCOUT_PROMPT_PATH, SUMMARIZER_PROMPT_PATH, TRIAGE_SKILL_FILES, CI_SETUP_SKILL_FILES, PR_SKILL_FILES, GENERAL_SKILL_FILES;
2904
+ var init_asset_manifest = __esm(() => {
2905
+ init_consolidate();
2906
+ init_deep_review_logic();
2907
+ init_deep_review_parity();
2908
+ init_deep_review_reliability();
2909
+ init_deep_review_resilience();
2910
+ init_review_refuter();
2911
+ init_materiality2();
2912
+ init_scout();
2913
+ init_summarizer();
2914
+ init_SKILL();
2915
+ init_admission_config_example();
2916
+ init_workflow();
2917
+ init_ci_admission();
2918
+ init_opencode_ci();
2919
+ init_SKILL2();
2920
+ init_adjudicator();
2921
+ init_SKILL3();
2922
+ init_SKILL4();
2923
+ BUNDLED_AGENT_FILES = {
2924
+ "deep-review-logic.md": deep_review_logic_default,
2925
+ "deep-review-parity.md": deep_review_parity_default,
2926
+ "deep-review-reliability.md": deep_review_reliability_default,
2927
+ "deep-review-resilience.md": deep_review_resilience_default,
2928
+ "review-refuter.md": review_refuter_default
2929
+ };
2930
+ PROFILE_PROMPT_FILES = {};
2931
+ CONSOLIDATE_PROMPT_PATH = consolidate_default;
2932
+ MATERIALITY_PROMPT_PATH = materiality_default;
2933
+ SCOUT_PROMPT_PATH = scout_default;
2934
+ SUMMARIZER_PROMPT_PATH = summarizer_default;
2935
+ TRIAGE_SKILL_FILES = {
2936
+ "SKILL.md": SKILL_default3,
2937
+ "adjudicator.md": adjudicator_default
2938
+ };
2939
+ CI_SETUP_SKILL_FILES = {
2940
+ "SKILL.md": SKILL_default2,
2941
+ "assets/admission-config.example.json": admission_config_example_default,
2942
+ "assets/workflow.yml": workflow_default,
2943
+ "references/ci-admission.md": ci_admission_default,
2944
+ "references/opencode-ci.md": opencode_ci_default
2945
+ };
2946
+ PR_SKILL_FILES = {
2947
+ "SKILL.md": SKILL_default4
2948
+ };
2949
+ GENERAL_SKILL_FILES = {
2950
+ "SKILL.md": SKILL_default
2951
+ };
2952
+ });
2953
+
2954
+ // src/assets.ts
2955
+ import { existsSync as existsSync2, readFileSync } from "fs";
2956
+ import path3 from "path";
2957
+ function detectAssetMode() {
2958
+ if (import.meta.dir.startsWith("/$bunfs") || import.meta.url.startsWith("file:///$bunfs")) {
2959
+ return "compiled";
2577
2960
  }
2578
- if (separator === ":" && /^\d+-\d+$/.test(value))
2579
- return false;
2580
- const colon = separator.includes(":");
2581
- if (!quoted) {
2582
- if (!colon && separator !== "=")
2583
- return false;
2584
- if (/[.()[\]{}<>]/.test(value))
2585
- return false;
2586
- if (colon && /^[A-Z][a-z]/.test(value))
2587
- return false;
2961
+ const gitDir = path3.resolve(import.meta.dir, "../.git");
2962
+ if (import.meta.dir.includes("node_modules") || !existsSync2(gitDir)) {
2963
+ return "npm";
2588
2964
  }
2589
- if (/\d/.test(value))
2590
- return true;
2591
- if (!/pass(?:word|wd)$/i.test(name) || /pass(?:word|wd)/i.test(value)) {
2592
- return false;
2965
+ return "dev";
2966
+ }
2967
+ function resolveVersion() {
2968
+ if (typeof __PRHERO_VERSION__ === "string" && __PRHERO_VERSION__.length > 0) {
2969
+ return __PRHERO_VERSION__;
2593
2970
  }
2594
- return quoted || !colon || name === name.toUpperCase();
2971
+ try {
2972
+ const pkgPath = path3.resolve(import.meta.dir, "../package.json");
2973
+ if (existsSync2(pkgPath)) {
2974
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
2975
+ if (typeof pkg.version === "string") {
2976
+ return pkg.version;
2977
+ }
2978
+ }
2979
+ } catch {}
2980
+ return "0.6.1";
2595
2981
  }
2596
- function redactPrivateKeys(text) {
2597
- if (!text.includes("PRIVATE KEY"))
2598
- return text;
2599
- let out = "";
2600
- let from = 0;
2601
- let noMoreEnds = false;
2602
- PEM_BEGIN.lastIndex = 0;
2603
- for (;; ) {
2604
- const begin = PEM_BEGIN.exec(text);
2605
- if (begin === null)
2606
- break;
2607
- let to = PEM_BEGIN.lastIndex;
2982
+ function resolveBundledFilePath(filePath, moduleDir = import.meta.dir) {
2983
+ return path3.isAbsolute(filePath) ? filePath : path3.resolve(moduleDir, filePath);
2984
+ }
2985
+ function resolveBundledFileMap(files) {
2986
+ return Object.fromEntries(Object.entries(files).map(([name, file]) => [
2987
+ name,
2988
+ resolveBundledFilePath(file)
2989
+ ]));
2990
+ }
2991
+ function resolveEngineAssets() {
2992
+ const mode = detectAssetMode();
2993
+ const version = resolveVersion();
2994
+ const bundledAgentFiles = resolveBundledFileMap(BUNDLED_AGENT_FILES);
2995
+ let defaultAgentsDir = path3.dirname(bundledAgentFiles["review-refuter.md"]);
2996
+ if (mode !== "compiled") {
2997
+ const fsDefaultDir = path3.resolve(import.meta.dir, "../prompts/default");
2998
+ if (existsSync2(fsDefaultDir)) {
2999
+ defaultAgentsDir = fsDefaultDir;
3000
+ }
3001
+ }
3002
+ return {
3003
+ mode,
3004
+ bundledAgentFiles,
3005
+ defaultAgentsDir,
3006
+ consolidatePromptPath: resolveBundledFilePath(CONSOLIDATE_PROMPT_PATH),
3007
+ materialityPromptPath: resolveBundledFilePath(MATERIALITY_PROMPT_PATH),
3008
+ scoutPromptPath: resolveBundledFilePath(SCOUT_PROMPT_PATH),
3009
+ summarizerPromptPath: resolveBundledFilePath(SUMMARIZER_PROMPT_PATH),
3010
+ triageSkillFiles: resolveBundledFileMap(TRIAGE_SKILL_FILES),
3011
+ ciSetupSkillFiles: resolveBundledFileMap(CI_SETUP_SKILL_FILES),
3012
+ prSkillFiles: resolveBundledFileMap(PR_SKILL_FILES),
3013
+ generalSkillFiles: resolveBundledFileMap(GENERAL_SKILL_FILES),
3014
+ version
3015
+ };
3016
+ }
3017
+ function selfInvocation() {
3018
+ const mode = detectAssetMode();
3019
+ if (mode === "compiled") {
3020
+ return {
3021
+ command: process.execPath,
3022
+ args: []
3023
+ };
3024
+ }
3025
+ return {
3026
+ command: process.execPath,
3027
+ args: [path3.resolve(import.meta.dir, "cli.ts")]
3028
+ };
3029
+ }
3030
+ function isNpxCacheInvocation(invocation) {
3031
+ return [invocation.command, ...invocation.args].some((part) => NPX_CACHE_SEGMENT.test(part));
3032
+ }
3033
+ function deriveEngineIdentity(pkg, revision) {
3034
+ const sha = revision.ok ? revision.stdout.trim() : "";
3035
+ return {
3036
+ name: pkg.name ?? "pr-hero",
3037
+ version: pkg.version ?? "0.0.0",
3038
+ ...sha.length === 0 ? {} : { revision: sha }
3039
+ };
3040
+ }
3041
+ function engineCheckoutRoot() {
3042
+ return path3.join(import.meta.dir, "..");
3043
+ }
3044
+ var NPX_REGISTRATION_REFUSED = "Crysk is running from npx's temporary cache; install crysk (npm i -g crysk) to register", NPX_CACHE_SEGMENT;
3045
+ var init_assets = __esm(() => {
3046
+ init_asset_manifest();
3047
+ NPX_CACHE_SEGMENT = /[\\/]_npx[\\/]/;
3048
+ });
3049
+
3050
+ // src/review/prompt-set.ts
3051
+ function profilePromptSet(profile, defaultAgentFiles, sets = PROFILE_PROMPT_FILES) {
3052
+ const overrides = { agents: {}, engine: {} };
3053
+ if (profile.promptSet === undefined)
3054
+ return overrides;
3055
+ const set = sets[profile.promptSet];
3056
+ if (set === undefined) {
3057
+ throw new Error(`model profile "${profile.id}" names prompt set "${profile.promptSet}", which this build does not have`);
3058
+ }
3059
+ for (const [file, bundledPath] of Object.entries(set)) {
3060
+ const filePath = resolveBundledFilePath(bundledPath);
3061
+ if (defaultAgentFiles.includes(file)) {
3062
+ overrides.agents[file] = filePath;
3063
+ } else if (isEnginePromptFile(file)) {
3064
+ overrides.engine[file] = filePath;
3065
+ } else {
3066
+ throw new Error(`prompt set "${profile.promptSet}" holds "${file}", which overrides no file of the default set`);
3067
+ }
3068
+ }
3069
+ return overrides;
3070
+ }
3071
+ function isEnginePromptFile(file) {
3072
+ return ENGINE_PROMPT_FILES.includes(file);
3073
+ }
3074
+ function parseAgentSource(raw) {
3075
+ const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
3076
+ if (!match?.[1] || match[2] === undefined) {
3077
+ throw new Error("agent file has no frontmatter block");
3078
+ }
3079
+ const [, frontmatter, body] = match;
3080
+ const field = (key) => {
3081
+ const line = frontmatter.split(`
3082
+ `).find((l) => l.startsWith(`${key}:`));
3083
+ return line?.slice(key.length + 1).trim().replace(/^"|"$/g, "");
3084
+ };
3085
+ const name = field("name");
3086
+ if (!name)
3087
+ throw new Error("agent file has no name field");
3088
+ const tools = field("tools");
3089
+ const model = field("model");
3090
+ const effort = field("effort");
3091
+ if (effort !== undefined && !isEffort(effort)) {
3092
+ throw new Error(`agent file declares effort "${effort}"; expected one of ${EFFORT_LEVELS.join(", ")}`);
3093
+ }
3094
+ return {
3095
+ name,
3096
+ description: field("description") ?? name,
3097
+ tools: tools ? tools.split(",").map((t) => t.trim()) : [],
3098
+ ...model ? { model } : {},
3099
+ ...effort === undefined ? {} : { effort },
3100
+ body: body.trim()
3101
+ };
3102
+ }
3103
+ async function parseAgentFile(filePath) {
3104
+ const raw = await Bun.file(filePath).text();
3105
+ try {
3106
+ return parseAgentSource(raw);
3107
+ } catch (error) {
3108
+ throw new Error(`${filePath}: ${error instanceof Error ? error.message : String(error)}`);
3109
+ }
3110
+ }
3111
+ function renderPriorsBlock(priors) {
3112
+ return priors.map((p) => `- ${p.path} (weight ${p.weight}): ${p.reason}`).join(`
3113
+ `);
3114
+ }
3115
+ function renderAgentBody(body, context) {
3116
+ const priors = wrapBlock("priors", context.nonce, renderPriorsBlock(context.priors));
3117
+ const gotchas = wrapBlock("gotchas", context.nonce, context.gotchas);
3118
+ return body.replaceAll("{{PRIORS}}", () => priors).replaceAll("{{GOTCHAS}}", () => gotchas);
3119
+ }
3120
+ async function promptSetFingerprint(files) {
3121
+ const hasher = new Bun.CryptoHasher("sha256");
3122
+ for (const file of files) {
3123
+ hasher.update(await Bun.file(file).text());
3124
+ }
3125
+ return hasher.digest("hex").slice(0, 16);
3126
+ }
3127
+ async function promptSetIdentity(agentsDir, files, name) {
3128
+ return {
3129
+ name: name ?? agentsDir.replace(/\/+$/, "").split("/").pop() ?? agentsDir,
3130
+ sha256: await promptSetFingerprint(files)
3131
+ };
3132
+ }
3133
+ var AGENT_NAMES, ENGINE_PROMPT_FILES;
3134
+ var init_prompt_set = __esm(() => {
3135
+ init_catalog();
3136
+ init_asset_manifest();
3137
+ init_assets();
3138
+ init_boundary();
3139
+ AGENT_NAMES = [
3140
+ "deep-review-reliability",
3141
+ "deep-review-resilience",
3142
+ "deep-review-parity",
3143
+ "review-refuter"
3144
+ ];
3145
+ ENGINE_PROMPT_FILES = [
3146
+ "consolidate.md",
3147
+ "scout.md",
3148
+ "summarizer.md",
3149
+ "materiality.md"
3150
+ ];
3151
+ });
3152
+
3153
+ // src/security/published-text.ts
3154
+ function isSecretValue(name, separator, raw) {
3155
+ const quoted = raw.startsWith('"') || raw.startsWith("'");
3156
+ const value = quoted ? raw.slice(1, -1) : raw;
3157
+ if (value.length < 6 || /^[\d_,.]+$/.test(value) || value.includes("$")) {
3158
+ return false;
3159
+ }
3160
+ if (separator === ":" && /^\d+-\d+$/.test(value))
3161
+ return false;
3162
+ const colon = separator.includes(":");
3163
+ if (!quoted) {
3164
+ if (!colon && separator !== "=")
3165
+ return false;
3166
+ if (/[.()[\]{}<>]/.test(value))
3167
+ return false;
3168
+ if (colon && /^[A-Z][a-z]/.test(value))
3169
+ return false;
3170
+ }
3171
+ if (/\d/.test(value))
3172
+ return true;
3173
+ if (!/pass(?:word|wd)$/i.test(name) || /pass(?:word|wd)/i.test(value)) {
3174
+ return false;
3175
+ }
3176
+ return quoted || !colon || name === name.toUpperCase();
3177
+ }
3178
+ function redactPrivateKeys(text) {
3179
+ if (!text.includes("PRIVATE KEY"))
3180
+ return text;
3181
+ let out = "";
3182
+ let from = 0;
3183
+ let noMoreEnds = false;
3184
+ PEM_BEGIN.lastIndex = 0;
3185
+ for (;; ) {
3186
+ const begin = PEM_BEGIN.exec(text);
3187
+ if (begin === null)
3188
+ break;
3189
+ let to = PEM_BEGIN.lastIndex;
2608
3190
  let closed = false;
2609
3191
  if (!noMoreEnds) {
2610
3192
  PEM_END.lastIndex = to;
@@ -2708,293 +3290,84 @@ function parseTriageMarker(body) {
2708
3290
  `, 1)[0] ?? "";
2709
3291
  if (!firstLine.endsWith(" -->"))
2710
3292
  return null;
2711
- const fields = firstLine.slice(prefix.length, firstLine.length - " -->".length);
2712
- const parts = new Map;
2713
- for (const token of fields.split(" ")) {
2714
- if (token.length === 0)
2715
- continue;
2716
- const eq = token.indexOf("=");
2717
- if (eq === -1)
2718
- continue;
2719
- parts.set(token.slice(0, eq), token.slice(eq + 1));
2720
- }
2721
- const rawTag = parts.get("tag");
2722
- const headSha = parts.get("head");
2723
- const rawActor = parts.get("actor");
2724
- if (rawTag === undefined || headSha === undefined || rawActor === undefined) {
2725
- return null;
2726
- }
2727
- if (!TRIAGE_TAGS.has(rawTag))
2728
- return null;
2729
- if (!TRIAGE_ACTORS.has(rawActor))
2730
- return null;
2731
- if (!FULL_SHA.test(headSha))
2732
- return null;
2733
- const tag = rawTag;
2734
- const actor = rawActor;
2735
- if (tag === "applied") {
2736
- if (parts.has("verdict"))
2737
- return null;
2738
- return { tag, headSha, actor };
2739
- }
2740
- const rawVerdict = parts.get("verdict");
2741
- if (rawVerdict === undefined || !TRIAGE_VERDICTS.has(rawVerdict)) {
2742
- return null;
2743
- }
2744
- const verdict = rawVerdict;
2745
- if (tag === "deferred") {
2746
- const rawIssue = parts.get("issue");
2747
- if (rawIssue === undefined) {
2748
- return { tag, headSha, actor, verdict };
2749
- }
2750
- const issue = Number.parseInt(rawIssue, 10);
2751
- if (!Number.isInteger(issue) || issue <= 0)
2752
- return null;
2753
- return { tag, headSha, actor, issue, verdict };
2754
- }
2755
- return { tag, headSha, actor, verdict };
2756
- }
2757
- var TRIAGE_MARKER_PREFIX, TRIAGE_TAGS, TRIAGE_ACTORS, TRIAGE_VERDICTS, FULL_SHA, ADJUDICATED_TAGS, TRIAGE_BADGE;
2758
- var init_triage = __esm(() => {
2759
- init_brand();
2760
- init_published_text();
2761
- TRIAGE_MARKER_PREFIX = `${MARKER_OPEN}triage `;
2762
- TRIAGE_TAGS = new Set([
2763
- "applied",
2764
- "dismissed",
2765
- "deferred",
2766
- "misclassified"
2767
- ]);
2768
- TRIAGE_ACTORS = new Set([
2769
- "agent",
2770
- "human"
2771
- ]);
2772
- TRIAGE_VERDICTS = new Set([
2773
- "upheld",
2774
- "rejected",
2775
- "inconclusive"
2776
- ]);
2777
- FULL_SHA = /^[0-9a-f]{40}$/;
2778
- ADJUDICATED_TAGS = new Set([
2779
- "dismissed",
2780
- "deferred",
2781
- "misclassified"
2782
- ]);
2783
- TRIAGE_BADGE = {
2784
- applied: { emoji: "\u2705", label: "APPLIED" },
2785
- dismissed: { emoji: "\u274C", label: "DISMISSED" },
2786
- deferred: { emoji: "\uD83D\uDCCB", label: "DEFERRED" },
2787
- misclassified: { emoji: "\uD83C\uDFF7\uFE0F", label: "MISCLASSIFIED" }
2788
- };
2789
- });
2790
-
2791
- // prompts/consolidate.md
2792
- var consolidate_default = "./consolidate-ac0mnfyj.md";
2793
- var init_consolidate = () => {};
2794
-
2795
- // prompts/default/deep-review-logic.md
2796
- var deep_review_logic_default = "./deep-review-logic-a6b1gczf.md";
2797
- var init_deep_review_logic = () => {};
2798
-
2799
- // prompts/default/deep-review-parity.md
2800
- var deep_review_parity_default = "./deep-review-parity-0ec904db.md";
2801
- var init_deep_review_parity = () => {};
2802
-
2803
- // prompts/default/deep-review-reliability.md
2804
- var deep_review_reliability_default = "./deep-review-reliability-qyakbjb9.md";
2805
- var init_deep_review_reliability = () => {};
2806
-
2807
- // prompts/default/deep-review-resilience.md
2808
- var deep_review_resilience_default = "./deep-review-resilience-3tz8y26e.md";
2809
- var init_deep_review_resilience = () => {};
2810
-
2811
- // prompts/default/review-refuter.md
2812
- var review_refuter_default = "./review-refuter-btpgnkcd.md";
2813
- var init_review_refuter = () => {};
2814
-
2815
- // prompts/materiality.md
2816
- var materiality_default = "./materiality-f1qwnvg1.md";
2817
- var init_materiality2 = () => {};
2818
-
2819
- // prompts/scout.md
2820
- var scout_default = "./scout-yvp153q7.md";
2821
- var init_scout = () => {};
2822
-
2823
- // prompts/summarizer.md
2824
- var summarizer_default = "./summarizer-zca44nxa.md";
2825
- var init_summarizer = () => {};
2826
-
2827
- // skills/crysk/SKILL.md
2828
- var SKILL_default = "./SKILL-xpf6kmdw.md";
2829
- var init_SKILL = () => {};
2830
-
2831
- // skills/crysk-ci-setup/assets/admission-config.example.json
2832
- var admission_config_example_default = "./admission-config.example-a9vqmmad.json";
2833
- var init_admission_config_example = () => {};
2834
-
2835
- // skills/crysk-ci-setup/assets/workflow.yml
2836
- var workflow_default = "./workflow-4pkyck01.yml";
2837
- var init_workflow = () => {};
2838
-
2839
- // skills/crysk-ci-setup/references/ci-admission.md
2840
- var ci_admission_default = "./ci-admission-0ken6ehx.md";
2841
- var init_ci_admission = () => {};
2842
-
2843
- // skills/crysk-ci-setup/references/opencode-ci.md
2844
- var opencode_ci_default = "./opencode-ci-ac5zksdn.md";
2845
- var init_opencode_ci = () => {};
2846
-
2847
- // skills/crysk-ci-setup/SKILL.md
2848
- var SKILL_default2 = "./SKILL-k4k0zn1w.md";
2849
- var init_SKILL2 = () => {};
2850
-
2851
- // skills/crysk-loop/adjudicator.md
2852
- var adjudicator_default = "./adjudicator-dtg2axnh.md";
2853
- var init_adjudicator = () => {};
2854
-
2855
- // skills/crysk-loop/SKILL.md
2856
- var SKILL_default3 = "./SKILL-vhb4c3vv.md";
2857
- var init_SKILL3 = () => {};
2858
-
2859
- // skills/crysk-pr/SKILL.md
2860
- var SKILL_default4 = "./SKILL-qaqsbygw.md";
2861
- var init_SKILL4 = () => {};
2862
-
2863
- // src/asset-manifest.ts
2864
- var BUNDLED_AGENT_FILES, CONSOLIDATE_PROMPT_PATH, MATERIALITY_PROMPT_PATH, SCOUT_PROMPT_PATH, SUMMARIZER_PROMPT_PATH, TRIAGE_SKILL_FILES, CI_SETUP_SKILL_FILES, PR_SKILL_FILES, GENERAL_SKILL_FILES;
2865
- var init_asset_manifest = __esm(() => {
2866
- init_consolidate();
2867
- init_deep_review_logic();
2868
- init_deep_review_parity();
2869
- init_deep_review_reliability();
2870
- init_deep_review_resilience();
2871
- init_review_refuter();
2872
- init_materiality2();
2873
- init_scout();
2874
- init_summarizer();
2875
- init_SKILL();
2876
- init_admission_config_example();
2877
- init_workflow();
2878
- init_ci_admission();
2879
- init_opencode_ci();
2880
- init_SKILL2();
2881
- init_adjudicator();
2882
- init_SKILL3();
2883
- init_SKILL4();
2884
- BUNDLED_AGENT_FILES = {
2885
- "deep-review-logic.md": deep_review_logic_default,
2886
- "deep-review-parity.md": deep_review_parity_default,
2887
- "deep-review-reliability.md": deep_review_reliability_default,
2888
- "deep-review-resilience.md": deep_review_resilience_default,
2889
- "review-refuter.md": review_refuter_default
2890
- };
2891
- CONSOLIDATE_PROMPT_PATH = consolidate_default;
2892
- MATERIALITY_PROMPT_PATH = materiality_default;
2893
- SCOUT_PROMPT_PATH = scout_default;
2894
- SUMMARIZER_PROMPT_PATH = summarizer_default;
2895
- TRIAGE_SKILL_FILES = {
2896
- "SKILL.md": SKILL_default3,
2897
- "adjudicator.md": adjudicator_default
2898
- };
2899
- CI_SETUP_SKILL_FILES = {
2900
- "SKILL.md": SKILL_default2,
2901
- "assets/admission-config.example.json": admission_config_example_default,
2902
- "assets/workflow.yml": workflow_default,
2903
- "references/ci-admission.md": ci_admission_default,
2904
- "references/opencode-ci.md": opencode_ci_default
2905
- };
2906
- PR_SKILL_FILES = {
2907
- "SKILL.md": SKILL_default4
2908
- };
2909
- GENERAL_SKILL_FILES = {
2910
- "SKILL.md": SKILL_default
2911
- };
2912
- });
2913
-
2914
- // src/assets.ts
2915
- import { existsSync as existsSync2, readFileSync } from "fs";
2916
- import path3 from "path";
2917
- function detectAssetMode() {
2918
- if (import.meta.dir.startsWith("/$bunfs") || import.meta.url.startsWith("file:///$bunfs")) {
2919
- return "compiled";
3293
+ const fields = firstLine.slice(prefix.length, firstLine.length - " -->".length);
3294
+ const parts = new Map;
3295
+ for (const token of fields.split(" ")) {
3296
+ if (token.length === 0)
3297
+ continue;
3298
+ const eq = token.indexOf("=");
3299
+ if (eq === -1)
3300
+ continue;
3301
+ parts.set(token.slice(0, eq), token.slice(eq + 1));
2920
3302
  }
2921
- const gitDir = path3.resolve(import.meta.dir, "../.git");
2922
- if (import.meta.dir.includes("node_modules") || !existsSync2(gitDir)) {
2923
- return "npm";
3303
+ const rawTag = parts.get("tag");
3304
+ const headSha = parts.get("head");
3305
+ const rawActor = parts.get("actor");
3306
+ if (rawTag === undefined || headSha === undefined || rawActor === undefined) {
3307
+ return null;
2924
3308
  }
2925
- return "dev";
2926
- }
2927
- function resolveVersion() {
2928
- if (typeof __PRHERO_VERSION__ === "string" && __PRHERO_VERSION__.length > 0) {
2929
- return __PRHERO_VERSION__;
3309
+ if (!TRIAGE_TAGS.has(rawTag))
3310
+ return null;
3311
+ if (!TRIAGE_ACTORS.has(rawActor))
3312
+ return null;
3313
+ if (!FULL_SHA.test(headSha))
3314
+ return null;
3315
+ const tag = rawTag;
3316
+ const actor = rawActor;
3317
+ if (tag === "applied") {
3318
+ if (parts.has("verdict"))
3319
+ return null;
3320
+ return { tag, headSha, actor };
2930
3321
  }
2931
- try {
2932
- const pkgPath = path3.resolve(import.meta.dir, "../package.json");
2933
- if (existsSync2(pkgPath)) {
2934
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
2935
- if (typeof pkg.version === "string") {
2936
- return pkg.version;
2937
- }
2938
- }
2939
- } catch {}
2940
- return "0.5.0";
2941
- }
2942
- function resolveEngineAssets() {
2943
- const mode = detectAssetMode();
2944
- const version = resolveVersion();
2945
- let defaultAgentsDir = path3.dirname(BUNDLED_AGENT_FILES["review-refuter.md"]);
2946
- if (mode !== "compiled") {
2947
- const fsDefaultDir = path3.resolve(import.meta.dir, "../prompts/default");
2948
- if (existsSync2(fsDefaultDir)) {
2949
- defaultAgentsDir = fsDefaultDir;
2950
- }
3322
+ const rawVerdict = parts.get("verdict");
3323
+ if (rawVerdict === undefined || !TRIAGE_VERDICTS.has(rawVerdict)) {
3324
+ return null;
2951
3325
  }
2952
- return {
2953
- mode,
2954
- bundledAgentFiles: BUNDLED_AGENT_FILES,
2955
- defaultAgentsDir,
2956
- consolidatePromptPath: CONSOLIDATE_PROMPT_PATH,
2957
- materialityPromptPath: MATERIALITY_PROMPT_PATH,
2958
- scoutPromptPath: SCOUT_PROMPT_PATH,
2959
- summarizerPromptPath: SUMMARIZER_PROMPT_PATH,
2960
- triageSkillFiles: TRIAGE_SKILL_FILES,
2961
- ciSetupSkillFiles: CI_SETUP_SKILL_FILES,
2962
- prSkillFiles: PR_SKILL_FILES,
2963
- generalSkillFiles: GENERAL_SKILL_FILES,
2964
- version
2965
- };
2966
- }
2967
- function selfInvocation() {
2968
- const mode = detectAssetMode();
2969
- if (mode === "compiled") {
2970
- return {
2971
- command: process.execPath,
2972
- args: []
2973
- };
3326
+ const verdict = rawVerdict;
3327
+ if (tag === "deferred") {
3328
+ const rawIssue = parts.get("issue");
3329
+ if (rawIssue === undefined) {
3330
+ return { tag, headSha, actor, verdict };
3331
+ }
3332
+ const issue = Number.parseInt(rawIssue, 10);
3333
+ if (!Number.isInteger(issue) || issue <= 0)
3334
+ return null;
3335
+ return { tag, headSha, actor, issue, verdict };
2974
3336
  }
2975
- return {
2976
- command: process.execPath,
2977
- args: [path3.resolve(import.meta.dir, "cli.ts")]
2978
- };
2979
- }
2980
- function isNpxCacheInvocation(invocation) {
2981
- return [invocation.command, ...invocation.args].some((part) => NPX_CACHE_SEGMENT.test(part));
3337
+ return { tag, headSha, actor, verdict };
2982
3338
  }
2983
- function deriveEngineIdentity(pkg, revision) {
2984
- const sha = revision.ok ? revision.stdout.trim() : "";
2985
- return {
2986
- name: pkg.name ?? "pr-hero",
2987
- version: pkg.version ?? "0.0.0",
2988
- ...sha.length === 0 ? {} : { revision: sha }
3339
+ var TRIAGE_MARKER_PREFIX, TRIAGE_TAGS, TRIAGE_ACTORS, TRIAGE_VERDICTS, FULL_SHA, ADJUDICATED_TAGS, TRIAGE_BADGE;
3340
+ var init_triage = __esm(() => {
3341
+ init_brand();
3342
+ init_published_text();
3343
+ TRIAGE_MARKER_PREFIX = `${MARKER_OPEN}triage `;
3344
+ TRIAGE_TAGS = new Set([
3345
+ "applied",
3346
+ "dismissed",
3347
+ "deferred",
3348
+ "misclassified"
3349
+ ]);
3350
+ TRIAGE_ACTORS = new Set([
3351
+ "agent",
3352
+ "human"
3353
+ ]);
3354
+ TRIAGE_VERDICTS = new Set([
3355
+ "upheld",
3356
+ "rejected",
3357
+ "inconclusive"
3358
+ ]);
3359
+ FULL_SHA = /^[0-9a-f]{40}$/;
3360
+ ADJUDICATED_TAGS = new Set([
3361
+ "dismissed",
3362
+ "deferred",
3363
+ "misclassified"
3364
+ ]);
3365
+ TRIAGE_BADGE = {
3366
+ applied: { emoji: "\u2705", label: "APPLIED" },
3367
+ dismissed: { emoji: "\u274C", label: "DISMISSED" },
3368
+ deferred: { emoji: "\uD83D\uDCCB", label: "DEFERRED" },
3369
+ misclassified: { emoji: "\uD83C\uDFF7\uFE0F", label: "MISCLASSIFIED" }
2989
3370
  };
2990
- }
2991
- function engineCheckoutRoot() {
2992
- return path3.join(import.meta.dir, "..");
2993
- }
2994
- var NPX_REGISTRATION_REFUSED = "Crysk is running from npx's temporary cache; install crysk (npm i -g crysk) to register", NPX_CACHE_SEGMENT;
2995
- var init_assets = __esm(() => {
2996
- init_asset_manifest();
2997
- NPX_CACHE_SEGMENT = /[\\/]_npx[\\/]/;
2998
3371
  });
2999
3372
 
3000
3373
  // src/brand-paths.ts
@@ -3836,6 +4209,19 @@ var init_git = __esm(() => {
3836
4209
  init_ignore_read();
3837
4210
  });
3838
4211
 
4212
+ // src/review/exit-code.ts
4213
+ function reviewExitCode(input) {
4214
+ if (input.sessionFailed || input.noReviewerRan === true) {
4215
+ return EXIT_REVIEW_FAILED;
4216
+ }
4217
+ if (input.droppedFindingIds > 0)
4218
+ return EXIT_REVIEW_FAILED;
4219
+ if (input.runStatus === "partial")
4220
+ return EXIT_REVIEW_INCOMPLETE;
4221
+ return EXIT_REVIEW_COMPLETE;
4222
+ }
4223
+ var EXIT_REVIEW_COMPLETE = 0, EXIT_REVIEW_FAILED = 1, EXIT_REVIEW_INCOMPLETE = 3;
4224
+
3839
4225
  // src/home-preflight.ts
3840
4226
  import path8 from "path";
3841
4227
  function prheroLayout(home, exists) {
@@ -4512,10 +4898,17 @@ function skipLine(ts, repoBase, pr, headSha, reason) {
4512
4898
  function launchedLine(ts, pr, repoBase, headSha) {
4513
4899
  return `${ts} launched pr=${pr} repo=${repoBase} head=${headSha.slice(0, 8)}`;
4514
4900
  }
4901
+ function reviewOutcomeResult(exitCode) {
4902
+ if (exitCode === EXIT_REVIEW_COMPLETE)
4903
+ return "ok";
4904
+ if (exitCode === EXIT_REVIEW_INCOMPLETE)
4905
+ return "incomplete";
4906
+ return "failed";
4907
+ }
4515
4908
  function outcomeLine(ts, repoBase, outcome) {
4516
- const status = outcome.ok ? "status=ok" : "status=failed";
4517
- const detail = outcome.ok ? outcome.counts === null ? "" : ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}` : ` exit=${outcome.exitCode}`;
4518
- return `${ts} outcome pr=${outcome.pr} repo=${repoBase} ${status}${detail}`;
4909
+ const counts = outcome.counts === null ? "" : ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}`;
4910
+ const detail = outcome.result === "ok" ? counts : outcome.result === "incomplete" ? ` exit=${outcome.exitCode}${counts}` : ` exit=${outcome.exitCode}`;
4911
+ return `${ts} outcome pr=${outcome.pr} repo=${repoBase} status=${outcome.result}${detail}`;
4519
4912
  }
4520
4913
  function countLaunchedToday(logText, dayPrefix) {
4521
4914
  let count = 0;
@@ -4598,9 +4991,13 @@ function osascriptNotifyArgs(title, text) {
4598
4991
  ];
4599
4992
  }
4600
4993
  function outcomeNotificationText(outcome) {
4601
- if (!outcome.ok) {
4994
+ if (outcome.result === "failed") {
4602
4995
  return `PR #${outcome.pr} review failed (exit ${outcome.exitCode})`;
4603
4996
  }
4997
+ if (outcome.result === "incomplete") {
4998
+ const prefix = `PR #${outcome.pr} review incomplete, run it again`;
4999
+ return outcome.counts === null ? `${prefix} (counts unavailable)` : `${prefix}: ${outcome.counts.blocking} blocking, ${outcome.counts.advisory} advisory`;
5000
+ }
4604
5001
  if (outcome.counts === null) {
4605
5002
  return `PR #${outcome.pr} reviewed (counts unavailable)`;
4606
5003
  }
@@ -5463,6 +5860,17 @@ function resolveAgentsDirSetting(input) {
5463
5860
  };
5464
5861
  }
5465
5862
  const assets = input.assets ?? resolveEngineAssets();
5863
+ const overrides = profilePromptSet(input.profile ?? FALLBACK_PROFILE, Object.keys(assets.bundledAgentFiles), input.promptSets).agents;
5864
+ const setName = (input.profile ?? FALLBACK_PROFILE).promptSet;
5865
+ if (Object.keys(overrides).length > 0 && setName !== undefined) {
5866
+ return {
5867
+ dir: `${BUNDLED_AGENTS_DIR_LABEL}, prompt set ${setName}`,
5868
+ source: "default",
5869
+ kind: "bundled",
5870
+ files: { ...assets.bundledAgentFiles, ...overrides },
5871
+ promptSet: setName
5872
+ };
5873
+ }
5466
5874
  if (assets.mode === "compiled") {
5467
5875
  return {
5468
5876
  dir: BUNDLED_AGENTS_DIR_LABEL,
@@ -5597,7 +6005,7 @@ function agentsDirProblems(specFiles, presentFiles) {
5597
6005
  }
5598
6006
  return problems.sort();
5599
6007
  }
5600
- function resolveAgentsDir(options, loaded, assets) {
6008
+ function resolveAgentsDir(options, loaded, assets, prompts = {}) {
5601
6009
  const seat = agentsDirSeat({
5602
6010
  config: loaded.effective,
5603
6011
  sources: loaded.sources,
@@ -5609,7 +6017,8 @@ function resolveAgentsDir(options, loaded, assets) {
5609
6017
  ...seat === undefined ? {} : { config: seat },
5610
6018
  env: readBrandEnv(process.env, "AGENTS_DIR")?.value,
5611
6019
  cwd: process.cwd(),
5612
- ...assets === undefined ? {} : { assets }
6020
+ ...assets === undefined ? {} : { assets },
6021
+ ...prompts
5613
6022
  });
5614
6023
  if (resolution.kind === "dir" && !existsSync5(resolution.dir)) {
5615
6024
  throw new CliError(`agents dir does not exist: ${resolution.dir}`, {
@@ -5750,6 +6159,7 @@ function parseConfigLayer(raw, file, admitted, isRepoFile, warnings) {
5750
6159
  throw new CliUsageError(`suspicion_priors[${i}].reason required`);
5751
6160
  }
5752
6161
  }
6162
+ const profile = parseProfile(config.profile, file);
5753
6163
  const summaryParse = parseSummaryConfig(config.summary, file);
5754
6164
  const summary = summaryParse?.summary;
5755
6165
  let models = parseModels(config.models, file);
@@ -5764,9 +6174,10 @@ function parseConfigLayer(raw, file, admitted, isRepoFile, warnings) {
5764
6174
  }
5765
6175
  }
5766
6176
  if (models?.judge !== undefined) {
5767
- const { model, dropped } = judgeModelChoice(models);
6177
+ const active = resolveProfile(profile);
6178
+ const { model, dropped } = judgeModelChoice(models, active);
5768
6179
  if (dropped.length > 0) {
5769
- warnings?.push(`${file}: models.judge skips ${dropped.join(", ")}: the materiality judge runs only on claude:sonnet-latest or claude:opus-latest${model === undefined ? ", so it stands down" : ""}.`);
6180
+ warnings?.push(`${file}: models.judge skips ${dropped.join(", ")}: the materiality judge runs only on ${profileJudgeModels(active).join(" or ")}${model === undefined ? ", so it stands down" : ""}.`);
5770
6181
  }
5771
6182
  }
5772
6183
  const credentials = parseCredentialsConfig(config.credentials, file);
@@ -5797,6 +6208,7 @@ function parseConfigLayer(raw, file, admitted, isRepoFile, warnings) {
5797
6208
  ...summary === undefined ? {} : { summary },
5798
6209
  ...models === undefined ? {} : { models },
5799
6210
  ...credentials === undefined ? {} : { credentials },
6211
+ ...profile === undefined ? {} : { profile },
5800
6212
  ...maxVerificationSteps === undefined ? {} : { max_verification_steps: maxVerificationSteps },
5801
6213
  ...maxConcurrentSteps === undefined ? {} : { max_concurrent_steps: maxConcurrentSteps },
5802
6214
  ...maxChangedLines === undefined ? {} : { max_changed_lines: maxChangedLines },
@@ -5815,6 +6227,15 @@ function parseConfigLayer(raw, file, admitted, isRepoFile, warnings) {
5815
6227
  ...ciAdmissionObserveOnly === undefined ? {} : { ci_admission_observe_only: ciAdmissionObserveOnly }
5816
6228
  };
5817
6229
  }
6230
+ function parseProfile(value, file) {
6231
+ if (value === undefined)
6232
+ return;
6233
+ const problem = profileIdProblem(value);
6234
+ if (problem === undefined)
6235
+ return value;
6236
+ const got = typeof value === "string" ? ` (got "${redactConfigValue(value)}")` : "";
6237
+ throw new CliUsageError(`${file} ${problem}${got}`);
6238
+ }
5818
6239
  function parseModels(value, file) {
5819
6240
  if (value === undefined)
5820
6241
  return;
@@ -5998,6 +6419,7 @@ function mergeConfig(global, repo) {
5998
6419
  const postMinSeverity = foldKey(layers, CONFIG_DIRECTION.post_min_severity, (layer) => layer.post_min_severity);
5999
6420
  const models = foldKey(layers, CONFIG_DIRECTION.models, (layer) => layer.models);
6000
6421
  const credentials = foldKey(layers, CONFIG_DIRECTION.credentials, (layer) => layer.credentials);
6422
+ const profile = foldKey(layers, CONFIG_DIRECTION.profile, (layer) => layer.profile);
6001
6423
  const ciReviewPolicy = foldKey(layers, CONFIG_DIRECTION.ci_review_policy, (layer) => layer.ci_review_policy);
6002
6424
  const ciMaxAttempts = foldKey(layers, CONFIG_DIRECTION.ci_max_attempts, (layer) => layer.ci_max_attempts);
6003
6425
  const ciMaxReviews = foldKey(layers, CONFIG_DIRECTION.ci_max_reviews, (layer) => layer.ci_max_reviews);
@@ -6017,6 +6439,7 @@ function mergeConfig(global, repo) {
6017
6439
  ...summaryEnabled.value === undefined ? {} : { summary },
6018
6440
  ...models.value === undefined ? {} : { models: models.value },
6019
6441
  ...credentials.value === undefined ? {} : { credentials: credentials.value },
6442
+ ...profile.value === undefined ? {} : { profile: profile.value },
6020
6443
  ...maxSteps.value === undefined ? {} : { max_verification_steps: maxSteps.value },
6021
6444
  ...maxConcurrentSteps.value === undefined ? {} : { max_concurrent_steps: maxConcurrentSteps.value },
6022
6445
  ...maxLines.value === undefined ? {} : { max_changed_lines: maxLines.value },
@@ -6042,6 +6465,7 @@ function mergeConfig(global, repo) {
6042
6465
  summary: { enabled: summaryEnabled.source },
6043
6466
  models: models.source,
6044
6467
  credentials: credentials.source,
6468
+ profile: profile.source,
6045
6469
  max_verification_steps: maxSteps.source,
6046
6470
  max_concurrent_steps: maxConcurrentSteps.source,
6047
6471
  max_changed_lines: maxLines.source,
@@ -6211,12 +6635,14 @@ function gotchasErrorMessage(gotchasPath, reason, present) {
6211
6635
  ].join(`
6212
6636
  `);
6213
6637
  }
6214
- var DEFAULT_HOP_BUDGET = 12, DEFAULT_WATCH_INTERVAL_MIN = 15, DEFAULT_GC_INTERVAL_MIN = 360, DEFAULT_HEAD_REF = "HEAD", DEFAULT_SUMMARY_MODEL = "haiku", HELP_TEXT, VALUE_FLAGS, BUNDLED_AGENTS_DIR_LABEL = "bundled default (from engine)", AGENT_FILE_PATTERNS, RETIRED_AGENT_HINTS, CONFIG_DIRECTION, SUMMARY_DIRECTION, CLAUDE_CREDENTIAL_KINDS, EMPTY_LOCAL_CONFIG, KNOWN_CONFIG_KEYS, PERSON_ONLY_KEYS, LOCAL_CONFIG_KEYS, GLOBAL_CONFIG_KEYS, REPO_CONFIG_LABEL = ".crysk/config.json", GLOBAL_CONFIG_LABEL = "~/.crysk/config.json", REMOVED_ROUTING_MESSAGE = '`routing` is gone: set models per role, e.g. `"models": {"hunter.logic": ["claude:sonnet-latest"]}`', SUMMARY_MODEL_EXAMPLE = '`"models": {"summary": ["claude:haiku-latest"]}`', SUMMARY_MODEL_INIT_VALUE = "haiku", SUMMARY_MODEL_CONVERTED, CREDENTIALS_EXAMPLE = '`"credentials": {"claude": ["subscription", "api_key"]}`', DEFAULT_MAX_VERIFICATION_STEPS = 8, GOTCHAS_PLACEHOLDER_MARKER = "human-attention-required", GOTCHAS_TEMPLATE, REVIEW_MD_TEMPLATE, SETUP_GOTCHAS_FALLBACK, RETIRED_SCAFFOLD_LINES, SCAFFOLD_BODY_LINES, NO_REVIEW_INSTRUCTIONS = "This repository provides no review instructions (no REVIEW.md or gotchas file).";
6638
+ var DEFAULT_HOP_BUDGET = 12, DEFAULT_WATCH_INTERVAL_MIN = 15, DEFAULT_GC_INTERVAL_MIN = 360, DEFAULT_HEAD_REF = "HEAD", DEFAULT_SUMMARY_MODEL, HELP_TEXT, VALUE_FLAGS, BUNDLED_AGENTS_DIR_LABEL = "bundled default (from engine)", AGENT_FILE_PATTERNS, RETIRED_AGENT_HINTS, CONFIG_DIRECTION, SUMMARY_DIRECTION, CLAUDE_CREDENTIAL_KINDS, EMPTY_LOCAL_CONFIG, KNOWN_CONFIG_KEYS, PERSON_ONLY_KEYS, LOCAL_CONFIG_KEYS, GLOBAL_CONFIG_KEYS, REPO_CONFIG_LABEL = ".crysk/config.json", GLOBAL_CONFIG_LABEL = "~/.crysk/config.json", REMOVED_ROUTING_MESSAGE = '`routing` is gone: set models per role, e.g. `"models": {"hunter.logic": ["claude:sonnet-latest"]}`', SUMMARY_MODEL_EXAMPLE = '`"models": {"summary": ["claude:haiku-latest"]}`', SUMMARY_MODEL_INIT_VALUE = "haiku", SUMMARY_MODEL_CONVERTED, CREDENTIALS_EXAMPLE = '`"credentials": {"claude": ["subscription", "api_key"]}`', DEFAULT_MAX_VERIFICATION_STEPS = 8, GOTCHAS_PLACEHOLDER_MARKER = "human-attention-required", GOTCHAS_TEMPLATE, REVIEW_MD_TEMPLATE, SETUP_GOTCHAS_FALLBACK, RETIRED_SCAFFOLD_LINES, SCAFFOLD_BODY_LINES, NO_REVIEW_INSTRUCTIONS = "This repository provides no review instructions (no REVIEW.md or gotchas file).";
6215
6639
  var init_preflight2 = __esm(() => {
6216
6640
  init_review_policy();
6217
6641
  init_model_name();
6642
+ init_profiles();
6218
6643
  init_routing();
6219
6644
  init_post_floor();
6645
+ init_prompt_set();
6220
6646
  init_spec();
6221
6647
  init_triage();
6222
6648
  init_assets();
@@ -6225,6 +6651,7 @@ var init_preflight2 = __esm(() => {
6225
6651
  init_errors();
6226
6652
  init_redact();
6227
6653
  init_size_gate();
6654
+ DEFAULT_SUMMARY_MODEL = profileModelAlias(profileRoute(FALLBACK_PROFILE, "summary").model);
6228
6655
  HELP_TEXT = `crysk \u2014 multi-agent review of a real repo + branch
6229
6656
 
6230
6657
  Usage:
@@ -6514,7 +6941,15 @@ questions; use it first.
6514
6941
  The size gate is a COST gate, not a quality gate: past its limits a diff bills
6515
6942
  several times more with a much wider spread, so Crysk skips it unattended
6516
6943
  rather than guess at the bill. An interactive run asks first. It says nothing
6517
- about how well a large diff reviews.`;
6944
+ about how well a large diff reviews.
6945
+
6946
+ Exit codes of a review (findings never change them):
6947
+ 0 the review is complete, with or without findings
6948
+ 1 no usable review: every hunter failed, no reviewer ran, or findings
6949
+ that should have been posted were dropped
6950
+ 2 usage error
6951
+ 3 the review is incomplete: a step failed (a hunter, the refuter,
6952
+ verify, adjudicate, or the time ceiling). Run it again.`;
6518
6953
  VALUE_FLAGS = new Set([
6519
6954
  "--repo",
6520
6955
  "--base",
@@ -6558,6 +6993,7 @@ about how well a large diff reviews.`;
6558
6993
  summary: "capped",
6559
6994
  models: "person",
6560
6995
  credentials: "person",
6996
+ profile: "person",
6561
6997
  max_verification_steps: "capped",
6562
6998
  max_concurrent_steps: "capped",
6563
6999
  max_changed_lines: "capped",
@@ -6584,7 +7020,7 @@ about how well a large diff reviews.`;
6584
7020
  suspicion_priors: []
6585
7021
  };
6586
7022
  KNOWN_CONFIG_KEYS = new Set(Object.keys(CONFIG_DIRECTION));
6587
- PERSON_ONLY_KEYS = new Set(["models", "credentials"]);
7023
+ PERSON_ONLY_KEYS = new Set(["models", "credentials", "profile"]);
6588
7024
  LOCAL_CONFIG_KEYS = new Set(Object.keys(CONFIG_DIRECTION).filter((key) => !PERSON_ONLY_KEYS.has(key)));
6589
7025
  GLOBAL_CONFIG_KEYS = new Set(Object.keys(CONFIG_DIRECTION).filter((key) => CONFIG_DIRECTION[key] !== "repo"));
6590
7026
  SUMMARY_MODEL_CONVERTED = ["claude:haiku-latest"];
@@ -7693,6 +8129,7 @@ init_findings_conformance();
7693
8129
  // src/review/pipeline.ts
7694
8130
  init_materiality();
7695
8131
  init_catalog();
8132
+ init_profiles();
7696
8133
  init_routing();
7697
8134
  import { existsSync as existsSync13 } from "fs";
7698
8135
  import { chmod, mkdir as mkdir8, realpath as realpath4 } from "fs/promises";
@@ -8873,77 +9310,7 @@ function enforcePlanInvariants(plan, findings, stats) {
8873
9310
  // src/review/pipeline.ts
8874
9311
  init_findings();
8875
9312
  init_materiality_gate();
8876
-
8877
- // src/review/prompt-set.ts
8878
- init_catalog();
8879
- init_boundary();
8880
- var AGENT_NAMES = [
8881
- "deep-review-reliability",
8882
- "deep-review-resilience",
8883
- "deep-review-parity",
8884
- "review-refuter"
8885
- ];
8886
- function parseAgentSource(raw) {
8887
- const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
8888
- if (!match?.[1] || match[2] === undefined) {
8889
- throw new Error("agent file has no frontmatter block");
8890
- }
8891
- const [, frontmatter, body] = match;
8892
- const field = (key) => {
8893
- const line = frontmatter.split(`
8894
- `).find((l) => l.startsWith(`${key}:`));
8895
- return line?.slice(key.length + 1).trim().replace(/^"|"$/g, "");
8896
- };
8897
- const name = field("name");
8898
- if (!name)
8899
- throw new Error("agent file has no name field");
8900
- const tools = field("tools");
8901
- const model = field("model");
8902
- const effort = field("effort");
8903
- if (effort !== undefined && !isEffort(effort)) {
8904
- throw new Error(`agent file declares effort "${effort}"; expected one of ${EFFORT_LEVELS.join(", ")}`);
8905
- }
8906
- return {
8907
- name,
8908
- description: field("description") ?? name,
8909
- tools: tools ? tools.split(",").map((t) => t.trim()) : [],
8910
- ...model ? { model } : {},
8911
- ...effort === undefined ? {} : { effort },
8912
- body: body.trim()
8913
- };
8914
- }
8915
- async function parseAgentFile(filePath) {
8916
- const raw = await Bun.file(filePath).text();
8917
- try {
8918
- return parseAgentSource(raw);
8919
- } catch (error) {
8920
- throw new Error(`${filePath}: ${error instanceof Error ? error.message : String(error)}`);
8921
- }
8922
- }
8923
- function renderPriorsBlock(priors) {
8924
- return priors.map((p) => `- ${p.path} (weight ${p.weight}): ${p.reason}`).join(`
8925
- `);
8926
- }
8927
- function renderAgentBody(body, context) {
8928
- const priors = wrapBlock("priors", context.nonce, renderPriorsBlock(context.priors));
8929
- const gotchas = wrapBlock("gotchas", context.nonce, context.gotchas);
8930
- return body.replaceAll("{{PRIORS}}", () => priors).replaceAll("{{GOTCHAS}}", () => gotchas);
8931
- }
8932
- async function promptSetFingerprint(files) {
8933
- const hasher = new Bun.CryptoHasher("sha256");
8934
- for (const file of files) {
8935
- hasher.update(await Bun.file(file).text());
8936
- }
8937
- return hasher.digest("hex").slice(0, 16);
8938
- }
8939
- async function promptSetIdentity(agentsDir, files, name) {
8940
- return {
8941
- name: name ?? agentsDir.replace(/\/+$/, "").split("/").pop() ?? agentsDir,
8942
- sha256: await promptSetFingerprint(files)
8943
- };
8944
- }
8945
-
8946
- // src/review/pipeline.ts
9313
+ init_prompt_set();
8947
9314
  init_spec();
8948
9315
  init_assets();
8949
9316
 
@@ -9434,6 +9801,7 @@ function buildDiversityPlan(input) {
9434
9801
  logicalModel: model,
9435
9802
  model: parsed.canonical,
9436
9803
  routeFingerprint: stepRoute.routeFingerprint,
9804
+ route: stepRoute.route,
9437
9805
  executionKey,
9438
9806
  stepKey
9439
9807
  });
@@ -9712,6 +10080,14 @@ function recordDiversityHunterFailure(ledger, plan, agent) {
9712
10080
  };
9713
10081
  return appendAttempt(ledger, attempt);
9714
10082
  }
10083
+ function provenanceRoute(leg, executedRoute) {
10084
+ if (executedRoute !== undefined)
10085
+ return executedRoute;
10086
+ if (leg.route.backend !== "claude-code") {
10087
+ throw new DiversityAdmissionError(`no executed route for ${leg.route.backend} leg ${leg.legId}`);
10088
+ }
10089
+ return leg.route;
10090
+ }
9715
10091
  function recordDiversityHunterResult(ledger, plan, agent, result, leg, executedRoute) {
9716
10092
  const resolvedLeg = leg ?? legForAgent(plan, agent);
9717
10093
  if (!resolvedLeg) {
@@ -9740,12 +10116,7 @@ function recordDiversityHunterResult(ledger, plan, agent, result, leg, executedR
9740
10116
  if (result.status !== "ok")
9741
10117
  return next;
9742
10118
  const terminalAttemptId = `${resolvedLeg.legId}-a${totalAttempts}`;
9743
- const routeProvenance = executedRoute ?? {
9744
- backend: "claude-code",
9745
- provider: "anthropic",
9746
- modelFamily: resolvedLeg.model.split("/")[0] ?? "unknown",
9747
- modelSnapshot: resolvedLeg.model
9748
- };
10119
+ const routeProvenance = provenanceRoute(resolvedLeg, executedRoute);
9749
10120
  const output = result.output;
9750
10121
  const findings = output?.findings ?? [];
9751
10122
  for (const [index, finding] of findings.entries()) {
@@ -10818,6 +11189,52 @@ import {
10818
11189
  } from "fs";
10819
11190
  import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
10820
11191
  import path18 from "path";
11192
+
11193
+ // src/security/oauth-providers.ts
11194
+ var OAUTH_PROVIDERS = [
11195
+ {
11196
+ id: "openai",
11197
+ rotatesRefreshToken: true,
11198
+ refresh: {
11199
+ tokenUrl: "https://auth.openai.com/oauth/token",
11200
+ clientId: "app_EMoamEEZ73f0CkXaXp7hrann"
11201
+ },
11202
+ permanentErrors: [
11203
+ "refresh_token_reused",
11204
+ "refresh_token_expired",
11205
+ "refresh_token_invalidated",
11206
+ "invalid_grant"
11207
+ ],
11208
+ accountId: {
11209
+ recordField: "accountId",
11210
+ tokens: ["id_token", "access_token"],
11211
+ claims: [
11212
+ ["chatgpt_account_id"],
11213
+ ["https://api.openai.com/auth", "chatgpt_account_id"],
11214
+ ["organizations", 0, "id"]
11215
+ ]
11216
+ }
11217
+ }
11218
+ ];
11219
+ function oauthProvider(id) {
11220
+ return OAUTH_PROVIDERS.find((provider) => provider.id === id);
11221
+ }
11222
+ var REVIEW_EXPIRY_MARGIN_MS = 2 * 60 * 60 * 1000;
11223
+ function recordExpiresAt(record) {
11224
+ if (typeof record !== "object" || record === null)
11225
+ return;
11226
+ const expires = record.expires;
11227
+ return typeof expires === "number" && Number.isFinite(expires) ? expires : undefined;
11228
+ }
11229
+ function reviewCopyOfRecord(providerId, record) {
11230
+ if (oauthProvider(providerId)?.rotatesRefreshToken !== true)
11231
+ return record;
11232
+ if (!("refresh" in record))
11233
+ return record;
11234
+ return { ...record, refresh: "" };
11235
+ }
11236
+
11237
+ // src/security/credential-broker.ts
10821
11238
  var CLAUDE_CREDENTIALS_KEYCHAIN_SERVICE = "Claude Code-credentials";
10822
11239
  var SECURITY_BIN = "/usr/bin/security";
10823
11240
 
@@ -10986,7 +11403,11 @@ class OpenCodeAuthBroker {
10986
11403
  if (!lookup.ok) {
10987
11404
  throw new CredentialProjectionError(lookup.failureClass);
10988
11405
  }
10989
- return buildOpenCodeProjection(input.kind, OPENCODE_OAUTH_PROVIDER, lookup.record);
11406
+ const expiresAt = recordExpiresAt(lookup.record);
11407
+ if (expiresAt !== undefined && expiresAt <= Date.now()) {
11408
+ throw new CredentialProjectionError("subscription_expiring");
11409
+ }
11410
+ return buildOpenCodeProjection(input.kind, OPENCODE_OAUTH_PROVIDER, reviewCopyOfRecord(OPENCODE_OAUTH_PROVIDER, lookup.record));
10990
11411
  }
10991
11412
  }
10992
11413
  async function lookupOpenCodeOAuthRecord(readerFn) {
@@ -11492,6 +11913,7 @@ class WorkspaceReadBroker {
11492
11913
  }
11493
11914
 
11494
11915
  // src/transport-registry.ts
11916
+ init_crysk_secrets();
11495
11917
  import { readFile as readFile4 } from "fs/promises";
11496
11918
  import os2 from "os";
11497
11919
  import path21 from "path";
@@ -13186,6 +13608,7 @@ class OpenCodeSdkTransport {
13186
13608
  cancellationSemantics = "provider-proof";
13187
13609
  credentialProjection = "server-lifetime";
13188
13610
  defaultRoute;
13611
+ failureCredential;
13189
13612
  client;
13190
13613
  stallDeadlineMs;
13191
13614
  abortConfirmMs;
@@ -13211,6 +13634,7 @@ class OpenCodeSdkTransport {
13211
13634
  };
13212
13635
  this.cancellationSemantics = "provider-proof";
13213
13636
  this.defaultRoute = options.defaultRoute;
13637
+ this.failureCredential = options.failureCredential;
13214
13638
  this.client = options.client;
13215
13639
  this.stallDeadlineMs = options.stallDeadlineMs ?? DEFAULT_STALL_DEADLINE_MS;
13216
13640
  this.abortConfirmMs = options.abortConfirmMs ?? SDK_ABORT_CONFIRM_MS;
@@ -13281,7 +13705,7 @@ class OpenCodeSdkTransport {
13281
13705
  };
13282
13706
  }
13283
13707
  async execute(request, context) {
13284
- const outcome = await this.executeAttempt(request, context);
13708
+ const outcome = this.withFailureCredential(await this.executeAttempt(request, context));
13285
13709
  try {
13286
13710
  const diagnosticEvidence = this.client.takeEvidence?.(request.sessionId, request.attempt);
13287
13711
  return diagnosticEvidence ? { ...outcome, diagnosticEvidence } : outcome;
@@ -13289,6 +13713,9 @@ class OpenCodeSdkTransport {
13289
13713
  return outcome;
13290
13714
  }
13291
13715
  }
13716
+ withFailureCredential(outcome) {
13717
+ return outcome.completion === "failed" && this.failureCredential !== undefined ? { ...outcome, failureCredential: this.failureCredential } : outcome;
13718
+ }
13292
13719
  async executeAttempt(request, context) {
13293
13720
  const notes = [];
13294
13721
  const diagnostics = [];
@@ -14045,6 +14472,9 @@ class OpenCodeSdkTransport {
14045
14472
  if (witness.includes(MARKER_PROVIDER_REFUSAL) && providerRefusalStatus(witness) === "404") {
14046
14473
  return "model_unavailable";
14047
14474
  }
14475
+ if (witness.includes(MARKER_PROVIDER_REFUSAL) && providerRefusalStatus(witness) === "401") {
14476
+ return "auth_invalid";
14477
+ }
14048
14478
  if (witness.includes(MARKER_PROVIDER_REFUSAL)) {
14049
14479
  return providerRefusalRetries(witness) === true ? "network_transient" : "runtime_unavailable";
14050
14480
  }
@@ -16062,6 +16492,14 @@ function checkD1_11Readiness(evidence) {
16062
16492
  missing
16063
16493
  };
16064
16494
  }
16495
+ function openCodeFailureCredential(provider, kind) {
16496
+ if (provider === undefined)
16497
+ return;
16498
+ const secretKind = kind === "opencode_chatgpt_oauth" ? "oauth" : kind === "provider_api_token" ? "api_key" : undefined;
16499
+ if (secretKind === undefined)
16500
+ return;
16501
+ return opencodeSecretName(provider, secretKind);
16502
+ }
16065
16503
 
16066
16504
  class DefaultTransportRegistry {
16067
16505
  factories = new Map;
@@ -16111,12 +16549,15 @@ class DefaultTransportRegistry {
16111
16549
  provider: route?.provider ?? "opencode"
16112
16550
  };
16113
16551
  const defaultRoute = route;
16552
+ const failureCredential = openCodeFailureCredential(route?.provider, merged.credentialKind);
16553
+ const credentialOption = failureCredential === undefined ? {} : { failureCredential };
16114
16554
  if (merged.openCodeClient) {
16115
16555
  return new OpenCodeSdkTransport({
16116
16556
  client: merged.openCodeClient,
16117
16557
  billingMode: usageBillingMode,
16118
16558
  admissionIdentity,
16119
- defaultRoute
16559
+ defaultRoute,
16560
+ ...credentialOption
16120
16561
  });
16121
16562
  }
16122
16563
  const codegraphBinaryPath = merged.codegraphBinaryPath ?? Bun.which("codegraph") ?? undefined;
@@ -16149,7 +16590,8 @@ class DefaultTransportRegistry {
16149
16590
  client,
16150
16591
  billingMode: usageBillingMode,
16151
16592
  admissionIdentity,
16152
- defaultRoute
16593
+ defaultRoute,
16594
+ ...credentialOption
16153
16595
  });
16154
16596
  });
16155
16597
  }
@@ -18891,6 +19333,43 @@ function refuterPrompt(batchJson, nonce) {
18891
19333
  function agentPromptPath(input, file) {
18892
19334
  return agentFilePath(input.agentFiles ? { kind: "bundled", dir: input.agentsDir, files: input.agentFiles } : { kind: "dir", dir: input.agentsDir }, file);
18893
19335
  }
19336
+ function activeProfile(input) {
19337
+ return input.modelProfile ?? FALLBACK_PROFILE;
19338
+ }
19339
+ function agentPromptChoice(input, agent, parsed) {
19340
+ if (input.bundledAgents !== true) {
19341
+ return {
19342
+ ...parsed.model === undefined ? {} : { model: parsed.model },
19343
+ ...parsed.effort === undefined ? {} : { effort: parsed.effort }
19344
+ };
19345
+ }
19346
+ const role = agentModelRole(agent);
19347
+ if (role === undefined)
19348
+ return {};
19349
+ const route = profileRoute(activeProfile(input), role);
19350
+ return {
19351
+ model: profileModelAlias(route.model),
19352
+ effort: profileRoleEffort(activeProfile(input), role)
19353
+ };
19354
+ }
19355
+ function agentRoleEffort(input, agent) {
19356
+ const role = agentModelRole(agent);
19357
+ return role === undefined ? defaultEffortForRole("other") : profileRoleEffort(activeProfile(input), role);
19358
+ }
19359
+ function enginePromptChoice(input, prompt, role, parsed, profileFallback) {
19360
+ const route = profileRoute(activeProfile(input), role);
19361
+ if (prompt.bundled === true) {
19362
+ return {
19363
+ model: profileModelAlias(route.model),
19364
+ effort: profileRoleEffort(activeProfile(input), role)
19365
+ };
19366
+ }
19367
+ const model = parsed.model ?? (profileFallback ? profileModelAlias(route.model) : undefined);
19368
+ return {
19369
+ ...model === undefined ? {} : { model },
19370
+ ...parsed.effort === undefined ? {} : { effort: parsed.effort }
19371
+ };
19372
+ }
18894
19373
  function triggerPatterns(agent, input) {
18895
19374
  return agent.trigger === "input" ? input.parityTriggerPaths : agent.trigger ?? [];
18896
19375
  }
@@ -19016,21 +19495,21 @@ async function execute(input, deps, state) {
19016
19495
  let routePlan = input.routePlan;
19017
19496
  if (!routePlan) {
19018
19497
  let summarizerFrontmatter;
19019
- if (input.summarizer) {
19498
+ if (input.summarizer && input.summarizer.bundled !== true) {
19020
19499
  try {
19021
19500
  const parsed = await parseAgentFile(input.summarizer.promptPath);
19022
19501
  summarizerFrontmatter = parsed.model;
19023
19502
  } catch {}
19024
19503
  }
19025
19504
  let scoutFrontmatter;
19026
- if (input.scout) {
19505
+ if (input.scout && input.scout.bundled !== true) {
19027
19506
  try {
19028
19507
  const parsed = await parseAgentFile(input.scout.promptPath);
19029
19508
  scoutFrontmatter = parsed.model;
19030
19509
  } catch {}
19031
19510
  }
19032
19511
  let consolidateFrontmatter;
19033
- if (input.consolidate) {
19512
+ if (input.consolidate && input.consolidate.bundled !== true) {
19034
19513
  try {
19035
19514
  const parsed = await parseAgentFile(input.consolidate.promptPath);
19036
19515
  consolidateFrontmatter = parsed.model;
@@ -19041,25 +19520,28 @@ async function execute(input, deps, state) {
19041
19520
  agents: diversityCtx.routeAgents,
19042
19521
  cliModel: input.model,
19043
19522
  models: effectiveModels,
19523
+ profile: activeProfile(input),
19524
+ ...input.bundledAgents === true ? { bundledAgents: true } : {},
19044
19525
  frontmatterModel: (agentKey) => frontmatterByKey.get(agentKey),
19045
19526
  ...input.summarizer === undefined ? {} : {
19046
19527
  summarizer: {
19047
19528
  model: input.summarizer.model,
19048
- frontmatterModel: summarizerFrontmatter
19529
+ frontmatterModel: summarizerFrontmatter,
19530
+ bundled: input.summarizer.bundled === true
19049
19531
  }
19050
19532
  },
19051
19533
  ...input.scout === undefined ? {} : {
19052
19534
  scout: {
19053
19535
  model: input.scout.model,
19054
19536
  frontmatterModel: scoutFrontmatter,
19055
- defaultModel: DEFAULT_SCOUT_MODEL
19537
+ bundled: input.scout.bundled === true
19056
19538
  }
19057
19539
  },
19058
19540
  ...input.consolidate === undefined ? {} : {
19059
19541
  consolidate: {
19060
19542
  model: input.consolidate.model,
19061
19543
  frontmatterModel: consolidateFrontmatter,
19062
- defaultModel: DEFAULT_CONSOLIDATE_MODEL
19544
+ bundled: input.consolidate.bundled === true
19063
19545
  }
19064
19546
  },
19065
19547
  ...input.materiality === undefined ? {} : { materiality: true }
@@ -19112,6 +19594,7 @@ async function execute(input, deps, state) {
19112
19594
  const hunterSpecs = [];
19113
19595
  for (const hunter of huntersAdmitted ? hunters : []) {
19114
19596
  const agent = await parseAgentFile(agentPromptPath(input, hunter.file));
19597
+ const prompt = agentPromptChoice(input, hunter, agent);
19115
19598
  const name = `hunter-${hunter.key}`;
19116
19599
  const systemPromptPath = path24.join(stepsDir, `${name}.system.md`);
19117
19600
  const shared = input.sharedPrefix === true && routeSharesPrefix(routeForStepKey(routePlan, name));
@@ -19139,8 +19622,8 @@ ${sharedBlock}`);
19139
19622
  ${SHARED_PREFIX_CLOSING}` : sharedBlock,
19140
19623
  tools: agent.tools,
19141
19624
  mcpConfigPath: input.mcpConfigPath,
19142
- model: resolveModel(input, hunter.model, agent.model, hunter.file),
19143
- ...stepEffortFields(routePlan, name, agent.effort, defaultEffortForRole("hunter")),
19625
+ model: resolveModel(input, hunter.model, prompt.model, hunter.file),
19626
+ ...stepEffortFields(routePlan, name, prompt.effort, agentRoleEffort(input, hunter)),
19144
19627
  cwd: input.worktree,
19145
19628
  outPath: path24.join(stepsDir, `${name}.draft.json`),
19146
19629
  timeoutMs: stepTimeoutMs,
@@ -19179,7 +19662,7 @@ ${SHARED_PREFIX_CLOSING}` : sharedBlock,
19179
19662
  summarizerMeta = {
19180
19663
  name,
19181
19664
  model: input.summarizer.model ?? input.model ?? "unresolved",
19182
- effort: defaultEffortForRole("summarizer"),
19665
+ effort: profileRoleEffort(activeProfile(input), "summary"),
19183
19666
  tools: [],
19184
19667
  systemPromptPath,
19185
19668
  outPath,
@@ -19188,8 +19671,9 @@ ${SHARED_PREFIX_CLOSING}` : sharedBlock,
19188
19671
  try {
19189
19672
  const agent = await parseAgentFile(input.summarizer.promptPath);
19190
19673
  await writeSystemPrompt(systemPromptPath, agent.body);
19191
- summarizerMeta.model = resolveModel(input, input.summarizer.model, agent.model, input.summarizer.promptPath);
19192
- const summarizerEffort = stepEffortFields(routePlan, name, agent.effort, defaultEffortForRole("summarizer"));
19674
+ const own = enginePromptChoice(input, input.summarizer, "summary", agent, false);
19675
+ summarizerMeta.model = resolveModel(input, input.summarizer.model, own.model, input.summarizer.promptPath);
19676
+ const summarizerEffort = stepEffortFields(routePlan, name, own.effort, profileRoleEffort(activeProfile(input), "summary"));
19193
19677
  summarizerMeta.effort = summarizerEffort.effort;
19194
19678
  summarizerMeta.tools = agent.tools;
19195
19679
  summarizerSpec = {
@@ -19540,8 +20024,9 @@ async function runRefuter(input, deps, state, batch, options) {
19540
20024
  gotchas: state.reviewInstructions ?? NO_REVIEW_INSTRUCTIONS,
19541
20025
  nonce: options.nonce
19542
20026
  }));
19543
- const model = resolveModel(input, options.agent.model, agent.model, options.agent.file);
19544
- const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), agent.effort, defaultEffortForRole("refuter"));
20027
+ const prompt = agentPromptChoice(input, options.agent, agent);
20028
+ const model = resolveModel(input, options.agent.model, prompt.model, options.agent.file);
20029
+ const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), prompt.effort, agentRoleEffort(input, options.agent));
19545
20030
  const forged = [];
19546
20031
  const specs = [];
19547
20032
  for (const survivor of batch) {
@@ -19663,8 +20148,9 @@ async function runVerify(input, deps, state, queued, options) {
19663
20148
  gotchas: state.reviewInstructions ?? NO_REVIEW_INSTRUCTIONS,
19664
20149
  nonce: options.nonce
19665
20150
  }));
19666
- const model = resolveModel(input, options.agent.model, agent.model, options.agent.file);
19667
- const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), agent.effort, defaultEffortForRole("verifier"));
20151
+ const prompt = agentPromptChoice(input, options.agent, agent);
20152
+ const model = resolveModel(input, options.agent.model, prompt.model, options.agent.file);
20153
+ const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), prompt.effort, defaultEffortForRole("verifier"));
19668
20154
  const forged = [];
19669
20155
  const specs = [];
19670
20156
  for (const subject of subjects) {
@@ -19789,8 +20275,9 @@ async function runAdjudicate(input, deps, state, queue, options) {
19789
20275
  const agent = await parseAgentFile(agentPromptPath(input, options.agent.file));
19790
20276
  const systemPromptPath = path24.join(options.stepsDir, "adjudicator.system.md");
19791
20277
  await writeSystemPrompt(systemPromptPath, body);
19792
- const model = resolveModel(input, options.agent.model, agent.model, options.agent.file);
19793
- const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), agent.effort, defaultEffortForRole("refuter"));
20278
+ const prompt = agentPromptChoice(input, options.agent, agent);
20279
+ const model = resolveModel(input, options.agent.model, prompt.model, options.agent.file);
20280
+ const effortFields = stepEffortFields(state.routePlan, agentStepKey(options.agent), prompt.effort, agentRoleEffort(input, options.agent));
19794
20281
  const specs = [];
19795
20282
  for (const [index, subject] of queue.entries()) {
19796
20283
  const prompt = composeAdjudicationPrompt(subject, options.nonce);
@@ -19865,7 +20352,7 @@ async function runAdjudicate(input, deps, state, queue, options) {
19865
20352
  return outcomes;
19866
20353
  }
19867
20354
  var SCOUT_TIMEOUT_MS = 15 * 60 * 1000;
19868
- var DEFAULT_SCOUT_MODEL = "sonnet";
20355
+ var DEFAULT_SCOUT_MODEL = profileModelAlias(profileRoute(FALLBACK_PROFILE, "scout").model);
19869
20356
  async function runScout(input, deps, state, patch, stepsDir, nonce) {
19870
20357
  if (!input.scout) {
19871
20358
  state.scout = {
@@ -19884,7 +20371,7 @@ async function runScout(input, deps, state, patch, stepsDir, nonce) {
19884
20371
  const meta = {
19885
20372
  name,
19886
20373
  model: input.scout.model ?? input.model ?? "unresolved",
19887
- effort: defaultEffortForRole("scout"),
20374
+ effort: profileRoleEffort(activeProfile(input), "scout"),
19888
20375
  tools: [],
19889
20376
  systemPromptPath,
19890
20377
  outPath,
@@ -19921,9 +20408,10 @@ async function runScout(input, deps, state, patch, stepsDir, nonce) {
19921
20408
  const raw = await Bun.file(input.scout.promptPath).text();
19922
20409
  const agent = parseAgentSource(raw);
19923
20410
  await writeSystemPrompt(systemPromptPath, agent.body);
19924
- meta.model = resolveModel(input, input.scout.model, agent.model ?? DEFAULT_SCOUT_MODEL, input.scout.promptPath);
20411
+ const own = enginePromptChoice(input, input.scout, "scout", agent, true);
20412
+ meta.model = resolveModel(input, input.scout.model, own.model, input.scout.promptPath);
19925
20413
  record.model = meta.model;
19926
- const scoutEffort = stepEffortFields(state.routePlan, name, agent.effort, defaultEffortForRole("scout"));
20414
+ const scoutEffort = stepEffortFields(state.routePlan, name, own.effort, profileRoleEffort(activeProfile(input), "scout"));
19927
20415
  meta.effort = scoutEffort.effort;
19928
20416
  record.prompt_sha256 = new Bun.CryptoHasher("sha256").update(raw).digest("hex");
19929
20417
  spec = {
@@ -19994,8 +20482,6 @@ async function runScout(input, deps, state, patch, stepsDir, nonce) {
19994
20482
  }
19995
20483
  var CONSOLIDATE_TIMEOUT_MS = 10 * 60 * 1000;
19996
20484
  var CONSOLIDATE_MAX_ATTEMPTS = 2;
19997
- var DEFAULT_CONSOLIDATE_MODEL = "sonnet";
19998
- var DEFAULT_CONSOLIDATE_EFFORT = "high";
19999
20485
  function ceilingGraceMs(input) {
20000
20486
  return input.ceilingGraceMs ?? DEFAULT_CANCELLATION_DEADLINE_MS + HARNESS_GRACE_MARGIN_MS;
20001
20487
  }
@@ -20091,9 +20577,10 @@ async function runConsolidation(input, deps, state, stepsDir, nonce) {
20091
20577
  const raw = await Bun.file(input.consolidate.promptPath).text();
20092
20578
  const agent = parseAgentSource(raw);
20093
20579
  await writeSystemPrompt(systemPromptPath, agent.body);
20094
- meta.model = resolveModel(input, input.consolidate.model, agent.model ?? DEFAULT_CONSOLIDATE_MODEL, input.consolidate.promptPath);
20580
+ const own = enginePromptChoice(input, input.consolidate, "consolidate", agent, true);
20581
+ meta.model = resolveModel(input, input.consolidate.model, own.model, input.consolidate.promptPath);
20095
20582
  record.model = meta.model;
20096
- const consolidateEffort = stepEffortFields(state.routePlan, name, agent.effort, DEFAULT_CONSOLIDATE_EFFORT);
20583
+ const consolidateEffort = stepEffortFields(state.routePlan, name, own.effort, profileRoleEffort(activeProfile(input), "consolidate"));
20097
20584
  meta.effort = consolidateEffort.effort;
20098
20585
  record.prompt_sha256 = new Bun.CryptoHasher("sha256").update(raw).digest("hex");
20099
20586
  spec = {
@@ -20204,7 +20691,7 @@ async function runMaterialityJudge(input, deps, state, stepsDir, nonce) {
20204
20691
  protected: 0,
20205
20692
  failed: 0,
20206
20693
  skipped_unsafe: 0,
20207
- model: MATERIALITY_JUDGE_MODEL,
20694
+ model: profileModelAlias(profileRoute(activeProfile(input), "judge").model),
20208
20695
  duration_ms: 0
20209
20696
  };
20210
20697
  state.materiality = record;
@@ -20219,9 +20706,9 @@ async function runMaterialityJudge(input, deps, state, stepsDir, nonce) {
20219
20706
  let route;
20220
20707
  if (state.routePlan !== undefined) {
20221
20708
  route = routeForStepKey(state.routePlan, MATERIALITY_STEP_KEY);
20222
- if (route === undefined || !isMeasuredJudgeRoute(route)) {
20709
+ if (route === undefined || !isMeasuredJudgeRoute(route, activeProfile(input))) {
20223
20710
  record.status = "unsupported_route";
20224
- record.reason = route !== undefined || resolveMaterialityJudgeRoute(input.models ?? input.config?.effective?.models) === undefined ? "judge route is not the measured claude-code route" : "route plan carries no judge step";
20711
+ record.reason = route !== undefined || resolveMaterialityJudgeRoute(input.models ?? input.config?.effective?.models, activeProfile(input)) === undefined ? "judge route is not the measured claude-code route" : "route plan carries no judge step";
20225
20712
  return;
20226
20713
  }
20227
20714
  record.model = route.modelSnapshot;
@@ -20260,7 +20747,7 @@ async function runMaterialityJudge(input, deps, state, stepsDir, nonce) {
20260
20747
  return;
20261
20748
  }
20262
20749
  const prTitle = input.prTitle !== undefined && input.prTitle.trim() !== "" ? input.prTitle : MATERIALITY_TITLE_FALLBACK;
20263
- const { effort } = stepEffortFields(state.routePlan, MATERIALITY_STEP_KEY, undefined, defaultEffortForRole("other"));
20750
+ const { effort } = stepEffortFields(state.routePlan, MATERIALITY_STEP_KEY, undefined, profileRoleEffort(activeProfile(input), "judge"));
20264
20751
  const specs = [];
20265
20752
  const ownerPolicy = state.reviewInstructions === undefined || state.reviewInstructions === NO_REVIEW_INSTRUCTIONS ? undefined : ownerPolicyText(state.reviewInstructions);
20266
20753
  for (const finding of judge) {
@@ -20527,6 +21014,12 @@ async function writePipelinePlan(input, state) {
20527
21014
  parity_hunter_fired: state.parityFired,
20528
21015
  ...input.engine === undefined ? {} : { engine: input.engine },
20529
21016
  ...input.promptSet === undefined ? {} : { prompt_set: input.promptSet },
21017
+ ...activeProfile(input).promptSet === undefined ? {} : {
21018
+ profile_prompt_set: {
21019
+ profile: activeProfile(input).id,
21020
+ name: activeProfile(input).promptSet
21021
+ }
21022
+ },
20530
21023
  ...input.config === undefined ? {} : { config: input.config },
20531
21024
  ...state.routePlan === undefined ? {} : {
20532
21025
  route_plan: state.routePlan,
@@ -20778,6 +21271,7 @@ function recordStepFailure(meta, error) {
20778
21271
 
20779
21272
  // src/index.ts
20780
21273
  init_preflight2();
21274
+ init_prompt_set();
20781
21275
 
20782
21276
  // src/review/report.ts
20783
21277
  await init_preflight3();
@@ -21562,7 +22056,7 @@ function envelopeModel(options, agentFiles, routePlan) {
21562
22056
  // src/index.ts
21563
22057
  init_spec();
21564
22058
  var ENGINE_NAME = "pr-hero";
21565
- var ENGINE_VERSION = "0.5.0";
22059
+ var ENGINE_VERSION = "0.6.1";
21566
22060
  export {
21567
22061
  ACTIVE_CHILD_PROCS,
21568
22062
  ACTIVE_SERVER_CLOSERS,
@@ -21579,7 +22073,6 @@ export {
21579
22073
  DEDUPE_CLAIM_OVERLAP_THRESHOLD,
21580
22074
  DEDUPE_SYMBOL_LINE_WINDOW,
21581
22075
  DEFAULT_BASE_REF,
21582
- DEFAULT_CONSOLIDATE_MODEL,
21583
22076
  DEFAULT_GC_INTERVAL_MIN,
21584
22077
  DEFAULT_HEAD_REF,
21585
22078
  DEFAULT_HOP_BUDGET,
@@ -21594,6 +22087,7 @@ export {
21594
22087
  DraftValidationError,
21595
22088
  EMPTY_LOCAL_CONFIG,
21596
22089
  ENGINE_NAME,
22090
+ ENGINE_PROMPT_FILES,
21597
22091
  ENGINE_VERSION,
21598
22092
  FINDINGS_CONFORMANCE_CASES,
21599
22093
  FORMAT_RETRY_REMINDER,
@@ -21626,6 +22120,7 @@ export {
21626
22120
  admitOpenCodeVersionPair,
21627
22121
  admitRoutePlan,
21628
22122
  agentFilePath,
22123
+ agentModelRole,
21629
22124
  agentStepKey,
21630
22125
  agentsDirProblems,
21631
22126
  agentsDirSeat,
@@ -21689,6 +22184,7 @@ export {
21689
22184
  mergeConfig,
21690
22185
  mergeRunEnvelope,
21691
22186
  movedHeadSentence,
22187
+ openCodeFailureCredential,
21692
22188
  openCodeLaunchServerFor,
21693
22189
  ownerPolicyText,
21694
22190
  parityTriggered,
@@ -21705,6 +22201,7 @@ export {
21705
22201
  planOpenCodeSdkImport,
21706
22202
  planRoutes,
21707
22203
  preflightAgentsDir,
22204
+ profilePromptSet,
21708
22205
  promptSetFingerprint,
21709
22206
  promptSetIdentity,
21710
22207
  readInstalledOpenCodeSdkVersion,
@@ -21740,6 +22237,7 @@ export {
21740
22237
  resolveSummary,
21741
22238
  rootCauseIdByFinding,
21742
22239
  routeForModel,
22240
+ routeForStepKey,
21743
22241
  routeSharesPrefix,
21744
22242
  runDirCandidate,
21745
22243
  runPipeline,
@@ -21747,7 +22245,9 @@ export {
21747
22245
  serversShuttingDown,
21748
22246
  settlementReceiptPath,
21749
22247
  severityEmoji,
22248
+ stepEffortFields,
21750
22249
  stepFailureReason,
22250
+ stepRouteFields,
21751
22251
  sumUsage,
21752
22252
  validateDraftFinding,
21753
22253
  validateFinding,