skybridge 0.0.0-dev.f29d75c → 0.0.0-dev.f2d6084

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 (331) hide show
  1. package/README.md +123 -116
  2. package/dist/cli/build-helpers.d.ts +7 -0
  3. package/dist/cli/build-helpers.js +82 -0
  4. package/dist/cli/build-helpers.js.map +1 -0
  5. package/dist/cli/build-helpers.test.js +64 -0
  6. package/dist/cli/build-helpers.test.js.map +1 -0
  7. package/dist/cli/detect-port.d.ts +18 -0
  8. package/dist/cli/detect-port.js +50 -0
  9. package/dist/cli/detect-port.js.map +1 -0
  10. package/dist/cli/header.js +1 -1
  11. package/dist/cli/header.js.map +1 -1
  12. package/dist/cli/resolve-views-dir.d.ts +1 -0
  13. package/dist/cli/resolve-views-dir.js +17 -0
  14. package/dist/cli/resolve-views-dir.js.map +1 -0
  15. package/dist/cli/run-command.js.map +1 -1
  16. package/dist/cli/telemetry.js.map +1 -1
  17. package/dist/cli/tunnel-control-server.d.ts +9 -0
  18. package/dist/cli/tunnel-control-server.js +31 -0
  19. package/dist/cli/tunnel-control-server.js.map +1 -0
  20. package/dist/cli/tunnel-control-server.test.js +39 -0
  21. package/dist/cli/tunnel-control-server.test.js.map +1 -0
  22. package/dist/cli/tunnel-handler.d.ts +3 -0
  23. package/dist/cli/tunnel-handler.js +48 -0
  24. package/dist/cli/tunnel-handler.js.map +1 -0
  25. package/dist/cli/tunnel-handler.test.d.ts +1 -0
  26. package/dist/cli/tunnel-handler.test.js +105 -0
  27. package/dist/cli/tunnel-handler.test.js.map +1 -0
  28. package/dist/cli/tunnel.d.ts +57 -0
  29. package/dist/cli/tunnel.js +154 -0
  30. package/dist/cli/tunnel.js.map +1 -0
  31. package/dist/cli/tunnel.test.d.ts +1 -0
  32. package/dist/cli/tunnel.test.js +190 -0
  33. package/dist/cli/tunnel.test.js.map +1 -0
  34. package/dist/cli/types.d.ts +5 -0
  35. package/dist/cli/types.js +2 -0
  36. package/dist/cli/types.js.map +1 -0
  37. package/dist/cli/use-execute-steps.js.map +1 -1
  38. package/dist/cli/use-messages.d.ts +3 -0
  39. package/dist/cli/use-messages.js +11 -0
  40. package/dist/cli/use-messages.js.map +1 -0
  41. package/dist/cli/use-nodemon.d.ts +2 -6
  42. package/dist/cli/use-nodemon.js +18 -14
  43. package/dist/cli/use-nodemon.js.map +1 -1
  44. package/dist/cli/use-open-browser.d.ts +1 -0
  45. package/dist/cli/use-open-browser.js +44 -0
  46. package/dist/cli/use-open-browser.js.map +1 -0
  47. package/dist/cli/use-open-tunnel-browser.d.ts +6 -0
  48. package/dist/cli/use-open-tunnel-browser.js +19 -0
  49. package/dist/cli/use-open-tunnel-browser.js.map +1 -0
  50. package/dist/cli/use-tunnel.d.ts +14 -0
  51. package/dist/cli/use-tunnel.js +131 -0
  52. package/dist/cli/use-tunnel.js.map +1 -0
  53. package/dist/cli/use-typescript-check.d.ts +1 -0
  54. package/dist/cli/use-typescript-check.js +42 -7
  55. package/dist/cli/use-typescript-check.js.map +1 -1
  56. package/dist/commands/build.d.ts +0 -1
  57. package/dist/commands/build.js +52 -8
  58. package/dist/commands/build.js.map +1 -1
  59. package/dist/commands/create.d.ts +9 -0
  60. package/dist/commands/create.js +30 -0
  61. package/dist/commands/create.js.map +1 -0
  62. package/dist/commands/dev.d.ts +4 -1
  63. package/dist/commands/dev.js +75 -8
  64. package/dist/commands/dev.js.map +1 -1
  65. package/dist/commands/start.d.ts +3 -1
  66. package/dist/commands/start.js +34 -12
  67. package/dist/commands/start.js.map +1 -1
  68. package/dist/commands/telemetry/disable.js.map +1 -1
  69. package/dist/commands/telemetry/enable.js.map +1 -1
  70. package/dist/commands/telemetry/status.js.map +1 -1
  71. package/dist/server/asset-base-url-transform-plugin.d.ts +6 -6
  72. package/dist/server/asset-base-url-transform-plugin.js +25 -11
  73. package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
  74. package/dist/server/asset-base-url-transform-plugin.test.js +92 -14
  75. package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
  76. package/dist/server/auth.d.ts +20 -0
  77. package/dist/server/auth.js +28 -0
  78. package/dist/server/auth.js.map +1 -0
  79. package/dist/server/build-manifest.test.d.ts +1 -0
  80. package/dist/server/build-manifest.test.js +27 -0
  81. package/dist/server/build-manifest.test.js.map +1 -0
  82. package/dist/server/content-helpers.d.ts +67 -0
  83. package/dist/server/content-helpers.js +79 -0
  84. package/dist/server/content-helpers.js.map +1 -0
  85. package/dist/server/content-helpers.test.d.ts +1 -0
  86. package/dist/server/content-helpers.test.js +70 -0
  87. package/dist/server/content-helpers.test.js.map +1 -0
  88. package/dist/server/express.d.ts +7 -5
  89. package/dist/server/express.js +52 -23
  90. package/dist/server/express.js.map +1 -1
  91. package/dist/server/express.test.js +411 -25
  92. package/dist/server/express.test.js.map +1 -1
  93. package/dist/server/file-ref.d.ts +28 -0
  94. package/dist/server/file-ref.js +27 -0
  95. package/dist/server/file-ref.js.map +1 -0
  96. package/dist/server/index.d.ts +7 -3
  97. package/dist/server/index.js +5 -2
  98. package/dist/server/index.js.map +1 -1
  99. package/dist/server/inferUtilityTypes.d.ts +6 -6
  100. package/dist/server/inferUtilityTypes.js.map +1 -1
  101. package/dist/server/metric.d.ts +14 -0
  102. package/dist/server/metric.js +62 -0
  103. package/dist/server/metric.js.map +1 -0
  104. package/dist/server/middleware.d.ts +137 -0
  105. package/dist/server/middleware.js +93 -0
  106. package/dist/server/middleware.js.map +1 -0
  107. package/dist/server/middleware.test-d.d.ts +1 -0
  108. package/dist/server/middleware.test-d.js +75 -0
  109. package/dist/server/middleware.test-d.js.map +1 -0
  110. package/dist/server/middleware.test.d.ts +1 -0
  111. package/dist/server/middleware.test.js +493 -0
  112. package/dist/server/middleware.test.js.map +1 -0
  113. package/dist/server/server.d.ts +340 -64
  114. package/dist/server/server.js +507 -102
  115. package/dist/server/server.js.map +1 -1
  116. package/dist/server/templateHelper.d.ts +5 -8
  117. package/dist/server/templateHelper.js +3 -22
  118. package/dist/server/templateHelper.js.map +1 -1
  119. package/dist/server/templates.generated.d.ts +4 -0
  120. package/dist/server/templates.generated.js +47 -0
  121. package/dist/server/templates.generated.js.map +1 -0
  122. package/dist/server/tunnel-proxy-router.d.ts +7 -0
  123. package/dist/server/tunnel-proxy-router.js +110 -0
  124. package/dist/server/tunnel-proxy-router.js.map +1 -0
  125. package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
  126. package/dist/server/tunnel-proxy-router.test.js +229 -0
  127. package/dist/server/tunnel-proxy-router.test.js.map +1 -0
  128. package/dist/server/viewsDevServer.d.ts +14 -0
  129. package/dist/server/viewsDevServer.js +45 -0
  130. package/dist/server/viewsDevServer.js.map +1 -0
  131. package/dist/test/utils.d.ts +13 -21
  132. package/dist/test/utils.js +42 -37
  133. package/dist/test/utils.js.map +1 -1
  134. package/dist/test/view.test.d.ts +1 -0
  135. package/dist/test/view.test.js +568 -0
  136. package/dist/test/view.test.js.map +1 -0
  137. package/dist/version.d.ts +1 -0
  138. package/dist/version.js +3 -0
  139. package/dist/version.js.map +1 -0
  140. package/dist/web/bridges/apps-sdk/adaptor.d.ts +14 -7
  141. package/dist/web/bridges/apps-sdk/adaptor.js +66 -29
  142. package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
  143. package/dist/web/bridges/apps-sdk/bridge.d.ts +2 -1
  144. package/dist/web/bridges/apps-sdk/bridge.js +1 -0
  145. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  146. package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
  147. package/dist/web/bridges/apps-sdk/index.js.map +1 -1
  148. package/dist/web/bridges/apps-sdk/types.d.ts +26 -11
  149. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  150. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
  151. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
  152. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  153. package/dist/web/bridges/get-adaptor.d.ts +7 -0
  154. package/dist/web/bridges/get-adaptor.js +7 -0
  155. package/dist/web/bridges/get-adaptor.js.map +1 -1
  156. package/dist/web/bridges/index.js.map +1 -1
  157. package/dist/web/bridges/mcp-app/adaptor.d.ts +26 -9
  158. package/dist/web/bridges/mcp-app/adaptor.js +159 -66
  159. package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
  160. package/dist/web/bridges/mcp-app/bridge.d.ts +16 -31
  161. package/dist/web/bridges/mcp-app/bridge.js +65 -201
  162. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  163. package/dist/web/bridges/mcp-app/index.js.map +1 -1
  164. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  165. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +17 -3
  166. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +14 -2
  167. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  168. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
  169. package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
  170. package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
  171. package/dist/web/bridges/mcp-app/view-tools.test.js +144 -0
  172. package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
  173. package/dist/web/bridges/types.d.ts +120 -14
  174. package/dist/web/bridges/types.js.map +1 -1
  175. package/dist/web/bridges/use-host-context.d.ts +5 -0
  176. package/dist/web/bridges/use-host-context.js +5 -0
  177. package/dist/web/bridges/use-host-context.js.map +1 -1
  178. package/dist/web/components/modal-provider.js +3 -5
  179. package/dist/web/components/modal-provider.js.map +1 -1
  180. package/dist/web/create-store.d.ts +26 -0
  181. package/dist/web/create-store.js +43 -3
  182. package/dist/web/create-store.js.map +1 -1
  183. package/dist/web/create-store.test.js +21 -18
  184. package/dist/web/create-store.test.js.map +1 -1
  185. package/dist/web/data-llm.d.ts +34 -1
  186. package/dist/web/data-llm.js +31 -3
  187. package/dist/web/data-llm.js.map +1 -1
  188. package/dist/web/data-llm.test.js +24 -23
  189. package/dist/web/data-llm.test.js.map +1 -1
  190. package/dist/web/generate-helpers.d.ts +22 -18
  191. package/dist/web/generate-helpers.js +22 -18
  192. package/dist/web/generate-helpers.js.map +1 -1
  193. package/dist/web/generate-helpers.test-d.js +26 -26
  194. package/dist/web/generate-helpers.test-d.js.map +1 -1
  195. package/dist/web/generate-helpers.test.js.map +1 -1
  196. package/dist/web/helpers/state.d.ts +2 -2
  197. package/dist/web/helpers/state.js +11 -11
  198. package/dist/web/helpers/state.js.map +1 -1
  199. package/dist/web/helpers/state.test.js +9 -9
  200. package/dist/web/helpers/state.test.js.map +1 -1
  201. package/dist/web/hooks/index.d.ts +6 -2
  202. package/dist/web/hooks/index.js +5 -1
  203. package/dist/web/hooks/index.js.map +1 -1
  204. package/dist/web/hooks/test/utils.d.ts +6 -2
  205. package/dist/web/hooks/test/utils.js +17 -2
  206. package/dist/web/hooks/test/utils.js.map +1 -1
  207. package/dist/web/hooks/use-call-tool.d.ts +45 -0
  208. package/dist/web/hooks/use-call-tool.js +28 -0
  209. package/dist/web/hooks/use-call-tool.js.map +1 -1
  210. package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
  211. package/dist/web/hooks/use-call-tool.test.js +27 -6
  212. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  213. package/dist/web/hooks/use-display-mode.d.ts +23 -3
  214. package/dist/web/hooks/use-display-mode.js +20 -0
  215. package/dist/web/hooks/use-display-mode.js.map +1 -1
  216. package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
  217. package/dist/web/hooks/use-display-mode.test-d.js +8 -0
  218. package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
  219. package/dist/web/hooks/use-display-mode.test.js.map +1 -1
  220. package/dist/web/hooks/use-download.d.ts +5 -0
  221. package/dist/web/hooks/use-download.js +8 -0
  222. package/dist/web/hooks/use-download.js.map +1 -0
  223. package/dist/web/hooks/use-download.test.d.ts +1 -0
  224. package/dist/web/hooks/use-download.test.js +95 -0
  225. package/dist/web/hooks/use-download.test.js.map +1 -0
  226. package/dist/web/hooks/use-files.d.ts +34 -1
  227. package/dist/web/hooks/use-files.js +33 -0
  228. package/dist/web/hooks/use-files.js.map +1 -1
  229. package/dist/web/hooks/use-files.test.js +22 -2
  230. package/dist/web/hooks/use-files.test.js.map +1 -1
  231. package/dist/web/hooks/use-layout.d.ts +2 -0
  232. package/dist/web/hooks/use-layout.js +2 -0
  233. package/dist/web/hooks/use-layout.js.map +1 -1
  234. package/dist/web/hooks/use-layout.test.js +3 -3
  235. package/dist/web/hooks/use-layout.test.js.map +1 -1
  236. package/dist/web/hooks/use-open-external.d.ts +20 -1
  237. package/dist/web/hooks/use-open-external.js +17 -1
  238. package/dist/web/hooks/use-open-external.js.map +1 -1
  239. package/dist/web/hooks/use-open-external.test.js +26 -11
  240. package/dist/web/hooks/use-open-external.test.js.map +1 -1
  241. package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
  242. package/dist/web/hooks/use-register-view-tool.js +50 -0
  243. package/dist/web/hooks/use-register-view-tool.js.map +1 -0
  244. package/dist/web/hooks/use-request-close.d.ts +16 -0
  245. package/dist/web/hooks/use-request-close.js +21 -0
  246. package/dist/web/hooks/use-request-close.js.map +1 -0
  247. package/dist/web/hooks/use-request-close.test.d.ts +1 -0
  248. package/dist/web/hooks/use-request-close.test.js +52 -0
  249. package/dist/web/hooks/use-request-close.test.js.map +1 -0
  250. package/dist/web/hooks/use-request-modal.d.ts +16 -1
  251. package/dist/web/hooks/use-request-modal.js +19 -4
  252. package/dist/web/hooks/use-request-modal.js.map +1 -1
  253. package/dist/web/hooks/use-request-modal.test.js +5 -1
  254. package/dist/web/hooks/use-request-modal.test.js.map +1 -1
  255. package/dist/web/hooks/use-request-size.d.ts +20 -0
  256. package/dist/web/hooks/use-request-size.js +24 -0
  257. package/dist/web/hooks/use-request-size.js.map +1 -0
  258. package/dist/web/hooks/use-request-size.test.d.ts +1 -0
  259. package/dist/web/hooks/use-request-size.test.js +65 -0
  260. package/dist/web/hooks/use-request-size.test.js.map +1 -0
  261. package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
  262. package/dist/web/hooks/use-send-follow-up-message.js +19 -2
  263. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  264. package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
  265. package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
  266. package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
  267. package/dist/web/hooks/use-set-open-in-app-url.test.js +5 -11
  268. package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
  269. package/dist/web/hooks/use-tool-info.d.ts +33 -0
  270. package/dist/web/hooks/use-tool-info.js +26 -0
  271. package/dist/web/hooks/use-tool-info.js.map +1 -1
  272. package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
  273. package/dist/web/hooks/use-tool-info.test.js +1 -1
  274. package/dist/web/hooks/use-tool-info.test.js.map +1 -1
  275. package/dist/web/hooks/use-user.d.ts +2 -0
  276. package/dist/web/hooks/use-user.js +20 -2
  277. package/dist/web/hooks/use-user.js.map +1 -1
  278. package/dist/web/hooks/use-user.test.js +29 -1
  279. package/dist/web/hooks/use-user.test.js.map +1 -1
  280. package/dist/web/hooks/use-view-state.d.ts +25 -0
  281. package/dist/web/hooks/use-view-state.js +32 -0
  282. package/dist/web/hooks/use-view-state.js.map +1 -0
  283. package/dist/web/hooks/use-view-state.test.d.ts +1 -0
  284. package/dist/web/hooks/use-view-state.test.js +177 -0
  285. package/dist/web/hooks/use-view-state.test.js.map +1 -0
  286. package/dist/web/index.d.ts +1 -2
  287. package/dist/web/index.js +1 -2
  288. package/dist/web/index.js.map +1 -1
  289. package/dist/web/mount-view.d.ts +20 -0
  290. package/dist/web/{mount-widget.js → mount-view.js} +21 -2
  291. package/dist/web/mount-view.js.map +1 -0
  292. package/dist/web/plugin/data-llm.test.js.map +1 -1
  293. package/dist/web/plugin/plugin.d.ts +32 -1
  294. package/dist/web/plugin/plugin.js +161 -18
  295. package/dist/web/plugin/plugin.js.map +1 -1
  296. package/dist/web/plugin/scan-views.d.ts +16 -0
  297. package/dist/web/plugin/scan-views.js +88 -0
  298. package/dist/web/plugin/scan-views.js.map +1 -0
  299. package/dist/web/plugin/scan-views.test.d.ts +1 -0
  300. package/dist/web/plugin/scan-views.test.js +99 -0
  301. package/dist/web/plugin/scan-views.test.js.map +1 -0
  302. package/dist/web/plugin/transform-data-llm.js +1 -1
  303. package/dist/web/plugin/transform-data-llm.js.map +1 -1
  304. package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
  305. package/dist/web/plugin/validate-view.d.ts +1 -0
  306. package/dist/web/plugin/validate-view.js +9 -0
  307. package/dist/web/plugin/validate-view.js.map +1 -0
  308. package/dist/web/plugin/validate-view.test.d.ts +1 -0
  309. package/dist/web/plugin/validate-view.test.js +24 -0
  310. package/dist/web/plugin/validate-view.test.js.map +1 -0
  311. package/dist/web/proxy.js.map +1 -1
  312. package/dist/web/types.d.ts +4 -0
  313. package/dist/web/types.js.map +1 -1
  314. package/package.json +39 -23
  315. package/tsconfig.base.json +5 -0
  316. package/dist/server/templates/development.hbs +0 -67
  317. package/dist/server/templates/production.hbs +0 -6
  318. package/dist/server/widgetsDevServer.d.ts +0 -12
  319. package/dist/server/widgetsDevServer.js +0 -57
  320. package/dist/server/widgetsDevServer.js.map +0 -1
  321. package/dist/test/widget.test.js +0 -261
  322. package/dist/test/widget.test.js.map +0 -1
  323. package/dist/web/hooks/use-widget-state.d.ts +0 -4
  324. package/dist/web/hooks/use-widget-state.js +0 -32
  325. package/dist/web/hooks/use-widget-state.js.map +0 -1
  326. package/dist/web/hooks/use-widget-state.test.js +0 -62
  327. package/dist/web/hooks/use-widget-state.test.js.map +0 -1
  328. package/dist/web/mount-widget.d.ts +0 -1
  329. package/dist/web/mount-widget.js.map +0 -1
  330. /package/dist/{test/widget.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
  331. /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
@@ -2,6 +2,7 @@ type TsError = {
2
2
  file: string;
3
3
  line: number;
4
4
  col: number;
5
+ code: string;
5
6
  message: string;
6
7
  };
7
8
  export declare function useTypeScriptCheck(): Array<TsError>;
@@ -1,6 +1,24 @@
1
- import { spawn } from "node:child_process";
2
1
  import { isAbsolute, relative } from "node:path";
2
+ import spawn from "cross-spawn";
3
3
  import { useEffect, useRef, useState } from "react";
4
+ // TypeScript nests from general to specific — the deepest line is the root cause.
5
+ function extractBestMessage(message, continuationLines) {
6
+ if (!continuationLines.length) {
7
+ return message;
8
+ }
9
+ let maxIndent = 0;
10
+ for (const line of continuationLines) {
11
+ const indent = line.length - line.trimStart().length;
12
+ if (indent > maxIndent) {
13
+ maxIndent = indent;
14
+ }
15
+ }
16
+ const deepest = continuationLines
17
+ .filter((l) => l.length - l.trimStart().length === maxIndent)
18
+ .map((l) => l.trim())
19
+ .filter(Boolean)[0];
20
+ return deepest ?? message;
21
+ }
4
22
  export function useTypeScriptCheck() {
5
23
  const tsProcessRef = useRef(null);
6
24
  const [tsErrors, setTsErrors] = useState([]);
@@ -12,31 +30,48 @@ export function useTypeScriptCheck() {
12
30
  tsProcessRef.current = tsProcess;
13
31
  let outputBuffer = "";
14
32
  let currentErrors = [];
33
+ let pendingError = null;
34
+ let continuationLines = [];
35
+ const flushPending = () => {
36
+ if (!pendingError) {
37
+ return;
38
+ }
39
+ pendingError.message = extractBestMessage(pendingError.message, continuationLines);
40
+ currentErrors.push(pendingError);
41
+ pendingError = null;
42
+ continuationLines = [];
43
+ };
15
44
  const processOutput = (data) => {
16
45
  outputBuffer += data.toString();
17
46
  const lines = outputBuffer.split("\n");
18
- outputBuffer = lines.pop() || ""; // Keep incomplete line in buffer
47
+ outputBuffer = lines.pop() || "";
19
48
  for (const line of lines) {
20
49
  const trimmed = line.trim();
21
- // Parse TypeScript error format: file.ts(10,5): error TS2322: message
22
- // Match pattern: filename(line,col): error code: message
23
50
  const errorMatch = trimmed.match(/^(.+?)\((\d+),(\d+)\):\s+error\s+(TS\d+)?\s*:?\s*(.+)$/);
24
51
  if (errorMatch) {
25
- const [, file, lineStr, colStr, , message] = errorMatch;
52
+ flushPending();
53
+ const [, file, lineStr, colStr, code, message] = errorMatch;
26
54
  if (file && lineStr && colStr && message) {
27
55
  let cleanFile = file.trim();
28
56
  if (isAbsolute(cleanFile)) {
29
57
  cleanFile = relative(process.cwd(), cleanFile);
30
58
  }
31
- currentErrors.push({
59
+ pendingError = {
32
60
  file: cleanFile,
33
61
  line: Number.parseInt(lineStr, 10),
34
62
  col: Number.parseInt(colStr, 10),
63
+ code: code ?? "",
35
64
  message: message.trim(),
36
- });
65
+ };
37
66
  }
67
+ continue;
68
+ }
69
+ if (pendingError && line.startsWith(" ")) {
70
+ continuationLines.push(line);
71
+ continue;
38
72
  }
39
73
  if (trimmed.includes("Found") && trimmed.includes("error")) {
74
+ flushPending();
40
75
  setTsErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);
41
76
  currentErrors = [];
42
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASpD,MAAM,UAAU,kBAAkB;IAChC,MAAM,YAAY,GAAG,MAAM,CAAkC,IAAI,CAAC,CAAC;IACnE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,KAAK,CACrB,KAAK,EACL,CAAC,KAAK,E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AE,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { isAbsolute, relative } from \"node:path\";\nimport spawn from \"cross-spawn\";\nimport { useEffect, useRef, useState } from \"react\";\n\ntype TsError = {\n file: string;\n line: number;\n col: number;\n code: string;\n message: string;\n};\n\n// TypeScript nests from general to specific — the deepest line is the root cause.\nfunction extractBestMessage(\n message: string,\n continuationLines: Array<string>,\n): string {\n if (!continuationLines.length) {\n return message;\n }\n let maxIndent = 0;\n for (const line of continuationLines) {\n const indent = line.length - line.trimStart().length;\n if (indent > maxIndent) {\n maxIndent = indent;\n }\n }\n const deepest = continuationLines\n .filter((l) => l.length - l.trimStart().length === maxIndent)\n .map((l) => l.trim())\n .filter(Boolean)[0];\n return deepest ?? message;\n}\n\nexport function useTypeScriptCheck(): Array<TsError> {\n const tsProcessRef = useRef<ReturnType<typeof spawn> | null>(null);\n const [tsErrors, setTsErrors] = useState<Array<TsError>>([]);\n\n useEffect(() => {\n const tsProcess = spawn(\n \"npx\",\n [\"tsc\", \"--noEmit\", \"--watch\", \"--pretty\", \"false\"],\n {\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n shell: true,\n },\n );\n\n tsProcessRef.current = tsProcess;\n\n let outputBuffer = \"\";\n let currentErrors: Array<TsError> = [];\n let pendingError: TsError | null = null;\n let continuationLines: Array<string> = [];\n\n const flushPending = () => {\n if (!pendingError) {\n return;\n }\n pendingError.message = extractBestMessage(\n pendingError.message,\n continuationLines,\n );\n currentErrors.push(pendingError);\n pendingError = null;\n continuationLines = [];\n };\n\n const processOutput = (data: Buffer) => {\n outputBuffer += data.toString();\n const lines = outputBuffer.split(\"\\n\");\n outputBuffer = lines.pop() || \"\";\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n const errorMatch = trimmed.match(\n /^(.+?)\\((\\d+),(\\d+)\\):\\s+error\\s+(TS\\d+)?\\s*:?\\s*(.+)$/,\n );\n if (errorMatch) {\n flushPending();\n const [, file, lineStr, colStr, code, message] = errorMatch;\n if (file && lineStr && colStr && message) {\n let cleanFile = file.trim();\n if (isAbsolute(cleanFile)) {\n cleanFile = relative(process.cwd(), cleanFile);\n }\n pendingError = {\n file: cleanFile,\n line: Number.parseInt(lineStr, 10),\n col: Number.parseInt(colStr, 10),\n code: code ?? \"\",\n message: message.trim(),\n };\n }\n continue;\n }\n\n if (pendingError && line.startsWith(\" \")) {\n continuationLines.push(line);\n continue;\n }\n\n if (trimmed.includes(\"Found\") && trimmed.includes(\"error\")) {\n flushPending();\n setTsErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);\n currentErrors = [];\n }\n }\n };\n\n if (tsProcess.stdout) {\n tsProcess.stdout.on(\"data\", processOutput);\n }\n if (tsProcess.stderr) {\n tsProcess.stderr.on(\"data\", processOutput);\n }\n\n return () => {\n if (tsProcessRef.current) {\n tsProcessRef.current.kill();\n }\n };\n }, []);\n\n return tsErrors;\n}\n"]}
@@ -4,6 +4,5 @@ export declare const commandSteps: CommandStep[];
4
4
  export default class Build extends Command {
5
5
  static description: string;
6
6
  static examples: string[];
7
- static flags: {};
8
7
  run(): Promise<void>;
9
8
  }
@@ -1,29 +1,73 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cpSync, rmSync } from "node:fs";
2
+ import { rmSync, writeFileSync } from "node:fs";
3
+ import path from "node:path";
3
4
  import { Command } from "@oclif/core";
4
5
  import { Box, render, Text } from "ink";
5
6
  import { useEffect } from "react";
7
+ import { emitEntryWrapper, emitManifestModule, emitVercelBuildOutput, } from "../cli/build-helpers.js";
6
8
  import { Header } from "../cli/header.js";
9
+ import { resolveViewsDir } from "../cli/resolve-views-dir.js";
7
10
  import { useExecuteSteps } from "../cli/use-execute-steps.js";
11
+ import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
8
12
  export const commandSteps = [
9
13
  {
10
- label: "Building widgets",
11
- command: "vite build -c web/vite.config.ts",
14
+ label: "Scanning views",
15
+ run: async () => {
16
+ const root = process.cwd();
17
+ const viewsDir = await resolveViewsDir(root);
18
+ scanAndWriteViewsDts(root, viewsDir);
19
+ },
12
20
  },
13
21
  {
14
22
  label: "Compiling server",
15
23
  run: () => rmSync("dist", { recursive: true, force: true }),
16
- command: "tsc -b",
24
+ command: "tsc -b --force",
17
25
  },
18
26
  {
19
- label: "Copying static assets",
20
- run: () => cpSync("web/dist", "dist/assets", { recursive: true }),
27
+ label: "Building views",
28
+ command: "vite build",
29
+ },
30
+ {
31
+ label: "Emitting manifest module",
32
+ // Inline the Vite manifest as a JS module so the wrapper can `import` it
33
+ // instead of `readFileSync(process.cwd() + ...)` at runtime — required for
34
+ // workerd, where neither cwd nor the assets directory is readable.
35
+ run: () => {
36
+ const root = process.cwd();
37
+ emitManifestModule(path.join(root, "dist", "assets", ".vite", "manifest.json"), path.join(root, "dist", "vite-manifest.js"));
38
+ },
39
+ },
40
+ {
41
+ label: "Emitting entry wrapper",
42
+ // dist/__entry.js primes the Vite manifest via __setBuildManifest, then
43
+ // dynamically imports user code. Deploy targets (Cloudflare, Vercel)
44
+ // bundle from here so the manifest is available at runtime.
45
+ run: () => {
46
+ emitEntryWrapper(path.join(process.cwd(), "dist"));
47
+ },
48
+ },
49
+ {
50
+ label: "Emitting Cloudflare redirects",
51
+ run: () => {
52
+ const root = process.cwd();
53
+ writeFileSync(path.join(root, "dist", "assets", "_redirects"), "/assets/assets/* /assets/:splat 200\n");
54
+ },
55
+ },
56
+ {
57
+ label: "Emitting Cloudflare headers",
58
+ run: () => {
59
+ const root = process.cwd();
60
+ writeFileSync(path.join(root, "dist", "assets", "_headers"), "/assets/*\n Access-Control-Allow-Origin: *\n");
61
+ },
62
+ },
63
+ {
64
+ label: "Emitting Vercel build output",
65
+ run: () => emitVercelBuildOutput(process.cwd()),
21
66
  },
22
67
  ];
23
68
  export default class Build extends Command {
24
- static description = "Build the widgets and MCP server";
69
+ static description = "Build the views and MCP server";
25
70
  static examples = ["skybridge build"];
26
- static flags = {};
27
71
  async run() {
28
72
  const App = () => {
29
73
  const { currentStep, status, error, execute } = useExecuteSteps(commandSteps);
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAoB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC;QACE,KAAK,EAAE,kBAAkB;QACzB,OAAO,EAAE,kCAAkC;KAC5C;IACD;QACE,KAAK,EAAE,kBAAkB;QACzB,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC3D,OAAO,EAAE,QAAQ;KAClB;IACD;QACE,KAAK,EAAE,uBAAuB;QAC9B,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KAClE;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAU,WAAW,GAAG,kCAAkC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/C,MAAM,CAAU,KAAK,GAAG,EAAE,CAAC;IAEpB,KAAK,CAAC,GAAG;QACd,MAAM,GAAG,GAAG,GAAG,EAAE;YACf,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,O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,KAAC,GAAG,KAAG,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { rmSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { Command } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { useEffect } from \"react\";\nimport {\n emitEntryWrapper,\n emitManifestModule,\n emitVercelBuildOutput,\n} from \"../cli/build-helpers.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveViewsDir } from \"../cli/resolve-views-dir.js\";\nimport { type CommandStep, useExecuteSteps } from \"../cli/use-execute-steps.js\";\nimport { scanAndWriteViewsDts } from \"../web/plugin/scan-views.js\";\n\nexport const commandSteps: CommandStep[] = [\n {\n label: \"Scanning views\",\n run: async () => {\n const root = process.cwd();\n const viewsDir = await resolveViewsDir(root);\n scanAndWriteViewsDts(root, viewsDir);\n },\n },\n {\n label: \"Compiling server\",\n run: () => rmSync(\"dist\", { recursive: true, force: true }),\n command: \"tsc -b --force\",\n },\n {\n label: \"Building views\",\n command: \"vite build\",\n },\n {\n label: \"Emitting manifest module\",\n // Inline the Vite manifest as a JS module so the wrapper can `import` it\n // instead of `readFileSync(process.cwd() + ...)` at runtime — required for\n // workerd, where neither cwd nor the assets directory is readable.\n run: () => {\n const root = process.cwd();\n emitManifestModule(\n path.join(root, \"dist\", \"assets\", \".vite\", \"manifest.json\"),\n path.join(root, \"dist\", \"vite-manifest.js\"),\n );\n },\n },\n {\n label: \"Emitting entry wrapper\",\n // dist/__entry.js primes the Vite manifest via __setBuildManifest, then\n // dynamically imports user code. Deploy targets (Cloudflare, Vercel)\n // bundle from here so the manifest is available at runtime.\n run: () => {\n emitEntryWrapper(path.join(process.cwd(), \"dist\"));\n },\n },\n {\n label: \"Emitting Cloudflare redirects\",\n run: () => {\n const root = process.cwd();\n writeFileSync(\n path.join(root, \"dist\", \"assets\", \"_redirects\"),\n \"/assets/assets/* /assets/:splat 200\\n\",\n );\n },\n },\n {\n label: \"Emitting Cloudflare headers\",\n run: () => {\n const root = process.cwd();\n writeFileSync(\n path.join(root, \"dist\", \"assets\", \"_headers\"),\n \"/assets/*\\n Access-Control-Allow-Origin: *\\n\",\n );\n },\n },\n {\n label: \"Emitting Vercel build output\",\n run: () => emitVercelBuildOutput(process.cwd()),\n },\n];\n\nexport default class Build extends Command {\n static override description = \"Build the views and MCP server\";\n static override examples = [\"skybridge build\"];\n\n public async run(): Promise<void> {\n const App = () => {\n const { currentStep, status, error, execute } =\n useExecuteSteps(commandSteps);\n\n useEffect(() => {\n execute();\n }, [execute]);\n\n return (\n <Box flexDirection=\"column\" padding={1}>\n <Header version={this.config.version}>\n <Text color=\"green\"> → building for production…</Text>\n </Header>\n\n {commandSteps.map((step, index) => {\n const isCurrent = index === currentStep && status === \"running\";\n const isCompleted = index < currentStep || status === \"success\";\n const isError = status === \"error\" && index === currentStep;\n\n return (\n <Box key={step.label} marginBottom={0}>\n <Text color={isError ? \"red\" : isCompleted ? \"green\" : \"grey\"}>\n {isError ? \"✗\" : isCompleted ? \"✓\" : isCurrent ? \"⟳\" : \"○\"}{\" \"}\n {step.label}\n </Text>\n </Box>\n );\n })}\n\n {status === \"success\" && (\n <Box marginTop={1}>\n <Text color=\"green\" bold>\n ✓ Build completed successfully!\n </Text>\n </Box>\n )}\n\n {status === \"error\" && error && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ✗ Build failed\n </Text>\n <Box marginTop={1} flexDirection=\"column\">\n {error.split(\"\\n\").map((line) => (\n <Text key={line} color=\"red\">\n {line}\n </Text>\n ))}\n </Box>\n </Box>\n )}\n </Box>\n );\n };\n\n render(<App />, {\n exitOnCtrlC: true,\n patchConsole: false,\n });\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Command, type Command as CommandLoadable, Help } from "@oclif/core";
2
+ export default class Create extends Command {
3
+ static description: string;
4
+ static strict: boolean;
5
+ run(): Promise<void>;
6
+ }
7
+ export declare class SkybridgeHelp extends Help {
8
+ showCommandHelp(command: CommandLoadable.Loadable): Promise<void>;
9
+ }
@@ -0,0 +1,30 @@
1
+ import { Command, Help } from "@oclif/core";
2
+ import spawn from "cross-spawn";
3
+ function passthrough(args) {
4
+ const { status, error } = spawn.sync("npx", ["--yes", "create-skybridge@latest", ...args], { stdio: "inherit" });
5
+ if (error) {
6
+ console.error(error);
7
+ process.exit(1);
8
+ }
9
+ process.exit(status ?? 1);
10
+ }
11
+ export default class Create extends Command {
12
+ static description = "Scaffold a new Skybridge project";
13
+ static strict = false;
14
+ async run() {
15
+ passthrough(this.argv);
16
+ }
17
+ }
18
+ // Registered as `oclif.helpClass` so that `skybridge create --help` forwards
19
+ // to `create-skybridge --help` (single source of truth for the help text)
20
+ // instead of rendering oclif's auto-generated help. All other commands fall
21
+ // through to the default `Help` behaviour.
22
+ export class SkybridgeHelp extends Help {
23
+ async showCommandHelp(command) {
24
+ if (command.id === "create") {
25
+ passthrough(["--help"]);
26
+ }
27
+ return super.showCommandHelp(command);
28
+ }
29
+ }
30
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmC,IAAI,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC,SAAS,WAAW,CAAC,IAAc;IACjC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,CAClC,KAAK,EACL,CAAC,OAAO,EAAE,yBAAyB,EAAE,GAAG,IAAI,CAAC,EAC7C,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC;IACF,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IACzC,MAAM,CAAU,WAAW,GAAG,kCAAkC,CAAC;IACjE,MAAM,CAAU,MAAM,GAAG,KAAK,CAAC;IAExB,KAAK,CAAC,GAAG;QACd,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;;AAGH,6EAA6E;AAC7E,0EAA0E;AAC1E,4EAA4E;AAC5E,2CAA2C;AAC3C,MAAM,OAAO,aAAc,SAAQ,IAAI;IAC5B,KAAK,CAAC,eAAe,CAC5B,OAAiC;QAEjC,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC5B,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import { Command, type Command as CommandLoadable, Help } from \"@oclif/core\";\nimport spawn from \"cross-spawn\";\n\nfunction passthrough(args: string[]): never {\n const { status, error } = spawn.sync(\n \"npx\",\n [\"--yes\", \"create-skybridge@latest\", ...args],\n { stdio: \"inherit\" },\n );\n if (error) {\n console.error(error);\n process.exit(1);\n }\n process.exit(status ?? 1);\n}\n\nexport default class Create extends Command {\n static override description = \"Scaffold a new Skybridge project\";\n static override strict = false;\n\n public async run(): Promise<void> {\n passthrough(this.argv);\n }\n}\n\n// Registered as `oclif.helpClass` so that `skybridge create --help` forwards\n// to `create-skybridge --help` (single source of truth for the help text)\n// instead of rendering oclif's auto-generated help. All other commands fall\n// through to the default `Help` behaviour.\nexport class SkybridgeHelp extends Help {\n override async showCommandHelp(\n command: CommandLoadable.Loadable,\n ): Promise<void> {\n if (command.id === \"create\") {\n passthrough([\"--help\"]);\n }\n return super.showCommandHelp(command);\n }\n}\n"]}
@@ -3,7 +3,10 @@ export default class Dev extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- "use-forwarded-host": import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ tunnel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
10
  };
8
11
  run(): Promise<void>;
9
12
  }
@@ -1,31 +1,98 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Command, Flags } from "@oclif/core";
3
3
  import { Box, render, Text } from "ink";
4
+ import { resolvePort } from "../cli/detect-port.js";
4
5
  import { Header } from "../cli/header.js";
6
+ import { resolveViewsDir } from "../cli/resolve-views-dir.js";
7
+ import { startTunnelControlServer } from "../cli/tunnel-control-server.js";
8
+ import { useMessages } from "../cli/use-messages.js";
5
9
  import { useNodemon } from "../cli/use-nodemon.js";
10
+ import { useOpenBrowser } from "../cli/use-open-browser.js";
11
+ import { useOpenTunnelBrowser } from "../cli/use-open-tunnel-browser.js";
12
+ import { useTunnel } from "../cli/use-tunnel.js";
6
13
  import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
14
+ import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
7
15
  export default class Dev extends Command {
8
16
  static description = "Start development server";
9
17
  static examples = ["skybridge"];
10
18
  static flags = {
11
- "use-forwarded-host": Flags.boolean({
12
- description: "Uses the forwarded host header to construct widget URLs instead of localhost, useful when accessing the dev server through a tunnel (e.g., ngrok)",
19
+ port: Flags.integer({
20
+ char: "p",
21
+ description: "Port to run the server on",
22
+ min: 1,
23
+ }),
24
+ tunnel: Flags.boolean({
25
+ description: "Open an Alpic tunnel for remote testing",
26
+ default: false,
27
+ }),
28
+ open: Flags.boolean({
29
+ description: "Open DevTools in the browser when the server is ready",
30
+ default: process.env.SKYBRIDGE_OPEN !== "false",
31
+ allowNo: true,
32
+ }),
33
+ verbose: Flags.boolean({
34
+ char: "v",
35
+ description: "Show tunnel logs",
36
+ default: false,
13
37
  }),
14
38
  };
15
39
  async run() {
16
40
  const { flags } = await this.parse(Dev);
41
+ // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit
42
+ // --watch`. Vite's plugin config hook writes the same file when nodemon
43
+ // boots the server, but tsc starts in parallel — if .skybridge/ doesn't
44
+ // exist at tsc startup, its watcher never picks up the late-created file
45
+ // and the dev UI reports phantom TS errors forever.
46
+ const root = process.cwd();
47
+ try {
48
+ scanAndWriteViewsDts(root, await resolveViewsDir(root));
49
+ }
50
+ catch {
51
+ // Best-effort: if the scan fails (e.g. broken vite config, duplicate
52
+ // view names) tsc may show phantom errors, but the dev server should
53
+ // still start so the developer can fix the underlying issue.
54
+ }
55
+ const { port, fallback, envWarning } = await resolvePort(flags.port);
56
+ if (envWarning) {
57
+ this.warn(envWarning);
58
+ }
59
+ const { port: controlPort, manager: tunnelManager, close: closeTunnelControl, } = await startTunnelControlServer(() => port);
17
60
  const env = {
18
61
  ...process.env,
19
- ...(flags["use-forwarded-host"]
20
- ? { SKYBRIDGE_USE_FORWARDED_HOST: "true" }
21
- : {}),
62
+ __PORT: String(port),
63
+ __TUNNEL_CONTROL_PORT: String(controlPort),
22
64
  };
23
65
  const App = () => {
24
66
  const tsErrors = useTypeScriptCheck();
25
- const messages = useNodemon(env);
26
- return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { color: "green", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Open DevTools to test your app locally:", " "] }), _jsx(Text, { color: "green", children: "http://localhost:3000/" })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { children: ["MCP server running at:", " "] }), _jsx(Text, { color: "white", bold: true, children: "http://localhost:3000/mcp" })] }), _jsx(Text, { color: "white", underline: true, children: "To test on ChatGPT:" }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "grey", children: "Make your local server accessible with " }), _jsx(Text, { color: "white", bold: true, children: "ngrok http 3000" })] }), _jsx(Box, { marginBottom: 1, children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "grey", children: "Connect to ChatGPT with URL " }), _jsx(Text, { color: "white", bold: true, children: "https://xxxxxx.ngrok-free.app/mcp" })] }) }), _jsx(Box, { children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { children: "Documentation: " }), _jsx(Text, { color: "white", bold: true, children: "https://docs.skybridge.tech/" })] }) }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { children: "If you like Skybridge, please " }), _jsxs(Text, { color: "white", bold: true, children: ["give it a star", " "] }), _jsx(Text, { children: "on GitHub: " }), _jsx(Text, { color: "white", underline: true, children: "https://github.com/alpic-ai/skybridge" }), _jsx(Text, { color: "grey", children: " \uD83D\uDE4F" })] }) }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message, index) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, `${message.type}-${index}-${message.text.slice(0, 20)}`)))] }))] }));
67
+ const [messages, pushMessage] = useMessages();
68
+ useNodemon(env, pushMessage);
69
+ useOpenBrowser(port, flags.open && !flags.tunnel);
70
+ const tunnelState = useTunnel(port, pushMessage, flags.verbose, flags.tunnel);
71
+ useOpenTunnelBrowser(tunnelState, flags.open && flags.tunnel);
72
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDFE0", " "] }), fallback ? (_jsx(Text, { color: "yellow", children: "3000 in use, running on " })) : (_jsx(Text, { children: "Running on " })), _jsx(Text, { color: "green", children: `http://localhost:${port}/mcp` })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test locally with DevTools:", " "] }), _jsx(Text, { color: "green", children: `http://localhost:${port}/` })] }), tunnelState.status === "idle" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Get a public URL and LLM Playground access with " }), _jsx(Text, { color: "cyan", bold: true, children: "--tunnel" }), _jsx(Text, { children: "." })] })), tunnelState.status === "starting" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { color: "yellow", children: tunnelState.message })] })), tunnelState.status === "connected" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Exposed on " }), _jsx(Text, { color: "green", children: `${tunnelState.url}/mcp` })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test with an LLM on Playground:", " "] }), _jsx(Text, { color: "green", children: `${tunnelState.url}/try` })] })] })), tunnelState.status === "error" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsxs(Text, { color: "red", children: ["Cannot open tunnel: ", tunnelState.message] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "red", children: `Try manually: npx alpic tunnel --port ${port}` })] })] })), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83D\uDEDF", " "] }), _jsx(Text, { children: "Need help? Reach us on " }), _jsx(Text, { color: "white", underline: true, children: "https://discord.alpic.ai" })] }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, message.id)))] }))] }));
73
+ };
74
+ // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee
75
+ // alpic gets killed before we exit. If anything ever calls `useInput` or
76
+ // puts stdin into raw mode, also wire an explicit `\x03` keypress to the
77
+ // shutdown function — Ink will otherwise swallow Ctrl-C without ever
78
+ // delivering SIGINT.
79
+ const ink = render(_jsx(App, {}), { exitOnCtrlC: false, patchConsole: true });
80
+ // Synchronous-first shutdown: kill the alpic subprocess up front so we
81
+ // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)
82
+ // exits the process before our async cleanup completes.
83
+ const shutdown = (code) => () => {
84
+ tunnelManager.stop();
85
+ void closeTunnelControl()
86
+ .catch((err) => {
87
+ console.error("Failed to close tunnel control server", err);
88
+ })
89
+ .finally(() => {
90
+ ink.unmount();
91
+ process.exit(code);
92
+ });
27
93
  };
