chutes-plugin 0.1.2 → 0.1.4

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
@@ -1,20 +1,5 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
2
  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
3
  var __export = (target, all) => {
19
4
  for (var name in all)
20
5
  __defProp(target, name, {
@@ -25,7 +10,6 @@ var __export = (target, all) => {
25
10
  });
26
11
  };
27
12
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
- var __require = import.meta.require;
29
13
 
30
14
  // src/cli/install.ts
31
15
  var exports_install = {};
@@ -34,110 +18,16 @@ __export(exports_install, {
34
18
  });
35
19
  import * as fs from "fs";
36
20
  import * as path from "path";
37
- async function install(options) {
21
+ async function install() {
38
22
  console.log(`\uD83D\uDC0D chutes-plugin installer
39
23
  `);
40
24
  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
41
25
  `);
42
- let installType = options.type;
43
- if (!installType) {
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)
48
- `);
49
- const readline = await import("readline");
50
- const rl = readline.createInterface({
51
- input: process.stdin,
52
- output: process.stdout
53
- });
54
- installType = await new Promise((resolve) => {
55
- rl.question("> ", (answer) => {
56
- rl.close();
57
- resolve(answer.trim());
58
- });
59
- });
60
- }
61
- console.log(`Installing type: ${installType}
62
- `);
63
- switch (installType) {
64
- case "1":
65
- case "project":
66
- await installProject();
67
- break;
68
- case "2":
69
- case "global":
70
- await installGlobal();
71
- break;
72
- case "3":
73
- case "npm":
74
- await installNpm();
75
- break;
76
- default:
77
- console.log(`\u274C Invalid installation type: "${installType}"`);
78
- console.log("Please choose: 1 (project), 2 (global), or 3 (npm)");
79
- process.exit(1);
80
- }
81
- }
82
- async function installProject() {
83
26
  const projectDir = process.cwd();
84
- const opencodeDir = path.join(projectDir, ".opencode");
85
- const pluginDir = path.join(opencodeDir, "plugin", "chutes-plugin");
86
- console.log(`Installing to project...
27
+ const pluginDir = path.join(projectDir, ".opencode", "plugin", "chutes-plugin");
28
+ console.log(`Installing chutes-plugin to project...
87
29
  `);
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);
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!");
124
- console.log(` Location: ${pluginDir}`);
125
- 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
130
- `);
131
- }
132
- async function installGlobal() {
133
- const homeDir = process.env.HOME || process.env.USERPROFILE;
134
- if (!homeDir) {
135
- console.error("\u274C Error: Could not determine home directory");
136
- process.exit(1);
137
- }
138
- const configDir = path.join(homeDir, ".config", "opencode");
139
- const pluginDir = path.join(configDir, "plugin", "chutes-plugin");
140
- console.log(`Installing globally...
30
+ console.log(`Copying plugin files to .opencode/plugin/chutes-plugin/
141
31
  `);
142
32
  fs.mkdirSync(pluginDir, { recursive: true });
143
33
  const distDir = path.join(__dirname, "..", "..", "dist");
@@ -148,66 +38,21 @@ async function installGlobal() {
148
38
  if (fs.existsSync(srcCliDir)) {
149
39
  fs.cpSync(srcCliDir, path.join(pluginDir, "src"), { recursive: true });
150
40
  }
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!");
41
+ console.log("\u2705 Successfully installed!");
172
42
  console.log(` Location: ${pluginDir}`);
173
43
  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
44
+ \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
178
45
  `);
179
- }
180
- async function installNpm() {
181
- const projectDir = process.cwd();
182
- const configPath = path.join(projectDir, "opencode.json");
183
- console.log(`Installing via npm...
184
- `);
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);
193
- }
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!');
46
+ console.log("Next steps:");
47
+ console.log("1. Restart OpenCode if it's running");
48
+ console.log("2. Run: opencode");
49
+ console.log("3. Connect your token: /connect chutes");
50
+ console.log("4. Select a Chutes model from the dropdown");
204
51
  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
