@cavelang/cli 0.4.0 → 0.5.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/dist/src/cli.d.ts +8 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +29 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/main.js +24 -6
- package/dist/src/main.js.map +1 -1
- package/package.json +10 -9
- package/src/cli.ts +31 -0
- package/src/index.ts +1 -1
- package/src/main.ts +24 -7
- package/License.md +0 -6
package/dist/src/cli.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Commands:
|
|
7
7
|
*
|
|
8
8
|
* - `cave parse [file]` — lint / dump the AST (`--json`)
|
|
9
|
+
* - `cave highlight [file]` — ANSI syntax colors (async, routed in `main.ts`)
|
|
9
10
|
* - `cave add [--db <path>] [file…]` — ingest into a store (`--strict`)
|
|
10
11
|
* - `cave query [--db <path>] '<pattern>'` — CAVE-Q (`--json`, `--all`)
|
|
11
12
|
* - `cave export [--db <path>]` — canonical text out (`--current`)
|
|
@@ -21,10 +22,16 @@ export type Output = {
|
|
|
21
22
|
readonly out: string;
|
|
22
23
|
readonly err: string;
|
|
23
24
|
};
|
|
24
|
-
export declare const usage = "cave \u2014 Compressed Atomic Verb Expressions\n\nUsage:\n cave parse [file...] [--json] lint CAVE text (stdin when no file)\n cave add [--db <path>] [file...] ingest into a store [--strict] [--no-prelude]\n cave import [--db <path>] [file...] restore/merge from CAVE text (same as add)\n cave query [--db <path>] <pattern> run a CAVE-Q pattern [--json] [--all] [--no-prelude]\n cave export [--db <path>] [--out <file>] emit canonical CAVE text [--current] [--no-prelude]\n cave mcp [--db <path>] serve the engine as an MCP server on stdio [--no-prelude]\n cave ingest [--db <path>] <globs/urls..> LLM-driven ingestion of files and web pages\n cave demo run the cave-loop reconstruction demo\n cave version print the cave version\n cave help [command] this text, or one command's options and examples\n\nEvery command answers --help. --db defaults to $CAVE_DB, or cave.db in\nthe current directory. The spec lives in the .claude/skills/ directory at\nthe repository root (section index in README.md).";
|
|
25
|
+
export declare const usage = "cave \u2014 Compressed Atomic Verb Expressions\n\nUsage:\n cave parse [file...] [--json] lint CAVE text (stdin when no file)\n cave highlight [file...] print CAVE text with ANSI syntax colors\n cave add [--db <path>] [file...] ingest into a store [--strict] [--no-prelude]\n cave import [--db <path>] [file...] restore/merge from CAVE text (same as add)\n cave query [--db <path>] <pattern> run a CAVE-Q pattern [--json] [--all] [--no-prelude]\n cave export [--db <path>] [--out <file>] emit canonical CAVE text [--current] [--no-prelude]\n cave mcp [--db <path>] serve the engine as an MCP server on stdio [--no-prelude]\n cave ingest [--db <path>] <globs/urls..> LLM-driven ingestion of files and web pages\n cave demo run the cave-loop reconstruction demo\n cave version print the cave version\n cave help [command] this text, or one command's options and examples\n\nEvery command answers --help. --db defaults to $CAVE_DB, or cave.db in\nthe current directory. The spec lives in the .claude/skills/ directory at\nthe repository root (section index in README.md).";
|
|
25
26
|
/** Per-command help, printed for \`cave <command> --help\` and \`cave help <command>\`. */
|
|
26
27
|
export declare const commandHelp: Record<string, string>;
|
|
27
28
|
export declare const parseCommand: (argv: readonly string[]) => Output;
|
|
29
|
+
/**
|
|
30
|
+
* `cave highlight` — ANSI syntax colors from the tree-sitter grammar's own
|
|
31
|
+
* highlight query. Async (the grammar WASM loads on first use), so `main.ts`
|
|
32
|
+
* routes it separately, like `mcp` and `ingest`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const highlightCommand: (argv: readonly string[]) => Promise<Output>;
|
|
28
35
|
export declare const addCommand: (argv: readonly string[]) => Output;
|
|
29
36
|
/**
|
|
30
37
|
* `cave import` — restore/merge a knowledge database from CAVE text files.
|
package/dist/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAWH,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB,CAAA;AAQD,eAAO,MAAM,KAAK,2sCAiBgC,CAAA;AAIlD,2FAA2F;AAC3F,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsH9C,CAAA;AAOD,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAyBtD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,MAAM,SAAS,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CAM9E,CAAA;AA+BD,eAAO,MAAM,UAAU,SA7BwB,SAAS,MAAM,EAAE,KAAG,MA6BrB,CAAA;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,SAzCqB,SAAS,MAAM,EAAE,KAAG,MAyCf,CAAA;AAEpD,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAsCtD,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAuBvD,CAAA;AAED,eAAO,MAAM,WAAW,QAAO,MACS,CAAA;AAExC,eAAO,MAAM,cAAc,QAAO,MACJ,CAAA;AAE9B,wEAAwE;AACxE,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAcrD,CAAA;AAED,iCAAiC;AACjC,eAAO,MAAM,IAAI,GAAI,MAAM,SAAS,MAAM,EAAE,KAAG,MAqC9C,CAAA"}
|
package/dist/src/cli.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Commands:
|
|
7
7
|
*
|
|
8
8
|
* - `cave parse [file]` — lint / dump the AST (`--json`)
|
|
9
|
+
* - `cave highlight [file]` — ANSI syntax colors (async, routed in `main.ts`)
|
|
9
10
|
* - `cave add [--db <path>] [file…]` — ingest into a store (`--strict`)
|
|
10
11
|
* - `cave query [--db <path>] '<pattern>'` — CAVE-Q (`--json`, `--all`)
|
|
11
12
|
* - `cave export [--db <path>]` — canonical text out (`--current`)
|
|
@@ -30,6 +31,7 @@ export const usage = `cave — Compressed Atomic Verb Expressions
|
|
|
30
31
|
|
|
31
32
|
Usage:
|
|
32
33
|
cave parse [file...] [--json] lint CAVE text (stdin when no file)
|
|
34
|
+
cave highlight [file...] print CAVE text with ANSI syntax colors
|
|
33
35
|
cave add [--db <path>] [file...] ingest into a store [--strict] [--no-prelude]
|
|
34
36
|
cave import [--db <path>] [file...] restore/merge from CAVE text (same as add)
|
|
35
37
|
cave query [--db <path>] <pattern> run a CAVE-Q pattern [--json] [--all] [--no-prelude]
|
|
@@ -61,6 +63,21 @@ Examples:
|
|
|
61
63
|
cave parse notes.cave
|
|
62
64
|
echo 'auth USES jwt @ 90%' | cave parse
|
|
63
65
|
cave parse notes.cave --json | jq '.lines[0]'`,
|
|
66
|
+
highlight: `cave highlight — print CAVE text with ANSI syntax colors
|
|
67
|
+
|
|
68
|
+
Usage:
|
|
69
|
+
cave highlight [file...]
|
|
70
|
+
|
|
71
|
+
Reads stdin when no file (or \`-\`) is given. Colors come from the
|
|
72
|
+
tree-sitter grammar's highlight query (@cavelang/tree-sitter-cave), the
|
|
73
|
+
same source editors use. Output always carries ANSI codes — pipe through
|
|
74
|
+
\`less -R\` to page. \`cave export\` colors its output the same way when
|
|
75
|
+
stdout is a terminal (disable with NO_COLOR).
|
|
76
|
+
|
|
77
|
+
Examples:
|
|
78
|
+
cave highlight notes.cave
|
|
79
|
+
echo 'auth USES jwt @ 90%' | cave highlight
|
|
80
|
+
cave highlight notes.cave | less -R`,
|
|
64
81
|
add: `cave add — ingest CAVE text into a knowledge database
|
|
65
82
|
|
|
66
83
|
Usage:
|
|
@@ -171,6 +188,18 @@ export const parseCommand = (argv) => {
|
|
|
171
188
|
.join('\n');
|
|
172
189
|
return { code: 1, out: `${summary}\n`, err: `${problems}\n` };
|
|
173
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* `cave highlight` — ANSI syntax colors from the tree-sitter grammar's own
|
|
193
|
+
* highlight query. Async (the grammar WASM loads on first use), so `main.ts`
|
|
194
|
+
* routes it separately, like `mcp` and `ingest`.
|
|
195
|
+
*/
|
|
196
|
+
export const highlightCommand = async (argv) => {
|
|
197
|
+
const { positionals } = parseArgs({ args: [...argv], options: {}, allowPositionals: true });
|
|
198
|
+
const input = readInput(positionals);
|
|
199
|
+
const { highlighter } = await import('@cavelang/highlight');
|
|
200
|
+
const { ansi } = await highlighter();
|
|
201
|
+
return ok(ansi(input));
|
|
202
|
+
};
|
|
174
203
|
const ingestCommand = (name) => (argv) => {
|
|
175
204
|
const { values, positionals } = parseArgs({
|
|
176
205
|
args: [...argv],
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE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AI,CAAC,CAAA;QAC1C,CAAC;QACD,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,OAAO;gBACV,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;YAC3B,KAAK,KAAK;gBACR,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;YACzB,KAAK,QAAQ;gBACX,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;YAC5B,KAAK,OAAO;gBACV,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;YAC3B,KAAK,QAAQ;gBACX,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;YAC5B,KAAK,MAAM;gBACT,OAAO,WAAW,EAAE,CAAA;YACtB,KAAK,SAAS,CAAC;YACf,KAAK,WAAW,CAAC;YACjB,KAAK,IAAI;gBACP,OAAO,cAAc,EAAE,CAAA;YACzB,KAAK,MAAM;gBACT,OAAO,WAAW,CAAC,IAAI,CAAC,CAAA;YAC1B,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ,CAAC;YACd,KAAK,IAAI;gBACP,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAA;YACzB;gBACE,OAAO,IAAI,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC,CAAC,CAAA;QACpF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5E,CAAC;AACH,CAAC,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* `@cavelang/cli` — the `cave` command (parse / add / query / export / demo).
|
|
3
3
|
* Programmatic access to the same implementations lives here.
|
|
4
4
|
*/
|
|
5
|
-
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from './cli.ts';
|
|
5
|
+
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, highlightCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from './cli.ts';
|
|
6
6
|
export type { Output } from './cli.ts';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACrL,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* `@cavelang/cli` — the `cave` command (parse / add / query / export / demo).
|
|
3
3
|
* Programmatic access to the same implementations lives here.
|
|
4
4
|
*/
|
|
5
|
-
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from "./cli.js";
|
|
5
|
+
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, highlightCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from "./cli.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/src/main.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** `cave` binary entry point — see `cli.ts` for the command implementations. */
|
|
3
|
-
import { cave } from "./cli.js";
|
|
3
|
+
import { cave, highlightCommand } from "./cli.js";
|
|
4
|
+
const write = (code, out, err) => {
|
|
5
|
+
if (out !== '') {
|
|
6
|
+
process.stdout.write(out);
|
|
7
|
+
}
|
|
8
|
+
if (err !== '') {
|
|
9
|
+
process.stderr.write(err);
|
|
10
|
+
}
|
|
11
|
+
process.exitCode = code;
|
|
12
|
+
};
|
|
4
13
|
// mcp and ingest own their help text, so `cave help X` becomes `cave X --help`.
|
|
5
14
|
const raw = process.argv.slice(2);
|
|
6
15
|
const argv = raw[0] === 'help' && (raw[1] === 'mcp' || raw[1] === 'ingest') ?
|
|
@@ -16,14 +25,23 @@ else if (argv[0] === 'ingest') {
|
|
|
16
25
|
const { runIngest } = await import('@cavelang/ingest');
|
|
17
26
|
process.exitCode = await runIngest(argv.slice(1));
|
|
18
27
|
}
|
|
28
|
+
else if (argv[0] === 'highlight' && !argv.includes('--help') && !argv.includes('-h')) {
|
|
29
|
+
// Async (grammar WASM loads on first use); --help stays on the sync path.
|
|
30
|
+
const { code, out, err } = await highlightCommand(argv.slice(1));
|
|
31
|
+
write(code, out, err);
|
|
32
|
+
}
|
|
19
33
|
else {
|
|
20
34
|
const { code, out, err } = cave(argv);
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
// Canonical CAVE text going to a terminal gets syntax colors from the same
|
|
36
|
+
// grammar query `cave highlight` uses; piping or NO_COLOR keeps bytes clean.
|
|
37
|
+
const colorize = code === 0 && argv[0] === 'export' && !argv.includes('--out') &&
|
|
38
|
+
out !== '' && process.stdout.isTTY === true && process.env['NO_COLOR'] === undefined;
|
|
39
|
+
if (colorize) {
|
|
40
|
+
const { highlighter } = await import('@cavelang/highlight');
|
|
41
|
+
write(code, (await highlighter()).ansi(out), err);
|
|
23
42
|
}
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
else {
|
|
44
|
+
write(code, out, err);
|
|
26
45
|
}
|
|
27
|
-
process.exitCode = code;
|
|
28
46
|
}
|
|
29
47
|
//# sourceMappingURL=main.js.map
|
package/dist/src/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";AACA,gFAAgF;AAEhF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";AACA,gFAAgF;AAEhF,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEjD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,GAAW,EAAQ,EAAE;IAC7D,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;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AAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IAChE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AACvB,CAAC;KAAM,CAAC;IACN,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IACrC,2EAA2E;IAC3E,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC5E,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,CAAA;IACtF,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;QAC3D,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IACnD,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACvB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cavelang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cave — CLI for parsing, storing, querying and exporting CAVE knowledge.",
|
|
6
6
|
"license": "CC0-1.0",
|
|
@@ -39,14 +39,15 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@cavelang/
|
|
43
|
-
"@cavelang/
|
|
44
|
-
"@cavelang/ingest": "0.
|
|
45
|
-
"@cavelang/
|
|
46
|
-
"@cavelang/
|
|
47
|
-
"@cavelang/
|
|
48
|
-
"@cavelang/
|
|
49
|
-
"@cavelang/
|
|
42
|
+
"@cavelang/canonical": "0.5.0",
|
|
43
|
+
"@cavelang/core": "0.5.0",
|
|
44
|
+
"@cavelang/ingest": "0.5.0",
|
|
45
|
+
"@cavelang/highlight": "0.5.0",
|
|
46
|
+
"@cavelang/loop": "0.5.0",
|
|
47
|
+
"@cavelang/mcp": "0.5.0",
|
|
48
|
+
"@cavelang/parser": "0.5.0",
|
|
49
|
+
"@cavelang/query": "0.5.0",
|
|
50
|
+
"@cavelang/store": "0.5.0"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
53
|
"build": "tsc -b",
|
package/src/cli.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Commands:
|
|
7
7
|
*
|
|
8
8
|
* - `cave parse [file]` — lint / dump the AST (`--json`)
|
|
9
|
+
* - `cave highlight [file]` — ANSI syntax colors (async, routed in `main.ts`)
|
|
9
10
|
* - `cave add [--db <path>] [file…]` — ingest into a store (`--strict`)
|
|
10
11
|
* - `cave query [--db <path>] '<pattern>'` — CAVE-Q (`--json`, `--all`)
|
|
11
12
|
* - `cave export [--db <path>]` — canonical text out (`--current`)
|
|
@@ -42,6 +43,7 @@ export const usage = `cave — Compressed Atomic Verb Expressions
|
|
|
42
43
|
|
|
43
44
|
Usage:
|
|
44
45
|
cave parse [file...] [--json] lint CAVE text (stdin when no file)
|
|
46
|
+
cave highlight [file...] print CAVE text with ANSI syntax colors
|
|
45
47
|
cave add [--db <path>] [file...] ingest into a store [--strict] [--no-prelude]
|
|
46
48
|
cave import [--db <path>] [file...] restore/merge from CAVE text (same as add)
|
|
47
49
|
cave query [--db <path>] <pattern> run a CAVE-Q pattern [--json] [--all] [--no-prelude]
|
|
@@ -76,6 +78,22 @@ Examples:
|
|
|
76
78
|
echo 'auth USES jwt @ 90%' | cave parse
|
|
77
79
|
cave parse notes.cave --json | jq '.lines[0]'`,
|
|
78
80
|
|
|
81
|
+
highlight: `cave highlight — print CAVE text with ANSI syntax colors
|
|
82
|
+
|
|
83
|
+
Usage:
|
|
84
|
+
cave highlight [file...]
|
|
85
|
+
|
|
86
|
+
Reads stdin when no file (or \`-\`) is given. Colors come from the
|
|
87
|
+
tree-sitter grammar's highlight query (@cavelang/tree-sitter-cave), the
|
|
88
|
+
same source editors use. Output always carries ANSI codes — pipe through
|
|
89
|
+
\`less -R\` to page. \`cave export\` colors its output the same way when
|
|
90
|
+
stdout is a terminal (disable with NO_COLOR).
|
|
91
|
+
|
|
92
|
+
Examples:
|
|
93
|
+
cave highlight notes.cave
|
|
94
|
+
echo 'auth USES jwt @ 90%' | cave highlight
|
|
95
|
+
cave highlight notes.cave | less -R`,
|
|
96
|
+
|
|
79
97
|
add: `cave add — ingest CAVE text into a knowledge database
|
|
80
98
|
|
|
81
99
|
Usage:
|
|
@@ -195,6 +213,19 @@ export const parseCommand = (argv: readonly string[]): Output => {
|
|
|
195
213
|
return { code: 1, out: `${summary}\n`, err: `${problems}\n` }
|
|
196
214
|
}
|
|
197
215
|
|
|
216
|
+
/**
|
|
217
|
+
* `cave highlight` — ANSI syntax colors from the tree-sitter grammar's own
|
|
218
|
+
* highlight query. Async (the grammar WASM loads on first use), so `main.ts`
|
|
219
|
+
* routes it separately, like `mcp` and `ingest`.
|
|
220
|
+
*/
|
|
221
|
+
export const highlightCommand = async (argv: readonly string[]): Promise<Output> => {
|
|
222
|
+
const { positionals } = parseArgs({ args: [...argv], options: {}, allowPositionals: true })
|
|
223
|
+
const input = readInput(positionals)
|
|
224
|
+
const { highlighter } = await import('@cavelang/highlight')
|
|
225
|
+
const { ansi } = await highlighter()
|
|
226
|
+
return ok(ansi(input))
|
|
227
|
+
}
|
|
228
|
+
|
|
198
229
|
const ingestCommand = (name: string) => (argv: readonly string[]): Output => {
|
|
199
230
|
const { values, positionals } = parseArgs({
|
|
200
231
|
args: [...argv],
|
package/src/index.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Programmatic access to the same implementations lives here.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from './cli.ts'
|
|
6
|
+
export { addCommand, cave, commandHelp, demoCommand, exportCommand, helpCommand, highlightCommand, importCommand, parseCommand, queryCommand, usage, versionCommand } from './cli.ts'
|
|
7
7
|
export type { Output } from './cli.ts'
|
package/src/main.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** `cave` binary entry point — see `cli.ts` for the command implementations. */
|
|
3
3
|
|
|
4
|
-
import { cave } from './cli.ts'
|
|
4
|
+
import { cave, highlightCommand } from './cli.ts'
|
|
5
|
+
|
|
6
|
+
const write = (code: number, out: string, err: string): void => {
|
|
7
|
+
if (out !== '') {
|
|
8
|
+
process.stdout.write(out)
|
|
9
|
+
}
|
|
10
|
+
if (err !== '') {
|
|
11
|
+
process.stderr.write(err)
|
|
12
|
+
}
|
|
13
|
+
process.exitCode = code
|
|
14
|
+
}
|
|
5
15
|
|
|
6
16
|
// mcp and ingest own their help text, so `cave help X` becomes `cave X --help`.
|
|
7
17
|
const raw = process.argv.slice(2)
|
|
@@ -16,13 +26,20 @@ if (argv[0] === 'mcp') {
|
|
|
16
26
|
// Long-running: drives an LLM agent over batches of files.
|
|
17
27
|
const { runIngest } = await import('@cavelang/ingest')
|
|
18
28
|
process.exitCode = await runIngest(argv.slice(1))
|
|
29
|
+
} else if (argv[0] === 'highlight' && !argv.includes('--help') && !argv.includes('-h')) {
|
|
30
|
+
// Async (grammar WASM loads on first use); --help stays on the sync path.
|
|
31
|
+
const { code, out, err } = await highlightCommand(argv.slice(1))
|
|
32
|
+
write(code, out, err)
|
|
19
33
|
} else {
|
|
20
34
|
const { code, out, err } = cave(argv)
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
// Canonical CAVE text going to a terminal gets syntax colors from the same
|
|
36
|
+
// grammar query `cave highlight` uses; piping or NO_COLOR keeps bytes clean.
|
|
37
|
+
const colorize = code === 0 && argv[0] === 'export' && !argv.includes('--out') &&
|
|
38
|
+
out !== '' && process.stdout.isTTY === true && process.env['NO_COLOR'] === undefined
|
|
39
|
+
if (colorize) {
|
|
40
|
+
const { highlighter } = await import('@cavelang/highlight')
|
|
41
|
+
write(code, (await highlighter()).ansi(out), err)
|
|
42
|
+
} else {
|
|
43
|
+
write(code, out, err)
|
|
23
44
|
}
|
|
24
|
-
if (err !== '') {
|
|
25
|
-
process.stderr.write(err)
|
|
26
|
-
}
|
|
27
|
-
process.exitCode = code
|
|
28
45
|
}
|
package/License.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
|
2
|
-
|
|
3
|
-
To the extent possible under law, the authors listed in [Authors.md](./Authors.md) have waived all copyright and related or neighboring rights to this software and associated documentation files (the "Software").
|
|
4
|
-
|
|
5
|
-
For more information, please see:
|
|
6
|
-
https://creativecommons.org/publicdomain/zero/1.0/
|