@glrs-dev/cli 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/{chunk-HQUCVJ4G.js → chunk-FBXSGZAA.js} +4 -0
  3. package/dist/chunk-J3FXSHMA.js +263 -0
  4. package/dist/{chunk-5ZVUFNCP.js → chunk-S6N5E2GG.js} +8 -1
  5. package/dist/{chunk-2VMFXAJH.js → chunk-UO7WHIKY.js} +18 -5
  6. package/dist/cli.js +10 -3
  7. package/dist/commands/autopilot-tui.d.ts +11 -1
  8. package/dist/commands/autopilot-tui.js +2 -1
  9. package/dist/commands/autopilot.d.ts +2 -0
  10. package/dist/commands/autopilot.js +62 -21
  11. package/dist/commands/debrief.d.ts +2 -0
  12. package/dist/commands/debrief.js +1 -1
  13. package/dist/commands/loop.d.ts +2 -0
  14. package/dist/commands/loop.js +33 -12
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/node_modules/@glrs-dev/adapter-opencode/dist/index.d.ts +9 -0
  18. package/dist/node_modules/@glrs-dev/adapter-opencode/dist/index.js +33 -15
  19. package/dist/node_modules/@glrs-dev/adapter-opencode/package.json +1 -1
  20. package/dist/node_modules/@glrs-dev/autopilot/dist/auto-ship-EVLBKHUZ.js +7 -0
  21. package/dist/node_modules/@glrs-dev/autopilot/dist/{changeset-generator-DG3MVWVV.js → changeset-generator-HAHYSSUR.js} +2 -2
  22. package/dist/node_modules/@glrs-dev/autopilot/dist/{chunk-VITL2Z45.js → chunk-2X3CWH47.js} +578 -62
  23. package/dist/node_modules/@glrs-dev/autopilot/dist/{chunk-Q4ULU6ER.js → chunk-2ZQ6SBV3.js} +4 -2
  24. package/dist/node_modules/@glrs-dev/autopilot/dist/chunk-6JZQLIRP.js +781 -0
  25. package/dist/node_modules/@glrs-dev/autopilot/dist/{chunk-E7PWTRFO.js → chunk-AWRK6S6G.js} +2 -2
  26. package/dist/node_modules/@glrs-dev/autopilot/dist/{chunk-M2ZVBPWL.js → chunk-BLEIZHET.js} +1 -1
  27. package/dist/node_modules/@glrs-dev/autopilot/dist/{chunk-7OSEI5TF.js → chunk-GXXCEGDD.js} +3 -1
  28. package/dist/node_modules/@glrs-dev/autopilot/dist/chunk-S34HOCZ4.js +44 -0
  29. package/dist/node_modules/@glrs-dev/autopilot/dist/index.d.ts +159 -9
  30. package/dist/node_modules/@glrs-dev/autopilot/dist/index.js +115 -35
  31. package/dist/node_modules/@glrs-dev/autopilot/dist/{logger-UITJGIZE.js → logger-3XLFMXLN.js} +1 -1
  32. package/dist/node_modules/@glrs-dev/autopilot/dist/loop-session-YLCVJGPV.js +9 -0
  33. package/dist/node_modules/@glrs-dev/autopilot/dist/plan-enrichment-4SQYV5FC.js +17 -0
  34. package/dist/node_modules/@glrs-dev/autopilot/package.json +1 -1
  35. package/dist/vendor/harness-opencode/dist/agents/prompts/agents-md-writer.md +1 -1
  36. package/dist/vendor/harness-opencode/dist/agents/prompts/architecture-advisor.md +1 -1
  37. package/dist/vendor/harness-opencode/dist/agents/prompts/code-searcher.md +1 -1
  38. package/dist/vendor/harness-opencode/dist/agents/prompts/docs-maintainer.md +0 -8
  39. package/dist/vendor/harness-opencode/dist/agents/prompts/gap-analyzer.md +1 -3
  40. package/dist/vendor/harness-opencode/dist/agents/prompts/lib-reader.md +1 -1
  41. package/dist/vendor/harness-opencode/dist/agents/prompts/plan-reviewer.md +0 -2
  42. package/dist/vendor/harness-opencode/dist/agents/prompts/plan.md +1 -1
  43. package/dist/vendor/harness-opencode/dist/agents/prompts/prime.md +78 -262
  44. package/dist/vendor/harness-opencode/dist/agents/prompts/research.md +5 -14
  45. package/dist/vendor/harness-opencode/dist/agents/prompts/scoper.md +7 -2
  46. package/dist/vendor/harness-opencode/dist/autopilot/strategies/default.md +29 -0
  47. package/dist/vendor/harness-opencode/dist/index.js +112 -82
  48. package/dist/vendor/harness-opencode/package.json +1 -1
  49. package/package.json +1 -1
  50. package/dist/node_modules/@glrs-dev/autopilot/dist/auto-ship-LCT6LIH7.js +0 -7
  51. package/dist/node_modules/@glrs-dev/autopilot/dist/chunk-ZNJWARTM.js +0 -449
  52. package/dist/node_modules/@glrs-dev/autopilot/dist/loop-session-XKL3NHUA.js +0 -8
  53. package/dist/node_modules/@glrs-dev/autopilot/dist/plan-enrichment-D3RPJR2J.js +0 -14
