agent-first-data 0.5.0__tar.gz → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-first-data
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Agent-First Data (AFDATA) — suffix-driven output formatting and protocol templates for AI agents
5
5
  License-Expression: MIT
6
6
  Project-URL: Repository, https://github.com/cmnspore/agent-first-data
@@ -84,8 +84,8 @@ Build AFDATA protocol structures. Return dict objects for transport payloads.
84
84
  # Success (result)
85
85
  build_json_ok(result: Any, trace: Any = None) -> dict
86
86
 
87
- # Error (simple message)
88
- build_json_error(message: str, trace: Any = None) -> dict
87
+ # Error (simple message, optional hint)
88
+ build_json_error(message: str, hint: str = None, trace: Any = None) -> dict
89
89
 
90
90
  # Generic (any code + fields)
91
91
  build_json(code: str, fields: Any, trace: Any = None) -> dict
@@ -118,6 +118,9 @@ response = build_json_ok(
118
118
  # Error
119
119
  err = build_json_error("user not found", trace={"duration_ms": 5})
120
120
 
121
+ # Error with hint
122
+ err_hint = build_json_error("wallet not found", hint="list wallets with: afpay wallet list", trace={"duration_ms": 5})
123
+
121
124
  # Specific error code
122
125
  not_found = build_json(
123
126
  "not_found",
@@ -204,7 +207,7 @@ class OutputFormat(enum.Enum): # JSON="json", YAML="yaml", PLAIN="plain"
204
207
  cli_parse_output(s: str) -> OutputFormat # Parse --output flag; raises ValueError on unknown
205
208
  cli_parse_log_filters(entries: list[str]) -> list[str] # Normalize --log: trim, lowercase, dedup, remove empty
206
209
  cli_output(value: Any, format: OutputFormat) -> str # Dispatch to output_json/yaml/plain
207
- build_cli_error(message: str) -> dict # {code:"error", error_code:"invalid_request", retryable:False, trace:{duration_ms:0}}
210
+ build_cli_error(message: str, hint: str = None) -> dict # {code:"error", error_code:"invalid_request", hint?, retryable:False, trace:{duration_ms:0}}
208
211
  ```
209
212
 
210
213
  **Canonical pattern** — parse all flags before doing work, emit JSONL errors to stdout:
@@ -75,8 +75,8 @@ Build AFDATA protocol structures. Return dict objects for transport payloads.
75
75
  # Success (result)
76
76
  build_json_ok(result: Any, trace: Any = None) -> dict
77
77
 
78
- # Error (simple message)
79
- build_json_error(message: str, trace: Any = None) -> dict
78
+ # Error (simple message, optional hint)
79
+ build_json_error(message: str, hint: str = None, trace: Any = None) -> dict
80
80
 
81
81
  # Generic (any code + fields)
82
82
  build_json(code: str, fields: Any, trace: Any = None) -> dict
@@ -109,6 +109,9 @@ response = build_json_ok(
109
109
  # Error
110
110
  err = build_json_error("user not found", trace={"duration_ms": 5})
111
111
 
112
+ # Error with hint
113
+ err_hint = build_json_error("wallet not found", hint="list wallets with: afpay wallet list", trace={"duration_ms": 5})
114
+
112
115
  # Specific error code
113
116
  not_found = build_json(
114
117
  "not_found",
@@ -195,7 +198,7 @@ class OutputFormat(enum.Enum): # JSON="json", YAML="yaml", PLAIN="plain"
195
198
  cli_parse_output(s: str) -> OutputFormat # Parse --output flag; raises ValueError on unknown
196
199
  cli_parse_log_filters(entries: list[str]) -> list[str] # Normalize --log: trim, lowercase, dedup, remove empty
197
200
  cli_output(value: Any, format: OutputFormat) -> str # Dispatch to output_json/yaml/plain
198
- build_cli_error(message: str) -> dict # {code:"error", error_code:"invalid_request", retryable:False, trace:{duration_ms:0}}
201
+ build_cli_error(message: str, hint: str = None) -> dict # {code:"error", error_code:"invalid_request", hint?, retryable:False, trace:{duration_ms:0}}
199
202
  ```
200
203
 
201
204
  **Canonical pattern** — parse all flags before doing work, emit JSONL errors to stdout:
@@ -69,7 +69,7 @@ def cli_output(value: Any, format: OutputFormat) -> str:
69
69
  return output_json(value)
70
70
 
71
71
 
72
- def build_cli_error(message: str) -> dict:
72
+ def build_cli_error(message: str, hint: str | None = None) -> dict:
73
73
  """Build a standard CLI parse error value.
74
74
 
75
75
  Use when argument parsing fails or a flag value is invalid.
@@ -83,10 +83,13 @@ def build_cli_error(message: str) -> dict:
83
83
  >>> v["retryable"]
84
84
  False
85
85
  """
86
- return {
86
+ m: dict = {
87
87
  "code": "error",
88
88
  "error_code": "invalid_request",
89
89
  "error": message,
90
90
  "retryable": False,
91
91
  "trace": {"duration_ms": 0},
92
92
  }
93
+ if hint is not None:
94
+ m["hint"] = hint
95
+ return m
@@ -25,9 +25,11 @@ def build_json_ok(result: Any, trace: Any = None) -> dict:
25
25
  return m
26
26
 
27
27
 
28
- def build_json_error(message: str, trace: Any = None) -> dict:
29
- """Build {code: "error", error: message, trace?}."""
28
+ def build_json_error(message: str, hint: str | None = None, trace: Any = None) -> dict:
29
+ """Build {code: "error", error: message, hint?, trace?}."""
30
30
  m: dict = {"code": "error", "error": message}
31
+ if hint is not None:
32
+ m["hint"] = hint
31
33
  if trace is not None:
32
34
  m["trace"] = trace
33
35
  return m
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-first-data
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Agent-First Data (AFDATA) — suffix-driven output formatting and protocol templates for AI agents
5
5
  License-Expression: MIT
6
6
  Project-URL: Repository, https://github.com/cmnspore/agent-first-data
@@ -84,8 +84,8 @@ Build AFDATA protocol structures. Return dict objects for transport payloads.
84
84
  # Success (result)
85
85
  build_json_ok(result: Any, trace: Any = None) -> dict
86
86
 
87
- # Error (simple message)
88
- build_json_error(message: str, trace: Any = None) -> dict
87
+ # Error (simple message, optional hint)
88
+ build_json_error(message: str, hint: str = None, trace: Any = None) -> dict
89
89
 
90
90
  # Generic (any code + fields)
91
91
  build_json(code: str, fields: Any, trace: Any = None) -> dict
@@ -118,6 +118,9 @@ response = build_json_ok(
118
118
  # Error
119
119
  err = build_json_error("user not found", trace={"duration_ms": 5})
120
120
 
121
+ # Error with hint
122
+ err_hint = build_json_error("wallet not found", hint="list wallets with: afpay wallet list", trace={"duration_ms": 5})
123
+
121
124
  # Specific error code
122
125
  not_found = build_json(
123
126
  "not_found",
@@ -204,7 +207,7 @@ class OutputFormat(enum.Enum): # JSON="json", YAML="yaml", PLAIN="plain"
204
207
  cli_parse_output(s: str) -> OutputFormat # Parse --output flag; raises ValueError on unknown
205
208
  cli_parse_log_filters(entries: list[str]) -> list[str] # Normalize --log: trim, lowercase, dedup, remove empty
206
209
  cli_output(value: Any, format: OutputFormat) -> str # Dispatch to output_json/yaml/plain
207
- build_cli_error(message: str) -> dict # {code:"error", error_code:"invalid_request", retryable:False, trace:{duration_ms:0}}
210
+ build_cli_error(message: str, hint: str = None) -> dict # {code:"error", error_code:"invalid_request", hint?, retryable:False, trace:{duration_ms:0}}
208
211
  ```
209
212
 
210
213
  **Canonical pattern** — parse all flags before doing work, emit JSONL errors to stdout:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agent-first-data"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "Agent-First Data (AFDATA) — suffix-driven output formatting and protocol templates for AI agents"
5
5
  license = "MIT"
6
6
  readme = "README.md"
@@ -75,6 +75,16 @@ def test_build_cli_error_is_valid_json():
75
75
  assert parsed["code"] == "error"
76
76
 
77
77
 
78
+ def test_build_cli_error_with_hint():
79
+ v = build_cli_error("bad flag", hint="try --help")
80
+ assert v["hint"] == "try --help"
81
+
82
+
83
+ def test_build_cli_error_without_hint_has_no_hint_key():
84
+ v = build_cli_error("oops")
85
+ assert "hint" not in v
86
+
87
+
78
88
  # ── cli_output ────────────────────────────────────────────────────────────────
79
89
 
80
90
  def test_cli_output_dispatches_json():
@@ -53,7 +53,11 @@ def test_protocol_fixtures():
53
53
  elif typ == "error":
54
54
  result = build_json_error(args["message"])
55
55
  elif typ == "error_trace":
56
- result = build_json_error(args["message"], args["trace"])
56
+ result = build_json_error(args["message"], trace=args["trace"])
57
+ elif typ == "error_hint":
58
+ result = build_json_error(args["message"], hint=args.get("hint"))
59
+ elif typ == "error_hint_trace":
60
+ result = build_json_error(args["message"], hint=args.get("hint"), trace=args["trace"])
57
61
  elif typ == "status":
58
62
  result = build_json(args["code"], args.get("fields"))
59
63
  else: