sodabase 0.1.9 → 0.1.11

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
@@ -22,13 +22,38 @@ node dist/cli.js # run the built CLI
22
22
  npm run dev # node --experimental-strip-types src/cli.tsx
23
23
  ```
24
24
 
25
+ ## Install just the MCP
26
+
27
+ ```bash
28
+ npx sodabase install-mcp # checkbox list, agents found locally pre-ticked
29
+ npx sodabase install-mcp -a cursor -a codex # or --agent cursor,codex / --all
30
+ npx sodabase install-mcp --no-skill # MCP only, skip the trust-advisor skill
31
+ npx sodabase install-mcp --no-input # no list: install for the agents found (CI/scripts)
32
+ ```
33
+
34
+ Without `--agent`, a terminal run shows a checkbox list with the agents found on this
35
+ machine pre-ticked (Claude Code if none); a piped run installs for those directly. Skips the wizard and sign-in (the agent signs in on its first MCP call) and runs the same
36
+ `add-mcp` + `skills add` installs as the hub's "Install MCP" step. Exits 1 only if the MCP
37
+ install fails; a skill failure warns with a manual fallback.
38
+
25
39
  Point at a local backend with `SODABASE_API_URL=http://localhost:8080`.
26
40
 
41
+ ## Pipeline checks (Edge Functions)
42
+
43
+ ```bash
44
+ npx sodabase rules pull --project <ref> # save supabase/functions/_shared/sodabase.rules.yml + its static_files entries (signed-in owner/admin)
45
+ npx sodabase functions lint # flag writes in supabase/functions/** without a check() line before them (offline; exits 1 if any)
46
+ ```
47
+
27
48
  ## Layout
28
49
 
