chutes-plugin 0.1.8 ā 0.1.9
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 +1 -1
- package/dist/cli/index.js +345 -21
- package/dist/cli/install.d.ts.map +1 -1
- package/dist/cli/install.js +47 -10
- package/dist/cli/install.js.map +1 -1
- package/package.json +2 -2
package/bin/chutes-plugin
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import '
|
|
2
|
+
import '../dist/cli/index.js';
|
package/dist/cli/index.js
CHANGED
|
@@ -1,8 +1,333 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, {
|
|
21
|
+
get: all[name],
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
set: (newValue) => all[name] = () => newValue
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
28
|
+
var __require = import.meta.require;
|
|
29
|
+
|
|
30
|
+
// src/cli/install.ts
|
|
31
|
+
var exports_install = {};
|
|
32
|
+
__export(exports_install, {
|
|
33
|
+
install: () => install
|
|
34
|
+
});
|
|
35
|
+
import * as fs from "fs";
|
|
36
|
+
import * as path from "path";
|
|
37
|
+
import * as os from "os";
|
|
38
|
+
async function install() {
|
|
39
|
+
console.log(`\uD83D\uDC0D chutes-plugin installer
|
|
40
|
+
`);
|
|
41
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
42
|
+
`);
|
|
43
|
+
const projectDir = process.cwd();
|
|
44
|
+
const opencodeConfigPath = path.join(projectDir, "opencode.json");
|
|
45
|
+
const projectPluginDir = path.join(projectDir, ".opencode", "plugin");
|
|
46
|
+
const globalPluginDir = path.join(os.homedir(), ".config", "opencode", "plugin");
|
|
47
|
+
const distFile = path.resolve(__dirname, "..", "..", "dist", "index.js");
|
|
48
|
+
if (!fs.existsSync(distFile)) {
|
|
49
|
+
console.error('\u274C Error: dist/index.js not found. Run "bun run build" first.');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
let installTarget = "project";
|
|
53
|
+
let pluginDir;
|
|
54
|
+
let pluginFile;
|
|
55
|
+
if (fs.existsSync(opencodeConfigPath)) {
|
|
56
|
+
console.log(`Detected opencode.json in current directory.
|
|
57
|
+
`);
|
|
58
|
+
console.log("Where would you like to install the plugin?");
|
|
59
|
+
console.log(" [1] Project (./.opencode/plugin/)");
|
|
60
|
+
console.log(" [2] Global (~/.config/opencode/plugin/)");
|
|
61
|
+
console.log(` [c] Cancel
|
|
62
|
+
`);
|
|
63
|
+
const { createInterface } = await import("readline/promises");
|
|
64
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
65
|
+
const answer = (await rl.question("Select option [1/2/c]: ")).trim().toLowerCase();
|
|
66
|
+
await rl.close();
|
|
67
|
+
if (answer === "1" || answer === "") {
|
|
68
|
+
installTarget = "project";
|
|
69
|
+
} else if (answer === "2") {
|
|
70
|
+
installTarget = "global";
|
|
71
|
+
} else {
|
|
72
|
+
console.log(`Installation cancelled.
|
|
73
|
+
`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
installTarget = "project";
|
|
78
|
+
}
|
|
79
|
+
if (installTarget === "project") {
|
|
80
|
+
pluginDir = projectPluginDir;
|
|
81
|
+
pluginFile = path.join(pluginDir, "chutes-plugin.js");
|
|
82
|
+
console.log(`
|
|
83
|
+
Installing chutes-plugin to project...
|
|
84
|
+
`);
|
|
85
|
+
} else {
|
|
86
|
+
pluginDir = globalPluginDir;
|
|
87
|
+
pluginFile = path.join(pluginDir, "chutes-plugin.js");
|
|
88
|
+
console.log(`
|
|
89
|
+
Installing chutes-plugin globally...
|
|
90
|
+
`);
|
|
91
|
+
}
|
|
92
|
+
console.log(`Creating plugin directory...
|
|
93
|
+
`);
|
|
94
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
95
|
+
console.log(`Copying plugin...
|
|
96
|
+
`);
|
|
97
|
+
fs.copyFileSync(distFile, pluginFile);
|
|
98
|
+
console.log("\u2705 Successfully installed!");
|
|
99
|
+
console.log(` Location: ${pluginFile}`);
|
|
100
|
+
console.log(`
|
|
101
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
102
|
+
`);
|
|
103
|
+
console.log("Next steps:");
|
|
104
|
+
console.log("1. Restart OpenCode if it's running");
|
|
105
|
+
console.log("2. Run: opencode");
|
|
106
|
+
console.log("3. Connect your token: /connect chutes");
|
|
107
|
+
console.log("4. Select a Chutes model from the dropdown");
|
|
108
|
+
console.log(`
|
|
109
|
+
Available tools:`);
|
|
110
|
+
console.log(" - chutes_list_models");
|
|
111
|
+
console.log(" - chutes_refresh_models");
|
|
112
|
+
console.log(" - chutes_status");
|
|
113
|
+
}
|
|
114
|
+
var __dirname = "/home/mark182/code/chutes-plugin/src/cli";
|
|
115
|
+
var init_install = () => {};
|
|
116
|
+
|
|
117
|
+
// src/cli/status.ts
|
|
118
|
+
var exports_status = {};
|
|
119
|
+
__export(exports_status, {
|
|
120
|
+
status: () => status
|
|
121
|
+
});
|
|
122
|
+
import * as fs2 from "fs";
|
|
123
|
+
import * as path2 from "path";
|
|
124
|
+
async function status() {
|
|
125
|
+
console.log(`\uD83D\uDC0D chutes-plugin status
|
|
126
|
+
`);
|
|
127
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
128
|
+
`);
|
|
129
|
+
const projectDir = process.cwd();
|
|
130
|
+
const pluginFile = path2.join(projectDir, ".opencode", "plugin", "chutes-plugin.js");
|
|
131
|
+
const hasPlugin = fs2.existsSync(pluginFile);
|
|
132
|
+
console.log(`Plugin installed: ${hasPlugin ? "\u2705 Yes" : "\u274C No"}`);
|
|
133
|
+
if (hasPlugin) {
|
|
134
|
+
console.log(`Location: ${pluginFile}`);
|
|
135
|
+
} else {
|
|
136
|
+
console.log(`
|
|
137
|
+
To install:`);
|
|
138
|
+
console.log(` bunx chutes-plugin install
|
|
139
|
+
`);
|
|
140
|
+
}
|
|
141
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
142
|
+
const authPath = homeDir ? path2.join(homeDir, ".local", "share", "opencode", "auth.json") : null;
|
|
143
|
+
let hasAuth = false;
|
|
144
|
+
if (authPath && fs2.existsSync(authPath)) {
|
|
145
|
+
try {
|
|
146
|
+
const content = fs2.readFileSync(authPath, "utf-8");
|
|
147
|
+
const auth = JSON.parse(content);
|
|
148
|
+
hasAuth = !!(auth.chutes || auth.CHUTES_API_TOKEN || auth.chutes_api_token);
|
|
149
|
+
} catch {
|
|
150
|
+
hasAuth = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
console.log(`API Token: ${hasAuth ? "\u2705 Connected" : "\u26A0\uFE0F Not connected"}`);
|
|
154
|
+
if (!hasAuth) {
|
|
155
|
+
console.log(`
|
|
156
|
+
To connect your token:`);
|
|
157
|
+
console.log(" 1. Run: opencode");
|
|
158
|
+
console.log(` 2. Type: /connect chutes
|
|
159
|
+
`);
|
|
160
|
+
}
|
|
161
|
+
console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
|
|
162
|
+
}
|
|
163
|
+
var init_status = () => {};
|
|
164
|
+
|
|
165
|
+
// src/cli/list.ts
|
|
166
|
+
var exports_list = {};
|
|
167
|
+
__export(exports_list, {
|
|
168
|
+
list: () => list
|
|
169
|
+
});
|
|
170
|
+
async function list() {
|
|
171
|
+
console.log(`\uD83D\uDC0D chutes-plugin models
|
|
172
|
+
`);
|
|
173
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
174
|
+
`);
|
|
175
|
+
console.log(`Fetching models from Chutes API...
|
|
176
|
+
`);
|
|
177
|
+
try {
|
|
178
|
+
const response = await fetch("https://llm.chutes.ai/v1/models", {
|
|
179
|
+
method: "GET",
|
|
180
|
+
headers: {
|
|
181
|
+
"Content-Type": "application/json"
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
console.log(`\u274C Error fetching models: ${response.status} ${response.statusText}`);
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
const data = await response.json();
|
|
189
|
+
const models = data.data || [];
|
|
190
|
+
console.log(`Found ${models.length} models:
|
|
191
|
+
`);
|
|
192
|
+
for (const model of models) {
|
|
193
|
+
console.log(`\u2022 ${model.id}`);
|
|
194
|
+
console.log(` Owner: ${model.owned_by}`);
|
|
195
|
+
console.log(` Pricing: $${model.pricing.prompt.toFixed(2)}/M input, $${model.pricing.completion.toFixed(2)}/M output
|
|
196
|
+
`);
|
|
197
|
+
}
|
|
198
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
199
|
+
`);
|
|
200
|
+
console.log("Tip: To use these models:");
|
|
201
|
+
console.log("1. Install the plugin: bunx chutes-plugin install");
|
|
202
|
+
console.log("2. Start OpenCode: opencode");
|
|
203
|
+
console.log("3. Connect token: /connect chutes");
|
|
204
|
+
console.log(`4. Select a Chutes model from the dropdown
|
|
205
|
+
`);
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.log(`\u274C Error fetching models: ${error instanceof Error ? error.message : String(error)}`);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/cli/refresh.ts
|
|
213
|
+
var exports_refresh = {};
|
|
214
|
+
__export(exports_refresh, {
|
|
215
|
+
refresh: () => refresh
|
|
216
|
+
});
|
|
217
|
+
async function refresh() {
|
|
218
|
+
console.log(`\uD83D\uDC0D chutes-plugin refresh
|
|
219
|
+
`);
|
|
220
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
221
|
+
`);
|
|
222
|
+
console.log(`Refreshing model cache...
|
|
223
|
+
`);
|
|
224
|
+
try {
|
|
225
|
+
const response = await fetch("https://llm.chutes.ai/v1/models", {
|
|
226
|
+
method: "GET",
|
|
227
|
+
headers: {
|
|
228
|
+
"Content-Type": "application/json"
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
if (!response.ok) {
|
|
232
|
+
console.log(`\u274C Error refreshing models: ${response.status} ${response.statusText}`);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
const data = await response.json();
|
|
236
|
+
const models = data.data || [];
|
|
237
|
+
console.log(`\u2705 Successfully refreshed ${models.length} models
|
|
238
|
+
`);
|
|
239
|
+
console.log("Note: The cache will be automatically refreshed when OpenCode restarts.");
|
|
240
|
+
console.log(`Models are cached in-memory for 1 hour during each OpenCode session.
|
|
241
|
+
`);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.log(`\u274C Error refreshing models: ${error instanceof Error ? error.message : String(error)}`);
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/cli/doctor.ts
|
|
249
|
+
var exports_doctor = {};
|
|
250
|
+
__export(exports_doctor, {
|
|
251
|
+
doctor: () => doctor
|
|
252
|
+
});
|
|
253
|
+
import * as fs3 from "fs";
|
|
254
|
+
import * as path3 from "path";
|
|
255
|
+
async function doctor() {
|
|
256
|
+
console.log(`\uD83D\uDC0D chutes-plugin doctor
|
|
257
|
+
`);
|
|
258
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
259
|
+
`);
|
|
260
|
+
let checks = 0;
|
|
261
|
+
let passed = 0;
|
|
262
|
+
function check(name, result, message) {
|
|
263
|
+
checks++;
|
|
264
|
+
if (result) {
|
|
265
|
+
passed++;
|
|
266
|
+
console.log(`\u2705 ${name}`);
|
|
267
|
+
} else {
|
|
268
|
+
console.log(`\u274C ${name}`);
|
|
269
|
+
console.log(` ${message}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const projectDir = process.cwd();
|
|
273
|
+
const pluginFile = path3.join(projectDir, ".opencode", "plugin", "chutes-plugin.js");
|
|
274
|
+
const hasPlugin = fs3.existsSync(pluginFile);
|
|
275
|
+
console.log(`Installation Checks:
|
|
276
|
+
`);
|
|
277
|
+
check("Plugin installed", hasPlugin, hasPlugin ? `Location: ${pluginFile}` : "Run: bunx chutes-plugin install");
|
|
278
|
+
console.log(`
|
|
279
|
+
API Checks:
|
|
280
|
+
`);
|
|
281
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
282
|
+
const authPath = homeDir ? path3.join(homeDir, ".local", "share", "opencode", "auth.json") : null;
|
|
283
|
+
let hasAuth = false;
|
|
284
|
+
if (authPath && fs3.existsSync(authPath)) {
|
|
285
|
+
try {
|
|
286
|
+
const content = fs3.readFileSync(authPath, "utf-8");
|
|
287
|
+
const auth = JSON.parse(content);
|
|
288
|
+
hasAuth = !!(auth.chutes || auth.CHUTES_API_TOKEN || auth.chutes_api_token);
|
|
289
|
+
} catch {
|
|
290
|
+
hasAuth = false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
check("API token connected", hasAuth, "Run: opencode, then type: /connect chutes");
|
|
294
|
+
console.log(`
|
|
295
|
+
Network Checks:
|
|
296
|
+
`);
|
|
297
|
+
try {
|
|
298
|
+
const response = await fetch("https://llm.chutes.ai/v1/models", {
|
|
299
|
+
method: "GET",
|
|
300
|
+
headers: { "Content-Type": "application/json" }
|
|
301
|
+
});
|
|
302
|
+
check("Can reach Chutes API", response.ok, `HTTP ${response.status}: ${response.statusText}`);
|
|
303
|
+
if (response.ok) {
|
|
304
|
+
const data = await response.json();
|
|
305
|
+
console.log(` Found ${data.data?.length || 0} models available
|
|
306
|
+
`);
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
check("Can reach Chutes API", false, `Connection failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
310
|
+
}
|
|
311
|
+
console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
312
|
+
`);
|
|
313
|
+
console.log(`Results: ${passed}/${checks} checks passed
|
|
314
|
+
`);
|
|
315
|
+
if (passed === checks) {
|
|
316
|
+
console.log(`\uD83C\uDF89 Everything looks good! You're ready to use chutes-plugin.
|
|
317
|
+
`);
|
|
318
|
+
} else {
|
|
319
|
+
console.log(`\u26A0\uFE0F Some checks failed. Please address the issues above.
|
|
320
|
+
`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
var init_doctor = () => {};
|
|
324
|
+
|
|
325
|
+
// src/cli/index.ts
|
|
326
|
+
import cac from "cac";
|
|
327
|
+
var cli = cac("chutes-plugin");
|
|
328
|
+
cli.version("0.1.0");
|
|
4
329
|
cli.usage(`
|
|
5
|
-
|
|
330
|
+
\uD83D\uDC0D chutes-plugin
|
|
6
331
|
|
|
7
332
|
A plugin for OpenCode that provides access to 58+ state-of-the-art AI models through the Chutes API.
|
|
8
333
|
|
|
@@ -23,28 +348,27 @@ Examples:
|
|
|
23
348
|
$ chutes-plugin refresh
|
|
24
349
|
$ chutes-plugin doctor
|
|
25
350
|
`);
|
|
26
|
-
cli.command(
|
|
27
|
-
|
|
28
|
-
|
|
351
|
+
cli.command("install", "Install the plugin to the current project").action(async () => {
|
|
352
|
+
const { install: install2 } = await Promise.resolve().then(() => (init_install(), exports_install));
|
|
353
|
+
await install2();
|
|
29
354
|
});
|
|
30
|
-
cli.command(
|
|
31
|
-
|
|
32
|
-
|
|
355
|
+
cli.command("status", "Check plugin status and configuration").action(async () => {
|
|
356
|
+
const { status: status2 } = await Promise.resolve().then(() => (init_status(), exports_status));
|
|
357
|
+
await status2();
|
|
33
358
|
});
|
|
34
|
-
cli.command(
|
|
35
|
-
|
|
36
|
-
|
|
359
|
+
cli.command("list", "List available models from the Chutes API").action(async () => {
|
|
360
|
+
const { list: list2 } = await Promise.resolve().then(() => exports_list);
|
|
361
|
+
await list2();
|
|
37
362
|
});
|
|
38
|
-
cli.command(
|
|
39
|
-
|
|
40
|
-
|
|
363
|
+
cli.command("refresh", "Force refresh the model cache").action(async () => {
|
|
364
|
+
const { refresh: refresh2 } = await Promise.resolve().then(() => exports_refresh);
|
|
365
|
+
await refresh2();
|
|
41
366
|
});
|
|
42
|
-
cli.command(
|
|
43
|
-
|
|
44
|
-
|
|
367
|
+
cli.command("doctor", "Verify that everything is configured correctly").action(async () => {
|
|
368
|
+
const { doctor: doctor2 } = await Promise.resolve().then(() => (init_doctor(), exports_doctor));
|
|
369
|
+
await doctor2();
|
|
45
370
|
});
|
|
46
371
|
cli.parse();
|
|
47
372
|
if (process.argv.length === 2) {
|
|
48
|
-
|
|
373
|
+
cli.outputHelp();
|
|
49
374
|
}
|
|
50
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/cli/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/cli/install.ts"],"names":[],"mappings":"AAIA,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAuE7C"}
|
package/dist/cli/install.js
CHANGED
|
@@ -1,22 +1,59 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
import * as os from 'node:os';
|
|
3
4
|
export async function install() {
|
|
4
5
|
console.log('š chutes-plugin installer\n');
|
|
5
6
|
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
|
|
6
7
|
const projectDir = process.cwd();
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fs.
|
|
12
|
-
const distFile = path.join(__dirname, '..', '..', 'dist', 'index.js');
|
|
13
|
-
if (fs.existsSync(distFile)) {
|
|
14
|
-
fs.copyFileSync(distFile, pluginFile);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
8
|
+
const opencodeConfigPath = path.join(projectDir, 'opencode.json');
|
|
9
|
+
const projectPluginDir = path.join(projectDir, '.opencode', 'plugin');
|
|
10
|
+
const globalPluginDir = path.join(os.homedir(), '.config', 'opencode', 'plugin');
|
|
11
|
+
const distFile = path.resolve(__dirname, '..', '..', 'dist', 'index.js');
|
|
12
|
+
if (!fs.existsSync(distFile)) {
|
|
17
13
|
console.error('ā Error: dist/index.js not found. Run "bun run build" first.');
|
|
18
14
|
process.exit(1);
|
|
19
15
|
}
|
|
16
|
+
let installTarget = 'project';
|
|
17
|
+
let pluginDir;
|
|
18
|
+
let pluginFile;
|
|
19
|
+
if (fs.existsSync(opencodeConfigPath)) {
|
|
20
|
+
console.log('Detected opencode.json in current directory.\n');
|
|
21
|
+
console.log('Where would you like to install the plugin?');
|
|
22
|
+
console.log(' [1] Project (./.opencode/plugin/)');
|
|
23
|
+
console.log(' [2] Global (~/.config/opencode/plugin/)');
|
|
24
|
+
console.log(' [c] Cancel\n');
|
|
25
|
+
const { createInterface } = await import('node:readline/promises');
|
|
26
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
27
|
+
const answer = (await rl.question('Select option [1/2/c]: ')).trim().toLowerCase();
|
|
28
|
+
await rl.close();
|
|
29
|
+
if (answer === '1' || answer === '') {
|
|
30
|
+
installTarget = 'project';
|
|
31
|
+
}
|
|
32
|
+
else if (answer === '2') {
|
|
33
|
+
installTarget = 'global';
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log('Installation cancelled.\n');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
installTarget = 'project';
|
|
42
|
+
}
|
|
43
|
+
if (installTarget === 'project') {
|
|
44
|
+
pluginDir = projectPluginDir;
|
|
45
|
+
pluginFile = path.join(pluginDir, 'chutes-plugin.js');
|
|
46
|
+
console.log('\nInstalling chutes-plugin to project...\n');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
pluginDir = globalPluginDir;
|
|
50
|
+
pluginFile = path.join(pluginDir, 'chutes-plugin.js');
|
|
51
|
+
console.log('\nInstalling chutes-plugin globally...\n');
|
|
52
|
+
}
|
|
53
|
+
console.log('Creating plugin directory...\n');
|
|
54
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
55
|
+
console.log('Copying plugin...\n');
|
|
56
|
+
fs.copyFileSync(distFile, pluginFile);
|
|
20
57
|
console.log('ā
Successfully installed!');
|
|
21
58
|
console.log(` Location: ${pluginFile}`);
|
|
22
59
|
console.log('\nāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n');
|
package/dist/cli/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/cli/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MA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,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7C,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACnC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEtC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chutes-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
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",
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"typescript-eslint": "^8.47.0",
|
|
52
52
|
"vitest": "^3.2.4"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|