claude-code-router 0.2.0__tar.gz → 0.2.1__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 (187) hide show
  1. claude_code_router-0.2.1/.github/workflows/publish.yml +136 -0
  2. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/CHANGELOG.md +24 -2
  3. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/PKG-INFO +5 -4
  4. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/README.md +4 -3
  5. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/config.py +8 -13
  6. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/doctor.py +5 -0
  7. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/locate.py +6 -1
  8. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/predict.py +7 -2
  9. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/workspace.py +1 -1
  10. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/__init__.py +8 -1
  11. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/prompt.py +2 -1
  12. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/install/__init__.py +0 -4
  13. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/install/settings.py +17 -0
  14. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/route/__init__.py +7 -11
  15. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/route/code.py +2 -2
  16. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/docs/CODE_FIRST_ROUTING.md +11 -7
  17. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/docs/REFERENCE.md +12 -11
  18. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/pyproject.toml +1 -1
  19. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/conftest.py +16 -0
  20. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_budget.py +1 -1
  21. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_code_first.py +24 -27
  22. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_predict.py +70 -17
  23. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_route_table.py +4 -2
  24. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/uv.lock +1 -1
  25. claude_code_router-0.2.0/.github/workflows/publish.yml +0 -65
  26. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/Explore.md +0 -0
  27. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/ccr-architect.md +0 -0
  28. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/ccr-critical.md +0 -0
  29. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/ccr-implement.md +0 -0
  30. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/ccr-quick.md +0 -0
  31. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/agents/ccr-small.md +0 -0
  32. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.claude/settings.json +0 -0
  33. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.gitattributes +0 -0
  34. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  35. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  36. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.github/pull_request_template.md +0 -0
  37. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.github/workflows/ci.yml +0 -0
  38. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/.gitignore +0 -0
  39. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/CONTRIBUTING.md +0 -0
  40. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/LICENSE +0 -0
  41. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/__init__.py +0 -0
  42. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/__main__.py +0 -0
  43. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/cli.py +0 -0
  44. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/detect/__init__.py +0 -0
  45. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/entry.py +0 -0
  46. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/__init__.py +0 -0
  47. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/classify.py +0 -0
  48. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/llm.py +0 -0
  49. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/risk.py +0 -0
  50. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/evaluate/text.py +0 -0
  51. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/__init__.py +0 -0
  52. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/build.py +0 -0
  53. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/db.py +0 -0
  54. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/files.py +0 -0
  55. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/git.py +0 -0
  56. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/parse.py +0 -0
  57. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/query.py +0 -0
  58. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/graph/resolve.py +0 -0
  59. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/headless.py +0 -0
  60. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/__init__.py +0 -0
  61. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/calibrate.py +0 -0
  62. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/dashboard.py +0 -0
  63. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/feedback.py +0 -0
  64. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/learn.py +0 -0
  65. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/prompts.py +0 -0
  66. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/redact.py +0 -0
  67. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/savings.py +0 -0
  68. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/shadow.py +0 -0
  69. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/stats.py +0 -0
  70. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/tune.py +0 -0
  71. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/history/why.py +0 -0
  72. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/bg.py +0 -0
  73. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/common.py +0 -0
  74. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/session_start.py +0 -0
  75. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/stop.py +0 -0
  76. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/hooks/tasks.py +0 -0
  77. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/install/agents.py +0 -0
  78. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/install/command.py +0 -0
  79. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/memory/__init__.py +0 -0
  80. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/memory/signals.py +0 -0
  81. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/memory/sources.py +0 -0
  82. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/report.py +0 -0
  83. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/route/budget.py +0 -0
  84. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/statusline.py +0 -0
  85. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/ccr/transcript.py +0 -0
  86. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/docs/images/dashboard.png +0 -0
  87. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/docs/images/explain.png +0 -0
  88. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/scripts/bench_graph.py +0 -0
  89. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/scripts/bench_hooks.py +0 -0
  90. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/scripts/bench_routing.py +0 -0
  91. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/go/go.mod +0 -0
  92. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/go/internal/store/store.go +0 -0
  93. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/go/internal/store/store_test.go +0 -0
  94. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/go/main.go +0 -0
  95. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/go/util.go +0 -0
  96. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/java/src/main/java/com/acme/app/App.java +0 -0
  97. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/java/src/main/java/com/acme/app/Helper.java +0 -0
  98. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/java/src/main/java/com/acme/util/Strings.java +0 -0
  99. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/.gitignore +0 -0
  100. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/app/__init__.py +0 -0
  101. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/app/core/__init__.py +0 -0
  102. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/app/core/engine.py +0 -0
  103. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/app/main.py +0 -0
  104. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/app/util.py +0 -0
  105. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/node_modules/dep/index.py +0 -0
  106. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/poetry.lock +0 -0
  107. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/tests/test_engine.py +0 -0
  108. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/py/tests/test_util.py +0 -0
  109. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/rust/Cargo.toml +0 -0
  110. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/rust/src/main.rs +0 -0
  111. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/rust/src/net/client.rs +0 -0
  112. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/rust/src/net/mod.rs +0 -0
  113. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/package-lock.json +0 -0
  114. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/app.min.js +0 -0
  115. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/app.ts +0 -0
  116. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/components/Button.tsx +0 -0
  117. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/format.ts +0 -0
  118. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/lib/index.ts +0 -0
  119. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/ts/src/lib/math.ts +0 -0
  120. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/zig/src/main.zig +0 -0
  121. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/graph/zig/src/util.zig +0 -0
  122. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/README.md +0 -0
  123. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/__init__.py +0 -0
  124. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/api/__init__.py +0 -0
  125. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/api/handlers.py +0 -0
  126. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/api/pagination.py +0 -0
  127. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/auth/__init__.py +0 -0
  128. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/auth/session.py +0 -0
  129. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/auth/tokens.py +0 -0
  130. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/core/__init__.py +0 -0
  131. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/core/config.py +0 -0
  132. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/core/engine.py +0 -0
  133. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/main.py +0 -0
  134. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/payments/__init__.py +0 -0
  135. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/payments/ledger.py +0 -0
  136. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/payments/stripe_client.py +0 -0
  137. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/reports/__init__.py +0 -0
  138. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/reports/export.py +0 -0
  139. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/utils/__init__.py +0 -0
  140. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/app/utils/strings.py +0 -0
  141. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/migrations/versions/0001_init.py +0 -0
  142. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/migrations/versions/0002_add_email.py +0 -0
  143. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/pyproject.toml +0 -0
  144. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/tests/test_engine.py +0 -0
  145. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/tests/test_pagination.py +0 -0
  146. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/shop_py/tests/test_strings.py +0 -0
  147. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/.github/workflows/ci.yml +0 -0
  148. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/cmd/server/main.go +0 -0
  149. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/deploy/terraform/main.tf +0 -0
  150. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/go.mod +0 -0
  151. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/internal/auth/jwt.go +0 -0
  152. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/internal/cache/cache.go +0 -0
  153. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/internal/http/router.go +0 -0
  154. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/internal/store/store.go +0 -0
  155. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/svc_go/internal/store/store_test.go +0 -0
  156. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/package.json +0 -0
  157. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/App.tsx +0 -0
  158. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/__tests__/format.test.ts +0 -0
  159. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/components/Button.tsx +0 -0
  160. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/components/Footer.tsx +0 -0
  161. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/components/Navbar.tsx +0 -0
  162. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/hooks/useAuth.ts +0 -0
  163. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/index.tsx +0 -0
  164. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/lib/api.ts +0 -0
  165. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/lib/format.ts +0 -0
  166. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/pages/Checkout.tsx +0 -0
  167. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/route/web_ts/src/pages/Home.tsx +0 -0
  168. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/run/error_max_budget_usd.json +0 -0
  169. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/run/error_max_turns.json +0 -0
  170. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/fixtures/run/success.json +0 -0
  171. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_calibrate.py +0 -0
  172. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_cli.py +0 -0
  173. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_config.py +0 -0
  174. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_dashboard.py +0 -0
  175. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_detect.py +0 -0
  176. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_evaluate.py +0 -0
  177. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_feedback_loops.py +0 -0
  178. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_graph.py +0 -0
  179. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_history.py +0 -0
  180. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_hooks.py +0 -0
  181. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_install.py +0 -0
  182. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_memory.py +0 -0
  183. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_privacy.py +0 -0
  184. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_release.py +0 -0
  185. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_routing_consistency.py +0 -0
  186. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_routing_gaps.py +0 -0
  187. {claude_code_router-0.2.0 → claude_code_router-0.2.1}/tests/test_run.py +0 -0
