agent-first-data 0.22.0 → 0.24.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 CHANGED
@@ -26,7 +26,7 @@ Useful names use TypeScript casing: `render`, `outputOptionsForPolicy`, `redacte
26
26
  - YAML keeps original keys and values (structure-preserving, like JSON), sorting keys by UTF-16 code unit order and quoting/escaping unsafe keys and string scalars. Plain strips formatting suffixes, formats values, sorts the same way, and renders nested objects/arrays as canonical JSON.
27
27
  - Logging records use `kind:"log"` with a nested `log` payload and a separate `level` field, so error-level logs are not terminal protocol errors.
28
28
  - `buildCliError(message, hint?)` returns a strict-ready CLI error with `error.retryable:false` and `trace:{}`.
29
- - Use `cliHandleVersionOrContinue()` before argument parsing so `--version`/`-V` always answers with a structured protocol-v1 `kind:"result"` version event — JSON by default, or `--output yaml|plain`/`--json` for another format; there is no conventional bare-text form. Pass your own value-taking global flag names so their value is not mistaken for the subcommand boundary.
29
+ - Use `cliHandleVersionOrContinue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event. Explicit `--output`/`--json` wins; pass the command's normal output as `defaultOutput` (JSON when omitted), plus its value-taking global flag names.
30
30
 
31
31
  ## Reference
32
32
 
