sodabase 0.1.12 → 0.1.13
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/dist/api/client.js +1 -1
- package/dist/api/fakeClient.js +1 -1
- package/dist/cli.js +2 -4
- package/dist/config/tokenStore.js +44 -7
- package/dist/login.js +5 -3
- package/dist/ui.js +2 -2
- package/package.json +3 -3
package/dist/api/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ApiError, } from "./types.js";
|
|
|
10
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
11
|
export const MCP_URL = `${(process.env.SODABASE_API_URL ?? "https://sodabase.io").replace(/\/$/, "")}/mcp`;
|
|
12
12
|
/** The trust-advisor skill repo, resolved by the `skills` CLI (owner/repo on its default branch). */
|
|
13
|
-
export const SKILL_REF = "
|
|
13
|
+
export const SKILL_REF = "labs-soda/agent-skills";
|
|
14
14
|
/** An error thrown when `connect()`'s poll is aborted (the user left the connect screen). */
|
|
15
15
|
const abortedError = () => new ApiError("connect aborted", 499, "aborted");
|
|
16
16
|
/** Pull the `email` claim out of a GoTrue JWT without verifying it (display only — the server already
|
package/dist/api/fakeClient.js
CHANGED
|
@@ -162,6 +162,6 @@ export class FakeClient {
|
|
|
162
162
|
}
|
|
163
163
|
async installSkill(agents) {
|
|
164
164
|
await this.tick(500);
|
|
165
|
-
return { command: `npx skills add
|
|
165
|
+
return { command: `npx skills add labs-soda/agent-skills -g ${agents.map((a) => "-a " + a).join(" ")}` };
|
|
166
166
|
}
|
|
167
167
|
}
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { render } from "ink";
|
|
4
4
|
import { rmSync } from "node:fs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
|
-
import { homedir } from "node:os";
|
|
7
6
|
import { join } from "node:path";
|
|
8
7
|
import { SodabaseClient } from "./api/client.js";
|
|
9
8
|
import { FakeClient } from "./api/fakeClient.js";
|
|
@@ -11,7 +10,7 @@ import { pickAgents } from "./agentPicker.js";
|
|
|
11
10
|
import { App } from "./app.js";
|
|
12
11
|
import { refreshSession, resolveGoTrueConfig } from "./api/gotrueAuth.js";
|
|
13
12
|
import { parseHelpOnly } from "./args.js";
|
|
14
|
-
import { clearCreds, freshCreds } from "./config/tokenStore.js";
|
|
13
|
+
import { clearCreds, configDir, freshCreds } from "./config/tokenStore.js";
|
|
15
14
|
import { FUNCTIONS_LINT_HELP, runLint } from "./functionsLint.js";
|
|
16
15
|
import { INSTALL_MCP_HELP, detectAgents, installedAgents, parseInstallMcpArgs, resolveAgents, runInstallMcp, } from "./installMcp.js";
|
|
17
16
|
import { LOGIN_HELP, LOGIN_NEEDS_TERMINAL, NOT_SIGNED_IN, loginOutcome } from "./login.js";
|
|
@@ -218,8 +217,7 @@ if (args.has("--logout")) {
|
|
|
218
217
|
// (tokens live in credentials.json, cleared above), but a clean sign-out shouldn't leave a file
|
|
219
218
|
// naming your last project on disk. Nothing writes it anymore, so this only ever cleans up.
|
|
220
219
|
try {
|
|
221
|
-
|
|
222
|
-
rmSync(join(base, "sodabase", "progress.json"));
|
|
220
|
+
rmSync(join(configDir(), "progress.json"));
|
|
223
221
|
}
|
|
224
222
|
catch {
|
|
225
223
|
/* already gone */
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// dep-free (no native keychain module). Documented tradeoff: less hardened than an OS
|
|
3
3
|
// keychain, but no node-gyp/platform build and no new dependency. Can move to a keychain
|
|
4
4
|
// later if warranted.
|
|
5
|
-
import { chmodSync, closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeSync } from "node:fs";
|
|
5
|
+
import { chmodSync, closeSync, fsyncSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, rmSync, writeSync } from "node:fs";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
8
|
import { ApiError } from "../api/types.js";
|
|
@@ -10,9 +10,29 @@ import { ApiError } from "../api/types.js";
|
|
|
10
10
|
export function isSignedIn(creds) {
|
|
11
11
|
return !!creds?.accessToken?.startsWith("eyJ") && (!creds.expiresAt || creds.expiresAt > Date.now() + 60_000);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return join(
|
|
13
|
+
/** Where the CLI keeps its files: `$XDG_CONFIG_HOME/sodabase`, else `~/.config/sodabase`. */
|
|
14
|
+
export function configDir() {
|
|
15
|
+
return join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "sodabase");
|
|
16
|
+
}
|
|
17
|
+
export function credsPath() {
|
|
18
|
+
return join(configDir(), "credentials.json");
|
|
19
|
+
}
|
|
20
|
+
// Windows refuses to replace a file another process has open (an antivirus scan, a second run reading it) with one of
|
|
21
|
+
// these; it clears within moments, so the rename is retried a few times before giving up.
|
|
22
|
+
const RENAME_BUSY = new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
23
|
+
function renameRetrying(from, to) {
|
|
24
|
+
for (let attempt = 1;; attempt++) {
|
|
25
|
+
try {
|
|
26
|
+
renameSync(from, to);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
const code = e?.code;
|
|
31
|
+
if (process.platform !== "win32" || attempt === 5 || typeof code !== "string" || !RENAME_BUSY.has(code))
|
|
32
|
+
throw e;
|
|
33
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 25 * attempt);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
16
36
|
}
|
|
17
37
|
export function loadCreds() {
|
|
18
38
|
try {
|
|
@@ -38,7 +58,7 @@ export function saveCreds(creds) {
|
|
|
38
58
|
closeSync(fd);
|
|
39
59
|
}
|
|
40
60
|
chmodSync(tmp, 0o600); // enforce even if a stale temp file pre-existed with looser perms
|
|
41
|
-
|
|
61
|
+
renameRetrying(tmp, path);
|
|
42
62
|
}
|
|
43
63
|
catch (e) {
|
|
44
64
|
rmSync(tmp, { force: true });
|
|
@@ -84,11 +104,28 @@ export async function freshCreds(refresh, opts = {}) {
|
|
|
84
104
|
}
|
|
85
105
|
return saved;
|
|
86
106
|
}
|
|
107
|
+
/** Sign out: the creds file, and any temp copy a run killed mid-save left beside it (it holds the same tokens).
|
|
108
|
+
* Best-effort, as before: a file another process holds open (Windows) stays rather than crashing the sign-out. */
|
|
87
109
|
export function clearCreds() {
|
|
110
|
+
const path = credsPath();
|
|
111
|
+
const rm = (p) => {
|
|
112
|
+
try {
|
|
113
|
+
rmSync(p, { force: true });
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
/* held open: leave it */
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
rm(path);
|
|
120
|
+
let names = [];
|
|
88
121
|
try {
|
|
89
|
-
|
|
122
|
+
names = readdirSync(dirname(path));
|
|
90
123
|
}
|
|
91
124
|
catch {
|
|
92
|
-
|
|
125
|
+
return; // no config folder: nothing saved
|
|
93
126
|
}
|
|
127
|
+
const tmp = /^credentials\.json\.\d+\.tmp$/;
|
|
128
|
+
for (const n of names)
|
|
129
|
+
if (tmp.test(n))
|
|
130
|
+
rm(join(dirname(path), n));
|
|
94
131
|
}
|
package/dist/login.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// `npx sodabase login` — sign in (browser or email code), save the session, and exit: no setup wizard. For an agent
|
|
2
2
|
// or a script that only needs a session before `rules pull`. Sign-in is interactive, so it refuses to start without
|
|
3
3
|
// a terminal on stdin (an agent's shell) and says where to run it instead.
|
|
4
|
+
import { credsPath } from "./config/tokenStore.js";
|
|
4
5
|
export const LOGIN_HELP = [
|
|
5
6
|
"sodabase login — sign in to Sodabase, save the session, and exit (no setup wizard)",
|
|
6
7
|
"",
|
|
@@ -10,8 +11,9 @@ export const LOGIN_HELP = [
|
|
|
10
11
|
" --help, -h show this help",
|
|
11
12
|
"",
|
|
12
13
|
"Sign-in opens your browser (or emails you a code), so run it in a terminal window of your own: a coding",
|
|
13
|
-
"agent's shell can't answer the prompts. The session is saved
|
|
14
|
-
"so other commands (e.g. `npx sodabase rules pull --project
|
|
14
|
+
"agent's shell can't answer the prompts. The session is saved in your config folder (~/.config/sodabase, or",
|
|
15
|
+
"$XDG_CONFIG_HOME/sodabase) and renews itself, so other commands (e.g. `npx sodabase rules pull --project",
|
|
16
|
+
"<ref>`) keep working without signing in again.",
|
|
15
17
|
"",
|
|
16
18
|
].join("\n");
|
|
17
19
|
export const LOGIN_NEEDS_TERMINAL = [
|
|
@@ -31,7 +33,7 @@ export function loginOutcome(saved) {
|
|
|
31
33
|
if (saved === false) {
|
|
32
34
|
return {
|
|
33
35
|
code: 1,
|
|
34
|
-
stderr:
|
|
36
|
+
stderr: `sodabase login: you signed in, but your session couldn't be saved to ${credsPath()}. ` +
|
|
35
37
|
"Check that the folder is writable, then run `npx sodabase login` again.\n",
|
|
36
38
|
};
|
|
37
39
|
}
|
package/dist/ui.js
CHANGED
|
@@ -482,7 +482,7 @@ export function Connect({ onDone }) {
|
|
|
482
482
|
return;
|
|
483
483
|
// A Sodabase-auth failure (expired session) won't be fixed by the Supabase browser flow — surface it.
|
|
484
484
|
if (e instanceof ApiError && e.status === 401) {
|
|
485
|
-
setError("Your Sodabase session has expired. Run `sodabase
|
|
485
|
+
setError("Your Sodabase session has expired. Run `npx sodabase login`, then try again.");
|
|
486
486
|
return;
|
|
487
487
|
}
|
|
488
488
|
// Anything else (offline / 5xx): fall through to authorize, which surfaces its own errors.
|
|
@@ -817,7 +817,7 @@ export function McpInstall({ onDone }) {
|
|
|
817
817
|
else if (key.return)
|
|
818
818
|
void run(list.picked());
|
|
819
819
|
}, { isActive: interactive && !busy && (!result || skillError !== null || ready) });
|
|
820
|
-
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
|
|
820
|
+
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 labs-soda/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 labs-soda/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
821
|
}
|
|
822
822
|
// ── Phase: manage projects (the hub's "Manage projects" entry) ───────────────────
|
|
823
823
|
// 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.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Sodabase onboarding wizard — interactive CLI (npx sodabase).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://sodabase.io",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"ink": "7.1.1",
|
|
49
|
-
"react": "19.
|
|
49
|
+
"react": "19.3.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "22.20.5",
|
|
53
|
-
"@types/react": "19.
|
|
53
|
+
"@types/react": "19.3.0",
|
|
54
54
|
"typescript": "5.9.3"
|
|
55
55
|
}
|
|
56
56
|
}
|