@ai-ide-bridge/cli 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/.turbo/turbo-build.log +1 -1
- package/dist/commands/configure.js +78 -10
- package/dist/commands/init.js +40 -1
- package/dist/utils/opencode.d.ts +3 -1
- package/dist/utils/opencode.js +3 -3
- package/package.json +1 -1
- package/src/commands/configure.ts +107 -12
- package/src/commands/init.ts +43 -1
- package/src/utils/opencode.ts +4 -3
- package/test/configure.test.ts +19 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { findOpencodeConfig, injectProvider } from '../utils/opencode.js';
|
|
2
2
|
import { readConfig } from '../utils/config.js';
|
|
3
|
+
import { createInterface } from 'node:readline';
|
|
4
|
+
import { CursorBridgePlugin } from '../plugins/cursor/index.js';
|
|
5
|
+
import { CopilotBridgePlugin } from '../plugins/copilot/index.js';
|
|
6
|
+
import { WindsurfBridgePlugin } from '../plugins/windsurf/index.js';
|
|
7
|
+
const PROVIDER_PLUGINS = {
|
|
8
|
+
cursor: CursorBridgePlugin,
|
|
9
|
+
copilot: CopilotBridgePlugin,
|
|
10
|
+
windsurf: WindsurfBridgePlugin,
|
|
11
|
+
};
|
|
3
12
|
export async function configureOpencodeCommand() {
|
|
4
13
|
const configPath = findOpencodeConfig();
|
|
5
14
|
if (!configPath) {
|
|
@@ -7,15 +16,74 @@ export async function configureOpencodeCommand() {
|
|
|
7
16
|
process.exit(1);
|
|
8
17
|
}
|
|
9
18
|
const bridgeConfig = readConfig();
|
|
19
|
+
const configuredPlugins = Object.keys(bridgeConfig.plugins || {});
|
|
20
|
+
if (configuredPlugins.length === 0) {
|
|
21
|
+
console.error('No plugins configured. Run `llm-bridge init` first.');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const allSelectedModels = {};
|
|
25
|
+
let firstSelectedModelId = null;
|
|
26
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
27
|
+
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
28
|
+
for (const pluginName of configuredPlugins) {
|
|
29
|
+
const PluginClass = PROVIDER_PLUGINS[pluginName];
|
|
30
|
+
if (!PluginClass) {
|
|
31
|
+
console.warn(`Skipping unknown provider: ${pluginName}`);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const plugin = new PluginClass();
|
|
35
|
+
const pluginConfig = bridgeConfig.plugins[pluginName];
|
|
36
|
+
let models;
|
|
37
|
+
try {
|
|
38
|
+
models = await plugin.listModels(pluginConfig);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
console.warn(`Failed to list models for ${pluginName}: ${e instanceof Error ? e.message : String(e)}`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (models.length === 0) {
|
|
45
|
+
console.warn(`No models available for ${pluginName}.`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
console.log(`\nModels available for ${pluginName}:`);
|
|
49
|
+
models.forEach((m, i) => {
|
|
50
|
+
console.log(` ${i + 1}) ${pluginName}/${m.id}`);
|
|
51
|
+
});
|
|
52
|
+
const input = await ask(`Select models (comma-separated numbers, 'all', or 'skip'): `);
|
|
53
|
+
let selectedIndices = [];
|
|
54
|
+
if (input.toLowerCase() === 'all') {
|
|
55
|
+
selectedIndices = models.map((_, i) => i);
|
|
56
|
+
}
|
|
57
|
+
else if (input.toLowerCase() === 'skip') {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
selectedIndices = input
|
|
62
|
+
.split(',')
|
|
63
|
+
.map((s) => parseInt(s.trim(), 10) - 1)
|
|
64
|
+
.filter((i) => i >= 0 && i < models.length);
|
|
65
|
+
}
|
|
66
|
+
if (selectedIndices.length === 0) {
|
|
67
|
+
console.log(`No models selected for ${pluginName}. Skipping.`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
for (const idx of selectedIndices) {
|
|
71
|
+
const model = models[idx];
|
|
72
|
+
const qualifiedId = `${pluginName}/${model.id}`;
|
|
73
|
+
allSelectedModels[qualifiedId] = { name: qualifiedId };
|
|
74
|
+
if (!firstSelectedModelId) {
|
|
75
|
+
firstSelectedModelId = qualifiedId;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
rl.close();
|
|
80
|
+
if (Object.keys(allSelectedModels).length === 0) {
|
|
81
|
+
console.error('No models selected. Run `llm-bridge configure` again to try again.');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
10
84
|
const providerId = 'llm-bridge';
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
? 'windsurf/claude-4.5-sonnet'
|
|
16
|
-
: 'cursor/composer-2';
|
|
17
|
-
injectProvider(configPath, providerId, modelId, bridgeConfig.port);
|
|
18
|
-
console.log(`Injected provider into ${configPath}`);
|
|
19
|
-
console.log(`Provider: ${providerId}, Model: ${modelId}, Port: ${bridgeConfig.port}`);
|
|
20
|
-
console.log(`Plugin: ${plugin}`);
|
|
85
|
+
injectProvider(configPath, providerId, allSelectedModels, bridgeConfig.port, firstSelectedModelId);
|
|
86
|
+
const modelCount = Object.keys(allSelectedModels).length;
|
|
87
|
+
console.log(`\nInjected provider into ${configPath}`);
|
|
88
|
+
console.log(`Provider: ${providerId}, Models: ${modelCount}, Default: ${firstSelectedModelId}`);
|
|
21
89
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -3,6 +3,7 @@ import { CursorBridgePlugin } from '../plugins/cursor/index.js';
|
|
|
3
3
|
import { CopilotBridgePlugin } from '../plugins/copilot/index.js';
|
|
4
4
|
import { WindsurfBridgePlugin } from '../plugins/windsurf/index.js';
|
|
5
5
|
import { createInterface } from 'node:readline';
|
|
6
|
+
import { stdin as processStdin, stdout as processStdout } from 'node:process';
|
|
6
7
|
import { loginCommand } from './login.js';
|
|
7
8
|
const PROVIDERS = ['cursor', 'copilot', 'windsurf'];
|
|
8
9
|
async function getProviderPlugin(provider) {
|
|
@@ -43,6 +44,44 @@ async function authenticateWithOAuth(provider) {
|
|
|
43
44
|
console.log(`OAuth not available for ${provider}. Use token authentication instead.`);
|
|
44
45
|
return false;
|
|
45
46
|
}
|
|
47
|
+
async function askHidden(prompt) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const stdin = processStdin;
|
|
50
|
+
const stdout = processStdout;
|
|
51
|
+
stdout.write(prompt);
|
|
52
|
+
const wasRaw = stdin.isRaw;
|
|
53
|
+
stdin.setRawMode(true);
|
|
54
|
+
stdin.resume();
|
|
55
|
+
let input = '';
|
|
56
|
+
const onData = (data) => {
|
|
57
|
+
const char = data.toString();
|
|
58
|
+
if (char === '\r' || char === '\n') {
|
|
59
|
+
stdin.setRawMode(wasRaw);
|
|
60
|
+
stdin.pause();
|
|
61
|
+
stdin.removeListener('data', onData);
|
|
62
|
+
stdout.write('\n');
|
|
63
|
+
resolve(input);
|
|
64
|
+
}
|
|
65
|
+
else if (char === '\x7f' || char === '\b') {
|
|
66
|
+
if (input.length > 0) {
|
|
67
|
+
input = input.slice(0, -1);
|
|
68
|
+
stdout.write('\b \b');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (char === '\x03') {
|
|
72
|
+
stdin.setRawMode(wasRaw);
|
|
73
|
+
stdin.pause();
|
|
74
|
+
stdin.removeListener('data', onData);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
input += char;
|
|
79
|
+
stdout.write('*');
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
stdin.on('data', onData);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
46
85
|
export async function initCommand() {
|
|
47
86
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
48
87
|
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
@@ -82,7 +121,7 @@ export async function initCommand() {
|
|
|
82
121
|
}
|
|
83
122
|
}
|
|
84
123
|
const envVar = getEnvVar(provider);
|
|
85
|
-
const credential = await
|
|
124
|
+
const credential = await askHidden(getCredentialPrompt(provider));
|
|
86
125
|
if (!credential) {
|
|
87
126
|
console.error('Credential is required.');
|
|
88
127
|
continue;
|
package/dist/utils/opencode.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function findOpencodeConfig(): string | null;
|
|
2
|
-
export declare function injectProvider(configPath: string, providerId: string,
|
|
2
|
+
export declare function injectProvider(configPath: string, providerId: string, models: Record<string, {
|
|
3
|
+
name: string;
|
|
4
|
+
}>, port: number, defaultModelId: string): void;
|
package/dist/utils/opencode.js
CHANGED
|
@@ -14,7 +14,7 @@ export function findOpencodeConfig() {
|
|
|
14
14
|
}
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
export function injectProvider(configPath, providerId,
|
|
17
|
+
export function injectProvider(configPath, providerId, models, port, defaultModelId) {
|
|
18
18
|
const raw = fs.readFileSync(configPath, 'utf8');
|
|
19
19
|
let config;
|
|
20
20
|
try {
|
|
@@ -32,8 +32,8 @@ export function injectProvider(configPath, providerId, modelId, port) {
|
|
|
32
32
|
apiKey: 'bridge-local',
|
|
33
33
|
baseURL: `http://127.0.0.1:${port}/v1`,
|
|
34
34
|
},
|
|
35
|
-
models
|
|
35
|
+
models,
|
|
36
36
|
};
|
|
37
|
-
config.model = `${providerId}/${
|
|
37
|
+
config.model = `${providerId}/${defaultModelId}`;
|
|
38
38
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { findOpencodeConfig, injectProvider } from '../utils/opencode.js';
|
|
2
2
|
import { readConfig } from '../utils/config.js';
|
|
3
|
+
import { createInterface } from 'node:readline';
|
|
4
|
+
import { CursorBridgePlugin } from '../plugins/cursor/index.js';
|
|
5
|
+
import { CopilotBridgePlugin } from '../plugins/copilot/index.js';
|
|
6
|
+
import { WindsurfBridgePlugin } from '../plugins/windsurf/index.js';
|
|
7
|
+
|
|
8
|
+
const PROVIDER_PLUGINS: Record<
|
|
9
|
+
string,
|
|
10
|
+
new () => {
|
|
11
|
+
name: string;
|
|
12
|
+
listModels(config: Record<string, string>): Promise<{ id: string; name: string }[]>;
|
|
13
|
+
}
|
|
14
|
+
> = {
|
|
15
|
+
cursor: CursorBridgePlugin,
|
|
16
|
+
copilot: CopilotBridgePlugin,
|
|
17
|
+
windsurf: WindsurfBridgePlugin,
|
|
18
|
+
};
|
|
3
19
|
|
|
4
20
|
export async function configureOpencodeCommand(): Promise<void> {
|
|
5
21
|
const configPath = findOpencodeConfig();
|
|
@@ -9,17 +25,96 @@ export async function configureOpencodeCommand(): Promise<void> {
|
|
|
9
25
|
}
|
|
10
26
|
|
|
11
27
|
const bridgeConfig = readConfig();
|
|
28
|
+
const configuredPlugins = Object.keys(bridgeConfig.plugins || {});
|
|
29
|
+
|
|
30
|
+
if (configuredPlugins.length === 0) {
|
|
31
|
+
console.error('No plugins configured. Run `llm-bridge init` first.');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const allSelectedModels: Record<string, { name: string }> = {};
|
|
36
|
+
let firstSelectedModelId: string | null = null;
|
|
37
|
+
|
|
38
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
39
|
+
const ask = (q: string) => new Promise<string>((resolve) => rl.question(q, resolve));
|
|
40
|
+
|
|
41
|
+
for (const pluginName of configuredPlugins) {
|
|
42
|
+
const PluginClass = PROVIDER_PLUGINS[pluginName];
|
|
43
|
+
if (!PluginClass) {
|
|
44
|
+
console.warn(`Skipping unknown provider: ${pluginName}`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const plugin = new PluginClass();
|
|
49
|
+
const pluginConfig = bridgeConfig.plugins[pluginName];
|
|
50
|
+
|
|
51
|
+
let models: { id: string; name: string }[];
|
|
52
|
+
try {
|
|
53
|
+
models = await plugin.listModels(pluginConfig);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.warn(
|
|
56
|
+
`Failed to list models for ${pluginName}: ${e instanceof Error ? e.message : String(e)}`,
|
|
57
|
+
);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (models.length === 0) {
|
|
62
|
+
console.warn(`No models available for ${pluginName}.`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.log(`\nModels available for ${pluginName}:`);
|
|
67
|
+
models.forEach((m, i) => {
|
|
68
|
+
console.log(` ${i + 1}) ${pluginName}/${m.id}`);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const input = await ask(`Select models (comma-separated numbers, 'all', or 'skip'): `);
|
|
72
|
+
|
|
73
|
+
let selectedIndices: number[] = [];
|
|
74
|
+
|
|
75
|
+
if (input.toLowerCase() === 'all') {
|
|
76
|
+
selectedIndices = models.map((_, i) => i);
|
|
77
|
+
} else if (input.toLowerCase() === 'skip') {
|
|
78
|
+
continue;
|
|
79
|
+
} else {
|
|
80
|
+
selectedIndices = input
|
|
81
|
+
.split(',')
|
|
82
|
+
.map((s) => parseInt(s.trim(), 10) - 1)
|
|
83
|
+
.filter((i) => i >= 0 && i < models.length);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (selectedIndices.length === 0) {
|
|
87
|
+
console.log(`No models selected for ${pluginName}. Skipping.`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const idx of selectedIndices) {
|
|
92
|
+
const model = models[idx];
|
|
93
|
+
const qualifiedId = `${pluginName}/${model.id}`;
|
|
94
|
+
allSelectedModels[qualifiedId] = { name: qualifiedId };
|
|
95
|
+
if (!firstSelectedModelId) {
|
|
96
|
+
firstSelectedModelId = qualifiedId;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
rl.close();
|
|
102
|
+
|
|
103
|
+
if (Object.keys(allSelectedModels).length === 0) {
|
|
104
|
+
console.error('No models selected. Run `llm-bridge configure` again to try again.');
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
12
108
|
const providerId = 'llm-bridge';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
console.log(
|
|
23
|
-
console.log(`Provider: ${providerId},
|
|
24
|
-
console.log(`Plugin: ${plugin}`);
|
|
109
|
+
injectProvider(
|
|
110
|
+
configPath,
|
|
111
|
+
providerId,
|
|
112
|
+
allSelectedModels,
|
|
113
|
+
bridgeConfig.port,
|
|
114
|
+
firstSelectedModelId!,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const modelCount = Object.keys(allSelectedModels).length;
|
|
118
|
+
console.log(`\nInjected provider into ${configPath}`);
|
|
119
|
+
console.log(`Provider: ${providerId}, Models: ${modelCount}, Default: ${firstSelectedModelId}`);
|
|
25
120
|
}
|
package/src/commands/init.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CursorBridgePlugin } from '../plugins/cursor/index.js';
|
|
|
3
3
|
import { CopilotBridgePlugin } from '../plugins/copilot/index.js';
|
|
4
4
|
import { WindsurfBridgePlugin } from '../plugins/windsurf/index.js';
|
|
5
5
|
import { createInterface } from 'node:readline';
|
|
6
|
+
import { stdin as processStdin, stdout as processStdout } from 'node:process';
|
|
6
7
|
import { loginCommand } from './login.js';
|
|
7
8
|
|
|
8
9
|
const PROVIDERS = ['cursor', 'copilot', 'windsurf'] as const;
|
|
@@ -50,6 +51,47 @@ async function authenticateWithOAuth(provider: Provider): Promise<boolean> {
|
|
|
50
51
|
return false;
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
async function askHidden(prompt: string): Promise<string> {
|
|
55
|
+
return new Promise<string>((resolve, reject) => {
|
|
56
|
+
const stdin = processStdin;
|
|
57
|
+
const stdout = processStdout;
|
|
58
|
+
|
|
59
|
+
stdout.write(prompt);
|
|
60
|
+
|
|
61
|
+
const wasRaw = stdin.isRaw;
|
|
62
|
+
stdin.setRawMode(true);
|
|
63
|
+
stdin.resume();
|
|
64
|
+
|
|
65
|
+
let input = '';
|
|
66
|
+
|
|
67
|
+
const onData = (data: Buffer) => {
|
|
68
|
+
const char = data.toString();
|
|
69
|
+
if (char === '\r' || char === '\n') {
|
|
70
|
+
stdin.setRawMode(wasRaw);
|
|
71
|
+
stdin.pause();
|
|
72
|
+
stdin.removeListener('data', onData);
|
|
73
|
+
stdout.write('\n');
|
|
74
|
+
resolve(input);
|
|
75
|
+
} else if (char === '\x7f' || char === '\b') {
|
|
76
|
+
if (input.length > 0) {
|
|
77
|
+
input = input.slice(0, -1);
|
|
78
|
+
stdout.write('\b \b');
|
|
79
|
+
}
|
|
80
|
+
} else if (char === '\x03') {
|
|
81
|
+
stdin.setRawMode(wasRaw);
|
|
82
|
+
stdin.pause();
|
|
83
|
+
stdin.removeListener('data', onData);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
} else {
|
|
86
|
+
input += char;
|
|
87
|
+
stdout.write('*');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
stdin.on('data', onData);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
53
95
|
export async function initCommand(): Promise<void> {
|
|
54
96
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
55
97
|
const ask = (q: string) => new Promise<string>((resolve) => rl.question(q, resolve));
|
|
@@ -95,7 +137,7 @@ export async function initCommand(): Promise<void> {
|
|
|
95
137
|
}
|
|
96
138
|
|
|
97
139
|
const envVar = getEnvVar(provider);
|
|
98
|
-
const credential = await
|
|
140
|
+
const credential = await askHidden(getCredentialPrompt(provider));
|
|
99
141
|
if (!credential) {
|
|
100
142
|
console.error('Credential is required.');
|
|
101
143
|
continue;
|
package/src/utils/opencode.ts
CHANGED
|
@@ -18,8 +18,9 @@ export function findOpencodeConfig(): string | null {
|
|
|
18
18
|
export function injectProvider(
|
|
19
19
|
configPath: string,
|
|
20
20
|
providerId: string,
|
|
21
|
-
|
|
21
|
+
models: Record<string, { name: string }>,
|
|
22
22
|
port: number,
|
|
23
|
+
defaultModelId: string,
|
|
23
24
|
): void {
|
|
24
25
|
const raw = fs.readFileSync(configPath, 'utf8');
|
|
25
26
|
let config: any;
|
|
@@ -36,8 +37,8 @@ export function injectProvider(
|
|
|
36
37
|
apiKey: 'bridge-local',
|
|
37
38
|
baseURL: `http://127.0.0.1:${port}/v1`,
|
|
38
39
|
},
|
|
39
|
-
models
|
|
40
|
+
models,
|
|
40
41
|
};
|
|
41
|
-
config.model = `${providerId}/${
|
|
42
|
+
config.model = `${providerId}/${defaultModelId}`;
|
|
42
43
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
43
44
|
}
|
package/test/configure.test.ts
CHANGED
|
@@ -12,17 +12,32 @@ describe('opencode utils', () => {
|
|
|
12
12
|
fs.writeFileSync(tmpFile, '{}');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('injects provider into empty config', () => {
|
|
16
|
-
|
|
15
|
+
it('injects provider with single model into empty config', () => {
|
|
16
|
+
const models = { 'cursor/composer-2': { name: 'cursor/composer-2' } };
|
|
17
|
+
injectProvider(tmpFile, 'test-provider', models, 3849, 'cursor/composer-2');
|
|
17
18
|
const config = JSON.parse(fs.readFileSync(tmpFile, 'utf8'));
|
|
18
19
|
expect(config.provider['test-provider']).toBeDefined();
|
|
19
20
|
expect(config.provider['test-provider'].options.baseURL).toBe('http://127.0.0.1:3849/v1');
|
|
20
|
-
expect(config.
|
|
21
|
+
expect(config.provider['test-provider'].models['cursor/composer-2']).toBeDefined();
|
|
22
|
+
expect(config.model).toBe('test-provider/cursor/composer-2');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('injects provider with multiple models', () => {
|
|
26
|
+
const models = {
|
|
27
|
+
'cursor/composer-2': { name: 'cursor/composer-2' },
|
|
28
|
+
'cursor/gpt-4o': { name: 'cursor/gpt-4o' },
|
|
29
|
+
};
|
|
30
|
+
injectProvider(tmpFile, 'test-provider', models, 3849, 'cursor/gpt-4o');
|
|
31
|
+
const config = JSON.parse(fs.readFileSync(tmpFile, 'utf8'));
|
|
32
|
+
expect(config.provider['test-provider'].models['cursor/composer-2']).toBeDefined();
|
|
33
|
+
expect(config.provider['test-provider'].models['cursor/gpt-4o']).toBeDefined();
|
|
34
|
+
expect(config.model).toBe('test-provider/cursor/gpt-4o');
|
|
21
35
|
});
|
|
22
36
|
|
|
23
37
|
it('preserves existing config fields', () => {
|
|
24
38
|
fs.writeFileSync(tmpFile, JSON.stringify({ existing: 'value' }));
|
|
25
|
-
|
|
39
|
+
const models = { 'cursor/composer-2': { name: 'cursor/composer-2' } };
|
|
40
|
+
injectProvider(tmpFile, 'test-provider', models, 3849, 'cursor/composer-2');
|
|
26
41
|
const config = JSON.parse(fs.readFileSync(tmpFile, 'utf8'));
|
|
27
42
|
expect(config.existing).toBe('value');
|
|
28
43
|
expect(config.provider['test-provider']).toBeDefined();
|