@x-all-in-one/coding-helper 0.5.0 → 0.5.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.
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { execSync, spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { bunInstaller } from '../wizard/installers/bun-installer.js';
|
|
6
|
+
const PLUGIN_PATTERNS = ['oh-my-openagent', 'oh-my-opencode'];
|
|
7
|
+
function isPluginEntry(p) {
|
|
8
|
+
return typeof p === 'string' && PLUGIN_PATTERNS.some(pattern => p === pattern || p.startsWith(`${pattern}@`));
|
|
9
|
+
}
|
|
10
|
+
function resolveBunxCommand() {
|
|
11
|
+
if (process.platform !== 'win32') {
|
|
12
|
+
return 'bunx';
|
|
13
|
+
}
|
|
14
|
+
for (const cmd of ['bunx.cmd', 'bunx.exe']) {
|
|
15
|
+
try {
|
|
16
|
+
execSync(`where ${cmd}`, { stdio: 'pipe' });
|
|
17
|
+
return cmd;
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
21
|
+
return 'bunx.cmd';
|
|
22
|
+
}
|
|
6
23
|
export class OhMyOpenAgentPlugin {
|
|
7
24
|
name = 'oh-my-openagent';
|
|
8
25
|
displayName = 'Oh My OpenAgent';
|
|
@@ -23,10 +40,9 @@ export class OhMyOpenAgentPlugin {
|
|
|
23
40
|
if (!hasBun) {
|
|
24
41
|
throw new Error('Bun is required for Oh My OpenAgent. Please install bun first.');
|
|
25
42
|
}
|
|
26
|
-
const
|
|
27
|
-
const bunxCommand = isWindows ? 'bunx.cmd' : 'bunx';
|
|
43
|
+
const bunxCommand = resolveBunxCommand();
|
|
28
44
|
return new Promise((resolve, reject) => {
|
|
29
|
-
const args = ['oh-my-
|
|
45
|
+
const args = ['oh-my-openagent@latest', 'install', '--no-tui', '--claude=no', '--openai=no', '--gemini=no', '--copilot=no'];
|
|
30
46
|
const child = spawn(bunxCommand, args, {
|
|
31
47
|
stdio: 'inherit',
|
|
32
48
|
shell: true,
|
|
@@ -45,16 +61,15 @@ export class OhMyOpenAgentPlugin {
|
|
|
45
61
|
if (!config.plugin) {
|
|
46
62
|
config.plugin = [];
|
|
47
63
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
64
|
+
config.plugin = config.plugin.filter((p) => !isPluginEntry(p));
|
|
65
|
+
config.plugin.push('oh-my-openagent@latest');
|
|
66
|
+
this.saveConfig(config);
|
|
67
|
+
this.migrateConfigFile();
|
|
53
68
|
}
|
|
54
69
|
unload() {
|
|
55
70
|
const config = this.getConfig();
|
|
56
71
|
if (config.plugin && Array.isArray(config.plugin)) {
|
|
57
|
-
config.plugin = config.plugin.filter((p) => !(
|
|
72
|
+
config.plugin = config.plugin.filter((p) => !isPluginEntry(p));
|
|
58
73
|
if (config.plugin.length === 0) {
|
|
59
74
|
delete config.plugin;
|
|
60
75
|
}
|
|
@@ -64,7 +79,7 @@ export class OhMyOpenAgentPlugin {
|
|
|
64
79
|
isLoaded() {
|
|
65
80
|
const config = this.getConfig();
|
|
66
81
|
if (config.plugin && Array.isArray(config.plugin)) {
|
|
67
|
-
return config.plugin.some(
|
|
82
|
+
return config.plugin.some(isPluginEntry);
|
|
68
83
|
}
|
|
69
84
|
return false;
|
|
70
85
|
}
|
|
@@ -83,5 +98,12 @@ export class OhMyOpenAgentPlugin {
|
|
|
83
98
|
saveConfig(config) {
|
|
84
99
|
writeFileSync(this.configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
85
100
|
}
|
|
101
|
+
migrateConfigFile() {
|
|
102
|
+
const legacyPath = join(homedir(), '.config', 'opencode', 'oh-my-opencode.json');
|
|
103
|
+
const newPath = join(homedir(), '.config', 'opencode', 'oh-my-openagent.json');
|
|
104
|
+
if (existsSync(legacyPath) && !existsSync(newPath)) {
|
|
105
|
+
renameSync(legacyPath, newPath);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
86
108
|
}
|
|
87
109
|
export const ohMyOpenAgentPlugin = new OhMyOpenAgentPlugin();
|
|
@@ -326,7 +326,8 @@ export class OpenCodeTool extends BaseTool {
|
|
|
326
326
|
try {
|
|
327
327
|
const config = this.getConfig();
|
|
328
328
|
if (config.plugin && Array.isArray(config.plugin)) {
|
|
329
|
-
|
|
329
|
+
const patterns = ['oh-my-openagent', 'oh-my-opencode'];
|
|
330
|
+
return config.plugin.some((p) => typeof p === 'string' && patterns.some(pattern => p === pattern || p.startsWith(`${pattern}@`)));
|
|
330
331
|
}
|
|
331
332
|
return false;
|
|
332
333
|
}
|
|
@@ -19,9 +19,18 @@ export class BunInstaller {
|
|
|
19
19
|
* 检查 Bun 是否已安装
|
|
20
20
|
*/
|
|
21
21
|
hasBun() {
|
|
22
|
-
|
|
22
|
+
if (process.platform === 'win32') {
|
|
23
|
+
for (const cmd of ['bun.cmd', 'bun.exe']) {
|
|
24
|
+
try {
|
|
25
|
+
execSync(`where ${cmd}`, { stdio: 'ignore' });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
23
32
|
try {
|
|
24
|
-
execSync(
|
|
33
|
+
execSync('which bun', { stdio: 'ignore' });
|
|
25
34
|
return true;
|
|
26
35
|
}
|
|
27
36
|
catch {
|