sodabase 0.1.4 → 0.1.7

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.
package/README.md CHANGED
@@ -1,11 +1,7 @@
1
- # sodabase (v2 CLI)
1
+ # sodabase
2
2
 
3
- The `npx sodabase` interactive onboarding wizard — the real, shippable package.
4
- Design: `docs/specs/v2-cli-onboarding-spec.md` (planning repo). Proven first as the
5
- zero-dep spike in that repo's `scripts/cli-wizard-spike/`; this is the Ink/TS port.
6
-
7
- > **Status: scaffold.** Toolchain + API client + token store are in; the flow screens
8
- > are being built on top. Lands behind the spec's §9 gates; **not published** (`private: true`).
3
+ The `npx sodabase` interactive onboarding wizard — a fullscreen Ink/TypeScript CLI that
4
+ connects a Supabase project and sets up read-only data-quality monitoring.
9
5
 
10
6
  ## Stack
11
7
 
@@ -12,6 +12,21 @@ export const MCP_URL = "https://sodabase.io/mcp";
12
12
  export const SKILL_REF = "sodabase/agent-skills";
13
13
  /** An error thrown when `connect()`'s poll is aborted (the user left the connect screen). */
14
14
  const abortedError = () => new ApiError("connect aborted", 499, "aborted");
15
+ /** Pull the `email` claim out of a GoTrue JWT without verifying it (display only — the server already
16
+ * authenticated the token). Best-effort: any malformed part just yields undefined. */
17
+ function emailFromJwt(jwt) {
18
+ try {
19
+ const payload = jwt.split(".")[1];
20
+ if (!payload)
21
+ return undefined;
22
+ const json = Buffer.from(payload.replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8");
23
+ const claims = JSON.parse(json);
24
+ return typeof claims.email === "string" && claims.email ? claims.email : undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
15
30
  /** Resolve after `ms`, or reject immediately if `signal` aborts (so leaving the screen doesn't wait).
16
31
  * The abort listener is removed when the timer wins — otherwise connect()'s per-poll calls would pile
17
32
  * up listeners on the same signal and trip Node's MaxListenersExceededWarning (which corrupts the TUI). */
@@ -53,11 +68,18 @@ export class SodabaseClient {
53
68
  this.bearer = token;
54
69
  }
55
70
  // ── Leg 1: GoTrue sign-in (loopback PKCE → aud="authenticated" session) ──────
56
- async signIn(provider) {
71
+ async signIn(provider, onUrl) {
57
72
  // Matches the web app's @supabase/ssr PKCE flow, driven from a loopback redirect.
58
73
  // Config + the one-time redirect-allowlist requirement live in gotrueAuth.ts.
59
74
  const cfg = resolveGoTrueConfig();
60
- const session = await loopbackSignIn(provider ? { ...cfg, provider } : cfg);
75
+ const session = await loopbackSignIn(provider ? { ...cfg, provider } : cfg, {
76
+ // Still open the browser (the default behaviour), but also hand the URL back to the caller so
77
+ // the wizard can show it — a user whose browser didn't open can copy it.
78
+ onUrl: (url) => {
79
+ openUrl(url);
80
+ onUrl?.(url);
81
+ },
82
+ });
61
83
  this.bearer = session.accessToken;
62
84
  return session;
63
85
  }
@@ -176,6 +198,17 @@ export class SodabaseClient {
176
198
  ...(p.already_watched ? { watching: true } : {}),
177
199
  }));
178
200
  }
201
+ // ── Identity: who's signed in + which workspace (for the home report header) ──
202
+ async whoami() {
203
+ const me = await this.get("/me");
204
+ const email = this.bearer ? emailFromJwt(this.bearer) : undefined;
205
+ return {
206
+ ...(email ? { email } : {}),
207
+ // `||` (not `??`) so an empty-string name/role from the API falls back instead of rendering blank.
208
+ workspaceName: me.workspace_name || me.workspace_id || "your workspace",
209
+ role: me.role || "member",
210
+ };
211
+ }
179
212
  // ── Status: the workspace's watched projects + live open-issue counts ────────
180
213
  async dashboardProjects() {
181
214
  const rows = await this.get("/projects");
@@ -44,7 +44,10 @@ export class FakeClient {
44
44
  hasConfigToml: true,
45
45
  };
46
46
  }
47
- async signIn(_provider) {
47
+ async signIn(provider, onUrl) {
48
+ // Mirror the real authorize URL shape so the demo shows the same copy-paste line (never opened).
49
+ onUrl?.(`https://supabase-demo.supabase.co/auth/v1/authorize?provider=${provider ?? "google"}` +
50
+ `&redirect_to=http%3A%2F%2F127.0.0.1%3A8976%2Fcallback`);
48
51
  await this.tick(800);
49
52
  return { accessToken: "demo.gotrue.jwt", expiresAt: Date.now() + 3600_000 };
50
53
  }
@@ -59,6 +62,10 @@ export class FakeClient {
59
62
  setBearer() {
60
63
  /* no-op in demo */
61
64
  }
65
+ async whoami() {
66
+ await this.tick(120);
67
+ return { email: "you@example.com", workspaceName: "Demo", role: "owner" };
68
+ }
62
69
  async connect(signal) {
63
70
  // No real browser in demo — just simulate the authorize + callback round-trip.
64
71
  await this.tick(900);
package/dist/app.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useApp, useInput, useStdout } from "ink";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
- import { AgentView, Chrome, Connect, Home, ManageProjects, ManageTables, McpInstall, ScopeAdjust, SignIn, WizardProvider, } from "./ui.js";
4
+ import { AgentView, Chrome, Connect, Home, ManageProjects, ManageTables, McpInstall, ScopeAdjust, SignIn, TooSmall, WizardProvider, MIN_COLS, MIN_ROWS, } from "./ui.js";
5
5
  // The alternate-screen takeover and dark theming (OSC 11/10) are set up in cli.tsx before the first render;
6
6
  // here we only track the terminal size so the frame can fill its full height.
7
7
  /** Track the terminal size for the full-height frame; null when stdout isn't a sized TTY (piped output). */
@@ -115,5 +115,11 @@ export function App({ services, fast, interactive, signedIn, demo, fullscreen })
115
115
  // Full-height frame only when cli.tsx put us in fullscreen (interactive TTY); otherwise inline (size null).
116
116
  const termSize = useTerminalSize();
117
117
  const size = fullscreen ? termSize : null;
118
+ // Too-small guard (fullscreen only): below the minimum the frame clips/wraps, so show a resize prompt rather
119
+ // than a broken layout. Reactive — useTerminalSize re-renders on resize, so enlarging restores the wizard.
120
+ // Piped/CI (size null) is never gated: there's no window to resize and the output is plain and scrollable.
121
+ if (size && (size.columns < MIN_COLS || size.rows < MIN_ROWS)) {
122
+ return (_jsx(WizardProvider, { value: { services, fast, interactive, signedIn, demo }, children: _jsx(TooSmall, { size: size }) }));
123
+ }
118
124
  return (_jsx(WizardProvider, { value: { services, fast, interactive, signedIn, demo }, children: _jsx(Chrome, { size: size, children: Current ? _jsx(Current, { ctx: ctx, onDone: onDone }) : null }) }));
119
125
  }
package/dist/ui.js CHANGED
@@ -111,6 +111,16 @@ export function Chrome({ size, children, }) {
111
111
  // frame top-aligns (its start stays visible) instead of centering and pushing the top off-screen.
112
112
  return (_jsx(ChromeCtx.Provider, { value: api, children: _jsxs(Box, { flexDirection: "column", width: columns, height: size.rows, backgroundColor: BG, children: [_jsx(TopBar, { columns: columns }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", alignItems: "center", paddingX: 2, backgroundColor: BG, children: [_jsx(Box, { flexGrow: 1, flexShrink: 0 }), _jsxs(Box, { flexDirection: "column", alignItems: "center", flexShrink: 0, children: [_jsx(BrandMark, {}), children] }), _jsx(Box, { flexGrow: 1, flexShrink: 0 })] }), _jsx(BottomBar, { columns: columns, children: footer })] }) }));
113
113
  }
114
+ // The smallest terminal the fullscreen frame lays out cleanly: below this the two-column setup screen, the
115
+ // top/bottom bars and the centered body start to clip or wrap, so we show a resize prompt instead of a broken
116
+ // frame (mirrors PostHog's wizard). Checked only in the fullscreen/interactive path; piped output isn't gated.
117
+ export const MIN_COLS = 80;
118
+ export const MIN_ROWS = 28;
119
+ /** Shown in place of the wizard when the terminal is smaller than MIN_COLS×MIN_ROWS. Re-renders reactively as
120
+ * the user resizes (App watches the terminal size), so enlarging the window brings the wizard straight back. */
121
+ export function TooSmall({ size }) {
122
+ return (_jsxs(Box, { flexDirection: "column", width: size.columns, height: size.rows, backgroundColor: BG, padding: 1, children: [_jsx(Text, { color: "yellow", bold: true, children: "The Sodabase wizard needs more room. Please make this terminal bigger." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: MUTED, children: ["Currently ", size.columns, "\u00D7", size.rows, ", needs at least ", MIN_COLS, "\u00D7", MIN_ROWS, "."] }) })] }));
123
+ }
114
124
  // ── presentational bits ─────────────────────────────────────────────────────────
115
125
  function Eyebrow({ children }) {
116
126
  return (_jsx(Text, { color: ACCENT, bold: true, children: children }));
@@ -158,6 +168,8 @@ export function SignIn({ onDone }) {
158
168
  const [code, setCode] = useState("");
159
169
  const [err, setErr] = useState(null);
160
170
  const [project, setProject] = useState(null);
171
+ // The provider authorize URL being opened — shown so a user whose browser didn't open can copy it.
172
+ const [signInUrl, setSignInUrl] = useState(undefined);
161
173
  const mounted = useRef(true);
162
174
  useEffect(() => () => void (mounted.current = false), []);
163
175
  // Finish sign-in the same way for every path: set the bearer, persist (never in --demo), advance.
@@ -189,9 +201,13 @@ export function SignIn({ onDone }) {
189
201
  async function go(provider) {
190
202
  setChosen(provider);
191
203
  setErr(null);
204
+ setSignInUrl(undefined); // clear any stale URL from a previous attempt
192
205
  setStage("signing");
193
206
  try {
194
- complete(await services.signIn(provider));
207
+ complete(await services.signIn(provider, (url) => {
208
+ if (mounted.current)
209
+ setSignInUrl(url);
210
+ }));
195
211
  }
196
212
  catch (e) {
197
213
  fail(e);
@@ -333,7 +349,7 @@ export function SignIn({ onDone }) {
333
349
  return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: signedIn ? "Signed in" : "Project detected" }), signedIn ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "\u2714" }), " Already signed in ", _jsx(Text, { dimColor: true, children: "(using your saved session)" })] }) })) : (_jsxs(_Fragment, { children: [_jsx(Box, { marginTop: 1, flexDirection: "column", width: 64, children: _jsx(Text, { children: "We'll set up data-quality monitoring for your Supabase project \u2014 watching freshness, volume and quality drift, without touching a line of your code." }) }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: !project ? (_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Detecting Supabase project\u2026"] })) : (_jsx(ProjectFacts, { project: project })) }), stage === "pick" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "How do you want to sign in?" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: PROVIDERS.map((p, i) => {
334
350
  const here = i === cursor;
335
351
  return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", p.label] }, p.id));
336
- }) })] })) : stage === "email" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Enter your email \u2014 we'll send you a sign-in code." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Email: ", _jsx(Text, { color: "green", children: email }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "sending" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Sending a sign-in code to ", email, "\u2026"] }) })) : stage === "code" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["We emailed a sign-in code to ", email, ". Enter it below."] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Code: ", _jsx(Text, { color: "green", children: code }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "verifying" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Verifying your code\u2026"] }) })) : stage === "error" && err ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", children: err.text }), err.hint && _jsx(Text, { dimColor: true, children: err.hint })] })) : (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to sign in with ", providerLabel, "\u2026"] }) }))] }))] }));
352
+ }) })] })) : stage === "email" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Enter your email \u2014 we'll send you a sign-in code." }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Email: ", _jsx(Text, { color: "green", children: email }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "sending" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Sending a sign-in code to ", email, "\u2026"] }) })) : stage === "code" ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["We emailed a sign-in code to ", email, ". Enter it below."] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["Code: ", _jsx(Text, { color: "green", children: code }), _jsx(Text, { inverse: true, children: " " })] }) })] })) : stage === "verifying" ? (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Verifying your code\u2026"] }) })) : stage === "error" && err ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", children: err.text }), err.hint && _jsx(Text, { dimColor: true, children: err.hint })] })) : (_jsxs(Box, { marginTop: 1, flexDirection: "column", alignItems: "center", children: [_jsxs(Text, { children: [_jsx(Text, { color: "green", children: spin }), " Opening your browser to sign in with ", providerLabel, "\u2026"] }), signInUrl && (_jsxs(Box, { marginTop: 1, flexDirection: "column", width: 64, children: [_jsx(Text, { dimColor: true, children: "If your browser didn't open, visit this URL:" }), _jsx(Text, { color: ACCENT, children: signInUrl })] }))] }))] }))] }));
337
353
  }
