@sixb/cli 0.2.2 → 0.2.4

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 (73) hide show
  1. package/README.md +25 -22
  2. package/dist/commands/access-token-utils.d.ts.map +1 -1
  3. package/dist/commands/agent.d.ts +5 -0
  4. package/dist/commands/agent.d.ts.map +1 -1
  5. package/dist/commands/api.d.ts.map +1 -1
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/deploy.d.ts.map +1 -1
  8. package/dist/commands/dev-runner.d.ts.map +1 -1
  9. package/dist/commands/env.d.ts +6 -1
  10. package/dist/commands/env.d.ts.map +1 -1
  11. package/dist/commands/lake-cleanup.d.ts +2 -12
  12. package/dist/commands/lake-cleanup.d.ts.map +1 -1
  13. package/dist/commands/lake-rejected.d.ts +10 -0
  14. package/dist/commands/lake-rejected.d.ts.map +1 -0
  15. package/dist/commands/orchestrator.d.ts.map +1 -1
  16. package/dist/commands/scheduler.d.ts +2 -5
  17. package/dist/commands/scheduler.d.ts.map +1 -1
  18. package/dist/commands/worker-group.d.ts.map +1 -1
  19. package/dist/lib/command-line.d.ts +12 -7
  20. package/dist/lib/command-line.d.ts.map +1 -1
  21. package/dist/lib/deploy-release.d.ts +7 -1
  22. package/dist/lib/deploy-release.d.ts.map +1 -1
  23. package/dist/lib/duration.d.ts +3 -0
  24. package/dist/lib/duration.d.ts.map +1 -0
  25. package/dist/lib/loadSixb.d.ts.map +1 -1
  26. package/dist/lib/production-roles.d.ts +0 -4
  27. package/dist/lib/production-roles.d.ts.map +1 -1
  28. package/dist/lib/runtime.d.ts +7 -9
  29. package/dist/lib/runtime.d.ts.map +1 -1
  30. package/dist/lib/worker-concurrency.d.ts.map +1 -1
  31. package/dist/lib/worker-registry.d.ts +4 -1
  32. package/dist/lib/worker-registry.d.ts.map +1 -1
  33. package/dist/runner/local-runner.d.ts +1 -1
  34. package/dist/tui/app.d.ts.map +1 -1
  35. package/dist/tui/format.d.ts +20 -0
  36. package/dist/tui/format.d.ts.map +1 -1
  37. package/dist/tui/transcript.d.ts.map +1 -1
  38. package/dist/ui/deploy-screens.d.ts +4 -2
  39. package/dist/ui/deploy-screens.d.ts.map +1 -1
  40. package/dist/ui/env-screens.d.ts +14 -1
  41. package/dist/ui/env-screens.d.ts.map +1 -1
  42. package/dist/ui/screens.d.ts +5 -11
  43. package/dist/ui/screens.d.ts.map +1 -1
  44. package/package.json +20 -16
  45. package/src/commands/access-token-utils.ts +2 -20
  46. package/src/commands/agent.ts +54 -8
  47. package/src/commands/api.ts +7 -0
  48. package/src/commands/check.ts +75 -1
  49. package/src/commands/deploy.ts +15 -3
  50. package/src/commands/dev-runner.ts +5 -0
  51. package/src/commands/env.ts +99 -20
  52. package/src/commands/lake-cleanup.ts +25 -48
  53. package/src/commands/lake-rejected.ts +36 -0
  54. package/src/commands/orchestrator.ts +2 -7
  55. package/src/commands/scheduler.ts +11 -61
  56. package/src/commands/worker-group.ts +6 -3
  57. package/src/index.tsx +10 -4
  58. package/src/lib/command-line.ts +25 -12
  59. package/src/lib/deploy-release.ts +42 -2
  60. package/src/lib/duration.ts +11 -0
  61. package/src/lib/loadSixb.ts +3 -4
  62. package/src/lib/production-roles.ts +0 -1
  63. package/src/lib/runtime.ts +62 -43
  64. package/src/lib/shareable-providers.ts +2 -2
  65. package/src/lib/worker-concurrency.ts +1 -0
  66. package/src/lib/worker-registry.ts +36 -1
  67. package/src/runner/local-runner.ts +1 -1
  68. package/src/tui/app.tsx +2 -1
  69. package/src/tui/format.ts +190 -3
  70. package/src/tui/transcript.tsx +8 -1
  71. package/src/ui/deploy-screens.ts +8 -1
  72. package/src/ui/env-screens.ts +39 -5
  73. package/src/ui/screens.ts +21 -20
