@kodrunhq/opencode-autopilot 1.1.0 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kodrunhq/opencode-autopilot",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Curated agents, skills, and commands for the OpenCode AI coding CLI — autonomous orchestrator, multi-agent code review, model fallback, and in-session asset creation tools.",
5
5
  "main": "src/index.ts",
6
6
  "keywords": [
package/src/index.ts CHANGED
@@ -12,7 +12,12 @@ import {
12
12
  import { fallbackDefaults } from "./orchestrator/fallback/fallback-config";
13
13
  import { resolveChain } from "./orchestrator/fallback/resolve-chain";
14
14
  import { ocConfidence } from "./tools/confidence";
15
- import { ocConfigure, setAvailableProviders, setOpenCodeConfig } from "./tools/configure";
15
+ import {
16
+ ocConfigure,
17
+ setAvailableProviders,
18
+ setOpenCodeConfig,
19
+ setProviderDiscoveryPromise,
20
+ } from "./tools/configure";
16
21
  import { ocCreateAgent } from "./tools/create-agent";
17
22
  import { ocCreateCommand } from "./tools/create-command";
18
23
  import { ocCreateSkill } from "./tools/create-skill";
@@ -34,17 +39,23 @@ const plugin: Plugin = async (input) => {
34
39
  console.error("[opencode-autopilot] Asset installation errors:", installResult.errors);
35
40
  }
36
41
 
37
- // Discover available providers/models from OpenCode SDK
42
+ // Discover available providers/models in the background (non-blocking).
43
+ // The promise is stored so oc_configure "start" can await it (with timeout).
38
44
  try {
39
- const providerResponse = await client.provider.list({
40
- query: { directory: process.cwd() },
41
- });
42
- const providerData = providerResponse.data;
43
- if (providerData?.all) {
44
- setAvailableProviders(providerData.all);
45
- }
45
+ const discoveryPromise = client.provider
46
+ .list({ query: { directory: process.cwd() } })
47
+ .then((providerResponse) => {
48
+ const providerData = providerResponse.data;
49
+ if (providerData?.all) {
50
+ setAvailableProviders(providerData.all);
51
+ }
52
+ })
53
+ .catch(() => {
54
+ // Provider discovery is best-effort; configure will show empty models
55
+ });
56
+ setProviderDiscoveryPromise(discoveryPromise);
46
57
  } catch {
47
- // Provider discovery is best-effort; configure will show empty models
58
+ // Guard against synchronous failures (e.g. client.provider undefined)
48
59
  }
49
60
 
50
61
  // Load config for first-load detection and fallback settings
@@ -41,11 +41,19 @@ let availableProviders: ReadonlyArray<{
41
41
  readonly models: Readonly<Record<string, { readonly id: string; readonly name: string }>>;
42
42
  }> = [];
43
43
 
44
+ /**
45
+ * Promise that resolves when provider discovery completes (or fails).
46
+ * handleStart awaits this (with timeout) so oc_configure doesn't race
47
+ * against background discovery.
48
+ */
49
+ let providerDiscoveryPromise: Promise<void> = Promise.resolve();
50
+
44
51
  // --- Exported helpers for test/plugin wiring ---
45
52
 
46
53
  export function resetPendingAssignments(): void {
47
54
  pendingAssignments = new Map();
48
55
  availableProviders = [];
56
+ providerDiscoveryPromise = Promise.resolve();
49
57
  }
50
58
 
51
59
  export function setOpenCodeConfig(config: Config | null): void {
@@ -62,6 +70,10 @@ export function setAvailableProviders(
62
70
  availableProviders = providers;
63
71
  }
64
72
 
73
+ export function setProviderDiscoveryPromise(promise: Promise<void>): void {
74
+ providerDiscoveryPromise = promise;
75
+ }
76
+
65
77
  // --- Core logic ---
66
78
 
67
79
  interface ConfigureArgs {
@@ -106,6 +118,12 @@ function serializeDiversityWarnings(warnings: readonly DiversityWarning[]): read
106
118
  }
107
119
 
108
120
  async function handleStart(configPath?: string): Promise<string> {
121
+ // Wait for background provider discovery (up to 5s) before building model list
122
+ await Promise.race([
123
+ providerDiscoveryPromise,
124
+ new Promise<void>((resolve) => setTimeout(resolve, 5000)),
125
+ ]);
126
+
109
127
  const modelsByProvider = discoverAvailableModels();
110
128
 
111
129
  // Load current plugin config to show existing assignments