@m2015agg/supabase-skill 0.1.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 (50) hide show
  1. package/README.md +383 -0
  2. package/dist/commands/columns.d.ts +2 -0
  3. package/dist/commands/columns.js +121 -0
  4. package/dist/commands/columns.js.map +1 -0
  5. package/dist/commands/context.d.ts +2 -0
  6. package/dist/commands/context.js +236 -0
  7. package/dist/commands/context.js.map +1 -0
  8. package/dist/commands/cron.d.ts +2 -0
  9. package/dist/commands/cron.js +116 -0
  10. package/dist/commands/cron.js.map +1 -0
  11. package/dist/commands/docs.d.ts +4 -0
  12. package/dist/commands/docs.js +182 -0
  13. package/dist/commands/docs.js.map +1 -0
  14. package/dist/commands/envs.d.ts +2 -0
  15. package/dist/commands/envs.js +22 -0
  16. package/dist/commands/envs.js.map +1 -0
  17. package/dist/commands/init.d.ts +2 -0
  18. package/dist/commands/init.js +85 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/install.d.ts +2 -0
  21. package/dist/commands/install.js +129 -0
  22. package/dist/commands/install.js.map +1 -0
  23. package/dist/commands/search.d.ts +2 -0
  24. package/dist/commands/search.js +102 -0
  25. package/dist/commands/search.js.map +1 -0
  26. package/dist/commands/snapshot.d.ts +2 -0
  27. package/dist/commands/snapshot.js +316 -0
  28. package/dist/commands/snapshot.js.map +1 -0
  29. package/dist/commands/table.d.ts +2 -0
  30. package/dist/commands/table.js +169 -0
  31. package/dist/commands/table.js.map +1 -0
  32. package/dist/commands/uninstall.d.ts +2 -0
  33. package/dist/commands/uninstall.js +30 -0
  34. package/dist/commands/uninstall.js.map +1 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +31 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/util/claude-md.d.ts +3 -0
  39. package/dist/util/claude-md.js +48 -0
  40. package/dist/util/claude-md.js.map +1 -0
  41. package/dist/util/config.d.ts +15 -0
  42. package/dist/util/config.js +37 -0
  43. package/dist/util/config.js.map +1 -0
  44. package/dist/util/db.d.ts +85 -0
  45. package/dist/util/db.js +237 -0
  46. package/dist/util/db.js.map +1 -0
  47. package/dist/util/detect.d.ts +13 -0
  48. package/dist/util/detect.js +34 -0
  49. package/dist/util/detect.js.map +1 -0
  50. package/package.json +44 -0
