@sixb/cli 0.1.21 → 0.1.23

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 (129) hide show
  1. package/README.md +18 -3
  2. package/dist/commands/api.d.ts.map +1 -1
  3. package/dist/commands/app.d.ts.map +1 -1
  4. package/dist/commands/build.d.ts.map +1 -1
  5. package/dist/commands/check.d.ts.map +1 -1
  6. package/dist/commands/db-migrate.d.ts.map +1 -1
  7. package/dist/commands/deploy.d.ts.map +1 -1
  8. package/dist/commands/desktop.d.ts +15 -0
  9. package/dist/commands/desktop.d.ts.map +1 -0
  10. package/dist/commands/dev-runner.d.ts +4 -0
  11. package/dist/commands/dev-runner.d.ts.map +1 -1
  12. package/dist/commands/dev.d.ts.map +1 -1
  13. package/dist/commands/init.d.ts.map +1 -1
  14. package/dist/commands/lake-check.d.ts.map +1 -1
  15. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  16. package/dist/commands/login.d.ts.map +1 -1
  17. package/dist/commands/logout.d.ts.map +1 -1
  18. package/dist/commands/orchestrator.d.ts.map +1 -1
  19. package/dist/commands/profile.d.ts.map +1 -1
  20. package/dist/commands/rules.d.ts.map +1 -1
  21. package/dist/commands/scheduler.d.ts.map +1 -1
  22. package/dist/commands/service-account.d.ts.map +1 -1
  23. package/dist/commands/status.d.ts.map +1 -1
  24. package/dist/commands/token.d.ts.map +1 -1
  25. package/dist/commands/typegen.d.ts.map +1 -1
  26. package/dist/commands/worker-group.d.ts +2 -0
  27. package/dist/commands/worker-group.d.ts.map +1 -1
  28. package/dist/commands/worker.d.ts +2 -0
  29. package/dist/commands/worker.d.ts.map +1 -1
  30. package/dist/lib/command-line.d.ts +22 -2
  31. package/dist/lib/command-line.d.ts.map +1 -1
  32. package/dist/lib/deploy-release.d.ts +3 -1
  33. package/dist/lib/deploy-release.d.ts.map +1 -1
  34. package/dist/lib/desktop.d.ts +26 -0
  35. package/dist/lib/desktop.d.ts.map +1 -0
  36. package/dist/lib/dev-messages.d.ts +43 -0
  37. package/dist/lib/dev-messages.d.ts.map +1 -0
  38. package/dist/lib/dev-supervisor.d.ts +27 -0
  39. package/dist/lib/dev-supervisor.d.ts.map +1 -1
  40. package/dist/lib/open-url.d.ts +3 -0
  41. package/dist/lib/open-url.d.ts.map +1 -0
  42. package/dist/lib/role-lifecycle.d.ts.map +1 -1
  43. package/dist/lib/runtime.d.ts +2 -0
  44. package/dist/lib/runtime.d.ts.map +1 -1
  45. package/dist/lib/worker-concurrency.d.ts +11 -0
  46. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  47. package/dist/lib/worker-registry.d.ts +2 -0
  48. package/dist/lib/worker-registry.d.ts.map +1 -1
  49. package/dist/ui/deploy-screens.d.ts +48 -0
  50. package/dist/ui/deploy-screens.d.ts.map +1 -0
  51. package/dist/ui/index.d.ts +28 -244
  52. package/dist/ui/index.d.ts.map +1 -1
  53. package/dist/ui/layout.d.ts +65 -0
  54. package/dist/ui/layout.d.ts.map +1 -0
  55. package/dist/ui/live/ansi.d.ts +8 -0
  56. package/dist/ui/live/ansi.d.ts.map +1 -0
  57. package/dist/ui/live/can-run-live.d.ts +6 -0
  58. package/dist/ui/live/can-run-live.d.ts.map +1 -0
  59. package/dist/ui/live/components.d.ts +17 -0
  60. package/dist/ui/live/components.d.ts.map +1 -0
  61. package/dist/ui/live/deploy.d.ts +22 -0
  62. package/dist/ui/live/deploy.d.ts.map +1 -0
  63. package/dist/ui/live/dev.d.ts +47 -0
  64. package/dist/ui/live/dev.d.ts.map +1 -0
  65. package/dist/ui/live/prompt.d.ts +30 -0
  66. package/dist/ui/live/prompt.d.ts.map +1 -0
  67. package/dist/ui/live/session.d.ts +27 -0
  68. package/dist/ui/live/session.d.ts.map +1 -0
  69. package/dist/ui/screens.d.ts +136 -0
  70. package/dist/ui/screens.d.ts.map +1 -0
  71. package/dist/ui/theme.d.ts +58 -0
  72. package/dist/ui/theme.d.ts.map +1 -0
  73. package/package.json +19 -18
  74. package/src/commands/{api.tsx → api.ts} +18 -27
  75. package/src/commands/{app.tsx → app.ts} +14 -18
  76. package/src/commands/build.ts +70 -0
  77. package/src/commands/{check.tsx → check.ts} +27 -18
  78. package/src/commands/db-migrate.ts +32 -0
  79. package/src/commands/{deploy.tsx → deploy.ts} +109 -102
  80. package/src/commands/desktop.ts +71 -0
  81. package/src/commands/{dev-runner.tsx → dev-runner.ts} +67 -33
  82. package/src/commands/{init.tsx → init.ts} +19 -8
  83. package/src/commands/lake-check.ts +36 -0
  84. package/src/commands/{lake-cleanup.tsx → lake-cleanup.ts} +17 -12
  85. package/src/commands/{login.tsx → login.ts} +36 -30
  86. package/src/commands/{logout.tsx → logout.ts} +5 -5
  87. package/src/commands/{orchestrator.tsx → orchestrator.ts} +15 -28
  88. package/src/commands/{profile.tsx → profile.ts} +38 -19
  89. package/src/commands/{rules.tsx → rules.ts} +15 -24
  90. package/src/commands/{scheduler.tsx → scheduler.ts} +14 -27
  91. package/src/commands/{service-account.tsx → service-account.ts} +37 -39
  92. package/src/commands/{status.tsx → status.ts} +8 -8
  93. package/src/commands/{token.tsx → token.ts} +19 -20
  94. package/src/commands/typegen.ts +18 -0
  95. package/src/commands/{worker-group.tsx → worker-group.ts} +40 -29
  96. package/src/commands/{worker.tsx → worker.ts} +30 -22
  97. package/src/index.tsx +22 -1
  98. package/src/lib/command-line.ts +108 -57
  99. package/src/lib/deploy-release.ts +17 -1
  100. package/src/lib/desktop.ts +52 -0
  101. package/src/lib/dev-messages.ts +44 -0
  102. package/src/lib/dev-supervisor.ts +132 -12
  103. package/src/lib/open-url.ts +15 -0
  104. package/src/lib/role-lifecycle.ts +2 -3
  105. package/src/lib/runtime.ts +4 -0
  106. package/src/lib/worker-concurrency.ts +31 -0
  107. package/src/lib/worker-registry.ts +4 -0
  108. package/src/ui/README.md +54 -0
  109. package/src/ui/deploy-screens.ts +360 -0
  110. package/src/ui/index.ts +158 -0
  111. package/src/ui/layout.ts +245 -0
  112. package/src/ui/live/ansi.ts +103 -0
  113. package/src/ui/live/can-run-live.ts +9 -0
  114. package/src/ui/live/components.tsx +81 -0
  115. package/src/ui/live/deploy.tsx +170 -0
  116. package/src/ui/live/dev.tsx +522 -0
  117. package/src/ui/live/prompt.tsx +205 -0
  118. package/src/ui/live/session.ts +103 -0
  119. package/src/ui/screens.ts +490 -0
  120. package/src/ui/theme.ts +122 -0
  121. package/dist/lib/role-view.d.ts +0 -21
  122. package/dist/lib/role-view.d.ts.map +0 -1
  123. package/src/commands/build.tsx +0 -65
  124. package/src/commands/db-migrate.tsx +0 -30
  125. package/src/commands/lake-check.tsx +0 -33
  126. package/src/commands/typegen.tsx +0 -18
  127. package/src/lib/role-view.ts +0 -49
  128. package/src/ui/index.tsx +0 -1398
  129. /package/src/commands/{dev.tsx → dev.ts} +0 -0
