@kitlangton/tailcode 0.2.0 → 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/bin/tailcode.ts +6 -14
- package/package.json +1 -1
package/bin/tailcode.ts
CHANGED
|
@@ -6,7 +6,7 @@ const DEFAULT_PORT = 4096
|
|
|
6
6
|
|
|
7
7
|
function printHelp() {
|
|
8
8
|
process.stdout.write(
|
|
9
|
-
`tailcode\n\nUsage:\n tailcode [--
|
|
9
|
+
`tailcode\n\nUsage:\n tailcode [--attach] [--help]\n\nOptions:\n --attach Attach to an already-running local OpenCode server\n --help Show this help\n`,
|
|
10
10
|
)
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -35,8 +35,8 @@ async function isHealthy(port: number) {
|
|
|
35
35
|
async function runAttach(port: number) {
|
|
36
36
|
const bin = Bun.which("opencode")
|
|
37
37
|
if (!bin) {
|
|
38
|
-
process.stderr.write("tailcode: 'opencode' is not installed
|
|
39
|
-
|
|
38
|
+
process.stderr.write("tailcode: 'opencode' is not installed\n")
|
|
39
|
+
process.exit(1)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
const target = `http://127.0.0.1:${port}`
|
|
@@ -52,7 +52,6 @@ async function runAttach(port: number) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const args = process.argv.slice(2)
|
|
55
|
-
const forceWizard = args.includes("--wizard")
|
|
56
55
|
const forceAttach = args.includes("--attach")
|
|
57
56
|
|
|
58
57
|
if (args.includes("--help") || args.includes("-h")) {
|
|
@@ -60,24 +59,17 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
60
59
|
process.exit(0)
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
if (forceWizard && forceAttach) {
|
|
64
|
-
process.stderr.write("tailcode: use either --wizard or --attach, not both\n")
|
|
65
|
-
process.exit(1)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
62
|
const port = resolvePort()
|
|
69
63
|
|
|
70
|
-
if (
|
|
64
|
+
if (forceAttach) {
|
|
71
65
|
const healthy = await isHealthy(port)
|
|
72
66
|
if (healthy) {
|
|
73
67
|
await runAttach(port)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (forceAttach) {
|
|
68
|
+
} else {
|
|
77
69
|
process.stderr.write(`tailcode: OpenCode is not running on http://127.0.0.1:${port}\n`)
|
|
78
|
-
process.stderr.write("tailcode: run without --attach to start the setup wizard\n")
|
|
79
70
|
process.exit(1)
|
|
80
71
|
}
|
|
81
72
|
}
|
|
82
73
|
|
|
74
|
+
// Default: always launch the wizard
|
|
83
75
|
await import("../src/main.tsx")
|