incur 0.3.25 → 0.4.1
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/README.md +11 -11
- package/SKILL.md +6 -6
- package/dist/Cli.js +14 -14
- package/dist/Cli.js.map +1 -1
- package/dist/Help.js +1 -1
- package/dist/Help.js.map +1 -1
- package/package.json +1 -1
- package/src/Cli.test.ts +64 -41
- package/src/Cli.ts +14 -14
- package/src/Help.test.ts +17 -17
- package/src/Help.ts +1 -1
- package/src/Openapi.test.ts +4 -4
- package/src/e2e.test.ts +59 -41
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
- [**`--llms` flag**](#agent-discovery): token-efficient command manifest in Markdown or JSON schema
|
|
41
41
|
- [**Well-formed I/O**](#well-formed-io): Schemas schemas for arguments, options, environment variables, and output
|
|
42
42
|
- [**Inferred types**](#inferred-types): generic type flow from schemas to `run` callbacks with zero manual annotations
|
|
43
|
-
- [**Global options**](#global-options): `--format`, `--
|
|
43
|
+
- [**Global options**](#global-options): `--format`, `--full-output`, `--help`, `--json`, `--version` on every CLI for free
|
|
44
44
|
- [**Light API surface**](#light-api-surface): `Cli.create()`, `.command()`, `.serve()` – that's it
|
|
45
45
|
- [**Middleware**](#middleware): composable before/after hooks with typed dependency injection via `cli.use()`
|
|
46
46
|
|
|
@@ -116,6 +116,7 @@ $ greet --help
|
|
|
116
116
|
# Global Options:
|
|
117
117
|
# --filter-output <keys> Filter output by key paths (e.g. foo,bar.baz,a[0,3])
|
|
118
118
|
# --format <toon|json|yaml|md|jsonl> Output format
|
|
119
|
+
# --full-output Show full output envelope
|
|
119
120
|
# --help Show help
|
|
120
121
|
# --llms Print LLM-readable manifest
|
|
121
122
|
# --mcp Start as MCP stdio server
|
|
@@ -123,7 +124,6 @@ $ greet --help
|
|
|
123
124
|
# --token-count Print token count of output instead of output
|
|
124
125
|
# --token-limit <n> Limit output to n tokens
|
|
125
126
|
# --token-offset <n> Skip first n tokens of output (for pagination)
|
|
126
|
-
# --verbose Show full output envelope
|
|
127
127
|
# --version Show version
|
|
128
128
|
```
|
|
129
129
|
|
|
@@ -186,6 +186,7 @@ $ my-cli --help
|
|
|
186
186
|
# Global Options:
|
|
187
187
|
# --filter-output <keys> Filter output by key paths (e.g. foo,bar.baz,a[0,3])
|
|
188
188
|
# --format <toon|json|yaml|md|jsonl> Output format
|
|
189
|
+
# --full-output Show full output envelope
|
|
189
190
|
# --help Show help
|
|
190
191
|
# --llms Print LLM-readable manifest
|
|
191
192
|
# --mcp Start as MCP stdio server
|
|
@@ -193,7 +194,6 @@ $ my-cli --help
|
|
|
193
194
|
# --token-count Print token count of output instead of output
|
|
194
195
|
# --token-limit <n> Limit output to n tokens
|
|
195
196
|
# --token-offset <n> Skip first n tokens of output (for pagination)
|
|
196
|
-
# --verbose Show full output envelope
|
|
197
197
|
# --version Show version
|
|
198
198
|
```
|
|
199
199
|
|
|
@@ -243,6 +243,7 @@ $ my-cli --help
|
|
|
243
243
|
# Global Options:
|
|
244
244
|
# --filter-output <keys> Filter output by key paths (e.g. foo,bar.baz,a[0,3])
|
|
245
245
|
# --format <toon|json|yaml|md|jsonl> Output format
|
|
246
|
+
# --full-output Show full output envelope
|
|
246
247
|
# --help Show help
|
|
247
248
|
# --llms Print LLM-readable manifest
|
|
248
249
|
# --mcp Start as MCP stdio server
|
|
@@ -250,7 +251,6 @@ $ my-cli --help
|
|
|
250
251
|
# --token-count Print token count of output instead of output
|
|
251
252
|
# --token-limit <n> Limit output to n tokens
|
|
252
253
|
# --token-offset <n> Skip first n tokens of output (for pagination)
|
|
253
|
-
# --verbose Show full output envelope
|
|
254
254
|
# --version Show version
|
|
255
255
|
```
|
|
256
256
|
|
|
@@ -370,7 +370,7 @@ GET /users/42 → my-cli users 42
|
|
|
370
370
|
POST /users { "name": "Bob" } → my-cli users --name Bob
|
|
371
371
|
```
|
|
372
372
|
|
|
373
|
-
Responses use the same JSON envelope as `--
|
|
373
|
+
Responses use the same JSON envelope as `--full-output --format json`:
|
|
374
374
|
|
|
375
375
|
```json
|
|
376
376
|
{ "ok": true, "data": { "users": [...] }, "meta": { "command": "users", "duration": "3ms" } }
|
|
@@ -411,7 +411,7 @@ my-cli --llms
|
|
|
411
411
|
|
|
412
412
|
Most CLIs expose tools via MCP or a single monolithic skill file. incur combines on-demand skill loading with TOON output to cut token usage across the entire session – from discovery through invocation and response.
|
|
413
413
|
|
|
414
|
-
The table below models a session with a 20-command CLI producing
|
|
414
|
+
The table below models a session with a 20-command CLI producing full output envelopes.
|
|
415
415
|
|
|
416
416
|
- **Session start** – tokens consumed just by having the tool available. _MCP injects all tool schemas into every turn; skills only load frontmatter (name + description)._
|
|
417
417
|
- **Discovery** – tokens to learn what commands exist and how to call them. _MCP gets this at session start; skills load the full skill file on demand; incur splits by command group so only relevant commands are loaded._
|
|
@@ -620,7 +620,7 @@ cli.command('greet', {
|
|
|
620
620
|
|
|
621
621
|
### Output policy
|
|
622
622
|
|
|
623
|
-
Control whether output data is displayed to humans. By default, output goes to everyone (`'all'`). Set `outputPolicy: 'agent-only'` to suppress data in TTY mode while still returning it to agents via `--json`, `--format`, or `--
|
|
623
|
+
Control whether output data is displayed to humans. By default, output goes to everyone (`'all'`). Set `outputPolicy: 'agent-only'` to suppress data in TTY mode while still returning it to agents via `--json`, `--format`, or `--full-output`.
|
|
624
624
|
|
|
625
625
|
```ts
|
|
626
626
|
cli.command('deploy', {
|
|
@@ -803,18 +803,18 @@ Every incur CLI includes these flags automatically:
|
|
|
803
803
|
|
|
804
804
|
| Flag | Description |
|
|
805
805
|
| ------------------------ | ------------------------------------------------------ |
|
|
806
|
+
| `--filter-output <keys>` | Filter output by key paths (e.g. `foo,bar.baz,a[0,3]`) |
|
|
807
|
+
| `--format <fmt>` | Output format: `toon`, `json`, `yaml`, `md` |
|
|
808
|
+
| `--full-output` | Include full envelope (`ok`, `data`, `meta`) |
|
|
806
809
|
| `--help`, `-h` | Show help for the CLI or a specific command |
|
|
807
|
-
| `--version` | Print CLI version |
|
|
808
810
|
| `--llms` | Output agent-readable command manifest |
|
|
809
811
|
| `--mcp` | Start as an MCP stdio server |
|
|
810
812
|
| `--json` | Shorthand for `--format json` |
|
|
811
|
-
| `--format <fmt>` | Output format: `toon`, `json`, `yaml`, `md` |
|
|
812
|
-
| `--filter-output <keys>` | Filter output by key paths (e.g. `foo,bar.baz,a[0,3]`) |
|
|
813
813
|
| `--schema` | Show JSON Schema for command's args, options, output |
|
|
814
814
|
| `--token-count` | Print token count of output instead of output |
|
|
815
815
|
| `--token-limit <n>` | Limit output to n tokens (for pagination) |
|
|
816
816
|
| `--token-offset <n>` | Skip first n tokens of output (for pagination) |
|
|
817
|
-
| `--
|
|
817
|
+
| `--version` | Print CLI version |
|
|
818
818
|
|
|
819
819
|
### Config file
|
|
820
820
|
|
package/SKILL.md
CHANGED
|
@@ -419,10 +419,10 @@ Control with `--format <fmt>` or `--json`:
|
|
|
419
419
|
|
|
420
420
|
### Envelope
|
|
421
421
|
|
|
422
|
-
With `--
|
|
422
|
+
With `--full-output`, the full envelope is emitted:
|
|
423
423
|
|
|
424
424
|
```sh
|
|
425
|
-
tool info express --
|
|
425
|
+
tool info express --full-output
|
|
426
426
|
```
|
|
427
427
|
|
|
428
428
|
```
|
|
@@ -435,7 +435,7 @@ meta:
|
|
|
435
435
|
duration: 12ms
|
|
436
436
|
```
|
|
437
437
|
|
|
438
|
-
Without `--
|
|
438
|
+
Without `--full-output`, only `data` is emitted. On errors, only the `error` block is emitted.
|
|
439
439
|
|
|
440
440
|
### Filtering output
|
|
441
441
|
|
|
@@ -482,7 +482,7 @@ tool users --token-limit 20
|
|
|
482
482
|
tool users --token-offset 20 --token-limit 20
|
|
483
483
|
```
|
|
484
484
|
|
|
485
|
-
With `--
|
|
485
|
+
With `--full-output`, truncated output includes `meta.nextOffset` for programmatic pagination.
|
|
486
486
|
|
|
487
487
|
### Command schema
|
|
488
488
|
|
|
@@ -725,7 +725,7 @@ Use `--llms --format json` for JSON schema manifest:
|
|
|
725
725
|
| `--mcp` | Start as an MCP stdio server |
|
|
726
726
|
| `--json` | Shorthand for `--format json` |
|
|
727
727
|
| `--format <fmt>` | Output format: `toon`, `json`, `yaml`, `md` |
|
|
728
|
-
| `--
|
|
728
|
+
| `--full-output` | Include full envelope (`ok`, `data`, `meta`) |
|
|
729
729
|
|
|
730
730
|
## Examples
|
|
731
731
|
|
|
@@ -760,7 +760,7 @@ Hints are displayed after examples in help output and included in skill files.
|
|
|
760
760
|
|
|
761
761
|
### Output policy
|
|
762
762
|
|
|
763
|
-
Control whether output data is displayed to humans. `'all'` (default) shows output to everyone. `'agent-only'` suppresses data in human/TTY mode while still returning it via `--json`, `--format`, or `--
|
|
763
|
+
Control whether output data is displayed to humans. `'all'` (default) shows output to everyone. `'agent-only'` suppresses data in human/TTY mode while still returning it via `--json`, `--format`, or `--full-output`.
|
|
764
764
|
|
|
765
765
|
```ts
|
|
766
766
|
cli.command('deploy', {
|
package/dist/Cli.js
CHANGED
|
@@ -163,7 +163,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
163
163
|
exit(1);
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
|
-
const {
|
|
166
|
+
const { fullOutput, format: formatFlag, formatExplicit, filterOutput, tokenLimit, tokenOffset, tokenCount, llms, llmsFull, mcp: mcpFlag, help, version, schema, configPath, configDisabled, rest: filtered, } = builtinFlags;
|
|
167
167
|
// --mcp: start as MCP stdio server
|
|
168
168
|
if (mcpFlag) {
|
|
169
169
|
await Mcp.serve(name, options.version ?? '0.0.0', commands, {
|
|
@@ -429,9 +429,9 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
429
429
|
lines.push('');
|
|
430
430
|
lines.push(`Run \`${name} --help\` to see the full command reference.`);
|
|
431
431
|
writeln(lines.join('\n'));
|
|
432
|
-
if (
|
|
432
|
+
if (fullOutput || formatExplicit) {
|
|
433
433
|
const output = { skills: result.paths };
|
|
434
|
-
if (
|
|
434
|
+
if (fullOutput && result.agents.length > 0)
|
|
435
435
|
output.agents = result.agents;
|
|
436
436
|
writeln(Formatter.format(output, formatExplicit ? formatFlag : 'toon'));
|
|
437
437
|
}
|
|
@@ -512,7 +512,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
512
512
|
lines.push(` "${s}"`);
|
|
513
513
|
}
|
|
514
514
|
writeln(lines.join('\n'));
|
|
515
|
-
if (
|
|
515
|
+
if (fullOutput || formatExplicit)
|
|
516
516
|
writeln(Formatter.format({ name, command: result.command, agents: result.agents }, formatExplicit ? formatFlag : 'toon'));
|
|
517
517
|
}
|
|
518
518
|
catch (err) {
|
|
@@ -769,7 +769,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
769
769
|
return writeln(String(estimateTokenCount(formatted)));
|
|
770
770
|
}
|
|
771
771
|
const cta = output.meta.cta;
|
|
772
|
-
if (human && !
|
|
772
|
+
if (human && !fullOutput) {
|
|
773
773
|
if (output.ok && output.data != null && renderOutput) {
|
|
774
774
|
const t = truncate(Formatter.format(output.data, format));
|
|
775
775
|
writeln(t.text);
|
|
@@ -780,7 +780,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
780
780
|
writeln(formatHumanCta(cta));
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
|
-
if (
|
|
783
|
+
if (fullOutput) {
|
|
784
784
|
if (tokenLimit != null || tokenOffset != null) {
|
|
785
785
|
// Truncate data separately so meta (including nextOffset) is always visible
|
|
786
786
|
const dataFormatted = output.ok && output.data != null
|
|
@@ -832,7 +832,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
832
832
|
description: ctaCommands.length === 1 ? 'Suggested command:' : 'Suggested commands:',
|
|
833
833
|
commands: ctaCommands,
|
|
834
834
|
};
|
|
835
|
-
if (human && !
|
|
835
|
+
if (human && !fullOutput) {
|
|
836
836
|
writeln(formatHumanError({ code: 'COMMAND_NOT_FOUND', message }));
|
|
837
837
|
const mergedCta = skillsCta
|
|
838
838
|
? { ...cta, commands: [...cta.commands, ...skillsCta.commands] }
|
|
@@ -877,7 +877,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
877
877
|
formatExplicit,
|
|
878
878
|
human,
|
|
879
879
|
renderOutput,
|
|
880
|
-
|
|
880
|
+
fullOutput,
|
|
881
881
|
truncate,
|
|
882
882
|
write,
|
|
883
883
|
writeln,
|
|
@@ -1040,7 +1040,7 @@ async function serveImpl(name, commands, argv, options = {}) {
|
|
|
1040
1040
|
formatExplicit,
|
|
1041
1041
|
human,
|
|
1042
1042
|
renderOutput,
|
|
1043
|
-
|
|
1043
|
+
fullOutput,
|
|
1044
1044
|
truncate,
|
|
1045
1045
|
write,
|
|
1046
1046
|
writeln,
|
|
@@ -1414,10 +1414,10 @@ function resolveCommand(commands, tokens) {
|
|
|
1414
1414
|
...(outputPolicy ? { outputPolicy } : undefined),
|
|
1415
1415
|
};
|
|
1416
1416
|
}
|
|
1417
|
-
/** @internal Extracts built-in flags (--
|
|
1417
|
+
/** @internal Extracts built-in flags (--full-output, --format, --json, --llms, --help, --version) from argv. */
|
|
1418
1418
|
const validFormats = new Set(['toon', 'json', 'yaml', 'md', 'jsonl']);
|
|
1419
1419
|
function extractBuiltinFlags(argv, options = {}) {
|
|
1420
|
-
let
|
|
1420
|
+
let fullOutput = false;
|
|
1421
1421
|
let llms = false;
|
|
1422
1422
|
let llmsFull = false;
|
|
1423
1423
|
let mcp = false;
|
|
@@ -1438,8 +1438,8 @@ function extractBuiltinFlags(argv, options = {}) {
|
|
|
1438
1438
|
const noCfgFlag = options.configFlag ? `--no-${options.configFlag}` : undefined;
|
|
1439
1439
|
for (let i = 0; i < argv.length; i++) {
|
|
1440
1440
|
const token = argv[i];
|
|
1441
|
-
if (token === '--
|
|
1442
|
-
|
|
1441
|
+
if (token === '--full-output')
|
|
1442
|
+
fullOutput = true;
|
|
1443
1443
|
else if (token === '--llms')
|
|
1444
1444
|
llms = true;
|
|
1445
1445
|
else if (token === '--llms-full')
|
|
@@ -1508,7 +1508,7 @@ function extractBuiltinFlags(argv, options = {}) {
|
|
|
1508
1508
|
rest.push(token);
|
|
1509
1509
|
}
|
|
1510
1510
|
return {
|
|
1511
|
-
|
|
1511
|
+
fullOutput,
|
|
1512
1512
|
format,
|
|
1513
1513
|
formatExplicit,
|
|
1514
1514
|
configPath,
|