@solidrt/cli 0.0.51 → 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 (93) hide show
  1. package/AGENTS.md +68 -38
  2. package/README.md +86 -15
  3. package/agents/assets.md +19 -5
  4. package/agents/debugging.md +169 -17
  5. package/dist/console.srtapp +94123 -73
  6. package/dist/server.js +3936 -0
  7. package/package.json +10 -11
  8. package/src/android/docs.md +21 -0
  9. package/src/android/main.ts +286 -0
  10. package/src/{bundler.ts → bundle/bundler.ts} +67 -55
  11. package/src/bundle/docs.md +12 -0
  12. package/src/{commands/bundle.ts → bundle/main.ts} +67 -25
  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 -41
  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} +21 -15
  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/{commands/pack.ts → pack/main.ts} +28 -17
  44. package/src/{packer.ts → pack/trailer.ts} +32 -42
  45. package/src/render/docs.md +19 -0
  46. package/src/{commands/render.ts → render/main.ts} +17 -15
  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 +239 -81
  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/repl.ts +223 -0
  58. package/src/server/state.ts +54 -0
  59. package/{server → src/server}/tsconfig.json +1 -1
  60. package/{server → src/server}/tunnel.ts +6 -6
  61. package/src/server/watcher.ts +121 -0
  62. package/src/tool/main.ts +70 -0
  63. package/src/types/bundle.d.ts +24 -0
  64. package/src/types/control.d.ts +90 -0
  65. package/src/types/registry.d.ts +16 -0
  66. package/scaffold/AGENTS.md +0 -185
  67. package/scaffold/package.json +0 -22
  68. package/scaffold/templates/components/icon.tsx +0 -48
  69. package/scaffold/templates/default/icon.tsx +0 -48
  70. package/server/main.ts +0 -308
  71. package/server/rebuild.ts +0 -76
  72. package/server/state.ts +0 -94
  73. package/src/args.ts +0 -210
  74. package/src/bundle-cli.ts +0 -13
  75. package/src/commands/client.ts +0 -34
  76. package/src/commands/mcp.ts +0 -617
  77. package/src/commands/server.ts +0 -73
  78. package/src/dev-android.ts +0 -176
  79. package/src/dev-client.ts +0 -29
  80. package/src/dev-server.ts +0 -302
  81. package/src/repl.ts +0 -249
  82. package/src/util.ts +0 -122
  83. package/src/watcher.ts +0 -73
  84. /package/src/{untyped-deps.d.ts → bundle/untyped-deps.d.ts} +0 -0
  85. /package/src/{prompt.ts → init/prompt.ts} +0 -0
  86. /package/{scaffold → src/init/scaffold}/gitignore +0 -0
  87. /package/{scaffold → src/init/scaffold}/icon.svg +0 -0
  88. /package/{scaffold → src/init/scaffold}/mcp.json +0 -0
  89. /package/{scaffold → src/init/scaffold}/tsconfig.json +0 -0
  90. /package/{server → src/server}/cache.ts +0 -0
  91. /package/{server → src/server}/proxy.ts +0 -0
  92. /package/{server → src/server}/qr.ts +0 -0
  93. /package/{server → src/server}/remap.ts +0 -0