@@ -34,18 +34,18 @@ import {
34
34
  workflowPath,
35
35
  } from "../lib/github-ci"
36
36
  import {
37
- DeployAccessView,
38
- DeployChecksView,
39
- DeployCiView,
40
- DeployCompleteView,
41
- type DeployProgressState,
42
- DeployProgressView,
43
- DeployReleaseView,
44
- DeployStatusView,
45
- renderCliError,
46
- renderPersistent,
37
+ cliErrorView,
38
+ deployAccessView,
39
+ deployChecksView,
40
+ deployCiView,
41
+ deployCompleteView,
42
+ deployReleaseView,
43
+ deployStatusView,
44
+ deployStepLine,
47
45
  renderStatic,
46
+ withTask,
48
47
  } from "../ui"
48
+ import { canRunLive } from "../ui/live/can-run-live"
49
49
 
50
50
  export interface DeployOptions {
51
51
  readonly dryRun?: boolean
@@ -61,27 +61,29 @@ export async function runDeploy(options: DeployOptions = {}): Promise<void> {
61
61
  if (options.dryRun) {
62
62
  const release = buildDeployRelease(config, { bunVersion: await resolveBunVersion(cwd) })
63
63
  if (options.json) return writeJson(release)
64
- await renderStatic(
65
- <DeployReleaseView release={release} configPath={relative(cwd, path) || path} />
66
- )
64
+ await renderStatic(deployReleaseView({ release, configPath: relative(cwd, path) || path }))
67
65
  return
68
66
  }
69
67
 
70
- const source = await packSource(cwd, options.ref)
71
- const release = buildDeployRelease(config, { bunVersion: await resolveBunVersion(cwd, source) })
72
-
73
- // Stop before uploading anything when the target already says the deploy cannot work.
74
- const checks = await config.target.check(release, {
75
- name: config.name,
76
- projectPath: source.projectPath,
68
+ const deployStartedAt = Date.now()
69
+ const { source, release, checks } = await withTask("deploy", "Packing source", async (task) => {
70
+ const source = await packSource(cwd, options.ref)
71
+ const release = buildDeployRelease(config, {
72
+ bunVersion: await resolveBunVersion(cwd, source),
73
+ })
74
+ // Stop before uploading anything when the target already says the deploy cannot work.
75
+ task.step(`Checking ${location(config)}`)
76
+ const checks = await config.target.check(release, {
77
+ name: config.name,
78
+ projectPath: source.projectPath,
79
+ })
80
+ return { source, release, checks }
77
81
  })
78
82
  if (checks.some(blocksDeploy)) {
79
- await renderStatic(
80
- <DeployChecksView name={config.name} location={location(config)} checks={checks} />
81
- )
83
+ await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
82
84
  process.exit(1)
83
85
  }
84
- const progress = createProgress(release, {
86
+ const progress = await createProgress(release, {
85
87
  commit: source.commit,
86
88
  ref: source.ref,
87
89
  dirty: source.dirty,
@@ -93,17 +95,20 @@ export async function runDeploy(options: DeployOptions = {}): Promise<void> {
93
95
  report: progress.report,
94
96
  })
95
97
  } catch (error) {
96
- progress.fail()
97
98
  const failed = progress.state.labels[progress.state.current ?? -1]
98
- await renderCliError(error, {
99
- title: failed ? `Deploy failed at "${failed}"` : "Deploy failed",
100
- details: progress.state.output,
101
- })
99
+ await progress.fail(
100
+ cliErrorView(error, {
101
+ title: failed ? `Deploy failed at "${failed}"` : "Deploy failed",
102
+ details: progress.state.output,
103
+ })
104
+ )
102
105
  process.exit(1)
103
106
  }
104
- progress.finish()
105
- await renderStatic(
106
- <DeployCompleteView release={release} commit={source.commit} ref={source.ref} />
107
+ await progress.finish(
108
+ deployCompleteView({
109
+ release,
110
+ seconds: (Date.now() - deployStartedAt) / 1000,
111
+ })
107
112
  )
108
113
  }
109
114
 
@@ -111,15 +116,13 @@ export async function runDeployCheck(options: { readonly json?: boolean; readonl
111
116
  const cwd = options.cwd ?? process.cwd()
112
117
  const { config } = await loadDeployConfig(cwd)
113
118
  const release = buildDeployRelease(config, { bunVersion: await resolveBunVersion(cwd) })
114
- const checks = await config.target.check(release, {
115
- name: config.name,
116
- projectPath: await projectPathOf(cwd),
117
- })
119
+ const projectPath = await projectPathOf(cwd)
120
+ const checks = await withTask("deploy check", `Checking ${location(config)}`, () =>
121
+ config.target.check(release, { name: config.name, projectPath })
122
+ )
118
123
  if (options.json) writeJson(checks)
119
124
  else
120
- await renderStatic(
121
- <DeployChecksView name={config.name} location={location(config)} checks={checks} />
122
- )
125
+ await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
123
126
  if (checks.some(blocksDeploy)) process.exitCode = 1
124
127
  }
125
128
 
@@ -144,9 +147,7 @@ export async function runDeploySetup(options: {
144
147
  })
145
148
  }
146
149
  const checks = await config.target.check(release, context)
147
- await renderStatic(
148
- <DeployChecksView name={config.name} location={location(config)} checks={checks} />
149
- )
150
+ await renderStatic(deployChecksView({ name: config.name, location: location(config), checks }))
150
151
  }
151
152
 
152
153
  export async function runDeployAccess(options: {
@@ -165,16 +166,16 @@ export async function runDeployAccess(options: {
165
166
  if (options.action === "list") {
166
167
  const keys = await access.list(context)
167
168
  if (options.json) return writeJson(keys)
168
- return renderStatic(<DeployAccessView title={`Keys for ${location(config)}`} keys={keys} />)
169
+ return renderStatic(deployAccessView({ title: `Keys for ${location(config)}`, keys }))
169
170
  }
170
171
  if (options.action === "add") {
171
172
  const added: DeployAccessKey[] = []
172
173
  for (const key of await publicKeys(options.value ?? ""))
173
174
  added.push(await access.add(key, context))
174
- return renderStatic(<DeployAccessView title="Authorized" keys={added} />)
175
+ return renderStatic(deployAccessView({ title: "Authorized", keys: added }))
175
176
  }
176
177
  const removed = await access.remove(options.value ?? "", context)
177
- return renderStatic(<DeployAccessView title="Revoked" keys={removed} />)
178
+ return renderStatic(deployAccessView({ title: "Revoked", keys: removed }))
178
179
  }
179
180
 
180
181
  /**
@@ -236,24 +237,23 @@ export async function runDeployCi(options: { readonly branch?: string; readonly
236
237
  }
237
238
 
238
239
  await renderStatic(
239
- <DeployCiView
240
- name={config.name}
241
- repo={repo.name}
242
- environment={CI_ENVIRONMENT}
243
- branch={branch}
244
- credential={credential.description}
245
- secrets={Object.values(secrets)}
246
- retired={retired}
247
- workflow={{
240
+ deployCiView({
241
+ name: config.name,
242
+ repo: repo.name,
243
+ environment: CI_ENVIRONMENT,
244
+ branch,
245
+ credential: credential.description,
246
+ secrets: Object.values(secrets),
247
+ retired,
248
+ workflow: {
248
249
  path,
249
250
  state: existing === null ? "written" : existing === workflow ? "unchanged" : "kept",
250
- }}
251
- token={
251
+ },
252
+ token:
252
253
  privateSubmodules.length > 0 && !(await hasSecret(repo, SUBMODULE_TOKEN_SECRET))
253
254
  ? { name: SUBMODULE_TOKEN_SECRET, submodules: privateSubmodules }
254
- : null
255
- }
256
- />
255
+ : null,
256
+ })
257
257
  )
258
258
  }
259
259
 
@@ -287,10 +287,12 @@ function location(config: DeployConfig): string {
287
287
 
288
288
  export async function runDeployStatus(options: { readonly json?: boolean; readonly cwd?: string }) {
289
289
  const { config } = await loadDeployConfig(options.cwd)
290
- const status = await config.target.status({ name: config.name })
290
+ const status = await withTask("deploy status", `Asking ${config.target.location}`, () =>
291
+ config.target.status({ name: config.name })
292
+ )
291
293
  if (options.json) return writeJson(status)
292
294
  await renderStatic(
293
- <DeployStatusView name={config.name} location={config.target.location} status={status} />
295
+ deployStatusView({ name: config.name, location: config.target.location, status })
294
296
  )
295
297
  }
296
298
 
@@ -324,11 +326,11 @@ export async function runDeployControl(options: {
324
326
  const { config } = await loadDeployConfig(options.cwd)
325
327
  await config.target.control(options.action, options.service, { name: config.name })
326
328
  await renderStatic(
327
- <DeployStatusView
328
- name={config.name}
329
- location={config.target.location}
330
- status={await config.target.status({ name: config.name })}
331
- />
329
+ deployStatusView({
330
+ name: config.name,
331
+ location: config.target.location,
332
+ status: await config.target.status({ name: config.name }),
333
+ })
332
334
  )
333
335
  }
334
336
 
@@ -336,68 +338,73 @@ export async function runDeployControl(options: {
336
338
  * Follows the target's progress: a live view in a terminal, one line per step and output line
337
339
  * elsewhere, so CI logs read top to bottom.
338
340
  */
339
- function createProgress(
341
+ async function createProgress(
340
342
  release: DeployRelease,
341
343
  source: { readonly commit: string; readonly ref: string; readonly dirty: boolean }
342
344
  ) {
343
- const state: { -readonly [Key in keyof DeployProgressState]: DeployProgressState[Key] } = {
344
- name: release.name,
345
- location: `${release.target.kind} ${release.target.location}`,
346
- commit: source.commit,
347
- ref: source.ref,
348
- dirty: source.dirty,
349
- labels: [],
350
- done: 0,
351
- current: null,
352
- output: [],
353
- outcome: "running",
345
+ const location = `${release.target.kind} ${release.target.location}`
346
+ const state = {
347
+ labels: [] as string[],
348
+ current: null as number | null,
349
+ /** The latest output lines of the step running now, kept when it fails. */
350
+ output: [] as string[],
354
351
  }
355
- const live = process.stdout.isTTY && !process.env.CI
356
- const app = live ? renderPersistent(<DeployProgressView state={{ ...state }} />) : null
352
+ const live = canRunLive()
353
+ ? await (await import("../ui/live/deploy")).startLiveDeploy({
354
+ name: release.name,
355
+ location,
356
+ ...source,
357
+ })
358
+ : null
357
359
  const started = new Map<number, number>()
358
- const render = () => app?.rerender(<DeployProgressView state={{ ...state }} />)
360
+ const seconds = (index: number) =>
361
+ ((Date.now() - (started.get(index) ?? Date.now())) / 1000).toFixed(1)
359
362
 
360
363
  if (!live) {
361
- console.log(`Deploying ${release.name} ${source.commit.slice(0, 12)} to ${state.location}`)
364
+ console.log(`Deploying ${release.name} ${source.commit.slice(0, 12)} to ${location}`)
362
365
  if (source.dirty) console.log("Uncommitted changes are not deployed.")
363
366
  }
364
367
 
365
368
  return {
366
369
  state,
367
370
  report(event: DeployEvent) {
368
- if (event.type === "steps") state.labels = [...event.labels]
371
+ if (event.type === "steps") {
372
+ state.labels = [...event.labels]
373
+ live?.steps(state.labels)
374
+ }
369
375
  if (event.type === "step" && event.status === "running") {
370
376
  // A step's output is what explains its failure; earlier steps' would bury it.
371
377
  state.output = []
372
378
  state.current = event.index
373
379
  started.set(event.index, Date.now())
374
- if (!live) console.log(`▸ ${state.labels[event.index]}`)
380
+ if (live) live.running(event.index)
381
+ else console.log(`▸ ${state.labels[event.index]}`)
375
382
  }
376
383
  if (event.type === "step" && event.status === "done") {
377
- state.done = event.index + 1
378
- if (!live) {
379
- const seconds = ((Date.now() - (started.get(event.index) ?? Date.now())) / 1000).toFixed(
380
- 1
381
- )
382
- console.log(`✓ ${state.labels[event.index]} (${seconds}s)`)
383
- }
384
+ if (live) live.done(event.index, seconds(event.index))
385
+ else console.log(deployStepLine(state.labels[event.index] ?? "", seconds(event.index)))
384
386
  }
385
387
  if (event.type === "output") {
386
388
  state.output = [...state.output, event.line].slice(-12)
387
- if (!live) console.log(` ${event.line}`)
389
+ if (live) live.output(event.line)
390
+ else console.log(` ${event.line}`)
388
391
  }
389
- render()
390
392
  },
391
- fail() {
392
- state.outcome = "failed"
393
- render()
394
- app?.unmount()
393
+ /** Ends the progress with the screen that explains how it ended. */
394
+ async fail(report: string) {
395
+ if (live) {
396
+ await live.failed(
397
+ state.current,
398
+ state.current === null ? null : seconds(state.current),
399
+ report
400
+ )
401
+ } else {
402
+ await renderStatic(report)
403
+ }
395
404
  },
396
- finish() {
397
- state.outcome = "done"
398
- state.current = null
399
- render()
400
- app?.unmount()
405
+ async finish(report: string) {
406
+ if (live) await live.finished(report)
407
+ else await renderStatic(report)
401
408
  },
402
409
  }
403
410
  }
@@ -0,0 +1,71 @@
1
+ import { join } from "node:path"
2
+ import { DEPLOY_CONFIG_FILE, loadDeployConfig } from "../lib/deploy-config"
3
+ import { deployPublicOrigins } from "../lib/deploy-release"
4
+ import { loadDesktop } from "../lib/desktop"
5
+ import { SixbCliError } from "../lib/errors"
6
+ import { configuredOrigin } from "../lib/public-origin"
7
+ import { keyValueResultView, renderStatic } from "../ui"
8
+
9
+ export interface DesktopBuildOptions {
10
+ readonly apiPublicOrigin?: string
11
+ readonly appPublicOrigin?: string
12
+ }
13
+
14
+ /** Packages the deployed app as a desktop app for this machine. */
15
+ export async function runDesktopBuild(options: DesktopBuildOptions = {}): Promise<void> {
16
+ const projectRoot = process.cwd()
17
+ const desktop = await loadDesktop(projectRoot)
18
+ const origins = await deployedOrigins(projectRoot, options)
19
+ const built = await desktop.buildDesktopApp({
20
+ projectRoot,
21
+ appUrl: origins.app,
22
+ apiOrigin: origins.api,
23
+ })
24
+
25
+ await renderStatic(
26
+ keyValueResultView({
27
+ title: "Built the desktop app",
28
+ items: [
29
+ { label: "Opens", value: origins.app },
30
+ { label: "Output", value: built.path },
31
+ ],
32
+ message: built.signed
33
+ ? undefined
34
+ : "Unsigned: people who download it are warned before it opens. See @sixb/desktop's README to sign it.",
35
+ })
36
+ )
37
+ }
38
+
39
+ /**
40
+ * Where the desktop app connects, found the way the production roles find their public origins:
41
+ * flags, then `SIXB_APP_PUBLIC_ORIGIN` and `SIXB_API_PUBLIC_ORIGIN`, then the deployment.
42
+ */
43
+ export async function deployedOrigins(
44
+ projectRoot: string,
45
+ options: DesktopBuildOptions
46
+ ): Promise<{ readonly app: string; readonly api: string }> {
47
+ const app = configuredOrigin(
48
+ options.appPublicOrigin,
49
+ "SIXB_APP_PUBLIC_ORIGIN",
50
+ "app public origin"
51
+ )
52
+ const api = configuredOrigin(
53
+ options.apiPublicOrigin,
54
+ "SIXB_API_PUBLIC_ORIGIN",
55
+ "API public origin"
56
+ )
57
+ const deployed =
58
+ (!app || !api) && (await Bun.file(join(projectRoot, DEPLOY_CONFIG_FILE)).exists())
59
+ ? deployPublicOrigins((await loadDeployConfig(projectRoot)).config)
60
+ : {}
61
+
62
+ const origins = { app: app ?? deployed.app, api: api ?? deployed.api }
63
+ if (!origins.app || !origins.api) {
64
+ throw new SixbCliError("[SixbCLI] The desktop app needs to know where the app is deployed.", {
65
+ remediation:
66
+ `Describe the deployment in ${DEPLOY_CONFIG_FILE}, or set SIXB_APP_PUBLIC_ORIGIN and ` +
67
+ "SIXB_API_PUBLIC_ORIGIN.",
68
+ })
69
+ }
70
+ return { app: origins.app, api: origins.api }
71
+ }
@@ -14,12 +14,23 @@ import {
14
14
  resolveBrowserTopology,
15
15
  servedUrl,
16
16
  } from "../lib/browser-topology"
17
+ import {
18
+ DEV_UI_ENV,
19
+ type DevChildMessage,
20
+ type DevReadyView,
21
+ type DevStartupStep,
22
+ } from "../lib/dev-messages"
23
+ import { errorMessage, errorRemediation } from "../lib/errors"
17
24
  import { type LoadedSixbHost, loadSixbFromEntry } from "../lib/loadSixb"
18
25
  import { stopQuietly } from "../lib/role-lifecycle"
19
26
  import { startSixbRuntime, stopSixbProviders } from "../lib/runtime"
20
27
  import { generateProjectTypes } from "../lib/typegen"
21
- import { resolveVectorConcurrency, resolveWorkerConcurrency } from "../lib/worker-concurrency"
22
- import { DevView, LoadingView, renderCliError, renderPersistent } from "../ui"
28
+ import {
29
+ resolveSubagentConcurrency,
30
+ resolveVectorConcurrency,
31
+ resolveWorkerConcurrency,
32
+ } from "../lib/worker-concurrency"
33
+ import { devView, renderCliError, renderStatic, startTask } from "../ui"
23
34
 
24
35
  export interface DevOptions {
25
36
  entry?: string
@@ -32,6 +43,10 @@ export interface DevOptions {
32
43
  agentTurnTimeout?: string
33
44
  concurrency?: readonly string[]
34
45
  vectorConcurrency?: string
46
+ subagentConcurrency?: string
47
+ subagentConcurrencyPerRun?: string
48
+ /** Also open the app in a desktop window. The supervisor does, so the window outlives restarts. */
49
+ desktop?: boolean
35
50
  }
36
51
 
37
52
  export async function runDevRuntime(options: DevOptions = {}) {
@@ -40,11 +55,20 @@ export async function runDevRuntime(options: DevOptions = {}) {
40
55
  const agentTurnTimeoutMs = resolveAgentTurnTimeoutMs(options.agentTurnTimeout)
41
56
  const workerConcurrency = resolveWorkerConcurrency(options.concurrency)
42
57
  const vectorConcurrency = resolveVectorConcurrency(options.vectorConcurrency)
58
+ const subagents = resolveSubagentConcurrency({
59
+ perWorker: options.subagentConcurrency,
60
+ perRun: options.subagentConcurrencyPerRun,
61
+ })
43
62
  const entry = resolve(options.entry ?? "sixb.config.ts")
44
63
 
45
- const app = renderPersistent(
46
- <LoadingView title="Starting sixb" subtitle={entry} status="Loading runtime" />
47
- )
64
+ // Under a supervisor that draws the live footer, this process reports and prints nothing.
65
+ const reportOnly = process.env[DEV_UI_ENV] === "footer"
66
+ const send = (message: DevChildMessage) => process.send?.(message)
67
+ const task = reportOnly ? null : startTask("dev", "Generating types")
68
+ const step = (name: DevStartupStep) => {
69
+ if (reportOnly) send({ type: "status", step: name })
70
+ else task?.step(name)
71
+ }
48
72
 
49
73
  let customAppServer: CustomAppDevServer | null = null
50
74
  let sixb: LoadedSixbHost | null = null
@@ -59,8 +83,10 @@ export async function runDevRuntime(options: DevOptions = {}) {
59
83
  process.on("SIGTERM", requestShutdown)
60
84
 
61
85
  try {
86
+ step("Generating types")
62
87
  await generateProjectTypes({ entry })
63
88
  abort.signal.throwIfAborted()
89
+ step("Loading project")
64
90
  const host: LoadedSixbHost = await loadSixbFromEntry(entry)
65
91
  sixb = host
66
92
  abort.signal.throwIfAborted()
@@ -102,9 +128,7 @@ export async function runDevRuntime(options: DevOptions = {}) {
102
128
  cohostWorkers: true,
103
129
  api: {
104
130
  start: () => {
105
- app.rerender(
106
- <LoadingView title="Starting sixb" subtitle={entry} status="Starting server" />
107
- )
131
+ step("Starting server")
108
132
  return server.start()
109
133
  },
110
134
  stop: () => server.stop(),
@@ -113,48 +137,58 @@ export async function runDevRuntime(options: DevOptions = {}) {
113
137
  agentTurnTimeoutMs,
114
138
  workerConcurrency,
115
139
  vectorConcurrency,
140
+ ...subagents,
116
141
  })
117
142
  abort.signal.throwIfAborted()
118
143
 
119
- app.rerender(<LoadingView title="Starting sixb" subtitle={entry} status="Starting app" />)
144
+ step("Starting app")
120
145
  const devApp = await startDevApp(customApp, { host: topology.host, port: topology.appPort })
121
146
  customAppServer = devApp.server
122
147
  abort.signal.throwIfAborted()
123
148
 
124
- app.rerender(
125
- <DevView
126
- name={sixb.id}
127
- apiUrl={apiUrl(topology)}
128
- apiDocsUrl={apiDocsUrl(topology)}
129
- wsUrl={apiEventsUrl(topology)}
130
- appUrl={customAppServer ? servedUrl(topology) : null}
131
- workers={[
132
- { type: "agent", worker: runtime.agentWorker },
133
- { type: "projection", worker: runtime.projectionWorker },
134
- { type: "pipeline", worker: runtime.pipelineWorker },
135
- { type: "workflow", worker: runtime.workflowWorker },
136
- { type: "sync", worker: runtime.syncWorker },
137
- ].flatMap(({ type, worker }) =>
138
- worker ? [{ type, concurrency: worker.concurrency }] : []
139
- )}
140
- warnings={devApp.warning ? [devApp.warning, ...runtime.warnings] : runtime.warnings}
141
- />
142
- )
149
+ const view: DevReadyView = {
150
+ name: sixb.id,
151
+ apiUrl: apiUrl(topology),
152
+ apiDocsUrl: apiDocsUrl(topology),
153
+ wsUrl: apiEventsUrl(topology),
154
+ appUrl: customAppServer ? servedUrl(topology) : null,
155
+ workers: [
156
+ { type: "agent", worker: runtime.agentWorker },
157
+ { type: "projection", worker: runtime.projectionWorker },
158
+ { type: "pipeline", worker: runtime.pipelineWorker },
159
+ { type: "workflow", worker: runtime.workflowWorker },
160
+ { type: "sync", worker: runtime.syncWorker },
161
+ ].flatMap(({ type, worker }) => (worker ? [{ type, concurrency: worker.concurrency }] : [])),
162
+ warnings: devApp.warning ? [devApp.warning, ...runtime.warnings] : runtime.warnings,
163
+ }
164
+ task?.stop()
165
+ if (!reportOnly) await renderStatic(devView(view))
143
166
 
144
167
  process.env.SIXB_DEV_READY = "1"
145
- process.send?.({ type: "ready", watchesApp: customAppServer?.watchesSources ?? false })
168
+ send({
169
+ type: "ready",
170
+ watchesApp: customAppServer?.watchesSources ?? false,
171
+ app: customAppServer
172
+ ? { url: servedUrl(topology), apiOrigin: topology.apiPublicOrigin }
173
+ : null,
174
+ view,
175
+ })
146
176
 
147
177
  await Promise.race([stopped, runtime.waitForWorkerFailure()])
148
178
  } catch (error) {
149
179
  if (!abort.signal.aborted) {
150
- process.send?.({ type: "startup-error" })
151
- app.unmount()
152
- await renderCliError(error)
180
+ const remediation = errorRemediation(error)
181
+ send({
182
+ type: "startup-error",
183
+ error: { message: errorMessage(error), ...(remediation ? { remediation } : {}) },
184
+ })
185
+ task?.stop()
186
+ if (!reportOnly) await renderCliError(error)
153
187
  process.exitCode = 1
154
188
  }
155
189
  } finally {
156
190
  process.env.SIXB_DEV_READY = ""
157
- app.unmount()
191
+ task?.stop()
158
192
  await stopQuietly(() => customAppServer?.stop() ?? Promise.resolve())
159
193
  await stopQuietly(() => runtime?.stop() ?? Promise.resolve())
160
194
  if (sixb && !runtimeOwnsProviders) await stopSixbProviders(sixb)
@@ -1,20 +1,31 @@
1
1
  import { relative, sep } from "node:path"
2
2
  import { scaffoldProject } from "create-sixb/scaffold"
3
- import { InitView, renderStatic } from "../ui"
3
+ import { initView, renderStatic } from "../ui"
4
+ import { canRunLive } from "../ui/live/can-run-live"
4
5
 
5
6
  export async function runInit(dir?: string): Promise<void> {
6
- const result = await scaffoldProject(dir ?? ".", { allowExisting: true })
7
+ const target = dir ?? (canRunLive() ? await askForDirectory() : ".")
8
+ const result = await scaffoldProject(target, { allowExisting: true })
7
9
 
8
10
  await renderStatic(
9
- <InitView
10
- name={result.name}
11
- targetDir={result.targetDir}
12
- files={result.files}
13
- commands={nextStepsFor(result.targetDir)}
14
- />
11
+ initView({
12
+ name: result.name,
13
+ files: result.files,
14
+ commands: nextStepsFor(result.targetDir),
15
+ })
15
16
  )
16
17
  }
17
18
 
19
+ async function askForDirectory(): Promise<string> {
20
+ const { promptText } = await import("../ui/live/prompt")
21
+ return promptText({
22
+ command: "init",
23
+ label: "Project directory",
24
+ defaultValue: ".",
25
+ hint: "A new folder for the project, or . for this one",
26
+ })
27
+ }
28
+
18
29
  function nextStepsFor(targetDir: string): string[] {
19
30
  const target = relative(process.cwd(), targetDir)
20
31
  const commands: string[] = []
@@ -0,0 +1,36 @@
1
+ import { errorMessage } from "../lib/errors"
2
+ import { loadSixbFromEntry } from "../lib/loadSixb"
3
+ import { resolveRuntimeEntry } from "../lib/production"
4
+ import {
5
+ checkRuntimeLakeDefinitions,
6
+ checkRuntimePipelineMarkings,
7
+ readAppliedMarkingNotices,
8
+ stopSixbProviders,
9
+ } from "../lib/runtime"
10
+ import { lakeCheckView, renderStatic, withTask } from "../ui"
11
+
12
+ export interface LakeCheckOptions {
13
+ entry?: string
14
+ }
15
+
16
+ export async function runLakeCheck(options: LakeCheckOptions = {}) {
17
+ const entry = await resolveRuntimeEntry({ entry: options.entry })
18
+ const sixb = await withTask("lake check", "Loading project", () => loadSixbFromEntry(entry))
19
+
20
+ try {
21
+ const warnings = await withTask("lake check", "Checking datasets", async (task) => {
22
+ await checkRuntimeLakeDefinitions(sixb)
23
+ task.step("Checking markings")
24
+ await checkRuntimePipelineMarkings(sixb)
25
+
26
+ // The code is right; what projections applied before it is a warning until they reproject.
27
+ return readAppliedMarkingNotices(sixb).catch((error: unknown) => [
28
+ `[SixbCLI] Could not read the dataset versions projections applied: ${errorMessage(error)}`,
29
+ ])
30
+ })
31
+
32
+ await renderStatic(lakeCheckView({ projectId: sixb.id, warnings }))
33
+ } finally {
34
+ await stopSixbProviders(sixb)
35
+ }
36
+ }