@solidrt/cli 0.0.50 → 0.0.52
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/AGENTS.md +79 -36
- package/README.md +86 -15
- package/agents/assets.md +46 -0
- package/agents/debugging.md +294 -0
- package/dist/console.srtapp +94123 -73
- package/dist/server.js +3936 -0
- package/package.json +11 -10
- package/src/android/docs.md +21 -0
- package/src/android/main.ts +286 -0
- package/src/{bundler.ts → bundle/bundler.ts} +163 -76
- package/src/bundle/docs.md +12 -0
- package/src/bundle/main.ts +203 -0
- package/src/check/docs.md +10 -0
- package/src/check/main.ts +85 -0
- package/src/{commands/check.ts → check/typecheck.ts} +11 -34
- package/src/client/docs.md +9 -0
- package/src/client/main.ts +33 -0
- package/src/console/docs.md +14 -0
- package/src/console/main.ts +21 -0
- package/src/demo/docs.md +27 -0
- package/src/demo/main.ts +67 -0
- package/src/init/docs.md +11 -0
- package/src/{commands/init.ts → init/main.ts} +31 -25
- package/src/init/scaffold/AGENTS.md +98 -0
- package/src/init/scaffold/package.json +23 -0
- package/{scaffold → src/init/scaffold}/templates/components/index.tsx +2 -3
- package/{scaffold → src/init/scaffold}/templates/default/index.tsx +2 -3
- package/src/lib/args.ts +194 -0
- package/src/{artifacts.ts → lib/artifacts.ts} +41 -1
- package/src/{dev-dir.ts → lib/dev-dir.ts} +10 -8
- package/src/{fonts.ts → lib/fonts.ts} +12 -26
- package/src/lib/mode.ts +77 -0
- package/src/{project.ts → lib/project.ts} +109 -61
- package/src/lib/registry.ts +120 -0
- package/src/lib/server-bundle.ts +24 -0
- package/src/lib/usage.ts +117 -0
- package/src/lib/util.ts +36 -0
- package/src/main.ts +109 -31
- package/src/mcp/docs.md +22 -0
- package/src/mcp/main.ts +719 -0
- package/src/pack/docs.md +18 -0
- package/src/{pack-folder.ts → pack/layout.ts} +13 -22
- package/src/pack/main.ts +86 -0
- package/src/pack/trailer.ts +97 -0
- package/src/render/docs.md +19 -0
- package/src/render/main.ts +49 -0
- package/src/server/args.ts +126 -0
- package/src/server/binaries.ts +47 -0
- package/src/server/config.ts +54 -0
- package/{server → src/server}/control.ts +246 -78
- package/src/server/docs.md +51 -0
- package/src/server/line-editor.ts +200 -0
- package/src/server/main.ts +473 -0
- package/src/server/mode.ts +92 -0
- package/src/server/rebuild.ts +90 -0
- package/src/server/registry.ts +138 -0
- package/src/server/remap.ts +60 -0
- package/src/server/repl.ts +223 -0
- package/src/server/state.ts +54 -0
- package/{server → src/server}/tsconfig.json +1 -1
- package/{server → src/server}/tunnel.ts +6 -6
- package/src/server/watcher.ts +121 -0
- package/src/tool/main.ts +70 -0
- package/src/types/bundle.d.ts +24 -0
- package/src/types/control.d.ts +90 -0
- package/src/types/registry.d.ts +16 -0
- package/scaffold/AGENTS.md +0 -630
- package/scaffold/package.json +0 -22
- package/scaffold/templates/components/icon.tsx +0 -48
- package/scaffold/templates/default/icon.tsx +0 -48
- package/server/main.ts +0 -308
- package/server/rebuild.ts +0 -68
- package/server/remap.ts +0 -47
- package/server/state.ts +0 -93
- package/src/args.ts +0 -212
- package/src/bundle-cli.ts +0 -13
- package/src/commands/bundle.ts +0 -76
- package/src/commands/client.ts +0 -34
- package/src/commands/mcp.ts +0 -603
- package/src/commands/pack.ts +0 -65
- package/src/commands/render.ts +0 -24
- package/src/commands/server.ts +0 -73
- package/src/dev-android.ts +0 -176
- package/src/dev-client.ts +0 -29
- package/src/dev-server.ts +0 -302
- package/src/packer.ts +0 -103
- package/src/repl.ts +0 -233
- package/src/util.ts +0 -121
- package/src/watcher.ts +0 -69
- /package/src/{untyped-deps.d.ts → bundle/untyped-deps.d.ts} +0 -0
- /package/src/{prompt.ts → init/prompt.ts} +0 -0
- /package/{scaffold → src/init/scaffold}/gitignore +0 -0
- /package/{scaffold → src/init/scaffold}/icon.svg +0 -0
- /package/{scaffold → src/init/scaffold}/mcp.json +0 -0
- /package/{scaffold → src/init/scaffold}/tsconfig.json +0 -0
- /package/{server → src/server}/cache.ts +0 -0
- /package/{server → src/server}/proxy.ts +0 -0
- /package/{server → src/server}/qr.ts +0 -0
package/src/main.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
3
|
+
// bin/srt lands here. This file routes the command word and nothing else:
|
|
4
|
+
// the bun commands live one folder each (src/<command>/main.ts) and load on
|
|
5
|
+
// demand, and `run`/`server` launch the flux dev server (src/server/), a
|
|
6
|
+
// process complete on its own that this launcher only resolves the binaries
|
|
7
|
+
// for (okf/done/srt-command-folders.md).
|
|
8
|
+
|
|
9
|
+
import { fileURLToPath } from "node:url"
|
|
10
|
+
import { existsSync, unlinkSync } from "node:fs"
|
|
11
|
+
import { tmpdir } from "node:os"
|
|
12
|
+
import { dirname, resolve } from "node:path"
|
|
13
|
+
import { values, command, source, port, appArgs, validateArgs } from "./lib/args"
|
|
14
|
+
import { printUsage, printVersion, hint } from "./lib/usage"
|
|
15
|
+
import { requireBinary } from "./lib/util"
|
|
16
|
+
import { buildServerBundle } from "./lib/server-bundle"
|
|
17
|
+
|
|
18
|
+
// -- Help and version --
|
|
19
|
+
|
|
20
|
+
// Answered before anything else: neither takes a command, so they must not
|
|
21
|
+
// fall through to the usage error.
|
|
22
|
+
if (values.help) {
|
|
23
|
+
printUsage()
|
|
24
|
+
process.exit(0)
|
|
25
|
+
}
|
|
26
|
+
if (values.version) {
|
|
27
|
+
printVersion()
|
|
28
|
+
process.exit(0)
|
|
29
|
+
}
|
|
13
30
|
|
|
14
31
|
// -- Validate args --
|
|
15
32
|
|
|
@@ -36,28 +53,89 @@ if (isProdBuild && process.env.NODE_ENV !== "production") {
|
|
|
36
53
|
process.exit(proc.exitCode ?? 0)
|
|
37
54
|
}
|
|
38
55
|
|
|
56
|
+
// -- run / server: launch the dev server --
|
|
57
|
+
|
|
58
|
+
// The server script the flux binary runs: the prebuilt bundle a published
|
|
59
|
+
// CLI ships, or (in a checkout) one built now into a temp file, removed on
|
|
60
|
+
// exit.
|
|
61
|
+
async function serverScript(): Promise<{ path: string; temp: boolean }> {
|
|
62
|
+
let prebuilt = fileURLToPath(new URL("../dist/server.js", import.meta.url))
|
|
63
|
+
if (existsSync(prebuilt)) return { path: prebuilt, temp: false }
|
|
64
|
+
let outfile = resolve(tmpdir(), `srt-dev-server-${process.pid}.js`)
|
|
65
|
+
await buildServerBundle(outfile)
|
|
66
|
+
return { path: outfile, temp: true }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// `demo` serves a demos project the same way `run` serves any other one:
|
|
70
|
+
// the entry is resolved for the caller (src/demo/main.ts) and the server is
|
|
71
|
+
// started IN that project, so mode.ts resolves it as a project and its
|
|
72
|
+
// assets/ folder is served like any app's.
|
|
73
|
+
async function launchServer(withClient: boolean, demo?: { cwd: string; entry: string }) {
|
|
74
|
+
let flux = requireBinary("flux")
|
|
75
|
+
let script = await serverScript()
|
|
76
|
+
|
|
77
|
+
let args: string[] = []
|
|
78
|
+
if (demo) {
|
|
79
|
+
args.push(demo.entry, "--project")
|
|
80
|
+
} else {
|
|
81
|
+
if (source !== undefined) args.push(source)
|
|
82
|
+
if (values.project) args.push("--project")
|
|
83
|
+
if (values.file) args.push("--file")
|
|
84
|
+
}
|
|
85
|
+
if (port !== undefined) args.push("--port", String(port))
|
|
86
|
+
for (let flag of ["lan", "proxy-http", "tunnel", "stats", "minify"] as const) {
|
|
87
|
+
if (values[flag]) args.push(`--${flag}`)
|
|
88
|
+
}
|
|
89
|
+
if (values.capture) args.push("--capture", values.capture)
|
|
90
|
+
if (withClient) {
|
|
91
|
+
args.push("--client", values.client ?? "0")
|
|
92
|
+
if (values["data-root"]) args.push("--data-root", values["data-root"])
|
|
93
|
+
if (values.size) args.push("--size", values.size)
|
|
94
|
+
}
|
|
95
|
+
if (appArgs.length) args.push("--", ...appArgs)
|
|
96
|
+
|
|
97
|
+
let proc = Bun.spawn([flux, script.path, ...args], {
|
|
98
|
+
cwd: demo?.cwd,
|
|
99
|
+
// stdin is passed through for the server's repl (flux:tty): with no
|
|
100
|
+
// terminal there the server runs without one.
|
|
101
|
+
stdio: ["inherit", "inherit", "inherit"],
|
|
102
|
+
env: {
|
|
103
|
+
...process.env,
|
|
104
|
+
SRT_PLATFORM_DIR: dirname(flux),
|
|
105
|
+
SRT_BUN: process.execPath,
|
|
106
|
+
SRT_CLI: fileURLToPath(new URL("..", import.meta.url)),
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
// The server ends itself on these (drops its record, stops the client);
|
|
110
|
+
// this process just relays them and waits.
|
|
111
|
+
let relay = () => proc.kill("SIGTERM")
|
|
112
|
+
process.on("SIGINT", relay)
|
|
113
|
+
process.on("SIGTERM", relay)
|
|
114
|
+
let code = await proc.exited
|
|
115
|
+
if (script.temp) {
|
|
116
|
+
try {
|
|
117
|
+
unlinkSync(script.path)
|
|
118
|
+
} catch {}
|
|
119
|
+
}
|
|
120
|
+
process.exit(code)
|
|
121
|
+
}
|
|
122
|
+
|
|
39
123
|
// -- Dispatch --
|
|
40
124
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await runCheckCommand()
|
|
47
|
-
} else if (command === "pack") {
|
|
48
|
-
await runPackCommand()
|
|
49
|
-
} else if (command === "render") {
|
|
50
|
-
await runRenderCommand()
|
|
51
|
-
} else if (command === "client") {
|
|
52
|
-
await runClientCommand()
|
|
53
|
-
} else if (command === "server") {
|
|
54
|
-
await runServerCommand()
|
|
125
|
+
const COMMANDS = ["init", "bundle", "check", "pack", "render", "client", "console", "android", "mcp", "tool"] as const
|
|
126
|
+
type Command = (typeof COMMANDS)[number]
|
|
127
|
+
|
|
128
|
+
if (command === "server") {
|
|
129
|
+
await launchServer(false)
|
|
55
130
|
} else if (command === "run") {
|
|
56
|
-
await
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
await
|
|
131
|
+
await launchServer(true)
|
|
132
|
+
} else if (command === "demo") {
|
|
133
|
+
let { main } = await import("./demo/main")
|
|
134
|
+
let target = await main()
|
|
135
|
+
if (target) await launchServer(true, target)
|
|
136
|
+
} else if (command !== undefined && (COMMANDS as readonly string[]).includes(command)) {
|
|
137
|
+
let { main } = await import(`./${command as Command}/main`)
|
|
138
|
+
await main()
|
|
60
139
|
} else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
140
|
+
hint(command === undefined ? undefined : `Unknown command "${command}"`)
|
|
141
|
+
}
|
package/src/mcp/docs.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# srt mcp
|
|
2
|
+
|
|
3
|
+
{{ usage mcp }}
|
|
4
|
+
|
|
5
|
+
Exposes the running app to a coding agent over MCP: logs (source-mapped back
|
|
6
|
+
to your TSX), stats (and the on-screen overlay), the live render tree,
|
|
7
|
+
screenshots and texture readback, GPU resources, input injection, a
|
|
8
|
+
virtual-time transport (`step_frames`, `set_time_scale`), reload and load, a
|
|
9
|
+
mute on the user's own input while the agent measures or tests
|
|
10
|
+
(`mute_user_input`/`unmute_user_input`), a pause on reload-on-save while it
|
|
11
|
+
edits (`pause_watch`/`resume_watch`), and any debug commands the app itself
|
|
12
|
+
registers.
|
|
13
|
+
A scaffolded project ships an `.mcp.json`, so Claude Code attaches to your
|
|
14
|
+
running app with no setup. Other agents keep their server list in their own
|
|
15
|
+
file; point it at `bun node_modules/@solidrt/cli/bin/srt mcp`, run from the
|
|
16
|
+
project root (agents/debugging.md in this package lists the file per client).
|
|
17
|
+
|
|
18
|
+
That connection is why SolidRT keeps the app inspectable from outside: an
|
|
19
|
+
agent working on your app should be able to look at what it is actually
|
|
20
|
+
doing, not just at the source. Every tool is a thin wrapper over the dev
|
|
21
|
+
server's HTTP control API, so a shell script or a CI step can do the same
|
|
22
|
+
without MCP (agents/debugging.md).
|