@@ -0,0 +1,225 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://agentfirstkit.org/schemas/agent-first-data/cli-help-v1.schema.json",
4
+ "title": "AFDATA CLI help v1 event",
5
+ "description": "Compact, progressively disclosed CLI help carried by an AFDATA result event.",
6
+ "type": "object",
7
+ "required": [
8
+ "kind",
9
+ "result",
10
+ "trace"
11
+ ],
12
+ "additionalProperties": false,
13
+ "properties": {
14
+ "kind": {
15
+ "const": "result"
16
+ },
17
+ "result": {
18
+ "type": "object",
19
+ "required": [
20
+ "code",
21
+ "help"
22
+ ],
23
+ "additionalProperties": false,
24
+ "properties": {
25
+ "code": {
26
+ "const": "help"
27
+ },
28
+ "help": {
29
+ "$ref": "#/$defs/help"
30
+ }
31
+ }
32
+ },
33
+ "trace": {
34
+ "type": "object"
35
+ }
36
+ },
37
+ "$defs": {
38
+ "argument": {
39
+ "type": "object",
40
+ "required": [
41
+ "name"
42
+ ],
43
+ "additionalProperties": false,
44
+ "properties": {
45
+ "name": {
46
+ "type": "string",
47
+ "minLength": 1
48
+ },
49
+ "short": {
50
+ "type": "string",
51
+ "pattern": "^-[^-]$"
52
+ },
53
+ "help": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "required": {
58
+ "const": true
59
+ },
60
+ "global": {
61
+ "const": true
62
+ },
63
+ "repeatable": {
64
+ "const": true
65
+ },
66
+ "value": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "values": {
71
+ "type": "array",
72
+ "minItems": 1,
73
+ "items": {
74
+ "type": "string",
75
+ "minLength": 1
76
+ }
77
+ },
78
+ "default": {
79
+ "type": "string"
80
+ },
81
+ "defaults": {
82
+ "type": "array",
83
+ "minItems": 1,
84
+ "items": {
85
+ "type": "string"
86
+ }
87
+ }
88
+ },
89
+ "allOf": [
90
+ {
91
+ "if": {
92
+ "properties": {
93
+ "name": {
94
+ "pattern": "^-"
95
+ }
96
+ }
97
+ },
98
+ "else": {
99
+ "not": {
100
+ "anyOf": [
101
+ {
102
+ "required": [
103
+ "value"
104
+ ]
105
+ },
106
+ {
107
+ "required": [
108
+ "values"
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ }
114
+ },
115
+ {
116
+ "not": {
117
+ "required": [
118
+ "value",
119
+ "values"
120
+ ]
121
+ }
122
+ },
123
+ {
124
+ "not": {
125
+ "required": [
126
+ "default",
127
+ "defaults"
128
+ ]
129
+ }
130
+ }
131
+ ]
132
+ },
133
+ "command": {
134
+ "type": "object",
135
+ "required": [
136
+ "name"
137
+ ],
138
+ "additionalProperties": false,
139
+ "properties": {
140
+ "name": {
141
+ "type": "string",
142
+ "minLength": 1
143
+ },
144
+ "about": {
145
+ "type": "string",
146
+ "minLength": 1
147
+ },
148
+ "usage": {
149
+ "type": "string",
150
+ "minLength": 1
151
+ },
152
+ "arguments": {
153
+ "type": "array",
154
+ "minItems": 1,
155
+ "items": {
156
+ "$ref": "#/$defs/argument"
157
+ }
158
+ },
159
+ "subcommands": {
160
+ "type": "array",
161
+ "minItems": 1,
162
+ "items": {
163
+ "$ref": "#/$defs/command"
164
+ }
165
+ }
166
+ }
167
+ },
168
+ "help": {
169
+ "type": "object",
170
+ "required": [
171
+ "scope",
172
+ "command_path",
173
+ "name"
174
+ ],
175
+ "additionalProperties": false,
176
+ "properties": {
177
+ "scope": {
178
+ "enum": [
179
+ "one_level",
180
+ "recursive"
181
+ ]
182
+ },
183
+ "command_path": {
184
+ "type": "string",
185
+ "minLength": 1
186
+ },
187
+ "inherited_arguments_from": {
188
+ "type": "array",
189
+ "minItems": 1,
190
+ "uniqueItems": true,
191
+ "items": {
192
+ "type": "string",
193
+ "minLength": 1
194
+ }
195
+ },
196
+ "name": {
197
+ "type": "string",
198
+ "minLength": 1
199
+ },
200
+ "about": {
201
+ "type": "string",
202
+ "minLength": 1
203
+ },
204
+ "usage": {
205
+ "type": "string",
206
+ "minLength": 1
207
+ },
208
+ "arguments": {
209
+ "type": "array",
210
+ "minItems": 1,
211
+ "items": {
212
+ "$ref": "#/$defs/argument"
213
+ }
214
+ },
215
+ "subcommands": {
216
+ "type": "array",
217
+ "minItems": 1,
218
+ "items": {
219
+ "$ref": "#/$defs/command"
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
package/dist/cli.d.ts CHANGED
@@ -186,8 +186,8 @@ export declare function cliRenderVersion(name: string, displayName: string | und
186
186
  * Throws for malformed version requests, for example `--version --output xml`.
187
187
  *
188
188
  * The one blessed behavior: `--version` always answers with a protocol-v1
189
- * `kind:"result"` version event — JSON by default, or `--output yaml|plain` (or
190
- * `--json`) for another format. There is no conventional bare-text path.
189
+ * `kind:"result"` version event. Explicit `--output`/`--json` wins; otherwise
190
+ * `defaultOutput` should be the command's normal output default.
191
191
  *
192
192
  * `valueFlags` is the caller's own value-taking global long flags (with or
193
193
  * without leading dashes; the leading dashes are stripped internally). It is the
@@ -200,7 +200,7 @@ export declare function cliRenderVersion(name: string, displayName: string | und
200
200
  * leaves `--version` for the subcommand's parser rather than printing the
201
201
  * tool version.
202
202
  */
203
- export declare function cliHandleVersionOrContinue(rawArgs: string[], valueFlags: string[], name: string, displayName: string | undefined, version: string, build: string | undefined): string | undefined;
203
+ export declare function cliHandleVersionOrContinue(rawArgs: string[], valueFlags: string[], name: string, displayName: string | undefined, version: string, build: string | undefined, defaultOutput?: OutputFormat): string | undefined;
204
204
  /**
205
205
  * Build a standard CLI parse error value. This function cannot fail.
206
206
  * Use when flag parsing fails or a flag value is invalid.
package/dist/cli.js CHANGED
@@ -322,8 +322,8 @@ function splitFlag(arg) {
322
322
  * Throws for malformed version requests, for example `--version --output xml`.
323
323
  *
324
324
  * The one blessed behavior: `--version` always answers with a protocol-v1
325
- * `kind:"result"` version event — JSON by default, or `--output yaml|plain` (or
326
- * `--json`) for another format. There is no conventional bare-text path.
325
+ * `kind:"result"` version event. Explicit `--output`/`--json` wins; otherwise
326
+ * `defaultOutput` should be the command's normal output default.
327
327
  *
328
328
  * `valueFlags` is the caller's own value-taking global long flags (with or
329
329
  * without leading dashes; the leading dashes are stripped internally). It is the
@@ -336,7 +336,7 @@ function splitFlag(arg) {
336
336
  * leaves `--version` for the subcommand's parser rather than printing the
337
337
  * tool version.
338
338
  */
339
- export function cliHandleVersionOrContinue(rawArgs, valueFlags, name, displayName, version, build) {
339
+ export function cliHandleVersionOrContinue(rawArgs, valueFlags, name, displayName, version, build, defaultOutput = "json") {
340
340
  const valueFlagSet = new Set(valueFlags.map((flag) => flag.replace(/^-+/u, "")));
341
341
  let versionRequested = false;
342
342
  let outputFormat;
@@ -351,7 +351,7 @@ export function cliHandleVersionOrContinue(rawArgs, valueFlags, name, displayNam
351
351
  if (!arg.startsWith("-"))
352
352
  break;
353
353
  const { name: flagName, inlineValue } = splitFlag(arg);
354
- if (arg === "--version" || arg === "-V") {
354
+ if (arg === "--version") {
355
355
  versionRequested = true;
356
356
  i += 1;
357
357
  continue;
@@ -412,7 +412,7 @@ export function cliHandleVersionOrContinue(rawArgs, valueFlags, name, displayNam
412
412
  return undefined;
413
413
  if (outputError !== undefined)
414
414
  throw outputError;
415
- return cliRenderVersion(name, displayName, version, build, outputFormat ?? "json");
415
+ return cliRenderVersion(name, displayName, version, build, outputFormat ?? defaultOutput);
416
416
  }
417
417
  /**
418
418
  * Build a standard CLI parse error value. This function cannot fail.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-first-data",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "A naming convention that lets AI agents understand your data without being told what it means, plus a CLI and library for reading and safely editing structured JSON, TOML, YAML, dotenv, and INI documents.",
5
5
  "license": "MIT",
6
6
  "repository": {