chutes-plugin 0.1.1 → 0.1.2
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/bin/chutes-plugin +2 -0
- package/dist/cli/chutes-plugin.js +2 -0
- package/dist/cli/index.js +106 -127
- package/package.json +4 -3
- package/src/cli/install.ts +109 -136
package/dist/cli/index.js
CHANGED
|
@@ -51,23 +51,15 @@ async function install(options) {
|
|
|
51
51
|
input: process.stdin,
|
|
52
52
|
output: process.stdout
|
|
53
53
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
rl.
|
|
57
|
-
|
|
58
|
-
resolve(answer.trim());
|
|
59
|
-
});
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
rl.close();
|
|
62
|
-
reject(new Error("Timeout waiting for user input"));
|
|
63
|
-
}, 1e4);
|
|
54
|
+
installType = await new Promise((resolve) => {
|
|
55
|
+
rl.question("> ", (answer) => {
|
|
56
|
+
rl.close();
|
|
57
|
+
resolve(answer.trim());
|
|
64
58
|
});
|
|
65
|
-
}
|
|
66
|
-
console.log(`No input detected, defaulting to npm installation...
|
|
67
|
-
`);
|
|
68
|
-
installType = "npm";
|
|
69
|
-
}
|
|
59
|
+
});
|
|
70
60
|
}
|
|
61
|
+
console.log(`Installing type: ${installType}
|
|
62
|
+
`);
|
|
71
63
|
switch (installType) {
|
|
72
64
|
case "1":
|
|
73
65
|
case "project":
|
|
@@ -82,7 +74,7 @@ async function install(options) {
|
|
|
82
74
|
await installNpm();
|
|
83
75
|
break;
|
|
84
76
|
default:
|
|
85
|
-
console.log(
|
|
77
|
+
console.log(`\u274C Invalid installation type: "${installType}"`);
|
|
86
78
|
console.log("Please choose: 1 (project), 2 (global), or 3 (npm)");
|
|
87
79
|
process.exit(1);
|
|
88
80
|
}
|
|
@@ -93,142 +85,129 @@ async function installProject() {
|
|
|
93
85
|
const pluginDir = path.join(opencodeDir, "plugin", "chutes-plugin");
|
|
94
86
|
console.log(`Installing to project...
|
|
95
87
|
`);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
config = {};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const plugins = config.plugins || [];
|
|
124
|
-
if (!Array.isArray(plugins)) {
|
|
125
|
-
config.plugins = [];
|
|
126
|
-
}
|
|
127
|
-
const pluginPath = "./.opencode/plugin/chutes-plugin/dist/index.js";
|
|
128
|
-
if (!plugins.includes(pluginPath)) {
|
|
129
|
-
config.plugins.push(pluginPath);
|
|
88
|
+
if (!fs.existsSync(opencodeDir)) {
|
|
89
|
+
fs.mkdirSync(opencodeDir, { recursive: true });
|
|
90
|
+
}
|
|
91
|
+
if (!fs.existsSync(path.join(opencodeDir, "plugin"))) {
|
|
92
|
+
fs.mkdirSync(path.join(opencodeDir, "plugin"), { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
95
|
+
const distDir = path.join(__dirname, "..", "..", "dist");
|
|
96
|
+
if (fs.existsSync(distDir)) {
|
|
97
|
+
fs.cpSync(distDir, path.join(pluginDir, "dist"), { recursive: true });
|
|
98
|
+
}
|
|
99
|
+
const srcCliDir = path.join(__dirname, "..");
|
|
100
|
+
if (fs.existsSync(srcCliDir)) {
|
|
101
|
+
fs.cpSync(srcCliDir, path.join(pluginDir, "src"), { recursive: true });
|
|
102
|
+
}
|
|
103
|
+
const packageJsonPath = path.join(opencodeDir, "opencode.json");
|
|
104
|
+
let config = {};
|
|
105
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
106
|
+
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
107
|
+
try {
|
|
108
|
+
config = JSON.parse(content);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
111
|
+
process.exit(1);
|
|
130
112
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
113
|
+
}
|
|
114
|
+
config.plugins = config.plugins || [];
|
|
115
|
+
if (!Array.isArray(config.plugins)) {
|
|
116
|
+
config.plugins = [];
|
|
117
|
+
}
|
|
118
|
+
const pluginPath = "./.opencode/plugin/chutes-plugin/dist/index.js";
|
|
119
|
+
if (!config.plugins.includes(pluginPath)) {
|
|
120
|
+
config.plugins.push(pluginPath);
|
|
121
|
+
}
|
|
122
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(config, null, 2));
|
|
123
|
+
console.log("\u2705 Successfully installed to project!");
|
|
124
|
+
console.log(` Location: ${pluginDir}`);
|
|
125
|
+
console.log(`
|
|
134
126
|
Next steps:`);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
console.log("1. Start OpenCode: opencode");
|
|
128
|
+
console.log("2. Connect your Chutes token: /connect chutes");
|
|
129
|
+
console.log(`3. Select a Chutes model from the dropdown
|
|
138
130
|
`);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.log(`\u274C Error installing to project: ${error instanceof Error ? error.message : String(error)}`);
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|
|
143
131
|
}
|
|
144
132
|
async function installGlobal() {
|
|
145
133
|
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
146
134
|
if (!homeDir) {
|
|
147
|
-
console.
|
|
135
|
+
console.error("\u274C Error: Could not determine home directory");
|
|
148
136
|
process.exit(1);
|
|
149
137
|
}
|
|
150
138
|
const configDir = path.join(homeDir, ".config", "opencode");
|
|
151
139
|
const pluginDir = path.join(configDir, "plugin", "chutes-plugin");
|
|
152
140
|
console.log(`Installing globally...
|
|
153
141
|
`);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
config = {};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
config.plugins = config.plugins || [];
|
|
176
|
-
if (!Array.isArray(config.plugins)) {
|
|
177
|
-
config.plugins = [];
|
|
178
|
-
}
|
|
179
|
-
const pluginPath = `${configDir}/plugin/chutes-plugin/dist/index.js`;
|
|
180
|
-
if (!config.plugins.includes(pluginPath)) {
|
|
181
|
-
config.plugins.push(pluginPath);
|
|
142
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
143
|
+
const distDir = path.join(__dirname, "..", "..", "dist");
|
|
144
|
+
if (fs.existsSync(distDir)) {
|
|
145
|
+
fs.cpSync(distDir, path.join(pluginDir, "dist"), { recursive: true });
|
|
146
|
+
}
|
|
147
|
+
const srcCliDir = path.join(__dirname, "..");
|
|
148
|
+
if (fs.existsSync(srcCliDir)) {
|
|
149
|
+
fs.cpSync(srcCliDir, path.join(pluginDir, "src"), { recursive: true });
|
|
150
|
+
}
|
|
151
|
+
const configPath = path.join(configDir, "opencode.json");
|
|
152
|
+
let config = {};
|
|
153
|
+
if (fs.existsSync(configPath)) {
|
|
154
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
155
|
+
try {
|
|
156
|
+
config = JSON.parse(content);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
159
|
+
process.exit(1);
|
|
182
160
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
161
|
+
}
|
|
162
|
+
config.plugins = config.plugins || [];
|
|
163
|
+
if (!Array.isArray(config.plugins)) {
|
|
164
|
+
config.plugins = [];
|
|
165
|
+
}
|
|
166
|
+
const pluginPath = `${configDir}/plugin/chutes-plugin/dist/index.js`;
|
|
167
|
+
if (!config.plugins.includes(pluginPath)) {
|
|
168
|
+
config.plugins.push(pluginPath);
|
|
169
|
+
}
|
|
170
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
171
|
+
console.log("\u2705 Successfully installed globally!");
|
|
172
|
+
console.log(` Location: ${pluginDir}`);
|
|
173
|
+
console.log(`
|
|
186
174
|
Next steps:`);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
175
|
+
console.log("1. Start OpenCode: opencode");
|
|
176
|
+
console.log("2. Connect your Chutes token: /connect chutes");
|
|
177
|
+
console.log(`3. Select a Chutes model from the dropdown
|
|
190
178
|
`);
|
|
191
|
-
} catch (error) {
|
|
192
|
-
console.log(`\u274C Error installing globally: ${error instanceof Error ? error.message : String(error)}`);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
179
|
}
|
|
196
180
|
async function installNpm() {
|
|
197
181
|
const projectDir = process.cwd();
|
|
198
182
|
const configPath = path.join(projectDir, "opencode.json");
|
|
199
183
|
console.log(`Installing via npm...
|
|
200
184
|
`);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
config = {};
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
config.plugins = config.plugins || [];
|
|
213
|
-
if (!Array.isArray(config.plugins)) {
|
|
214
|
-
config.plugins = [];
|
|
215
|
-
}
|
|
216
|
-
if (!config.plugins.includes("chutes-plugin")) {
|
|
217
|
-
config.plugins.push("chutes-plugin");
|
|
185
|
+
let config = {};
|
|
186
|
+
if (fs.existsSync(configPath)) {
|
|
187
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
188
|
+
try {
|
|
189
|
+
config = JSON.parse(content);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
192
|
+
process.exit(1);
|
|
218
193
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
194
|
+
}
|
|
195
|
+
config.plugins = config.plugins || [];
|
|
196
|
+
if (!Array.isArray(config.plugins)) {
|
|
197
|
+
config.plugins = [];
|
|
198
|
+
}
|
|
199
|
+
if (!config.plugins.includes("chutes-plugin")) {
|
|
200
|
+
config.plugins.push("chutes-plugin");
|
|
201
|
+
}
|
|
202
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
203
|
+
console.log('\u2705 Added "chutes-plugin" to opencode.json!');
|
|
204
|
+
console.log(`
|
|
222
205
|
Next steps:`);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
206
|
+
console.log("1. Start OpenCode: opencode");
|
|
207
|
+
console.log("2. The plugin will be auto-installed on first run");
|
|
208
|
+
console.log("3. Connect your Chutes token: /connect chutes");
|
|
209
|
+
console.log(`4. Select a Chutes model from the dropdown
|
|
227
210
|
`);
|
|
228
|
-
} catch (error) {
|
|
229
|
-
console.log(`\u274C Error installing via npm: ${error instanceof Error ? error.message : String(error)}`);
|
|
230
|
-
process.exit(1);
|
|
231
|
-
}
|
|
232
211
|
}
|
|
233
212
|
var __dirname = "/home/mark182/code/chutes-plugin/src/cli";
|
|
234
213
|
var init_install = () => {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chutes-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Chutes Models plugin for OpenCode - Access 48+ state-of-the-art AI models through the Chutes API",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gianmarco Martinelli",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
|
-
"chutes-plugin": "dist/cli/
|
|
17
|
+
"chutes-plugin": "dist/cli/chutes-plugin.js"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"src/version.ts",
|
|
29
|
-
"src/cli"
|
|
29
|
+
"src/cli",
|
|
30
|
+
"bin"
|
|
30
31
|
],
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"@opencode-ai/plugin": "1.0.85",
|
package/src/cli/install.ts
CHANGED
|
@@ -23,24 +23,16 @@ export async function install(options: InstallOptions): Promise<void> {
|
|
|
23
23
|
output: process.stdout,
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
rl.
|
|
29
|
-
|
|
30
|
-
resolve(answer.trim());
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
setTimeout(() => {
|
|
34
|
-
rl.close();
|
|
35
|
-
reject(new Error('Timeout waiting for user input'));
|
|
36
|
-
}, 10000);
|
|
26
|
+
installType = await new Promise<string>((resolve) => {
|
|
27
|
+
rl.question('> ', (answer) => {
|
|
28
|
+
rl.close();
|
|
29
|
+
resolve(answer.trim());
|
|
37
30
|
});
|
|
38
|
-
}
|
|
39
|
-
console.log('No input detected, defaulting to npm installation...\n');
|
|
40
|
-
installType = 'npm';
|
|
41
|
-
}
|
|
31
|
+
});
|
|
42
32
|
}
|
|
43
33
|
|
|
34
|
+
console.log(`Installing type: ${installType}\n`);
|
|
35
|
+
|
|
44
36
|
switch (installType) {
|
|
45
37
|
case '1':
|
|
46
38
|
case 'project':
|
|
@@ -55,7 +47,7 @@ export async function install(options: InstallOptions): Promise<void> {
|
|
|
55
47
|
await installNpm();
|
|
56
48
|
break;
|
|
57
49
|
default:
|
|
58
|
-
console.log(
|
|
50
|
+
console.log(`❌ Invalid installation type: "${installType}"`);
|
|
59
51
|
console.log('Please choose: 1 (project), 2 (global), or 3 (npm)');
|
|
60
52
|
process.exit(1);
|
|
61
53
|
}
|
|
@@ -68,68 +60,62 @@ async function installProject(): Promise<void> {
|
|
|
68
60
|
|
|
69
61
|
console.log('Installing to project...\n');
|
|
70
62
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (!fs.existsSync(path.join(opencodeDir, 'plugin'))) {
|
|
77
|
-
fs.mkdirSync(path.join(opencodeDir, 'plugin'), { recursive: true });
|
|
78
|
-
}
|
|
63
|
+
if (!fs.existsSync(opencodeDir)) {
|
|
64
|
+
fs.mkdirSync(opencodeDir, { recursive: true });
|
|
65
|
+
}
|
|
79
66
|
|
|
80
|
-
|
|
67
|
+
if (!fs.existsSync(path.join(opencodeDir, 'plugin'))) {
|
|
68
|
+
fs.mkdirSync(path.join(opencodeDir, 'plugin'), { recursive: true });
|
|
69
|
+
}
|
|
81
70
|
|
|
82
|
-
|
|
83
|
-
if (fs.existsSync(distDir)) {
|
|
84
|
-
fs.cpSync(distDir, path.join(pluginDir, 'dist'), { recursive: true });
|
|
85
|
-
}
|
|
71
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
86
72
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
73
|
+
const distDir = path.join(__dirname, '..', '..', 'dist');
|
|
74
|
+
if (fs.existsSync(distDir)) {
|
|
75
|
+
fs.cpSync(distDir, path.join(pluginDir, 'dist'), { recursive: true });
|
|
76
|
+
}
|
|
91
77
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
config = JSON.parse(content);
|
|
98
|
-
} catch {
|
|
99
|
-
console.log('⚠️ Warning: Could not parse existing opencode.json, creating new one');
|
|
100
|
-
config = {};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
78
|
+
const srcCliDir = path.join(__dirname, '..');
|
|
79
|
+
if (fs.existsSync(srcCliDir)) {
|
|
80
|
+
fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
|
|
81
|
+
}
|
|
103
82
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
const packageJsonPath = path.join(opencodeDir, 'opencode.json');
|
|
84
|
+
let config: Record<string, unknown> = {};
|
|
85
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
86
|
+
const content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
87
|
+
try {
|
|
88
|
+
config = JSON.parse(content);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
91
|
+
process.exit(1);
|
|
107
92
|
}
|
|
93
|
+
}
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
config.plugins = config.plugins || [];
|
|
96
|
+
if (!Array.isArray(config.plugins)) {
|
|
97
|
+
config.plugins = [];
|
|
98
|
+
}
|
|
113
99
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
console.log('\nNext steps:');
|
|
118
|
-
console.log('1. Start OpenCode: opencode');
|
|
119
|
-
console.log('2. Connect your Chutes token: /connect chutes');
|
|
120
|
-
console.log('3. Select a Chutes model from the dropdown\n');
|
|
121
|
-
} catch (error) {
|
|
122
|
-
console.log(
|
|
123
|
-
`❌ Error installing to project: ${error instanceof Error ? error.message : String(error)}`
|
|
124
|
-
);
|
|
125
|
-
process.exit(1);
|
|
100
|
+
const pluginPath = './.opencode/plugin/chutes-plugin/dist/index.js';
|
|
101
|
+
if (!config.plugins.includes(pluginPath)) {
|
|
102
|
+
config.plugins.push(pluginPath);
|
|
126
103
|
}
|
|
104
|
+
|
|
105
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(config, null, 2));
|
|
106
|
+
|
|
107
|
+
console.log('✅ Successfully installed to project!');
|
|
108
|
+
console.log(` Location: ${pluginDir}`);
|
|
109
|
+
console.log('\nNext steps:');
|
|
110
|
+
console.log('1. Start OpenCode: opencode');
|
|
111
|
+
console.log('2. Connect your Chutes token: /connect chutes');
|
|
112
|
+
console.log('3. Select a Chutes model from the dropdown\n');
|
|
127
113
|
}
|
|
128
114
|
|
|
129
115
|
async function installGlobal(): Promise<void> {
|
|
130
116
|
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
131
117
|
if (!homeDir) {
|
|
132
|
-
console.
|
|
118
|
+
console.error('❌ Error: Could not determine home directory');
|
|
133
119
|
process.exit(1);
|
|
134
120
|
}
|
|
135
121
|
|
|
@@ -138,54 +124,48 @@ async function installGlobal(): Promise<void> {
|
|
|
138
124
|
|
|
139
125
|
console.log('Installing globally...\n');
|
|
140
126
|
|
|
141
|
-
|
|
142
|
-
fs.mkdirSync(pluginDir, { recursive: true });
|
|
143
|
-
|
|
144
|
-
const distDir = path.join(__dirname, '..', '..', 'dist');
|
|
145
|
-
if (fs.existsSync(distDir)) {
|
|
146
|
-
fs.cpSync(distDir, path.join(pluginDir, 'dist'), { recursive: true });
|
|
147
|
-
}
|
|
127
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
148
128
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
129
|
+
const distDir = path.join(__dirname, '..', '..', 'dist');
|
|
130
|
+
if (fs.existsSync(distDir)) {
|
|
131
|
+
fs.cpSync(distDir, path.join(pluginDir, 'dist'), { recursive: true });
|
|
132
|
+
}
|
|
153
133
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
config = JSON.parse(content);
|
|
160
|
-
} catch {
|
|
161
|
-
console.log('⚠️ Warning: Could not parse existing opencode.json, creating new one');
|
|
162
|
-
config = {};
|
|
163
|
-
}
|
|
164
|
-
}
|
|
134
|
+
const srcCliDir = path.join(__dirname, '..');
|
|
135
|
+
if (fs.existsSync(srcCliDir)) {
|
|
136
|
+
fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
|
|
137
|
+
}
|
|
165
138
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
139
|
+
const configPath = path.join(configDir, 'opencode.json');
|
|
140
|
+
let config: Record<string, unknown> = {};
|
|
141
|
+
if (fs.existsSync(configPath)) {
|
|
142
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
143
|
+
try {
|
|
144
|
+
config = JSON.parse(content);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
147
|
+
process.exit(1);
|
|
169
148
|
}
|
|
149
|
+
}
|
|
170
150
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
151
|
+
config.plugins = config.plugins || [];
|
|
152
|
+
if (!Array.isArray(config.plugins)) {
|
|
153
|
+
config.plugins = [];
|
|
154
|
+
}
|
|
175
155
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
console.log('\nNext steps:');
|
|
180
|
-
console.log('1. Start OpenCode: opencode');
|
|
181
|
-
console.log('2. Connect your Chutes token: /connect chutes');
|
|
182
|
-
console.log('3. Select a Chutes model from the dropdown\n');
|
|
183
|
-
} catch (error) {
|
|
184
|
-
console.log(
|
|
185
|
-
`❌ Error installing globally: ${error instanceof Error ? error.message : String(error)}`
|
|
186
|
-
);
|
|
187
|
-
process.exit(1);
|
|
156
|
+
const pluginPath = `${configDir}/plugin/chutes-plugin/dist/index.js`;
|
|
157
|
+
if (!config.plugins.includes(pluginPath)) {
|
|
158
|
+
config.plugins.push(pluginPath);
|
|
188
159
|
}
|
|
160
|
+
|
|
161
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
162
|
+
|
|
163
|
+
console.log('✅ Successfully installed globally!');
|
|
164
|
+
console.log(` Location: ${pluginDir}`);
|
|
165
|
+
console.log('\nNext steps:');
|
|
166
|
+
console.log('1. Start OpenCode: opencode');
|
|
167
|
+
console.log('2. Connect your Chutes token: /connect chutes');
|
|
168
|
+
console.log('3. Select a Chutes model from the dropdown\n');
|
|
189
169
|
}
|
|
190
170
|
|
|
191
171
|
async function installNpm(): Promise<void> {
|
|
@@ -194,39 +174,32 @@ async function installNpm(): Promise<void> {
|
|
|
194
174
|
|
|
195
175
|
console.log('Installing via npm...\n');
|
|
196
176
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
config = {};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
config.plugins = config.plugins || [];
|
|
210
|
-
if (!Array.isArray(config.plugins)) {
|
|
211
|
-
config.plugins = [];
|
|
177
|
+
let config: Record<string, unknown> = {};
|
|
178
|
+
if (fs.existsSync(configPath)) {
|
|
179
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
180
|
+
try {
|
|
181
|
+
config = JSON.parse(content);
|
|
182
|
+
} catch (e) {
|
|
183
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
184
|
+
process.exit(1);
|
|
212
185
|
}
|
|
186
|
+
}
|
|
213
187
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
188
|
+
config.plugins = config.plugins || [];
|
|
189
|
+
if (!Array.isArray(config.plugins)) {
|
|
190
|
+
config.plugins = [];
|
|
191
|
+
}
|
|
217
192
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
console.log('✅ Added "chutes-plugin" to opencode.json!');
|
|
221
|
-
console.log('\nNext steps:');
|
|
222
|
-
console.log('1. Start OpenCode: opencode');
|
|
223
|
-
console.log('2. The plugin will be auto-installed on first run');
|
|
224
|
-
console.log('3. Connect your Chutes token: /connect chutes');
|
|
225
|
-
console.log('4. Select a Chutes model from the dropdown\n');
|
|
226
|
-
} catch (error) {
|
|
227
|
-
console.log(
|
|
228
|
-
`❌ Error installing via npm: ${error instanceof Error ? error.message : String(error)}`
|
|
229
|
-
);
|
|
230
|
-
process.exit(1);
|
|
193
|
+
if (!config.plugins.includes('chutes-plugin')) {
|
|
194
|
+
config.plugins.push('chutes-plugin');
|
|
231
195
|
}
|
|
196
|
+
|
|
197
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
198
|
+
|
|
199
|
+
console.log('✅ Added "chutes-plugin" to opencode.json!');
|
|
200
|
+
console.log('\nNext steps:');
|
|
201
|
+
console.log('1. Start OpenCode: opencode');
|
|
202
|
+
console.log('2. The plugin will be auto-installed on first run');
|
|
203
|
+
console.log('3. Connect your Chutes token: /connect chutes');
|
|
204
|
+
console.log('4. Select a Chutes model from the dropdown\n');
|
|
232
205
|
}
|