@@ -0,0 +1,136 @@
1
+ name: Release
2
+
3
+ # A push to main that changes the version releases it: tag vX.Y.Z, create the GitHub release from
4
+ # CHANGELOG.md, publish to PyPI, then npm. Every step is skipped when it is already done, so a
5
+ # push that does not change the version does nothing, and a failed run can simply be re-run.
6
+ # A release created by hand still publishes (the release event), and the GitHub release created
7
+ # here does not trigger a second run because GITHUB_TOKEN events never start workflows.
8
+
9
+ on:
10
+ push:
11
+ branches: [main]
12
+ release:
13
+ types: [published]
14
+ workflow_dispatch:
15
+
16
+ concurrency:
17
+ group: release
18
+ cancel-in-progress: false
19
+
20
+ permissions:
21
+ contents: read
22
+
23
+ jobs:
24
+ check:
25
+ runs-on: ubuntu-latest
26
+ outputs:
27
+ version: ${{ steps.v.outputs.version }}
28
+ need_release: ${{ steps.v.outputs.need_release }}
29
+ need_pypi: ${{ steps.v.outputs.need_pypi }}
30
+ need_npm: ${{ steps.v.outputs.need_npm }}
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - id: v
34
+ env:
35
+ EVENT: ${{ github.event_name }}
36
+ TAG: ${{ github.event.release.tag_name }}
37
+ run: |
38
+ set -euo pipefail
39
+ py=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
40
+ name=$(node -p "require('./npm/package.json').name")
41
+ npmv=$(node -p "require('./npm/package.json').version")
42
+ echo "pyproject=$py npm=$name@$npmv"
43
+ if [ "$py" != "$npmv" ]; then echo "::error::pyproject ($py) and npm/package.json ($npmv) disagree"; exit 1; fi
44
+ if [ "$EVENT" = "release" ] && [ "$TAG" != "v$py" ]; then
45
+ echo "::error::release tag $TAG does not match version v$py"; exit 1
46
+ fi
47
+ if git ls-remote --exit-code --tags origin "refs/tags/v$py" >/dev/null; then need_release=false; else need_release=true; fi
48
+ code=$(curl -s -o /dev/null -w '%{http_code}' "https://pypi.org/pypi/claude-code-router/$py/json")
49
+ if [ "$code" = 200 ]; then need_pypi=false; else need_pypi=true; fi
50
+ if npm view "$name@$py" version >/dev/null 2>&1; then need_npm=false; else need_npm=true; fi
51
+ echo "tag needed=$need_release pypi needed=$need_pypi npm needed=$need_npm"
52
+ {
53
+ echo "version=$py"
54
+ echo "need_release=$need_release"
55
+ echo "need_pypi=$need_pypi"
56
+ echo "need_npm=$need_npm"
57
+ } >> "$GITHUB_OUTPUT"
58
+
59
+ release:
60
+ needs: check
61
+ if: needs.check.outputs.need_release == 'true' && github.event_name != 'release'
62
+ runs-on: ubuntu-latest
63
+ permissions:
64
+ contents: write # create the tag and the GitHub release
65
+ steps:
66
+ - uses: actions/checkout@v4
67
+ - name: Create tag and GitHub release
68
+ env:
69
+ GH_TOKEN: ${{ github.token }}
70
+ VERSION: ${{ needs.check.outputs.version }}
71
+ run: |
72
+ set -euo pipefail
73
+ # Release notes: this version's section of CHANGELOG.md.
74
+ awk -v v="$VERSION" '
75
+ $0 ~ "^## \\[" v "\\]" { on = 1; next }
76
+ on && /^## \[/ { exit }
77
+ on { print }
78
+ ' CHANGELOG.md > notes.md
79
+ [ -s notes.md ] || echo "See CHANGELOG.md." > notes.md
80
+ gh release create "v$VERSION" --target "$GITHUB_SHA" --title "v$VERSION" --notes-file notes.md
81
+
82
+ build:
83
+ needs: check
84
+ if: needs.check.outputs.need_pypi == 'true'
85
+ runs-on: ubuntu-latest
86
+ steps:
87
+ - uses: actions/checkout@v4
88
+ - uses: astral-sh/setup-uv@v5
89
+ - name: Build
90
+ run: uv build
91
+ - name: Check metadata
92
+ run: uvx twine check dist/*
93
+ - uses: actions/upload-artifact@v4
94
+ with:
95
+ name: dist
96
+ path: dist/
97
+
98
+ publish-pypi:
99
+ needs: [check, release, build]
100
+ # Run after the release job unless it failed; skipped is fine (tag already there).
101
+ if: >-
102
+ always() && needs.check.result == 'success' && needs.build.result == 'success' &&
103
+ needs.release.result != 'failure' && needs.release.result != 'cancelled'
104
+ runs-on: ubuntu-latest
105
+ environment: pypi
106
+ permissions:
107
+ id-token: write # PyPI Trusted Publishing
108
+ steps:
109
+ - uses: actions/download-artifact@v4
110
+ with:
111
+ name: dist
112
+ path: dist/
113
+ - uses: pypa/gh-action-pypi-publish@release/v1
114
+
115
+ # The npm package is a launcher that installs the PyPI release, so it goes out after PyPI.
116
+ publish-npm:
117
+ needs: [check, release, publish-pypi]
118
+ if: >-
119
+ always() && needs.check.result == 'success' && needs.check.outputs.need_npm == 'true' &&
120
+ needs.release.result != 'failure' && needs.release.result != 'cancelled' &&
121
+ (needs.publish-pypi.result == 'success' || needs.check.outputs.need_pypi == 'false')
122
+ runs-on: ubuntu-latest
123
+ environment: npm
124
+ permissions:
125
+ contents: read
126
+ id-token: write # npm Trusted Publishing and provenance
127
+ steps:
128
+ - uses: actions/checkout@v4
129
+ - uses: actions/setup-node@v4
130
+ with:
131
+ node-version: "22"
132
+ - name: Use an npm that supports Trusted Publishing
133
+ run: npm install -g npm@11
134
+ - name: Publish
135
+ working-directory: npm
136
+ run: npm publish --access public --provenance
@@ -4,7 +4,29 @@ All notable changes to this project are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
- ## [0.2.0] - unreleased
7
+ ## [0.2.1] - 2026-11-24
8
+
9
+ ### Changed
10
+ - Code-first routing and the Haiku change prediction are always on; `code_first.enabled` and
11
+ `predict.enabled` are gone (an old setting is ignored with a warning). Without the `claude`
12
+ CLI, or when Haiku is late, routing silently keeps its rule-based tier.
13
+ - Recent commits only strengthen a file match that already stands on its own, and are ignored
14
+ when they touch more than 40 files (an initial import), so a fresh repo no longer turns a
15
+ loose word match into a critical path.
16
+ - A follow-up prompt waits for Haiku at most once.
17
+
18
+ ### Added
19
+ - The prompt hook keeps the prediction inside Claude Code's installed hook timeout, and
20
+ `ccr doctor` warns when that timeout is under 15 s (re-run `ccr init`).
21
+ - `CCR_NO_PREDICT=1` keeps test suites from calling the real CLI.
22
+ - Releases are automatic: a push to main that changes the version tags it, creates the GitHub
23
+ release from this changelog, and publishes to PyPI and then npm. Steps already done are skipped.
24
+
25
+ ### Fixed
26
+ - The npm package name in the repo and README is now `@satya-prakash/claude-code-router`, the
27
+ name 0.2.0 was published under.
28
+
29
+ ## [0.2.0] - 2026-11-24
8
30
 
9
31
  ### Added
10
32
  - Code-first routing behind `code_first.enabled` (off by default): uncommitted edits and
@@ -12,7 +34,7 @@ All notable changes to this project are documented here.
12
34
  by one tier. Trivial edits, questions, steps and small-scope wording keep their keyword tier.
13
35
  - Haiku change prediction behind `predict.enabled` (off by default): when routing is unsure,
14
36
  Haiku predicts the files, size and contract changes, and the tier moves by one at most. See `docs/CODE_FIRST_ROUTING.md`.
15
- - npm launcher package `claude-code-tier-router` (in `npm/`): installs `ccr` with npm and
37
+ - npm launcher package `@satya-prakash/claude-code-router` (in `npm/`): installs `ccr` with npm and
16
38
  runs the matching PyPI release from a private Python environment.
17
39
  - Release workflow publishes to npm after PyPI and checks that the tag matches both versions.
18
40
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: claude-code-router
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Route Claude Code tasks to the cheapest sufficient model and effort
5
5
  Project-URL: Homepage, https://github.com/ai-solution-architect-roadmap/claude-code-router
6
6
  Project-URL: Documentation, https://github.com/ai-solution-architect-roadmap/claude-code-router/blob/main/docs/REFERENCE.md
@@ -87,7 +87,7 @@ pipx install claude-code-router
87
87
  # or
88
88
  pip install claude-code-router
89
89
  # or, with npm (installs the same Python package into ~/.ccr-npm on first run)
90
- npm install -g claude-code-tier-router
90
+ npm install -g @satya-prakash/claude-code-router
91
91
 
92
92
  ccr --help
93
93
  ```
@@ -270,8 +270,9 @@ you add your own `critical_paths`, `critical_terms` and `hard_terms`.
270
270
 
271
271
  ## Privacy
272
272
 
273
- All routing decisions run locally. The only model call ccr makes on its own is an optional,
274
- opt-in classification by haiku through your own `claude` CLI. Local state lives in `.ccr/`.
273
+ Routing runs locally. When the rules are unsure, the prompt hook asks haiku through your own
274
+ `claude` CLI to predict the change, sending the prompt, file paths, symbol names and the diff
275
+ stat (no source). Local state lives in `.ccr/`.
275
276
 
276
277
  ## Documentation
277
278
 
@@ -60,7 +60,7 @@ pipx install claude-code-router
60
60
  # or
61
61
  pip install claude-code-router
62
62
  # or, with npm (installs the same Python package into ~/.ccr-npm on first run)
63
- npm install -g claude-code-tier-router
63
+ npm install -g @satya-prakash/claude-code-router
64
64
 
65
65
  ccr --help
66
66
  ```
@@ -243,8 +243,9 @@ you add your own `critical_paths`, `critical_terms` and `hard_terms`.
243
243
 
244
244
  ## Privacy
245
245
 
246
- All routing decisions run locally. The only model call ccr makes on its own is an optional,
247
- opt-in classification by haiku through your own `claude` CLI. Local state lives in `.ccr/`.
246
+ Routing runs locally. When the rules are unsure, the prompt hook asks haiku through your own
247
+ `claude` CLI to predict the change, sending the prompt, file paths, symbol names and the diff
248
+ stat (no source). Local state lives in `.ccr/`.
248
249
 
249
250
  ## Documentation
250
251
 
@@ -120,24 +120,23 @@ DEFAULTS: dict = {
120
120
  # only when 3+ independent signals agree)
121
121
  "ceiling_without_critical": "T3",
122
122
  },
123
- # Code-first routing (opt in): find the files from the real repository state (uncommitted
123
+ # Code-first routing (always on): find the files from the real repository state (uncommitted
124
124
  # edits, recent commits, named paths and symbols) and score that code. The score can raise
125
125
  # a real code change one tier above its keyword route; it never lowers a tier or moves
126
126
  # trivial edits and questions, and steps or small-scope words still win.
127
127
  # See docs/CODE_FIRST_ROUTING.md.
128
128
  "code_first": {
129
- "enabled": False,
130
129
  "recent_commits": 5, # files from the last N commits strengthen a match
131
130
  "min_confidence": 0.5, # location confidence needed to route from the code
132
131
  "bands": [0.2, 0.4, 0.6], # code score edges: T1 | T2 | T2H | T3
133
132
  "tie_margin": 0.04, # within this of an edge, the class base breaks the tie
134
133
  },
135
- # Step 2 of code-first routing (opt in): when routing is unsure, ask Haiku (your claude
134
+ # Step 2 of code-first routing (always on): when routing is unsure, ask Haiku (your claude
136
135
  # CLI) to predict the change: files, size, interface or schema change. A small change
137
136
  # lowers the tier by one, a large one raises it by one; never past a T4 rule or below a
138
- # critical path. Cached per prompt and repository state. See docs/CODE_FIRST_ROUTING.md.
137
+ # critical path. Cached per prompt and repository state. Without the claude CLI, or when it
138
+ # is late, routing silently keeps its rule-based tier. See docs/CODE_FIRST_ROUTING.md.
139
139
  "predict": {
140
- "enabled": False,
141
140
  "model": "haiku",
142
141
  "effort": "low",
143
142
  "timeout_s": 10.0, # hard limit; a late answer leaves routing as it was.
@@ -493,10 +492,8 @@ def _merge_code_first(cfg: Config, raw: dict) -> None:
493
492
  d = cfg.data["code_first"]
494
493
  for k, v in sec.items():
495
494
  if k == "enabled":
496
- if isinstance(v, bool):
497
- d[k] = v
498
- else:
499
- cfg.errors.append(f"code_first.enabled: expected true or false, got {v!r}")
495
+ # always on since 0.2.1; an old opt-in setting is ignored, not an error
496
+ cfg.warnings.append("code_first.enabled: ignored, code-first is always on")
500
497
  elif k == "recent_commits":
501
498
  if _num(cfg, "code_first.recent_commits", v, 0, 100):
502
499
  d[k] = int(v)
@@ -527,10 +524,8 @@ def _merge_predict(cfg: Config, raw: dict) -> None:
527
524
  d = cfg.data["predict"]
528
525
  for k, v in sec.items():
529
526
  if k == "enabled":
530
- if isinstance(v, bool):
531
- d[k] = v
532
- else:
533
- cfg.errors.append(f"predict.enabled: expected true or false, got {v!r}")
527
+ # always on since 0.2.1; an old opt-in setting is ignored, not an error
528
+ cfg.warnings.append("predict.enabled: ignored, predict is always on")
534
529
  elif k == "model":
535
530
  if _valid_model(v):
536
531
  d[k] = v
@@ -42,6 +42,11 @@ def _doctor_settings(root: Path) -> list[tuple[str, str]]:
42
42
  if isinstance(hooks, dict) and hooks:
43
43
  if "ccr" in json.dumps(hooks):
44
44
  out.append(("OK", f"ccr hooks wired ({', '.join(hooks)})"))
45
+ from ccr.install.settings import installed_prompt_timeout
46
+ t = installed_prompt_timeout(root)
47
+ if t is not None and t < 15:
48
+ out.append(("WARN", f"prompt hook timeout is {t:.0f}s: too short for the Haiku "
49
+ "change prediction; re-run `ccr init` (sets 15s)"))
45
50
  else:
46
51
  out.append(("WARN", "hooks present but none call ccr"))
47
52
  else:
@@ -316,6 +316,7 @@ WS_UNANCHORED = 0.5 # an uncommitted edit when the prompt names no code (split
316
316
  WS_NEARBY = 0.2 # an uncommitted edit next to a file the prompt points at
317
317
  WS_MAX_UNANCHORED = 10
318
318
  RECENT_MATCHED = 0.25 # a file the prompt points at that changed in the last few commits
319
+ RECENT_MAX_FILES = 40 # recent commits touching more files than this say nothing
319
320
 
320
321
 
321
322
  def _match_workspace(c: _Ctx, ws) -> None:
@@ -349,8 +350,12 @@ def _match_workspace(c: _Ctx, ws) -> None:
349
350
  if p not in c.uni_set:
350
351
  c.universe.append(p)
351
352
  c.uni_set.add(p)
353
+ # recent commits only strengthen a match that already stands on its own, and only when
354
+ # they are a small slice of the repo (not an initial import or a mass rewrite)
355
+ if len(ws.recent) > RECENT_MAX_FILES:
356
+ return
352
357
  for p in ws.recent:
353
- if p not in ws.dirty and before.get(p, 0.0) >= 0.2:
358
+ if p not in ws.dirty and before.get(p, 0.0) >= 0.4:
354
359
  c.acc.add(p, RECENT_MATCHED, "changed in a recent commit")
355
360
  loc.recent.append(p)
356
361
 
@@ -1,7 +1,7 @@
1
1
  """Step 2 of code-first routing: ask Haiku to predict the change a task will make.
2
2
 
3
- Opt in with `predict.enabled`. Only asked when routing is unsure (low confidence, a code score
4
- near a band edge, or keywords and code disagreeing by two tiers or more), with a hard
3
+ Always on; skipped without the claude CLI. Only asked when routing is unsure (low
4
+ confidence, a code score near a band edge, or keywords and code disagreeing by two tiers or more), with a hard
5
5
  timeout, and answers are cached per prompt and repository state. Goes through the user's own
6
6
  `claude` CLI like `ccr explain --llm` (ccr.evaluate.llm.run_claude), so tests mock one runner.
7
7
 
@@ -255,6 +255,9 @@ def predict(task: str, root, graph, located: list[str], *, workspace=None, cfg=N
255
255
  runner=None) -> tuple[Prediction | None, str]:
256
256
  """(prediction or None, status). Never raises."""
257
257
  from ccr.evaluate import llm as L
258
+ import os
259
+ if runner is None and os.environ.get("CCR_NO_PREDICT"): # test suites: never reach Haiku
260
+ return None, "unavailable: CCR_NO_PREDICT is set"
258
261
  root = Path(root)
259
262
  pc = cfg["predict"] if cfg is not None else {"model": "haiku", "effort": "low",
260
263
  "timeout_s": 10.0}
@@ -265,6 +268,8 @@ def predict(task: str, root, graph, located: list[str], *, workspace=None, cfg=N
265
268
  head = out.strip() if out else None
266
269
  except Exception:
267
270
  pass
271
+ if float(pc["timeout_s"]) < 1.0:
272
+ return None, "skipped: no time left inside the hook's timeout"
268
273
  key = cache_key(task, located, workspace, head)
269
274
  hit = cache_get(root, key)
270
275
  if hit is not None:
@@ -1,5 +1,5 @@
1
1
  """What is changing in the working tree right now: uncommitted edits and recently committed
2
- files. Used by code-first routing (`code_first.enabled`) to find the files a prompt is about
2
+ files. Used by code-first routing (always on) to find the files a prompt is about
3
3
  from the real repository state instead of from prompt words alone.
4
4
 
5
5
  Two or three short git calls, each with a tight timeout. Outside git, or when git is slow or
@@ -49,7 +49,14 @@ def _body(name: str, raw: bytes, environ, result: dict) -> tuple[str | None, obj
49
49
  cfg = load_config(root)
50
50
  if not environ.get("CCR_HOOK_WATCHDOG_MS"):
51
51
  result["budget"] = float(cfg["hooks"]["watchdog_ms"]) / 1000.0
52
- if cfg["predict"]["enabled"] and name == "prompt": # room for the Haiku prediction
52
+ if name == "prompt": # room for the Haiku change prediction
53
+ from ccr.install.settings import installed_prompt_timeout
54
+ limit = installed_prompt_timeout(root)
55
+ if limit is not None and limit - 2.0 < float(cfg["predict"]["timeout_s"]):
56
+ # an install from before 0.2.1 gives this hook 5 s: keep the prediction inside
57
+ # it so Claude Code never kills the hook (and its routing line); `ccr init`
58
+ # raises it to 15 s
59
+ cfg.data["predict"]["timeout_s"] = max(0.0, limit - 2.0)
53
60
  result["budget"] = max(result["budget"], float(cfg["predict"]["timeout_s"]) + 1.0)
54
61
  if cfg.errors and name != "session-start":
55
62
  return None, root # corrupt config: stay out of the way (doctor reports it)
@@ -233,7 +233,8 @@ def _follow_up(prompt: str, d, pending: dict, session: dict, root, cfg, graph_kw
233
233
  note = None
234
234
  files = [f for f in session.get("files") or [] if isinstance(f, str)]
235
235
  if files and not d.location.located:
236
- d = decide(prompt[:MAX_EVAL_CHARS] + "\n" + " ".join(files), root, cfg=cfg, **graph_kw)
236
+ d = decide(prompt[:MAX_EVAL_CHARS] + "\n" + " ".join(files), root, cfg=cfg,
237
+ allow_predict=False, **graph_kw) # one Haiku wait per prompt at most
237
238
  note = "uses the files from the previous task"
238
239
  inherit = None
239
240
  if d.task_class.confidence < FOLLOWUP_MAX_CONFIDENCE and pending.get("tier") \
@@ -134,10 +134,6 @@ def config_template(cfg) -> str:
134
134
  "prompts",
135
135
  " prompt_retention_days: 30 # drop stored prompts older than this (0 = forever)",
136
136
  " # rework_minutes: 15 success_gap_minutes: 120 (see the README)", "",
137
- "# Opt in: let the files a task touches (uncommitted edits, recent commits, named",
138
- "# paths and symbols) raise a real code change by one tier.",
139
- "code_first:",
140
- " enabled: false", "",
141
137
  "# Headless `ccr run`: success also requires this command to pass.",
142
138
  "run:",
143
139
  " test_command: null # e.g. \"pytest -q\" or \"npm test --silent\"",
@@ -91,6 +91,23 @@ def _check_hooks(hooks: object, where: str) -> dict:
91
91
  return hooks
92
92
 
93
93
 
94
+ def installed_prompt_timeout(root: Path) -> float | None:
95
+ """Claude Code's timeout (s) on ccr's UserPromptSubmit hook in the project settings, or
96
+ None when it is not found. Read on every prompt, so plain json and no validation."""
97
+ import json
98
+ for name in ("settings.local.json", "settings.json"):
99
+ try:
100
+ data = json.loads((Path(root) / ".claude" / name).read_text(encoding="utf-8"))
101
+ for g in data.get("hooks", {}).get("UserPromptSubmit", []):
102
+ for h in g.get("hooks", []):
103
+ if _is_our_hook(h) and "prompt" in str(h.get("command", "")):
104
+ t = h.get("timeout")
105
+ return float(t) if isinstance(t, (int, float)) else 60.0
106
+ except Exception:
107
+ continue
108
+ return None
109
+
110
+
94
111
  def _is_our_hook(h: object) -> bool:
95
112
  return isinstance(h, dict) and our_subcommand(str(h.get("command", ""))) == "hook"
96
113
 
@@ -139,11 +139,9 @@ def decide(task: str, root: str | Path = ".", *, cfg: Config | None = None,
139
139
  if memory is _AUTO:
140
140
  from ccr.memory import collect
141
141
  memory = collect(root, nested=nested_memory)
142
- workspace = None
143
- if cfg["code_first"]["enabled"]:
144
- from ccr.evaluate.workspace import snapshot
145
- workspace = snapshot(root, cfg["code_first"]["recent_commits"])
146
- notes += workspace.notes
142
+ from ccr.evaluate.workspace import snapshot
143
+ workspace = snapshot(root, cfg["code_first"]["recent_commits"])
144
+ notes += workspace.notes
147
145
  try:
148
146
  loc = locate(task, root, graph, memory, workspace=workspace)
149
147
  tc = classify(task, located=loc.located, hard_terms=cfg["hard_terms"])
@@ -179,7 +177,7 @@ def decide(task: str, root: str | Path = ".", *, cfg: Config | None = None,
179
177
  from ccr import history as H
180
178
  history_records = H.read(root, window_days=cfg["history"]["window_days"], now=now)
181
179
  d = _route(tc, loc, risk, budget, history_records, cfg, conf, workspace)
182
- if cfg["predict"]["enabled"] and allow_predict:
180
+ if allow_predict:
183
181
  why = _unsure(d, cfg)
184
182
  if why is None:
185
183
  d.predict = {"asked": False, "status": "not needed: routing is sure"}
@@ -630,11 +628,9 @@ def _route(tc: TaskClass, loc: Location, risk: Risk, budget: Budget, records: li
630
628
  _risk_note(kind, risk, ups, downs, reasons)
631
629
 
632
630
  keyword_tier = tier
633
- code = None
634
- if cfg["code_first"]["enabled"]:
635
- from ccr.route.code import code_tier
636
- code = code_tier(tc, loc, risk, cfg, workspace)
637
- tier = _code_raise(tier, code, ups, downs, reasons)
631
+ from ccr.route.code import code_tier
632
+ code = code_tier(tc, loc, risk, cfg, workspace)
633
+ tier = _code_raise(tier, code, ups, downs, reasons)
638
634
  predict_used = False
639
635
  if prediction is not None:
640
636
  code_rose = any(u.startswith(_CODE_UP + _CRITICAL_UP) for u in ups)
@@ -1,6 +1,6 @@
1
1
  """Code-first tier: a score of the code a task touches, which can raise a real code change
2
- by one tier above its keyword route (ccr/route/__init__.py `_code_raise`). Enabled with
3
- `code_first.enabled` (see docs/CODE_FIRST_ROUTING.md).
2
+ by one tier above its keyword route (ccr/route/__init__.py `_code_raise`). Always on since
3
+ 0.2.1 (see docs/CODE_FIRST_ROUTING.md).
4
4
 
5
5
  Score components, each in [0, 1] (noisy-or, so one strong factor is enough and several
6
6
  moderate ones add up):
@@ -1,7 +1,7 @@
1
1
  # Code-first routing
2
2
 
3
- Status: steps 1 and 3 prototyped behind `code_first.enabled`, step 2 behind `predict.enabled`
4
- (both off by default). Step 4 is designed here and comes next.
3
+ Status: steps 1, 2 and 3 are always on since 0.2.1 (they were opt in in 0.2.0). Step 4 is
4
+ designed here and comes next.
5
5
 
6
6
  ## Problem
7
7
 
@@ -54,7 +54,7 @@ More than 200 changed files (a mass rewrite or a generated tree) are ignored as
54
54
 
55
55
  ## Step 2: predict the change (built)
56
56
 
57
- `ccr/evaluate/predict.py`, opt in with `predict.enabled`. It asks Haiku through your own
57
+ `ccr/evaluate/predict.py`, always on. It asks Haiku through your own
58
58
  `claude` CLI (no API key), the same way `ccr explain --llm` does.
59
59
 
60
60
  **When it asks.** Only for real code changes (tests, bugfix, feature, refactor, perf,
@@ -208,15 +208,13 @@ The hook must stay well under the 1.5 s watchdog: one `git diff --numstat`, no g
208
208
  ## Configuration
209
209
 
210
210
  ```yaml
211
- code_first:
212
- enabled: false # opt in
211
+ code_first: # always on; an old `enabled` key is ignored with a warning
213
212
  recent_commits: 5 # files from the last N commits strengthen a match
214
213
  min_confidence: 0.5 # location confidence needed to route from the code
215
214
  bands: [0.2, 0.4, 0.6] # code score edges: T1 | T2 | T2H | T3
216
215
  tie_margin: 0.04 # near an edge, the keyword class breaks the tie
217
216
 
218
- predict: # step 2, needs your claude CLI
219
- enabled: false
217
+ predict: # step 2, always on; needs your claude CLI, else it is skipped
220
218
  model: haiku
221
219
  effort: low
222
220
  timeout_s: 10 # hard limit (max 13); a late answer leaves routing as it was
@@ -224,5 +222,11 @@ predict: # step 2, needs your claude CLI
224
222
  boundary: 0.08 # code score this close to a band edge counts as unsure
225
223
  ```
226
224
 
225
+ **Fallbacks.** No claude CLI, a timeout, a bad answer or no time left: routing keeps its
226
+ rule-based tier and the hook stays quiet (`ccr explain` shows a note). An install from before
227
+ 0.2.1 gives the prompt hook only 5 s in Claude Code, so the hook shrinks the prediction to fit
228
+ (3 s) and `ccr doctor` asks you to re-run `ccr init`, which sets 15 s. Test suites set
229
+ `CCR_NO_PREDICT=1` so they never reach the real CLI.
230
+
227
231
  `ccr explain "<task>"` shows the code score, its top components and whether it raised the
228
232
  tier, or why the keyword tier was kept.
@@ -16,9 +16,9 @@ ccr: T2 (sonnet/medium) — touches app/payments/ledger.py, 2 dependents, no tes
16
16
  critical path: payments. Delegate implementation to ccr-implement; use Explore (haiku) for search.
17
17
  ```
18
18
 
19
- Everything that decides a tier is rule-based, token-free and local. The only model call ccr
20
- makes on its own is an optional, opt-in classification by haiku through your own `claude`
21
- CLI.
19
+ The rules, the code graph and your working tree decide most tiers, locally and token-free.
20
+ When they are unsure, the prompt hook also asks haiku, through your own `claude` CLI, to
21
+ predict the change (up to 10 s, cached). Without the CLI, routing stays rule-based.
22
22
 
23
23
  ---
24
24
 
@@ -169,12 +169,12 @@ Prompt length is not a signal. The code the task touches is.
169
169
 
170
170
  `ccr explain "<task>"` shows each step with its reasons and scores. It runs nothing.
171
171
 
172
- **Code-first routing (opt in).** With `code_first.enabled: true`, your uncommitted edits
172
+ **Code-first routing (always on).** Your uncommitted edits
173
173
  and recent commits also help find the files, and a score of that code (files, lines already
174
174
  changed, dependents, complexity, tests, churn, critical paths, memory flags) can raise a real
175
175
  code change by one tier above the steps above. It never lowers a tier, never moves trivial
176
- edits or questions, and steps or small-scope words still win. With `predict.enabled: true`,
177
- prompts where routing is unsure also ask Haiku (your claude CLI, up to 10 s) to predict the
176
+ edits or questions, and steps or small-scope words still win. Prompts where routing is unsure
177
+ also ask Haiku (your claude CLI, up to 10 s) to predict the
178
178
  change; a small change lowers the tier by one and a large one raises it by one, never past a
179
179
  T4 rule or below a critical path. See [Code-first routing](CODE_FIRST_ROUTING.md).
180
180
 
@@ -262,15 +262,13 @@ routing:
262
262
  max_escalation: 2 # tiers above the class base without a T4 rule
263
263
  ceiling_without_critical: T3
264
264
 
265
- code_first: # opt in: the code can raise a change, see docs/CODE_FIRST_ROUTING.md
266
- enabled: false
265
+ code_first: # always on: the code can raise a change, see docs/CODE_FIRST_ROUTING.md
267
266
  recent_commits: 5 # files from the last N commits strengthen a match
268
267
  min_confidence: 0.5 # location confidence needed to route from the code
269
268
  bands: [0.2, 0.4, 0.6] # code score edges: T1 | T2 | T2H | T3
270
269
  tie_margin: 0.04 # near an edge, the keyword class breaks the tie
271
270
 
272
- predict: # opt in: Haiku predicts the change when routing is unsure
273
- enabled: false
271
+ predict: # always on: Haiku predicts the change when routing is unsure
274
272
  model: haiku
275
273
  effort: low
276
274
  timeout_s: 10 # hard limit (max 13); a late answer leaves routing as it was
@@ -566,8 +564,11 @@ a failure and routes one tier higher. Use `ccr feedback` when that inference is
566
564
  - the opt-in LLM classification: `ccr explain --llm`, and `ccr run` unless you pass
567
565
  `--no-llm`. It runs haiku/low with no tools, no MCP and no session, and is only asked
568
566
  when rule confidence is below `llm.threshold`;
567
+ - the change prediction in the prompt hook: haiku/low with no tools and no MCP, only when
568
+ routing is unsure. It sends the prompt, the located file paths with their symbol names
569
+ and line spans (no source) and the uncommitted diff stat. Answers are cached in
570
+ `.ccr/local/predict-cache.json` without the prompt text;
569
571
  - the `ccr run` task itself.
570
- Hooks never call a model.
571
572
  - Grammar downloads (tree-sitter-language-pack) are the only network access ccr itself
572
573
  makes.
573
574
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "claude-code-router"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "Route Claude Code tasks to the cheapest sufficient model and effort"
5
5
  requires-python = ">=3.10"
6
6
  license = "MIT"
@@ -27,6 +27,22 @@ def git_commit_all(root: Path) -> None:
27
27
  env=env)
28
28
 
29
29
 
30
+ @pytest.fixture(autouse=True)
31
+ def _no_real_haiku(monkeypatch):
32
+ """The change prediction is always on; tests never reach the real claude CLI. Tests that
33
+ pass their own `predict_runner` still exercise the predictor."""
34
+ from ccr.evaluate import predict as P
35
+ real = P.predict
36
+ monkeypatch.setenv("CCR_NO_PREDICT", "1") # hook subprocesses too
37
+
38
+ def guarded(*args, runner=None, **kw):
39
+ if runner is None:
40
+ return None, "unavailable: claude CLI not used in tests"
41
+ return real(*args, runner=runner, **kw)
42
+ guarded.__wrapped__ = real
43
+ monkeypatch.setattr(P, "predict", guarded)
44
+
45
+
30
46
  @pytest.fixture(scope="session")
31
47
  def route_env(tmp_path_factory):
32
48
  """{name: (root, MemoryReport)} for the routing fixture repos: git history + graph built,
@@ -153,7 +153,7 @@ def _route(route_env, repo, task, budget):
153
153
  ("svc_go", "Add a /healthz endpoint to the router in internal/http/router.go", "T2", "T1"),
154
154
  ("shop_py", "Refactor Engine.run into smaller functions without changing behaviour", "T2H",
155
155
  "T2"),
156
- ("web_ts", "Fix the bug where formatPrice shows NaN for zero amounts", "T1", "T0"),
156
+ ("web_ts", "Fix the bug where formatPrice shows NaN for zero amounts", "T2", "T1"),
157
157
  ("shop_py", "What does Engine.run do?", "T0", "T0"), # floor
158
158
  ("shop_py", "Fix the JWT signature verification vulnerability in app/auth/tokens.py",
159
159
  "T4", "T4"), # never T4