Expand description
Agent-First Data (AFDATA) output formatting and protocol templates.
Public APIs, grouped by concern (see each item’s own docs for details; the full symbol list is the crate root’s own rustdoc index, not repeated here — it drifts out of sync with a hand-maintained count otherwise):
- Protocol v1 builders:
json_result,json_error,json_progress,json_log(each returns a builder; call.build()) - Protocol reader:
decode_protocol_eventparses and strict-validates one protocol line into a typedDecodedEvent - Redaction:
redacted_value/Redactor::value(JSON values),redact_url_secrets/Redactor::url(URL strings),redact_argv/Redactor::argv(command lines) —Redactorcarries customsecret_names/policy - Output rendering:
render— the singlevalue × format × options → Stringentry point for JSON, YAML, and plain (logfmt) output - Parse utilities:
normalize_utc_offset,is_valid_rfc3339_date,is_valid_rfc3339_time,is_valid_rfc3339,is_valid_bcp47 - Closed-world CLI compiler:
CliSpec,CommandSpec,ArgSpec,Combination, andOutputSpecgenerate parsing, typedResolvedInvocationvalues, output plans, and help-v2 from one registry. - Established CLI utilities:
cli_parse_output,cli_parse_log_filters(returnsLogFilters), andCliEmitter. - (feature
skill):skill::validate_skill/skill::validate_skill_named— strict Agent SkillsSKILL.mdfront-matter validation - (feature
skill-admin):skill::run_skill_admin— install/uninstall/status a spore’s embedded Agent Skill across Codex, Claude Code, opencode, and Hermes; returns a typedskill::SkillReport - (feature
tracing):afdata_tracing::try_initinitializes an AFDATA stdout logging layer with configurable format and redaction; alsoafdata_tracing::LogFormat
The shared cross-language contract (which of these exist, under what name, in each of
Rust/Python/TypeScript/Go) is tracked in spec/api-surface.json and cross-checked by
scripts/validate_api_surface.py.
Modules§
- afdata_
tracing - AFDATA-compliant tracing layer.
- document
- Format-independent document values (dot-path access, typed coercion, and pluggable JSON/TOML/YAML/dotenv/INI backends). Format-independent document values: dot-path get/set/add/remove, type-directed CLI-string coercion, keyed-list (slug-addressed array) helpers, and typed serde adapters, backed by pluggable JSON/TOML/YAML/dotenv/INI format readers and writers.
- skill
- Agent Skills
SKILL.mdfront-matter validation. - stream_
redirect - Optional process stdout/stderr file redirection.
Structs§
- ArgSpec
- One command-local application argument.
- Bound
CliSpec - A built registry with exactly one handler per action.
- Built
CliSpec - Validated registry used for resolution and help generation.
- CliEmitter
- Stateful emitter for structured CLI executions.
- CliError
- Structured CLI-resolution error. It never contains raw argument values.
- CliHelp
V2 - Agent-first help-v2 payload.
- CliShape
- One legal shape of a call.
- CliSpec
- Serializable version-one closed-world CLI registry.
- CliSpec
Error - Stable build-time registry error.
- Combination
- One named legal application invocation shape.
- Command
Spec - One exact command path in a CLI registry.
- Decoded
Error - Decoded
kind:"error"event. - Decoded
Log - Decoded
kind:"log"event. - Decoded
Progress - Decoded
kind:"progress"event. - Decoded
Result - Decoded
kind:"result"event. - Error
Builder - Builder for error events.
- Event
- A typed, strict-valid AFDATA protocol v1 event.
- LogBuilder
- Builder for log events.
- LogFilters
- Parsed and normalized log filters (trimmed, lowercased, deduplicated).
- Output
Options - Output options combining redaction and rendering style.
- Progress
Builder - Builder for progress events.
- Protocol
Violation - A single protocol-validation violation: a stable machine-readable
ruleslug, a JSON pointer to the offending location (""= the whole event), and a human-readablemessage. - Redactor
- Configurable redaction builder for secrets and legacy field names.
- Resolved
Docs - The registry asked to describe itself in full.
- Resolved
Help - Resolved help response plus its lifecycle output plan.
- Resolved
Invocation - One legal invocation, projected onto the shape that matched it.
- Resolved
Version - Resolved version response plus its lifecycle output plan.
- Result
Builder - Builder for result events.
- Synthetic
Invocation - Type-correct argv generated from a registered shape.
Enums§
- ArgSyntax
- An argument’s exact command-local spelling.
- ArgValue
Type - Closed portable value type used by CLI specs and resolved invocations.
- Build
Error - Error type for builder failures.
- CliEmitter
Error - Error returned by
CliEmitter. - CliError
Rule - Stable closed set of invocation-error rules.
- CliOutcome
- What an argv resolved to.
- CliValue
- A typed value produced by a built CLI registry.
- Decoded
Event - A decoded, strict-valid AFDATA protocol v1 event, typed by kind.
- Event
Decode Error - Error returned by
decode_protocol_event. - Fixed
Value - A finite fixed enum constraint.
- LogLevel
- Log level enumeration (serialized as lowercase).
- Output
Format - Output format for CLI and pipe/MCP modes.
- Output
Lifecycle - Protocol output lifecycle.
- Output
Plan - Where a resolved call’s output goes, and in what form.
- Output
Spec - Closed output contract for one combination.
- Output
To - Where a
CliEmittersends its events, selected by--output-to. - Plain
Style - Rendering style for plain (logfmt) output only. JSON and YAML are always structure-preserving and ignore this.
- Redaction
Policy - Which fields a
Redactorscrubs. The default isRedactionPolicy::All.
Functions§
- build_
afdata_ cli - Build a registry under AFDATA’s naming conventions.
- build_
cli_ error - Build a CLI error event with optional hint.
- build_
cli_ version - Build a standard CLI version event: a
kind:"result"event whose payload is{ "code": "version", "name": <name>, "version": <version> }, plus"display_name"/"build"when given.nameis the short/bin identity (e.g."afdata");display_nameis an optional human-facing product name (e.g."Agent-First Data");buildis an opaque caller-supplied identifier (a git commit SHA, for example) — its meaning is entirely up to the caller. Both areNonewhen unavailable, and simply absent from the payload. - cli_
error_ event - Wrap a CLI-resolution failure in an event whose
codenames the failure. - cli_
help_ event - Wrap a resolved help response in a
cli-help-v2result event. - cli_
parse_ log_ filters - Normalize
--logflag entries: trim, lowercase, deduplicate, remove empty. - cli_
parse_ output - Parse
--outputflag value intoOutputFormat. - cli_
render_ version - Render a CLI version response as a protocol-v1 event in
format. - cli_
version_ event - Wrap a resolved version response in a protocol result event.
- decode_
protocol_ event - Parse one protocol v1 line, strict-validate it, and return a typed decoded event.
- is_
valid_ bcp47 - Return true when
sis a structurally well-formed BCP 47 (RFC 5646) language tag. - is_
valid_ rfc3339 - Return true when
sis a complete RFC 3339date-time, such as2026-02-14T10:30:00Zor2026-02-14T10:30:00.5+08:00. - is_
valid_ rfc3339_ date - Return true when
sis an RFC 3339full-date(YYYY-MM-DD). - is_
valid_ rfc3339_ time - Return true when
sis an RFC 3339partial-time(HH:MM:SS[.fraction]). - json_
error - Fluent builder: start building an error event.
- json_
log - Fluent builder: start building a log event.
- json_
progress - Fluent builder: start building a progress event.
- json_
result - Fluent builder: start building a result event.
- normalize_
utc_ offset - Normalize a fixed UTC offset string to AFDATA canonical form.
- redact_
argv - Redact secret values out of a command line, using default options.
- redact_
url_ secrets - Redact secret components of a single URL string, using default options.
- redacted_
value - Return a JSON value copy with default
_secretredaction applied. - render
- Render a value as a string in the given format with the given options.
- render_
cli_ reference - Render an offline Markdown reference for a whole registry.
- validate_
protocol_ event - Validate one protocol v1 event envelope.
- validate_
protocol_ stream - Validate a finite structured CLI event stream:
(log | progress)* -> exactly one (result | error) -> end.