@solidrt/cli 0.0.51 → 0.0.53

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 (100) 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 +173 -17
  5. package/dist/console.srtapp +73916 -51
  6. package/dist/demos/3d/assets/icon.svg +23 -0
  7. package/dist/demos/3d/package.json +9 -0
  8. package/dist/demos/3d/the-third-dimension/the-third-dimension.srt.js +7528 -0
  9. package/dist/demos/components/assets/icon.png +0 -0
  10. package/dist/demos/components/assets/icon.svg +23 -0
  11. package/dist/demos/components/gallery/gallery.srt.js +14087 -0
  12. package/dist/demos/components/package.json +9 -0
  13. package/dist/server.js +3936 -0
  14. package/package.json +10 -11
  15. package/src/android/docs.md +21 -0
  16. package/src/android/main.ts +286 -0
  17. package/src/{bundler.ts → bundle/bundler.ts} +70 -58
  18. package/src/bundle/docs.md +12 -0
  19. package/src/{commands/bundle.ts → bundle/main.ts} +67 -25
  20. package/src/{untyped-deps.d.ts → bundle/untyped-deps.d.ts} +3 -3
  21. package/src/check/docs.md +10 -0
  22. package/src/check/main.ts +85 -0
  23. package/src/{commands/check.ts → check/typecheck.ts} +11 -41
  24. package/src/client/docs.md +9 -0
  25. package/src/client/main.ts +33 -0
  26. package/src/console/docs.md +14 -0
  27. package/src/console/main.ts +21 -0
  28. package/src/demo/docs.md +33 -0
  29. package/src/demo/main.ts +69 -0
  30. package/src/init/docs.md +11 -0
  31. package/src/{commands/init.ts → init/main.ts} +21 -15
  32. package/src/init/scaffold/AGENTS.md +100 -0
  33. package/src/init/scaffold/package.json +23 -0
  34. package/{scaffold → src/init/scaffold}/templates/components/index.tsx +2 -3
  35. package/{scaffold → src/init/scaffold}/templates/default/index.tsx +2 -3
  36. package/src/lib/args.ts +194 -0
  37. package/src/{artifacts.ts → lib/artifacts.ts} +41 -1
  38. package/src/{dev-dir.ts → lib/dev-dir.ts} +10 -8
  39. package/src/{fonts.ts → lib/fonts.ts} +12 -26
  40. package/src/lib/mode.ts +77 -0
  41. package/src/{project.ts → lib/project.ts} +109 -61
  42. package/src/lib/registry.ts +120 -0
  43. package/src/lib/server-bundle.ts +24 -0
  44. package/src/lib/usage.ts +117 -0
  45. package/src/lib/util.ts +36 -0
  46. package/src/main.ts +109 -31
  47. package/src/mcp/docs.md +22 -0
  48. package/src/mcp/main.ts +719 -0
  49. package/src/pack/docs.md +18 -0
  50. package/src/{pack-folder.ts → pack/layout.ts} +13 -22
  51. package/src/{commands/pack.ts → pack/main.ts} +28 -17
  52. package/src/{packer.ts → pack/trailer.ts} +32 -42
  53. package/src/render/docs.md +19 -0
  54. package/src/{commands/render.ts → render/main.ts} +17 -15
  55. package/src/server/args.ts +126 -0
  56. package/src/server/binaries.ts +47 -0
  57. package/src/server/config.ts +54 -0
  58. package/{server → src/server}/control.ts +239 -81
  59. package/src/server/docs.md +51 -0
  60. package/src/server/line-editor.ts +200 -0
  61. package/src/server/main.ts +476 -0
  62. package/src/server/mode.ts +92 -0
  63. package/src/server/rebuild.ts +90 -0
  64. package/src/server/registry.ts +138 -0
  65. package/src/server/repl.ts +223 -0
  66. package/src/server/state.ts +54 -0
  67. package/{server → src/server}/tsconfig.json +1 -1
  68. package/{server → src/server}/tunnel.ts +6 -6
  69. package/src/server/watcher.ts +121 -0
  70. package/src/tool/main.ts +70 -0
  71. package/src/types/bundle.d.ts +24 -0
  72. package/src/types/control.d.ts +90 -0
  73. package/src/types/registry.d.ts +16 -0
  74. package/scaffold/AGENTS.md +0 -185
  75. package/scaffold/package.json +0 -22
  76. package/scaffold/templates/components/icon.tsx +0 -48
  77. package/scaffold/templates/default/icon.tsx +0 -48
  78. package/server/main.ts +0 -308
  79. package/server/rebuild.ts +0 -76
  80. package/server/state.ts +0 -94
  81. package/src/args.ts +0 -210
  82. package/src/bundle-cli.ts +0 -13
  83. package/src/commands/client.ts +0 -34
  84. package/src/commands/mcp.ts +0 -617
  85. package/src/commands/server.ts +0 -73
  86. package/src/dev-android.ts +0 -176
  87. package/src/dev-client.ts +0 -29
  88. package/src/dev-server.ts +0 -302
  89. package/src/repl.ts +0 -249
  90. package/src/util.ts +0 -122
  91. package/src/watcher.ts +0 -73
  92. /package/src/{prompt.ts → init/prompt.ts} +0 -0
  93. /package/{scaffold → src/init/scaffold}/gitignore +0 -0
  94. /package/{scaffold → src/init/scaffold}/icon.svg +0 -0
  95. /package/{scaffold → src/init/scaffold}/mcp.json +0 -0
  96. /package/{scaffold → src/init/scaffold}/tsconfig.json +0 -0
  97. /package/{server → src/server}/cache.ts +0 -0
  98. /package/{server → src/server}/proxy.ts +0 -0
  99. /package/{server → src/server}/qr.ts +0 -0
  100. /package/{server → src/server}/remap.ts +0 -0
package/src/main.ts CHANGED
@@ -1,15 +1,32 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { values, command, validateArgs, printUsage } from "./args"
4
- import { runInitCommand } from "./commands/init"
5
- import { runBundleCommand } from "./commands/bundle"
6
- import { runCheckCommand } from "./commands/check"
7
- import { runPackCommand } from "./commands/pack"
8
- import { runRenderCommand } from "./commands/render"
9
- import { runServerCommand } from "./commands/server"
10
- import { runClientCommand } from "./commands/client"
11
- import { runMcpCommand } from "./commands/mcp"
12
- import { spawnClient } from "./dev-client"
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
- if (command === "init") {
42
- await runInitCommand()
43
- } else if (command === "bundle") {
44
- await runBundleCommand()
45
- } else if (command === "check") {
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 runServerCommand()
57
- spawnClient()
58
- } else if (command === "mcp") {
59
- await runMcpCommand()
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
- printUsage()
62
- process.exit(1)
63
- }
140
+ hint(command === undefined ? undefined : `Unknown command "${command}"`)
141
+ }
@@ -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).