28
- render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: true });
94
+ process.once("SIGINT", shutdown(130));
95
+ process.once("SIGTERM", shutdown(143));
29
96
  }
30
97
  }
31
98
  //# sourceMappingURL=dev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACtC,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAU,KAAK,GAAG;QACtB,oBAAoB,EAAE,KAAK,CAAC,OAAO,CAAC;YAClC,WAAW,EACT,mJAAmJ;SACtJ,CAAC;KACH,CAAC;IAEK,KAAK,CA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AC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC","sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveViewsDir } from \"../cli/resolve-views-dir.js\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { useMessages } from \"../cli/use-messages.js\";\nimport { useNodemon } from \"../cli/use-nodemon.js\";\nimport { useOpenBrowser } from \"../cli/use-open-browser.js\";\nimport { useOpenTunnelBrowser } from \"../cli/use-open-tunnel-browser.js\";\nimport { useTunnel } from \"../cli/use-tunnel.js\";\nimport { useTypeScriptCheck } from \"../cli/use-typescript-check.js\";\nimport { scanAndWriteViewsDts } from \"../web/plugin/scan-views.js\";\n\nexport default class Dev extends Command {\n static override description = \"Start development server\";\n static override examples = [\"skybridge\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n tunnel: Flags.boolean({\n description: \"Open an Alpic tunnel for remote testing\",\n default: false,\n }),\n open: Flags.boolean({\n description: \"Open DevTools in the browser when the server is ready\",\n default: process.env.SKYBRIDGE_OPEN !== \"false\",\n allowNo: true,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Show tunnel logs\",\n default: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Dev);\n\n // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit\n // --watch`. Vite's plugin config hook writes the same file when nodemon\n // boots the server, but tsc starts in parallel — if .skybridge/ doesn't\n // exist at tsc startup, its watcher never picks up the late-created file\n // and the dev UI reports phantom TS errors forever.\n const root = process.cwd();\n try {\n scanAndWriteViewsDts(root, await resolveViewsDir(root));\n } catch {\n // Best-effort: if the scan fails (e.g. broken vite config, duplicate\n // view names) tsc may show phantom errors, but the dev server should\n // still start so the developer can fix the underlying issue.\n }\n\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n const {\n port: controlPort,\n manager: tunnelManager,\n close: closeTunnelControl,\n } = await startTunnelControlServer(() => port);\n\n const env = {\n ...process.env,\n __PORT: String(port),\n __TUNNEL_CONTROL_PORT: String(controlPort),\n };\n\n const App = () => {\n const tsErrors = useTypeScriptCheck();\n const [messages, pushMessage] = useMessages();\n useNodemon(env, pushMessage);\n useOpenBrowser(port, flags.open && !flags.tunnel);\n const tunnelState = useTunnel(\n port,\n pushMessage,\n flags.verbose,\n flags.tunnel,\n );\n useOpenTunnelBrowser(tunnelState, flags.open && flags.tunnel);\n\n return (\n <Box flexDirection=\"column\" padding={1} marginLeft={1}>\n <Header version={this.config.version} />\n\n <Box>\n <Text>🏠{\" \"}</Text>\n {fallback ? (\n <Text color=\"yellow\">3000 in use, running on </Text>\n ) : (\n <Text>Running on </Text>\n )}\n <Text color=\"green\">{`http://localhost:${port}/mcp`}</Text>\n </Box>\n <Box marginBottom={1}>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test locally with DevTools:{\" \"}\n </Text>\n <Text color=\"green\">{`http://localhost:${port}/`}</Text>\n </Box>\n\n {tunnelState.status === \"idle\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Get a public URL and LLM Playground access with </Text>\n <Text color=\"cyan\" bold>\n --tunnel\n </Text>\n <Text>.</Text>\n </Box>\n )}\n {tunnelState.status === \"starting\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"yellow\">{tunnelState.message}</Text>\n </Box>\n )}\n {tunnelState.status === \"connected\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Exposed on </Text>\n <Text color=\"green\">{`${tunnelState.url}/mcp`}</Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test with an LLM on Playground:{\" \"}\n </Text>\n <Text color=\"green\">{`${tunnelState.url}/try`}</Text>\n </Box>\n </Box>\n )}\n {tunnelState.status === \"error\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"red\">\n Cannot open tunnel: {tunnelState.message}\n </Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"red\">{`Try manually: npx alpic tunnel --port ${port}`}</Text>\n </Box>\n </Box>\n )}\n\n <Box>\n <Text>🛟{\" \"}</Text>\n <Text>Need help? Reach us on </Text>\n <Text color=\"white\" underline>\n https://discord.alpic.ai\n </Text>\n </Box>\n\n {tsErrors.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ⚠️ TypeScript errors found:\n </Text>\n {tsErrors.map((error) => (\n <Box\n key={`${error.file}:${error.line}:${error.col}`}\n marginLeft={2}\n flexDirection=\"column\"\n >\n <Box>\n <Text color=\"white\">{error.file}</Text>\n <Text color=\"grey\">\n ({error.line},{error.col}):{\" \"}\n </Text>\n </Box>\n <Box marginLeft={2}>\n <Text color=\"red\">{error.message}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n {messages.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"white\" bold>\n Logs:\n </Text>\n {messages.map((message) => (\n <Box key={message.id} marginLeft={2}>\n {message.type === \"restart\" ? (\n <>\n <Text color=\"green\">✓{\" \"}</Text>\n <Text color=\"white\">{message.text}</Text>\n </>\n ) : message.type === \"error\" ? (\n <Text color=\"red\">{message.text}</Text>\n ) : (\n <Text>{message.text}</Text>\n )}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee\n // alpic gets killed before we exit. If anything ever calls `useInput` or\n // puts stdin into raw mode, also wire an explicit `\\x03` keypress to the\n // shutdown function — Ink will otherwise swallow Ctrl-C without ever\n // delivering SIGINT.\n const ink = render(<App />, { exitOnCtrlC: false, patchConsole: true });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)\n // exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n ink.unmount();\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n }\n}\n"]}
