@cavelang/cli 0.36.10 → 0.38.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelang/cli",
3
- "version": "0.36.10",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "description": "cave — CLI for parsing, storing, querying and exporting CAVE knowledge.",
6
6
  "keywords": [
@@ -100,26 +100,26 @@
100
100
  "mdast-util-from-markdown": "2.0.3",
101
101
  "mdast-util-gfm-footnote": "2.1.0",
102
102
  "micromark-extension-gfm-footnote": "2.1.0",
103
- "@cavelang/canonical": "0.36.10",
104
- "@cavelang/core": "0.36.10",
105
- "@cavelang/highlight": "0.36.10",
106
- "@cavelang/fusion": "0.36.10",
107
- "@cavelang/parser": "0.36.10",
108
- "@cavelang/query": "0.36.10",
109
- "@cavelang/store": "0.36.10"
103
+ "@cavelang/canonical": "0.38.0",
104
+ "@cavelang/core": "0.38.0",
105
+ "@cavelang/fusion": "0.38.0",
106
+ "@cavelang/highlight": "0.38.0",
107
+ "@cavelang/query": "0.38.0",
108
+ "@cavelang/parser": "0.38.0",
109
+ "@cavelang/store": "0.38.0"
110
110
  },
111
111
  "devDependencies": {
112
- "@cavelang/act": "0.36.10",
113
- "@cavelang/connect": "0.36.10",
114
- "@cavelang/automate": "0.36.10",
115
- "@cavelang/ingest": "0.36.10",
116
- "@cavelang/loop": "0.36.10",
117
- "@cavelang/mcp": "0.36.10",
118
- "@cavelang/rules": "0.36.10",
119
- "@cavelang/eval": "0.36.10",
120
- "@cavelang/shape": "0.36.10",
121
- "@cavelang/sync": "0.36.10",
122
- "@cavelang/view": "0.36.10"
112
+ "@cavelang/act": "0.38.0",
113
+ "@cavelang/automate": "0.38.0",
114
+ "@cavelang/connect": "0.38.0",
115
+ "@cavelang/eval": "0.38.0",
116
+ "@cavelang/ingest": "0.38.0",
117
+ "@cavelang/rules": "0.38.0",
118
+ "@cavelang/loop": "0.38.0",
119
+ "@cavelang/sync": "0.38.0",
120
+ "@cavelang/shape": "0.38.0",
121
+ "@cavelang/mcp": "0.38.0",
122
+ "@cavelang/view": "0.38.0"
123
123
  },
