layerbase 0.4.2 → 1.0.0

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
@@ -3,13 +3,16 @@
3
3
  [![npm version](https://img.shields.io/npm/v/layerbase.svg)](https://www.npmjs.com/package/layerbase)
4
4
  [![license](https://img.shields.io/npm/l/layerbase.svg)](https://www.npmjs.com/package/layerbase)
5
5
 
6
- The Layerbase cloud CLI: connect to your managed cloud databases with their
7
- native clients, drop into local [spindb](https://github.com/robertjbass/spindb),
8
- and never paste a connection string into your shell history.
6
+ The Layerbase CLI is **local-first**: it is a drop-in for
7
+ [spindb](https://github.com/robertjbass/spindb) for local database work, plus a
8
+ `cloud` layer for your managed **Layerbase cloud** account. Connect with native
9
+ clients, drop into spindb, and never paste a connection string into your shell
10
+ history.
9
11
 
10
- `layerbase` is the bridge between **spindb** (the open-source local database
11
- manager) and your **Layerbase cloud** account. Think `flyctl` / `heroku` /
12
- `neonctl`, but it also wraps spindb for local work.
12
+ **The bare command namespace belongs to spindb.** Any command that is not one of
13
+ layerbase's own verbs forwards straight to your local spindb install, verbatim,
14
+ so `lbase create / ls / start / backup / branch ...` behave exactly like
15
+ `spindb <same>`. Cloud database commands live under `lbase cloud <verb>`.
13
16
 
14
17
  ## Install
15
18
 
@@ -27,53 +30,75 @@ This installs two commands, `layerbase` and a shorter `lbase`. For a two-letter
27
30
  ## Quick start
28
31
 
29
32
  ```bash
30
- layerbase # open the interactive menu
31
- layerbase login # sign in through your browser
32
- layerbase ls # list your cloud databases
33
- layerbase psql my-db # connect with the right client, no password typed
33
+ lbase # spindb's interactive menu (local databases)
34
+ lbase create my-db --engine postgres # any spindb command, verbatim
35
+ lbase login # sign in through your browser
36
+ lbase cloud ls # list your cloud databases
37
+ lbase psql my-cloud-db # connect with the right client, no password typed
34
38
  ```
35
39
 
36
- ## Commands
40
+ ## Local databases (drop-in for spindb)
37
41
 
38
- | Command | Description |
39
- | --- | --- |
40
- | `layerbase` | Interactive menu: a hub to sign in, list, connect, and run spindb. |
41
- | `layerbase login` | Sign in via the browser; stores a token in `~/.layerbase-cli`. |
42
- | `layerbase logout` | Remove the stored credentials. |
43
- | `layerbase whoami` | Show the signed-in account and token expiry (`--json`). |
44
- | `layerbase ls` | List your cloud databases (`--json` for scripting). |
45
- | `layerbase connect <db>` | Connect with the engine's native client. |
46
- | `layerbase psql <db>` | Connect to a Postgres-family database. |
47
- | `layerbase redis-cli <db>` | Connect to a Redis / Valkey database. |
48
- | `layerbase mysql <db>` | Connect to a MySQL / MariaDB database. |
49
- | `layerbase connection-string <db>` | Print the connection string (reveals the password). |
50
- | `layerbase spindb [args...]` | Run the local spindb CLI (passes args through). |
51
- | `layerbase alias` | Set up the short `lb` command (only if it is free). |
52
-
53
- `<db>` accepts a cloud database id or its name. Add `--print` to `connect` to
54
- show the connection details instead of launching a client.
55
-
56
- ## Interactive menu
57
-
58
- Run `layerbase` with no command for an arrow-key menu. It is a small hub: each
59
- action runs, then the menu returns, so you can sign in, list databases, drop
60
- into spindb, and keep going.
42
+ Every spindb command works. Anything that is not a layerbase verb (see the
43
+ [cloud commands](#cloud-account) below) forwards straight to your local
44
+ [spindb](https://github.com/robertjbass/spindb) install, with every flag and the
45
+ exit code preserved:
61
46
 
47
+ ```bash
48
+ lbase create my-db --engine postgres # == spindb create my-db --engine postgres
49
+ lbase ls # == spindb list
50
+ lbase start my-db # == spindb start my-db
51
+ lbase backup my-db # == spindb backup my-db
52
+ lbase branch my-db feature-x # == spindb branch my-db feature-x
53
+ lbase <cmd> --help # == spindb <cmd> --help
62
54
  ```
63
- ◆ Layerbase cloud + local databases
64
55
 
65
- Signed in as you@example.com
56
+ Bare `lbase` with no arguments opens spindb's own interactive menu. If spindb
57
+ does not recognize a command either, spindb's own error is shown and the exit
58
+ code is nonzero. `lbase spindb [args...]` is an explicit form of the same
59
+ passthrough.
66
60
 
67
- ❯ List cloud databases
68
- Connect to a database
69
- Run spindb local databases
70
- Log out
71
- Quit
61
+ ## Cloud account
72
62
 
73
- Up/Down to move · Enter to select · q to quit
74
- ```
63
+ These are the only verbs layerbase owns; everything else is spindb.
75
64
 
76
- The menu is sugar over the commands above, so everything stays scriptable.
65
+ | Command | Description |
66
+ | --- | --- |
67
+ | `lbase login` | Sign in via the browser; stores a token in `~/.layerbase-cli`. |
68
+ | `lbase logout` | Remove the stored credentials. |
69
+ | `lbase whoami` | Show the signed-in account and token expiry (`--json`). |
70
+ | `lbase cloud ls` | List your cloud databases (`--json` for scripting). |
71
+ | `lbase cloud connect <db>` | Connect with the engine's native client. |
72
+ | `lbase cloud clone <db> [name]` | Clone a cloud database into a local spindb container. |
73
+ | `lbase cloud connection-string <db>` | Print the connection string (reveals the password; alias: `url`). |
74
+ | `lbase psql <db>` | Connect to a cloud Postgres-family database. |
75
+ | `lbase redis-cli <db>` | Connect to a cloud Redis / Valkey database. |
76
+ | `lbase mysql <db>` | Connect to a cloud MySQL / MariaDB database. |
77
+ | `lbase alias` | Set up the short `lb` command (only if it is free). |
78
+ | `lbase chat` | Interactive console for your Layerbase account. |
79
+
80
+ `<db>` accepts a cloud database id or its name. Add `--print` to
81
+ `cloud connect` to show the connection details instead of launching a client.
82
+ `lbase cloud` with no subcommand prints the cloud help.
83
+
84
+ **Rule of thumb: bare = spindb, cloud = `lbase cloud <verb>`.** So `lbase ls`
85
+ lists your **local** containers (spindb) and `lbase cloud ls` lists your
86
+ **cloud** databases; likewise `lbase url` / `lbase connect` are local while
87
+ `lbase cloud connection-string` / `lbase cloud connect` are cloud.
88
+
89
+ ### Help and version
90
+
91
+ `lbase --help` / `-h` and `lbase help` render this unified help. `lbase --version`
92
+ / `-v` print the layerbase version. Because everything else forwards to spindb,
93
+ `lbase version` (no dashes) forwards to **spindb's** `version` command, and
94
+ `lbase <cmd> --help` reaches spindb's help for that command.
95
+
96
+ ## The chat console
97
+
98
+ `lbase chat` opens an interactive console for your Layerbase account (a
99
+ Claude-Code-style prompt). Type `/help` to see commands, `/spindb` (or `/menu`)
100
+ to hand off to local spindb, `/quit` to exit. Inside the console, `/ls`,
101
+ `/connect`, and `/clone` mean the **cloud** commands (it is the cloud console).
77
102
 
78
103
  ## The spindb bridge
79
104
 
@@ -101,7 +126,7 @@ deleted on exit. The password is never an argv value.
101
126
  | Postgres family | `PGPASSFILE` (temp `0600` file), deleted on exit |
102
127
  | MySQL / MariaDB | `--defaults-extra-file` (temp `0600` file), deleted on exit |
103
128
  | Redis / Valkey | `REDISCLI_AUTH` environment variable |
104
- | Other engines | `layerbase connection-string` / `--print` |
129
+ | Other engines | `layerbase cloud connection-string` / `--print` |
105
130
 
106
131
  Connecting requires the engine's native client (`psql`, `mysql`, `redis-cli`)
107
132
  on your `PATH`.
@@ -132,8 +157,18 @@ alone and suggests a shell alias instead.
132
157
  ## Requirements
133
158
 
134
159
  - Node.js 20 or newer.
135
- - For `connect` / `psql` / `redis-cli` / `mysql`: the matching native client on
136
- your `PATH`.
160
+ - For `cloud connect` / `psql` / `redis-cli` / `mysql`: the matching native
161
+ client on your `PATH`.
162
+
163
+ ## For maintainers
164
+
165
+ The bare command namespace belongs to spindb. **New cloud functionality goes
166
+ under the `cloud` namespace (`lbase cloud <verb>`), or must be proven
167
+ collision-free against `spindb --help` INCLUDING aliases before it can claim a
168
+ bare verb.** The registered layerbase verbs are the single source of truth in
169
+ `src/lib/commands.ts`, and `scripts/check-spindb-collisions.ts` (part of
170
+ `pnpm check`) fails the build if any registered bare verb collides with a spindb
171
+ command. See `CLAUDE.md` for the full contract.
137
172
 
138
173
  ## License
139
174
 
package/dist/cli.js CHANGED
@@ -7,74 +7,175 @@ import { runExec } from './commands/connect.js';
7
7
  import { runInteractive } from './commands/interactive.js';
8
8
  import { runClone } from './commands/clone.js';
9
9
  import { runSpindb } from './lib/run-spindb.js';
10
- const cli = meow(`
11
- Usage
12
- $ layerbase <command> [options]
10
+ import { registeredCommandNames } from './lib/commands.js';
11
+ import { getVersion } from './lib/version.js';
12
+ const VERSION = getVersion();
13
+ const UNIFIED_HELP = `
14
+ Layerbase ${VERSION} - local-first database CLI (also as lbase)
13
15
 
14
- Commands
15
- login Sign in via your browser; saves a token to ~/.layerbase-cli
16
- logout Remove the stored credentials
17
- whoami Show the signed-in account (--json to script it)
18
- ls List your cloud databases
19
- connect <db> Connect with the right client for the engine
20
- clone <db> [name] Clone a cloud database into a local spindb container
21
- psql <db> Connect to a Postgres-family database
22
- redis-cli <db> Connect to a Redis/Valkey database
23
- mysql <db> Connect to a MySQL/MariaDB database
24
- connection-string <db> Print the connection string (reveals the password)
25
- spindb [args...] Run the local spindb CLI (passes args through)
26
- alias Set up the short lb command (only if it is free)
16
+ Local databases (drop-in for spindb - every spindb command works)
17
+ create, ls, start, stop, connect, clone, branch, backup, restore, run,
18
+ query, pull, menu, ...
19
+ Anything not listed under "Cloud account" runs against your local spindb
20
+ install verbatim, flags included. Run "lbase <cmd> --help" for details.
27
21
 
28
- Run with no command for the interactive prompt (type /commands). Also lbase.
22
+ Cloud account
23
+ login / logout / whoami Manage your Layerbase session
24
+ cloud ls List your cloud databases (--json to script)
25
+ cloud connect <db> Connect with the engine's native client
26
+ cloud clone <db> [name] Clone a cloud database into local spindb
27
+ cloud connection-string <db> Print the connection string (reveals password)
28
+ psql / mysql / redis-cli <db> Connect to a cloud database by engine
29
+ alias Set up the short "lb" command
30
+ chat Interactive console for your Layerbase account
29
31
 
30
- Options
31
- --print With connect: show connection info, do not exec
32
- --json With ls: print JSON instead of a table
33
- --api-url <url> Cloud API base (env: LAYERBASE_API_URL)
32
+ Notes
33
+ bare = spindb, cloud = "lbase cloud <verb>"
34
+ "lbase --help" / "--version" show this help / the layerbase version.
35
+ "lbase version" forwards to spindb's version command.
34
36
 
35
37
  Examples
36
- $ layerbase # interactive menu
37
- $ layerbase login
38
- $ layerbase ls
39
- $ layerbase psql my-db
40
- $ layerbase spindb create postgres
41
- `, {
38
+ $ lbase # spindb's interactive menu
39
+ $ lbase create my-db --engine sqlite
40
+ $ lbase login
41
+ $ lbase cloud ls
42
+ $ lbase psql my-cloud-db
43
+ `;
44
+ const CLOUD_HELP = `
45
+ Cloud account commands
46
+
47
+ login / logout / whoami Manage your Layerbase session
48
+ lbase cloud ls List your cloud databases (--json to script)
49
+ lbase cloud connect <db> Connect with the engine's native client
50
+ lbase cloud clone <db> [name] Clone a cloud database into local spindb
51
+ lbase cloud connection-string <db> (alias: url)
52
+ Print the connection string (reveals password)
53
+ lbase psql / mysql / redis-cli <db> Connect to a cloud database by engine
54
+
55
+ "<db>" accepts a cloud database id or its name.
56
+ `;
57
+ function printHelp() {
58
+ process.stdout.write(`${UNIFIED_HELP}\n`);
59
+ }
60
+ function printCloudHelp() {
61
+ process.stdout.write(`${CLOUD_HELP}\n`);
62
+ }
63
+ // Dispatch a "lbase cloud <verb> ..." invocation to the existing cloud command
64
+ // implementations. Flags (e.g. --json on cloud ls) are already parsed by meow.
65
+ async function runCloud(rest, flags) {
66
+ const [sub = '', ...cloudArgs] = rest;
67
+ if (!sub) {
68
+ printCloudHelp();
69
+ process.exit(0);
70
+ }
71
+ if (sub === 'ls') {
72
+ render(_jsx(App, { command: "ls", args: [], flags: flags }));
73
+ return;
74
+ }
75
+ if (sub === 'connect') {
76
+ await runExec({ command: 'connect', args: cloudArgs, flags });
77
+ return;
78
+ }
79
+ if (sub === 'clone') {
80
+ const dbRef = cloudArgs[0];
81
+ if (!dbRef) {
82
+ process.stderr.write('Usage: layerbase cloud clone <db> [local-name]\n');
83
+ process.exit(1);
84
+ }
85
+ process.exit(await runClone({ dbRef, localName: cloudArgs[1] }));
86
+ }
87
+ // `url` is accepted as a sub-alias for connection-string (matching spindb's
88
+ // own url|connection-string naming).
89
+ if (sub === 'connection-string' || sub === 'url') {
90
+ render(_jsx(App, { command: "connection-string", args: cloudArgs, flags: flags }));
91
+ return;
92
+ }
93
+ process.stderr.write(`Unknown cloud command: ${sub}\n`);
94
+ printCloudHelp();
95
+ process.exit(1);
96
+ }
97
+ // Everything below is a pre-meow raw-argv interception. It is the single
98
+ // dispatch point for the whole CLI. We read process.argv verbatim (never
99
+ // through meow, which strips/reorders flags and would corrupt forwarded spindb
100
+ // commands) and forward everything from the command token onward, flags and
101
+ // order preserved. meow is constructed AFTER these interceptions, so it only
102
+ // ever parses a genuinely layerbase-owned command.
103
+ const rawArgs = process.argv.slice(2);
104
+ const firstArgIndex = rawArgs.findIndex((arg) => !arg.startsWith('-'));
105
+ const leadingCommand = firstArgIndex >= 0 ? rawArgs[firstArgIndex] : '';
106
+ // First-token help/version flags (no command before them) render layerbase's
107
+ // own unified help / version. After a spindb-bound token they forward verbatim
108
+ // via the fallthrough below (so "lbase create --help" reaches spindb's help).
109
+ if (!leadingCommand && rawArgs.length > 0) {
110
+ const flag = rawArgs[0];
111
+ if (flag === '--help' || flag === '-h') {
112
+ printHelp();
113
+ process.exit(0);
114
+ }
115
+ if (flag === '--version' || flag === '-v') {
116
+ process.stdout.write(`${VERSION}\n`);
117
+ process.exit(0);
118
+ }
119
+ }
120
+ // Bare invocation with no args: on a TTY hand off to spindb's interactive menu
121
+ // (the zero-arg case of the fallthrough); in a non-TTY context (pipes, CI)
122
+ // print the unified help and exit 0 instead of hanging on a prompt.
123
+ if (rawArgs.length === 0) {
124
+ if (process.stdin.isTTY) {
125
+ process.exit(await runSpindb([]));
126
+ }
127
+ printHelp();
128
+ process.exit(0);
129
+ }
130
+ // Explicit "spindb" prefix: strip the token, forward the rest to spindb. Kept
131
+ // as an explicit escape hatch even though bare fallthrough covers most cases.
132
+ if (leadingCommand === 'spindb') {
133
+ process.exit(await runSpindb(rawArgs.slice(firstArgIndex + 1)));
134
+ }
135
+ // Local-first fallthrough: any first token that is NOT a registered layerbase
136
+ // verb forwards verbatim to the local spindb CLI, INCLUDING the token itself,
137
+ // flags and order preserved. This is what makes "lbase create / list / backup /
138
+ // branch / connect / clone / ls / url ..." behave exactly like the same spindb
139
+ // command. The registered verbs are the ONLY bare words layerbase owns; the
140
+ // bare namespace otherwise belongs entirely to spindb.
141
+ const REGISTERED_COMMANDS = new Set(registeredCommandNames());
142
+ if (leadingCommand && !REGISTERED_COMMANDS.has(leadingCommand)) {
143
+ process.exit(await runSpindb(rawArgs.slice(firstArgIndex)));
144
+ }
145
+ const cli = meow(UNIFIED_HELP, {
42
146
  importMeta: import.meta,
147
+ autoHelp: false,
148
+ autoVersion: false,
149
+ version: VERSION,
43
150
  flags: {
44
151
  print: { type: 'boolean', default: false },
45
152
  json: { type: 'boolean', default: false },
46
153
  apiUrl: { type: 'string' },
47
154
  },
48
155
  });
49
- const EXEC_COMMANDS = new Set(['connect', 'psql', 'redis-cli', 'mysql']);
156
+ const EXEC_COMMANDS = new Set(['psql', 'redis-cli', 'mysql']);
50
157
  const [command = '', ...rest] = cli.input;
51
158
  if (command === 'help') {
52
- cli.showHelp(0);
159
+ printHelp();
160
+ process.exit(0);
53
161
  }
54
- else if (!command) {
55
- // No command: interactive menu on a TTY, help otherwise (pipes, CI).
56
- if (process.stdin.isTTY) {
57
- await runInteractive(cli.flags);
58
- }
59
- else {
60
- cli.showHelp(0);
61
- }
62
- }
63
- else if (command === 'spindb') {
64
- process.exit(await runSpindb(rest));
65
- }
66
- else if (command === 'clone') {
67
- const dbRef = rest[0];
68
- if (!dbRef) {
69
- process.stderr.write('Usage: layerbase clone <db> [local-name]\n');
162
+ else if (command === 'chat') {
163
+ // chat is the ONLY entry into the Ink interactive console (the bare no-arg
164
+ // launch moved to spindb). It needs a real terminal for the prompt.
165
+ if (!process.stdin.isTTY) {
166
+ process.stderr.write('layerbase chat needs an interactive terminal.\n');
70
167
  process.exit(1);
71
168
  }
72
- process.exit(await runClone({ dbRef, localName: rest[1] }));
169
+ await runInteractive(cli.flags);
170
+ }
171
+ else if (command === 'cloud') {
172
+ await runCloud(rest, cli.flags);
73
173
  }
74
174
  else if (EXEC_COMMANDS.has(command)) {
75
175
  await runExec({ command, args: rest, flags: cli.flags });
76
176
  }
77
177
  else {
178
+ // login, logout, whoami, alias.
78
179
  render(_jsx(App, { command: command, args: rest, flags: cli.flags }));
79
180
  }
80
181
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,GAAG,GAAG,IAAI,CACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BD,EACC;IACE,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,KAAK,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;QAC1C,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;QACzC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC3B;CACF,CACF,CAAA;AAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;AAExE,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAA;AAEzC,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;IACvB,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;KAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACpB,qEAAqE;IACrE,IAAI,OAAO,CAAC,KAAK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CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;KAAM,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;IAC/B,MAAM,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;KAAM,IAAI,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;IACtC,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAA;AAC1D,CAAC;KAAM,CAAC;IACN,gCAAgC;IAChC,MAAM,CAAC,KAAC,GAAG,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,GAAI,CAAC,CAAA;AACjE,CAAC"}
@@ -1,4 +1,8 @@
1
1
  import { loadCredentials } from '../lib/config.js';
2
+ import { getVersion } from '../lib/version.js';
3
+ // Sent on every cloud API request so CLI traffic is attributable in server logs
4
+ // (vs the desktop app or the dashboard). Read from package.json, not hardcoded.
5
+ const USER_AGENT = `layerbase-cli/${getVersion()}`;
2
6
  // These /api/cli/* endpoints and the /auth/cli login pages are implemented in
3
7
  // the layerbase web app (app/(frontend)/api/cli/* and app/(frontend)/auth/cli/*).
4
8
  // They must be deployed for `login` and the cloud calls below to work; the CLI
@@ -15,6 +19,7 @@ async function authedFetch(path, init) {
15
19
  headers: {
16
20
  authorization: `Bearer ${credentials.token}`,
17
21
  'content-type': 'application/json',
22
+ 'user-agent': USER_AGENT,
18
23
  ...init?.headers,
19
24
  },
20
25
  });
@@ -24,7 +29,7 @@ async function authedFetch(path, init) {
24
29
  if (!response.ok) {
25
30
  const body = await response.text().catch(() => '');
26
31
  throw new Error(`Cloud API ${response.status}: ${body || response.statusText}. ` +
27
- 'Check the database id or name (`layerbase ls`).');
32
+ 'Check the database id or name (`layerbase cloud ls`).');
28
33
  }
29
34
  return response;
30
35
  }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,kBAAkB,CAAC,KAAK,CAAC,kBAAkB,CAClE,CAAA;IACD,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAA;AAClD,CAAC"}
@@ -1,14 +1,28 @@
1
- // The command registry: the single source of truth for the interactive harness.
2
- // Adding a command here makes it show up in the prompt palette, the /menu, and
3
- // /help automatically. This is the seam future AI chat plugs into (a default
4
- // handler for non-command input).
1
+ // The command registry: the single source of truth for BOTH top-level CLI
2
+ // routing and the interactive (chat) harness.
3
+ //
4
+ // - registeredCommandNames() -> the bare tokens layerbase OWNS. cli.tsx reads
5
+ // it to gate the spindb fallthrough: any first token NOT in this set is
6
+ // forwarded verbatim to the local spindb CLI. The bare namespace otherwise
7
+ // belongs entirely to spindb (local-first).
8
+ // - availableCommands()/findCommand() -> the interactive palette inside the
9
+ // `chat` console. There, ls/connect/clone keep their CLOUD meaning (chat is
10
+ // the cloud account console).
5
11
  // When true (the pre-AI state), bare input whose FIRST word matches a command
6
- // runs it (with the rest as args), so `login` behaves like `/login` and
7
- // `spindb start db` forwards to spindb like `/spindb start db`. Once AI chat is
8
- // wired in, flip this to false so bare text is sent to the model instead.
9
- // Deliberately an in-code constant, not an env var: it encodes a code-evolution
10
- // stage, not a runtime/operator decision.
12
+ // runs it (with the rest as args), so `login` behaves like `/login` inside the
13
+ // chat console. Once AI chat is wired in, flip this to false so bare text is
14
+ // sent to the model instead. Deliberately an in-code constant, not an env var:
15
+ // it encodes a code-evolution stage, not a runtime/operator decision.
11
16
  export const ALLOW_FORWARD_SLASH_OMISSION = true;
17
+ // MAINTAINER NOTE: this registry is the SINGLE SOURCE OF TRUTH for which bare
18
+ // top-level tokens layerbase owns. Everything else forwards to spindb. The bare
19
+ // namespace belongs to spindb: NEW cloud functionality goes under the `cloud`
20
+ // namespace (`lbase cloud <verb>`), NOT a new bare verb. If you truly must add
21
+ // a bare verb, first prove it is collision-free against `spindb --help`
22
+ // INCLUDING aliases (scripts/check-spindb-collisions.ts enforces this in the
23
+ // check chain). `help` intentionally overlaps spindb's `help`: layerbase owns
24
+ // the top-level help token and renders its own unified help; spindb's help
25
+ // stays reachable via `lbase spindb help` or `lbase <cmd> --help`.
12
26
  export const COMMANDS = [
13
27
  { name: 'login', summary: 'Sign in via your browser', hideWhenAuthed: true },
14
28
  {
@@ -17,31 +31,72 @@ export const COMMANDS = [
17
31
  requiresAuth: true,
18
32
  },
19
33
  { name: 'whoami', summary: 'Show the signed-in account', requiresAuth: true },
20
- { name: 'ls', summary: 'List your cloud databases', requiresAuth: true },
34
+ {
35
+ name: 'psql',
36
+ summary: 'Connect to a cloud Postgres-family database',
37
+ cliOnly: true,
38
+ },
39
+ {
40
+ name: 'redis-cli',
41
+ summary: 'Connect to a cloud Redis/Valkey database',
42
+ cliOnly: true,
43
+ },
44
+ {
45
+ name: 'mysql',
46
+ summary: 'Connect to a cloud MySQL/MariaDB database',
47
+ cliOnly: true,
48
+ },
49
+ { name: 'alias', summary: 'Set up the short lb command', cliOnly: true },
50
+ {
51
+ name: 'chat',
52
+ summary: 'Interactive console for your Layerbase account',
53
+ cliOnly: true,
54
+ },
55
+ {
56
+ name: 'cloud',
57
+ summary: 'Cloud database commands (ls, connect, clone, connection-string)',
58
+ cliOnly: true,
59
+ },
60
+ {
61
+ name: 'spindb',
62
+ summary: 'Open the local spindb manager (forwards all args)',
63
+ aliases: ['menu'],
64
+ },
65
+ { name: 'help', summary: 'Show the unified help' },
66
+ {
67
+ name: 'ls',
68
+ summary: 'List your cloud databases',
69
+ requiresAuth: true,
70
+ interactiveOnly: true,
71
+ },
21
72
  {
22
73
  name: 'connect',
23
74
  summary: 'Connect to a cloud database',
24
75
  requiresAuth: true,
76
+ interactiveOnly: true,
25
77
  },
26
78
  {
27
79
  name: 'clone',
28
80
  summary: 'Clone a cloud database into a local spindb container',
29
81
  requiresAuth: true,
82
+ interactiveOnly: true,
30
83
  },
31
- {
32
- name: 'spindb',
33
- summary: 'Open the local spindb manager',
34
- aliases: ['menu'],
35
- },
36
- { name: 'help', summary: 'List the available commands' },
37
- { name: 'quit', summary: 'Exit', aliases: ['exit'] },
84
+ { name: 'quit', summary: 'Exit', aliases: ['exit'], interactiveOnly: true },
38
85
  ];
86
+ // The registered bare token names cli.tsx uses to gate the spindb fallthrough.
87
+ // Excludes interactiveOnly concepts (ls/connect/clone/quit), which fall through
88
+ // to spindb at the top level; includes cliOnly commands (psql, cloud, ...).
89
+ export function registeredCommandNames() {
90
+ return COMMANDS.filter((c) => !c.interactiveOnly).map((c) => c.name);
91
+ }
39
92
  export function findCommand(token) {
40
93
  const t = token.toLowerCase();
41
- return COMMANDS.find((c) => c.name === t || c.aliases?.includes(t));
94
+ return COMMANDS.find((c) => !c.cliOnly && (c.name === t || c.aliases?.includes(t)));
42
95
  }
43
96
  export function availableCommands(loggedIn) {
44
97
  return COMMANDS.filter((c) => {
98
+ if (c.cliOnly)
99
+ return false;
45
100
  if (c.requiresAuth && !loggedIn)
46
101
  return false;
47
102
  if (c.hideWhenAuthed && loggedIn)
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/lib/commands.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,6EAA6E;AAC7E,kCAAkC;AAElC,8EAA8E;AAC9E,wEAAwE;AACxE,gFAAgF;AAChF,0EAA0E;AAC1E,gFAAgF;AAChF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAA;AAahD,MAAM,CAAC,MAAM,QAAQ,GAAkB;IACrC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,IAAI,EAAE;IAC5E;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,sCAAsC;QAC/C,YAAY,EAAE,IAAI;KACnB;IACD,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,IAAI,EAAE;IAC7E,EAAE,IAAI,EA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AAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAChC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACtB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;YAC9B,IAAI,GAAG;gBAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QAC3E,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { dirname, join } from 'node:path';
4
+ // The CLI version, read from package.json (the single source of truth) so no
5
+ // version string is ever hardcoded. Used for `--version`, the help header, and
6
+ // the `layerbase-cli/<version>` User-Agent on cloud API requests. Resolved
7
+ // relative to this module: src/lib/version.ts (dev) and dist/lib/version.js
8
+ // (published) both sit two levels below the package.json.
9
+ let cached = null;
10
+ export function getVersion() {
11
+ if (cached)
12
+ return cached;
13
+ try {
14
+ const here = dirname(fileURLToPath(import.meta.url));
15
+ const pkgPath = join(here, '..', '..', 'package.json');
16
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
17
+ cached = pkg.version;
18
+ }
19
+ catch {
20
+ // Never let a missing/unreadable package.json break the CLI (e.g. the
21
+ // spindb fallthrough path). Degrade the reported version instead.
22
+ cached = 'unknown';
23
+ }
24
+ return cached;
25
+ }
26
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,4EAA4E;AAC5E,0DAA0D;AAC1D,IAAI,MAAM,GAAkB,IAAI,CAAA;AAEhC,MAAM,UAAU,UAAU;IACxB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAA;IACzB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAA;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAwB,CAAA;QAC5E,MAAM,GAAG,GAAG,CAAC,OAAO,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,sEAAsE;QACtE,kEAAkE;QAClE,MAAM,GAAG,SAAS,CAAA;IACpB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "layerbase",
3
- "version": "0.4.2",
3
+ "version": "1.0.0",
4
4
  "description": "Layerbase cloud CLI: connect to your managed databases without leaking the connection string into shell history.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,7 +24,8 @@
24
24
  "format": "prettier --write .",
25
25
  "lint": "eslint .",
26
26
  "check:types": "tsc --noEmit",
27
- "check": "tsc --noEmit && eslint .",
27
+ "check:collisions": "tsx scripts/check-spindb-collisions.ts",
28
+ "check": "tsc --noEmit && eslint . && pnpm check:collisions",
28
29
  "prepack": "pnpm build"
29
30
  },
30
31
  "dependencies": {