@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.
Files changed (98) hide show
  1. package/AGENTS.md +79 -36
  2. package/README.md +86 -15
  3. package/agents/assets.md +46 -0
  4. package/agents/debugging.md +294 -0
  5. package/dist/console.srtapp +94123 -73
  6. package/dist/server.js +3936 -0
  7. package/package.json +11 -10
  8. package/src/android/docs.md +21 -0
  9. package/src/android/main.ts +286 -0
  10. package/src/{bundler.ts → bundle/bundler.ts} +163 -76
  11. package/src/bundle/docs.md +12 -0
  12. package/src/bundle/main.ts +203 -0
  13. package/src/check/docs.md +10 -0
  14. package/src/check/main.ts +85 -0
  15. package/src/{commands/check.ts → check/typecheck.ts} +11 -34
  16. package/src/client/docs.md +9 -0
  17. package/src/client/main.ts +33 -0
  18. package/src/console/docs.md +14 -0
  19. package/src/console/main.ts +21 -0
  20. package/src/demo/docs.md +27 -0
  21. package/src/demo/main.ts +67 -0
  22. package/src/init/docs.md +11 -0
  23. package/src/{commands/init.ts → init/main.ts} +31 -25
  24. package/src/init/scaffold/AGENTS.md +98 -0
  25. package/src/init/scaffold/package.json +23 -0
  26. package/{scaffold → src/init/scaffold}/templates/components/index.tsx +2 -3
  27. package/{scaffold → src/init/scaffold}/templates/default/index.tsx +2 -3
  28. package/src/lib/args.ts +194 -0
  29. package/src/{artifacts.ts → lib/artifacts.ts} +41 -1
  30. package/src/{dev-dir.ts → lib/dev-dir.ts} +10 -8
  31. package/src/{fonts.ts → lib/fonts.ts} +12 -26
  32. package/src/lib/mode.ts +77 -0
  33. package/src/{project.ts → lib/project.ts} +109 -61
  34. package/src/lib/registry.ts +120 -0
  35. package/src/lib/server-bundle.ts +24 -0
  36. package/src/lib/usage.ts +117 -0
  37. package/src/lib/util.ts +36 -0
  38. package/src/main.ts +109 -31
  39. package/src/mcp/docs.md +22 -0
  40. package/src/mcp/main.ts +719 -0
  41. package/src/pack/docs.md +18 -0
  42. package/src/{pack-folder.ts → pack/layout.ts} +13 -22
  43. package/src/pack/main.ts +86 -0
  44. package/src/pack/trailer.ts +97 -0
  45. package/src/render/docs.md +19 -0
  46. package/src/render/main.ts +49 -0
  47. package/src/server/args.ts +126 -0
  48. package/src/server/binaries.ts +47 -0
  49. package/src/server/config.ts +54 -0
  50. package/{server → src/server}/control.ts +246 -78
  51. package/src/server/docs.md +51 -0
  52. package/src/server/line-editor.ts +200 -0
  53. package/src/server/main.ts +473 -0
  54. package/src/server/mode.ts +92 -0
  55. package/src/server/rebuild.ts +90 -0
  56. package/src/server/registry.ts +138 -0
  57. package/src/server/remap.ts +60 -0
  58. package/src/server/repl.ts +223 -0
  59. package/src/server/state.ts +54 -0
  60. package/{server → src/server}/tsconfig.json +1 -1
  61. package/{server → src/server}/tunnel.ts +6 -6
  62. package/src/server/watcher.ts +121 -0
  63. package/src/tool/main.ts +70 -0
  64. package/src/types/bundle.d.ts +24 -0
  65. package/src/types/control.d.ts +90 -0
  66. package/src/types/registry.d.ts +16 -0
  67. package/scaffold/AGENTS.md +0 -630
  68. package/scaffold/package.json +0 -22
  69. package/scaffold/templates/components/icon.tsx +0 -48
  70. package/scaffold/templates/default/icon.tsx +0 -48
  71. package/server/main.ts +0 -308
  72. package/server/rebuild.ts +0 -68
  73. package/server/remap.ts +0 -47
  74. package/server/state.ts +0 -93
  75. package/src/args.ts +0 -212
  76. package/src/bundle-cli.ts +0 -13
  77. package/src/commands/bundle.ts +0 -76
  78. package/src/commands/client.ts +0 -34
  79. package/src/commands/mcp.ts +0 -603
  80. package/src/commands/pack.ts +0 -65
  81. package/src/commands/render.ts +0 -24
  82. package/src/commands/server.ts +0 -73
  83. package/src/dev-android.ts +0 -176
  84. package/src/dev-client.ts +0 -29
  85. package/src/dev-server.ts +0 -302
  86. package/src/packer.ts +0 -103
  87. package/src/repl.ts +0 -233
  88. package/src/util.ts +0 -121
  89. package/src/watcher.ts +0 -69
  90. /package/src/{untyped-deps.d.ts → bundle/untyped-deps.d.ts} +0 -0
  91. /package/src/{prompt.ts → init/prompt.ts} +0 -0
  92. /package/{scaffold → src/init/scaffold}/gitignore +0 -0
  93. /package/{scaffold → src/init/scaffold}/icon.svg +0 -0
  94. /package/{scaffold → src/init/scaffold}/mcp.json +0 -0
  95. /package/{scaffold → src/init/scaffold}/tsconfig.json +0 -0
  96. /package/{server → src/server}/cache.ts +0 -0
  97. /package/{server → src/server}/proxy.ts +0 -0
  98. /package/{server → src/server}/qr.ts +0 -0