@@ -387,7 +387,7 @@ function ToolRow({
387
387
  {line.preview?.map((row, index) => (
388
388
  <text key={`${index}-${row.slice(0, 12)}`}>
389
389
  <span fg={colors.faint}>{index === 0 ? " ⎿ " : " "}</span>
390
- <span fg={colors.faint}>{oneLine(row, room)}</span>
390
+ <span fg={line.diff ? diffColor(colors, row) : colors.faint}>{oneLine(row, room)}</span>
391
391
  </text>
392
392
  ))}
393
393
  </box>
@@ -455,6 +455,13 @@ function CommandPanel({
455
455
 
456
456
  const COMMAND_LINES = 3
457
457
 
458
+ /** A diff row's color: added green, removed red, anything else faint. */
459
+ function diffColor(colors: TuiColors, row: string): string {
460
+ if (row.startsWith("+")) return colors.green
461
+ if (row.startsWith("-")) return colors.red
462
+ return colors.faint
463
+ }
464
+
458
465
  /** Under a turn's answer: where it ran, on which model, and how long it took. */
459
466
  function RunMeta({
460
467
  colors,
@@ -20,15 +20,18 @@ import {
20
20
  section,
21
21
  stack,
22
22
  table,
23
+ warnings as warningLines,
23
24
  } from "./layout"
24
25
  import { glyph, tone } from "./theme"
25
26
 
26
27
  export function deployReleaseView({
27
28
  release,
28
29
  configPath,
30
+ warnings = [],
29
31
  }: {
30
32
  release: DeployRelease
31
33
  configPath: string
34
+ warnings?: readonly string[]
32
35
  }): string {
33
36
  const steps = [
34
37
  ...(release.steps.env ? [{ label: "env", commands: [release.steps.env] }] : []),
@@ -93,6 +96,7 @@ export function deployReleaseView({
93
96
  origins.size > 0 ? tone.muted("plus the public origins above") : null
94
97
  )
95
98
  ),
99
+ warningLines(warnings),
96
100
  headline("idle", "Nothing was deployed", "--json prints the full release")
97
101
  )
98
102
  }
@@ -107,11 +111,13 @@ export function deployCompleteView({
107
111
  release,
108
112
  seconds,
109
113
  keptEnv = false,
114
+ warnings = [],
110
115
  }: {
111
116
  release: DeployRelease
112
117
  seconds?: number
113
118
  /** The deploy couldn't update the server's `.env`, so this release runs on its current values. */
114
119
  keptEnv?: boolean
120
+ warnings?: readonly string[]
115
121
  }): string {
116
122
  const urls = release.services.flatMap((service) =>
117
123
  service.http ? [{ label: service.name, value: service.http.publicOrigin }] : []
@@ -129,7 +135,8 @@ export function deployCompleteView({
129
135
  "This release runs on the server's current .env, not on the latest values. Deploy again to update them.",
130
136
  tone.muted
131
137
  )
132
- : null
138
+ : null,
139
+ warningLines(warnings)
133
140
  )
134
141
  }
135
142
 
@@ -27,15 +27,49 @@ export function envSetView(input: {
27
27
  )
28
28
  }
29
29
 
30
+ /** What `init` did with `sixb.env.ts`: wrote names into it, left it to the author, or had none to add. */
31
+ export type EnvInitConfig =
32
+ | { readonly kind: "written"; readonly names: number }
33
+ | { readonly kind: "paste"; readonly names: number; readonly lines: readonly string[] }
34
+ | { readonly kind: "unchanged" }
35
+
30
36
  export function envInitView(input: {
31
- readonly uploaded: readonly { readonly env: EnvName; readonly count: number }[]
32
- readonly names: number
37
+ /** Per environment: how many values were sent, and how many it had already. */
38
+ readonly uploaded: readonly {
39
+ readonly env: EnvName
40
+ readonly count: number
41
+ readonly already: number
42
+ }[]
43
+ readonly config: EnvInitConfig
33
44
  }): string {
34
- const uploaded = input.uploaded.map(({ env, count }) => `${plural(count, "variable")} to ${env}`)
45
+ const sent = input.uploaded.filter(({ count }) => count > 0)
46
+ const had = input.uploaded.filter(({ already }) => already > 0)
47
+ const { config } = input
35
48
  return screen(
36
49
  stack(
37
- headline("ok", `Uploaded ${uploaded.join(" and ")}`),
38
- headline("ok", `Wrote sixb.env.ts with ${plural(input.names, "name")}`)
50
+ sent.length > 0
51
+ ? headline(
52
+ "ok",
53
+ `Uploaded ${sent.map(({ env, count }) => `${plural(count, "variable")} to ${env}`).join(" and ")}`
54
+ )
55
+ : headline("ok", "Nothing to upload"),
56
+ had.length > 0
57
+ ? tone.muted(
58
+ `Already there: ${had.map(({ env, already }) => `${already} in ${env}`).join(", ")}`
59
+ )
60
+ : null,
61
+ config.kind === "written"
62
+ ? headline("ok", `Wrote sixb.env.ts with ${plural(config.names, "name")}`)
63
+ : null,
64
+ config.kind === "paste"
65
+ ? stack(
66
+ headline("warn", `Add ${plural(config.names, "name")} to \`vars\` in sixb.env.ts`),
67
+ tone.muted(
68
+ "It isn't an empty `vars: {}`, so it was left alone. A first guess at each:"
69
+ ),
70
+ config.lines.join("\n")
71
+ )
72
+ : null
39
73
  )
40
74
  )
41
75
  }
package/src/ui/screens.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { LakeRetentionReport } from "@sixb/core/lake-storage"
1
2
  import {
2
3
  CLI_EXAMPLES,
3
4
  type CliHelp,
@@ -430,39 +431,39 @@ export function lakeCheckView({
430
431
  return screen(headline("ok", "Lake definitions compatible", projectId), warningLines(warnings))
431
432
  }
432
433
 
433
- export interface LakeCleanupReport {
434
- readonly dryRun: boolean
435
- readonly expireOlderThan: string
436
- readonly deleteOlderThan: string
437
- readonly snapshots: number
438
- readonly keptSnapshots?: number
439
- readonly oldFiles: number
440
- readonly orphanedFiles: number
441
- }
442
-
443
434
  export function lakeCleanupView({
444
435
  projectId,
436
+ keepVersionsFor,
437
+ deleteFilesAfter,
445
438
  report,
446
439
  }: {
447
440
  projectId: string
448
- report: LakeCleanupReport
441
+ keepVersionsFor: string
442
+ deleteFilesAfter: string
443
+ report: LakeRetentionReport
449
444
  }): string {
445
+ // A dry run measures one pass: when more remain, what the run would clean is more than it counts.
446
+ const measuredOnePass = report.dryRun && report.hasMore
447
+ const atLeast = (count: number) => (measuredOnePass ? `${count}+` : String(count))
448
+
450
449
  return screen(
451
450
  header(report.dryRun ? "lake cleanup --dry-run" : "lake cleanup", projectId),
452
451
  rows([
453
- { label: "Expire older than", value: report.expireOlderThan },
454
- { label: "Delete older than", value: report.deleteOlderThan },
455
- { label: "Snapshots", value: String(report.snapshots) },
456
- ...(report.keptSnapshots === undefined
457
- ? []
458
- : [{ label: "Kept snapshots", value: String(report.keptSnapshots) }]),
459
- { label: "Old files", value: String(report.oldFiles) },
460
- { label: "Orphaned files", value: String(report.orphanedFiles) },
452
+ { label: "Keep versions for", value: keepVersionsFor },
453
+ { label: "Delete files after", value: deleteFilesAfter },
454
+ { label: "Expired versions", value: atLeast(report.expiredVersions) },
455
+ { label: "Kept versions", value: String(report.keptVersions) },
456
+ { label: "Deleted files", value: atLeast(report.deletedFiles) },
457
+ { label: "Orphaned files", value: atLeast(report.orphanedFiles) },
461
458
  ]),
462
459
  headline(
463
460
  "ok",
464
461
  report.dryRun ? "Lake cleanup dry run complete" : "Lake cleanup complete",
465
- report.dryRun ? "nothing was deleted" : undefined
462
+ report.dryRun
463
+ ? measuredOnePass
464
+ ? "nothing was deleted; one pass measured, more remain"
465
+ : "nothing was deleted"
466
+ : undefined
466
467
  )
467
468
  )
468
469
  }