agent-first-data 0.24.0__tar.gz → 0.26.0__tar.gz
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.
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/PKG-INFO +3 -3
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/README.md +2 -2
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/__init__.py +2 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/assets/cli-help-v1.schema.json +4 -2
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/cli.py +1 -10
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/format.py +57 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data.egg-info/PKG-INFO +3 -3
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/pyproject.toml +1 -1
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/tests/test_cli.py +7 -7
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/tests/test_format.py +18 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/assets/protocol-v1.schema.json +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/assets/registry.json +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data.egg-info/SOURCES.txt +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data.egg-info/dependency_links.txt +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data.egg-info/top_level.txt +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/setup.cfg +0 -0
- {agent_first_data-0.24.0 → agent_first_data-0.26.0}/tests/test_no_stderr_policy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-first-data
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.26.0
|
|
4
4
|
Summary: 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-Expression: MIT
|
|
6
6
|
Project-URL: Repository, https://github.com/agentfirstkit/agent-first-data
|
|
@@ -28,7 +28,7 @@ print(render(value, OutputFormat.JSON))
|
|
|
28
28
|
print(render(value, OutputFormat.PLAIN))
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
31
|
+
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `redact_argv`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
32
32
|
|
|
33
33
|
## Behavior Notes
|
|
34
34
|
|
|
@@ -37,7 +37,7 @@ Useful names use Python casing: `render` (the single value x format x options ->
|
|
|
37
37
|
- 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.
|
|
38
38
|
- Logging records use `kind:"log"` with a nested `log` payload and a separate `level` field, so error-level logs are not terminal protocol errors.
|
|
39
39
|
- `build_cli_error(message, hint?)` returns a strict-ready CLI error with `error.retryable:false` and `trace:{}`.
|
|
40
|
-
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event.
|
|
40
|
+
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event. An explicit `--output` wins; pass the command's normal output as `default_format` (JSON when omitted), plus its value-taking global flag names.
|
|
41
41
|
|
|
42
42
|
## Reference
|
|
43
43
|
|
|
@@ -19,7 +19,7 @@ print(render(value, OutputFormat.JSON))
|
|
|
19
19
|
print(render(value, OutputFormat.PLAIN))
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
22
|
+
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `redact_argv`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
23
23
|
|
|
24
24
|
## Behavior Notes
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ Useful names use Python casing: `render` (the single value x format x options ->
|
|
|
28
28
|
- 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.
|
|
29
29
|
- Logging records use `kind:"log"` with a nested `log` payload and a separate `level` field, so error-level logs are not terminal protocol errors.
|
|
30
30
|
- `build_cli_error(message, hint?)` returns a strict-ready CLI error with `error.retryable:false` and `trace:{}`.
|
|
31
|
-
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event.
|
|
31
|
+
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event. An explicit `--output` wins; pass the command's normal output as `default_format` (JSON when omitted), plus its value-taking global flag names.
|
|
32
32
|
|
|
33
33
|
## Reference
|
|
34
34
|
|
|
@@ -24,6 +24,7 @@ from agent_first_data.format import (
|
|
|
24
24
|
PlainStyle,
|
|
25
25
|
OutputOptions,
|
|
26
26
|
redacted_value,
|
|
27
|
+
redact_argv,
|
|
27
28
|
redact_url_secrets,
|
|
28
29
|
normalize_utc_offset,
|
|
29
30
|
is_valid_bcp47,
|
|
@@ -70,6 +71,7 @@ __all__ = [
|
|
|
70
71
|
"PlainStyle",
|
|
71
72
|
"OutputOptions",
|
|
72
73
|
"redacted_value",
|
|
74
|
+
"redact_argv",
|
|
73
75
|
"redact_url_secrets",
|
|
74
76
|
"normalize_utc_offset",
|
|
75
77
|
"is_valid_bcp47",
|
{agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/assets/cli-help-v1.schema.json
RENAMED
|
@@ -147,7 +147,8 @@
|
|
|
147
147
|
},
|
|
148
148
|
"usage": {
|
|
149
149
|
"type": "string",
|
|
150
|
-
"minLength": 1
|
|
150
|
+
"minLength": 1,
|
|
151
|
+
"pattern": "^[^\\n\\r]+$"
|
|
151
152
|
},
|
|
152
153
|
"arguments": {
|
|
153
154
|
"type": "array",
|
|
@@ -203,7 +204,8 @@
|
|
|
203
204
|
},
|
|
204
205
|
"usage": {
|
|
205
206
|
"type": "string",
|
|
206
|
-
"minLength": 1
|
|
207
|
+
"minLength": 1,
|
|
208
|
+
"pattern": "^[^\\n\\r]+$"
|
|
207
209
|
},
|
|
208
210
|
"arguments": {
|
|
209
211
|
"type": "array",
|
|
@@ -463,7 +463,7 @@ def cli_handle_version_or_continue(
|
|
|
463
463
|
|
|
464
464
|
The one blessed behavior: ``--version``/``-V`` always answers with a
|
|
465
465
|
protocol-v1 ``kind:"result"`` version event (see :func:`build_cli_version`) —
|
|
466
|
-
An explicit ``--
|
|
466
|
+
An explicit ``--output <json|yaml|plain>`` wins; otherwise
|
|
467
467
|
``default_format`` should be the command's normal output default.
|
|
468
468
|
|
|
469
469
|
Only a top-level version request is recognized: scanning stops at the first
|
|
@@ -496,15 +496,6 @@ def cli_handle_version_or_continue(
|
|
|
496
496
|
version_requested = True
|
|
497
497
|
i += 1
|
|
498
498
|
continue
|
|
499
|
-
if arg == "--json":
|
|
500
|
-
if output_format is not None and output_format is not OutputFormat.JSON:
|
|
501
|
-
output_error = ValueError(
|
|
502
|
-
"conflicting output formats: --json conflicts with previous output format"
|
|
503
|
-
)
|
|
504
|
-
else:
|
|
505
|
-
output_format = OutputFormat.JSON
|
|
506
|
-
i += 1
|
|
507
|
-
continue
|
|
508
499
|
# `--output-to` takes a value but does not affect version output. Consume
|
|
509
500
|
# its space-separated value so it is not mistaken for the subcommand
|
|
510
501
|
# boundary (which would hide a later `--version`/`--output`).
|
|
@@ -613,6 +613,63 @@ def redact_url_secrets(url: str, *, secret_names: Sequence[str] = ()) -> str:
|
|
|
613
613
|
return redacted if redacted is not None else url
|
|
614
614
|
|
|
615
615
|
|
|
616
|
+
def redact_argv(
|
|
617
|
+
args: Sequence[str],
|
|
618
|
+
*,
|
|
619
|
+
secret_names: Sequence[str] = (),
|
|
620
|
+
policy: RedactionPolicy | None = None,
|
|
621
|
+
) -> list[str]:
|
|
622
|
+
"""Redact secret values out of a command line.
|
|
623
|
+
|
|
624
|
+
A long flag whose name is secret by AFDATA naming (``--api-key-secret``, or
|
|
625
|
+
an exact ``secret_names`` entry) has its value replaced by ``***``, in both
|
|
626
|
+
``--flag=value`` and ``--flag value`` spellings. Everything else is
|
|
627
|
+
preserved byte-for-byte.
|
|
628
|
+
|
|
629
|
+
Free text is deliberately never scanned: a bare ``api_key_secret=sk-live``
|
|
630
|
+
positional, or a secret-looking token after a non-secret flag, is left
|
|
631
|
+
alone. AFDATA decides sensitivity from the *field name*, and argv is no
|
|
632
|
+
exception — rename the flag rather than pattern-matching values. A flag with
|
|
633
|
+
no value (end of argv, or followed by another flag) is likewise left
|
|
634
|
+
inspectable.
|
|
635
|
+
|
|
636
|
+
Only long (``--``) flags are recognized, matching the convention's
|
|
637
|
+
long-flags-only rule.
|
|
638
|
+
|
|
639
|
+
Intended for CLIs that record their own invocation — startup diagnostics,
|
|
640
|
+
audit trails, crash reports — where writing argv verbatim would put a
|
|
641
|
+
credential in the log.
|
|
642
|
+
"""
|
|
643
|
+
if policy is RedactionPolicy.Off:
|
|
644
|
+
return list(args)
|
|
645
|
+
context = _RedactionContext.from_names(secret_names)
|
|
646
|
+
out: list[str] = []
|
|
647
|
+
redact_next = False
|
|
648
|
+
for arg in args:
|
|
649
|
+
if redact_next:
|
|
650
|
+
redact_next = False
|
|
651
|
+
if not arg.startswith("-"):
|
|
652
|
+
out.append("***")
|
|
653
|
+
continue
|
|
654
|
+
if arg.startswith("--"):
|
|
655
|
+
rest = arg[2:]
|
|
656
|
+
name, sep, _value = rest.partition("=")
|
|
657
|
+
if sep:
|
|
658
|
+
if _is_secret_flag_name(name, context):
|
|
659
|
+
out.append(f"--{name}=***")
|
|
660
|
+
continue
|
|
661
|
+
elif _is_secret_flag_name(rest, context):
|
|
662
|
+
redact_next = True
|
|
663
|
+
out.append(arg)
|
|
664
|
+
return out
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
def _is_secret_flag_name(flag_name: str, context: _RedactionContext) -> bool:
|
|
668
|
+
"""Whether a long flag's name is secret, normalizing kebab-case to snake_case."""
|
|
669
|
+
normalized = flag_name.replace("-", "_")
|
|
670
|
+
return context.is_secret_key(normalized) or context.is_secret_key(flag_name)
|
|
671
|
+
|
|
672
|
+
|
|
616
673
|
def _apply_redaction(value: Any, secret_names: Sequence[str], policy: RedactionPolicy | None) -> None:
|
|
617
674
|
context = _RedactionContext.from_names(secret_names)
|
|
618
675
|
_apply_redaction_policy_with_context(value, policy, context)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-first-data
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.26.0
|
|
4
4
|
Summary: 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-Expression: MIT
|
|
6
6
|
Project-URL: Repository, https://github.com/agentfirstkit/agent-first-data
|
|
@@ -28,7 +28,7 @@ print(render(value, OutputFormat.JSON))
|
|
|
28
28
|
print(render(value, OutputFormat.PLAIN))
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
31
|
+
Useful names use Python casing: `render` (the single value x format x options -> str entry point; takes an `OutputFormat` and an optional keyword-only `options=`), `redacted_value`, `redact_url_secrets`, `redact_argv`, `normalize_utc_offset`, `is_valid_rfc3339_date`, `is_valid_rfc3339_time`, `is_valid_rfc3339`, `is_valid_bcp47`, `cli_parse_output`, `build_cli_error`, `build_cli_version`, `cli_handle_version_or_continue`, `decode_protocol_event`.
|
|
32
32
|
|
|
33
33
|
## Behavior Notes
|
|
34
34
|
|
|
@@ -37,7 +37,7 @@ Useful names use Python casing: `render` (the single value x format x options ->
|
|
|
37
37
|
- 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.
|
|
38
38
|
- Logging records use `kind:"log"` with a nested `log` payload and a separate `level` field, so error-level logs are not terminal protocol errors.
|
|
39
39
|
- `build_cli_error(message, hint?)` returns a strict-ready CLI error with `error.retryable:false` and `trace:{}`.
|
|
40
|
-
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event.
|
|
40
|
+
- Use `cli_handle_version_or_continue()` before argument parsing so `--version` always answers with a structured protocol-v1 `kind:"result"` version event. An explicit `--output` wins; pass the command's normal output as `default_format` (JSON when omitted), plus its value-taking global flag names.
|
|
41
41
|
|
|
42
42
|
## Reference
|
|
43
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "agent-first-data"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.26.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
|
readme = "README.md"
|
|
@@ -671,9 +671,11 @@ def test_cli_handle_version_supports_inline_output_format():
|
|
|
671
671
|
assert 'version: "1.2.3"' in out
|
|
672
672
|
|
|
673
673
|
|
|
674
|
-
def
|
|
674
|
+
def test_cli_handle_version_ignores_json_flag():
|
|
675
|
+
# --json belongs to the application: it must not select a format, and it
|
|
676
|
+
# must not conflict with one. --output yaml still wins.
|
|
675
677
|
out = cli_handle_version_or_continue(
|
|
676
|
-
["--version", "--json"],
|
|
678
|
+
["--version", "--json", "--output", "yaml"],
|
|
677
679
|
VERSION_VALUE_FLAGS,
|
|
678
680
|
"agent-cli",
|
|
679
681
|
None,
|
|
@@ -681,15 +683,13 @@ def test_cli_handle_version_json_alias():
|
|
|
681
683
|
None,
|
|
682
684
|
)
|
|
683
685
|
assert out is not None
|
|
684
|
-
|
|
685
|
-
assert parsed["kind"] == "result"
|
|
686
|
-
assert parsed["result"]["version"] == "1.2.3"
|
|
686
|
+
assert out.startswith("---\n")
|
|
687
687
|
|
|
688
688
|
|
|
689
|
-
def
|
|
689
|
+
def test_cli_handle_version_conflicting_output_formats():
|
|
690
690
|
with pytest.raises(ValueError, match="conflicting output formats"):
|
|
691
691
|
cli_handle_version_or_continue(
|
|
692
|
-
["--version", "--json", "--output", "yaml"],
|
|
692
|
+
["--version", "--output", "json", "--output", "yaml"],
|
|
693
693
|
VERSION_VALUE_FLAGS,
|
|
694
694
|
"agent-cli",
|
|
695
695
|
None,
|
|
@@ -25,6 +25,7 @@ from agent_first_data import (
|
|
|
25
25
|
OutputOptions,
|
|
26
26
|
OutputFormat,
|
|
27
27
|
redacted_value,
|
|
28
|
+
redact_argv,
|
|
28
29
|
redact_url_secrets,
|
|
29
30
|
render,
|
|
30
31
|
normalize_utc_offset,
|
|
@@ -64,6 +65,23 @@ def test_redact_url_fixtures():
|
|
|
64
65
|
assert got == case["expected"], f"[redact_url/{name}] got {got!r}"
|
|
65
66
|
|
|
66
67
|
|
|
68
|
+
def test_redact_argv_fixtures():
|
|
69
|
+
for case in _load("redact_argv.json"):
|
|
70
|
+
name = case["name"]
|
|
71
|
+
options = _redaction_options(case)
|
|
72
|
+
got = redact_argv(
|
|
73
|
+
case["input"],
|
|
74
|
+
secret_names=options.secret_names,
|
|
75
|
+
policy=options.policy,
|
|
76
|
+
)
|
|
77
|
+
assert got == case["expected"], f"[redact_argv/{name}] got {got!r}"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_redact_argv_default_matches_explicit_defaults():
|
|
81
|
+
args = ["tool", "--api-key-secret=sk-live"]
|
|
82
|
+
assert redact_argv(args) == redact_argv(args, secret_names=(), policy=None)
|
|
83
|
+
|
|
84
|
+
|
|
67
85
|
def test_redaction_options_fixtures():
|
|
68
86
|
for case in _load("redaction_options.json"):
|
|
69
87
|
name = case["name"]
|
{agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data/assets/protocol-v1.schema.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agent_first_data-0.24.0 → agent_first_data-0.26.0}/agent_first_data.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|