agent-first-data 0.13.0 → 0.13.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 +2 -1
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +63 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ console.log(outputJson(value));
|
|
|
20
20
|
console.log(outputPlain(value));
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Useful names use TypeScript casing: `outputJson`, `outputYaml`, `outputPlain`, `outputJsonWithOptions`, `redactedValue`, `redactSecretsInPlace`, `redactUrlSecrets`, `parseSize`, `normalizeUtcOffset`, `cliParseOutput`, `cliOutput`, and `
|
|
23
|
+
Useful names use TypeScript casing: `outputJson`, `outputYaml`, `outputPlain`, `outputJsonWithOptions`, `redactedValue`, `redactSecretsInPlace`, `redactUrlSecrets`, `parseSize`, `normalizeUtcOffset`, `cliParseOutput`, `cliOutput`, `buildCliError`, `buildCliVersion`, and `cliHandleVersionOrContinue`.
|
|
24
24
|
|
|
25
25
|
Logging is available through `initJson`, `initPlain`, `initYaml`, `span`, and `log`.
|
|
26
26
|
|
|
@@ -37,6 +37,7 @@ initJson({ secretNames: ["authorization"] });
|
|
|
37
37
|
- YAML/plain quote and escape keys as well as values, sort by UTF-16 code unit order, and render nested objects in arrays as canonical JSON.
|
|
38
38
|
- Logging records use `code: "log"` plus a separate `level` field, so error-level logs are not terminal protocol errors.
|
|
39
39
|
- `build_cli_error(message, hint?)` returns `{code:"error", error: message, hint?}` only.
|
|
40
|
+
- Use `cliHandleVersionOrContinue()` before argument parsing so bare `--version` stays conventional and `--version --output json|yaml|plain` stays structured.
|
|
40
41
|
|
|
41
42
|
## Reference
|
|
42
43
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -34,6 +34,19 @@ export declare function cliOutput(value: JsonValue, format: OutputFormat): strin
|
|
|
34
34
|
* JSON ignores OutputStyle and preserves original keys and values after redaction.
|
|
35
35
|
*/
|
|
36
36
|
export declare function cliOutputWithOptions(value: JsonValue, format: OutputFormat, outputOptions: OutputOptions): string;
|
|
37
|
+
/** Build a standard CLI version value. */
|
|
38
|
+
export declare function buildCliVersion(version: string): JsonValue;
|
|
39
|
+
/**
|
|
40
|
+
* Render CLI version output.
|
|
41
|
+
* Pass an OutputFormat for AFDATA JSON/YAML/plain. Pass null to preserve
|
|
42
|
+
* conventional "<name> <version>" text.
|
|
43
|
+
*/
|
|
44
|
+
export declare function cliRenderVersion(name: string, version: string, format?: OutputFormat | null): string;
|
|
45
|
+
/**
|
|
46
|
+
* Render version output if --version/-V is present; otherwise return undefined.
|
|
47
|
+
* Throws for malformed version requests, for example `--version --output xml`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function cliHandleVersionOrContinue(rawArgs: string[], name: string, version: string, defaultOutput?: OutputFormat | null, outputFlag?: string, allowOutputFormat?: boolean): string | undefined;
|
|
37
50
|
/**
|
|
38
51
|
* Build a standard CLI parse error value.
|
|
39
52
|
* Use when flag parsing fails or a flag value is invalid.
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AFDATA CLI helpers — output format parsing, log filter normalization, error building.
|
|
3
3
|
*/
|
|
4
|
-
import { outputJson, outputJsonWithOptions, outputYaml, outputYamlWithOptions, outputPlain, outputPlainWithOptions, } from "./format.js";
|
|
4
|
+
import { buildJson, outputJson, outputJsonWithOptions, outputYaml, outputYamlWithOptions, outputPlain, outputPlainWithOptions, } from "./format.js";
|
|
5
5
|
/**
|
|
6
6
|
* Parse the --output flag value into an OutputFormat.
|
|
7
7
|
* Throws on unknown values; catch and pass message to buildCliError.
|
|
@@ -58,6 +58,68 @@ export function cliOutputWithOptions(value, format, outputOptions) {
|
|
|
58
58
|
return outputPlainWithOptions(value, outputOptions);
|
|
59
59
|
return outputJsonWithOptions(value, outputOptions);
|
|
60
60
|
}
|
|
61
|
+
/** Build a standard CLI version value. */
|
|
62
|
+
export function buildCliVersion(version) {
|
|
63
|
+
return buildJson("version", { version });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render CLI version output.
|
|
67
|
+
* Pass an OutputFormat for AFDATA JSON/YAML/plain. Pass null to preserve
|
|
68
|
+
* conventional "<name> <version>" text.
|
|
69
|
+
*/
|
|
70
|
+
export function cliRenderVersion(name, version, format = null) {
|
|
71
|
+
const rendered = format === null ? `${name} ${version}` : cliOutput(buildCliVersion(version), format);
|
|
72
|
+
return `${rendered.replace(/\n+$/u, "")}\n`;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Render version output if --version/-V is present; otherwise return undefined.
|
|
76
|
+
* Throws for malformed version requests, for example `--version --output xml`.
|
|
77
|
+
*/
|
|
78
|
+
export function cliHandleVersionOrContinue(rawArgs, name, version, defaultOutput = null, outputFlag = "--output", allowOutputFormat = true) {
|
|
79
|
+
let versionRequested = false;
|
|
80
|
+
let outputFormat;
|
|
81
|
+
let outputError;
|
|
82
|
+
for (let i = 0; i < rawArgs.length;) {
|
|
83
|
+
const arg = rawArgs[i];
|
|
84
|
+
if (arg === "--")
|
|
85
|
+
break;
|
|
86
|
+
if (arg === "--version" || arg === "-V") {
|
|
87
|
+
versionRequested = true;
|
|
88
|
+
i += 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (allowOutputFormat && (arg === outputFlag || arg.startsWith(`${outputFlag}=`))) {
|
|
92
|
+
let value;
|
|
93
|
+
let step = 1;
|
|
94
|
+
if (arg.startsWith(`${outputFlag}=`)) {
|
|
95
|
+
value = arg.slice(outputFlag.length + 1);
|
|
96
|
+
}
|
|
97
|
+
else if (rawArgs[i + 1] !== undefined && !rawArgs[i + 1].startsWith("-")) {
|
|
98
|
+
value = rawArgs[i + 1];
|
|
99
|
+
step = 2;
|
|
100
|
+
}
|
|
101
|
+
if (value === undefined) {
|
|
102
|
+
outputError = new Error(`missing value for ${outputFlag}: expected json, yaml, or plain`);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
try {
|
|
106
|
+
outputFormat = cliParseOutput(value);
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
outputError = e;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
i += step;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
i += 1;
|
|
116
|
+
}
|
|
117
|
+
if (!versionRequested)
|
|
118
|
+
return undefined;
|
|
119
|
+
if (outputError !== undefined)
|
|
120
|
+
throw outputError;
|
|
121
|
+
return cliRenderVersion(name, version, allowOutputFormat && outputFormat !== undefined ? outputFormat : defaultOutput);
|
|
122
|
+
}
|
|
61
123
|
/**
|
|
62
124
|
* Build a standard CLI parse error value.
|
|
63
125
|
* Use when flag parsing fails or a flag value is invalid.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { buildJsonOk, buildJsonError, buildJson, type JsonValue, RedactionPolicy, type RedactionOptions, OutputStyle, type OutputOptions, outputJson, outputJsonWith, outputJsonWithOptions, outputYaml, outputYamlWithOptions, outputPlain, outputPlainWithOptions, redactSecretsInPlace, redactSecretsInPlaceWithOptions, redactedValue, redactedValueWith, redactedValueWithOptions, redactUrlSecrets, redactUrlSecretsWithOptions, parseSize, normalizeUtcOffset, } from "./format.js";
|
|
5
5
|
export { log, span, initJson, initPlain, initYaml } from "./afdata_logging.js";
|
|
6
|
-
export { type OutputFormat, cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, } from "./cli.js";
|
|
6
|
+
export { type OutputFormat, cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
|
7
7
|
export { type SkillSpec, type SkillAction, type SkillScope, type SkillAgentSelection, type SkillAgent, type SkillOptions, type SkillTargetStatus, type SkillUninstallStatus, type SkillReport, SkillError, runSkillAdmin, } from "./skill.js";
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { buildJsonOk, buildJsonError, buildJson, RedactionPolicy, OutputStyle, outputJson, outputJsonWith, outputJsonWithOptions, outputYaml, outputYamlWithOptions, outputPlain, outputPlainWithOptions, redactSecretsInPlace, redactSecretsInPlaceWithOptions, redactedValue, redactedValueWith, redactedValueWithOptions, redactUrlSecrets, redactUrlSecretsWithOptions, parseSize, normalizeUtcOffset, } from "./format.js";
|
|
5
5
|
export { log, span, initJson, initPlain, initYaml } from "./afdata_logging.js";
|
|
6
|
-
export { cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, } from "./cli.js";
|
|
6
|
+
export { cliParseOutput, cliParseLogFilters, cliOutput, cliOutputWithOptions, buildCliError, buildCliVersion, cliRenderVersion, cliHandleVersionOrContinue, } from "./cli.js";
|
|
7
7
|
export { SkillError, runSkillAdmin, } from "./skill.js";
|