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