@nestcorehq/cli 0.0.0-stage → 0.8.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -2
  3. package/dist/index.js +1393 -0
  4. package/package.json +39 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NestCore
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,214 @@
1
- # Temporary Holding Version
1
+ # @nestcorehq/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The command-line interface for the [NestCore](https://nestcore.io) platform.
4
+
5
+ `nestcore` brings the day-to-day backend workflow into your terminal and your
6
+ repo: sign in once, link a directory to a project, run versioned SQL
7
+ migrations, and generate TypeScript types straight from your live schema — the
8
+ same ergonomics you expect from a modern backend toolchain.
9
+
10
+ ```bash
11
+ npm install -g @nestcorehq/cli
12
+ # or run without installing:
13
+ npx @nestcorehq/cli --help
14
+ ```
15
+
16
+ > Requires Node.js 22+.
17
+
18
+ ---
19
+
20
+ ## Quick start
21
+
22
+ ```bash
23
+ # 1. Sign in (credentials are stored in ~/.nestcore/credentials.json, mode 0600)
24
+ nestcore login
25
+
26
+ # 2. Link the current directory to one of your projects
27
+ nestcore link my-project # by slug, name, or id
28
+ # → writes .nestcore/config.json (safe to commit)
29
+
30
+ # 3. Scaffold and apply a migration
31
+ nestcore migration new "create posts table"
32
+ # → edits migrations/001_create_posts_table.sql
33
+ nestcore db push
34
+
35
+ # 4. Generate types from the live schema
36
+ nestcore gen types # → nestcore.types.ts
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Commands
42
+
43
+ ### Auth
44
+
45
+ | Command | Description |
46
+ | --- | --- |
47
+ | `nestcore login` | Sign in. Reads `--email` / `--password`, then `NESTCORE_EMAIL` / `NESTCORE_PASSWORD`, then prompts interactively (password input is masked). |
48
+ | `nestcore logout` | Revoke the refresh token and clear the local session. |
49
+ | `nestcore whoami` | Show the current session, API URL, and token expiry. |
50
+
51
+ ### Projects
52
+
53
+ | Command | Description |
54
+ | --- | --- |
55
+ | `nestcore projects` | List your projects (name, slug, id). |
56
+ | `nestcore link [id\|slug\|name]` | Link the current directory to a project. With no argument and a single project, links it automatically; otherwise lists choices. Writes `.nestcore/config.json`. |
57
+
58
+ ### Database & migrations
59
+
60
+ | Command | Description |
61
+ | --- | --- |
62
+ | `nestcore migration new <name>` | Scaffold `migrations/NNN_<name>.sql` with `up` / `-- migrate:down` sections. |
63
+ | `nestcore db push` | Apply every pending migration in order, inside a transaction each. |
64
+ | `nestcore db status` | Show which migrations are applied, pending, failed, or modified-after-apply. |
65
+ | `nestcore db rollback [id]` | Roll back the latest applied migration (or a specific `id`) using its `-- migrate:down` section. |
66
+ | `nestcore db reset --yes` | **Destructive.** Drop every table in the project (internal `auth_*` tables are spared) and re-apply all migrations from scratch. Requires `--yes`. First dry-runs the drop + every migration in a rolled-back transaction; if that fails, nothing is dropped. |
67
+ | `nestcore db sql "<SQL>"` | Run ad-hoc SQL against the linked project. `--file <path>` runs a file. |
68
+ | `nestcore db connect` | Print the direct Postgres connection string (when the deployment has direct connections enabled). |
69
+ | `nestcore gen types` | Introspect the schema and emit TypeScript interfaces + a `Database` map (`bigint`/`numeric` and enums are typed `string`, `json`/`jsonb` `unknown` — matching what the API returns). `--out <file>` (default `nestcore.types.ts`) or `--stdout`. |
70
+
71
+ ### Integrations
72
+
73
+ | Command | Description |
74
+ | --- | --- |
75
+ | `nestcore webhooks list` | List the project's webhooks. |
76
+ | `nestcore webhooks create --url <u> [--events INSERT,UPDATE,DELETE] [--table <t>] [--name <n>]` | Create a webhook (prints the signing secret once). |
77
+ | `nestcore webhooks delete <id>` / `test <id>` | Remove a webhook / send it a test event. |
78
+ | `nestcore sms get` | Show the project's Twilio/SMS config. |
79
+ | `nestcore sms set [--sid <s>] [--token <t>] [--from <n>] [--enable\|--disable]` | Configure Twilio (auth token stored encrypted). |
80
+ | `nestcore sms test <phone>` | Send a test SMS. |
81
+
82
+ ### AI
83
+
84
+ | Command | Description |
85
+ | --- | --- |
86
+ | `nestcore ai overview` | Counts of memories, memory subjects, collections, documents, threads, messages, traces (last 24 h) and embedded columns. Shows zeros until the project uses an AI feature. |
87
+ | `nestcore ai embeddings list` | Embedded columns with progress: rows, embedded, pending, failed and the last error. |
88
+ | `nestcore ai embeddings enable --table <t> --columns <a,b> [--target <col>] [--model <m>] [--provider <p>]` | Keep a `vector(768)` column (default `<first column>_embedding`) up to date from the source columns, and backfill existing rows. Admin role. |
89
+ | `nestcore ai embeddings reembed <table> <column> [--model <m>] [--provider <p>]` | Re-embed every row, optionally switching model. Admin role. |
90
+ | `nestcore ai embeddings disable <table> <column> [--drop-columns]` | Stop embedding a column; `--drop-columns` also drops the vector columns. Admin role. |
91
+ | `nestcore ai collections list` | Vector collections with their model, document counts and chunking. |
92
+ | `nestcore ai traces [--limit n] [--status ok\|error]` | Recent AI calls (default 20, max 500): kind, caller, model, tokens, cost, latency and status. |
93
+
94
+ ### Options
95
+
96
+ | Option | Applies to | Description |
97
+ | --- | --- | --- |
98
+ | `-p, --project <id\|slug>` | db / gen / webhooks / sms / auth-security / ai | Target a specific project, overriding the linked one. |
99
+ | `-d, --dir <path>` | migration / db | Migrations directory (default `migrations`). |
100
+ | `-o, --out <file>` | gen types | Output file. |
101
+ | `--stdout` | gen types | Print to stdout instead of a file. |
102
+ | `-f, --file <path>` | db sql | Read SQL from a file. |
103
+ | `--url <url>` | login | API base URL (default `https://api.nestcore.io`). |
104
+ | `-h, --help` | — | Show help. |
105
+ | `-v, --version` | — | Show version. |
106
+
107
+ ---
108
+
109
+ ## Migrations
110
+
111
+ A migration is a plain `.sql` file named `NNN_description.sql`. The numeric
112
+ prefix defines apply order. An optional `-- migrate:down` line splits the file
113
+ into a forward (`up`) section and a rollback (`down`) section:
114
+
115
+ ```sql
116
+ -- Migration 001: create posts table
117
+ -- Forward (up) SQL — applied by `nestcore db push`.
118
+ CREATE TABLE posts (
119
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
120
+ title text NOT NULL,
121
+ created_at timestamptz DEFAULT now()
122
+ );
123
+
124
+ -- migrate:down
125
+ -- Rollback SQL — applied by `nestcore db rollback`.
126
+ DROP TABLE posts;
127
+ ```
128
+
129
+ How it works:
130
+
131
+ - A `migrations` registry table tracks `migration_id`, `name`, `checksum`,
132
+ `executed_at`, and `status`.
133
+ - Each migration runs wrapped in `BEGIN; … COMMIT;` — a failure rolls the whole
134
+ file back and is recorded as `failed`.
135
+ - Already-applied migrations are skipped. If an applied file's checksum no
136
+ longer matches, `db push` refuses to continue (add a new migration instead of
137
+ editing history).
138
+
139
+ ---
140
+
141
+ ## Type generation
142
+
143
+ `nestcore gen types` reads `information_schema.columns` for your `public`
144
+ schema (skipping internal `auth_*`, `pg_*`, and `_*` tables) and emits a
145
+ strongly-typed module:
146
+
147
+ ```ts
148
+ // Generated by @nestcorehq/cli — do not edit by hand.
149
+ export interface Posts {
150
+ id: string;
151
+ title: string;
152
+ created_at?: string | null;
153
+ }
154
+
155
+ export interface Database {
156
+ "posts": Posts;
157
+ }
158
+ ```
159
+
160
+ Re-run it after every schema change and commit the output, or wire it into a
161
+ `predev` / `prebuild` script.
162
+
163
+ ---
164
+
165
+ ## Permissions
166
+
167
+ Raw SQL (`db sql`, `db push`/`status`/`rollback`/`reset`, `gen types`, `db diff`) runs only for the user who **created** the project; other workspace members get a 403 explaining this.
168
+
169
+ ## Configuration & files
170
+
171
+ | Path | Scope | Contents |
172
+ | --- | --- | --- |
173
+ | `~/.nestcore/credentials.json` | global, `0600` | Access/refresh tokens, API URL, user. Shared with the NestCore MCP server; token refreshes are serialised through `~/.nestcore/credentials.lock`. |
174
+ | `./.nestcore/config.json` | per-directory | Linked `projectId`, `projectSlug`, `name`, `apiUrl` (same file the MCP server reads; older files with `slug` still work). Safe to commit. |
175
+
176
+ Environment variables (override stored values):
177
+
178
+ - `NESTCORE_API_URL` — API base URL.
179
+ - `NESTCORE_EMAIL`, `NESTCORE_PASSWORD` — non-interactive login.
180
+ - `NESTCORE_MFA_CODE` — two-factor code for non-interactive login.
181
+ - `NO_COLOR` — disable ANSI colors.
182
+
183
+ ### Upgrading from `@orbitneststudio/cli`
184
+
185
+ The CLI was renamed from OrbitNest to NestCore. Existing setups keep working:
186
+
187
+ - `orbitnest` is installed as a second command name for `nestcore`.
188
+ - `~/.orbitnest/credentials.json` is read when `~/.nestcore/credentials.json`
189
+ doesn't exist yet; new sessions are written to `~/.nestcore` (and mirrored to
190
+ the old file while it exists, so older tools sharing it stay signed in).
191
+ - `./.orbitnest/config.json` and `./.orbitnest/schema.snapshot.json` are read
192
+ when the `.nestcore` equivalents are absent; `link` and `db diff --save` write
193
+ the new paths.
194
+ - The old `ORBITNEST_*` environment variables are used when the `NESTCORE_*`
195
+ ones are unset.
196
+
197
+ ---
198
+
199
+ ## Development
200
+
201
+ ```bash
202
+ npm install
203
+ npm run build # bundle to dist/ with tsup (CJS + shebang)
204
+ npm run dev # watch mode
205
+ npm run typecheck # tsc --noEmit
206
+
207
+ node dist/index.js --help
208
+ ```
209
+
210
+ ---
211
+
212
+ ## License
213
+
214
+ MIT © NestCore