Issue #850: std: no JSON reader (agent.nika searches the text for the first “key”:)

Open and answer this issue on GitHub.

blocked · opened 2026-10-25 · updated 2026-10-26 · 2 comments

Part of #847 (found by step 2).

Problem. agent.nika needs total_cost_usd, num_turns, usage.*, session_id, is_error, terminal_reason from the JSON that claude --output-format json prints. std has no JSON reader, so the script searches for the first "key":. That breaks on a key that occurs twice (modelUsage repeats token names) or inside a string value. CLAUDE.md: a missing std entry that a tool needs is a finding, fixed in the compiler/std.

To build. This is a language-surface decision (a std module), so first check ADR-288 and whether a JSON module is already decided; if not, file the decision for the owner (label decision) and change this issue to blocked.

  1. Decision basis: parse into a tree (json::parse(text) -> json::Value, get(key), as_str/as_i64/as_f64/as_bool) vs. a path accessor json::get(text, "usage.input_tokens"). The second covers what the tools need.
  2. Build it in std with tests in tests/compiler/.
  3. Move agent_json in scripts/agent.nika to it.

Comments

keywan-ghadami, 2026-10-25

JSON is already decided: it is the official package json (ADR-338, ADR-344), not a std module. It is tracked in #604 (packages/json/, json::parse -> json::Value, read[T], write[T]). This issue therefore waits for #604 step 1 (json::parse with Value, Error with position); then agent_json in scripts/agent.nika moves to it. Label changed to blocked.


Generated by Claude Code

keywan-ghadami, 2026-10-26

Update (2026-10-26): the decision this issue asks for is taken. JSON is the official package packages/json/ (ADR-338, ADR-344), not a std module, and json::parse(text) -> json::Value throws json::Error exists with as_i64/as_u64/as_f64 (#604, ADR-344 D6a, Part III 17.3). So steps 1 and 2 are done by #604; the remaining step is 3, moving agent_json in scripts/agent.nika to json::parse.

It stays blocked on one point: scripts/agent.nika is a single file run with nikaia run, and a use json taking the official package in without a [dependencies] entry is ADR-338 D3 (#604 step 6, not built). Once a script can use the package, step 3 is a small change.


Generated by Claude Code

Back to Open Issues