chutes-plugin 0.1.0 → 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 +25 -5
- package/package.json +4 -3
- package/src/cli/install.ts +25 -6
package/dist/cli/index.js
CHANGED
|
@@ -58,6 +58,8 @@ async function install(options) {
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
console.log(`Installing type: ${installType}
|
|
62
|
+
`);
|
|
61
63
|
switch (installType) {
|
|
62
64
|
case "1":
|
|
63
65
|
case "project":
|
|
@@ -72,7 +74,8 @@ async function install(options) {
|
|
|
72
74
|
await installNpm();
|
|
73
75
|
break;
|
|
74
76
|
default:
|
|
75
|
-
console.log(
|
|
77
|
+
console.log(`\u274C Invalid installation type: "${installType}"`);
|
|
78
|
+
console.log("Please choose: 1 (project), 2 (global), or 3 (npm)");
|
|
76
79
|
process.exit(1);
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -101,7 +104,12 @@ async function installProject() {
|
|
|
101
104
|
let config = {};
|
|
102
105
|
if (fs.existsSync(packageJsonPath)) {
|
|
103
106
|
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
104
|
-
|
|
107
|
+
try {
|
|
108
|
+
config = JSON.parse(content);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
config.plugins = config.plugins || [];
|
|
107
115
|
if (!Array.isArray(config.plugins)) {
|
|
@@ -113,6 +121,7 @@ async function installProject() {
|
|
|
113
121
|
}
|
|
114
122
|
fs.writeFileSync(packageJsonPath, JSON.stringify(config, null, 2));
|
|
115
123
|
console.log("\u2705 Successfully installed to project!");
|
|
124
|
+
console.log(` Location: ${pluginDir}`);
|
|
116
125
|
console.log(`
|
|
117
126
|
Next steps:`);
|
|
118
127
|
console.log("1. Start OpenCode: opencode");
|
|
@@ -123,7 +132,7 @@ Next steps:`);
|
|
|
123
132
|
async function installGlobal() {
|
|
124
133
|
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
125
134
|
if (!homeDir) {
|
|
126
|
-
console.
|
|
135
|
+
console.error("\u274C Error: Could not determine home directory");
|
|
127
136
|
process.exit(1);
|
|
128
137
|
}
|
|
129
138
|
const configDir = path.join(homeDir, ".config", "opencode");
|
|
@@ -143,7 +152,12 @@ async function installGlobal() {
|
|
|
143
152
|
let config = {};
|
|
144
153
|
if (fs.existsSync(configPath)) {
|
|
145
154
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
146
|
-
|
|
155
|
+
try {
|
|
156
|
+
config = JSON.parse(content);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
147
161
|
}
|
|
148
162
|
config.plugins = config.plugins || [];
|
|
149
163
|
if (!Array.isArray(config.plugins)) {
|
|
@@ -155,6 +169,7 @@ async function installGlobal() {
|
|
|
155
169
|
}
|
|
156
170
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
157
171
|
console.log("\u2705 Successfully installed globally!");
|
|
172
|
+
console.log(` Location: ${pluginDir}`);
|
|
158
173
|
console.log(`
|
|
159
174
|
Next steps:`);
|
|
160
175
|
console.log("1. Start OpenCode: opencode");
|
|
@@ -170,7 +185,12 @@ async function installNpm() {
|
|
|
170
185
|
let config = {};
|
|
171
186
|
if (fs.existsSync(configPath)) {
|
|
172
187
|
const content = fs.readFileSync(configPath, "utf-8");
|
|
173
|
-
|
|
188
|
+
try {
|
|
189
|
+
config = JSON.parse(content);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
console.error("\u274C Failed to parse opencode.json:", e);
|
|
192
|
+
process.exit(1);
|
|
193
|
+
}
|
|
174
194
|
}
|
|
175
195
|
config.plugins = config.plugins || [];
|
|
176
196
|
if (!Array.isArray(config.plugins)) {
|
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
|
@@ -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;
|
|
@@ -32,6 +31,8 @@ export async function install(options: InstallOptions): Promise<void> {
|
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
console.log(`Installing type: ${installType}\n`);
|
|
35
|
+
|
|
35
36
|
switch (installType) {
|
|
36
37
|
case '1':
|
|
37
38
|
case 'project':
|
|
@@ -46,7 +47,8 @@ export async function install(options: InstallOptions): Promise<void> {
|
|
|
46
47
|
await installNpm();
|
|
47
48
|
break;
|
|
48
49
|
default:
|
|
49
|
-
console.log(
|
|
50
|
+
console.log(`❌ Invalid installation type: "${installType}"`);
|
|
51
|
+
console.log('Please choose: 1 (project), 2 (global), or 3 (npm)');
|
|
50
52
|
process.exit(1);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -82,7 +84,12 @@ async function installProject(): Promise<void> {
|
|
|
82
84
|
let config: Record<string, unknown> = {};
|
|
83
85
|
if (fs.existsSync(packageJsonPath)) {
|
|
84
86
|
const content = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
85
|
-
|
|
87
|
+
try {
|
|
88
|
+
config = JSON.parse(content);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
config.plugins = config.plugins || [];
|
|
@@ -98,6 +105,7 @@ async function installProject(): Promise<void> {
|
|
|
98
105
|
fs.writeFileSync(packageJsonPath, JSON.stringify(config, null, 2));
|
|
99
106
|
|
|
100
107
|
console.log('✅ Successfully installed to project!');
|
|
108
|
+
console.log(` Location: ${pluginDir}`);
|
|
101
109
|
console.log('\nNext steps:');
|
|
102
110
|
console.log('1. Start OpenCode: opencode');
|
|
103
111
|
console.log('2. Connect your Chutes token: /connect chutes');
|
|
@@ -107,7 +115,7 @@ async function installProject(): Promise<void> {
|
|
|
107
115
|
async function installGlobal(): Promise<void> {
|
|
108
116
|
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
109
117
|
if (!homeDir) {
|
|
110
|
-
console.
|
|
118
|
+
console.error('❌ Error: Could not determine home directory');
|
|
111
119
|
process.exit(1);
|
|
112
120
|
}
|
|
113
121
|
|
|
@@ -132,7 +140,12 @@ async function installGlobal(): Promise<void> {
|
|
|
132
140
|
let config: Record<string, unknown> = {};
|
|
133
141
|
if (fs.existsSync(configPath)) {
|
|
134
142
|
const content = fs.readFileSync(configPath, 'utf-8');
|
|
135
|
-
|
|
143
|
+
try {
|
|
144
|
+
config = JSON.parse(content);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
150
|
|
|
138
151
|
config.plugins = config.plugins || [];
|
|
@@ -148,6 +161,7 @@ async function installGlobal(): Promise<void> {
|
|
|
148
161
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
149
162
|
|
|
150
163
|
console.log('✅ Successfully installed globally!');
|
|
164
|
+
console.log(` Location: ${pluginDir}`);
|
|
151
165
|
console.log('\nNext steps:');
|
|
152
166
|
console.log('1. Start OpenCode: opencode');
|
|
153
167
|
console.log('2. Connect your Chutes token: /connect chutes');
|
|
@@ -163,7 +177,12 @@ async function installNpm(): Promise<void> {
|
|
|
163
177
|
let config: Record<string, unknown> = {};
|
|
164
178
|
if (fs.existsSync(configPath)) {
|
|
165
179
|
const content = fs.readFileSync(configPath, 'utf-8');
|
|
166
|
-
|
|
180
|
+
try {
|
|
181
|
+
config = JSON.parse(content);
|
|
182
|
+
} catch (e) {
|
|
183
|
+
console.error('❌ Failed to parse opencode.json:', e);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
167
186
|
}
|
|
168
187
|
|
|
169
188
|
config.plugins = config.plugins || [];
|