package/src/args.ts DELETED
@@ -1,210 +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
- },
39
- allowPositionals: true,
40
- })
41
-
42
- export const DEFAULT_DEV_PORT = 0x8844
43
-
44
- // The session number: -s/--session <N> selects the dev server (port
45
- // DEFAULT_DEV_PORT + N, see dev-server.ts resolveDevPort) and the default
46
- // client slot. Resolved at load, like the port.
47
- function resolveSession(): number {
48
- let raw = values.session
49
- if (raw === undefined) return 0
50
- let n = Number(raw)
51
- if (!/^\d+$/.test(raw) || DEFAULT_DEV_PORT + n > 65535) {
52
- console.error(
53
- `Invalid --session value "${raw}": expected a non-negative integer with ${DEFAULT_DEV_PORT} + N at most 65535`,
54
- )
55
- process.exit(1)
56
- }
57
- return n
58
- }
59
- export let session = resolveSession()
60
-
61
- // Storage flags for a locally spawned client. Dev client trees live in
62
- // ~/.solidrt/clients/client<M>/, reached through --data-root so the client
63
- // runtime keeps its single pref-path default rule (see lattice/src/storage.rs
64
- // and okf/backlog/parallel-dev-servers.md); an explicit --data-root wins. The
65
- // client slot defaults to the session number, so each session gets its own
66
- // tree with a single flag. Roots are passed absolute because the client
67
- // chdirs into its app sandbox at startup.
68
- export function clientStorageArgs(): string[] {
69
- let root = values["data-root"]
70
- let args = ["--data-root", root ? resolve(root) : clientsRoot()]
71
- let client = values.client ?? String(session)
72
- if (!/^\d+$/.test(client)) {
73
- console.error(`Invalid --client value "${client}": expected a non-negative integer`)
74
- process.exit(1)
75
- }
76
- args.push("--client", client)
77
- return args
78
- }
79
-
80
- export let command = positionals[0]
81
- export let source = positionals[1]
82
- export let isTsx = source?.endsWith(".tsx") || source?.endsWith(".jsx")
83
- export let isPrebuilt = source?.endsWith(".srt.js") || source?.endsWith(".srt.bin")
84
- // A .srt.js also ends with .js: prebuilt wins, or the server would re-bundle
85
- // a prebuilt bundle as source and skip the prebuilt load path.
86
- export let isTs = (source?.endsWith(".ts") || source?.endsWith(".js")) && !isPrebuilt
87
- export let isSource = isTsx || isTs
88
-
89
- function usage(line: string): never {
90
- console.error("Usage: " + line)
91
- process.exit(1)
92
- }
93
-
94
- // Per-command argument requirements. Called once before dispatch.
95
- export function validateArgs() {
96
- switch (command) {
97
- case "bundle":
98
- if (values.flux) {
99
- if (!source || !isTs) usage("srt bundle --flux [options] <entry.[ts|js]>")
100
- } else if (!source || (!isSource && !isPrebuilt)) {
101
- usage("srt bundle [options] <entry.[tsx|jsx|ts|js|srt.js|srt.bin]>")
102
- }
103
- break
104
- case "check":
105
- if (!source || !isSource) usage("srt check <entry.[tsx|jsx|ts|js]>")
106
- break
107
- case "render":
108
- if (!source || !isTsx) usage("srt render <entry.[tsx|jsx]>")
109
- break
110
- case "pack":
111
- if (values.flux) {
112
- if (!source || !isTs) usage("srt pack --flux [options] <entry.[ts|js]>")
113
- } else if (!source || !isSource) {
114
- usage("srt pack [options] <entry.[tsx|jsx|ts|js]>")
115
- }
116
- break
117
- }
118
-
119
- // --android installs/launches the client on a device; it is a client action,
120
- // so it is only valid for `client`.
121
- if (values.android && command !== "client") {
122
- usage("srt client --android (--android is only valid with the client command)")
123
- }
124
- // --server points a standalone client at a dev server; `run` and `server`
125
- // own their server side, so it is only valid for `client`.
126
- if (values.server && command !== "client") {
127
- usage("srt client --server <host[:port]> (--server is only valid with the client command)")
128
- }
129
- // --port moves the dev server off its default port, so it belongs to the
130
- // commands that start one (`run`, `server`) or attach to one (`mcp`). A
131
- // standalone client carries the port in --server <host:port> instead.
132
- if (values.port !== undefined && command !== "run" && command !== "server" && command !== "mcp") {
133
- usage("srt <run|server|mcp> --port <N> (--port is only valid with the run, server and mcp commands)")
134
- }
135
- // --session selects a dev server (and the default client slot), so it is
136
- // valid wherever a dev server is started, attached to, or resolved.
137
- if (
138
- values.session !== undefined &&
139
- command !== "run" &&
140
- command !== "server" &&
141
- command !== "client" &&
142
- command !== "mcp"
143
- ) {
144
- usage("srt <run|server|client|mcp> -s <N> (--session is only valid with the run, server, client and mcp commands)")
145
- }
146
- }
147
-
148
- export function printUsage() {
149
- console.error(`Usage: srt <command> [options] [file]
150
-
151
- Commands:
152
- init <dir> Scaffold a new SolidRT project into a new (empty) folder
153
- run [file] Start dev server + local solidrt-go client
154
- server [file] Start dev server only
155
- client Start solidrt-go client only
156
- bundle <file> Transpile TS/JS/TSX/JSX to JS or bytecode
157
- check <file> Verify the app builds and typechecks, without writing anything
158
- render <file.tsx|jsx> Replay a script (optional) and render frames for video generation
159
- pack <file> Bundle + compile to a standalone executable (experimental)
160
- mcp MCP server (stdio) exposing the running dev server to coding agents
161
-
162
- run/server options:
163
- -s, --session <N> Session number: dev server on port 34884+N, client slot N (default: 0)
164
- --port <N> Dev server port (default: 34884 + session)
165
- --proxy-http Route fetch calls through the dev server (HTTP cache enabled)
166
- --capture <file> Record connected clients' key events to a script file
167
- --tunnel Accept ticket-paired clients through the p2p tunnel
168
- -- <args...> Everything after -- reaches the app on every client (flux:process argv)
169
-
170
- run/client options:
171
- --size <WxH> Window size (default: 1280x720)
172
- --stats Show the debug stats overlay (FPS, memory, frame timings)
173
- --data-root <dir> Client data root (default: ~/.solidrt/clients)
174
- -c, --client <N> Client number: its own data tree under the data root (default: the session)
175
-
176
- client options:
177
- -s, --session <N> Connect to this session's dev server on this machine
178
- (127.0.0.1:34884+N); without it, start on the connect screen
179
- --server <host[:port]> Connect to a dev server at this address (default port: 34884 + session)
180
- --android Install and launch the client on a connected Android device
181
- --device <serial> Target a specific adb device by serial or unique prefix
182
-
183
- mcp options:
184
- -s, --session <N> Attach to the dev server of this session (default: resolve by project)
185
- --port <N> Port of the dev server to attach to (default: resolve by project)
186
-
187
- bundle options:
188
- -f, --flux Bundle for the bare Flux runtime, without SolidJS (entry must be .ts|.js)
189
- -d, --dev Use development build of SolidJS (default: production)
190
- -m, --minify Minify the output
191
- --compile Compile to bytecode
192
- -o, --output <dir> Output directory (default: <project>/dist/bundle)
193
- --stdout Write bundle to stdout
194
-
195
- pack options:
196
- --folder Write the flat app folder (runner + manifest + bundle + assets)
197
- instead of the single-file executable
198
- -f, --flux Pack for the bare Flux runtime instead of SolidRT (entry must be .ts|.js)
199
- -m, --minify Minify the output
200
- -o, --output <name> Output filename
201
-
202
- render options:
203
- --script <file> Script file to replay (default: no scripted input)
204
- --fps <N> Frames per second (default: 60)
205
- --duration <N> Duration in seconds, fractions allowed (default: 1)
206
- --size <WxH> Frame size in physical pixels (default: 1280x720)
207
- -o, --output <path> Where frames land: a directory (frame-NNNNNN.png inside it)
208
- or a path prefix (default: the current directory)
209
- -- <args...> Everything after -- is passed to the app (flux:process argv)`)
210
- }
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,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
- }