@solidrt/cli 0.0.24 → 0.0.26
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 +10 -7
- package/scaffold/AGENTS.md +16 -0
- package/scaffold/mcp.json +8 -0
- package/scaffold/package.json +5 -5
- package/{src → server}/cache.ts +23 -51
- package/server/control.ts +132 -0
- package/server/main.ts +292 -0
- package/server/proxy.ts +72 -0
- package/server/qr.ts +35 -0
- package/server/state.ts +46 -0
- package/server/tsconfig.json +11 -0
- package/server/tunnel.ts +53 -0
- package/src/args.ts +3 -0
- package/src/commands/init.ts +1 -0
- package/src/commands/mcp.ts +158 -0
- package/src/commands/server.ts +13 -18
- package/src/dev-client.ts +10 -21
- package/src/dev-server.ts +141 -246
- package/src/main.ts +3 -0
- package/src/repl.ts +54 -42
- package/src/util.ts +27 -16
- package/src/watcher.ts +3 -6
package/src/util.ts
CHANGED
|
@@ -2,31 +2,26 @@ import { resolveBinary } from "./artifacts"
|
|
|
2
2
|
import { existsSync } from "node:fs"
|
|
3
3
|
import { resolve } from "node:path"
|
|
4
4
|
import type { Interface as ReadlineInterface } from "node:readline"
|
|
5
|
-
import type {
|
|
6
|
-
import type { Bonjour } from "bonjour-service"
|
|
5
|
+
// import type { Bonjour } from "bonjour-service" (mDNS advertise, kept - see dev-server.ts)
|
|
7
6
|
|
|
8
7
|
export let state = {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// What srt believes the current bundle is; the server process keeps its own
|
|
9
|
+
// latched copy for late-joining clients (see packages/cli/server/).
|
|
11
10
|
currentCode: null as string | null,
|
|
12
11
|
source: undefined as string | undefined,
|
|
13
12
|
sourceDir: process.cwd(),
|
|
14
13
|
child: null as ReturnType<typeof Bun.spawn> | null,
|
|
15
|
-
server
|
|
14
|
+
// The spawned flux dev-server process (see dev-server.ts startServer).
|
|
15
|
+
serverProc: null as ReturnType<typeof Bun.spawn> | null,
|
|
16
|
+
shuttingDown: false,
|
|
16
17
|
serverUrl: null as string | null,
|
|
17
18
|
rl: null as ReadlineInterface | null,
|
|
18
|
-
bonjour: null as Bonjour | null,
|
|
19
|
+
// bonjour: null as Bonjour | null, (mDNS advertise, kept - see dev-server.ts)
|
|
19
20
|
stats: false,
|
|
20
21
|
// --capture <file>: destination for captured key events, or undefined when
|
|
21
|
-
// off
|
|
22
|
-
//
|
|
23
|
-
// several connected clients merge into one coherent timeline, tagged by
|
|
24
|
-
// `device` (see dev-server.ts) so they can be told apart. Streamed to disk
|
|
25
|
-
// as JSON Lines (one event object per line) as each arrives - see
|
|
26
|
-
// dev-server.ts's "capture" message handling.
|
|
22
|
+
// off; the server process owns the capture file and clock (see
|
|
23
|
+
// packages/cli/server/main.ts's "capture" message handling).
|
|
27
24
|
capture: undefined as string | undefined,
|
|
28
|
-
captureStartMs: 0,
|
|
29
|
-
captureLastAt: 0, // ms, same clock as captureStartMs
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
// Build target per binary, for the "not found" hint. Run from the repo root.
|
|
@@ -93,9 +88,25 @@ export function printErr(...args: any[]) {
|
|
|
93
88
|
state.rl?.prompt(true)
|
|
94
89
|
}
|
|
95
90
|
|
|
91
|
+
// Pipe a child stream to `out` without mangling the repl prompt: clear the
|
|
92
|
+
// prompt line, write the chunk, redraw the prompt.
|
|
93
|
+
export function pipeAbovePrompt(stream: ReadableStream<Uint8Array>, out: NodeJS.WriteStream) {
|
|
94
|
+
let reader = stream.getReader()
|
|
95
|
+
;(async () => {
|
|
96
|
+
while (true) {
|
|
97
|
+
let { done, value } = await reader.read()
|
|
98
|
+
if (done || !value) break
|
|
99
|
+
process.stdout.write("\r\x1b[K")
|
|
100
|
+
out.write(value)
|
|
101
|
+
state.rl?.prompt(true)
|
|
102
|
+
}
|
|
103
|
+
})()
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
export function shutdown() {
|
|
107
|
+
state.shuttingDown = true
|
|
97
108
|
if (state.child) state.child.kill()
|
|
98
|
-
if (state.
|
|
99
|
-
if (state.bonjour) state.bonjour.destroy()
|
|
109
|
+
if (state.serverProc) state.serverProc.kill()
|
|
110
|
+
// if (state.bonjour) state.bonjour.destroy() (mDNS advertise, kept - see dev-server.ts)
|
|
100
111
|
process.exit(0)
|
|
101
112
|
}
|
package/src/watcher.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { watch } from "node:fs"
|
|
2
2
|
import { resolve, dirname } from "path"
|
|
3
3
|
import { state, print, printErr } from "./util"
|
|
4
|
-
import { buildReload, showBuildFailure } from "./dev-server"
|
|
4
|
+
import { buildReload, sendReload, showBuildFailure } from "./dev-server"
|
|
5
5
|
import { bundle, codeFromOutputs } from "./bundler"
|
|
6
6
|
|
|
7
7
|
let currentWatcher: ReturnType<typeof watch> | null = null
|
|
@@ -28,13 +28,10 @@ export function startWatcher() {
|
|
|
28
28
|
let result = await bundle(state.source)
|
|
29
29
|
if (!result) {
|
|
30
30
|
printErr("[cli] Build failed, waiting for changes...")
|
|
31
|
-
showBuildFailure()
|
|
31
|
+
await showBuildFailure()
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
34
|
state.currentCode = await codeFromOutputs(result.outputs)
|
|
35
|
-
|
|
36
|
-
for (let ws of state.clients.keys()) {
|
|
37
|
-
ws.send(msg)
|
|
38
|
-
}
|
|
35
|
+
await sendReload(buildReload({ code: state.currentCode }), { latch: true })
|
|
39
36
|
})
|
|
40
37
|
}
|