agentcap-cli 0.5.3__tar.gz → 0.5.4__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.
Files changed (120) hide show
  1. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/PKG-INFO +43 -8
  2. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/README.md +42 -7
  3. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/landing/v2/README.md +4 -3
  4. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/pyproject.toml +1 -1
  5. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/__init__.py +1 -1
  6. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/cli_history.py +24 -1
  7. agentcap_cli-0.5.4/src/agentcap/fixes.py +336 -0
  8. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/waste.py +299 -52
  9. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_agents.py +137 -0
  10. agentcap_cli-0.5.4/tests/test_fixes.py +166 -0
  11. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/.gitignore +0 -0
  12. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/LICENSE +0 -0
  13. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/codex-plugin/LICENSE +0 -0
  14. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/plugin/LICENSE +0 -0
  15. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/plugin/README.md +0 -0
  16. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/_lifeline_exec.py +0 -0
  17. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/_lifeline_watch.py +0 -0
  18. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/adapters.py +0 -0
  19. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/alerts.py +0 -0
  20. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/analytics.py +0 -0
  21. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/budget.py +0 -0
  22. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/clamp.py +0 -0
  23. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/cli.py +0 -0
  24. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/data/pricing.json +0 -0
  25. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/demo.py +0 -0
  26. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/devtools/__init__.py +0 -0
  27. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/devtools/fake_upstream.py +0 -0
  28. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/estimate.py +0 -0
  29. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/eta.py +0 -0
  30. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/failsafe.py +0 -0
  31. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/harness.py +0 -0
  32. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/history.py +0 -0
  33. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/ledger.py +0 -0
  34. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/license.py +0 -0
  35. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/lifeline.py +0 -0
  36. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/live_quota.py +0 -0
  37. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/logschema.py +0 -0
  38. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/loop.py +0 -0
  39. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/plans.py +0 -0
  40. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/pricing.py +0 -0
  41. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/private.py +0 -0
  42. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/procstop.py +0 -0
  43. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/proxy.py +0 -0
  44. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/quota.py +0 -0
  45. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/report.py +0 -0
  46. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/runner.py +0 -0
  47. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/upstreams.py +0 -0
  48. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/src/agentcap/usage.py +0 -0
  49. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/conftest.py +0 -0
  50. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-a1b2c3.jsonl +0 -0
  51. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p/subagents/agent-d4e5f6.jsonl +0 -0
  52. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/claude/projects/-home-dev-shop/sess-p.jsonl +0 -0
  53. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-00-thr-parent.jsonl +0 -0
  54. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-00-50-thr-child.jsonl +0 -0
  55. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/agents/codex/sessions/2026/10/29/rollout-2026-10-29T09-01-20-thr-fork.jsonl +0 -0
  56. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/harness_logs/agy-1.4.11-2026-10-30.jsonl +0 -0
  57. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/harness_logs/claude-2.1.316-pretooluse.json +0 -0
  58. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/harness_logs/claude-2.1.316-statusline.json +0 -0
  59. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/harness_logs/codex-rollout-2026-10-29.jsonl +0 -0
  60. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/harness_logs/opencode-2026-10-30.jsonl +0 -0
  61. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/history/claude/.credentials.json +0 -0
  62. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/history/claude/projects/-home-dev-shop/1f0c-sess-a.jsonl +0 -0
  63. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/history/codex/auth.json +0 -0
  64. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/history/codex/sessions/2026/10/29/rollout-2026-10-29T10-00-00-0199aaaa-bbbb-cccc-dddd-eeeeeeeeeeee.jsonl +0 -0
  65. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/README.md +0 -0
  66. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/anthropic_403_permission_error.json +0 -0
  67. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/openai_403_region_blocked.json +0 -0
  68. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/openrouter_401_user_not_found.json +0 -0
  69. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/openrouter_403_moderation.json +0 -0
  70. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/fixtures/upstream/openrouter_429_rate_limited.json +0 -0
  71. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/license_support.py +0 -0
  72. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/proxy_support.py +0 -0
  73. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_adapters.py +0 -0
  74. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_agent_set.py +0 -0
  75. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_alerts.py +0 -0
  76. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_analytics.py +0 -0
  77. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_anthropic_proxy.py +0 -0
  78. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_anthropic_units.py +0 -0
  79. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_budget.py +0 -0
  80. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_cc_plugin.py +0 -0
  81. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_child_status.py +0 -0
  82. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_clamp.py +0 -0
  83. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_claude_adapter_and_tiers.py +0 -0
  84. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_cli.py +0 -0
  85. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_codex_plugin.py +0 -0
  86. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_concurrent_forgive.py +0 -0
  87. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_e2e_claude.py +0 -0
  88. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_estimate.py +0 -0
  89. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_exit_codes.py +0 -0
  90. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_failsafe.py +0 -0
  91. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_harness.py +0 -0
  92. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_history.py +0 -0
  93. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_ledger.py +0 -0
  94. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_license.py +0 -0
  95. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_lifeline.py +0 -0
  96. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_live_quota.py +0 -0
  97. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_log_contract.py +0 -0
  98. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_log_contract_live.py +0 -0
  99. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_loop.py +0 -0
  100. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_plugin_package.py +0 -0
  101. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_pricing.py +0 -0
  102. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_private_dirs.py +0 -0
  103. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_procstop.py +0 -0
  104. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_prompt_block.py +0 -0
  105. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_proxy_auth.py +0 -0
  106. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_proxy_cancel.py +0 -0
  107. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_proxy_core.py +0 -0
  108. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_proxy_extras.py +0 -0
  109. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_proxy_streaming.py +0 -0
  110. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_quota.py +0 -0
  111. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_release.py +0 -0
  112. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_report_cli.py +0 -0
  113. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_runaway.py +0 -0
  114. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_runner.py +0 -0
  115. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_self_approve.py +0 -0
  116. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_stop_matrix.py +0 -0
  117. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_upstream_refusals.py +0 -0
  118. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_upstreams.py +0 -0
  119. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_usage.py +0 -0
  120. {agentcap_cli-0.5.3 → agentcap_cli-0.5.4}/tests/test_zombie_collector.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentcap-cli
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt.
5
5
  Project-URL: Homepage, https://agentcap.launchbench.studio
