chutes-plugin 0.1.2 → 0.1.3

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 CHANGED
@@ -42,9 +42,9 @@ async function install(options) {
42
42
  let installType = options.type;
43
43
  if (!installType) {
44
44
  console.log("Choose installation type:");
45
- console.log("1. Project (install to .opencode/plugin/)");
46
- console.log("2. Global (install to ~/.config/opencode/plugin/)");
47
- console.log(`3. NPM (add to opencode.json for auto-install)
45
+ console.log("1. Project (copy plugin files to .opencode/plugin/)");
46
+ console.log("2. Global (copy plugin files to ~/.config/opencode/plugin/)");
47
+ console.log(`3. NPM (add "chutes-plugin" to opencode.json)
48
48
  `);
49
49
  const readline = await import("readline");
50
50
  const rl = readline.createInterface({
@@ -81,16 +81,11 @@ async function install(options) {
81
81
  }
82
82
  async function installProject() {
83
83
  const projectDir = process.cwd();
84
- const opencodeDir = path.join(projectDir, ".opencode");
85
- const pluginDir = path.join(opencodeDir, "plugin", "chutes-plugin");
84
+ const pluginDir = path.join(projectDir, ".opencode", "plugin", "chutes-plugin");
86
85
  console.log(`Installing to project...
87
86
  `);
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
- }
87
+ console.log(`Copying plugin files to .opencode/plugin/...
88
+ `);
94
89
  fs.mkdirSync(pluginDir, { recursive: true });
95
90
  const distDir = path.join(__dirname, "..", "..", "dist");
96
91
  if (fs.existsSync(distDir)) {
@@ -100,33 +95,10 @@ async function installProject() {
100
95
  if (fs.existsSync(srcCliDir)) {
101
96
  fs.cpSync(srcCliDir, path.join(pluginDir, "src"), { recursive: true });
102
97
  }
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);
112
- }
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!");
98
+ console.log("\u2705 Plugin files installed to .opencode/plugin/chutes-plugin/");
124
99
  console.log(` Location: ${pluginDir}`);
125
100
  console.log(`
126
- Next steps:`);
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
101
+ Note: Plugins in .opencode/plugin/ are auto-loaded by OpenCode.
130
102
  `);
131
103
  }
132
104
  async function installGlobal() {
@@ -148,33 +120,10 @@ async function installGlobal() {
148
120
  if (fs.existsSync(srcCliDir)) {
149
121
  fs.cpSync(srcCliDir, path.join(pluginDir, "src"), { recursive: true });
150
122
  }
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);
160
- }
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!");
123
+ console.log("\u2705 Plugin files installed globally!");
172
124
  console.log(` Location: ${pluginDir}`);
173
125
  console.log(`
174
- Next steps:`);
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
126
+ Note: Plugins in ~/.config/opencode/plugin/ are auto-loaded by OpenCode.
178
127
  `);
179
128
  }
180
129
  async function installNpm() {
@@ -196,17 +145,13 @@ async function installNpm() {
196
145
  if (!Array.isArray(config.plugins)) {
197
146
  config.plugins = [];
198
147
  }
199
- if (!config.plugins.includes("chutes-plugin")) {
200
- config.plugins.push("chutes-plugin");
148
+ const plugins = config.plugins;
149
+ if (!plugins.includes("chutes-plugin")) {
150
+ plugins.push("chutes-plugin");
201
151
  }
202
152
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
203
153
  console.log('\u2705 Added "chutes-plugin" to opencode.json!');
204
- console.log(`
205
- Next steps:`);
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
154
+ console.log(` OpenCode will auto-install the plugin on next startup.
210
155
  `);
211
156
  }
212
157
  var __dirname = "/home/mark182/code/chutes-plugin/src/cli";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chutes-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",
@@ -13,9 +13,9 @@ export async function install(options: InstallOptions): Promise<void> {
13
13
 
14
14
  if (!installType) {
15
15
  console.log('Choose installation type:');
16
- console.log('1. Project (install to .opencode/plugin/)');
17
- console.log('2. Global (install to ~/.config/opencode/plugin/)');
18
- console.log('3. NPM (add to opencode.json for auto-install)\n');
16
+ console.log('1. Project (copy plugin files to .opencode/plugin/)');
17
+ console.log('2. Global (copy plugin files to ~/.config/opencode/plugin/)');
18
+ console.log('3. NPM (add "chutes-plugin" to opencode.json)\n');
19
19
 
20
20
  const readline = await import('node:readline');
21
21
  const rl = readline.createInterface({
@@ -55,18 +55,10 @@ export async function install(options: InstallOptions): Promise<void> {
55
55
 
56
56
  async function installProject(): Promise<void> {
57
57
  const projectDir = process.cwd();
58
- const opencodeDir = path.join(projectDir, '.opencode');
59
- const pluginDir = path.join(opencodeDir, 'plugin', 'chutes-plugin');
58
+ const pluginDir = path.join(projectDir, '.opencode', 'plugin', 'chutes-plugin');
60
59
 
61
60
  console.log('Installing to project...\n');
62
-
63
- if (!fs.existsSync(opencodeDir)) {
64
- fs.mkdirSync(opencodeDir, { recursive: true });
65
- }
66
-
67
- if (!fs.existsSync(path.join(opencodeDir, 'plugin'))) {
68
- fs.mkdirSync(path.join(opencodeDir, 'plugin'), { recursive: true });
69
- }
61
+ console.log('Copying plugin files to .opencode/plugin/...\n');
70
62
 
71
63
  fs.mkdirSync(pluginDir, { recursive: true });
72
64
 
@@ -80,36 +72,9 @@ async function installProject(): Promise<void> {
80
72
  fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
81
73
  }
82
74
 
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);
92
- }
93
- }
94
-
95
- config.plugins = config.plugins || [];
96
- if (!Array.isArray(config.plugins)) {
97
- config.plugins = [];
98
- }
99
-
100
- const pluginPath = './.opencode/plugin/chutes-plugin/dist/index.js';
101
- if (!config.plugins.includes(pluginPath)) {
102
- config.plugins.push(pluginPath);
103
- }
104
-
105
- fs.writeFileSync(packageJsonPath, JSON.stringify(config, null, 2));
106
-
107
- console.log('✅ Successfully installed to project!');
75
+ console.log('✅ Plugin files installed to .opencode/plugin/chutes-plugin/');
108
76
  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');
77
+ console.log('\nNote: Plugins in .opencode/plugin/ are auto-loaded by OpenCode.\n');
113
78
  }
114
79
 
115
80
  async function installGlobal(): Promise<void> {
@@ -136,36 +101,9 @@ async function installGlobal(): Promise<void> {
136
101
  fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
137
102
  }
138
103
 
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);
148
- }
149
- }
150
-
151
- config.plugins = config.plugins || [];
152
- if (!Array.isArray(config.plugins)) {
153
- config.plugins = [];
154
- }
155
-
156
- const pluginPath = `${configDir}/plugin/chutes-plugin/dist/index.js`;
157
- if (!config.plugins.includes(pluginPath)) {
158
- config.plugins.push(pluginPath);
159
- }
160
-
161
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
162
-
163
- console.log('✅ Successfully installed globally!');
104
+ console.log('✅ Plugin files installed globally!');
164
105
  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');
106
+ console.log('\nNote: Plugins in ~/.config/opencode/plugin/ are auto-loaded by OpenCode.\n');
169
107
  }
170
108
 
171
109
  async function installNpm(): Promise<void> {
@@ -190,16 +128,13 @@ async function installNpm(): Promise<void> {
190
128
  config.plugins = [];
191
129
  }
192
130
 
193
- if (!config.plugins.includes('chutes-plugin')) {
194
- config.plugins.push('chutes-plugin');
131
+ const plugins = config.plugins as string[];
132
+ if (!plugins.includes('chutes-plugin')) {
133
+ plugins.push('chutes-plugin');
195
134
  }
196
135
 
197
136
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
198
137
 
199
138
  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');
139
+ console.log(' OpenCode will auto-install the plugin on next startup.\n');
205
140
  }