338
354
  // ── Phase: connect (multi-step: authorize → list → pick project) ─────────────────
339
355
  /** Short status tags shown next to a project in the picker: "watching" (already set up in this workspace) and
@@ -451,11 +467,21 @@ const STEP_LABELS = {
451
467
  };
452
468
  const stepLabel = (name) => STEP_LABELS[name] ?? name;
453
469
  export function AgentView({ ctx, onDone }) {
454
- useFooter(_jsx(Text, { dimColor: true, children: "setting up\u2026 \u00B7 esc to cancel" }), []);
455
- const { services, fast } = useWizard();
470
+ const { services, fast, interactive } = useWizard();
456
471
  const [steps, setSteps] = useState([]);
457
472
  const [logs, setLogs] = useState(["Planning the trust setup."]);
458
473
  const [error, setError] = useState(null);
474
+ // The job is finished and we're holding the completed screen until the user presses a key (interactive
475
+ // only) — so the "all 5 done" result doesn't flash past before they can read it.
476
+ const [finished, setFinished] = useState(false);
477
+ // Each completed step logs exactly one tail line. Without this, every poll re-appended the latest
478
+ // completed step's line while the job sat on it, printing the same row several times over.
479
+ const loggedRef = useRef(new Set());
480
+ useFooter(_jsx(Text, { dimColor: true, children: finished ? "done · enter to continue" : "setting up… · esc to cancel" }), [finished]);
481
+ useInput((_i, key) => {
482
+ if (key.return)
483
+ onDone({});
484
+ }, { isActive: interactive && finished });
459
485
  useEffect(() => {
460
486
  let on = true;
461
487
  (async () => {
@@ -466,10 +492,20 @@ export function AgentView({ ctx, onDone }) {
466
492
  if (!on)
467
493
  return;
468
494
  setSteps(st.steps);
469
- const last = st.steps.filter((s) => s.status === "done" || s.status === "skipped").at(-1);
470
- if (last?.detail)
471
- setLogs((l) => [...l, `${stepLabel(last.name)} — ${last.detail}`].slice(-4));
495
+ // Append a tail line for any step that just reached a terminal state, once each, in order.
496
+ for (const s of st.steps) {
497
+ if ((s.status === "done" || s.status === "skipped") && s.detail && !loggedRef.current.has(s.name)) {
498
+ loggedRef.current.add(s.name);
499
+ setLogs((l) => [...l, `${stepLabel(s.name)} — ${s.detail}`].slice(-4));
500
+ }
501
+ }
472
502
  if (st.status === "done") {
503
+ // Interactive: hold the completed screen until a keypress. Non-interactive (CI/pipe): no
504
+ // keyboard to wait on, so advance after a readable beat as before.
505
+ if (interactive) {
506
+ setFinished(true);
507
+ return;
508
+ }
473
509
  await sleep(fast ? 80 : 500);
474
510
  if (on)
475
511
  onDone({});
@@ -495,7 +531,7 @@ export function AgentView({ ctx, onDone }) {
495
531
  const mk = s.status === "done" ? "✔" : s.status === "running" ? "▶" : s.status === "skipped" ? "—" : "□";
496
532
  const color = s.status === "done" || s.status === "running" ? "green" : undefined;
497
533
  return (_jsxs(Text, { color: color, dimColor: s.status === "pending" || s.status === "queued" || s.status === "skipped", children: [" ", mk, " ", stepLabel(s.name)] }, s.name));
498
- }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Progress" }), " ", _jsx(Text, { bold: true, children: `${done}/${total}` })] }) })] })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Tail logs" }), logs.map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, i)))] })] }))] }));
534
+ }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [_jsx(Text, { color: "green", children: "Progress" }), " ", _jsx(Text, { bold: true, children: `${done}/${total}` })] }) }), finished && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "green", children: "\u2714 Monitoring is live \u2014 press enter to continue" }) }))] })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Tail logs" }), logs.map((l, i) => (_jsxs(Text, { dimColor: true, children: [" ", l] }, i)))] })] }))] }));
499
535
  }
500
536
  // ── Phase: Scope (onboard-then-adjust; monitor ids) ──────────────────────────────
501
537
  export function ScopeAdjust({ onDone }) {
@@ -596,12 +632,15 @@ export function McpInstall({ onDone }) {
596
632
  // The agents the MCP install actually wrote, so the skill-error hold can advance with the right context.
597
633
  const [installedAgents, setInstalledAgents] = useState([]);
598
634
  const [busy, setBusy] = useState(false);
635
+ // Install succeeded and we're holding the result screen until the user presses enter (so the ✔ summary
636
+ // and "restart your agent" note don't flash past before returning to the hub).
637
+ const [ready, setReady] = useState(false);
599
638
  const [error, setError] = useState(null);
600
639
  // MCP install is reached only from the hub menu (interactive). Back-navigation can unmount this
601
640
  // mid-install, so guard every post-await state update.
602
641
  const mounted = useRef(true);
603
642
  useEffect(() => () => void (mounted.current = false), []);
604
- useFooter(busy ? (_jsx(Text, { dimColor: true, children: "installing\u2026" })) : (_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter install \u00B7 n skip \u00B7 esc to go back" })), [busy]);
643
+ useFooter(busy ? (_jsx(Text, { dimColor: true, children: "installing\u2026" })) : ready || skillError ? (_jsx(Text, { dimColor: true, children: "enter to continue" })) : (_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter install \u00B7 n skip \u00B7 esc to go back" })), [busy, ready, skillError]);
605
644
  async function run(choices) {
606
645
  if (choices.length === 0) {
607
646
  onDone({ installed: [] });
@@ -631,10 +670,14 @@ export function McpInstall({ onDone }) {
631
670
  await sleep(fast ? 300 : 900);
632
671
  if (!mounted.current)
633
672
  return;
634
- // Hold on a skill failure so the manual fallback is readable/actionable (enter advances);
635
- // otherwise finish.
673
+ // Hold on a skill failure so the manual fallback is readable/actionable (enter advances). Otherwise,
674
+ // interactive: hold the success screen until the user presses enter; non-interactive: just finish.
636
675
  if (skillFailed)
637
676
  setBusy(false);
677
+ else if (interactive) {
678
+ setBusy(false);
679
+ setReady(true);
680
+ }
638
681
  else
639
682
  onDone({ installed: choices });
640
683
  }
@@ -649,6 +692,12 @@ export function McpInstall({ onDone }) {
649
692
  useInput((input, key) => {
650
693
  if (busy)
651
694
  return;
695
+ if (ready) {
696
+ // Holding on the success screen: enter returns to the hub.
697
+ if (key.return)
698
+ onDone({ installed: installedAgents });
699
+ return;
700
+ }
652
701
  if (skillError) {
653
702
  // Holding after a non-fatal skill failure: the MCP already landed, so advance on enter.
654
703
  if (key.return)
@@ -670,8 +719,8 @@ export function McpInstall({ onDone }) {
670
719
  void run([]);
671
720
  else if (key.return)
672
721
  void run(AGENTS.filter((_, i) => sel[i]));
673
- }, { isActive: interactive && !busy && (!result || skillError !== null) });
674
- return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Set up your coding agent (optional)" }), error ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't auto-install the MCP: ", error] }), _jsx(Text, { dimColor: true, children: "Add it yourself (Claude Code):" }), _jsxs(Text, { color: "cyan", children: [" ", "claude mcp add --transport http sodabase https://sodabase.io/mcp"] }), interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : result ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["Ran: ", result.command] }), result.wrote.map((w) => (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " ", w.agent, " ", _jsxs(Text, { dimColor: true, children: ["\u2192 ", w.path] })] }, w.agent))), skillResult && (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " trust-advisor skill ", _jsx(Text, { dimColor: true, children: "\u2192 sodabase/agent-skills" })] })), skillError && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't install the trust-advisor skill: ", skillError] }), _jsx(Text, { dimColor: true, children: "Add it yourself:" }), _jsxs(Text, { color: "cyan", children: [" ", "npx skills add sodabase/agent-skills"] })] })), _jsx(Text, { color: "green", children: "Ready next time you restart your agent." }), skillError && interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Install the Sodabase MCP + trust-advisor skill so your agent can ask \"is this data safe to trust?\"" }), _jsx(Text, { dimColor: true, children: "Explicit \u2014 we show the exact change and only write on your confirm." })] }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: AGENTS.map((a, i) => {
722
+ }, { isActive: interactive && !busy && (!result || skillError !== null || ready) });
723
+ return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: "Set up your coding agent (optional)" }), error ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't auto-install the MCP: ", error] }), _jsx(Text, { dimColor: true, children: "Add it yourself (Claude Code):" }), _jsxs(Text, { color: "cyan", children: [" ", "claude mcp add --transport http sodabase https://sodabase.io/mcp"] }), interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : result ? (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { dimColor: true, children: ["Ran: ", result.command] }), result.wrote.map((w) => (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " ", w.agent, " ", _jsxs(Text, { dimColor: true, children: ["\u2192 ", w.path] })] }, w.agent))), skillResult && (_jsxs(Text, { children: [" ", _jsx(Text, { color: "green", children: "\u2714" }), " trust-advisor skill ", _jsx(Text, { dimColor: true, children: "\u2192 sodabase/agent-skills" })] })), skillError && (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "yellow", children: ["Couldn't install the trust-advisor skill: ", skillError] }), _jsx(Text, { dimColor: true, children: "Add it yourself:" }), _jsxs(Text, { color: "cyan", children: [" ", "npx skills add sodabase/agent-skills"] })] })), _jsx(Text, { color: "green", children: "Ready next time you restart your agent." }), (ready || skillError) && interactive && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "enter to continue" }) }))] })) : (_jsxs(_Fragment, { children: [_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Install the Sodabase MCP + trust-advisor skill so your agent can ask \"is this data safe to trust?\"" }), _jsx(Text, { dimColor: true, children: "Explicit \u2014 we show the exact change and only write on your confirm." })] }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: AGENTS.map((a, i) => {
675
724
  const on = sel[i];
676
725
  const here = interactive && i === cursor;
677
726
  return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [here ? "❯ " : " ", on ? "[x]" : "[ ]", " ", a] }, a));
@@ -848,6 +897,7 @@ export function Home({ ctx, onDone }) {
848
897
  const { exit } = useApp();
849
898
  const { services, fast, interactive } = useWizard();
850
899
  const [projects, setProjects] = useState(null);
900
+ const [identity, setIdentity] = useState(null);
851
901
  const [cursor, setCursor] = useState(0);
852
902
  useEffect(() => {
853
903
  let on = true;
@@ -862,6 +912,17 @@ export function Home({ ctx, onDone }) {
862
912
  setProjects([]); // no projects yet / offline — render the empty-state + menu
863
913
  }
864
914
  })();
915
+ // Who's signed in + which workspace — fetched alongside the report, never blocking it.
916
+ (async () => {
917
+ try {
918
+ const me = await services.whoami();
919
+ if (on)
920
+ setIdentity(me);
921
+ }
922
+ catch {
923
+ /* identity line is best-effort — the report still renders without it */
924
+ }
925
+ })();
865
926
  return () => {
866
927
  on = false;
867
928
  };
