@formant/formant-cli 0.4.5 → 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/README.md +82 -1
- package/dist/base-command.d.ts +17 -0
- package/dist/base-command.js +33 -0
- package/dist/base-command.js.map +1 -1
- package/dist/help.js +2 -0
- package/dist/help.js.map +1 -1
- package/oclif.manifest.json +1711 -1131
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -171,7 +171,7 @@ The CLI will automatically load credentials from your `.env` file.
|
|
|
171
171
|
## Quick Start
|
|
172
172
|
|
|
173
173
|
```bash
|
|
174
|
-
# View your organization
|
|
174
|
+
# View your organization (add --toon for compact output, --json for machine-readable)
|
|
175
175
|
fcli org get
|
|
176
176
|
|
|
177
177
|
# List devices with data
|
|
@@ -468,6 +468,7 @@ These flags work with any command:
|
|
|
468
468
|
- `--dev` — Target the dev environment (for testing)
|
|
469
469
|
- `--stage` — Target the stage environment (for staging)
|
|
470
470
|
- `--json` — Output raw JSON instead of formatted tables
|
|
471
|
+
- `--toon` — Output data in TOON (Token-Oriented Object Notation) format
|
|
471
472
|
- `-h, --help` — Show help for any command
|
|
472
473
|
|
|
473
474
|
**Default environment:** Production (unless `--dev` or `--stage` is specified)
|
|
@@ -550,6 +551,60 @@ Use with `jq` for advanced processing:
|
|
|
550
551
|
fcli device list --json | jq '.items[] | select(.online==true) | .name'
|
|
551
552
|
```
|
|
552
553
|
|
|
554
|
+
### TOON
|
|
555
|
+
|
|
556
|
+
**`--toon` is the recommended output format when working with AI tools, LLM prompts, or any context where token efficiency matters.**
|
|
557
|
+
|
|
558
|
+
TOON (Token-Oriented Object Notation) is a compact, schema-aware encoding of structured data that is both human-readable and significantly more token-efficient than JSON — making it ideal for pasting into LLM prompts, storing in context windows, and scripting with AI agents.
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
$ fcli org get --toon
|
|
562
|
+
name: Acme Robotics
|
|
563
|
+
id: 6380a48c-0847-4543-a67f-9b7ccc41ec21
|
|
564
|
+
plan: paid
|
|
565
|
+
daysDataRetained: 600
|
|
566
|
+
aiEnabled: true
|
|
567
|
+
investigationsEnabled: true
|
|
568
|
+
flags[19]: settings.role,settings.user,settings.device,...
|
|
569
|
+
billingInfo:
|
|
570
|
+
usagePrices:
|
|
571
|
+
devices: 1100
|
|
572
|
+
dataPoints: 0.00015
|
|
573
|
+
bytes: 3e-9
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
$ fcli user list --toon
|
|
578
|
+
items[2]{id,email,firstName,lastName,enabled}:
|
|
579
|
+
4f79f32b-...,alice@acme.io,Alice,Smith,true
|
|
580
|
+
9a1c22de-...,bob@acme.io,Bob,Jones,true
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Key properties of TOON output:
|
|
584
|
+
|
|
585
|
+
- **Arrays are schema-compressed** — `items[N]{field1,field2,...}:` header followed by rows, rather than repeating field names for every object
|
|
586
|
+
- **Scalars are unquoted** — only strings with special characters are quoted
|
|
587
|
+
- **Nested objects are indented** — structure is preserved but without JSON's punctuation overhead
|
|
588
|
+
- **Null and boolean values are compact** — `null`, `true`, `false` without quotes
|
|
589
|
+
|
|
590
|
+
**When to use `--toon` vs `--json`:**
|
|
591
|
+
|
|
592
|
+
| Use case | Recommended flag |
|
|
593
|
+
|---|---|
|
|
594
|
+
| Pasting into an LLM prompt | `--toon` |
|
|
595
|
+
| AI agent / agentic scripting | `--toon` |
|
|
596
|
+
| Shell scripting with `jq` | `--json` |
|
|
597
|
+
| Saving to a file for later processing | `--json` |
|
|
598
|
+
| Quick human inspection | (default) |
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
# Pipe directly into an LLM context or agent prompt
|
|
602
|
+
fcli device list --toon
|
|
603
|
+
fcli event list --severity critical --toon
|
|
604
|
+
fcli investigation runs <id> --toon
|
|
605
|
+
fcli org get --toon
|
|
606
|
+
```
|
|
607
|
+
|
|
553
608
|
## Examples
|
|
554
609
|
|
|
555
610
|
### Monitor fleet health
|
|
@@ -629,6 +684,32 @@ fcli analytics query --sql "SELECT * FROM events WHERE created_at > '2026-01-01'
|
|
|
629
684
|
--json > analytics_export.json
|
|
630
685
|
```
|
|
631
686
|
|
|
687
|
+
### Use with AI tools and LLMs
|
|
688
|
+
|
|
689
|
+
`--toon` produces compact, token-efficient output that is well-suited for LLM prompts and agentic workflows. Use it anywhere you would otherwise paste JSON into a prompt.
|
|
690
|
+
|
|
691
|
+
```bash
|
|
692
|
+
# Summarize your fleet for an LLM
|
|
693
|
+
fcli device list --with-data --toon
|
|
694
|
+
|
|
695
|
+
# Get org context in compact form
|
|
696
|
+
fcli org get --toon
|
|
697
|
+
|
|
698
|
+
# Pipe investigation results into an AI workflow
|
|
699
|
+
fcli investigation runs <investigation-id> --toon
|
|
700
|
+
|
|
701
|
+
# Combine with other tools for agentic scripting
|
|
702
|
+
fcli event list --severity critical --limit 20 --toon | your-ai-tool analyze
|
|
703
|
+
|
|
704
|
+
# Check recent events and device state together
|
|
705
|
+
{
|
|
706
|
+
echo "=== Critical Events ==="
|
|
707
|
+
fcli event list --severity critical --limit 10 --toon
|
|
708
|
+
echo "=== Fleet Status ==="
|
|
709
|
+
fcli device list --include-offline --toon
|
|
710
|
+
} | your-ai-tool "Summarize what's wrong with my fleet"
|
|
711
|
+
```
|
|
712
|
+
|
|
632
713
|
## Development
|
|
633
714
|
|
|
634
715
|
### Build from source
|
package/dist/base-command.d.ts
CHANGED
|
@@ -12,11 +12,28 @@ export declare abstract class BaseCommand<T extends typeof Command> extends Comm
|
|
|
12
12
|
static baseFlags: {
|
|
13
13
|
dev: Interfaces.BooleanFlag<boolean>;
|
|
14
14
|
stage: Interfaces.BooleanFlag<boolean>;
|
|
15
|
+
toon: Interfaces.BooleanFlag<boolean>;
|
|
15
16
|
};
|
|
16
17
|
protected flags: InferredFlags<T>;
|
|
17
18
|
protected args: InferredArgs<T>;
|
|
18
19
|
/** Resolved environment based on --dev / --stage flags. */
|
|
19
20
|
protected get env(): Environment;
|
|
21
|
+
/** Returns true when --toon flag is active. */
|
|
22
|
+
toonEnabled(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true when either --json or --toon is active.
|
|
25
|
+
* Overriding this ensures human-readable output is suppressed for both flags,
|
|
26
|
+
* without requiring changes to individual command files.
|
|
27
|
+
*/
|
|
28
|
+
jsonEnabled(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Called by oclif when jsonEnabled() is true and run() returns successfully.
|
|
31
|
+
* When --toon is active, encodes the result as TOON instead of JSON.
|
|
32
|
+
*
|
|
33
|
+
* Note: must write to process.stdout directly — this.log() is suppressed
|
|
34
|
+
* by oclif whenever jsonEnabled() returns true.
|
|
35
|
+
*/
|
|
36
|
+
protected logJson(json: unknown): void;
|
|
20
37
|
init(): Promise<void>;
|
|
21
38
|
/**
|
|
22
39
|
* Make an authenticated GET/POST request to a Formant API.
|
package/dist/base-command.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { encode } from '@toon-format/toon';
|
|
2
3
|
import { apiRequest } from './lib/api.js';
|
|
3
4
|
import { login } from './lib/auth.js';
|
|
4
5
|
/**
|
|
@@ -18,6 +19,11 @@ export class BaseCommand extends Command {
|
|
|
18
19
|
exclusive: ['dev'],
|
|
19
20
|
helpGroup: 'GLOBAL',
|
|
20
21
|
}),
|
|
22
|
+
toon: Flags.boolean({
|
|
23
|
+
description: 'Output data in TOON (Token-Oriented Object Notation) format',
|
|
24
|
+
exclusive: ['json'],
|
|
25
|
+
helpGroup: 'GLOBAL',
|
|
26
|
+
}),
|
|
21
27
|
};
|
|
22
28
|
flags;
|
|
23
29
|
args;
|
|
@@ -29,6 +35,33 @@ export class BaseCommand extends Command {
|
|
|
29
35
|
return 'stage';
|
|
30
36
|
return 'prod';
|
|
31
37
|
}
|
|
38
|
+
/** Returns true when --toon flag is active. */
|
|
39
|
+
toonEnabled() {
|
|
40
|
+
return Boolean(this.flags?.toon);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns true when either --json or --toon is active.
|
|
44
|
+
* Overriding this ensures human-readable output is suppressed for both flags,
|
|
45
|
+
* without requiring changes to individual command files.
|
|
46
|
+
*/
|
|
47
|
+
jsonEnabled() {
|
|
48
|
+
return super.jsonEnabled() || this.toonEnabled();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Called by oclif when jsonEnabled() is true and run() returns successfully.
|
|
52
|
+
* When --toon is active, encodes the result as TOON instead of JSON.
|
|
53
|
+
*
|
|
54
|
+
* Note: must write to process.stdout directly — this.log() is suppressed
|
|
55
|
+
* by oclif whenever jsonEnabled() returns true.
|
|
56
|
+
*/
|
|
57
|
+
logJson(json) {
|
|
58
|
+
if (this.toonEnabled()) {
|
|
59
|
+
process.stdout.write(encode(json) + '\n');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
super.logJson(json);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
32
65
|
async init() {
|
|
33
66
|
await super.init();
|
|
34
67
|
const { args, flags } = await this.parse({
|
package/dist/base-command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../src/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAA;AACtD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAiB,UAAU,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AAQnC;;;GAGG;AACH,MAAM,OAAgB,WAAsC,SAAQ,OAAO;IACzE,MAAM,CA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|
--dev Target the dev environment (for testing)
|
|
52
52
|
--stage Target the stage environment (for staging)
|
|
53
53
|
--json Output raw JSON instead of formatted tables
|
|
54
|
+
--toon Output data in TOON (Token-Oriented Object Notation) format
|
|
54
55
|
-h, --help Show help for any command
|
|
55
56
|
|
|
56
57
|
AUTHENTICATION
|
|
@@ -133,6 +134,7 @@ EXAMPLES
|
|
|
133
134
|
TIPS
|
|
134
135
|
* Use --json with any command to get machine-readable output for scripting
|
|
135
136
|
* Pipe output to jq for advanced JSON processing: fcli device list --json | jq
|
|
137
|
+
* Use --toon for compact Token-Oriented Object Notation output (great for LLM prompts)
|
|
136
138
|
* Set --dev or --stage to target non-production environments
|
|
137
139
|
* Use fcli <command> --help to see detailed help for any command
|
|
138
140
|
|
package/dist/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,IAAI;IACrB,KAAK,CAAC,YAAY;QACnC,MAAM,MAAM,GAAG;;kDAE+B,IAAI,CAAC,MAAM,CAAC,OAAO
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,IAAI;IACrB,KAAK,CAAC,YAAY;QACnC,MAAM,MAAM,GAAG;;kDAE+B,IAAI,CAAC,MAAM,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2IpE,CAAA;QAEG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAClB,CAAC;CACF"}
|