package/src/args.ts DELETED
@@ -1,212 +0,0 @@
1
- import { parseArgs } from "node:util"
2
- import { resolve } from "node:path"
3
- import { clientsRoot } from "./dev-dir"
4
-
5
- // Everything after a bare "--" is the app's argument vector, kept out of
6
- // parseArgs (which would fold it into positionals) and forwarded verbatim to
7
- // the runner, where it becomes flux:process argv. srt's own flags may follow
8
- // the source file, so the separator is required.
9
- let rawArgs = process.argv.slice(2)
10
- let appArgsSep = rawArgs.indexOf("--")
11
- export let appArgs = appArgsSep === -1 ? [] : rawArgs.slice(appArgsSep + 1)
12
-
13
- export let { values, positionals } = parseArgs({
14
- args: appArgsSep === -1 ? rawArgs : rawArgs.slice(0, appArgsSep),
15
- options: {
16
- dev: { type: "boolean", short: "d", default: false },
17
- minify: { type: "boolean", short: "m", default: false },
18
- compile: { type: "boolean", default: false },
19
- flux: { type: "boolean", short: "f", default: false },
20
- session: { type: "string", short: "s" },
21
- folder: { type: "boolean", default: false },
22
- stdout: { type: "boolean", default: false },
23
- output: { type: "string", short: "o" },
24
- "proxy-http": { type: "boolean", default: false },
25
- fps: { type: "string" },
26
- duration: { type: "string" },
27
- size: { type: "string" },
28
- script: { type: "string" },
29
- capture: { type: "string" },
30
- tunnel: { type: "boolean", default: false },
31
- stats: { type: "boolean", default: false },
32
- "data-root": { type: "string" },
33
- client: { type: "string", short: "c" },
34
- server: { type: "string" },
35
- port: { type: "string" },
36
- android: { type: "boolean", default: false },
37
- device: { type: "string" },
38
- with: { type: "string" },
39
- },
40
- allowPositionals: true,
41
- })
42
-
43
- export const DEFAULT_DEV_PORT = 0x8844
44
-
45
- // The session number: -s/--session <N> selects the dev server (port
46
- // DEFAULT_DEV_PORT + N, see dev-server.ts resolveDevPort) and the default
47
- // client slot. Resolved at load, like the port.
48
- function resolveSession(): number {
49
- let raw = values.session
50
- if (raw === undefined) return 0
51
- let n = Number(raw)
52
- if (!/^\d+$/.test(raw) || DEFAULT_DEV_PORT + n > 65535) {
53
- console.error(
54
- `Invalid --session value "${raw}": expected a non-negative integer with ${DEFAULT_DEV_PORT} + N at most 65535`,
55
- )
56
- process.exit(1)
57
- }
58
- return n
59
- }
60
- export let session = resolveSession()
61
-
62
- // Storage flags for a locally spawned client. Dev client trees live in
63
- // ~/.solidrt/clients/client<M>/, reached through --data-root so the client
64
- // runtime keeps its single pref-path default rule (see lattice/src/storage.rs
65
- // and okf/backlog/parallel-dev-servers.md); an explicit --data-root wins. The
66
- // client slot defaults to the session number, so each session gets its own
67
- // tree with a single flag. Roots are passed absolute because the client
68
- // chdirs into its app sandbox at startup.
69
- export function clientStorageArgs(): string[] {
70
- let root = values["data-root"]
71
- let args = ["--data-root", root ? resolve(root) : clientsRoot()]
72
- let client = values.client ?? String(session)
73
- if (!/^\d+$/.test(client)) {
74
- console.error(`Invalid --client value "${client}": expected a non-negative integer`)
75
- process.exit(1)
76
- }
77
- args.push("--client", client)
78
- return args
79
- }
80
-
81
- export let command = positionals[0]
82
- export let source = positionals[1]
83
- export let isTsx = source?.endsWith(".tsx") || source?.endsWith(".jsx")
84
- export let isTs = source?.endsWith(".ts") || source?.endsWith(".js")
85
- export let isSource = isTsx || isTs
86
- export let isPrebuilt = source?.endsWith(".srt.js") || source?.endsWith(".srt.bin")
87
-
88
- function usage(line: string): never {
89
- console.error("Usage: " + line)
90
- process.exit(1)
91
- }
92
-
93
- // Per-command argument requirements. Called once before dispatch.
94
- export function validateArgs() {
95
- switch (command) {
96
- case "bundle":
97
- if (values.flux) {
98
- if (!source || !isTs) usage("srt bundle --flux [options] <entry.[ts|js]>")
99
- } else if (!source || (!isSource && !isPrebuilt)) {
100
- usage("srt bundle [options] <entry.[tsx|jsx|ts|js|srt.js|srt.bin]>")
101
- }
102
- break
103
- case "check":
104
- if (!source || !isSource) usage("srt check <entry.[tsx|jsx|ts|js]>")
105
- break
106
- case "render":
107
- if (!source || !isTsx) usage("srt render <entry.[tsx|jsx]>")
108
- break
109
- case "pack":
110
- if (values.flux) {
111
- if (!source || !isTs) usage("srt pack --flux [options] <entry.[ts|js]>")
112
- } else if (!source || !isSource) {
113
- usage("srt pack [options] <entry.[tsx|jsx|ts|js]>")
114
- }
115
- break
116
- }
117
-
118
- // --android installs/launches the client on a device; it is a client action,
119
- // so it is only valid for `client`.
120
- if (values.android && command !== "client") {
121
- usage("srt client --android (--android is only valid with the client command)")
122
- }
123
- // --server points a standalone client at a dev server; `run` and `server`
124
- // own their server side, so it is only valid for `client`.
125
- if (values.server && command !== "client") {
126
- usage("srt client --server <host[:port]> (--server is only valid with the client command)")
127
- }
128
- // --port moves the dev server off its default port, so it belongs to the
129
- // commands that start one (`run`, `server`) or attach to one (`mcp`). A
130
- // standalone client carries the port in --server <host:port> instead.
131
- if (values.port !== undefined && command !== "run" && command !== "server" && command !== "mcp") {
132
- usage("srt <run|server|mcp> --port <N> (--port is only valid with the run, server and mcp commands)")
133
- }
134
- // --session selects a dev server (and the default client slot), so it is
135
- // valid wherever a dev server is started, attached to, or resolved.
136
- if (
137
- values.session !== undefined &&
138
- command !== "run" &&
139
- command !== "server" &&
140
- command !== "client" &&
141
- command !== "mcp"
142
- ) {
143
- usage("srt <run|server|client|mcp> -s <N> (--session is only valid with the run, server, client and mcp commands)")
144
- }
145
- }
146
-
147
- export function printUsage() {
148
- console.error(`Usage: srt <command> [options] [file]
149
-
150
- Commands:
151
- init <dir> Scaffold a new SolidRT project into a new (empty) folder
152
- run [file] Start dev server + local solidrt-go client
153
- server [file] Start dev server only
154
- client Start solidrt-go client only
155
- bundle <file> Transpile TS/JS/TSX/JSX to JS or bytecode
156
- check <file> Verify the app builds and typechecks, without writing anything
157
- render <file.tsx|jsx> Replay a script (optional) and render frames for video generation
158
- pack <file> Bundle + compile to a standalone executable (experimental)
159
- mcp MCP server (stdio) exposing the running dev server to coding agents
160
-
161
- init options:
162
- --with <pkg,pkg> Extensions to include, e.g. @solidrt/components,@solidrt/3d (skips the picker)
163
-
164
- run/server options:
165
- -s, --session <N> Session number: dev server on port 34884+N, client slot N (default: 0)
166
- --port <N> Dev server port (default: 34884 + session)
167
- --proxy-http Route fetch calls through the dev server (HTTP cache enabled)
168
- --capture <file> Record connected clients' key events to a script file
169
- --tunnel Accept ticket-paired clients through the p2p tunnel
170
- -- <args...> Everything after -- reaches the app on every client (flux:process argv)
171
-
172
- run/client options:
173
- --size <WxH> Window size (default: 1280x720)
174
- --stats Show the debug stats overlay (FPS, memory, frame timings)
175
- --data-root <dir> Client data root (default: ~/.solidrt/clients)
176
- -c, --client <N> Client number: its own data tree under the data root (default: the session)
177
-
178
- client options:
179
- -s, --session <N> Connect to this session's dev server on this machine
180
- (127.0.0.1:34884+N); without it, start on the connect screen
181
- --server <host[:port]> Connect to a dev server at this address (default port: 34884 + session)
182
- --android Install and launch the client on a connected Android device
183
- --device <serial> Target a specific adb device by serial or unique prefix
184
-
185
- mcp options:
186
- -s, --session <N> Attach to the dev server of this session (default: resolve by project)
187
- --port <N> Port of the dev server to attach to (default: resolve by project)
188
-
189
- bundle options:
190
- -f, --flux Bundle for the bare Flux runtime, without SolidJS (entry must be .ts|.js)
191
- -d, --dev Use development build of SolidJS (default: production)
192
- -m, --minify Minify the output
193
- --compile Compile to bytecode
194
- -o, --output <name> Output filename
195
- --stdout Write bundle to stdout
196
-
197
- pack options:
198
- --folder Write the flat app folder (runner + manifest + bundle + assets)
199
- instead of the single-file executable
200
- -f, --flux Pack for the bare Flux runtime instead of SolidRT (entry must be .ts|.js)
201
- -m, --minify Minify the output
202
- -o, --output <name> Output filename
203
-
204
- render options:
205
- --script <file> Script file to replay (default: no scripted input)
206
- --fps <N> Frames per second (default: 60)
207
- --duration <N> Duration in seconds, fractions allowed (default: 1)
208
- --size <WxH> Frame size in physical pixels (default: 1280x720)
209
- -o, --output <path> Where frames land: a directory (frame-NNNNNN.png inside it)
210
- or a path prefix (default: the current directory)
211
- -- <args...> Everything after -- is passed to the app (flux:process argv)`)
212
- }
package/src/bundle-cli.ts DELETED
@@ -1,13 +0,0 @@
1
- // Standalone bundler entry, spawned by the dev server (a flux process) as a
2
- // Bun subprocess to rebuild the app on an MCP-triggered reload. flux cannot call
3
- // Bun.build, so the server shells out to this. Params arrive as one JSON
4
- // argument; one JSON object { code, map, manifest, isolates } goes to stdout
5
- // and diagnostics to stderr. On a build failure it exits non-zero with an
6
- // empty stdout.
7
-
8
- import { bundleWith, type BundleOptions } from "./bundler"
9
-
10
- let params = JSON.parse(process.argv[2] ?? "{}") as BundleOptions
11
- let result = await bundleWith(params)
12
- if (!result) process.exit(1)
13
- process.stdout.write(JSON.stringify(result))
@@ -1,76 +0,0 @@
1
- import { values, source, isPrebuilt } from "../args"
2
- import { bundle, bundleTo, bundleFlux, compileToBytecode } from "../bundler"
3
- import { resolve } from "path"
4
-
5
- // Write to stdout and resolve only once the whole payload is flushed.
6
- // process.stdout.write to a pipe is async and applies backpressure; the
7
- // callback fires after every byte is drained, so it is safe to exit after.
8
- function writeStdout(data: string): Promise<void> {
9
- return new Promise((resolve, reject) => {
10
- process.stdout.write(data, (err) => (err ? reject(err) : resolve()))
11
- })
12
- }
13
-
14
- // Compile JS to a .srt.bin file and report its size.
15
- async function writeBytecode(jsCode: string, outfile: string) {
16
- let bytecode = await compileToBytecode(jsCode)
17
- await Bun.write(outfile, bytecode)
18
- let binSize = (await Bun.file(outfile).stat()).size
19
- console.log(`>> wrote ${binSize} bytes to ${outfile}`)
20
- }
21
-
22
- export async function runBundleCommand() {
23
- if (values.flux) {
24
- let baseName = values.output ?? source!.replace(/\.[jt]s$/, "")
25
- let jsCode = await bundleFlux(source!)
26
-
27
- if (values.stdout) {
28
- await writeStdout(jsCode)
29
- } else if (values.compile) {
30
- await writeBytecode(jsCode, baseName + ".flux.bin")
31
- } else {
32
- let outfile = baseName + ".flux.js"
33
- await Bun.write(outfile, jsCode)
34
- console.log(`>> wrote ${jsCode.length} bytes to ${outfile}`)
35
- }
36
- process.exit()
37
- }
38
-
39
- if (isPrebuilt) {
40
- if (!source!.endsWith(".srt.js")) {
41
- console.error("Can only compile .srt.js files. .srt.bin is already compiled.")
42
- process.exit(1)
43
- }
44
- let jsFile = resolve(source!)
45
- let binOut = jsFile.replace(/\.srt\.js$/, ".srt.bin").replace(/\.js$/, ".bin")
46
- await writeBytecode(await Bun.file(jsFile).text(), binOut)
47
- process.exit()
48
- }
49
-
50
- let baseName = values.output ?? source!.replace(/\.[jt]sx?$/, "")
51
-
52
- if (values.stdout) {
53
- let result = await bundle()
54
- if (!result) {
55
- console.error("Build failed")
56
- process.exit(1)
57
- }
58
- await writeStdout(result.code)
59
- process.exit()
60
- }
61
-
62
- if (values.compile) {
63
- let result = await bundle()
64
- if (!result) {
65
- console.error("Build failed")
66
- process.exit(1)
67
- }
68
- await writeBytecode(result.code, baseName + ".srt.bin")
69
- process.exit()
70
- }
71
-
72
- let jsOutfile = baseName + ".srt.js"
73
- let result = await bundleTo(jsOutfile)
74
- console.log(`>> wrote ${result.code.length} bytes to ${jsOutfile}`)
75
- process.exit()
76
- }
@@ -1,34 +0,0 @@
1
- import { values, clientStorageArgs } from "../args"
2
- import { requireBinary, run } from "../util"
3
- import { spawnAndroidClient } from "../dev-android"
4
- import { DEV_HOST, DEV_PORT } from "../dev-server"
5
-
6
- // Standalone solidrt-go client (no dev server). The `run` command instead uses
7
- // spawnClient() to launch a client tied to the dev-server lifecycle. --server
8
- // auto-connects to a dev server at the given address, and -s <N> is its
9
- // shorthand for the session's server on this machine; without either, the
10
- // client starts on the connect screen. With --android it is installed and
11
- // launched on a connected Android device instead of run locally.
12
- export async function runClientCommand() {
13
- if (values.android) {
14
- await spawnAndroidClient()
15
- return
16
- }
17
-
18
- let runner = requireBinary("solidrt-go")
19
- let args: string[] = [...clientStorageArgs()]
20
- if (values.size) args.push("--size", values.size)
21
- // Both flags resolve to the one address the client understands. --server
22
- // wins: an explicit host is never overridden by a session number, which
23
- // only ever names a loopback port.
24
- let address = values.server
25
- ? values.server.includes(":")
26
- ? values.server
27
- : `${values.server}:${DEV_PORT}`
28
- : values.session !== undefined
29
- ? `${DEV_HOST}:${DEV_PORT}`
30
- : null
31
- if (address) args.push("--dev-server", address)
32
- let exit = await run(runner, args)
33
- process.exit(exit)
34
- }