210
- `);
52
+ Available tools:`);
53
+ console.log(" - chutes_list_models");
54
+ console.log(" - chutes_refresh_models");
55
+ console.log(" - chutes_status");
211
56
  }
212
57
  var __dirname = "/home/mark182/code/chutes-plugin/src/cli";
213
58
  var init_install = () => {};
@@ -488,13 +333,13 @@ cli.version("0.1.0");
488
333
  cli.usage(`
489
334
  \uD83D\uDC0D chutes-plugin
490
335
 
491
- A plugin for OpenCode that provides access to 48+ state-of-the-art AI models through the Chutes API.
336
+ A plugin for OpenCode that provides access to 58+ state-of-the-art AI models through the Chutes API.
492
337
 
493
338
  Usage:
494
339
  $ chutes-plugin <command>
495
340
 
496
341
  Commands:
497
- install Install the plugin (project, global, or npm)
342
+ install Install the plugin to the current project (.opencode/plugin/)
498
343
  status Check plugin status and configuration
499
344
  list List available models from the Chutes API
500
345
  refresh Force refresh the model cache
@@ -507,9 +352,9 @@ Examples:
507
352
  $ chutes-plugin refresh
508
353
  $ chutes-plugin doctor
509
354
  `);
510
- cli.command("install", "Install the plugin to OpenCode").option("--type <type>", "Installation type: project, global, or npm").action(async (options) => {
355
+ cli.command("install", "Install the plugin to the current project").action(async () => {
511
356
  const { install: install2 } = await Promise.resolve().then(() => (init_install(), exports_install));
512
- await install2(options);
357
+ await install2();
513
358
  });
514
359
  cli.command("status", "Check plugin status and configuration").action(async () => {
515
360
  const { status: status2 } = await Promise.resolve().then(() => (init_status(), exports_status));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chutes-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",
package/src/cli/index.ts CHANGED
@@ -6,13 +6,13 @@ cli.version('0.1.0');
6
6
  cli.usage(`
7
7
  🐍 chutes-plugin
8
8
 
9
- A plugin for OpenCode that provides access to 48+ state-of-the-art AI models through the Chutes API.
9
+ A plugin for OpenCode that provides access to 58+ state-of-the-art AI models through the Chutes API.
10
10
 
11
11
  Usage:
12
12
  $ chutes-plugin <command>
13
13
 
14
14
  Commands:
15
- install Install the plugin (project, global, or npm)
15
+ install Install the plugin to the current project (.opencode/plugin/)
16
16
  status Check plugin status and configuration
17
17
  list List available models from the Chutes API
18
18
  refresh Force refresh the model cache
@@ -26,13 +26,10 @@ Examples:
26
26
  $ chutes-plugin doctor
27
27
  `);
28
28
 
29
- cli
30
- .command('install', 'Install the plugin to OpenCode')
31
- .option('--type <type>', 'Installation type: project, global, or npm')
32
- .action(async (options) => {
33
- const { install } = await import('./install.js');
34
- await install(options);
35
- });
29
+ cli.command('install', 'Install the plugin to the current project').action(async () => {
30
+ const { install } = await import('./install.js');
31
+ await install();
32
+ });
36
33
 
37
34
  cli.command('status', 'Check plugin status and configuration').action(async () => {
38
35
  const { status } = await import('./status.js');
@@ -1,128 +1,15 @@
1
1
  import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
 
4
- interface InstallOptions {
5
- type?: string;
6
- }
7
-
8
- export async function install(options: InstallOptions): Promise<void> {
4
+ export async function install(): Promise<void> {
9
5
  console.log('🐍 chutes-plugin installer\n');
10
6
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
11
7
 
12
- let installType = options.type;
13
-
14
- if (!installType) {
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');
19
-
20
- const readline = await import('node:readline');
21
- const rl = readline.createInterface({
22
- input: process.stdin,
23
- output: process.stdout,
24
- });
25
-
26
- installType = await new Promise<string>((resolve) => {
27
- rl.question('> ', (answer) => {
28
- rl.close();
29
- resolve(answer.trim());
30
- });
31
- });
32
- }
33
-
34
- console.log(`Installing type: ${installType}\n`);
35
-
36
- switch (installType) {
37
- case '1':
38
- case 'project':
39
- await installProject();
40
- break;
41
- case '2':
42
- case 'global':
43
- await installGlobal();
44
- break;
45
- case '3':
46
- case 'npm':
47
- await installNpm();
48
- break;
49
- default:
50
- console.log(`❌ Invalid installation type: "${installType}"`);
51
- console.log('Please choose: 1 (project), 2 (global), or 3 (npm)');
52
- process.exit(1);
53
- }
54
- }
55
-
56
- async function installProject(): Promise<void> {
57
8
  const projectDir = process.cwd();
58
- const opencodeDir = path.join(projectDir, '.opencode');
59
- const pluginDir = path.join(opencodeDir, 'plugin', 'chutes-plugin');
60
-
61
- 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
- }
70
-
71
- fs.mkdirSync(pluginDir, { recursive: true });
72
-
73
- const distDir = path.join(__dirname, '..', '..', 'dist');
74
- if (fs.existsSync(distDir)) {
75
- fs.cpSync(distDir, path.join(pluginDir, 'dist'), { recursive: true });
76
- }
77
-
78
- const srcCliDir = path.join(__dirname, '..');
79
- if (fs.existsSync(srcCliDir)) {
80
- fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
81
- }
82
-
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
- }
9
+ const pluginDir = path.join(projectDir, '.opencode', 'plugin', 'chutes-plugin');
94
10
 
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!');
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');
113
- }
114
-
115
- async function installGlobal(): Promise<void> {
116
- const homeDir = process.env.HOME || process.env.USERPROFILE;
117
- if (!homeDir) {
118
- console.error('❌ Error: Could not determine home directory');
119
- process.exit(1);
120
- }
121
-
122
- const configDir = path.join(homeDir, '.config', 'opencode');
123
- const pluginDir = path.join(configDir, 'plugin', 'chutes-plugin');
124
-
125
- console.log('Installing globally...\n');
11
+ console.log('Installing chutes-plugin to project...\n');
12
+ console.log('Copying plugin files to .opencode/plugin/chutes-plugin/\n');
126
13
 
127
14
  fs.mkdirSync(pluginDir, { recursive: true });
128
15
 
@@ -136,70 +23,16 @@ async function installGlobal(): Promise<void> {
136
23
  fs.cpSync(srcCliDir, path.join(pluginDir, 'src'), { recursive: true });
137
24
  }
138
25
 
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!');
26
+ console.log('✅ Successfully installed!');
164
27
  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');
169
- }
170
-
171
- async function installNpm(): Promise<void> {
172
- const projectDir = process.cwd();
173
- const configPath = path.join(projectDir, 'opencode.json');
174
-
175
- console.log('Installing via npm...\n');
176
-
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);
185
- }
186
- }
187
-
188
- config.plugins = config.plugins || [];
189
- if (!Array.isArray(config.plugins)) {
190
- config.plugins = [];
191
- }
192
-
193
- if (!config.plugins.includes('chutes-plugin')) {
194
- config.plugins.push('chutes-plugin');
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');
28
+ console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
29
+ console.log('Next steps:');
30
+ console.log("1. Restart OpenCode if it's running");
31
+ console.log('2. Run: opencode');
32
+ console.log('3. Connect your token: /connect chutes');
33
+ console.log('4. Select a Chutes model from the dropdown');
34
+ console.log('\nAvailable tools:');
35
+ console.log(' - chutes_list_models');
36
+ console.log(' - chutes_refresh_models');
37
+ console.log(' - chutes_status');
205
38
  }