Agent-First Data v0.39.0: One Entry from main, Typed Reads, Route-Aware Redaction
CliMain runs a registry CLI from main and settles every write failure, invocation reads are typed, redaction judges a value by its real route, the standard skill verbs mount on any CliSpec program, lint warns on formatted quantity strings, and the Bash kit moves to API 3.
A CLI built on a registry spec used to stop at a resolved invocation and leave
the rest of main to the program: open the redirect files, answer help and
version, run the command, and decide what a failed write means. Every program
wrote that loop slightly differently. This release moves it into the library,
and makes the pieces it hands over typed.
CliMain: the whole lifecycle from main
CliMain binds one handler per action, resolves argv, runs an optional
check, installs --stdout-file and --stderr-file, answers help, version
and docs, and then runs the command through one emitter built from the
resolved OutputPlan.
- Refusals before sinks. A handler is the pure step from a
ResolvedInvocationto the program’s own command value. It runs before any file sink opens, so a rejected argument or a failed check never leaves an empty redirect file behind. - Write failures settled once. A closed reader is exit 0; any other failed
write is exit 4 with
output_write_failed. The emitter is the only route to stdout and stderr, raw bytes included. - A program’s own version event.
CliMain::versionanswers--versionwith an event the program builds from the standard fields, for a version identity that carries more than the registry knows, such as the protocol versions a build speaks. run_with_planis the output half alone, for a plan that came from somewhere other than the registry.CliEmitterkeeps its constructor modes in all four SDKs.
Typed invocation reads
A ResolvedInvocation is read only through typed accessors: text, flag,
integer::<T>, json_text, key_value, source, and their optional and
repeated forms. Asking for an id the matched combination does not declare, as
the wrong type, or as an integer type the declared range does not fit, is an
InvocationReadError. That is a defect in the program, not in the caller’s
input, so it reports cli_invocation_invalid at exit 1. Fixed bounds belong in
ArgSpec::range, where a violation is a usage error at exit 2.
Sourced arguments hand over the classified ValueSource rather than a string
to re-parse. Classification is syntax only, so nothing is read until the
program calls read() or read_secret(). KEY=VALUE is now a value type.
Redaction by route
A value taken out of its document keeps the names above it. document::locate
returns the node with its path steps, and Redactor::value_at renders it
exactly as the whole redacted document would show it: a token under
credentials_secret.primary stays *** even though its own key says nothing
about secrets. Redactor::is_secret_path gates printing it raw. Python and
TypeScript expose the same contract as redacted_value_at / redactedValueAt
and is_secret_path / isSecretPath. Judging a path by its last segment alone
is the mistake this closes.
Standard skill verbs for any CliSpec program
skill::skill_cli_commands registers skill status, skill install and
skill uninstall with their arguments and help derived from the SkillSpec.
SkillCliRequest carries a resolved verb into a program’s own command type,
execute returns an inspectable outcome, and emit writes the one terminal
event with SkillErrorKind codes and exit 2 for usage errors. run_skill_cli
does both for a handler that returns ExitCode. The agent and scope tables are
the single source for the enum values, so adding an agent is one line. The
afdata binary now uses these shared verbs.
Lint: formatted quantities in typed data
formatted_quantity_string is a new warning. It matches whole strings shaped
like integers, grouped numbers, quantities with display units, compact or
clock-style durations, and absence placeholders such as — or n/a. Typed
data should carry numbers or null and leave formatting to the presentation
boundary; for a recognized unit the finding suggests the field suffix to use.
Identifier-like names (version, id, code, sku, name, title and
similar) and suffixes whose convention is a string are exempt. In v0.39.0 the warning was included by default and excluded by
--min-severity error. See the current lint contract for advisory output and filtering.
Smaller additions
json_log(..).timestamp_now()andjson_progress(..).timestamp_now()stamp the currenttimestamp_epoch_ms.AtomicWrite::new(bytes).mode(0o600).new_only().write(path)is an atomic write with explicit Unix permission bits and a refuse-existing option.- On Windows, opening a document with the no-follow policy now refuses reparse points by handle instead of reporting the policy as unsupported.
Breaking: Bash kit API 3
AFDATA_BASH_API_VERSION is now 3.
afdata_config_getis gone. Read a config value withafdata_cli value FILE KEY [--default VALUE], which brings--input-format,--slug-fieldand--reveal-secretwith it.afdata_trytakesOUT ERR STATUS COMMAND...: stdout and stderr are captured separately. Pass the literal&1asERRto merge them, the same convention asafdata_spawn.
A script that checks AFDATA_BASH_API_VERSION before loading the kit should
require 3 once it moves to the new afdata_try form.