29
50
  ```
30
51
  src/
31
- cli.tsx entry — renders <App/>
52
+ cli.tsx entry — renders <App/> (or runs the install-mcp subcommand)
53
+ installMcp.ts `install-mcp`: arg parsing, agent detection, plain-output install
54
+ rulesPull.ts `rules pull`: the rules file + a line-based config.toml static_files edit
55
+ functionsLint.ts `functions lint`: unchecked-write heuristic over supabase/functions/**
56
+ agentPicker.tsx `install-mcp`'s inline agent checkbox list
32
57
  app.tsx the Ink app (flow orchestrator + screens)
33
58
  api/
34
59
  client.ts HTTP client for the real endpoints (device grant, onboarding
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // The agent checkbox list: the state + keys (useAgentChecklist) and the rows (AgentChecklist) are shared by the
3
+ // wizard's MCP step (ui.tsx) and `npx sodabase install-mcp`, which renders it inline (no fullscreen) via
4
+ // pickAgents. Agents found on this machine start ticked and are marked "found"; ones that already have the MCP
5
+ // are marked "already set up" and start unticked.
6
+ import { Box, Text, render, useApp, useInput } from "ink";
7
+ import { useState } from "react";
8
+ import { MCP_AGENTS } from "./installMcp.js";
9
+ /** Which agents are ticked + the cursor, and the ↑↓/space handling. `handleKey` returns true if it used the key. */
10
+ export function useAgentChecklist(preselected) {
11
+ const [sel, setSel] = useState(() => MCP_AGENTS.map((a) => preselected.includes(a)));
12
+ const [cursor, setCursor] = useState(0);
13
+ const handleKey = (input, key) => {
14
+ if (key.upArrow)
15
+ setCursor((c) => Math.max(0, c - 1));
16
+ else if (key.downArrow)
17
+ setCursor((c) => Math.min(MCP_AGENTS.length - 1, c + 1));
18
+ else if (input === " ")
19
+ setSel((s) => s.map((v, i) => (i === cursor ? !v : v)));
20
+ else
21
+ return false;
22
+ return true;
23
+ };
24
+ return { sel, cursor, handleKey, picked: () => MCP_AGENTS.filter((_, i) => sel[i]) };
25
+ }
26
+ export function AgentChecklist({ sel, cursor, found, installed }) {
27
+ return (_jsx(Box, { flexDirection: "column", children: MCP_AGENTS.map((a, i) => {
28
+ const on = sel[i];
29
+ return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [i === cursor ? "❯ " : " ", on ? "[x]" : "[ ]", " ", a, installed.includes(a) ? (_jsx(Text, { color: "green", children: " \u00B7 already set up" })) : (found.includes(a) && _jsx(Text, { dimColor: true, children: " \u00B7 found" }))] }, a));
30
+ }) }));
31
+ }
32
+ function AgentPicker({ preselected, found, installed, skill, onDone }) {
33
+ const { exit } = useApp();
34
+ const list = useAgentChecklist(preselected);
35
+ const finish = (agents) => {
36
+ onDone(agents);
37
+ exit();
38
+ };
39
+ useInput((input, key) => {
40
+ if (list.handleKey(input, key))
41
+ return;
42
+ if (key.return)
43
+ finish(list.picked());
44
+ else if (key.escape || input === "q" || (key.ctrl && input === "c"))
45
+ finish(null);
46
+ });
47
+ return (_jsxs(Box, { flexDirection: "column", marginY: 1, children: [_jsxs(Text, { children: ["Install the Sodabase MCP", skill ? " + trust-advisor skill" : "", " for:"] }), _jsx(Box, { marginTop: 1, children: _jsx(AgentChecklist, { sel: list.sel, cursor: list.cursor, found: found, installed: installed }) }), installed.length > 0 && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Already set up agents stay as they are unless you tick them (reinstalls)." }) })), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191\u2193 move \u00B7 space toggle \u00B7 enter install \u00B7 esc cancel" }) })] }));
48
+ }
49
+ /** Show the checkbox list; resolves to the ticked agents, or null if the user cancelled. */
50
+ export async function pickAgents(preselected, found, installed, skill) {
51
+ let picked = null;
52
+ // exitOnCtrlC off: ctrl+c is handled above as a cancel, so we still print a clean "nothing installed".
53
+ const app = render(_jsx(AgentPicker, { preselected: preselected, found: found, installed: installed, skill: skill, onDone: (a) => (picked = a) }), {
54
+ exitOnCtrlC: false,
55
+ });
56
+ await app.waitUntilExit();
57
+ return picked;
58
+ }
@@ -7,7 +7,8 @@ import { existsSync, readFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
  import { emailOtpStart, emailOtpVerify, loopbackSignIn, resolveGoTrueConfig } from "./gotrueAuth.js";
9
9
  import { ApiError, } from "./types.js";
10
- export const MCP_URL = "https://sodabase.io/mcp";
10
+ /** The MCP endpoint on the same origin the client talks to, so a dev install (SODABASE_API_URL) points at the dev MCP. */
11
+ export const MCP_URL = `${(process.env.SODABASE_API_URL ?? "https://sodabase.io").replace(/\/$/, "")}/mcp`;
11
12
  /** The trust-advisor skill repo, resolved by the `skills` CLI (owner/repo on its default branch). */
12
13
  export const SKILL_REF = "sodabase/agent-skills";
13
14
  /** An error thrown when `connect()`'s poll is aborted (the user left the connect screen). */
@@ -316,6 +317,10 @@ export class SodabaseClient {
316
317
  });
317
318
  return { command };
318
319
  }
320
+ // ── `rules pull`: the project's pipeline rules file (writers only; GET /projects/{ref}/edge/rules-file) ──
321
+ async rulesFile(projectRef) {
322
+ return this.get(`/projects/${encodeURIComponent(projectRef)}/edge/rules-file`);
323
+ }
319
324
  // ── low-level helpers ───────────────────────────────────────────────────────
320
325
  authHeaders() {
321
326
  return this.bearer ? { authorization: `Bearer ${this.bearer}` } : {};
package/dist/cli.js CHANGED
@@ -7,15 +7,116 @@ import { homedir } from "node:os";
7
7
  import { join } from "node:path";
8
8
  import { SodabaseClient } from "./api/client.js";
9
9
  import { FakeClient } from "./api/fakeClient.js";
10
+ import { pickAgents } from "./agentPicker.js";
10
11
  import { App } from "./app.js";
11
- import { clearCreds, loadCreds } from "./config/tokenStore.js";
12
+ import { clearCreds, isSignedIn, loadCreds } from "./config/tokenStore.js";
13
+ import { runLint } from "./functionsLint.js";
14
+ import { INSTALL_MCP_HELP, detectAgents, installedAgents, parseInstallMcpArgs, resolveAgents, runInstallMcp, } from "./installMcp.js";
15
+ import { RULES_PULL_HELP, parseRulesPullArgs, runRulesPull } from "./rulesPull.js";
16
+ import { ApiError } from "./api/types.js";
12
17
  const argv = process.argv.slice(2);
13
18
  const args = new Set(argv);
19
+ /** process.exit() drops output still queued on a pipe (async on macOS, e.g. `| tee log`): await this first. */
20
+ async function drained() {
21
+ await Promise.all([process.stdout, process.stderr].map((s) => new Promise((done) => s.write("", done))));
22
+ }
23
+ // `install-mcp`: a one-shot, non-interactive install of the MCP + skill — no wizard, no sign-in.
24
+ if (argv[0] === "install-mcp") {
25
+ const opts = parseInstallMcpArgs(argv.slice(1));
26
+ if ("error" in opts) {
27
+ process.stderr.write(`sodabase install-mcp: ${opts.error}\n\n${INSTALL_MCP_HELP}`);
28
+ await drained();
29
+ process.exit(2);
30
+ }
31
+ if (opts.help) {
32
+ process.stdout.write(INSTALL_MCP_HELP);
33
+ await drained();
34
+ process.exit(0);
35
+ }
36
+ const found = detectAgents();
37
+ // With --agent, only those agents' configs matter (for the "refreshed" label) — don't read the others.
38
+ const installed = installedAgents(undefined, opts.skill, undefined, undefined, opts.agents.length ? opts.agents : undefined);
39
+ let target = resolveAgents(opts.agents, found, installed);
40
+ // No --agent in a terminal: always let the user choose, starting from what we found. Piped/CI runs
41
+ // (or --no-input) skip the list and install for the detected agents that don't have it yet. Both ends
42
+ // must be a TTY: with stdout piped (`| tee log`) the list would render invisibly and look like a hang.
43
+ if (!opts.agents.length && opts.input && process.stdin.isTTY && process.stdout.isTTY) {
44
+ const picked = await pickAgents(target.agents, found, installed, opts.skill);
45
+ if (!picked?.length) {
46
+ process.stdout.write("Nothing installed.\n");
47
+ await drained();
48
+ process.exit(0);
49
+ }
50
+ target = { agents: picked, detected: false };
51
+ }
52
+ if (!target.agents.length) {
53
+ // Only reachable from auto-target: every detected agent is already set up.
54
+ process.stdout.write(`Already set up for ${installed.join(", ")}. Nothing to do.\n`);
55
+ await drained();
56
+ process.exit(0);
57
+ }
58
+ const code = await runInstallMcp(new SodabaseClient(), { ...opts, ...target, installed }, (line) => process.stdout.write(`${line}\n`));
59
+ await drained();
60
+ process.exit(code);
61
+ }
62
+ // `functions lint`: static and offline — flags writes in supabase/functions/** with no check() line before them.
63
+ if (argv[0] === "functions" && argv[1] === "lint") {
64
+ const code = runLint(process.cwd(), (line) => process.stdout.write(`${line}\n`));
65
+ await drained();
66
+ process.exit(code);
67
+ }
68
+ // `rules pull --project <ref>`: the project's pipeline rules file + its static_files entries (signed-in writer).
69
+ if (argv[0] === "rules" && argv[1] === "pull") {
70
+ const opts = parseRulesPullArgs(argv.slice(2));
71
+ const fail = async (msg, code = 1) => {
72
+ process.stderr.write(`sodabase rules pull: ${msg}\n${code === 2 ? `\n${RULES_PULL_HELP}` : ""}`);
73
+ await drained();
74
+ process.exit(code);
75
+ };
76
+ if ("error" in opts)
77
+ await fail(opts.error, 2);
78
+ const { project, help } = opts;
79
+ if (help) {
80
+ process.stdout.write(RULES_PULL_HELP);
81
+ await drained();
82
+ process.exit(0);
83
+ }
84
+ const creds = loadCreds();
85
+ const login = "not signed in (or the session expired) — run `npx sodabase --login` first";
86
+ if (!isSignedIn(creds))
87
+ await fail(login);
88
+ const client = new SodabaseClient();
89
+ client.setBearer(creds.accessToken);
90
+ try {
91
+ const code = await runRulesPull(project, (r) => client.rulesFile(r), process.cwd(), (line) => process.stdout.write(`${line}\n`));
92
+ await drained();
93
+ process.exit(code);
94
+ }
95
+ catch (err) {
96
+ if (!(err instanceof ApiError))
97
+ throw err;
98
+ if (err.status === 401)
99
+ await fail(login);
100
+ if (err.status === 403)
101
+ await fail("only a workspace owner or admin can pull the rules file");
102
+ if (err.status === 404)
103
+ await fail("no such project in your workspace, or pipeline checks aren't on for it yet");
104
+ await fail(err.message);
105
+ }
106
+ }
14
107
  if (args.has("--help") || args.has("-h")) {
15
108
  process.stdout.write([
16
109
  "sodabase — data-quality onboarding wizard",
17
110
  "",
18
111
  "Usage: npx sodabase [options]",
112
+ " npx sodabase install-mcp [-a, --agent <id>] [--all] [--no-skill] [--no-input]",
113
+ " npx sodabase rules pull --project <ref>",
114
+ " npx sodabase functions lint",
115
+ "",
116
+ "Commands:",
117
+ " install-mcp install the MCP + trust-advisor skill for your coding agent, then exit",
118
+ " rules pull save the project's pipeline rules file and list it in each function's static_files",
119
+ " functions lint flag writes in supabase/functions without a check() line before them",
19
120
  "",
20
121
  "Options:",
21
122
  " --demo run the whole flow offline against a fake backend",
@@ -76,7 +177,7 @@ const services = demo
76
177
  // (e.g. a leftover --demo session) skipping sign-in and then 401-ing on /api/v1.
77
178
  if (creds?.accessToken && creds.accessToken.startsWith("eyJ")) {
78
179
  c.setBearer(creds.accessToken);
79
- signedIn = !creds.expiresAt || creds.expiresAt > Date.now() + 60_000;
180
+ signedIn = isSignedIn(creds);
80
181
  }
81
182
  return c;
82
183
  })();
@@ -5,6 +5,10 @@
5
5
  import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { homedir } from "node:os";
7
7
  import { dirname, join } from "node:path";
8
+ /** A real GoTrue JWT (starts "eyJ"; a leftover --demo token doesn't) with over a minute left on it. */
9
+ export function isSignedIn(creds) {
10
+ return !!creds?.accessToken?.startsWith("eyJ") && (!creds.expiresAt || creds.expiresAt > Date.now() + 60_000);
11
+ }
8
12
  function credsPath() {
9
13
  const base = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
10
14
  return join(base, "sodabase", "credentials.json");
@@ -0,0 +1,162 @@
1
+ // `npx sodabase functions lint` — flags database writes in supabase/functions/** that no `check()` line from
2
+ // @sodabase/edge covers (planning repo edge-function-writes-mvp-spec §4.1, §11 P5). Static and offline: no sign-in.
3
+ //
4
+ // What counts as a write: supabase-js / Drizzle `.insert(` `.upsert(` `.update(`, and a postgres.js
5
+ // sql`insert …` / sql`update …` template. A write is covered when the file imports @sodabase/edge and a `check(`
6
+ // call comes earlier in the same block or an enclosing one (a check inside a sibling, already-closed block doesn't).
7
+ // shortcut: brace-depth heuristic, not an AST (typescript is dev-only); an outer function's earlier check() can mask a
8
+ // write, `${}` inside templates and regex literals aren't parsed — upgrade to the TS compiler API if it misleads.
9
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
10
+ import { join, relative } from "node:path";
11
+ const EDGE_IMPORT = /\bfrom\s*["'](?:jsr:|npm:)?@sodabase\/edge(?:@[^"']*)?(?:\/[^"']*)?["']/;
12
+ const CALL_WRITE = /\.(insert|upsert|update)\s*\(/g;
13
+ const SQL_TAG = /\bsql\s*$/;
14
+ const SQL_WRITE = /^\s*(insert|update)\b/i;
15
+ const CHECK = /\bcheck\s*\(/g;
16
+ // node:crypto's hash.update(data) is not a database write: neither the same-line chain nor a name bound to one
17
+ const HASH_CHAIN = /create(?:Hash|Hmac)\s*\(/;
18
+ const HASH_BINDING = /\b(?:const|let|var)\s+(\w+)\s*=\s*(?:[\w.]+\.)?create(?:Hash|Hmac)\s*\(/g;
19
+ /** Blank comments, strings and template bodies (keeping newlines and the quote characters), so braces and calls
20
+ * inside them don't count. Returns the blanked code and each template's start offset + raw body. */
21
+ function blank(src) {
22
+ const out = src.split("");
23
+ const templates = [];
24
+ const wipe = (from, to) => {
25
+ for (let k = from; k < to; k++)
26
+ if (out[k] !== "\n")
27
+ out[k] = " ";
28
+ };
29
+ let i = 0;
30
+ while (i < src.length) {
31
+ const c = src[i];
32
+ if (c === "/" && src[i + 1] === "/") {
33
+ const end = src.indexOf("\n", i);
34
+ const stop = end === -1 ? src.length : end;
35
+ wipe(i, stop);
36
+ i = stop;
37
+ }
38
+ else if (c === "/" && src[i + 1] === "*") {
39
+ const end = src.indexOf("*/", i + 2);
40
+ const stop = end === -1 ? src.length : end + 2;
41
+ wipe(i, stop);
42
+ i = stop;
43
+ }
44
+ else if (c === "'" || c === '"' || c === "`") {
45
+ let j = i + 1;
46
+ while (j < src.length && src[j] !== c && !(c !== "`" && src[j] === "\n"))
47
+ j += src[j] === "\\" ? 2 : 1;
48
+ if (c === "`")
49
+ templates.push({ at: i, body: src.slice(i + 1, j) });
50
+ wipe(i + 1, Math.min(j, src.length));
51
+ i = j + 1;
52
+ }
53
+ else
54
+ i++;
55
+ }
56
+ return { code: out.join(""), templates };
57
+ }
58
+ /** The unchecked writes in one source file. */
59
+ export function lintSource(src) {
60
+ const { code, templates } = blank(src);
61
+ const imported = EDGE_IMPORT.test(src);
62
+ const checks = new Set();
63
+ for (const m of code.matchAll(CHECK))
64
+ checks.add(m.index);
65
+ const hashes = new Set([...code.matchAll(HASH_BINDING)].map((m) => m[1]));
66
+ const writes = [];
67
+ for (const m of code.matchAll(CALL_WRITE)) {
68
+ // at most 256 chars back (a hostile long line stays linear); `\b` stops the name regex retrying inside a word
69
+ const before = code.slice(Math.max(code.lastIndexOf("\n", m.index) + 1, m.index - 256), m.index);
70
+ if (m[1] === "update" && (HASH_CHAIN.test(before) || hashes.has(/\b(\w+)\s*$/.exec(before)?.[1] ?? "")))
71
+ continue;
72
+ writes.push({ at: m.index, kind: m[1] });
73
+ }
74
+ for (const t of templates) {
75
+ const w = SQL_WRITE.exec(t.body);
76
+ if (w && SQL_TAG.test(code.slice(Math.max(0, t.at - 64), t.at)))
77
+ writes.push({ at: t.at, kind: `sql ${w[1].toLowerCase()}` });
78
+ }
79
+ // One forward pass: a stack of "a check() ran earlier in this block", one entry per open block (plus the file). A
80
+ // write is covered when its block or an enclosing one has one; a check inside a closed sibling block doesn't count.
81
+ const covered = new Set();
82
+ if (imported) {
83
+ const at = new Set(writes.map((w) => w.at));
84
+ const stack = [false];
85
+ for (let i = 0; i < code.length; i++) {
86
+ const c = code[i];
87
+ if (c === "{")
88
+ stack.push(false);
89
+ else if (c === "}") {
90
+ if (stack.length > 1)
91
+ stack.pop();
92
+ }
93
+ if (checks.has(i))
94
+ stack[stack.length - 1] = true;
95
+ if (at.has(i) && stack.includes(true))
96
+ covered.add(i);
97
+ }
98
+ }
99
+ const starts = [0];
100
+ for (let i = 0; i < src.length; i++)
101
+ if (src[i] === "\n")
102
+ starts.push(i + 1);
103
+ const lineOf = (pos) => {
104
+ let lo = 0;
105
+ let hi = starts.length - 1;
106
+ while (lo < hi) {
107
+ const mid = (lo + hi + 1) >> 1;
108
+ if (starts[mid] <= pos)
109
+ lo = mid;
110
+ else
111
+ hi = mid - 1;
112
+ }
113
+ return lo + 1;
114
+ };
115
+ return writes
116
+ .filter((w) => !covered.has(w.at))
117
+ .map((w) => ({ line: lineOf(w.at), kind: w.kind }))
118
+ .sort((a, b) => a.line - b.line);
119
+ }
120
+ const SOURCE = /\.(ts|tsx|js|mjs)$/;
121
+ const MAX_BYTES = 1_000_000; // a bigger "source" file is generated or hostile: skipped, and said so
122
+ /** The source files under `dir`, relative to it. Symlinks are never followed (a link out of the tree, or a loop). */
123
+ function sources(dir, rel = "") {
124
+ const out = [];
125
+ for (const d of readdirSync(join(dir, rel), { withFileTypes: true })) {
126
+ if (d.isSymbolicLink() || d.name === "node_modules")
127
+ continue;
128
+ const path = rel ? join(rel, d.name) : d.name;
129
+ if (d.isDirectory())
130
+ out.push(...sources(dir, path));
131
+ else if (d.isFile() && SOURCE.test(d.name))
132
+ out.push(path);
133
+ }
134
+ return out;
135
+ }
136
+ /** Lint supabase/functions/** under `cwd`; prints file:line per finding. 1 = findings, 2 = no functions folder. */
137
+ export function runLint(cwd, log) {
138
+ const root = join(cwd, "supabase", "functions");
139
+ if (!existsSync(root)) {
140
+ log("No supabase/functions folder here — run this from your Supabase project's root.");
141
+ return 2;
142
+ }
143
+ const files = sources(root).sort();
144
+ let found = 0;
145
+ for (const f of files) {
146
+ const full = join(root, f);
147
+ if (statSync(full).size > MAX_BYTES) {
148
+ log(`${relative(cwd, full)}: skipped (over 1 MB)`);
149
+ continue;
150
+ }
151
+ for (const x of lintSource(readFileSync(full, "utf8"))) {
152
+ found++;
153
+ log(`${relative(cwd, full)}:${x.line} ${x.kind} without a check() before it`);
154
+ }
155
+ }
156
+ if (found) {
157
+ log(`\n${found} write(s) without a check() line. Add sb.check("<schema>.<table>", rows) before each one.`);
158
+ return 1;
159
+ }
160
+ log(`No unchecked writes in ${files.length} file(s).`);
161
+ return 0;
162
+ }
@@ -0,0 +1,171 @@
1
+ // `npx sodabase install-mcp` — the hub's "Install MCP for your agent" step as a one-shot subcommand:
2
+ // no sign-in, no fullscreen, just the agent checkbox list (agentPicker.tsx) unless --agent is given. Runs the same add-mcp + skills installs as the wizard
3
+ // (Services.installMcp / installSkill) and prints a plain summary. Sign-in isn't needed here: the MCP server
4
+ // runs its own OAuth the first time the agent calls it.
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { homedir } from "node:os";
7
+ import { join } from "node:path";
8
+ import { MCP_URL, SKILL_REF } from "./api/client.js";
9
+ // These ids are forwarded verbatim to BOTH `add-mcp -a` and `skills -a` (see client.ts).
10
+ // Keep every id in this list valid for both CLIs — all three are today; an id only one of
11
+ // them knows would make that tool's install fail (non-fatal, but all-or-nothing for skills).
12
+ // It's also the allowlist for --agent: on Windows the installs spawn through a shell, so a
13
+ // user-supplied id must never reach argv unchecked.
14
+ export const MCP_AGENTS = ["claude-code", "cursor", "codex"];
15
+ const FALLBACK_AGENTS = ["claude-code"];
16
+ // Where each agent leaves its config once installed — used to pick targets when no --agent is given.
17
+ const AGENT_MARKERS = {
18
+ "claude-code": [".claude.json", ".claude"],
19
+ cursor: [".cursor"],
20
+ codex: [".codex"],
21
+ };
22
+ /** The supported agents that look installed under `home` (any marker present). */
23
+ export function detectAgents(home = homedir(), exists = existsSync) {
24
+ return MCP_AGENTS.filter((a) => AGENT_MARKERS[a].some((m) => exists(join(home, m))));
25
+ }
26
+ // The global MCP config add-mcp writes for each agent, how to spot OUR entry in it (name + current URL, so a
27
+ // stale `sodabase` entry pointing at an old/dev host gets refreshed), and where `skills` puts the skill.
28
+ // The substring check first skips parsing a large `~/.claude.json` when our URL isn't in it at all.
29
+ const hasJsonEntry = (text) => text.includes(MCP_URL) &&
30
+ JSON.parse(text).mcpServers?.sodabase?.url === MCP_URL;
31
+ // Line by line, not one regex: our table's keys run from `[mcp_servers.sodabase]` to the next table header, a
32
+ // value may itself contain `[` (`args = ["x"]`), and a `url` under a subtable (`[mcp_servers.sodabase.env]`) isn't ours.
33
+ export const TOML_HEADER = /^\s*\[\[?\s*([^\]]+?)\s*\]\]?\s*(#.*)?$/;
34
+ const TOML_URL = /^\s*url\s*=\s*(["'])(.*?)\1\s*(#.*)?$/;
35
+ function hasTomlEntry(text) {
36
+ let ours = false;
37
+ for (const line of text.split(/\r?\n/)) {
38
+ const header = TOML_HEADER.exec(line);
39
+ if (header)
40
+ ours = header[1] === "mcp_servers.sodabase";
41
+ else if (ours && TOML_URL.exec(line)?.[2] === MCP_URL)
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ // Each agent's global skills dir, as the `skills` CLI (1.7.x) has it: Cursor reads its own, Codex the shared one.
47
+ const SKILL_DIR = join("skills", "sodabase-trust-advisor", "SKILL.md");
48
+ const MCP_CONFIGS = {
49
+ "claude-code": { file: ".claude.json", has: hasJsonEntry, skill: join(".claude", SKILL_DIR) },
50
+ cursor: { file: join(".cursor", "mcp.json"), has: hasJsonEntry, skill: join(".cursor", SKILL_DIR) },
51
+ codex: { file: join(".codex", "config.toml"), has: hasTomlEntry, skill: join(".agents", SKILL_DIR) },
52
+ };
53
+ /**
54
+ * The agents (of `among`) already fully set up: a `sodabase` MCP entry at the current URL in their global
55
+ * config, plus the trust-advisor skill when `skill` is wanted (so a missing skill still gets installed).
56
+ * Unreadable/malformed config = not set up.
57
+ */
58
+ export function installedAgents(home = homedir(), skill = true, read = (p) => readFileSync(p, "utf8"), exists = existsSync, among = MCP_AGENTS) {
59
+ return MCP_AGENTS.filter((a) => among.includes(a)).filter((a) => {
60
+ const c = MCP_CONFIGS[a];
61
+ try {
62
+ return c.has(read(join(home, c.file))) && (!skill || exists(join(home, c.skill)));
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Explicit --agent/--all wins (reinstalling is harmless). Otherwise every detected agent that doesn't have
71
+ * the MCP yet — empty when they all do — falling back to Claude Code when no agent is detected at all.
72
+ */
73
+ export function resolveAgents(explicit, detected, installed = []) {
74
+ if (explicit.length)
75
+ return { agents: explicit, detected: false };
76
+ if (!detected.length)
77
+ return { agents: FALLBACK_AGENTS, detected: false };
78
+ return { agents: detected.filter((a) => !installed.includes(a)), detected: true };
79
+ }
80
+ export const INSTALL_MCP_HELP = [
81
+ "sodabase install-mcp — install the Sodabase MCP + trust-advisor skill for your coding agent",
82
+ "",
83
+ "Usage: npx sodabase install-mcp [options]",
84
+ "",
85
+ "Options:",
86
+ ` -a, --agent <id> agent to install for; repeat or comma-separate`,
87
+ ` one of: ${MCP_AGENTS.join(", ")}`,
88
+ " --all install for every supported agent",
89
+ " --no-skill install only the MCP, skip the trust-advisor skill",
90
+ " --no-input don't show the agent checkbox list",
91
+ " --help, -h show this help",
92
+ "",
93
+ "Without --agent, shows a checkbox list with the agents found on this machine ticked, except",
94
+ "those that already have the MCP (claude-code if none found). Without a terminal (or with",
95
+ "--no-input), installs for those directly.",
96
+ "",
97
+ "No sign-in needed: your agent signs in to Sodabase the first time it uses the MCP.",
98
+ "",
99
+ ].join("\n");
100
+ /** Parse the args AFTER `install-mcp`. Returns the options, or an error message for bad input. */
101
+ export function parseInstallMcpArgs(argv) {
102
+ // --help wins over everything else on the line, including bad options.
103
+ if (argv.some((a) => a === "--help" || a === "-h"))
104
+ return { agents: [], skill: true, help: true, input: true };
105
+ const agents = [];
106
+ let skill = true;
107
+ let input = true;
108
+ for (let i = 0; i < argv.length; i++) {
109
+ const arg = argv[i];
110
+ if (arg === "--no-skill")
111
+ skill = false;
112
+ else if (arg === "--no-input")
113
+ input = false;
114
+ else if (arg === "--all")
115
+ agents.push(...MCP_AGENTS);
116
+ else if (arg === "-a" || arg === "--agent") {
117
+ const value = argv[++i];
118
+ if (!value || value.startsWith("-"))
119
+ return { error: `${arg} needs an agent id (${MCP_AGENTS.join(", ")})` };
120
+ agents.push(...value.split(","));
121
+ }
122
+ else if (arg.startsWith("--agent=")) {
123
+ const value = arg.slice("--agent=".length);
124
+ // An empty value (e.g. an unset $AGENT) must fail like `-a` with no value, not fall back to auto-detect.
125
+ if (!value.split(",").some((v) => v.trim()))
126
+ return { error: `--agent needs an agent id (${MCP_AGENTS.join(", ")})` };
127
+ agents.push(...value.split(","));
128
+ }
129
+ else
130
+ return { error: `unknown option: ${arg}` };
131
+ }
132
+ const ids = [...new Set(agents.map((a) => a.trim()).filter(Boolean))];
133
+ const unknown = ids.filter((a) => !MCP_AGENTS.includes(a));
134
+ if (unknown.length)
135
+ return { error: `unknown agent: ${unknown.join(", ")} (supported: ${MCP_AGENTS.join(", ")})` };
136
+ return { agents: ids, skill, help: false, input };
137
+ }
138
+ /** Run the install and print the outcome. Returns the process exit code (1 only if the MCP itself failed). */
139
+ export async function runInstallMcp(services, opts, out) {
140
+ out(`Installing the Sodabase MCP for ${opts.agents.join(", ")}${opts.detected ? " (found on this machine)" : ""}…`);
141
+ try {
142
+ const r = await services.installMcp(opts.agents);
143
+ out(`Ran: ${r.command}`);
144
+ for (const w of r.wrote)
145
+ out(` ✔ ${w.agent} → ${w.path}${opts.installed?.includes(w.agent) ? " (was already set up, refreshed)" : ""}`);
146
+ }
147
+ catch (e) {
148
+ out(`Couldn't auto-install the MCP: ${e instanceof Error ? e.message : String(e)}`);
149
+ out("Add it yourself:");
150
+ for (const a of opts.agents)
151
+ out(a === "claude-code"
152
+ ? ` claude mcp add --scope user --transport http sodabase ${MCP_URL}`
153
+ : ` npx add-mcp ${MCP_URL} -g -a ${a}`);
154
+ return 1;
155
+ }
156
+ // Same contract as the wizard: the MCP is the main thing, so a skill failure warns with a manual
157
+ // fallback but doesn't fail the command.
158
+ if (opts.skill) {
159
+ try {
160
+ await services.installSkill(opts.agents);
161
+ out(` ✔ trust-advisor skill → ${SKILL_REF}`);
162
+ }
163
+ catch (e) {
164
+ out(`Couldn't install the trust-advisor skill: ${e instanceof Error ? e.message : String(e)}`);
165
+ out("Add it yourself:");
166
+ out(` npx skills add ${SKILL_REF}`);
167
+ }
168
+ }
169
+ out("Ready next time you restart your agent.");
170
+ return 0;
171
+ }
@@ -0,0 +1,181 @@
1
+ // `npx sodabase rules pull --project <ref>` — fetch the project's pipeline rules file (the backend's generator, the
2
+ // same one the MCP `pipeline_rules` tool uses), save it as supabase/functions/_shared/sodabase.rules.yml, and make sure
3
+ // every function lists it in `static_files` in supabase/config.toml (planning repo edge-function-writes-mvp-spec §5.3).
4
+ // shortcut: line-based TOML edit, not a parser (no deps); upgrade if config.toml shapes defeat it.
5
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
6
+ import { dirname, join, relative } from "node:path";
7
+ import { TOML_HEADER } from "./installMcp.js";
8
+ export const RULES_FILE = join("supabase", "functions", "_shared", "sodabase.rules.yml");
9
+ export const STATIC_PATH = "./functions/_shared/sodabase.rules.yml"; // relative to supabase/, as config.toml has it
10
+ export const RULES_PULL_HELP = [
11
+ "sodabase rules pull — save the project's pipeline rules file and list it in each function's static_files",
12
+ "",
13
+ "Usage: npx sodabase rules pull --project <ref>",
14
+ "",
15
+ "Options:",
16
+ " --project <ref> your 20-character Supabase project ref",
17
+ " --help, -h show this help",
18
+ "",
19
+ "Run it from your Supabase project's root, signed in (`npx sodabase --login`) as a workspace owner or admin.",
20
+ "",
21
+ ].join("\n");
22
+ /** Parse the args AFTER `rules pull`. Returns the project ref (or help), or an error message for bad input. */
23
+ export function parseRulesPullArgs(argv) {
24
+ if (argv.some((a) => a === "--help" || a === "-h"))
25
+ return { project: "", help: true };
26
+ let project;
27
+ for (let i = 0; i < argv.length; i++) {
28
+ const arg = argv[i];
29
+ if (arg === "--project")
30
+ project = argv[++i];
31
+ else if (arg.startsWith("--project="))
32
+ project = arg.slice("--project=".length);
33
+ else
34
+ return { error: `unknown option: ${arg}` };
35
+ }
36
+ if (!project || !/^[a-z0-9]{20}$/.test(project))
37
+ return { error: "--project <ref> is required (your 20-character project ref)" };
38
+ return { project, help: false };
39
+ }
40
+ /** The index just past the `]` that closes the first `[` at or after `from` (quotes respected), or -1. */
41
+ function closeOf(line, from) {
42
+ let depth = 0;
43
+ let quote = "";
44
+ for (let i = from; i < line.length; i++) {
45
+ const c = line[i];
46
+ if (quote) {
47
+ if (c === "\\" && quote === '"')
48
+ i++;
49
+ else if (c === quote)
50
+ quote = "";
51
+ }
52
+ else if (c === '"' || c === "'")
53
+ quote = c;
54
+ else if (c === "#")
55
+ return -1;
56
+ else if (c === "[")
57
+ depth++;
58
+ else if (c === "]" && --depth === 0)
59
+ return i;
60
+ }
61
+ return -1;
62
+ }
63
+ function sectionOf(key, fn) {
64
+ return key === `functions.${fn}` || key === `functions."${fn}"` || key === `functions.'${fn}'`;
65
+ }
66
+ /** Add `path` to each function's `static_files` (adding the key or the `[functions.<fn>]` section when missing).
67
+ * Every other line is left byte-identical. `changed` names the functions whose config moved. */
68
+ export function ensureStaticFiles(toml, functions, path = STATIC_PATH) {
69
+ const eol = toml.includes("\r\n") ? "\r\n" : "\n";
70
+ const lines = toml.split(eol);
71
+ const entry = JSON.stringify(path);
72
+ const listed = (s) => s.includes(entry) || s.includes(`'${path}'`);
73
+ const changed = [];
74
+ for (const fn of functions) {
75
+ const start = lines.findIndex((l) => {
76
+ const h = TOML_HEADER.exec(l);
77
+ return !!h && !l.trim().startsWith("[[") && sectionOf(h[1], fn);
78
+ });
79
+ if (start === -1) {
80
+ const at = lines.length && lines[lines.length - 1] === "" ? lines.length - 1 : lines.length;
81
+ const add = [`[functions.${fn}]`, `static_files = [${entry}]`];
82
+ if (at > 0 && lines[at - 1].trim() !== "")
83
+ add.unshift("");
84
+ lines.splice(at, 0, ...add);
85
+ changed.push(fn);
86
+ continue;
87
+ }
88
+ let end = lines.findIndex((l, i) => i > start && TOML_HEADER.test(l));
89
+ if (end === -1)
90
+ end = lines.length;
91
+ const key = lines.findIndex((l, i) => i > start && i < end && /^\s*static_files\s*=/.test(l));
92
+ if (key === -1) {
93
+ lines.splice(start + 1, 0, `static_files = [${entry}]`);
94
+ changed.push(fn);
95
+ continue;
96
+ }
97
+ // the array runs from `key` to the line holding its closing `]`
98
+ let close = key;
99
+ let at = closeOf(lines[key], lines[key].indexOf("="));
100
+ if (at === -1) {
101
+ close = lines.findIndex((l, i) => i > key && i < end && /^[^#]*\]/.test(l) && !/^\s*#/.test(l));
102
+ if (close === -1)
103
+ continue; // shapes we don't understand stay untouched
104
+ at = lines[close].indexOf("]");
105
+ }
106
+ if (listed(lines.slice(key, close + 1).join(eol)))
107
+ continue;
108
+ const line = lines[close];
109
+ const before = line.slice(0, at);
110
+ if (close === key || before.trim() !== "") {
111
+ // `static_files = ["a"]` / `= []` / ` "b" ]`: insert before the `]`
112
+ const head = before.replace(/\s*$/, "");
113
+ const sep = head.endsWith("[") ? "" : head.endsWith(",") ? " " : ", ";
114
+ lines[close] = `${head}${sep}${entry}${line.slice(at)}`;
115
+ }
116
+ else {
117
+ // multi-line with `]` on its own line: a new element line before it (and a comma after the previous one)
118
+ let prev = close - 1;
119
+ while (prev > key && (lines[prev].trim() === "" || lines[prev].trim().startsWith("#")))
120
+ prev--;
121
+ const indent = prev > key ? /^\s*/.exec(lines[prev])[0] : " ";
122
+ if (prev > key && !/,\s*(#.*)?$/.test(lines[prev]))
123
+ lines[prev] = lines[prev].replace(/\s*(#.*)?$/, (m) => `,${m}`);
124
+ lines.splice(close, 0, `${indent}${entry},`);
125
+ }
126
+ changed.push(fn);
127
+ }
128
+ return { text: lines.join(eol), changed };
129
+ }
130
+ /** True when `path` exists and is a symlink (a cloned repo can plant one to redirect our writes). */
131
+ function isLink(path) {
132
+ try {
133
+ return lstatSync(path).isSymbolicLink();
134
+ }
135
+ catch {
136
+ return false;
137
+ }
138
+ }
139
+ /** The deployable functions: the folders under supabase/functions not starting with `_` or `.`. */
140
+ export function functionDirs(cwd) {
141
+ const root = join(cwd, "supabase", "functions");
142
+ if (!existsSync(root))
143
+ return [];
144
+ return readdirSync(root, { withFileTypes: true })
145
+ // the backend's function-name rule: anything else (`a.b`, `x]`, a newline) would break or inject into config.toml
146
+ .filter((d) => d.isDirectory() && !/^[_.]/.test(d.name) && /^[A-Za-z0-9_-]{1,64}$/.test(d.name))
147
+ .map((d) => d.name)
148
+ .sort();
149
+ }
150
+ /** Write the rules file + the static_files entries; prints what changed. 0 ok, 1 no supabase/config.toml here. */
151
+ export async function runRulesPull(ref, fetchRules, cwd, log) {
152
+ const config = join(cwd, "supabase", "config.toml");
153
+ if (!existsSync(config)) {
154
+ log("No supabase/config.toml here — run this from your Supabase project's root.");
155
+ return 1;
156
+ }
157
+ const rules = join(cwd, RULES_FILE); // never a path from the server
158
+ const linked = [join(cwd, "supabase"), dirname(dirname(rules)), dirname(rules), rules, config].find(isLink);
159
+ if (linked) {
160
+ log(`${relative(cwd, linked) || linked} is a symlink — refusing to write through it. Replace it with a real file or folder.`);
161
+ return 1;
162
+ }
163
+ const { content } = await fetchRules(ref);
164
+ const old = existsSync(rules) ? readFileSync(rules, "utf8") : null;
165
+ mkdirSync(dirname(rules), { recursive: true });
166
+ writeFileSync(rules, content);
167
+ log(`${old === null ? "Created" : old === content ? "Unchanged" : "Updated"} ${RULES_FILE}`);
168
+ const fns = functionDirs(cwd);
169
+ const { text, changed } = ensureStaticFiles(readFileSync(config, "utf8"), fns);
170
+ if (changed.length) {
171
+ writeFileSync(config, text);
172
+ for (const fn of changed)
173
+ log(`Added ${STATIC_PATH} to static_files for [functions.${fn}] in supabase/config.toml`);
174
+ }
175
+ else if (fns.length)
176
+ log(`supabase/config.toml already ships it for ${fns.length} function(s).`);
177
+ else
178
+ log("No functions under supabase/functions yet — run this again once you add one.");
179
+ log("Review the diff and commit both files; deploy your functions to use the new rules.");
180
+ return 0;
181
+ }
package/dist/ui.js CHANGED
@@ -4,6 +4,9 @@ import { createRequire } from "node:module";
4
4
  import React, { createContext, useContext, useEffect, useRef, useState } from "react";
5
5
  import { ApiError, anomalyCount, totalIssues } from "./api/types.js";
6
6
  import { saveCreds } from "./config/tokenStore.js";
7
+ import { AgentChecklist, useAgentChecklist } from "./agentPicker.js";
8
+ import { MCP_URL } from "./api/client.js";
9
+ import { detectAgents, installedAgents as agentsSetUp, resolveAgents } from "./installMcp.js";
7
10
  // ── utils ─────────────────────────────────────────────────────────────────────
8
11
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
9
12
  function useSpinner() {
@@ -711,14 +714,16 @@ export function ScopeAdjust({ onDone }) {
711
714
  })()) })] }));
712
715
  }
713
716
  // ── Phase: consented in-flow MCP install ─────────────────────────────────────────
714
- // These ids are forwarded verbatim to BOTH `add-mcp -a` and `skills -a` (see client.ts).
715
- // Keep every id in this list valid for both CLIs — all three are today; an id only one of
716
- // them knows would make that tool's install fail (non-fatal, but all-or-nothing for skills).
717
- const AGENTS = ["claude-code", "cursor", "codex"];
717
+ // Same agents, preselection and checkbox list as `install-mcp` (see installMcp.ts / agentPicker.tsx).
718
718
  export function McpInstall({ onDone }) {
719
719
  const { services, fast, interactive } = useWizard();
720
- const [sel, setSel] = useState([true, false, false]);
721
- const [cursor, setCursor] = useState(0);
720
+ // Ticked to start: the agents found on this machine that don't have the MCP yet (claude-code if none found).
721
+ const [local] = useState(() => {
722
+ const found = detectAgents();
723
+ const installed = agentsSetUp();
724
+ return { found, installed, preselected: resolveAgents([], found, installed).agents };
725
+ });
726
+ const list = useAgentChecklist(local.preselected);
722
727
  const [result, setResult] = useState(null);
723
728
  const [skillResult, setSkillResult] = useState(null);
724
729
  const [skillError, setSkillError] = useState(null);
@@ -802,22 +807,14 @@ export function McpInstall({ onDone }) {
802
807
  onDone({ installed: [] });
803
808
  return;
804
809
  }
805
- if (key.upArrow)
806
- setCursor((c) => Math.max(0, c - 1));
807
- else if (key.downArrow)
808
- setCursor((c) => Math.min(AGENTS.length - 1, c + 1));
809
- else if (input === " ")
810
- setSel((s) => s.map((v, i) => (i === cursor ? !v : v)));
811
- else if (input === "n")
810
+ if (list.handleKey(input, key))
811
+ return;
812
+ if (input === "n")
812
813
  void run([]);
813
814
  else if (key.return)
814
- void run(AGENTS.filter((_, i) => sel[i]));
815
+ void run(list.picked());
815
816
  }, { isActive: interactive && !busy && (!result || skillError !== null || ready) });
816
- 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) => {
817
- const on = sel[i];
818
- const here = interactive && i === cursor;
819
- return (_jsxs(Text, { color: on ? "green" : undefined, dimColor: !on, children: [here ? "❯ " : " ", on ? "[x]" : "[ ]", " ", a] }, a));
820
- }) })] }))] }));
817
+ 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 ", MCP_URL] }), 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, children: _jsx(AgentChecklist, { sel: list.sel, cursor: interactive ? list.cursor : null, found: local.found, installed: local.installed }) })] }))] }));
821
818
  }
822
819
  // ── Phase: manage projects (the hub's "Manage projects" entry) ───────────────────
823
820
  // A picker over the projects already being watched; selecting one drills into its watched tables.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sodabase",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Sodabase onboarding wizard — interactive CLI (npx sodabase).",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://sodabase.io",
@@ -26,7 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "bin": {
29
- "sodabase": "dist/cli.js"
29
+ "sodabase": "./dist/cli.js"
30
30
  },
31
31
  "files": [
32
32
  "dist"