opencode-pilot 0.2.1 → 0.2.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/package.json +1 -1
- package/plugin/index.js +9 -4
package/package.json
CHANGED
package/plugin/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// The plugin checks if the daemon is running and starts it if needed.
|
|
5
5
|
|
|
6
6
|
import { existsSync, readFileSync } from 'fs'
|
|
7
|
+
import { spawn } from 'child_process'
|
|
7
8
|
import { join } from 'path'
|
|
8
9
|
import { homedir } from 'os'
|
|
9
10
|
import YAML from 'yaml'
|
|
@@ -33,7 +34,7 @@ function getPort() {
|
|
|
33
34
|
/**
|
|
34
35
|
* OpenCode plugin that auto-starts the daemon if not running
|
|
35
36
|
*/
|
|
36
|
-
export const PilotPlugin = async (
|
|
37
|
+
export const PilotPlugin = async () => {
|
|
37
38
|
const port = getPort()
|
|
38
39
|
|
|
39
40
|
try {
|
|
@@ -46,11 +47,15 @@ export const PilotPlugin = async ({ $ }) => {
|
|
|
46
47
|
return {}
|
|
47
48
|
}
|
|
48
49
|
} catch {
|
|
49
|
-
// Not running, start it
|
|
50
|
+
// Not running, start it as detached background process
|
|
50
51
|
try {
|
|
51
|
-
|
|
52
|
+
const child = spawn('npx', ['opencode-pilot', 'start'], {
|
|
53
|
+
detached: true,
|
|
54
|
+
stdio: 'ignore',
|
|
55
|
+
})
|
|
56
|
+
child.unref()
|
|
52
57
|
} catch {
|
|
53
|
-
// Ignore start errors
|
|
58
|
+
// Ignore start errors
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|