@@ -2,7 +2,7 @@ import {
2
2
  hasSpec,
3
3
  readSpecGoal,
4
4
  readSpecTitle
5
- } from "./chunk-7OSEI5TF.js";
5
+ } from "./chunk-GXXCEGDD.js";
6
6
 
7
7
  // src/changeset-generator.ts
8
8
  import * as fs from "fs";
@@ -64,7 +64,7 @@ async function generateChangeset(planPath, repoRoot, opts = {}) {
64
64
  const randomSuffix = opts._randomSuffix ?? defaultRandomSuffix;
65
65
  const title = readPlanTitle(planPath) || "Autopilot run";
66
66
  const goal = readPlanGoal(planPath) || title;
67
- const bumpLevel = inferBumpLevel(title);
67
+ const bumpLevel = opts.bumpLevel ?? inferBumpLevel(title);
68
68
  const slug = slugifyTitle(title);
69
69
  const content = `---
70
70
  "${packageName}": ${bumpLevel}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hasSpec,
3
3
  readSpecTitle
4
- } from "./chunk-7OSEI5TF.js";
4
+ } from "./chunk-GXXCEGDD.js";
5
5
 
6
6
  // src/auto-ship.ts
7
7
  import { execFile as execFileCb } from "child_process";
@@ -94,7 +94,9 @@ function specItemToPlanItem(item) {
94
94
  verify: item.verify ?? "",
95
95
  ...item.mirror !== void 0 ? { mirror: item.mirror } : {},
96
96
  ...item.context !== void 0 ? { context: item.context } : {},
97
- ...item.conventions !== void 0 ? { conventions: item.conventions } : {}
97
+ ...item.conventions !== void 0 ? { conventions: item.conventions } : {},
98
+ ...item.proof !== void 0 ? { proof: item.proof } : {},
99
+ ...item.proof_type !== void 0 ? { proof_type: item.proof_type } : {}
98
100
  };
99
101
  }
100
102
  function parseSpecItems(phasePath) {
@@ -0,0 +1,44 @@
1
+ // src/model-resolver.ts
2
+ var CLAUDE_TIER_ALIASES = {
3
+ deep: "claude-opus-4-7",
4
+ prime: "claude-opus-4-7",
5
+ mid: "claude-sonnet-4-6",
6
+ "mid-execute": "claude-sonnet-4-6",
7
+ "autopilot-execute": "claude-haiku-4-5-20251001",
8
+ fast: "claude-haiku-4-5-20251001"
9
+ };
10
+ var warnedOnce = null;
11
+ function warn(message) {
12
+ if (!warnedOnce) warnedOnce = /* @__PURE__ */ new Set();
13
+ if (warnedOnce.has(message)) return;
14
+ warnedOnce.add(message);
15
+ console.warn(`[model-resolver] ${message}`);
16
+ }
17
+ function resolveModel(specifier, adapterName, opencodeTiers) {
18
+ if (specifier.includes("/")) {
19
+ return specifier;
20
+ }
21
+ if (adapterName === "claude-code-cli") {
22
+ if (specifier in CLAUDE_TIER_ALIASES) {
23
+ return CLAUDE_TIER_ALIASES[specifier];
24
+ }
25
+ return specifier;
26
+ }
27
+ if (!opencodeTiers) {
28
+ return specifier;
29
+ }
30
+ const resolved = opencodeTiers[specifier];
31
+ if (resolved !== void 0) {
32
+ return Array.isArray(resolved) ? resolved[0] : resolved;
33
+ }
34
+ const fallback = opencodeTiers["deep"];
35
+ if (fallback !== void 0) {
36
+ warn(`Unknown tier "${specifier}"; falling back to "deep"`);
37
+ return Array.isArray(fallback) ? fallback[0] : fallback;
38
+ }
39
+ return specifier;
40
+ }
41
+
42
+ export {
43
+ resolveModel
44
+ };
@@ -22,9 +22,11 @@ interface AgentAdapter {
22
22
  readonly name: string;
23
23
  start(opts: {
24
24
  cwd: string;
25
+ agents?: Record<string, unknown>;
25
26
  }): Promise<AgentHandle>;
26
27
  createSession(handle: AgentHandle, opts: {
27
28
  agentName?: string;
29
+ model?: string;
28
30
  }): Promise<string>;
29
31
  sendAndWait(handle: AgentHandle, opts: {
30
32
  sessionId: string;
@@ -68,6 +70,8 @@ interface SessionStartEvent {
68
70
  resume: boolean;
69
71
  enrichModel?: string;
70
72
  executeModel?: string;
73
+ adapter?: string;
74
+ branch?: string;
71
75
  }
72
76
  interface SessionDoneEvent {
73
77
  type: "session:done";
@@ -305,6 +309,8 @@ interface PlanItem {
305
309
  tests: string[];
306
310
  verify: string;
307
311
  checked: boolean;
312
+ proof?: string;
313
+ proof_type?: string;
308
314
  }
309
315
  /**
310
316
  * Parse a plan at the given path and return structured progress data.
@@ -338,10 +344,13 @@ declare function parseItems(content: string): PlanItem[];
338
344
  *
339
345
  * Each command runs via `/bin/sh -c` so users can write shell features
340
346
  * (pipes, redirects, env vars) into a `verify:` field. Per-command
341
- * timeout = 5 minutes; on timeout we synthesize a stderr message and
342
- * return `passed: false` rather than throwing `runVerifyCommands`
343
- * always returns a `VerifyResult[]` so callers can build a result table
344
- * without wrapping every call in try/catch.
347
+ * timeout is determined by the item's proof_type:
348
+ * - unit_test: 30s, api_check: 10s, structural/typecheck: 60s, e2e: 120s
349
+ * - unknown/custom: uses config.verify_timeout (default 5 minutes).
350
+ * On timeout we synthesize a stderr message and return `passed: false`
351
+ * rather than throwing — `runVerifyCommands` always returns a
352
+ * `VerifyResult[]` so callers can build a result table without wrapping
353
+ * every call in try/catch.
345
354
  */
346
355
 
347
356
  declare const execFileDefault$3: typeof execFile.__promisify__;
@@ -420,6 +429,7 @@ interface AutopilotLogger {
420
429
  */
421
430
  declare function createAutopilotLogger(opts: {
422
431
  cwd: string;
432
+ level?: string;
423
433
  }): AutopilotLogger;
424
434
  /**
425
435
  * Convenience factory for module-level loggers when the root logger is
@@ -529,6 +539,13 @@ interface RalphLoopOptions {
529
539
  * Supports plain webhooks and Slack incoming webhooks (auto-detected).
530
540
  */
531
541
  notifyUrl?: string;
542
+ /**
543
+ * Webhook event types to send (optional).
544
+ * When empty or undefined, all events are sent.
545
+ * Valid event types: "iteration_complete", "phase_complete", "run_complete", "error", "struggle", "stall".
546
+ * Events outside this list are silently dropped before any network call.
547
+ */
548
+ notifyEvents?: Array<"iteration_complete" | "phase_complete" | "run_complete" | "error" | "struggle" | "stall">;
532
549
  /**
533
550
  * When true, the agent adapter is NOT shut down in the finally block.
534
551
  * Instead, the adapter + handle are exposed on the LoopResult so the
@@ -557,6 +574,27 @@ interface RalphLoopOptions {
557
574
  * Optional only when _deps.startServer is provided (legacy test path).
558
575
  */
559
576
  adapter?: AgentAdapter;
577
+ /**
578
+ * Resolved model ID for this loop session. When provided, overrides
579
+ * the default model resolution based on agentName or adapter config.
580
+ * This field enables config-driven model routing for workflow stages.
581
+ */
582
+ model?: string;
583
+ /**
584
+ * Per-call agent overrides (item 4.2). When provided, passed to the
585
+ * adapter's start() method to apply per-phase agent configuration.
586
+ * Each phase can have its own agent-to-model mapping.
587
+ */
588
+ agentOverrides?: Record<string, unknown>;
589
+ /**
590
+ * Optional config object for iteration budget tuning (item 3.2),
591
+ * commit settings (item 3.5), and other autopilot features.
592
+ * - config.stall_timeout: per-iteration stall timeout in ms (overrides tier default)
593
+ * - config.auto_commit: boolean (default true) — whether to commit on SIGINT/SIGTERM
594
+ * - config.commit_prefix: string (optional) — prepended to commit subjects
595
+ * When provided, extracted values override tier-based defaults in the loop.
596
+ */
597
+ config?: unknown;
560
598
  }
561
599
  /**
562
600
  * Run the Ralph loop: send prompt → wait for idle → inspect response →
@@ -643,6 +681,11 @@ interface LoopSessionOptions {
643
681
  * Required in production — the CLI injects the OpenCode adapter.
644
682
  */
645
683
  adapter?: AgentAdapter;
684
+ /**
685
+ * Resolved autopilot configuration from `.glrs/autopilot.yaml` (plan-specific > project > defaults).
686
+ * Unused in this wave — wired for future consumers that need to read individual config fields.
687
+ */
688
+ config?: unknown;
646
689
  /**
647
690
  * Optional abort signal for graceful shutdown. When the signal fires,
648
691
  * the loop writes a checkpoint and returns with exitReason: "aborted"
@@ -671,6 +714,21 @@ interface SessionRunnerOptions {
671
714
  * Defaults to `<cwd>/.agent/autopilot-events.jsonl`.
672
715
  */
673
716
  eventStreamPath?: string;
717
+ /**
718
+ * Enrichment configuration (strategy, retry, timeouts).
719
+ * Passed through to enrichPlanForFastModel when --fast is used.
720
+ */
721
+ enrichmentConfig?: {
722
+ strategy?: string;
723
+ retry?: boolean;
724
+ max_retries?: number;
725
+ stall_timeout?: number;
726
+ };
727
+ /**
728
+ * Resolved autopilot configuration from `.glrs/autopilot.yaml`.
729
+ * Passed through to enrichment, loop execution, and debrief for model resolution.
730
+ */
731
+ config?: unknown;
674
732
  /**
675
733
  * Injectable dependencies for testing.
676
734
  * @internal
@@ -687,7 +745,7 @@ interface SessionResult {
687
745
  */
688
746
  interface SessionRunnerDeps {
689
747
  /** Override enrichPlanForFastModel for testing. */
690
- enrichPlan?: (cwd: string, planPath: string, logger?: AutopilotLogger) => Promise<void>;
748
+ enrichPlan?: (cwd: string, planPath: string, logger?: AutopilotLogger) => Promise<string>;
691
749
  /** Override runLoopSession for testing. */
692
750
  runLoopSession?: (opts: LoopSessionOptions & {
693
751
  _deps?: unknown;
@@ -776,6 +834,25 @@ declare function runLoopSession(opts: LoopSessionOptions & {
776
834
  _deps?: LoopSessionDeps;
777
835
  }): Promise<LoopResult>;
778
836
 
837
+ /**
838
+ * Adapter-aware model resolver. Resolves a model specifier to a concrete model ID
839
+ * based on the active adapter (OpenCode or Claude Code CLI).
840
+ *
841
+ * Both adapters support:
842
+ * - Full model IDs containing "/" (e.g., "amazon-bedrock/claude-opus") pass through unchanged
843
+ *
844
+ * OpenCode adapter:
845
+ * - Tier names resolve through `opencodeTiers` map
846
+ * - Unknown tier names fall back to `opencodeTiers?.deep` with a warning
847
+ * - Array-valued tiers return the first element
848
+ *
849
+ * Claude Code CLI adapter:
850
+ * - Known tier aliases map to specific Claude model IDs
851
+ * - Unknown literals pass through unchanged
852
+ */
853
+ type AdapterName = "opencode" | "claude-code-cli";
854
+ declare function resolveModel(specifier: string, adapterName: AdapterName, opencodeTiers?: Record<string, string | string[]>): string;
855
+
779
856
  /**
780
857
  * Plan enrichment for fast-model execution.
781
858
  *
@@ -800,6 +877,18 @@ declare function runLoopSession(opts: LoopSessionOptions & {
800
877
  * against an already-enriched plan.
801
878
  */
802
879
 
880
+ interface EnrichmentRunConfig {
881
+ retry?: boolean;
882
+ max_retries?: number;
883
+ stall_timeout?: number;
884
+ strategy?: string;
885
+ }
886
+ /**
887
+ * Returns true when a file has no structured plan items — no checkboxes
888
+ * (`- [ ]`) and no numbered headings (`### N.N`). Such files need
889
+ * decomposition before the enrichment loop can process them.
890
+ */
891
+ declare function isFreeformFile(resolvedPath: string): boolean;
803
892
  /**
804
893
  * Enrich a plan for fast-model execution by generating spec/*.yaml files.
805
894
  *
@@ -811,8 +900,13 @@ declare function runLoopSession(opts: LoopSessionOptions & {
811
900
  * Idempotency: if spec/ already exists with all items fully enriched,
812
901
  * enriched, the entire pass is skipped. Per-file: if a spec YAML already
813
902
  * exists and is sufficiently enriched, that file is skipped.
903
+ *
904
+ * Retry: when enrichment stalls or errors, kills the server and retries the
905
+ * entire pass. The per-file idempotency check skips already-enriched files,
906
+ * so retries only pay for failures. Controlled by enrichmentConfig.retry
907
+ * (default true) and enrichmentConfig.max_retries (default 3).
814
908
  */
815
- declare function enrichPlanForFastModel(cwd: string, planPath: string, logger?: AutopilotLogger, emitter?: SessionEventEmitter, adapter?: AgentAdapter): Promise<void>;
909
+ declare function enrichPlanForFastModel(cwd: string, planPath: string, logger?: AutopilotLogger, emitter?: SessionEventEmitter, adapter?: AgentAdapter, enrichmentConfig?: EnrichmentRunConfig, config?: unknown): Promise<string>;
816
910
 
817
911
  interface ValidationResult {
818
912
  valid: boolean;
@@ -854,6 +948,8 @@ declare function parseSpecItems(phasePath: string): Array<PlanItem & {
854
948
  mirror?: string;
855
949
  context?: string;
856
950
  conventions?: string;
951
+ proof?: string;
952
+ proof_type?: string;
857
953
  }>;
858
954
  /**
859
955
  * Detect phase files from spec/main.yaml. Returns sorted list of phase
@@ -977,7 +1073,9 @@ declare const TIMEOUT_MS: number;
977
1073
  * call than a productive think. Fast models are the most responsive
978
1074
  * and warrant the shortest window.
979
1075
  *
980
- * The CLI accepts `--stall-timeout <ms>` to override the tier-default.
1076
+ * Fallback defaults when config.stall_timeout is not set.
1077
+ * The CLI accepts `--stall-timeout <ms>` to override the tier-default,
1078
+ * and config.stall_timeout overrides both the CLI default and tier lookup.
981
1079
  */
982
1080
  declare const STALL_MS_BY_TIER: {
983
1081
  readonly deep: number;
@@ -988,7 +1086,10 @@ declare const STALL_MS_BY_TIER: {
988
1086
  };
989
1087
  /** Backwards-compatible default (used when no tier is resolved). */
990
1088
  declare const STALL_MS: number;
991
- /** Phase-level iteration budgets, keyed by model tier (item 2.7). */
1089
+ /**
1090
+ * Phase-level iteration budgets, keyed by model tier (item 2.7).
1091
+ * Fallback defaults when config.max_iterations_per_phase is not set.
1092
+ */
992
1093
  declare const MAX_ITERATIONS_PER_PHASE_BY_TIER: {
993
1094
  readonly deep: 5;
994
1095
  readonly mid: 8;
@@ -1005,6 +1106,53 @@ declare const MAX_ITERATIONS_PER_PHASE_BY_TIER: {
1005
1106
  */
1006
1107
  declare const STATUS_INTERVAL_MS: number;
1007
1108
 
1109
+ /**
1110
+ * CLI flag override application for autopilot configuration.
1111
+ *
1112
+ * Maps CLI flags to their config field equivalents and applies them with
1113
+ * proper precedence. All fields are optional; undefined flags are ignored.
1114
+ * Returns a new config object without mutating the input.
1115
+ */
1116
+ interface CLIFlags {
1117
+ /** Adapter name override (--adapter / -a) */
1118
+ adapter?: string;
1119
+ /** Use fast executor model (--fast / -f) */
1120
+ fast?: boolean;
1121
+ /** Resume from checkpoint (--resume) */
1122
+ resume?: boolean;
1123
+ /** Per-phase iteration budget override (--max-iterations-per-phase) */
1124
+ maxIterationsPerPhase?: number;
1125
+ /** Number of parallel lanes (--parallel) */
1126
+ parallel?: number;
1127
+ /** Auto-ship after completion (--ship) */
1128
+ ship?: boolean;
1129
+ /** Per-iteration stall timeout in ms (--stall-timeout) */
1130
+ stallTimeout?: number;
1131
+ /** Webhook URL for notifications (--notify) */
1132
+ notify?: string;
1133
+ }
1134
+ /**
1135
+ * Applies CLI flag overrides to autopilot configuration.
1136
+ *
1137
+ * Maps each CLI flag to its config field equivalent:
1138
+ * - `--adapter` → `adapter` (highest precedence)
1139
+ * - `--fast` → `models.execution` (resolved by adapter)
1140
+ * - `--parallel N` → `execution_order: "parallel"` + `parallel_lanes: N`
1141
+ * - `--ship` → `auto_ship: true`
1142
+ * - `--resume` → `checkpoint: true` (implicit)
1143
+ * - `--max-iterations-per-phase N` → `max_iterations_per_phase: N`
1144
+ * - `--stall-timeout N` → `stall_timeout: N`
1145
+ * - `--notify URL` → `notify_url: URL`
1146
+ *
1147
+ * Undefined flags are skipped (no override applied).
1148
+ * `--fast` resolves to the active adapter's execution tier.
1149
+ *
1150
+ * @param config The resolved autopilot configuration
1151
+ * @param flags CLI flags to apply
1152
+ * @returns A new config object with overrides applied (input is not mutated)
1153
+ */
1154
+ declare function applyCLIOverrides(config: unknown, flags: CLIFlags): unknown;
1155
+
1008
1156
  /**
1009
1157
  * Status-heartbeat helper for the autopilot loop.
1010
1158
  *
@@ -1685,6 +1833,8 @@ interface GenerateChangesetResult {
1685
1833
  interface GenerateChangesetOptions {
1686
1834
  /** Override the package name (default: "@glrs-dev/harness-plugin-opencode"). */
1687
1835
  packageName?: string;
1836
+ /** Override the bump level (default: inferred from title keywords). */
1837
+ bumpLevel?: BumpLevel;
1688
1838
  /**
1689
1839
  * Test-only: deterministic random suffix for filename collision avoidance.
1690
1840
  * @internal
@@ -1762,4 +1912,4 @@ interface ScoperSessionResult {
1762
1912
  scopePath: string;
1763
1913
  }
1764
1914
 
1765
- export { type SessionResult$1 as AdapterSessionResult, type AgentAdapter, type AgentHandle, type AutopilotLogger, type Checkpoint, type CostUpdateEvent, type CredentialExpiredEvent, type EnrichDoneEvent, type EnrichFileDoneEvent, type EnrichFileErrorEvent, type EnrichFileSkipEvent, type EnrichFileStartEvent, type EnrichStartEvent, type ErrorEvent, EventStreamReader, EventStreamWriter, type IterationDoneEvent, type IterationStartEvent, type LoopExitReason, type LoopResult, type LoopSessionDeps, type LoopSessionOptions, MAX_ITERATIONS, MAX_ITERATIONS_PER_PHASE_BY_TIER, type PhaseDoneEvent, type PhaseResult, type PhaseStartEvent, type PlanItem, type PlanSessionOptions, type PlanSessionResult, type PlanState, type RalphLoopOptions, STALL_MS, STALL_MS_BY_TIER, STATUS_INTERVAL_MS, STRUGGLE_THRESHOLD, type ScoperSessionOptions, type ScoperSessionResult, type SessionDoneEvent, type SessionEvent, SessionEventEmitter, type SessionHandle, type SessionResult, SessionRunner, type SessionRunnerDeps, type SessionRunnerOptions, type SessionStartEvent, type SessionStatus, StruggleDetector, TIMEOUT_MS, type ThinkingEvent, type ToolCallEvent, type VerifyDoneEvent, type VerifyResult, type VerifyResultEvent, type VerifyStartEvent, type WorktreeHandle, autoShip, buildConflictGraph, checkKillSwitch, childLogger, createAutopilotLogger, createStatusHeartbeat, createWorktree, deleteCheckpoint, deriveState, detectSentinel, detectSpecPhases, enrichPlanForFastModel, filterUncheckedSpecPhases, formatCost, formatElapsed, generateChangeset, getChangedFiles, hasParallelism, hasSpec, markPhaseCompleted, mergeWorktree, parseItems, parsePlanState, parseSpecItems, readCheckpoint, readSpecConstraints, readSpecGoal, recordHead, resetSoft, runLanes, runLoopSession, runPlanSession, runRalphLoop, runVerifyCommands, validateMainSpec, validatePhaseSpec, validatePlan, validateScope, writeCheckpoint };
1915
+ export { type AdapterName, type SessionResult$1 as AdapterSessionResult, type AgentAdapter, type AgentHandle, type AutopilotLogger, type CLIFlags, type Checkpoint, type CostUpdateEvent, type CredentialExpiredEvent, type EnrichDoneEvent, type EnrichFileDoneEvent, type EnrichFileErrorEvent, type EnrichFileSkipEvent, type EnrichFileStartEvent, type EnrichStartEvent, type ErrorEvent, EventStreamReader, EventStreamWriter, type IterationDoneEvent, type IterationStartEvent, type LoopExitReason, type LoopResult, type LoopSessionDeps, type LoopSessionOptions, MAX_ITERATIONS, MAX_ITERATIONS_PER_PHASE_BY_TIER, type PhaseDoneEvent, type PhaseResult, type PhaseStartEvent, type PlanItem, type PlanSessionOptions, type PlanSessionResult, type PlanState, type RalphLoopOptions, STALL_MS, STALL_MS_BY_TIER, STATUS_INTERVAL_MS, STRUGGLE_THRESHOLD, type ScoperSessionOptions, type ScoperSessionResult, type SessionDoneEvent, type SessionEvent, SessionEventEmitter, type SessionHandle, type SessionResult, SessionRunner, type SessionRunnerDeps, type SessionRunnerOptions, type SessionStartEvent, type SessionStatus, StruggleDetector, TIMEOUT_MS, type ThinkingEvent, type ToolCallEvent, type VerifyDoneEvent, type VerifyResult, type VerifyResultEvent, type VerifyStartEvent, type WorktreeHandle, applyCLIOverrides, autoShip, buildConflictGraph, checkKillSwitch, childLogger, createAutopilotLogger, createStatusHeartbeat, createWorktree, deleteCheckpoint, deriveState, detectSentinel, detectSpecPhases, enrichPlanForFastModel, filterUncheckedSpecPhases, formatCost, formatElapsed, generateChangeset, getChangedFiles, hasParallelism, hasSpec, isFreeformFile, markPhaseCompleted, mergeWorktree, parseItems, parsePlanState, parseSpecItems, readCheckpoint, readSpecConstraints, readSpecGoal, recordHead, resetSoft, resolveModel, runLanes, runLoopSession, runPlanSession, runRalphLoop, runVerifyCommands, validateMainSpec, validatePhaseSpec, validatePlan, validateScope, writeCheckpoint };
@@ -1,12 +1,13 @@
1
1
  import {
2
- enrichPlanForFastModel
3
- } from "./chunk-ZNJWARTM.js";
2
+ enrichPlanForFastModel,
3
+ isFreeformFile
4
+ } from "./chunk-6JZQLIRP.js";
4
5
  import {
5
6
  generateChangeset
6
- } from "./chunk-E7PWTRFO.js";
7
+ } from "./chunk-AWRK6S6G.js";
7
8
  import {
8
9
  autoShip
9
- } from "./chunk-M2ZVBPWL.js";
10
+ } from "./chunk-BLEIZHET.js";
10
11
  import {
11
12
  MAX_ITERATIONS,
12
13
  MAX_ITERATIONS_PER_PHASE_BY_TIER,
@@ -40,11 +41,14 @@ import {
40
41
  validatePlan,
41
42
  validateScope,
42
43
  writeCheckpoint
43
- } from "./chunk-VITL2Z45.js";
44
+ } from "./chunk-2X3CWH47.js";
45
+ import {
46
+ resolveModel
47
+ } from "./chunk-S34HOCZ4.js";
44
48
  import {
45
49
  childLogger,
46
50
  createAutopilotLogger
47
- } from "./chunk-Q4ULU6ER.js";
51
+ } from "./chunk-2ZQ6SBV3.js";
48
52
  import {
49
53
  detectSpecPhases,
50
54
  filterUncheckedSpecPhases,
@@ -54,7 +58,7 @@ import {
54
58
  readSpecGoal,
55
59
  validateMainSpec,
56
60
  validatePhaseSpec
57
- } from "./chunk-7OSEI5TF.js";
61
+ } from "./chunk-GXXCEGDD.js";
58
62
 
59
63
  // src/event-stream.ts
60
64
  import * as fs from "fs";
@@ -298,34 +302,49 @@ var SessionRunner = class {
298
302
  if (_createLogger) {
299
303
  logger = _createLogger({ cwd });
300
304
  } else {
301
- const { createAutopilotLogger: createAutopilotLogger2 } = await import("./logger-UITJGIZE.js");
302
- logger = createAutopilotLogger2({ cwd });
305
+ const { createAutopilotLogger: createAutopilotLogger2 } = await import("./logger-3XLFMXLN.js");
306
+ const logLevel = this.opts.config?.log_level;
307
+ logger = createAutopilotLogger2({ cwd, level: logLevel });
303
308
  }
309
+ const adapterName = this.opts.adapter?.name ?? "unknown";
304
310
  let enrichModel = "unknown";
305
311
  let executeModel = "unknown";
306
- try {
307
- const { join: join3 } = await import("path");
308
- const { readFileSync: readFileSync3 } = await import("fs");
309
- const configHome = process.env["XDG_CONFIG_HOME"] ?? join3(process.env["HOME"] ?? "", ".config");
310
- const configPath = join3(configHome, "opencode", "opencode.json");
311
- const raw = readFileSync3(configPath, "utf8");
312
- const config = JSON.parse(raw);
313
- const plugins = Array.isArray(config.plugin) ? config.plugin : [];
314
- for (const entry of plugins) {
315
- if (Array.isArray(entry) && entry.length >= 2) {
316
- const opts2 = entry[1];
317
- const models = opts2?.models;
318
- if (models) {
319
- const deepArr = models["deep"] ?? models["prime"];
320
- if (Array.isArray(deepArr) && deepArr[0]) enrichModel = deepArr[0];
321
- const execArr = models["autopilot-execute"] ?? models["mid-execute"] ?? models["mid"];
322
- if (Array.isArray(execArr) && execArr[0]) executeModel = execArr[0];
312
+ const cfgObj = this.opts.config;
313
+ const cfgModels = cfgObj?.models;
314
+ if (adapterName === "claude-code-cli") {
315
+ enrichModel = cfgModels?.enrichment ?? "claude-opus-4-7";
316
+ executeModel = cfgModels?.execution ?? "claude-haiku-4-5-20251001";
317
+ } else {
318
+ try {
319
+ const { join: join3 } = await import("path");
320
+ const { readFileSync: readFileSync3 } = await import("fs");
321
+ const configHome = process.env["XDG_CONFIG_HOME"] ?? join3(process.env["HOME"] ?? "", ".config");
322
+ const configPath = join3(configHome, "opencode", "opencode.json");
323
+ const raw = readFileSync3(configPath, "utf8");
324
+ const config = JSON.parse(raw);
325
+ const plugins = Array.isArray(config.plugin) ? config.plugin : [];
326
+ for (const entry of plugins) {
327
+ if (Array.isArray(entry) && entry.length >= 2) {
328
+ const opts2 = entry[1];
329
+ const models = opts2?.models;
330
+ if (models) {
331
+ const deepArr = models["deep"] ?? models["prime"];
332
+ if (Array.isArray(deepArr) && deepArr[0]) enrichModel = deepArr[0];
333
+ const execArr = models["autopilot-execute"] ?? models["mid-execute"] ?? models["mid"];
334
+ if (Array.isArray(execArr) && execArr[0]) executeModel = execArr[0];
335
+ }
323
336
  }
324
337
  }
338
+ if (typeof config.model === "string" && enrichModel === "unknown") {
339
+ enrichModel = config.model;
340
+ }
341
+ } catch {
325
342
  }
326
- if (typeof config.model === "string" && enrichModel === "unknown") {
327
- enrichModel = config.model;
328
- }
343
+ }
344
+ let branch = "unknown";
345
+ try {
346
+ const { execFileSync } = await import("child_process");
347
+ branch = execFileSync("git", ["branch", "--show-current"], { cwd, encoding: "utf8" }).trim() || "detached";
329
348
  } catch {
330
349
  }
331
350
  emitEvent({
@@ -336,9 +355,12 @@ var SessionRunner = class {
336
355
  fast: fast ?? false,
337
356
  resume: resume ?? false,
338
357
  enrichModel,
339
- executeModel
358
+ executeModel,
359
+ adapter: adapterName,
360
+ branch
340
361
  });
341
362
  let loopResult;
363
+ let effectivePlanPath = planPath;
342
364
  try {
343
365
  if (fast && planPath) {
344
366
  emitEvent({
@@ -350,15 +372,15 @@ var SessionRunner = class {
350
372
  });
351
373
  try {
352
374
  if (_enrichPlan) {
353
- await _enrichPlan(cwd, planPath, logger);
375
+ effectivePlanPath = await _enrichPlan(cwd, planPath, logger);
354
376
  emitEvent({
355
377
  type: "enrich:done",
356
378
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
357
379
  filesProcessed: 0
358
380
  });
359
381
  } else {
360
- const { enrichPlanForFastModel: enrichPlanForFastModel2 } = await import("./plan-enrichment-D3RPJR2J.js");
361
- await enrichPlanForFastModel2(cwd, planPath, logger, this.events, this.opts.adapter);
382
+ const { enrichPlanForFastModel: enrichPlanForFastModel2 } = await import("./plan-enrichment-4SQYV5FC.js");
383
+ effectivePlanPath = await enrichPlanForFastModel2(cwd, planPath, logger, this.events, this.opts.adapter, this.opts.enrichmentConfig, this.opts.config);
362
384
  }
363
385
  } catch (err) {
364
386
  const message = err instanceof Error ? err.message : String(err);
@@ -370,7 +392,7 @@ var SessionRunner = class {
370
392
  }
371
393
  }
372
394
  const loopOpts = {
373
- planPath,
395
+ planPath: effectivePlanPath,
374
396
  cwd,
375
397
  fast,
376
398
  resume,
@@ -380,12 +402,13 @@ var SessionRunner = class {
380
402
  logger,
381
403
  emitter: this.events,
382
404
  adapter: this.opts.adapter,
405
+ config: this.opts.config,
383
406
  signal: this._abortController?.signal
384
407
  };
385
408
  if (_runLoopSession) {
386
409
  loopResult = await _runLoopSession(loopOpts);
387
410
  } else {
388
- const { runLoopSession: runLoopSession2 } = await import("./loop-session-XKL3NHUA.js");
411
+ const { runLoopSession: runLoopSession2 } = await import("./loop-session-YLCVJGPV.js");
389
412
  loopResult = await runLoopSession2(loopOpts);
390
413
  }
391
414
  } catch (err) {
@@ -419,6 +442,60 @@ var SessionRunner = class {
419
442
  }
420
443
  };
421
444
 
445
+ // src/config-reader.ts
446
+ function deepClone(obj) {
447
+ if (obj === null || typeof obj !== "object") {
448
+ return obj;
449
+ }
450
+ if (Array.isArray(obj)) {
451
+ return obj.map((item) => deepClone(item));
452
+ }
453
+ if (obj instanceof Date) {
454
+ return new Date(obj.getTime());
455
+ }
456
+ const cloned = {};
457
+ for (const key in obj) {
458
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
459
+ cloned[key] = deepClone(obj[key]);
460
+ }
461
+ }
462
+ return cloned;
463
+ }
464
+ function applyCLIOverrides(config, flags) {
465
+ const result = deepClone(config);
466
+ if (!result.models || typeof result.models !== "object") {
467
+ result.models = {};
468
+ }
469
+ const models = result.models;
470
+ if (flags.adapter !== void 0) {
471
+ result.adapter = flags.adapter;
472
+ }
473
+ if (flags.fast) {
474
+ const activeAdapter = flags.adapter ?? result.adapter;
475
+ models.execution = activeAdapter === "claude-code-cli" ? "claude-haiku-4-5-20251001" : "autopilot-execute";
476
+ }
477
+ if (flags.parallel !== void 0) {
478
+ result.execution_order = "parallel";
479
+ result.parallel_lanes = flags.parallel;
480
+ }
481
+ if (flags.ship) {
482
+ result.auto_ship = true;
483
+ }
484
+ if (flags.resume) {
485
+ result.checkpoint = true;
486
+ }
487
+ if (flags.maxIterationsPerPhase !== void 0) {
488
+ result.max_iterations_per_phase = flags.maxIterationsPerPhase;
489
+ }
490
+ if (flags.stallTimeout !== void 0) {
491
+ result.stall_timeout = flags.stallTimeout;
492
+ }
493
+ if (flags.notify !== void 0) {
494
+ result.notify_url = flags.notify;
495
+ }
496
+ return result;
497
+ }
498
+
422
499
  // src/session-state.ts
423
500
  function deriveId(planPath, startedAt) {
424
501
  const raw = `${planPath}|${startedAt}`;
@@ -646,6 +723,7 @@ export {
646
723
  SessionRunner,
647
724
  StruggleDetector,
648
725
  TIMEOUT_MS,
726
+ applyCLIOverrides,
649
727
  autoShip,
650
728
  buildConflictGraph,
651
729
  checkKillSwitch,
@@ -665,6 +743,7 @@ export {
665
743
  getChangedFiles,
666
744
  hasParallelism,
667
745
  hasSpec,
746
+ isFreeformFile,
668
747
  markPhaseCompleted,
669
748
  mergeWorktree,
670
749
  parseItems,
@@ -675,6 +754,7 @@ export {
675
754
  readSpecGoal,
676
755
  recordHead,
677
756
  resetSoft,
757
+ resolveModel,
678
758
  runLanes,
679
759
  runLoopSession,
680
760
  runPlanSession,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  childLogger,
3
3
  createAutopilotLogger
4
- } from "./chunk-Q4ULU6ER.js";
4
+ } from "./chunk-2ZQ6SBV3.js";
5
5
  export {
6
6
  childLogger,
7
7
  createAutopilotLogger
@@ -0,0 +1,9 @@
1
+ import {
2
+ runLoopSession
3
+ } from "./chunk-2X3CWH47.js";
4
+ import "./chunk-S34HOCZ4.js";
5
+ import "./chunk-2ZQ6SBV3.js";
6
+ import "./chunk-GXXCEGDD.js";
7
+ export {
8
+ runLoopSession
9
+ };