superdb-mcp 0.51231.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.
@@ -0,0 +1,408 @@
1
+ ---
2
+ name: zq-to-super-upgrades
3
+ description: "Migration guide from zq to SuperDB. Covers all breaking changes and syntax updates."
4
+ superdb_version: "0.51231"
5
+ last_updated: "2026-01-05"
6
+ source: "https://github.com/chrismo/superkit/blob/main/doc/zq-to-super-upgrades.md"
7
+ ---
8
+
9
+ # Upgrading zq to super
10
+
11
+ This document is designed for AI assistants performing automated upgrades of zq
12
+ scripts to SuperDB. It covers all breaking changes between zq and the current
13
+ SuperDB release.
14
+
15
+ ## Quick Reference
16
+
17
+ | Category | zq | super |
18
+ |------------|------------------|-----------------------------|
19
+ | Keyword | `yield` | `values` |
20
+ | Function | `parse_zson` | `parse_sup` |
21
+ | Function | `func` | `fn` |
22
+ | Operator | `over` | `unnest` |
23
+ | Switch | `-z` / `-Z` | `-s` / `-S` |
24
+ | Switch | `-f text` | `-f line` |
25
+ | Switch | (implicit) | `-c` required before query |
26
+ | Comments | `//` | `--` or `/* */` |
27
+ | Regexp | `/pattern/` | `'pattern'` (string) |
28
+ | Cast | `type(value)` | `value::type` |
29
+ | Agg filter | `count() where x`| `count() filter (x)` |
30
+
31
+ ## CLI Changes
32
+
33
+ ### The `-c` switch is now required
34
+
35
+ `super` requires a `-c` switch before any query string. `zq` accepted the query
36
+ string as a positional argument.
37
+
38
+ **OLD:**
39
+ ```bash
40
+ echo '{"a":1}' | zq 'yield a' -
41
+ ```
42
+
43
+ **NEW:**
44
+ ```bash
45
+ echo '{"a":1}' | super -c 'values a' -
46
+ ```
47
+
48
+ ### The `-c` switch must immediately precede the query string
49
+
50
+ The query must come directly after `-c`. Other flags go before `-c`.
51
+
52
+ **CORRECT:**
53
+ ```bash
54
+ echo '{"a":1}' | super -s -c 'values a' -
55
+ ```
56
+
57
+ **INCORRECT:**
58
+ ```bash
59
+ -- This is ILLEGAL - flags cannot go between -c and the query
60
+ echo '{"a":1}' | super -c -s 'values a' -
61
+ ```
62
+
63
+ ### When there is no query, do NOT use `-c`
64
+
65
+ If you're just reformatting data without a query, omit `-c` entirely.
66
+
67
+ **OLD:**
68
+ ```bash
69
+ zq -j input.json
70
+ ```
71
+
72
+ **NEW:**
73
+ ```bash
74
+ super -j input.json
75
+ ```
76
+
77
+ **INCORRECT:**
78
+ ```bash
79
+ -- This is ILLEGAL - -c requires a query string to follow it
80
+ super -c -j input.json
81
+ ```
82
+
83
+ ### Output format switches
84
+
85
+ - `-f text` → `-f line`
86
+ - `-z` → `-s` (line-oriented Super JSON)
87
+ - `-Z` → `-S` (formatted Super JSON)
88
+
89
+ ### Comments
90
+
91
+ zq used `//` for single-line comments. SuperDB uses PostgreSQL-compatible syntax:
92
+ - `--` for single-line comments
93
+ - `/* ... */` for multi-line comments
94
+
95
+ ## Simple Renames
96
+
97
+ ### yield → values
98
+
99
+ ```bash
100
+ -- OLD
101
+ zq 'yield {a:1}'
102
+
103
+ -- NEW
104
+ super -c 'values {a:1}'
105
+ ```
106
+
107
+ ### parse_zson → parse_sup
108
+
109
+ ```bash
110
+ -- OLD
111
+ zq 'parse_zson(s)'
112
+
113
+ -- NEW
114
+ super -c 'parse_sup(s)'
115
+ ```
116
+
117
+ ### func → fn
118
+
119
+ ```bash
120
+ -- OLD
121
+ func double(x): ( x * 2 )
122
+
123
+ -- NEW
124
+ fn double(x): ( x * 2 )
125
+ ```
126
+
127
+ ### over → unnest (basic usage)
128
+
129
+ Simple uses are a direct replacement:
130
+
131
+ ```bash
132
+ -- OLD
133
+ zq 'yield [1,2,3] | over this'
134
+
135
+ -- NEW
136
+ super -c 'values [1,2,3] | unnest this'
137
+ ```
138
+
139
+ ## Behavioral Changes
140
+
141
+ ### Indexing is 0-based (with pragma for 1-based)
142
+
143
+ 0-based indexing is the default. Use `pragma index_base = 1` for SQL-style
144
+ 1-based indexing when needed.
145
+
146
+ ```bash
147
+ -- 0-based indexing (default)
148
+ super -s -c "values ['a','b','c'][0]"
149
+ "a"
150
+ ```
151
+
152
+ ```bash
153
+ -- 1-based indexing via pragma
154
+ super -s -c "
155
+ pragma index_base = 1
156
+ values ['a','b','c'][1]
157
+ "
158
+ "a"
159
+ ```
160
+
161
+ The pragma affects array/string indexing, slicing, and functions like `SUBSTRING()`.
162
+
163
+ ### unnest with `into` (formerly `=>`)
164
+
165
+ `over this => (...)` becomes `unnest this into (...)`:
166
+
167
+ ```bash
168
+ -- OLD
169
+ zq 'over arr => ( yield this * 2 )'
170
+
171
+ -- NEW
172
+ super -c 'unnest arr into ( values this * 2 )'
173
+ ```
174
+
175
+ ### unnest with multiple values (formerly `with`)
176
+
177
+ `over a with b => (...)` becomes `unnest {b,a} into (...)`.
178
+
179
+ **Warning:** This has behavioral changes. Inside the parentheses, `this` used to
180
+ be just `a` in zq, but now `this` is the record `{b,a}` in super.
181
+
182
+ ### grep requires explicit `this` argument
183
+
184
+ - Inline regexp (`/.../`) syntax removed — use strings
185
+ - Globs no longer supported in grep
186
+ - `this` must be passed explicitly
187
+
188
+ ```bash
189
+ -- OLD (no longer works)
190
+ zq -z "grep(/a*b/,s)"
191
+ zq -z "yield ['a','b'] | grep(/b/)"
192
+
193
+ -- NEW
194
+ super -s -c "grep('a.*b', s)"
195
+ super -s -c "values ['a','b'] | grep('b', this)"
196
+ ```
197
+
198
+ ### is and nest_dotted require explicit `this`
199
+
200
+ ```bash
201
+ -- OLD (no longer works)
202
+ zq -z "yield 2 | is(<int64>)"
203
+
204
+ -- NEW
205
+ super -s -c "values 2 | is(this, <int64>)"
206
+ ```
207
+
208
+ `nest_dotted` follows the same pattern.
209
+
210
+ ### Cast syntax changes
211
+
212
+ Function-style casting (`type(value)`) is no longer supported. Use `::` casting:
213
+
214
+ ```bash
215
+ -- OLD (no longer works)
216
+ zq -z "{a:time('2025-08-28T12:00:00Z')}"
217
+
218
+ -- NEW (preferred)
219
+ super -s -c "{a:'2025-08-28T12:00:00Z'::time}"
220
+ {a:2025-08-28T12:00:00Z}
221
+ ```
222
+
223
+ Alternative syntaxes (legal but not preferred):
224
+ - `cast(value, <type>)`
225
+ - `CAST(value AS type)`
226
+
227
+ ### Lateral subqueries require array wrapping
228
+
229
+ Lateral subqueries that produce multiple values must be wrapped in `[...]`:
230
+
231
+ ```bash
232
+ -- OLD (no longer works - produces error)
233
+ super -s -c "[3,2,1] | { a: ( unnest this | values this ) }"
234
+ {a:error("query expression produced multiple values (consider [subquery])")}
235
+
236
+ -- NEW
237
+ super -s -c "[3,2,1] | { a: [unnest this | values this] }"
238
+ {a:[3,2,1]}
239
+ ```
240
+
241
+ ### User-defined operator syntax
242
+
243
+ **Declaration:** Remove parentheses around parameters.
244
+
245
+ ```bash
246
+ -- OLD
247
+ op myop(a, b): ( ... )
248
+
249
+ -- NEW
250
+ op myop a, b: ( ... )
251
+ ```
252
+
253
+ **Invocation:** Use space-separated arguments (or `call` keyword).
254
+
255
+ ```bash
256
+ -- OLD
257
+ myop(x, y)
258
+
259
+ -- NEW
260
+ myop x, y
261
+ -- or: call myop x, y
262
+ ```
263
+
264
+ ### FROM vs from separation
265
+
266
+ Pipe-operator `from` and SQL `FROM` clause are now distinct. Relational FROM
267
+ requires a SELECT clause:
268
+
269
+ ```bash
270
+ -- OLD (no longer works)
271
+ super -c 'from ( from a )'
272
+
273
+ -- NEW
274
+ super -c 'select * from ( select * from a )'
275
+ ```
276
+
277
+ ### Aggregate filter clause
278
+
279
+ The `where` clause on aggregates changed to SQL-standard `filter`:
280
+
281
+ ```bash
282
+ -- OLD
283
+ count() where grep('bar', this)
284
+
285
+ -- NEW
286
+ count() filter (grep('bar', this))
287
+ ```
288
+
289
+ ## Removed Features
290
+
291
+ ### Streaming aggregation functions
292
+
293
+ Per-record cumulative aggregations are removed.
294
+
295
+ **Row numbering** — use the `count` operator:
296
+
297
+ ```bash
298
+ -- OLD: put row_num:=count(this)
299
+ -- NEW:
300
+ super -s -c 'values {a:1},{b:2},{c:3} | count | {row:count,...that}'
301
+ {row:1,a:1}
302
+ {row:2,b:2}
303
+ {row:3,c:3}
304
+ ```
305
+
306
+ **Other aggregations** (`sum`, `avg`, `min`, `max`, `collect`) — use `aggregate`,
307
+ but note it collapses all records:
308
+
309
+ ```bash
310
+ super -s -c 'values {v:10},{v:20},{v:30} | aggregate total:=sum(v)'
311
+ {total:60}
312
+ ```
313
+
314
+ **No replacement exists** for progressive patterns like streaming `collect`:
315
+
316
+ ```bash
317
+ -- OLD (no longer works): yield 1,2,3 | yield collect(this)
318
+ -- produced: [1], [1,2], [1,2,3]
319
+ ```
320
+
321
+ Grouped aggregation (`collect(x) by key`) still works.
322
+
323
+ ### Removed functions
324
+
325
+ The functions `crop()`, `fill()`, `fit()`, `order()`, and `shape()` have been
326
+ removed. Use cast instead — see Cast syntax changes.
327
+
328
+ ### Inline regexp syntax
329
+
330
+ `/pattern/` is no longer supported. Use string patterns: `'pattern'`
331
+
332
+ ### Globs in grep
333
+
334
+ Globs are no longer supported in the `grep` function. Use regex patterns.
335
+
336
+ ## Type Changes
337
+
338
+ ### Count functions return int64
339
+
340
+ These now return `int64` instead of `uint64`:
341
+ - `count()` function
342
+ - `dcount()` function
343
+ - `uniq` operator count field
344
+ - `count` operator output field
345
+
346
+ ```bash
347
+ -- OLD: returned uint64
348
+ super -s -c "values 1,2,3 | aggregate cnt:=count() | typeof(cnt)"
349
+ <uint64>
350
+
351
+ -- NEW: returns int64
352
+ super -s -c "values 1,2,3 | aggregate cnt:=count() | typeof(cnt)"
353
+ <int64>
354
+ ```
355
+
356
+ ## Advanced/Lake Features
357
+
358
+ ### Robot from f-string syntax
359
+
360
+ Dynamic data source specification now uses f-string syntax. This is primarily
361
+ relevant when using SuperDB with a lake (database):
362
+
363
+ ```bash
364
+ from f'{pool_name}'
365
+ ```
366
+
367
+ If you previously scanned entities within an array of strings, emulate that with
368
+ `unnest` upstream of the robot from.
369
+
370
+ ## Formatting Conventions for AI Upgraders
371
+
372
+ When performing upgrades, follow these formatting conventions for consistency:
373
+
374
+ ### Use double quotes for query strings
375
+
376
+ Single-quoted strings are valid SuperDB syntax, so use double quotes for the
377
+ shell query string to avoid confusion:
378
+
379
+ ```bash
380
+ -- GOOD
381
+ super -s -c "values 'hello'"
382
+
383
+ -- AVOID (works but confusing)
384
+ super -s -c 'values "hello"'
385
+ ```
386
+
387
+ ### Multi-line query formatting
388
+
389
+ For multi-line queries, use this format:
390
+
391
+ ```bash
392
+ super -j -c "
393
+ unnest this
394
+ | cut Id,Name
395
+ " -
396
+ ```
397
+
398
+ - Opening double-quote ends the first line
399
+ - Query content starts on new line, indented 2 spaces from `super`
400
+ - Closing double-quote on its own line, aligned with `super`
401
+
402
+ ### Switch ordering
403
+
404
+ Place `-c` last, with all other switches before it:
405
+
406
+ ```bash
407
+ super -s -f json -c "values this" input.json
408
+ ```
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "superdb-mcp",
3
+ "version": "0.51231.0",
4
+ "description": "MCP server for SuperDB - execute SuperSQL queries, version detection, and embedded documentation",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "superdb-mcp": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "docs"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "start": "node dist/index.js",
17
+ "dev": "tsc --watch",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/chrismo/superdb-mcp.git"
23
+ },
24
+ "keywords": [
25
+ "mcp",
26
+ "superdb",
27
+ "supersql",
28
+ "data",
29
+ "query"
30
+ ],
31
+ "author": "chrismo",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@modelcontextprotocol/sdk": "^1.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^20.0.0",
38
+ "typescript": "^5.0.0"
39
+ },
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ }
43
+ }