124
124
  "scripts": {
125
125
  "build": "tsc -b && node scripts/consolidate.mjs",
package/src/cli.ts CHANGED
@@ -119,7 +119,7 @@ Usage:
119
119
  cave highlight [file...] print CAVE text with ANSI syntax colors
120
120
  cave add [--db <path>] [file...] ingest into a store [--strict] [--check] [--no-prelude] [--no-src]
121
121
  cave import [--db <path>] [file...] restore/merge from CAVE text (add without @src: stamping)
122
- cave query [--db <path>] <pattern> run a bounded CAVE-Q page [--limit <n>] [--cursor <token>] [--json]
122
+ cave query [--db <path>] <pattern> run a bounded CAVE-Q page [--limit <n>] [--cursor <token>] [--json | --jsonl]
123
123
  cave search [--db <path>] <terms..> full-text search over claims and comments (FTS5) [--raw] [--limit <n>] [--json]
124
124
  cave resolve [--db <path>] contested facts + winners (spec §26) [--aliases] [--policy] [--json]
125
125
  cave derive [--db <path>] [rules.cave..] declare + fire rules (spec §24) [--dry-run] [--full] [--list] [--retract <rule>]
@@ -256,11 +256,13 @@ Examples:
256
256
  query: `cave query — run a CAVE-Q pattern against a store
257
257
 
258
258
  Usage:
259
- cave query [--db <path>] <pattern> [WHERE <filter>] [--limit <n>] [--cursor <token>] [--json] [--all] [--aliases] [--as-of <t>] [--at <t>] [--resolve] [--sources] [--no-prelude]
259
+ cave query [--db <path>] <pattern> [WHERE <filter>] [--limit <n>] [--cursor <token>] [--json | --jsonl] [--all] [--aliases] [--as-of <t>] [--at <t>] [--resolve] [--sources] [--no-prelude]
260
260
 
261
261
  Options:
262
262
  ${dbHelp}
263
263
  --json emit a versioned cave.query-page/v1 JSON object
264
+ --jsonl emit one bindings object per match; next cursor goes to stderr
265
+ (exclusive with --json; no matches produce no output)
264
266
  --limit <n> matches per page (default ${defaultQueryLimit}, maximum 1000)
265
267
  --cursor <t> continue the same frozen query snapshot
266
268
  --all match all beliefs, not just current ones
@@ -1016,6 +1018,7 @@ export const addCommand = ingestCommand('add')
1016
1018
  export const importCommand = ingestCommand('import')
1017
1019
 
1018
1020
  const queryOptions = {
1021
+ jsonl: { type: 'boolean' },
1019
1022
  db: { type: 'string' },
1020
1023
  json: { type: 'boolean' },
1021
1024
  all: { type: 'boolean' },
@@ -1030,6 +1033,7 @@ const queryOptions = {
1030
1033
  } as const
1031
1034
 
1032
1035
  type QueryValues = {
1036
+ jsonl?: boolean
1033
1037
  db?: string
1034
1038
  json?: boolean
1035
1039
  all?: boolean
@@ -1048,6 +1052,9 @@ const parseQuery = (argv: readonly string[]): { values: QueryValues, pattern: st
1048
1052
  if (positionals.length === 0) {
1049
1053
  return { failure: fail('cave query: a pattern is required (spec §12.1)\n') }
1050
1054
  }
1055
+ if (values.json === true && values.jsonl === true) {
1056
+ return { failure: fail('cave query: --json and --jsonl are mutually exclusive\n') }
1057
+ }
1051
1058
  if (values.sources === true && values.cursor !== undefined) {
1052
1059
  return { failure: fail('cave query: --cursor does not apply to --sources — the overlay exists for one invocation and is answered whole\n') }
1053
1060
  }
@@ -1151,6 +1158,13 @@ const renderQueryPage = (
1151
1158
  ): Output => {
1152
1159
  {
1153
1160
  const result = page()
1161
+ if (values.jsonl === true) {
1162
+ return {
1163
+ code: 0,
1164
+ out: result.matches.map(match => `${JSON.stringify(match.bindings)}\n`).join(''),
1165
+ err: result.next === undefined ? '' : `next: ${result.next}\n`
1166
+ }
1167
+ }
1154
1168
  if (values.json === true) {
1155
1169
  return ok(`${JSON.stringify(result, undefined, 2)}\n`)
1156
1170
  }
package/src/commands.ts CHANGED
@@ -18,7 +18,7 @@ export const commandRegistry = [
18
18
  { name: 'highlight', importantOptions: [] },
19
19
  { name: 'add', importantOptions: ['--strict', '--check', '--no-prelude', '--no-src'] },
20
20
  { name: 'import', importantOptions: ['--strict', '--no-prelude'] },
21
- { name: 'query', importantOptions: ['--json', '--limit', '--cursor', '--all', '--aliases', '--as-of', '--at', '--resolve', '--sources', '--no-prelude'] },
21
+ { name: 'query', importantOptions: ['--json', '--jsonl', '--limit', '--cursor', '--all', '--aliases', '--as-of', '--at', '--resolve', '--sources', '--no-prelude'] },
22
22
  { name: 'search', importantOptions: ['--raw', '--limit', '--json', '--no-prelude'] },
23
23
  { name: 'resolve', importantOptions: ['--aliases', '--policy', '--json', '--no-prelude'] },
24
24
  { name: 'derive', importantOptions: ['--dry-run', '--full', '--aliases', '--min-conf', '--max-passes', '--list', '--retract', '--json', '--no-prelude'] },
package/src/main.ts CHANGED
@@ -1,6 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  /** `cave` binary entry point — one lifecycle for every command. */
3
3
 
4
- import { runCli } from './dispatch.ts'
4
+ // Keep runtime warnings out of normal CLI output; debug mode retains Node's
5
+ // warning diagnostics. Install before loading SQLite and delegated commands.
6
+ if (process.env['CAVE_DEBUG'] !== '1') {
7
+ // Node exposes its default printer as an ordinary listener. Its name alone
8
+ // is ambiguous: preload scripts can register their own `onWarning`. Match
9
+ // the printer's internal formatting call too, and preserve every subscriber
10
+ // if Node changes this implementation (covered on each supported runtime).
11
+ const printer = process.listeners('warning').find(listener =>
12
+ listener.name === 'onWarning' &&
13
+ Function.prototype.toString.call(listener).includes('ErrorPrototypeToString(warning)'))
14
+ if (printer !== undefined) process.removeListener('warning', printer)
15
+ }
16
+
17
+ const { runCli } = await import('./dispatch.ts')
5
18
 
6
19
  process.exitCode = await runCli(process.argv.slice(2))