6
6
  Project-URL: Repository, https://github.com/Blitz00X/agentcap
@@ -39,7 +39,7 @@ tool loops and error streaks.
39
39
  ```text
40
40
  $ agentcap waste --since 7d
41
41
  SUBAGENTS $41.20 25% of spend in 31 subagent/forked threads
42
- OPUS $38.90 24% of spend
42
+ OPUS $38.90 24% of spend (model choice, not counted as waste)
43
43
  CACHE MISSES $6.10 57 cache re-writes after the TTL ran out (5 min since the last request, or 1 h)
44
44
  main session $2.30 21x subagents $3.80 36x
45
45
  Tip: idle subagents re-wrote their own context 36x (~$3.80). Set subagentPromptCacheTtl: "1h" ...
@@ -50,6 +50,37 @@ Pro would have stopped this run at $3.12 / at 4 repeats (Bash x11 in 7f3a91c2, $
50
50
  ```
51
51
  *(illustrative numbers; run it on your own logs, it is read-only)*
52
52
 
53
+ **Try it first, nothing installed.** With [uv](https://docs.astral.sh/uv/), this downloads the
54
+ package into a throwaway environment and reads your local Claude Code / Codex logs. It installs
55
+ no hook, changes no settings, makes no model call and sends nothing anywhere:
56
+
57
+ ```bash
58
+ uvx --from agentcap-cli agentcap waste --since 7d
59
+ ```
60
+
61
+ The hooks, the statusline and the Pro licence come later, only if you install the plugin or the
62
+ command (see "Install").
63
+
64
+ **Where do you keep correcting your agent?** `agentcap fixes` reads the same logs and counts your
65
+ corrections, interrupts, rejected tool calls, churning files and "done" claims with no test run,
66
+ then says which ones to turn into a check (a hook, a permission rule, a test) instead of one more
67
+ line in CLAUDE.md:
68
+
69
+ ```bash
70
+ uvx --from agentcap-cli agentcap fixes --since 30d
71
+ ```
72
+
73
+ ```text
74
+ CORRECTIONS 47 5.3 per 100 of your messages (wrong / undo / stop / still broken)
75
+ right after done 7 the agent said it was finished, your next message corrected it
76
+ INTERRUPTS 67 you stopped a turn
77
+ DONE, NO TEST 14 "done" after editing, no test/lint/build run since the edit
78
+ EDIT CHURN 38 files edited >= 5x in one session
79
+ TURN THESE INTO CHECKS (a check runs every time; a line in CLAUDE.md is only a request)
80
+ 1. 14x "done" after editing with no test/lint/build since -> a Stop hook that runs your test command ...
81
+ ```
82
+ *(our own 30 days; your words appear on your screen only, `--json` has counts and no text)*
83
+
53
84
  ## Stop loops and quota burn (Pro)
54
85
 
55
86
  ```bash
@@ -85,10 +116,13 @@ your subscription quota % and Codex support.
85
116
  approve refused). With whole-percent quota steps a 1.5% limit stops at the next step, 2%.
86
117
  - **Free** runs the same detectors in observe-only mode and prints what Pro would have done.
87
118
 
88
- Honest limits: Claude tool-error streaks are only caught on API-key runs (the subscription hook sees
89
- the call, not its result); the stop can be one request late; quota % is account-level; verified on
90
- fixtures, fake CLIs and real Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT
91
- Plus accounts (see "Supported & tested").
119
+ Honest limits: the stop can be one request late (headless `claude -p` reads `/usage` every 30 s:
120
+ in a live test a 2-point limit ended at 4 points, and a headless turn can exit 0 after a denial);
121
+ quota % is account-level, so other sessions and devices count; macOS is not yet tested on a real
122
+ Mac. Claude tool-error streaks are caught on subscriptions too: the plugin and
123
+ `agentcap run --quota -- claude` both use a `PostToolUseFailure` hook (8 failing calls in a row). Verified on fixtures, fake CLIs and real
124
+ Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT Plus accounts (see
125
+ "Supported & tested").
92
126
 
93
127
  ## The API-key cap
94
128
 
@@ -789,10 +823,11 @@ fingerprint hash (SHA-256; it contains no hostname and no username) to Polar's
789
823
  public licence API at `api.polar.sh`. Free users make no licence requests at
790
824
  all.
791
825
 
792
- ## `agentcap waste` and usage history (Free, new in 0.2)
826
+ ## `agentcap waste`, `agentcap fixes` and usage history (Free)
793
827
 
794
828
  ```bash
795
- agentcap waste # subagent + Opus share, cache misses, tool loops, error streaks ($ each)
829
+ agentcap waste # where it went (new work / checks / rework / loops), subagents, cache misses, streaks
830
+ agentcap fixes # your corrections, interrupts, rejections, churn -> checks to add (Claude Code)
796
831
  agentcap report --by agent # session -> subagent tree with $ and Opus share
797
832
  agentcap import # read-only: ~/.claude/projects, ~/.codex/sessions, AgentCap's ledger
798
833
  agentcap report --by day # Free: day | session | model | project, tokens + API-equivalent $
@@ -9,7 +9,7 @@ tool loops and error streaks.
9
9
  ```text
10
10
  $ agentcap waste --since 7d
11
11
  SUBAGENTS $41.20 25% of spend in 31 subagent/forked threads
12
- OPUS $38.90 24% of spend
12
+ OPUS $38.90 24% of spend (model choice, not counted as waste)
13
13
  CACHE MISSES $6.10 57 cache re-writes after the TTL ran out (5 min since the last request, or 1 h)
14
14
  main session $2.30 21x subagents $3.80 36x
15
15
  Tip: idle subagents re-wrote their own context 36x (~$3.80). Set subagentPromptCacheTtl: "1h" ...
@@ -20,6 +20,37 @@ Pro would have stopped this run at $3.12 / at 4 repeats (Bash x11 in 7f3a91c2, $
20
20
  ```
21
21
  *(illustrative numbers; run it on your own logs, it is read-only)*
22
22
 
23
+ **Try it first, nothing installed.** With [uv](https://docs.astral.sh/uv/), this downloads the
24
+ package into a throwaway environment and reads your local Claude Code / Codex logs. It installs
25
+ no hook, changes no settings, makes no model call and sends nothing anywhere:
26
+
27
+ ```bash
28
+ uvx --from agentcap-cli agentcap waste --since 7d
29
+ ```
30
+
31
+ The hooks, the statusline and the Pro licence come later, only if you install the plugin or the
32
+ command (see "Install").
33
+
34
+ **Where do you keep correcting your agent?** `agentcap fixes` reads the same logs and counts your
35
+ corrections, interrupts, rejected tool calls, churning files and "done" claims with no test run,
36
+ then says which ones to turn into a check (a hook, a permission rule, a test) instead of one more
37
+ line in CLAUDE.md:
38
+
39
+ ```bash
40
+ uvx --from agentcap-cli agentcap fixes --since 30d
41
+ ```
42
+
43
+ ```text
44
+ CORRECTIONS 47 5.3 per 100 of your messages (wrong / undo / stop / still broken)
45
+ right after done 7 the agent said it was finished, your next message corrected it
46
+ INTERRUPTS 67 you stopped a turn
47
+ DONE, NO TEST 14 "done" after editing, no test/lint/build run since the edit
48
+ EDIT CHURN 38 files edited >= 5x in one session
49
+ TURN THESE INTO CHECKS (a check runs every time; a line in CLAUDE.md is only a request)
50
+ 1. 14x "done" after editing with no test/lint/build since -> a Stop hook that runs your test command ...
51
+ ```
52
+ *(our own 30 days; your words appear on your screen only, `--json` has counts and no text)*
53
+
23
54
  ## Stop loops and quota burn (Pro)
24
55
 
25
56
  ```bash
@@ -55,10 +86,13 @@ your subscription quota % and Codex support.
55
86
  approve refused). With whole-percent quota steps a 1.5% limit stops at the next step, 2%.
56
87
  - **Free** runs the same detectors in observe-only mode and prints what Pro would have done.
57
88
 
58
- Honest limits: Claude tool-error streaks are only caught on API-key runs (the subscription hook sees
59
- the call, not its result); the stop can be one request late; quota % is account-level; verified on
60
- fixtures, fake CLIs and real Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT
61
- Plus accounts (see "Supported & tested").
89
+ Honest limits: the stop can be one request late (headless `claude -p` reads `/usage` every 30 s:
90
+ in a live test a 2-point limit ended at 4 points, and a headless turn can exit 0 after a denial);
91
+ quota % is account-level, so other sessions and devices count; macOS is not yet tested on a real
92
+ Mac. Claude tool-error streaks are caught on subscriptions too: the plugin and
93
+ `agentcap run --quota -- claude` both use a `PostToolUseFailure` hook (8 failing calls in a row). Verified on fixtures, fake CLIs and real
94
+ Claude Code hooks; quota stops verified on real Claude Pro and ChatGPT Plus accounts (see
95
+ "Supported & tested").
62
96
 
63
97
  ## The API-key cap
64
98
 
@@ -759,10 +793,11 @@ fingerprint hash (SHA-256; it contains no hostname and no username) to Polar's
759
793
  public licence API at `api.polar.sh`. Free users make no licence requests at
760
794
  all.
761
795
 
762
- ## `agentcap waste` and usage history (Free, new in 0.2)
796
+ ## `agentcap waste`, `agentcap fixes` and usage history (Free)
763
797
 
764
798
  ```bash
765
- agentcap waste # subagent + Opus share, cache misses, tool loops, error streaks ($ each)
799
+ agentcap waste # where it went (new work / checks / rework / loops), subagents, cache misses, streaks
800
+ agentcap fixes # your corrections, interrupts, rejections, churn -> checks to add (Claude Code)
766
801
  agentcap report --by agent # session -> subagent tree with $ and Opus share
767
802
  agentcap import # read-only: ~/.claude/projects, ~/.codex/sessions, AgentCap's ledger
768
803
  agentcap report --by day # Free: day | session | model | project, tokens + API-equivalent $
@@ -13,9 +13,10 @@ python3 -m http.server 8787
13
13
 
14
14
  ## What is here
15
15
 
16
- - `index.html` — the page. No build step, no framework, no trackers.
17
- - `style.css` — the whole design.
18
- - `script.js` — the copy-to-clipboard button only.
16
+ - `index.html` — the page (new design 26 November 2026; plain three-part hero and quota meter 27 November). No build step, no framework. Cookieless Umami from the same origin (`/u/script.js`).
17
+ - `landing.css` — the page design. No inline styles: the live CSP is `style-src 'self'; script-src 'self'`.
18
+ - `app.js` — the hero quota meter, the usage / quota / loop demo, tabs and copy buttons. Sets widths through CSSOM, never `style=""` attributes.
19
+ - `style.css` / `script.js` — the previous design, still used by `privacy/`.
19
20
  - `fonts.css` / `fonts/` — self-hosted Instrument Serif and IBM Plex.
20
21
  - `agentcap-0.2.0.vsix` — served from the site root, not from this folder.
21
22
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "agentcap-cli"
7
- version = "0.5.3"
7
+ version = "0.5.4"
8
8
  description = "Local-first quota and cost guard for coding agents: per-job share of Claude Code/Codex/Gemini subscription quota, loop breaker, evidence receipt."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -2,6 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__ = "0.5.3"
5
+ __version__ = "0.5.4"
6
6
 
7
7
  __all__ = ["__version__"]
@@ -47,6 +47,16 @@ def register(subparsers: argparse._SubParsersAction) -> None:
47
47
  wst.add_argument("--top", type=int, default=3)
48
48
  wst.add_argument("--json", action="store_true")
49
49
 
50
+ fx = subparsers.add_parser(
51
+ "fixes", help="where you keep correcting your agent, and what to turn into a check (Free, read-only)"
52
+ )
53
+ fx.add_argument("--since", default="30d", help="all, 7d, 24h or YYYY-MM-DD (default 30d)")
54
+ fx.add_argument("--claude-dir", type=Path, help="default ~/.claude/projects")
55
+ fx.add_argument("--top", type=int, default=3)
56
+ fx.add_argument("--examples", type=int, default=5, help="latest corrections to show (0: none)")
57
+ fx.add_argument("--json", action="store_true", help="counts only; add --include-text for your words")
58
+ fx.add_argument("--include-text", action="store_true", help="with --json: include the first 70 characters")
59
+
50
60
  bud = subparsers.add_parser("budget", help="set task/hour/day $ caps and per-job quota %% in one place")
51
61
  bsub = bud.add_subparsers(dest="budget_action")
52
62
  bset = bsub.add_parser("set", help="set or change budget values (others are kept)")
@@ -180,7 +190,20 @@ def dispatch(args: argparse.Namespace) -> int | None:
180
190
  return 2
181
191
  rep = waste.scan(since=since, claude_dir=args.claude_dir, codex_dir=args.codex_dir)
182
192
  period = "all time" if since is None else f"since {args.since}"
183
- print(waste.render_json(rep) if args.json else waste.render(rep, period, args.top))
193
+ print(waste.render_json(rep) if args.json
194
+ else waste.render(rep, period, args.top, color=waste.color_enabled(sys.stdout)))
195
+ return 0
196
+ if args.subcommand == "fixes":
197
+ from . import fixes
198
+ try:
199
+ since = report.parse_since(args.since)
200
+ except ValueError as exc:
201
+ print(f"agentcap: {exc}", file=sys.stderr)
202
+ return 2
203
+ rep = fixes.scan(since=since, claude_dir=args.claude_dir)
204
+ period = "all time" if since is None else f"since {args.since}"
205
+ print(fixes.render_json(rep, args.include_text) if args.json
206
+ else fixes.render(rep, period, args.top, max(args.examples, 0)))
184
207
  return 0
185
208
  if args.subcommand == "import":
186
209
  _do_import(args, history.HistoryStore(args.db))
@@ -0,0 +1,336 @@
1
+ """`agentcap fixes` (Free): where you keep correcting your agent, and what to turn into a check.
2
+
3
+ Reads Claude Code session logs read-only and finds the moments you had to step in:
4
+
5
+ * corrections: your next message after an agent turn says it was wrong, to undo,
6
+ to stop, or that it still does not work (English and Turkish phrases)
7
+ * corrections right after the agent said it was done
8
+ * interrupts (Esc) and tool calls you rejected
9
+ * edit churn: one file edited many times in one session
10
+ * "done" after editing code with no test / lint / build run since the last edit
11
+
12
+ It then suggests checks that run every time (a hook, a permission rule, a test) for
13
+ the patterns that repeat, instead of one more line in CLAUDE.md. No model call, no
14
+ network. Your messages are shown on this screen only (first 70 characters); ``--json``
15
+ holds counts and no text unless ``--include-text``.
16
+
17
+ Claude Code only for now; Codex logs are not read yet.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import json
23
+ import re
24
+ from collections import Counter
25
+ from dataclasses import asdict, dataclass, field
26
+ from pathlib import Path
27
+ from typing import Any, Iterator
28
+
29
+ from .history import _lines, _safe_file, _ts
30
+ from .waste import VERIFY_RE, command_text, edited_files
31
+
32
+ CHURN_MIN = 5 # edits to one file in one session
33
+ EXAMPLES = 5
34
+ SNIPPET = 70
35
+
36
+ # A correction is your message right after an agent turn. Strong phrases count anywhere
37
+ # in the first 200 characters; weak ones ("no", "wait", "hayır") only at the start.
38
+ _STRONG = re.compile(
39
+ r"(?<!\w)("
40
+ r"that'?s (not|wrong)|this is wrong|not what i|i (said|told you|asked)|you (didn'?t|did not|broke|forgot|missed)"
41
+ r"|(doesn'?t|does not|didn'?t|did not|still (doesn'?t|does not)) work|not working|still (broken|failing|wrong)"
42
+ r"|why did you|revert (it|that|this)|undo (it|that|this)|put it back|roll ?back"
43
+ r"|yanlış|olmadı|olmamış|olmuyor|çalışmıyor|çalışmadı|demedim|dememiştim|söylemedim|istemedim"
44
+ r"|bozdun|bozmuşsun|geri al|eski haline|hala (aynı|olmadı|çalışmıyor|yok)|hâlâ"
45
+ r"|neden (böyle|bunu|öyle)|niye (böyle|bunu)|anlamadın|yanlış anladın|öyle değil|bu değil(?! mi)"
46
+ r")(?!\w)", re.I)
47
+ _WEAK_START = re.compile(
48
+ r"^\s*(no|nope|wrong|don'?t|do not|actually|instead|hayır|yok|yapma|değil|ulan|lan|yav|yahu)"
49
+ r"(?!\w)", re.I)
50
+ # "stop" / "wait" / "dur" / "bekle" open plenty of plain updates ("dur, VPS açıldı"); only a short
51
+ # message that is little more than the word counts.
52
+ _STOP_ONLY = re.compile(r"^\s*(stop|wait|hold on|dur|bekle)\b[\s\W]*(\w+[\s\W]*){0,3}$", re.I)
53
+ _PASTED = re.compile(r"<pasted_content\b.*?(</pasted_content>|$)", re.S)
54
+ _DONE = re.compile(
55
+ r"(?<!\w)(done|finished|complete[d]?|all set|fixed|ready|works now|all tests pass(ed)?|bitti|tamamlandı|hazır"
56
+ r"|düzeltildi|çalışıyor|tamam)(?!\w)", re.I)
57
+ _SKIP_PREFIX = ("<command-", "<local-command", "<system-reminder", "<user-prompt-submit-hook", "Caveat:",
58
+ "<task-notification", "<bash-input", "<bash-stdout", "<bash-stderr")
59
+ _REJECTED = ("doesn't want to proceed with this tool use", "tool use was rejected")
60
+ _INTERRUPT = "[Request interrupted by user"
61
+ # "done, no test" only counts edits to code; notes, docs and config need no test run
62
+ _CODE_EXT = frozenset({".py", ".js", ".mjs", ".cjs", ".ts", ".tsx", ".jsx", ".go", ".rs", ".java", ".kt", ".c",
63
+ ".cc", ".cpp", ".h", ".hpp", ".cs", ".rb", ".php", ".swift", ".sh", ".vue", ".svelte"})
64
+ _NOT_A_PROGRAM = frozenset({"for", "if", "while", "until", "case", "{", "(", "[", "echo", "printf", "cat", "ls",
65
+ "true", "false", "test", "export", "source", "."})
66
+
67
+
68
+ @dataclass
69
+ class Fix:
70
+ kind: str # correction | interrupt | rejected
71
+ session: str
72
+ ts: float
73
+ after: str # what the agent did just before: tool names or "text"
74
+ after_done: bool = False
75
+ text: str = "" # your words, first SNIPPET chars (never in --json unless asked)
76
+
77
+
78
+ @dataclass
79
+ class FixesReport:
80
+ sessions: int = 0
81
+ messages: int = 0 # your own messages
82
+ first_ts: float | None = None
83
+ fixes: list[Fix] = field(default_factory=list)
84
+ churn: list[tuple[str, str, int]] = field(default_factory=list) # (session, file, edits)
85
+ done_untested: int = 0 # "done" after edits with no verification since
86
+ rejected_tools: Counter = field(default_factory=Counter) # "Bash git", "Edit", ...
87
+
88
+ def count(self, kind: str) -> int:
89
+ return sum(1 for f in self.fixes if f.kind == kind)
90
+
91
+ def to_dict(self, include_text: bool = False) -> dict[str, Any]:
92
+ fixes = [asdict(f) for f in self.fixes]
93
+ if not include_text:
94
+ for f in fixes:
95
+ f.pop("text", None)
96
+ return {"sessions": self.sessions, "messages": self.messages, "first_ts": self.first_ts,
97
+ "corrections": self.count("correction"), "interrupts": self.count("interrupt"),
98
+ "rejected": self.count("rejected"),
99
+ "corrections_after_done": sum(1 for f in self.fixes if f.kind == "correction" and f.after_done),
100
+ "done_untested": self.done_untested,
101
+ "rejected_tools": dict(self.rejected_tools),
102
+ "churn": [{"session": s, "file": Path(p).name, "edits": n} for s, p, n in self.churn],
103
+ "fixes": fixes}
104
+
105
+
106
+ def is_correction(text: str) -> bool:
107
+ """Your own words only: pasted text is left out."""
108
+
109
+ head = _PASTED.sub(" ", text).strip()[:200]
110
+ return bool(head and (_STRONG.search(head) or _WEAK_START.match(head) or _STOP_ONLY.match(head)))
111
+
112
+
113
+ def _human_text(obj: dict[str, Any]) -> tuple[str | None, bool]:
114
+ """(your text, interrupted) for a user line written by a person; (None, False) otherwise."""
115
+
116
+ if obj.get("type") != "user" or obj.get("isMeta") or obj.get("isCompactSummary") or obj.get("toolUseResult"):
117
+ return None, False
118
+ msg = obj.get("message")
119
+ if not isinstance(msg, dict):
120
+ return None, False
121
+ content = msg.get("content")
122
+ if isinstance(content, str):
123
+ parts = [content]
124
+ elif isinstance(content, list):
125
+ if any(isinstance(b, dict) and b.get("type") == "tool_result" for b in content):
126
+ return None, False
127
+ parts = [str(b.get("text") or "") for b in content if isinstance(b, dict) and b.get("type") == "text"]
128
+ else:
129
+ return None, False
130
+ parts = [p.strip() for p in parts if p.strip() and not p.lstrip().startswith(_SKIP_PREFIX)]
131
+ if not parts:
132
+ return None, False
133
+ text = "\n".join(parts)
134
+ if text.startswith(_INTERRUPT):
135
+ return text, True
136
+ return text, False
137
+
138
+
139
+ def _rejections(obj: dict[str, Any]) -> Iterator[str]:
140
+ msg = obj.get("message")
141
+ if obj.get("type") != "user" or not isinstance(msg, dict) or not isinstance(msg.get("content"), list):
142
+ return
143
+ for b in msg["content"]:
144
+ if isinstance(b, dict) and b.get("type") == "tool_result":
145
+ body = b.get("content")
146
+ text = body if isinstance(body, str) else json.dumps(body, default=str)
147
+ if any(r in text[:400] for r in _REJECTED):
148
+ yield str(b.get("tool_use_id"))
149
+
150
+
151
+ _CMD_PREFIX = re.compile(r"^\s*(?:(?:cd|pushd)\s+\S+\s*(?:&&|;)\s*|[A-Z_][A-Z0-9_]*=\S*\s+|(?:sudo|env|time|timeout\s+\S+)\s+)+")
152
+
153
+
154
+ def _tool_label(name: str, payload: Any) -> str:
155
+ if name == "Bash":
156
+ cmd = _CMD_PREFIX.sub("", command_text(payload) or "").strip().split()
157
+ return f"Bash {cmd[0].rsplit('/', 1)[-1]}" if cmd else "Bash"
158
+ if name.startswith("mcp__"):
159
+ return name.rsplit("__", 1)[-1]
160
+ return name
161
+
162
+
163
+ def _session(path: Path, since: float | None, rep: FixesReport, seen: set[str]) -> None:
164
+ sess = path.stem
165
+ tools: dict[str, str] = {} # tool_use id -> label
166
+ turn: list[str] = [] # tool labels since your last message
167
+ turn_text = "" # the agent's last text in this turn
168
+ agent_spoke = False
169
+ edits: Counter = Counter()
170
+ dirty = False # edited since the last verification
171
+ counted = False
172
+ for obj in _lines(path):
173
+ if obj is None:
174
+ continue
175
+ uid = obj.get("uuid")
176
+ if isinstance(uid, str): # a resumed session copies earlier lines
177
+ if uid in seen:
178
+ continue
179
+ seen.add(uid)
180
+ ts = _ts(obj.get("timestamp"))
181
+ if ts is None or (since is not None and ts < since):
182
+ continue
183
+ sess = str(obj.get("sessionId") or sess)
184
+ if obj.get("isSidechain"):
185
+ continue
186
+ kind = obj.get("type")
187
+ if kind == "assistant":
188
+ msg = obj.get("message") if isinstance(obj.get("message"), dict) else {}
189
+ for b in msg.get("content") or []:
190
+ if not isinstance(b, dict):
191
+ continue
192
+ if b.get("type") == "tool_use":
193
+ name = str(b.get("name") or "?")
194
+ label = _tool_label(name, b.get("input"))
195
+ tools[str(b.get("id"))] = label
196
+ turn.append(label)
197
+ agent_spoke = True
198
+ files = edited_files(name, b.get("input"))
199
+ for f in files:
200
+ edits[f] += 1
201
+ if any(Path(f).suffix.lower() in _CODE_EXT for f in files):
202
+ dirty = True
203
+ cmd = command_text(b.get("input")) if name == "Bash" else None
204
+ if cmd and VERIFY_RE.search(cmd):
205
+ dirty = False
206
+ elif b.get("type") == "text" and str(b.get("text") or "").strip():
207
+ turn_text = str(b["text"])
208
+ agent_spoke = True
209
+ continue
210
+ for tid in _rejections(obj):
211
+ label = tools.get(tid, "?")
212
+ rep.rejected_tools[label] += 1
213
+ rep.fixes.append(Fix("rejected", sess, ts, label))
214
+ text, interrupted = _human_text(obj)
215
+ if text is None:
216
+ continue
217
+ if not counted:
218
+ rep.sessions += 1
219
+ counted = True
220
+ rep.first_ts = ts if rep.first_ts is None else min(rep.first_ts, ts)
221
+ after = "/".join(sorted(set(turn))[:3]) if turn else "text"
222
+ tail = turn_text.strip()[-300:]
223
+ said_done = bool(agent_spoke and _DONE.search(tail))
224
+ if interrupted:
225
+ rep.fixes.append(Fix("interrupt", sess, ts, after))
226
+ continue
227
+ rep.messages += 1
228
+ if said_done and dirty:
229
+ rep.done_untested += 1
230
+ if agent_spoke and is_correction(text):
231
+ rep.fixes.append(Fix("correction", sess, ts, after, said_done,
232
+ " ".join(text.split())[:SNIPPET]))
233
+ turn, turn_text, agent_spoke = [], "", False
234
+ for f, n in edits.items():
235
+ if n >= CHURN_MIN:
236
+ rep.churn.append((sess, f, n))
237
+
238
+
239
+ def scan(home: Path | None = None, since: float | None = None, claude_dir: Path | None = None) -> FixesReport:
240
+ home = Path(home) if home is not None else Path.home()
241
+ claude_dir = claude_dir or home / ".claude" / "projects"
242
+ rep = FixesReport()
243
+ seen: set[str] = set()
244
+ if claude_dir.is_dir():
245
+ paths = [p for p in claude_dir.rglob("*.jsonl") if p.parent.name != "subagents" and _safe_file(p)]
246
+
247
+ def key(p: Path) -> tuple[float, str]:
248
+ try:
249
+ return (p.stat().st_mtime, str(p))
250
+ except OSError:
251
+ return (0.0, str(p))
252
+ for path in sorted(paths, key=key):
253
+ _session(path, since, rep, seen)
254
+ rep.churn.sort(key=lambda x: -x[2])
255
+ rep.fixes.sort(key=lambda f: f.ts)
256
+ return rep
257
+
258
+
259
+ # --------------------------------------------------------------------- render
260
+ def _per100(n: int, d: int) -> str:
261
+ return f"{n / d * 100:.1f} per 100 of your messages" if d else "-"
262
+
263
+
264
+ def suggestions(rep: FixesReport) -> list[str]:
265
+ out: list[tuple[int, str]] = []
266
+ if rep.done_untested:
267
+ out.append((rep.done_untested,
268
+ f"{rep.done_untested}x \"done\" after editing with no test/lint/build since -> a Stop hook that"
269
+ " runs your test command before the agent may finish"))
270
+ after_done = sum(1 for f in rep.fixes if f.kind == "correction" and f.after_done)
271
+ if after_done:
272
+ out.append((after_done,
273
+ f"{after_done}x you corrected the agent right after it said done -> the same Stop hook; a check"
274
+ " that fails is a better \"done\" than the agent's word"))
275
+ for label, n in rep.rejected_tools.most_common(2):
276
+ cmd = label.split(" ", 1)[1] if label.startswith("Bash ") else ""
277
+ if n >= 2 and cmd and cmd not in _NOT_A_PROGRAM:
278
+ out.append((n, f"you rejected `{cmd}` {n}x -> a permission rule in .claude/settings.json:"
279
+ f" \"deny\": [\"Bash({cmd}:*)\"] (or \"ask\"), so it never runs unasked"))
280
+ elif n >= 2 and label in ("Edit", "Write", "MultiEdit", "NotebookEdit"):
281
+ out.append((n, f"you rejected {label} {n}x -> an \"ask\" rule for {label} on the paths you protect"
282
+ " (permissions in .claude/settings.json)"))
283
+ if rep.churn:
284
+ s, f, n = rep.churn[0]
285
+ out.append((n, f"{Path(f).name} edited {n}x in one session -> a check the agent runs after each edit"
286
+ " (test, lint, screenshot), so it sees the result instead of you"))
287
+ out.sort(key=lambda x: -x[0])
288
+ return [t for _, t in out[:4]]
289
+
290
+
291
+ def render(rep: FixesReport, period: str, top: int = 3, examples: int = EXAMPLES) -> str:
292
+ import datetime as _dt
293
+
294
+ start = (_dt.datetime.fromtimestamp(rep.first_ts).strftime("%d %b %Y") if rep.first_ts else "-")
295
+ out = [f"agentcap fixes - {period} - {rep.sessions} Claude Code sessions - {rep.messages} messages from you"
296
+ f" (history from {start})",
297
+ "(local Claude Code logs, read-only; nothing leaves this machine; your words are shown on this screen only)",
298
+ ""]
299
+ if not rep.messages:
300
+ out.append("No messages from you in this period.")
301
+ return "\n".join(out)
302
+ corr = [f for f in rep.fixes if f.kind == "correction"]
303
+ done = [f for f in corr if f.after_done]
304
+ out.append(f"CORRECTIONS {len(corr):5} {_per100(len(corr), rep.messages)}"
305
+ " (wrong / undo / stop / still broken)")
306
+ out.append(f" right after done {len(done):4} the agent said it was finished, your next message corrected it")
307
+ out.append(f"INTERRUPTS {rep.count('interrupt'):5} you stopped a turn")
308
+ rej = ", ".join(f"{k} x{n}" for k, n in rep.rejected_tools.most_common(top))
309
+ out.append(f"REJECTED CALLS {rep.count('rejected'):5} you said no to a tool call" + (f" ({rej})" if rej else ""))
310
+ out.append(f"DONE, NO TEST {rep.done_untested:5} \"done\" after editing, no test/lint/build run since the edit")
311
+ out.append(f"EDIT CHURN {len(rep.churn):5} files edited >= {CHURN_MIN}x in one session")
312
+ for s, f, n in rep.churn[:top]:
313
+ out.append(f" {s[:8]} {Path(f).name[:40]:<40} x{n}")
314
+ if corr:
315
+ before = Counter(f.after.split("/")[0] if f.after != "text" else "only text" for f in corr)
316
+ out.append("")
317
+ out.append("JUST BEFORE YOU CORRECTED IT, THE AGENT RAN")
318
+ out.append(" " + " ".join(f"{k} {n}" for k, n in before.most_common(5)))
319
+ out.append("")
320
+ out.append("LATEST CORRECTIONS (your words, first 70 characters)")
321
+ for f in corr[-examples:]:
322
+ day = _dt.datetime.fromtimestamp(f.ts).strftime("%d %b")
323
+ out.append(f" {day} {f.session[:8]} after {f.after[:24]:<24} \"{f.text}\"")
324
+ sug = suggestions(rep)
325
+ if sug:
326
+ out.append("")
327
+ out.append("TURN THESE INTO CHECKS (a check runs every time; a line in CLAUDE.md is only a request)")
328
+ for i, s in enumerate(sug, 1):
329
+ out.append(f" {i}. {s}")
330
+ out.append("")
331
+ out.append("Counts come from phrases in your messages (English and Turkish); about 1 in 6 is a false match in our own history.")
332
+ return "\n".join(out)
333
+
334
+
335
+ def render_json(rep: FixesReport, include_text: bool = False) -> str:
336
+ return json.dumps(rep.to_dict(include_text), indent=2)