@@ -2,6 +2,8 @@ import { Command } from "@oclif/core";
2
2
  export default class Start extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
- static flags: {};
5
+ static flags: {
6
+ port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ };
6
8
  run(): Promise<void>;
7
9
  }
@@ -1,32 +1,54 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
- import { Command } from "@oclif/core";
3
+ import { Command, Flags } from "@oclif/core";
4
+ import { resolvePort } from "../cli/detect-port.js";
4
5
  import { runCommand } from "../cli/run-command.js";
5
6
  export default class Start extends Command {
6
7
  static description = "Start production server";
7
8
  static examples = ["skybridge start"];
8
- static flags = {};
9
+ static flags = {
10
+ port: Flags.integer({
11
+ char: "p",
12
+ description: "Port to run the server on",
13
+ min: 1,
14
+ }),
15
+ };
9
16
  async run() {
17
+ const { flags } = await this.parse(Start);
18
+ const { port, fallback, envWarning } = await resolvePort(flags.port);
19
+ if (envWarning) {
20
+ this.warn(envWarning);
21
+ }
10
22
  console.clear();
11
- const candidates = [
12
- resolve(process.cwd(), "dist/server/src/index.js"),
13
- resolve(process.cwd(), "dist/index.js"),
14
- ];
15
- const indexPath = candidates.find(existsSync);
16
- if (!indexPath) {
23
+ // `dist/server.js` is the natural entry (the user's `await server.run()`
24
+ // binds the port). Prefer `dist/__entry.js` when present because it
25
+ // primes the Vite manifest first — without it, hashed asset URLs in
26
+ // views won't resolve.
27
+ const entryPath = resolve(process.cwd(), "dist/__entry.js");
28
+ const fallbackPath = resolve(process.cwd(), "dist/server.js");
29
+ const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;
30
+ if (!existsSync(indexPath)) {
17
31
  console.error("❌ Error: No build output found");
18
32
  console.error("");
19
33
  console.error("Please build your project first:");
20
34
  console.error(" skybridge build");
21
35
  console.error("");
22
36
  process.exit(1);
23
- return;
24
37
  }
25
- console.log(`\x1b[36m\x1b[1m⛰ Welcome to Skybridge\x1b[0m \x1b[36mv${this.config.version}\x1b[0m`);
26
- console.log(`Server running at: \x1b[32m\x1b[1mhttp://localhost:3000/mcp\x1b[0m`);
38
+ console.log(`\x1b[36m\x1b[1m⛰ Skybridge\x1b[0m \x1b[36mv${this.config.version}\x1b[0m`);
39
+ if (fallback) {
40
+ console.log(`\x1b[33m3000 in use, running on\x1b[0m \x1b[32mhttp://localhost:${port}/mcp\x1b[0m`);
41
+ }
42
+ else {
43
+ console.log(`Running on \x1b[32mhttp://localhost:${port}/mcp\x1b[0m`);
44
+ }
27
45
  await runCommand(`node ${indexPath}`, {
28
46
  stdio: ["ignore", "inherit", "inherit"],
29
- env: { ...process.env, NODE_ENV: "production" },
47
+ env: {
48
+ ...process.env,
49
+ NODE_ENV: "production",
50
+ __PORT: String(port),
51
+ },
30
52
  });
31
53
  }
32
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,uB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AS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;QAEnE,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAChD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAClD,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CACT,8CAA8C,IAAI,CAAC,MAAM,CAAC,OAAO,SAAS,CAC3E,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CACT,mEAAmE,IAAI,aAAa,CACrF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,aAAa,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,UAAU,CAAC,QAAQ,SAAS,EAAE,EAAE;YACpC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YACvC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,QAAQ,EAAE,YAAY;gBACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { runCommand } from \"../cli/run-command.js\";\n\nexport default class Start extends Command {\n static override description = \"Start production server\";\n static override examples = [\"skybridge start\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Start);\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n console.clear();\n\n // `dist/server.js` is the natural entry (the user's `await server.run()`\n // binds the port). Prefer `dist/__entry.js` when present because it\n // primes the Vite manifest first — without it, hashed asset URLs in\n // views won't resolve.\n const entryPath = resolve(process.cwd(), \"dist/__entry.js\");\n const fallbackPath = resolve(process.cwd(), \"dist/server.js\");\n const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;\n\n if (!existsSync(indexPath)) {\n console.error(\"❌ Error: No build output found\");\n console.error(\"\");\n console.error(\"Please build your project first:\");\n console.error(\" skybridge build\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(\n `\\x1b[36m\\x1b[1m⛰ Skybridge\\x1b[0m \\x1b[36mv${this.config.version}\\x1b[0m`,\n );\n if (fallback) {\n console.log(\n `\\x1b[33m3000 in use, running on\\x1b[0m \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`,\n );\n } else {\n console.log(`Running on \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`);\n }\n\n await runCommand(`node ${indexPath}`, {\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n env: {\n ...process.env,\n NODE_ENV: \"production\",\n __PORT: String(port),\n },\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"disable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/disable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,MAAM,CAAU,WAAW,GAAG,6CAA6C,CAAC;IAErE,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,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,QAAQ,uBAAS,EAC7B,KAAC,IAAI,uCAA4B,EACjC,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,+BAElB,IACH,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yDAAgD,GAC9D,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,gOAKX,GACH,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC","sourcesContent":["import { Command } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { setEnabled } from \"../../cli/telemetry.js\";\n\nexport default class TelemetryDisable extends Command {\n static override description = \"Disable Skybridge telemetry on this machine\";\n\n public async run(): Promise<void> {\n await this.parse(TelemetryDisable);\n setEnabled(false);\n\n const App = () => (\n <Box flexDirection=\"column\" padding={1}>\n <Box>\n <Text color=\"yellow\">✓</Text>\n <Text> Telemetry has been </Text>\n <Text color=\"yellow\" bold>\n disabled\n </Text>\n </Box>\n <Box marginTop={1}>\n <Text color=\"gray\">Config saved to ~/.skybridge/config.json</Text>\n </Box>\n <Box marginTop={1}>\n <Text color=\"gray\">\n Skybridge never collects Personally Identifiable Information (PII).\n If you'd like to help us improve Skybridge by allowing anonymous CLI\n usage data, please reenable telemetry with: skybridge telemetry\n enable\n </Text>\n </Box>\n </Box>\n );\n\n render(<App />);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"enable.js","sourceRoot":"","sources":["../../../src/commands/telemetry/enable.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,MAAM,CAAC,OAAO,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AAI,IAAC,KAAK,EAAC,OAAO,uBAAS,EAC5B,KAAC,IAAI,uCAA4B,EACjC,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,8BAEjB,IACH,EACN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yDAAgD,GAC9D,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC","sourcesContent":["import { Command } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { setEnabled } from \"../../cli/telemetry.js\";\n\nexport default class TelemetryEnable extends Command {\n static override description = \"Enable Skybridge telemetry on this machine\";\n\n public async run(): Promise<void> {\n await this.parse(TelemetryEnable);\n setEnabled(true);\n\n const App = () => (\n <Box flexDirection=\"column\" padding={1}>\n <Box>\n <Text color=\"green\">✓</Text>\n <Text> Telemetry has been </Text>\n <Text color=\"green\" bold>\n enabled\n </Text>\n </Box>\n <Box marginTop={1}>\n <Text color=\"gray\">Config saved to ~/.skybridge/config.json</Text>\n </Box>\n </Box>\n );\n\n render(<App />);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/telemetry/status.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,MAAM,CAAU,WAAW,GACzB,2DAA2D,CAAC;IAEvD,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAE5B,MAAM,GAAG,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D,CAAC;IAEvD,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;QAE5B,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,CAChB,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,KAAC,IAAI,IAAC,IAAI,QAAC,SAAS,0CAEb,EAEP,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,MAAC,GAAG,eACF,KAAC,IAAI,2BAAgB,EACpB,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,8BAEjB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,+BAElB,CACR,IACG,EAEN,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,aACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6BAAoB,EACtC,KAAC,IAAI,cAAE,YAAY,EAAE,GAAQ,IACzB,IACF,EAEN,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,6DAAoD,EACtE,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,uDAA8C,EAChE,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,wDAA+C,IAC7D,IACF,CACP,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,CAAC,CAAC;IAClB,CAAC","sourcesContent":["import { Command } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { getMachineId, isEnabled } from \"../../cli/telemetry.js\";\n\nexport default class TelemetryStatus extends Command {\n static override description =\n \"Get Skybridge current telemetry settings for this machine\";\n\n public async run(): Promise<void> {\n await this.parse(TelemetryStatus);\n const enabled = isEnabled();\n\n const App = () => (\n <Box flexDirection=\"column\" padding={1}>\n <Text bold underline>\n Skybridge Telemetry\n </Text>\n\n <Box marginTop={1} flexDirection=\"column\">\n <Box>\n <Text>Status: </Text>\n {enabled ? (\n <Text color=\"green\" bold>\n Enabled\n </Text>\n ) : (\n <Text color=\"yellow\" bold>\n Disabled\n </Text>\n )}\n </Box>\n\n <Box marginTop={1}>\n <Text color=\"gray\">Machine ID: </Text>\n <Text>{getMachineId()}</Text>\n </Box>\n </Box>\n\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"gray\">To opt out, run: skybridge telemetry disable</Text>\n <Text color=\"gray\">Or set: SKYBRIDGE_TELEMETRY_DISABLED=1</Text>\n <Text color=\"gray\">Debug mode: SKYBRIDGE_TELEMETRY_DEBUG=1</Text>\n </Box>\n </Box>\n );\n\n render(<App />);\n }\n}\n"]}