Repository navigation
feat(cli): --json on the guarded paid leaves (F2) - #1581
Conversation
eval personas discover, eval skill-coverage and tools preference already had --dry-run and --max-usd. Each now also takes --json and prints one cli_output.v1 document: the dry-run estimate (or item counts), a --max-usd refusal as budget_stopped with exit 3, the success payload under data, and an input error with the leaf's --help as its next step. The input-error next is opt-in per leaf (input_help_next), so no other leaf's contract changes. Part of intel#94. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unpriced usage causes cost reporting to erase known spend, including in budget-stop and write-failure documents.
1 open issue
What changed in this PR
1 new finding.
Advances #94 F2 by adding structured JSON output to three guarded paid CLI commands.
Changes:
- Adds
--jsonfor persona discovery, skill coverage, and tool preference. - Reports estimates, results, budget stops, and failures, preserving cost information after write failures.
- Updates regression tests, CLI reference, documentation, and changelog.
| File | Description |
|---|---|
dokimi/tests/test_personas_discover_output.py |
Updates write-error assertions. |
dokimi/tests/test_input_refusal_exit_sites.py |
Adjusts the exit-site baseline. |
dokimi/tests/test_cli_output.py |
Registers the three JSON leaves. |
dokimi/tests/test_cli_json_paid.py |
Tests paid-command JSON outcomes. |
dokimi/scripts/growth_baseline.json |
Removes the reduced function’s exception. |
dokimi/dokimi/commands/tools.py |
Adds tool-preference JSON output. |
dokimi/dokimi/commands/skill_coverage.py |
Adds skill-coverage JSON output. |
dokimi/dokimi/commands/personas.py |
Adds persona-discovery JSON output. |
dokimi/dokimi/cli.py |
Adds help steps and avoids duplicate documents. |
dokimi/dokimi/cli_output.py |
Adds cost and estimate helpers. |
dokimi/docs/tool-preference.md |
Documents JSON output. |
dokimi/docs/reference/cli-interface.json |
Records the new flags. |
dokimi/changelog.d/20261203_120000_napetrov_cli-json-paid.md |
Announces JSON support. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 18 selected item(s). CI at Review details
|
CLI interface change detectedThis PR changes dokimi's user-facing CLI surface (commands and/or options): ~ `dokimi eval personas discover` parameters changed:
+ added option `--json`
~ `dokimi eval skill-coverage` parameters changed:
+ added option `--json`
~ `dokimi tools preference` parameters changed:
+ added option `--json`Updated on every push; the |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1581 +/- ##
========================================
Coverage 96.44% 96.44%
========================================
Files 575 575
Lines 75717 75872 +155
Branches 13046 13076 +30
========================================
+ Hits 73022 73172 +150
Misses 1646 1646
- Partials 1049 1054 +5
🚀 New features to boost your workflow:
|
Mutation of changed linesAt 5fb6417: 74 caught · 0 missed · 6 inconclusive This is not a clean result:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟡 Changes needed · reviewed 7160be4
To fix: some --json documents still lose the cost of paid calls or say "see stderr" for an input error (line comments); the doc and test gaps there are smaller.
✅ make ci-local --offline: 34,308 passed, changed lines 97% covered · eval score ragas fault contract) fails on the base too · ✅ the new tests pass 20 random orders · ✅ strict docs build
The three leaves now print one document on every exit, and the write failures after the call keep their cost.
Agreed with @Copilot: the known spend is lost when a call has no price.
…81-dokimi-1581.Pne3Vc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_EfDc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_IkOj Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_IkO6 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_IkPB Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_IkPG Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_IkPL Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…1.Pne3Vc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABb7eAqg Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…1.Pne3Vc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…1.Pne3Vc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_EfDc Thread: PRRT_kwDOVBg7g86_IkPB Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_EfDc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…581-dokimi-1581.Pne3Vc Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
Re: review by vlad-perevezentsev
|
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟡 Changes needed · re-checked 4c3836b
To fix: the branch conflicts with current main after #1543 (--out-dir) in commands/tools.py, and --json needs to cover that new path (line comment).
✅ GitHub CI on 4c3836b: 22 jobs pass · ✅ an unwritable --out now gives cannot write /proc/nope/x.json: … with tools preference --help as the next step · git merge origin/main: conflicts in tools.py and tool-preference.md
The earlier points are fixed, and the generation-failure cost is fine to follow #1583.
…json-paid-1 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com> # Conflicts: # dokimi/docs/reference/cli-interface.json # dokimi/docs/tool-preference.md # dokimi/dokimi/commands/skill_coverage.py # dokimi/dokimi/commands/tools.py
Thread: PRRT_kwDOVBg7g86_urI6 Thread: PRR_kwDOVBg7g88AAAABcPn-Cw Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g86_urI6 Thread: PRR_kwDOVBg7g88AAAABcPn-Cw Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
Re: review by vlad-perevezentsev
|
antonwolfy
left a comment
There was a problem hiding this comment.
LGTM. The three leaves print one document on every exit, the cost survives the write failures after the paid calls, and the --out-dir path of tools preference is covered after the merge with main. No findings.
What I ran, on a Linux review host at 0f30589:
make ci-local: 38 passed, 0 failed, 16 skipped (matrix legs on other Pythons and org-level checks); 35,902 tests passed, 28 skipped.- Read the diff of
cli.py,cli_output.pyand the three commands against the documents the description lists (dry run, refused cap, mid-run stop, write failures).
Checked, no issues
- Commits: every non-merge commit has a
Signed-off-by. - Opt-in
next:input_help_nextis set only on the three leaves, so no other leaf's input-error document changes. - Unpriced calls:
skill-coverageandtools preferencetake spend from the client's meter, so known dollars stay incostwith a null remainder. - Persona generation failure: a malformed reply still reports zero calls. The author tracks it in #1583 and the earlier reviewer accepted that.
vchamarthi
left a comment
There was a problem hiding this comment.
@napetrov, could you fix the 3 small things I've marked fix before merge (in the line comments) and answer my 2 questions below? I'll approve once that's done.
I'll approve once that's done.
My questions before I approve:
--factors ,(a comma with no name) is read as no factors: a dry run with--jsonreportscomplete, an emptyfactorslist and only the baseline items, while--factors ''gives the default factors. Decide whether a--factorslist with no names should be refused like an unknown factor, and say which in--helpor the docs.- The PR description says the tools
--max-usdlimit names the unpriced call, but the limit text isa call came back with no price, so --max-usd cannot be enforcedand does not say which call. Change the PR description to match the text, or add the unpriced call's item id to the limit text.
Optional, non-blocking (1)
dokimi/dokimi/commands/personas.py:148: A persona reply with nopersonaskey exits 5 and reportscost.calls0, though the paid call was made.
What I checked on 0f30589:
- When I changed the code on purpose, the tests still passed for 7 of 12 changes, and no test pins these down yet (non-blocking):
dokimi/dokimi/cli.py:475(the handled error is raised again),dokimi/dokimi/commands/personas.py:101(the handled error is raised again),dokimi/dokimi/commands/skill_coverage.py:164(the handled error is raised again) and 3 more. - The 237 changed tests pass, and fail on main as expected.
- The full test suite passes with main merged in (40,685 tests), apart from failures main has too.
- It merges cleanly onto main.
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AKf0o Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AKf0q Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AKf0t Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABcd8VMw.b Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
…s next step (intel#94) Test-narrowed: the tools preference post-call refusal now names its --help step (the intel#1581 nit), so the old next == [] expectation is replaced by the help-step asserts; that test now has four asserts where it had three. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

Part of #94 (F2,
--jsonon the guarded paid leaves). #94 stays open.Summary
Adds
--json(cli_output.v1) to three paid leaves that already have--dry-runand--max-usd:eval personas discovereval skill-coveragetools preferenceskill routingandrepo hits judgealready have--jsonon main and are not touched.skill novelty analyzeandcatalog routingare left for a follow-up PR.What the document says
statuscomplete,data.estimate(personas, skill-coverage) or the item counts (tools),cost.calls0,cost.spent_usd0, andcost.estimate_kindnull.statusbudget_stopped,limits[0].codeidentifies the cap (max_usdormax_calls),reason= the refusal text. Exit 3 is not a cli_output error code, so there is noerrorobject.statuscomplete.datais the leaf's payload. For tools preference this is the saved tool_preference artifact, schema_version included.artifacts.outnames the report, including its actual path under--out-dir.artifacts.copynames a successful--outcopy when run directories are enabled. Tool preference and skill coverage meter the calls. The envelope keeps known spend when some calls are unpriced, with a null remainder. For personas the cost is the list-price estimate of the one generation call, because generation is not metered until fix(cost): judge_metrics skips cache replays; one Spend accumulator for totals #1183.statusbudget_stopped withlimits[0].codemax_usdormax_calls, exit 1, as before. The exit code is unchanged; the document only adds the status.statusfailed, or budget_stopped with exit 3 when calls were skipped: at the cap, or because a call had no list price (themax_usdlimit explains that the missing price prevented cap enforcement). The payload stays underdata.error.codeinput, andnextholds the leaf's own--helpas a free step, for errors raised asInputError(bad arguments, an unreadable input, an unwritable tool preference output, or an unwritable analysis file (<product>_analysis.json, saved with--save-analysis) before any paid call). This is opt-in per leaf through theinput_help_nextdefault, so no other leaf's input-error contract changes.--outiserror.codeinput(exit 2) withcoststill holding what the calls spent, andnextempty. A rejected save isstatusfailed (exit 1) and retains the call cost. Malformed persona replies still emit the fallback infra document without recording the generation call. The error handling is tracked in fix(personas): eval personas discover exits 1 when its model call fails (#1555) #1583.Evidence
tests/test_cli_json_paid.pyexercises the CLI with model calls mocked. It tests the no-client dry runs, known spend when coverage receives mixed pricing, output-path errors, and schema rejection. It also covers the default tool preference report, a run directory, a copy, a budget stop, failed writes, and the skill-coverage call limit. Plain-mode schema rejection and persona output paths are also covered.tests/test_cli_output.py: the three leaves are added to the invariant set that has no next by design.docs/reference/cli-interface.jsonincludes the three new--jsonentries.Merge danger
cli.py_exit_with_documentnow addsnextonly when a leaf setsinput_help_next. The three leaves set it. Nothing else changes.cli.pymain: anInputErrorno longer prints a second document when the leaf already printed its own (the skill-coverage write failure does).tools preferencerecords each published path. An output failure preserves call cost and any report already saved to the run directory.cli_output.pyaddscost_ofandemit_estimate; both are new, and no existing caller changes.🤖 Generated with Claude Code