gyoshu 0.4.1 → 0.4.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.
Files changed (2) hide show
  1. package/bin/gyoshu.js +181 -0
  2. package/package.json +6 -2
package/bin/gyoshu.js ADDED
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Gyoshu CLI - Install/uninstall helper for OpenCode
5
+ *
6
+ * Usage:
7
+ * bunx gyoshu install - Add gyoshu to opencode.json
8
+ * bunx gyoshu uninstall - Remove gyoshu from opencode.json
9
+ * bunx gyoshu check - Verify installation status
10
+ */
11
+
12
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
13
+ import { join } from 'path';
14
+
15
+ const OPENCODE_CONFIG = 'opencode.json';
16
+
17
+ function findOpencodeConfig() {
18
+ // Check current directory
19
+ if (existsSync(OPENCODE_CONFIG)) {
20
+ return OPENCODE_CONFIG;
21
+ }
22
+ // Check home directory
23
+ const homeConfig = join(process.env.HOME || '', OPENCODE_CONFIG);
24
+ if (existsSync(homeConfig)) {
25
+ return homeConfig;
26
+ }
27
+ return null;
28
+ }
29
+
30
+ function readConfig(configPath) {
31
+ try {
32
+ const content = readFileSync(configPath, 'utf-8');
33
+ return JSON.parse(content);
34
+ } catch (e) {
35
+ return null;
36
+ }
37
+ }
38
+
39
+ function writeConfig(configPath, config) {
40
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
41
+ }
42
+
43
+ function install() {
44
+ let configPath = findOpencodeConfig();
45
+ let config;
46
+
47
+ if (configPath) {
48
+ config = readConfig(configPath);
49
+ if (!config) {
50
+ console.error(`Error: Could not parse ${configPath}`);
51
+ process.exit(1);
52
+ }
53
+ } else {
54
+ // Create new config in current directory
55
+ configPath = OPENCODE_CONFIG;
56
+ config = {};
57
+ console.log(`Creating new ${OPENCODE_CONFIG}...`);
58
+ }
59
+
60
+ // Ensure plugin array exists
61
+ if (!Array.isArray(config.plugin)) {
62
+ config.plugin = [];
63
+ }
64
+
65
+ // Check if already installed
66
+ if (config.plugin.includes('gyoshu')) {
67
+ console.log('Gyoshu is already installed in ' + configPath);
68
+ return;
69
+ }
70
+
71
+ // Add gyoshu
72
+ config.plugin.push('gyoshu');
73
+ writeConfig(configPath, config);
74
+
75
+ console.log('Gyoshu installed successfully!');
76
+ console.log(`Updated: ${configPath}`);
77
+ console.log('\nNext steps:');
78
+ console.log(' 1. Start OpenCode: opencode');
79
+ console.log(' 2. Run: /gyoshu doctor');
80
+ }
81
+
82
+ function uninstall() {
83
+ const configPath = findOpencodeConfig();
84
+
85
+ if (!configPath) {
86
+ console.log('No opencode.json found. Nothing to uninstall.');
87
+ return;
88
+ }
89
+
90
+ const config = readConfig(configPath);
91
+ if (!config) {
92
+ console.error(`Error: Could not parse ${configPath}`);
93
+ process.exit(1);
94
+ }
95
+
96
+ if (!Array.isArray(config.plugin) || !config.plugin.includes('gyoshu')) {
97
+ console.log('Gyoshu is not installed.');
98
+ return;
99
+ }
100
+
101
+ // Remove gyoshu
102
+ config.plugin = config.plugin.filter(p => p !== 'gyoshu');
103
+ writeConfig(configPath, config);
104
+
105
+ console.log('Gyoshu uninstalled successfully!');
106
+ console.log(`Updated: ${configPath}`);
107
+ }
108
+
109
+ function check() {
110
+ const configPath = findOpencodeConfig();
111
+
112
+ if (!configPath) {
113
+ console.log('Status: NOT INSTALLED');
114
+ console.log('No opencode.json found.');
115
+ console.log('\nTo install: bunx gyoshu install');
116
+ return;
117
+ }
118
+
119
+ const config = readConfig(configPath);
120
+ if (!config) {
121
+ console.log('Status: ERROR');
122
+ console.log(`Could not parse ${configPath}`);
123
+ return;
124
+ }
125
+
126
+ const isInstalled = Array.isArray(config.plugin) && config.plugin.includes('gyoshu');
127
+
128
+ if (isInstalled) {
129
+ console.log('Status: INSTALLED');
130
+ console.log(`Config: ${configPath}`);
131
+ console.log('\nTo verify in OpenCode: /gyoshu doctor');
132
+ } else {
133
+ console.log('Status: NOT INSTALLED');
134
+ console.log(`Config exists: ${configPath}`);
135
+ console.log('\nTo install: bunx gyoshu install');
136
+ }
137
+ }
138
+
139
+ function showHelp() {
140
+ console.log(`
141
+ Gyoshu - Scientific Research Agent for OpenCode
142
+
143
+ Usage:
144
+ gyoshu install Add gyoshu to opencode.json
145
+ gyoshu uninstall Remove gyoshu from opencode.json
146
+ gyoshu check Verify installation status
147
+ gyoshu help Show this help message
148
+
149
+ Examples:
150
+ bunx gyoshu install
151
+ npx gyoshu check
152
+
153
+ More info: https://github.com/Yeachan-Heo/My-Jogyo
154
+ `);
155
+ }
156
+
157
+ // Main
158
+ const command = process.argv[2];
159
+
160
+ switch (command) {
161
+ case 'install':
162
+ install();
163
+ break;
164
+ case 'uninstall':
165
+ uninstall();
166
+ break;
167
+ case 'check':
168
+ check();
169
+ break;
170
+ case 'help':
171
+ case '--help':
172
+ case '-h':
173
+ showHelp();
174
+ break;
175
+ default:
176
+ if (command) {
177
+ console.error(`Unknown command: ${command}\n`);
178
+ }
179
+ showHelp();
180
+ process.exit(command ? 1 : 0);
181
+ }
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "gyoshu",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Scientific research agent extension for OpenCode - turns research goals into reproducible Jupyter notebooks",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "exports": {
8
8
  ".": "./src/index.ts"
9
9
  },
10
+ "bin": {
11
+ "gyoshu": "./bin/gyoshu.js"
12
+ },
10
13
  "files": [
11
- "src/"
14
+ "src/",
15
+ "bin/"
12
16
  ],
13
17
  "scripts": {
14
18
  "test": "bun test ./tests",