@@ -894,7 +955,9 @@ export function Home({ ctx, onDone }) {
894
955
  const monitors = list.reduce((a, p) => a + p.monitors, 0);
895
956
  const rules = list.reduce((a, p) => a + p.rules, 0);
896
957
  useFooter(_jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 enter select \u00B7 esc to quit" }), []);
897
- return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: watching ? "Sodabase is watching" : "Welcome to Sodabase" }), _jsx(Box, { marginTop: 1, flexDirection: "column", children: projects === null ? (_jsx(Text, { dimColor: true, children: "loading your trust report\u2026" })) : watching ? (_jsxs(_Fragment, { children: [_jsxs(StatRow, { label: "Tables watched", children: [_jsx(Text, { color: "green", bold: true, children: tables }), " ", "across ", plural(list.length, "project")] }), _jsxs(StatRow, { label: "Issues", children: [_jsx(Text, { color: issues > 0 ? "yellow" : "green", bold: true, children: issues }), " ", issues > 0 ? (_jsxs(Text, { dimColor: true, children: ["\u00B7 ", anomalyLabel(anomalies), " & ", plural(brokenRules, "broken rule")] })) : (_jsx(Text, { dimColor: true, children: "\u00B7 all clear" }))] }), _jsxs(StatRow, { label: "Coverage", children: [_jsx(Text, { bold: true, children: plural(monitors, "monitor") }), _jsx(Text, { dimColor: true, children: " & " }), _jsx(Text, { bold: true, children: plural(rules, "rule") })] }), ctx.installed && ctx.installed.length > 0 && (_jsxs(StatRow, { label: "MCP", children: [_jsx(Text, { color: "green", children: "\u2714" }), " installed for ", ctx.installed.join(", ")] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { children: "You're not watching any projects yet." }), _jsx(Text, { dimColor: true, children: "Pick one below \u2014 Sodabase sets up read-only monitoring, no code changes." })] })) }), interactive && projects !== null && (_jsx(_Fragment, { children: _jsx(Box, { marginTop: 1, flexDirection: "column", children: HOME_MENU.map((m, i) => {
958
+ return (_jsxs(Box, { flexDirection: "column", paddingX: 2, marginTop: 1, alignItems: "center", children: [_jsx(Eyebrow, { children: watching ? "Sodabase is watching" : "Welcome to Sodabase" }), identity && (_jsx(Box, { marginTop: 1, children: identity.email ? (_jsxs(Text, { dimColor: true, children: ["Signed in as ", _jsx(Text, { color: WHITE, children: identity.email }), " \u00B7 workspace", " ", _jsx(Text, { color: WHITE, children: identity.workspaceName })] })) : (
959
+ // No email on the JWT — a role isn't an identity, so just name the workspace.
960
+ _jsxs(Text, { dimColor: true, children: ["Workspace ", _jsx(Text, { color: WHITE, children: identity.workspaceName })] })) })), _jsx(Box, { marginTop: 1, flexDirection: "column", children: projects === null ? (_jsx(Text, { dimColor: true, children: "loading your trust report\u2026" })) : watching ? (_jsxs(_Fragment, { children: [_jsxs(StatRow, { label: "Tables watched", children: [_jsx(Text, { color: "green", bold: true, children: tables }), " ", "across ", plural(list.length, "project")] }), _jsxs(StatRow, { label: "Issues", children: [_jsx(Text, { color: issues > 0 ? "yellow" : "green", bold: true, children: issues }), " ", issues > 0 ? (_jsxs(Text, { dimColor: true, children: ["\u00B7 ", anomalyLabel(anomalies), " & ", plural(brokenRules, "broken rule")] })) : (_jsx(Text, { dimColor: true, children: "\u00B7 all clear" }))] }), _jsxs(StatRow, { label: "Coverage", children: [_jsx(Text, { bold: true, children: plural(monitors, "monitor") }), _jsx(Text, { dimColor: true, children: " & " }), _jsx(Text, { bold: true, children: plural(rules, "rule") })] }), ctx.installed && ctx.installed.length > 0 && (_jsxs(StatRow, { label: "MCP", children: [_jsx(Text, { color: "green", children: "\u2714" }), " installed for ", ctx.installed.join(", ")] }))] })) : (_jsxs(_Fragment, { children: [_jsx(Text, { children: "You're not watching any projects yet." }), _jsx(Text, { dimColor: true, children: "Pick one below \u2014 Sodabase sets up read-only monitoring, no code changes." })] })) }), interactive && projects !== null && (_jsx(_Fragment, { children: _jsx(Box, { marginTop: 1, flexDirection: "column", children: HOME_MENU.map((m, i) => {
898
961
  const here = i === cursor;
899
962
  return (_jsxs(Text, { color: here ? "green" : undefined, children: [here ? "❯ " : " ", m.label, " ", _jsxs(Text, { dimColor: true, children: ["\u00B7 ", m.hint] })] }, m.id));
900
963
  }) }) }))] }));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sodabase",
3
- "version": "0.1.4",
4
- "description": "Sodabase onboarding wizard — v2 interactive CLI (npx sodabase).",
3
+ "version": "0.1.7",
4
+ "description": "Sodabase onboarding wizard — interactive CLI (npx sodabase).",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://sodabase.io",
7
7
  "repository": {