berget 2.2.6 → 2.2.7
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/.github/workflows/publish.yml +6 -6
- package/.github/workflows/test.yml +11 -5
- package/.husky/pre-commit +1 -0
- package/.prettierignore +15 -0
- package/.prettierrc +5 -3
- package/CONTRIBUTING.md +38 -0
- package/README.md +2 -148
- package/dist/index.js +21 -21
- package/dist/package.json +28 -2
- package/dist/src/agents/app.js +28 -0
- package/dist/src/agents/backend.js +25 -0
- package/dist/src/agents/devops.js +34 -0
- package/dist/src/agents/frontend.js +25 -0
- package/dist/src/agents/fullstack.js +25 -0
- package/dist/src/agents/index.js +61 -0
- package/dist/src/agents/quality.js +70 -0
- package/dist/src/agents/security.js +26 -0
- package/dist/src/agents/types.js +2 -0
- package/dist/src/client.js +54 -62
- package/dist/src/commands/api-keys.js +132 -140
- package/dist/src/commands/auth.js +9 -9
- package/dist/src/commands/autocomplete.js +9 -9
- package/dist/src/commands/billing.js +7 -9
- package/dist/src/commands/chat.js +90 -92
- package/dist/src/commands/clusters.js +12 -12
- package/dist/src/commands/code/__tests__/auth-sync.test.js +348 -0
- package/dist/src/commands/code/__tests__/fake-api-key-service.js +23 -0
- package/dist/src/commands/code/__tests__/fake-auth-service.js +55 -0
- package/dist/src/commands/code/__tests__/fake-command-runner.js +5 -7
- package/dist/src/commands/code/__tests__/fake-file-store.js +9 -0
- package/dist/src/commands/code/__tests__/fake-prompter.js +60 -18
- package/dist/src/commands/code/__tests__/setup-flow.test.js +374 -107
- package/dist/src/commands/code/adapters/clack-prompter.js +10 -0
- package/dist/src/commands/code/adapters/fs-file-store.js +8 -3
- package/dist/src/commands/code/adapters/spawn-command-runner.js +15 -11
- package/dist/src/commands/code/auth-sync.js +283 -0
- package/dist/src/commands/code/errors.js +4 -4
- package/dist/src/commands/code/ports/auth-services.js +2 -0
- package/dist/src/commands/code/setup.js +234 -93
- package/dist/src/commands/code.js +139 -251
- package/dist/src/commands/models.js +13 -15
- package/dist/src/commands/users.js +6 -8
- package/dist/src/constants/command-structure.js +116 -116
- package/dist/src/services/api-key-service.js +43 -48
- package/dist/src/services/auth-service.js +60 -299
- package/dist/src/services/browser-auth.js +278 -0
- package/dist/src/services/chat-service.js +78 -91
- package/dist/src/services/cluster-service.js +6 -6
- package/dist/src/services/collaborator-service.js +5 -8
- package/dist/src/services/flux-service.js +5 -8
- package/dist/src/services/helm-service.js +5 -8
- package/dist/src/services/kubectl-service.js +7 -10
- package/dist/src/utils/config-checker.js +5 -5
- package/dist/src/utils/config-loader.js +25 -25
- package/dist/src/utils/default-api-key.js +23 -23
- package/dist/src/utils/env-manager.js +7 -7
- package/dist/src/utils/error-handler.js +60 -61
- package/dist/src/utils/logger.js +7 -7
- package/dist/src/utils/markdown-renderer.js +2 -2
- package/dist/src/utils/opencode-validator.js +17 -20
- package/dist/src/utils/token-manager.js +38 -11
- package/dist/tests/commands/chat.test.js +24 -24
- package/dist/tests/commands/code.test.js +147 -147
- package/dist/tests/utils/config-loader.test.js +114 -114
- package/dist/tests/utils/env-manager.test.js +57 -57
- package/dist/tests/utils/opencode-validator.test.js +33 -33
- package/dist/vitest.config.js +1 -1
- package/eslint.config.mjs +47 -0
- package/index.ts +42 -48
- package/package.json +28 -2
- package/src/agents/app.ts +27 -0
- package/src/agents/backend.ts +24 -0
- package/src/agents/devops.ts +33 -0
- package/src/agents/frontend.ts +24 -0
- package/src/agents/fullstack.ts +24 -0
- package/src/agents/index.ts +71 -0
- package/src/agents/quality.ts +69 -0
- package/src/agents/security.ts +26 -0
- package/src/agents/types.ts +17 -0
- package/src/client.ts +125 -167
- package/src/commands/api-keys.ts +261 -358
- package/src/commands/auth.ts +24 -30
- package/src/commands/autocomplete.ts +12 -12
- package/src/commands/billing.ts +22 -27
- package/src/commands/chat.ts +230 -323
- package/src/commands/clusters.ts +33 -33
- package/src/commands/code/__tests__/auth-sync.test.ts +481 -0
- package/src/commands/code/__tests__/fake-api-key-service.ts +13 -0
- package/src/commands/code/__tests__/fake-auth-service.ts +50 -0
- package/src/commands/code/__tests__/fake-command-runner.ts +39 -42
- package/src/commands/code/__tests__/fake-file-store.ts +32 -23
- package/src/commands/code/__tests__/fake-prompter.ts +107 -69
- package/src/commands/code/__tests__/setup-flow.test.ts +624 -270
- package/src/commands/code/adapters/clack-prompter.ts +50 -38
- package/src/commands/code/adapters/fs-file-store.ts +31 -27
- package/src/commands/code/adapters/spawn-command-runner.ts +33 -29
- package/src/commands/code/auth-sync.ts +329 -0
- package/src/commands/code/errors.ts +15 -15
- package/src/commands/code/ports/auth-services.ts +14 -0
- package/src/commands/code/ports/command-runner.ts +8 -4
- package/src/commands/code/ports/file-store.ts +5 -4
- package/src/commands/code/ports/prompter.ts +24 -18
- package/src/commands/code/setup.ts +545 -317
- package/src/commands/code.ts +271 -473
- package/src/commands/index.ts +19 -19
- package/src/commands/models.ts +32 -37
- package/src/commands/users.ts +15 -22
- package/src/constants/command-structure.ts +119 -142
- package/src/services/api-key-service.ts +96 -113
- package/src/services/auth-service.ts +92 -339
- package/src/services/browser-auth.ts +296 -0
- package/src/services/chat-service.ts +246 -279
- package/src/services/cluster-service.ts +29 -32
- package/src/services/collaborator-service.ts +13 -18
- package/src/services/flux-service.ts +16 -18
- package/src/services/helm-service.ts +16 -18
- package/src/services/kubectl-service.ts +12 -14
- package/src/types/api.d.ts +924 -926
- package/src/types/json.d.ts +3 -3
- package/src/utils/config-checker.ts +10 -10
- package/src/utils/config-loader.ts +110 -127
- package/src/utils/default-api-key.ts +81 -93
- package/src/utils/env-manager.ts +36 -40
- package/src/utils/error-handler.ts +83 -78
- package/src/utils/logger.ts +41 -41
- package/src/utils/markdown-renderer.ts +11 -11
- package/src/utils/opencode-validator.ts +51 -56
- package/src/utils/token-manager.ts +84 -64
- package/templates/agents/app.md +1 -0
- package/templates/agents/backend.md +1 -0
- package/templates/agents/devops.md +2 -0
- package/templates/agents/frontend.md +1 -0
- package/templates/agents/fullstack.md +1 -0
- package/templates/agents/quality.md +45 -40
- package/templates/agents/security.md +1 -0
- package/tests/commands/chat.test.ts +60 -70
- package/tests/commands/code.test.ts +330 -376
- package/tests/utils/config-loader.test.ts +260 -260
- package/tests/utils/env-manager.test.ts +127 -134
- package/tests/utils/opencode-validator.test.ts +58 -63
- package/tsconfig.json +2 -2
- package/vitest.config.ts +3 -3
- package/AGENTS.md +0 -374
- package/TODO.md +0 -19
package/src/types/json.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
2
|
-
const value: any
|
|
3
|
-
export = value
|
|
1
|
+
declare module "*.json" {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
4
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as fs from
|
|
2
|
-
import * as path from
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Check for .bergetconfig file and handle cluster switching
|
|
6
6
|
*/
|
|
7
7
|
export function checkBergetConfig(): void {
|
|
8
|
-
const configPath = path.join(process.cwd(),
|
|
8
|
+
const configPath = path.join(process.cwd(), ".bergetconfig");
|
|
9
9
|
if (fs.existsSync(configPath)) {
|
|
10
10
|
try {
|
|
11
|
-
const config = fs.readFileSync(configPath,
|
|
12
|
-
const match = config.match(/cluster:\s*(.+)/)
|
|
11
|
+
const config = fs.readFileSync(configPath, "utf8");
|
|
12
|
+
const match = config.match(/cluster:\s*(.+)/);
|
|
13
13
|
if (match && match[1]) {
|
|
14
|
-
const clusterName = match[1].trim()
|
|
15
|
-
console.log(`🔄 Berget: Switched to cluster "${clusterName}"`)
|
|
16
|
-
console.log(
|
|
17
|
-
console.log(
|
|
14
|
+
const clusterName = match[1].trim();
|
|
15
|
+
console.log(`🔄 Berget: Switched to cluster "${clusterName}"`);
|
|
16
|
+
console.log("✓ kubectl config updated");
|
|
17
|
+
console.log("");
|
|
18
18
|
}
|
|
19
|
-
} catch
|
|
19
|
+
} catch {
|
|
20
20
|
// Silently ignore errors reading config
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from
|
|
2
|
-
import * as path from
|
|
3
|
-
import { logger } from
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { logger } from "./logger";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Centralized agent configuration loader
|
|
@@ -8,73 +8,73 @@ import { logger } from './logger'
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export interface AgentConfig {
|
|
11
|
-
model: string
|
|
12
|
-
temperature: number
|
|
13
|
-
top_p: number
|
|
14
|
-
mode:
|
|
11
|
+
model: string;
|
|
12
|
+
temperature: number;
|
|
13
|
+
top_p: number;
|
|
14
|
+
mode: "primary" | "subagent";
|
|
15
15
|
permission: {
|
|
16
|
-
edit:
|
|
17
|
-
bash:
|
|
18
|
-
webfetch:
|
|
19
|
-
}
|
|
20
|
-
description?: string
|
|
21
|
-
prompt?: string
|
|
22
|
-
note?: string
|
|
16
|
+
edit: "allow" | "deny";
|
|
17
|
+
bash: "allow" | "deny";
|
|
18
|
+
webfetch: "allow" | "deny";
|
|
19
|
+
};
|
|
20
|
+
description?: string;
|
|
21
|
+
prompt?: string;
|
|
22
|
+
note?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface ModelConfig {
|
|
26
|
-
primary: string
|
|
27
|
-
small: string
|
|
26
|
+
primary: string;
|
|
27
|
+
small: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface ProviderModelConfig {
|
|
31
|
-
name: string
|
|
31
|
+
name: string;
|
|
32
32
|
limit: {
|
|
33
|
-
output: number
|
|
34
|
-
context: number
|
|
35
|
-
}
|
|
33
|
+
output: number;
|
|
34
|
+
context: number;
|
|
35
|
+
};
|
|
36
36
|
modalities?: {
|
|
37
|
-
input: string[]
|
|
38
|
-
output: string[]
|
|
39
|
-
}
|
|
37
|
+
input: string[];
|
|
38
|
+
output: string[];
|
|
39
|
+
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface OpenCodeConfig {
|
|
43
|
-
$schema?: string
|
|
44
|
-
username?: string
|
|
45
|
-
theme?: string
|
|
46
|
-
share?: string
|
|
47
|
-
autoupdate?: boolean
|
|
48
|
-
model?: string
|
|
49
|
-
small_model?: string
|
|
50
|
-
agent?: Record<string, AgentConfig
|
|
51
|
-
command?: Record<string, any
|
|
52
|
-
watcher?: Record<string, any
|
|
53
|
-
provider?: Record<string, any
|
|
43
|
+
$schema?: string;
|
|
44
|
+
username?: string;
|
|
45
|
+
theme?: string;
|
|
46
|
+
share?: string;
|
|
47
|
+
autoupdate?: boolean;
|
|
48
|
+
model?: string;
|
|
49
|
+
small_model?: string;
|
|
50
|
+
agent?: Record<string, AgentConfig>;
|
|
51
|
+
command?: Record<string, any>;
|
|
52
|
+
watcher?: Record<string, any>;
|
|
53
|
+
provider?: Record<string, any>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export class ConfigLoader {
|
|
57
|
-
private static instance: ConfigLoader
|
|
58
|
-
private config: OpenCodeConfig | null = null
|
|
59
|
-
private configPath: string
|
|
57
|
+
private static instance: ConfigLoader;
|
|
58
|
+
private config: OpenCodeConfig | null = null;
|
|
59
|
+
private configPath: string;
|
|
60
60
|
|
|
61
61
|
private constructor(configPath?: string) {
|
|
62
62
|
// Default to opencode.json in current working directory
|
|
63
|
-
this.configPath = configPath || path.join(process.cwd(),
|
|
63
|
+
this.configPath = configPath || path.join(process.cwd(), "opencode.json");
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
public static getInstance(configPath?: string): ConfigLoader {
|
|
67
67
|
if (!ConfigLoader.instance) {
|
|
68
|
-
ConfigLoader.instance = new ConfigLoader(configPath)
|
|
68
|
+
ConfigLoader.instance = new ConfigLoader(configPath);
|
|
69
69
|
}
|
|
70
|
-
return ConfigLoader.instance
|
|
70
|
+
return ConfigLoader.instance;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Clear the singleton instance (for testing purposes)
|
|
75
75
|
*/
|
|
76
76
|
public static clearInstance(): void {
|
|
77
|
-
ConfigLoader.instance = null as any
|
|
77
|
+
ConfigLoader.instance = null as any;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -82,29 +82,24 @@ export class ConfigLoader {
|
|
|
82
82
|
*/
|
|
83
83
|
public loadConfig(): OpenCodeConfig {
|
|
84
84
|
if (this.config) {
|
|
85
|
-
return this.config
|
|
85
|
+
return this.config;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
try {
|
|
89
89
|
if (!fs.existsSync(this.configPath)) {
|
|
90
|
-
throw new Error(`Configuration file not found: ${this.configPath}`)
|
|
90
|
+
throw new Error(`Configuration file not found: ${this.configPath}`);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const configContent = fs.readFileSync(this.configPath,
|
|
94
|
-
this.config = JSON.parse(configContent) as OpenCodeConfig
|
|
93
|
+
const configContent = fs.readFileSync(this.configPath, "utf8");
|
|
94
|
+
this.config = JSON.parse(configContent) as OpenCodeConfig;
|
|
95
95
|
|
|
96
|
-
logger.debug(`Loaded configuration from ${this.configPath}`)
|
|
97
|
-
return this.config
|
|
96
|
+
logger.debug(`Loaded configuration from ${this.configPath}`);
|
|
97
|
+
return this.config;
|
|
98
98
|
} catch (error) {
|
|
99
|
-
logger.error(
|
|
100
|
-
`Failed to load configuration from ${this.configPath}:`,
|
|
101
|
-
error
|
|
102
|
-
)
|
|
99
|
+
logger.error(`Failed to load configuration from ${this.configPath}:`, error);
|
|
103
100
|
throw new Error(
|
|
104
|
-
`Failed to load configuration: ${
|
|
105
|
-
|
|
106
|
-
}`
|
|
107
|
-
)
|
|
101
|
+
`Failed to load configuration: ${error instanceof Error ? error.message : String(error)}`
|
|
102
|
+
);
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
|
|
@@ -113,11 +108,11 @@ export class ConfigLoader {
|
|
|
113
108
|
*/
|
|
114
109
|
public getAgentConfig(agentName: string): AgentConfig | null {
|
|
115
110
|
try {
|
|
116
|
-
const config = this.loadConfig()
|
|
117
|
-
return config.agent?.[agentName] || null
|
|
118
|
-
} catch
|
|
111
|
+
const config = this.loadConfig();
|
|
112
|
+
return config.agent?.[agentName] || null;
|
|
113
|
+
} catch {
|
|
119
114
|
// Config file doesn't exist, return null
|
|
120
|
-
return null
|
|
115
|
+
return null;
|
|
121
116
|
}
|
|
122
117
|
}
|
|
123
118
|
|
|
@@ -126,11 +121,11 @@ export class ConfigLoader {
|
|
|
126
121
|
*/
|
|
127
122
|
public getAllAgentConfigs(): Record<string, AgentConfig> {
|
|
128
123
|
try {
|
|
129
|
-
const config = this.loadConfig()
|
|
130
|
-
return config.agent || {}
|
|
131
|
-
} catch
|
|
124
|
+
const config = this.loadConfig();
|
|
125
|
+
return config.agent || {};
|
|
126
|
+
} catch {
|
|
132
127
|
// Config file doesn't exist, return empty object
|
|
133
|
-
return {}
|
|
128
|
+
return {};
|
|
134
129
|
}
|
|
135
130
|
}
|
|
136
131
|
|
|
@@ -139,19 +134,19 @@ export class ConfigLoader {
|
|
|
139
134
|
*/
|
|
140
135
|
public getModelConfig(): ModelConfig {
|
|
141
136
|
try {
|
|
142
|
-
const config = this.loadConfig()
|
|
137
|
+
const config = this.loadConfig();
|
|
143
138
|
|
|
144
139
|
// Extract from config or fall back to defaults
|
|
145
|
-
const primary = config.model ||
|
|
146
|
-
const small = config.small_model ||
|
|
140
|
+
const primary = config.model || "berget/glm-4.7";
|
|
141
|
+
const small = config.small_model || "berget/gpt-oss";
|
|
147
142
|
|
|
148
|
-
return { primary, small }
|
|
149
|
-
} catch
|
|
143
|
+
return { primary, small };
|
|
144
|
+
} catch {
|
|
150
145
|
// Fallback to defaults when no config exists (init scenario)
|
|
151
146
|
return {
|
|
152
|
-
primary:
|
|
153
|
-
small:
|
|
154
|
-
}
|
|
147
|
+
primary: "berget/glm-4.7",
|
|
148
|
+
small: "berget/gpt-oss",
|
|
149
|
+
};
|
|
155
150
|
}
|
|
156
151
|
}
|
|
157
152
|
|
|
@@ -160,38 +155,35 @@ export class ConfigLoader {
|
|
|
160
155
|
*/
|
|
161
156
|
public getProviderModels(): Record<string, ProviderModelConfig> {
|
|
162
157
|
try {
|
|
163
|
-
const config = this.loadConfig()
|
|
158
|
+
const config = this.loadConfig();
|
|
164
159
|
|
|
165
160
|
// Extract from provider configuration
|
|
166
161
|
if (config.provider?.berget?.models) {
|
|
167
|
-
return config.provider.berget.models as Record<
|
|
168
|
-
string,
|
|
169
|
-
ProviderModelConfig
|
|
170
|
-
>
|
|
162
|
+
return config.provider.berget.models as Record<string, ProviderModelConfig>;
|
|
171
163
|
}
|
|
172
|
-
} catch
|
|
164
|
+
} catch {
|
|
173
165
|
// Config file doesn't exist, use fallback defaults
|
|
174
166
|
}
|
|
175
167
|
|
|
176
168
|
// Fallback to defaults
|
|
177
169
|
return {
|
|
178
|
-
|
|
179
|
-
name:
|
|
170
|
+
"glm-4.7": {
|
|
171
|
+
name: "GLM-4.7",
|
|
180
172
|
limit: { output: 4000, context: 90000 },
|
|
181
173
|
},
|
|
182
|
-
|
|
183
|
-
name:
|
|
174
|
+
"gpt-oss": {
|
|
175
|
+
name: "GPT-OSS",
|
|
184
176
|
limit: { output: 4000, context: 128000 },
|
|
185
177
|
modalities: {
|
|
186
|
-
input: [
|
|
187
|
-
output: [
|
|
178
|
+
input: ["text", "image"],
|
|
179
|
+
output: ["text"],
|
|
188
180
|
},
|
|
189
181
|
},
|
|
190
|
-
|
|
191
|
-
name:
|
|
182
|
+
"llama-8b": {
|
|
183
|
+
name: "llama-3.1-8b",
|
|
192
184
|
limit: { output: 4000, context: 128000 },
|
|
193
185
|
},
|
|
194
|
-
}
|
|
186
|
+
};
|
|
195
187
|
}
|
|
196
188
|
|
|
197
189
|
/**
|
|
@@ -199,11 +191,11 @@ export class ConfigLoader {
|
|
|
199
191
|
*/
|
|
200
192
|
public getCommandConfigs(): Record<string, any> {
|
|
201
193
|
try {
|
|
202
|
-
const config = this.loadConfig()
|
|
203
|
-
return config.command || {}
|
|
204
|
-
} catch
|
|
194
|
+
const config = this.loadConfig();
|
|
195
|
+
return config.command || {};
|
|
196
|
+
} catch {
|
|
205
197
|
// Config file doesn't exist, return empty object
|
|
206
|
-
return {}
|
|
198
|
+
return {};
|
|
207
199
|
}
|
|
208
200
|
}
|
|
209
201
|
|
|
@@ -212,15 +204,15 @@ export class ConfigLoader {
|
|
|
212
204
|
*/
|
|
213
205
|
public getWatcherConfig(): Record<string, any> {
|
|
214
206
|
try {
|
|
215
|
-
const config = this.loadConfig()
|
|
207
|
+
const config = this.loadConfig();
|
|
216
208
|
return (
|
|
217
209
|
config.watcher || {
|
|
218
|
-
ignore: [
|
|
210
|
+
ignore: ["node_modules", "dist", ".git", "coverage"],
|
|
219
211
|
}
|
|
220
|
-
)
|
|
221
|
-
} catch
|
|
212
|
+
);
|
|
213
|
+
} catch {
|
|
222
214
|
// Config file doesn't exist, return default watcher config
|
|
223
|
-
return { ignore: [
|
|
215
|
+
return { ignore: ["node_modules", "dist", ".git", "coverage"] };
|
|
224
216
|
}
|
|
225
217
|
}
|
|
226
218
|
|
|
@@ -229,11 +221,11 @@ export class ConfigLoader {
|
|
|
229
221
|
*/
|
|
230
222
|
public getProviderConfig(): Record<string, any> {
|
|
231
223
|
try {
|
|
232
|
-
const config = this.loadConfig()
|
|
233
|
-
return config.provider || {}
|
|
234
|
-
} catch
|
|
224
|
+
const config = this.loadConfig();
|
|
225
|
+
return config.provider || {};
|
|
226
|
+
} catch {
|
|
235
227
|
// Config file doesn't exist, return empty object
|
|
236
|
-
return {}
|
|
228
|
+
return {};
|
|
237
229
|
}
|
|
238
230
|
}
|
|
239
231
|
|
|
@@ -241,55 +233,53 @@ export class ConfigLoader {
|
|
|
241
233
|
* Check if an agent exists
|
|
242
234
|
*/
|
|
243
235
|
public hasAgent(agentName: string): boolean {
|
|
244
|
-
return agentName in this.getAllAgentConfigs()
|
|
236
|
+
return agentName in this.getAllAgentConfigs();
|
|
245
237
|
}
|
|
246
238
|
|
|
247
239
|
/**
|
|
248
240
|
* Get list of all available agent names
|
|
249
241
|
*/
|
|
250
242
|
public getAgentNames(): string[] {
|
|
251
|
-
return Object.keys(this.getAllAgentConfigs())
|
|
243
|
+
return Object.keys(this.getAllAgentConfigs());
|
|
252
244
|
}
|
|
253
245
|
|
|
254
246
|
/**
|
|
255
247
|
* Get list of primary agents (mode: 'primary')
|
|
256
248
|
*/
|
|
257
249
|
public getPrimaryAgentNames(): string[] {
|
|
258
|
-
const agents = this.getAllAgentConfigs()
|
|
259
|
-
return Object.keys(agents).filter(
|
|
250
|
+
const agents = this.getAllAgentConfigs();
|
|
251
|
+
return Object.keys(agents).filter(name => agents[name].mode === "primary");
|
|
260
252
|
}
|
|
261
253
|
|
|
262
254
|
/**
|
|
263
255
|
* Get list of subagents (mode: 'subagent')
|
|
264
256
|
*/
|
|
265
257
|
public getSubagentNames(): string[] {
|
|
266
|
-
const agents = this.getAllAgentConfigs()
|
|
267
|
-
return Object.keys(agents).filter(
|
|
268
|
-
(name) => agents[name].mode === 'subagent'
|
|
269
|
-
)
|
|
258
|
+
const agents = this.getAllAgentConfigs();
|
|
259
|
+
return Object.keys(agents).filter(name => agents[name].mode === "subagent");
|
|
270
260
|
}
|
|
271
261
|
|
|
272
262
|
/**
|
|
273
263
|
* Reload configuration from file
|
|
274
264
|
*/
|
|
275
265
|
public reloadConfig(): OpenCodeConfig {
|
|
276
|
-
this.config = null
|
|
277
|
-
return this.loadConfig()
|
|
266
|
+
this.config = null;
|
|
267
|
+
return this.loadConfig();
|
|
278
268
|
}
|
|
279
269
|
|
|
280
270
|
/**
|
|
281
271
|
* Set custom configuration path (for testing or different environments)
|
|
282
272
|
*/
|
|
283
273
|
public setConfigPath(configPath: string): void {
|
|
284
|
-
this.configPath = configPath
|
|
285
|
-
this.config = null // Force reload
|
|
274
|
+
this.configPath = configPath;
|
|
275
|
+
this.config = null; // Force reload
|
|
286
276
|
}
|
|
287
277
|
|
|
288
278
|
/**
|
|
289
279
|
* Get the current configuration path
|
|
290
280
|
*/
|
|
291
281
|
public getConfigPath(): string {
|
|
292
|
-
return this.configPath
|
|
282
|
+
return this.configPath;
|
|
293
283
|
}
|
|
294
284
|
}
|
|
295
285
|
|
|
@@ -297,40 +287,33 @@ export class ConfigLoader {
|
|
|
297
287
|
* Convenience function to get the config loader instance
|
|
298
288
|
*/
|
|
299
289
|
export function getConfigLoader(configPath?: string): ConfigLoader {
|
|
300
|
-
return ConfigLoader.getInstance(configPath)
|
|
290
|
+
return ConfigLoader.getInstance(configPath);
|
|
301
291
|
}
|
|
302
292
|
|
|
303
293
|
/**
|
|
304
294
|
* Convenience function to get agent configuration
|
|
305
295
|
*/
|
|
306
|
-
export function getAgentConfig(
|
|
307
|
-
agentName
|
|
308
|
-
configPath?: string
|
|
309
|
-
): AgentConfig | null {
|
|
310
|
-
return getConfigLoader(configPath).getAgentConfig(agentName)
|
|
296
|
+
export function getAgentConfig(agentName: string, configPath?: string): AgentConfig | null {
|
|
297
|
+
return getConfigLoader(configPath).getAgentConfig(agentName);
|
|
311
298
|
}
|
|
312
299
|
|
|
313
300
|
/**
|
|
314
301
|
* Convenience function to get all agent configurations
|
|
315
302
|
*/
|
|
316
|
-
export function getAllAgentConfigs(
|
|
317
|
-
configPath
|
|
318
|
-
): Record<string, AgentConfig> {
|
|
319
|
-
return getConfigLoader(configPath).getAllAgentConfigs()
|
|
303
|
+
export function getAllAgentConfigs(configPath?: string): Record<string, AgentConfig> {
|
|
304
|
+
return getConfigLoader(configPath).getAllAgentConfigs();
|
|
320
305
|
}
|
|
321
306
|
|
|
322
307
|
/**
|
|
323
308
|
* Convenience function to get model configuration
|
|
324
309
|
*/
|
|
325
310
|
export function getModelConfig(configPath?: string): ModelConfig {
|
|
326
|
-
return getConfigLoader(configPath).getModelConfig()
|
|
311
|
+
return getConfigLoader(configPath).getModelConfig();
|
|
327
312
|
}
|
|
328
313
|
|
|
329
314
|
/**
|
|
330
315
|
* Convenience function to get provider models
|
|
331
316
|
*/
|
|
332
|
-
export function getProviderModels(
|
|
333
|
-
configPath
|
|
334
|
-
): Record<string, ProviderModelConfig> {
|
|
335
|
-
return getConfigLoader(configPath).getProviderModels()
|
|
317
|
+
export function getProviderModels(configPath?: string): Record<string, ProviderModelConfig> {
|
|
318
|
+
return getConfigLoader(configPath).getProviderModels();
|
|
336
319
|
}
|