package/README.md ADDED
@@ -0,0 +1,383 @@
1
+ # @m2015agg/supabase-skill
2
+
3
+ **Supabase CLI skill for AI agents.** Installs comprehensive Supabase CLI instructions into your `CLAUDE.md`, `AGENTS.md`, or `.cursorrules` with multi-environment support (dev/stage/prod).
4
+
5
+ No MCP server. No context window bloat. No running processes. Just a CLI skill doc that teaches your AI agent every Supabase command it needs.
6
+
7
+ ## Why This Exists
8
+
9
+ The Supabase MCP server dumps its entire schema into your agent's context window — 30-40% gone before your agent even starts thinking. It also can't talk to multiple databases in the same session.
10
+
11
+ The Supabase CLI already does everything the MCP does. Your agent just doesn't know about it unless you document it.
12
+
13
+ This package:
14
+ - **Detects** your Supabase CLI installation and login status
15
+ - **Lists** your projects and lets you tag them as `prod`, `stage`, or `dev`
16
+ - **Writes** a comprehensive CLI skill doc into your CLAUDE.md with your actual project refs baked in
17
+ - **Covers** every Supabase CLI command: SQL, migrations, schema, inspect, storage, edge functions, snippets, secrets
18
+ - **Enforces** safety rules (never mutate prod without approval, always specify `--project-ref`)
19
+
20
+ One install. Zero runtime overhead. Your agent knows every command.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install -g @m2015agg/supabase-skill
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Global Setup
31
+
32
+ ```bash
33
+ supabase-skill install
34
+ ```
35
+
36
+ Interactive wizard that:
37
+ 1. Checks if `supabase` CLI is installed
38
+ 2. Checks if you're logged in (`supabase login`)
39
+ 3. Lists your Supabase projects
40
+ 4. Lets you tag each as `prod` / `stage` / `dev` / `skip`
41
+ 5. Saves config to `~/.config/supabase-skill/config.json`
42
+ 6. Upserts the full skill doc into `~/.claude/CLAUDE.md`
43
+ 7. Adds `SUPABASE_ACCESS_TOKEN` to your shell profile if missing
44
+
45
+ ```
46
+ $ supabase-skill install
47
+
48
+ Checking supabase CLI... ✓ v2.67.1
49
+ Checking login status... ✓ logged in
50
+
51
+ Found 2 project(s):
52
+ 1. My App Production (abcdefghijklmnopqrst)
53
+ 2. My App Staging (tsrqponmlkjihgfedcba)
54
+
55
+ Tag each project (prod/stage/dev/skip):
56
+ My App Production → prod
57
+ My App Staging → stage
58
+
59
+ supabase-skill install complete:
60
+ ~/.config/supabase-skill/config.json: created
61
+ ~/.claude/CLAUDE.md: updated
62
+
63
+ Next: run `supabase-skill init` in any project directory.
64
+ ```
65
+
66
+ ### 2. Per-Project Setup
67
+
68
+ ```bash
69
+ cd your-project
70
+ supabase-skill init
71
+ ```
72
+
73
+ This:
74
+ 1. Upserts the skill doc into `CLAUDE.md` and `.claude/CLAUDE.md` (if the `.claude/` dir exists)
75
+ 2. Creates/updates `.env` with your project refs (`SUPABASE_PROD_REF=...`, `SUPABASE_STAGE_REF=...`)
76
+ 3. Ensures `.gitignore` includes `.env`
77
+
78
+ ### 3. Done
79
+
80
+ Next time Claude Code (or Codex, Cursor, etc.) opens your project, it reads the skill doc and knows every Supabase command, which ref is prod vs stage, and the safety rules.
81
+
82
+ ## Commands
83
+
84
+ | Command | Description |
85
+ |---------|-------------|
86
+ | `supabase-skill install` | Global setup wizard (CLI check, env tagging, CLAUDE.md) |
87
+ | `supabase-skill init` | Per-project setup (CLAUDE.md + .env + .gitignore) |
88
+ | `supabase-skill snapshot` | Snapshot DB schema to `.supabase-schema/` for fast agent lookups |
89
+ | `supabase-skill context <query>` | Full context: columns, FKs, related tables (2 levels), related functions |
90
+ | `supabase-skill table <name>` | Single table detail with relationships, functions, related summaries |
91
+ | `supabase-skill columns [name]` | Search columns by name, `--type`, `--fk`, `--pk`, `--table` |
92
+ | `supabase-skill search <query>` | Search tables, columns, functions, and FKs locally |
93
+ | `supabase-skill docs` | Output the skill doc to stdout |
94
+ | `supabase-skill docs --format <fmt>` | Output as `claude`, `agents`, `cursor`, `skill`, or `raw` |
95
+ | `supabase-skill envs` | List configured environments with project refs |
96
+ | `supabase-skill uninstall` | Remove skill doc from current project's CLAUDE.md files |
97
+ | `supabase-skill uninstall --global` | Remove from `~/.claude/CLAUDE.md` |
98
+
99
+ ## What It Writes to CLAUDE.md
100
+
101
+ The skill doc is injected between `<!-- supabase-skill:start -->` and `<!-- supabase-skill:end -->` markers. This means:
102
+
103
+ - **Idempotent**: Run `install` or `init` multiple times — it updates in place, never duplicates
104
+ - **Clean removal**: `uninstall` removes exactly the marked section, nothing else
105
+ - **Non-destructive**: Your existing CLAUDE.md content is preserved
106
+
107
+ ### The Skill Doc
108
+
109
+ Here's exactly what gets written (with your project refs filled in):
110
+
111
+ ```markdown
112
+ ## supabase-cli (Supabase Database & Infrastructure)
113
+
114
+ Requires: `supabase` CLI installed, logged in via `supabase login`.
115
+ All commands support `-o json` for structured output.
116
+
117
+ ### Environments
118
+ - **PROD**: `abcdefghijklmnopqrst` (My App Production) — ⚠️ NEVER modify without explicit approval
119
+ - **STAGE**: `tsrqponmlkjihgfedcba` (My App Staging)
120
+ - **Default**: Use STAGE for testing. PROD requires explicit approval.
121
+ ```
122
+
123
+ It covers **every major Supabase CLI capability** organized by task:
124
+
125
+ | Section | Commands Covered |
126
+ |---------|-----------------|
127
+ | **SQL Execution** | `db execute` with `--stdin` and `-f` |
128
+ | **Migrations** | `migration new`, `list`, `up`, `down`, `repair`, `squash`, `fetch` |
129
+ | **Schema Management** | `db diff`, `dump`, `pull`, `push`, `lint` |
130
+ | **Database Inspection** | All 12 `inspect db` commands (table-stats, index-stats, long-running-queries, outliers, bloat, locks, blocking, db-stats, vacuum-stats, role-stats, replication-slots) + `inspect report` |
131
+ | **Storage** | `storage ls`, `cp`, `rm`, `mv` |
132
+ | **Edge Functions** | `functions list`, `deploy`, `delete`, `serve` |
133
+ | **Project Management** | `projects list`, `api-keys`, `secrets list/set` |
134
+ | **SQL Snippets** | `snippets list`, `download` |
135
+ | **Safety Rules** | Never mutate prod without approval, always use `--project-ref`, use `-o json`, test on stage first |
136
+
137
+ ### Safety Rules (built into the skill doc)
138
+
139
+ The skill doc includes explicit safety rules that the agent follows:
140
+
141
+ ```
142
+ - NEVER run mutations on PROD without explicit user approval
143
+ - ALWAYS specify --project-ref — never rely on linked project for remote ops
144
+ - Use -o json for structured output the agent can parse
145
+ - Run supabase migration list BEFORE and AFTER migration operations
146
+ - Test migrations on STAGE before applying to PROD
147
+ ```
148
+
149
+ ## Schema Snapshot (CodeGraph for Your Database)
150
+
151
+ The killer feature. Instead of your agent running SQL against `information_schema` every time it needs to understand your database (burning context and API calls), `snapshot` creates a local file cache that Claude can grep and read instantly.
152
+
153
+ ### Create a Snapshot
154
+
155
+ ```bash
156
+ supabase-skill snapshot
157
+ ```
158
+
159
+ One API call fetches the full OpenAPI spec from PostgREST, then splits it into small, searchable markdown files:
160
+
161
+ ```
162
+ .supabase-schema/
163
+ ├── index.md # All tables, views, functions at a glance
164
+ ├── tables/
165
+ │ ├── episodes.md # Columns, types, PKs, FKs, defaults, notes
166
+ │ ├── subscriptions.md
167
+ │ ├── users.md
168
+ │ └── ... (one file per table + view)
169
+ ├── relationships.json # Every FK mapping: "episodes.subscription_id" → "subscriptions.id"
170
+ └── functions.md # All RPC functions with parameter signatures
171
+ ```
172
+
173
+ ### What a Table File Looks Like
174
+
175
+ ```markdown
176
+ # episodes
177
+
178
+ 15 columns | 1 PK | 2 FK
179
+
180
+ | Column | Type | Nullable | Default | FK |
181
+ |--------|------|----------|---------|-----|
182
+ | id **PK** | uuid | NOT NULL | gen_random_uuid() | |
183
+ | subscription_id | uuid | NOT NULL | | → subscriptions.id |
184
+ | status | text | nullable | new | |
185
+ | audio_url | text | nullable | | |
186
+ | metadata_id | uuid | nullable | | → episode_metadata.id |
187
+ ...
188
+
189
+ ## Notes
190
+ - **processing_metadata**: Stores additional processing information and AI analysis results
191
+ ```
192
+
193
+ ### Search the Snapshot
194
+
195
+ ```bash
196
+ # Find everything related to "episode"
197
+ supabase-skill search episode
198
+
199
+ # Output:
200
+ # TABLES: episodes, episode_chunks, episode_metadata, ...
201
+ # COLUMNS: ai_sections.episode_id (uuid), segments.episode_id (uuid), ...
202
+ # FUNCTIONS: browse_episodes, episode_semantic_search, ...
203
+ # FKS: episodes.subscription_id → subscriptions.id, ...
204
+
205
+ # JSON output for programmatic use
206
+ supabase-skill search subscription --json
207
+ ```
208
+
209
+ ### Context — The Smart Query (Like CodeGraph's `codegraph_context`)
210
+
211
+ ```bash
212
+ # "What's the full picture for episodes?"
213
+ supabase-skill context episodes
214
+ ```
215
+
216
+ Returns everything in one shot:
217
+ - Full column listing with types, PKs, FKs, defaults
218
+ - All related tables (2 levels deep via FK chains)
219
+ - Which direction: "references" vs "referenced by"
220
+ - Related RPC functions
221
+ - Column notes/descriptions
222
+
223
+ ```bash
224
+ # Deeper FK traversal
225
+ supabase-skill context episodes --depth 3
226
+
227
+ # Topic-based (matches any table/column containing the term)
228
+ supabase-skill context subscription
229
+ supabase-skill context chat
230
+ ```
231
+
232
+ ### Table — Single Table Deep Dive
233
+
234
+ ```bash
235
+ supabase-skill table subscriptions
236
+ ```
237
+
238
+ Returns the full table file plus:
239
+ - Outgoing FKs ("this table references")
240
+ - Incoming FKs ("referenced by")
241
+ - Related RPC functions (name-matched)
242
+ - Related table summaries (column counts for each FK target)
243
+
244
+ ### Columns — Cross-Database Column Search
245
+
246
+ Stop running `SELECT column_name FROM information_schema.columns WHERE...` every time.
247
+
248
+ ```bash
249
+ # Find all jsonb columns across the entire database
250
+ supabase-skill columns --type jsonb
251
+
252
+ # All foreign key columns in episode-related tables
253
+ supabase-skill columns --fk --table episode
254
+
255
+ # All primary keys
256
+ supabase-skill columns --pk
257
+
258
+ # All NOT NULL columns with defaults
259
+ supabase-skill columns --not-null --has-default
260
+
261
+ # Find all "status" columns and their types
262
+ supabase-skill columns status
263
+
264
+ # Combine: all uuid columns that are foreign keys
265
+ supabase-skill columns --type uuid --fk
266
+ ```
267
+
268
+ ### How Agents Use It
269
+
270
+ Instead of:
271
+ ```
272
+ Agent: "Let me query the database to understand the schema..."
273
+ → runs SQL against information_schema (3-5 seconds, eats context)
274
+ → parses results
275
+ → stores in conversation memory
276
+ ```
277
+
278
+ Now:
279
+ ```
280
+ Agent: reads .supabase-schema/tables/episodes.md (instant, 20 lines)
281
+ Agent: reads .supabase-schema/relationships.json (instant, FK map)
282
+ ```
283
+
284
+ The snapshot is **markdown** (not JSON) so Claude reads it naturally with zero parsing overhead. Add `.supabase-schema/` to your `.gitignore` and refresh with `supabase-skill snapshot` whenever your schema changes.
285
+
286
+ ## Multi-Format Output
287
+
288
+ Generate the skill doc for different AI agent platforms:
289
+
290
+ ```bash
291
+ # Claude Code (CLAUDE.md)
292
+ supabase-skill docs --format claude
293
+
294
+ # OpenAI Codex (AGENTS.md)
295
+ supabase-skill docs --format agents
296
+
297
+ # Cursor (.cursorrules)
298
+ supabase-skill docs --format cursor
299
+
300
+ # OpenClaw / ClawHub (SKILL.md with frontmatter)
301
+ supabase-skill docs --format skill
302
+
303
+ # Raw (no wrapping)
304
+ supabase-skill docs
305
+ ```
306
+
307
+ ## Config File
308
+
309
+ Stored at `~/.config/supabase-skill/config.json`:
310
+
311
+ ```json
312
+ {
313
+ "environments": {
314
+ "prod": { "ref": "abcdefghijklmnopqrst", "name": "My App Production" },
315
+ "stage": { "ref": "tsrqponmlkjihgfedcba", "name": "My App Staging" }
316
+ },
317
+ "defaultEnv": "stage",
318
+ "safetyRules": {
319
+ "prodRequiresApproval": true,
320
+ "alwaysSpecifyRef": true
321
+ }
322
+ }
323
+ ```
324
+
325
+ ## Real-World Token Savings — Hard Numbers
326
+
327
+ We analyzed 14 Claude Code conversations on a production Supabase project (80 tables, 48 RPCs, 86 foreign keys) to measure how many tokens schema exploration actually consumes.
328
+
329
+ ### Before supabase-skill (SQL queries every time)
330
+
331
+ | Metric | Value |
332
+ |--------|-------|
333
+ | Conversations doing schema exploration | **14** |
334
+ | Total schema query + result dumps | **265 calls** |
335
+ | Total tokens consumed by schema results | **~330,000** |
336
+ | Cost at Opus rates ($15/M input) | **$4.96** |
337
+ | Average tokens per schema call | **~1,247** |
338
+ | Heaviest single query result | **~22,282 tokens** |
339
+
340
+ #### Heaviest Conversations
341
+
342
+ | Session | Calls | Tokens | Task |
343
+ |---------|-------|--------|------|
344
+ | Support AI Console planning | 56 | ~81,000 | Exploring tables for agent access |
345
+ | Study Mode migration design | 41 | ~74,000 | Designing new tables + FKs |
346
+ | Schema exploration | 43 | ~53,000 | General schema discovery |
347
+ | Building supabase-skill | 24 | ~33,000 | This tool, ironically |
348
+
349
+ ### After supabase-skill (local snapshot)
350
+
351
+ | Operation | Before (SQL query) | After (local file) | Savings |
352
+ |-----------|-------------------|---------------------|---------|
353
+ | "What columns does episodes have?" | ~1,200 tokens | ~80 tokens | **93%** |
354
+ | "Find all jsonb columns" | ~3,000 tokens | ~200 tokens | **93%** |
355
+ | "What references episodes?" | ~2,000 tokens | ~150 tokens | **92%** |
356
+ | "Show me the full schema" | ~22,000 tokens | ~500 tokens | **98%** |
357
+
358
+ **Conservative estimate**: Those 330,000 tokens across 14 conversations drop to roughly **15,000-20,000 tokens** with the local snapshot. That's a **~95% reduction** — or about **$4.70 saved** at Opus rates just from the conversations we measured.
359
+
360
+ And that's just one project. The savings compound across every conversation, every day, for every developer on the team.
361
+
362
+ ## Why CLIs Beat MCP for Agents
363
+
364
+ | | MCP Server | CLI Skill Doc |
365
+ |---|---|---|
366
+ | **Context overhead** | 30-40% of context window consumed by schema | Zero — agent reads a concise doc |
367
+ | **Schema exploration** | ~1,247 tokens per query (measured) | ~80-200 tokens per file read |
368
+ | **Multi-environment** | One database per server instance | `--project-ref` switches instantly |
369
+ | **Runtime** | Server process running in background | No process — just `exec` calls |
370
+ | **Dependencies** | Protocol handshake, WebSocket, auth | `supabase` binary + a text file |
371
+ | **Structured output** | Custom serialization | `-o json` flag built into every command |
372
+ | **Composability** | None | Pipe output: `supabase ... -o json \| jq '...'` |
373
+ | **Testing** | Spin up server, connect, send request | `supabase --help` in terminal |
374
+
375
+ ## Requirements
376
+
377
+ - [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) installed
378
+ - Logged in via `supabase login`
379
+ - Node.js 18+
380
+
381
+ ## License
382
+
383
+ MIT
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function columnsCommand(): Command;
@@ -0,0 +1,121 @@
1
+ import { Command } from "commander";
2
+ import { join } from "node:path";
3
+ import { existsSync, readFileSync, readdirSync } from "node:fs";
4
+ import { hasDb, openDb, queryColumns } from "../util/db.js";
5
+ function write(msg) {
6
+ process.stdout.write(msg);
7
+ }
8
+ function queryMarkdown(tablesDir, opts) {
9
+ const results = [];
10
+ const files = readdirSync(tablesDir).filter((f) => f.endsWith(".md"));
11
+ for (const file of files) {
12
+ const table = file.replace(".md", "");
13
+ if (opts.table && !table.toLowerCase().includes(opts.table.toLowerCase()))
14
+ continue;
15
+ for (const line of readFileSync(join(tablesDir, file), "utf-8").split("\n")) {
16
+ if (line.startsWith("|") && !line.startsWith("| Column") && !line.startsWith("|---")) {
17
+ const cols = line.split("|").slice(1, -1).map((c) => c.trim());
18
+ if (cols.length >= 5) {
19
+ const match = {
20
+ table,
21
+ column: cols[0].replace(/\s*\*\*PK\*\*/, ""),
22
+ type: cols[1],
23
+ nullable: cols[2],
24
+ defaultVal: cols[3],
25
+ fk: cols[4],
26
+ isPk: cols[0].includes("**PK**"),
27
+ };
28
+ if (opts.name && !match.column.toLowerCase().includes(opts.name.toLowerCase()))
29
+ continue;
30
+ if (opts.type && !match.type.toLowerCase().includes(opts.type.toLowerCase()))
31
+ continue;
32
+ if (opts.fk && !match.fk)
33
+ continue;
34
+ if (opts.pk && !match.isPk)
35
+ continue;
36
+ if (opts.nullable && match.nullable !== "nullable")
37
+ continue;
38
+ if (opts.notNull && match.nullable !== "NOT NULL")
39
+ continue;
40
+ if (opts.hasDefault && !match.defaultVal)
41
+ continue;
42
+ results.push(match);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return results;
48
+ }
49
+ function sqliteToMatch(r) {
50
+ return {
51
+ table: r.table_name,
52
+ column: r.name,
53
+ type: r.type || "unknown",
54
+ nullable: r.nullable ? "nullable" : "NOT NULL",
55
+ defaultVal: r.default_value || "",
56
+ fk: r.fk_table ? `→ ${r.fk_table}.${r.fk_column}` : "",
57
+ isPk: !!r.is_pk,
58
+ };
59
+ }
60
+ export function columnsCommand() {
61
+ return new Command("columns")
62
+ .description("Search columns across all tables by name, type, or attributes")
63
+ .argument("[query]", "Column name to search for")
64
+ .option("--dir <dir>", "Schema directory", ".supabase-schema")
65
+ .option("--type <type>", "Filter by data type (uuid, text, jsonb, integer, timestamp, boolean, etc.)")
66
+ .option("--fk", "Show only foreign key columns")
67
+ .option("--pk", "Show only primary key columns")
68
+ .option("--nullable", "Show only nullable columns")
69
+ .option("--not-null", "Show only NOT NULL columns")
70
+ .option("--has-default", "Show only columns with defaults")
71
+ .option("--table <name>", "Filter to specific table")
72
+ .option("--json", "Output as JSON")
73
+ .action((query, opts) => {
74
+ const schemaDir = join(process.cwd(), opts.dir);
75
+ const tablesDir = join(schemaDir, "tables");
76
+ if (!existsSync(schemaDir)) {
77
+ write(`No schema snapshot found at ${opts.dir}/\n`);
78
+ write("Run `supabase-skill snapshot` first.\n");
79
+ process.exit(1);
80
+ }
81
+ let columns;
82
+ if (hasDb(schemaDir)) {
83
+ const db = openDb(schemaDir);
84
+ const results = queryColumns(db, {
85
+ name: query, type: opts.type, fk: opts.fk, pk: opts.pk,
86
+ nullable: opts.nullable, notNull: opts.notNull, hasDefault: opts.hasDefault, table: opts.table,
87
+ });
88
+ db.close();
89
+ columns = results.map(sqliteToMatch);
90
+ }
91
+ else {
92
+ columns = queryMarkdown(tablesDir, {
93
+ name: query, type: opts.type, fk: opts.fk, pk: opts.pk,
94
+ nullable: opts.nullable, notNull: opts.notNull, hasDefault: opts.hasDefault, table: opts.table,
95
+ });
96
+ }
97
+ if (opts.json) {
98
+ write(JSON.stringify(columns, null, 2) + "\n");
99
+ return;
100
+ }
101
+ if (columns.length === 0) {
102
+ write("No matching columns found.\n");
103
+ return;
104
+ }
105
+ write(`\n${columns.length} matching column(s):\n\n`);
106
+ write("| Table | Column | Type | Nullable | Default | FK |\n");
107
+ write("|-------|--------|------|----------|---------|----|\n");
108
+ for (const col of columns) {
109
+ const pk = col.isPk ? " **PK**" : "";
110
+ write(`| ${col.table} | ${col.column}${pk} | ${col.type} | ${col.nullable} | ${col.defaultVal} | ${col.fk} |\n`);
111
+ }
112
+ write("\n");
113
+ const tables = new Set(columns.map((c) => c.table));
114
+ const types = new Map();
115
+ for (const col of columns) {
116
+ types.set(col.type, (types.get(col.type) || 0) + 1);
117
+ }
118
+ write(`Across ${tables.size} table(s). Types: ${[...types.entries()].map(([t, n]) => `${t}(${n})`).join(", ")}\n\n`);
119
+ });
120
+ }
121
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.js","sourceRoot":"","sources":["../../src/commands/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAA0B,MAAM,eAAe,CAAC;AAEpF,SAAS,KAAK,CAAC,GAAW;IACxB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAYD,SAAS,aAAa,CAAC,SAAiB,EAAE,IAGzC;IACC,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAA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