fix(cli): per-language commands, honest scorecard tiers, tests-aware detection#20
Conversation
…detection
Post-v5 follow-ups so generated commands, the scorecard, and language
auto-detection are correct and consistent on multi-language repos.
Per-language commands (docs are `docs <lang> <subject>`, not `--doc`):
- thread the resolved language through the AI fix-prompt (`compose_prompt`),
the `check` cycle/metric `fix`, the scorecard next-step hint, the `docs`
index hints, and the HTML viewer's Prompt Generator — every emitted
`code-ranker docs …` / `report --prompt …` now names the language.
- `resolve_language_snap` returns the resolved language key (was snapshot only).
- `docs <lang> <subject>` localizes `<lang>` placeholders in served docs to the
concrete language (`docs rust hk`, `--plugins rust`); `base` keeps the generic
placeholder. Compact one-line `docs <lang> ai` catalog.
- templates carry a `{lang}` placeholder (prompt.md, builtin.toml remediation).
Scorecard `--focus <metric>` tiers are now honest: each ranked module shows its
own tier for that metric (`warn`/`info`/`—`) instead of a blanket `warn`; the
header/next-step hint name the resolved language, not the first plugin.
Auto-detect honors `[ignore] tests`: marker-less, extension-detected plugins
(c/cpp/csharp/markdown) walk with the same tests/gitignore filters analysis uses,
so a project whose only such files are test fixtures is no longer detected then
warned about as empty.
Docs synced (CLI.md, DESIGN.md, templates.md, ai-skill.md, USE-CASES.md,
customization/README.md, plugins/base/{AI,HK}.md, contrib) + sample goldens.
No format/CLI-surface contract changed, so no version bump.
Claude-Session: https://claude.ai/code/session_01Jcdvq3iTsqk74KfrXxZzcP
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThreads a resolved language key through docs rendering, prompt composition, scorecard output, remediation strings, fixtures, tests, and documentation so ChangesLanguage parameter threading
ignore_tests propagation into plugin detection
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20 +/- ##
=======================================
Coverage 98.36% 98.37%
=======================================
Files 128 128
Lines 16034 16079 +45
=======================================
+ Hits 15772 15817 +45
Misses 262 262 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
code-ranker View diff report ↗rust: ok
baseline main @f79d519 2026-06-28 17:14 UTC · updated 2026-06-28 21:43 UTC |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
crates/code-ranker-cli/src/recommend_test.rs (1)
944-945: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep asserting the canonical language key here.
resolve_language_snapnow returns the resolved key that prompt/docs output uses. Dropping it from this alias test means a regression from canonicalpythonback to rawpywould still pass here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/code-ranker-cli/src/recommend_test.rs` around lines 944 - 945, The alias test in resolve_language_snap is only checking the returned snap and currently drops the resolved language key, which could miss a regression back to raw py. Update the assertion in recommend_test.rs to keep validating the canonical resolved key from resolve_language_snap for the py alias, alongside the existing SRP principle check, so the test fails if the returned key is not python.crates/code-ranker-cli/src/docs_test.rs (1)
57-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the rendered
docs <lang>command text, not just pass the arg.These tests now call the lang-aware helpers, but they never verify the language-scoped header each function renders. A regression that drops
{lang}from the command hint would still pass.Also applies to: 123-123, 133-141
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/code-ranker-cli/src/docs_test.rs` at line 57, The docs tests using render_category, render_name, and render_spec should assert the full rendered docs command text including the language-scoped header, not just pass "rust" as an argument. Update the affected assertions to verify the output contains the expected "docs <lang>" hint from the lang-aware helpers, so a regression that drops the language placeholder would fail. Use the existing render_category and related test cases in docs_test.rs to locate the checks that need strengthening.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@contrib/prompting-self-improve.md`:
- Around line 154-159: Update the run example in the self-improve prompt so it
stays language-scoped: the “BEFORE” step currently uses bare code-ranker report
., which can rely on auto-detection and pick the wrong prompt/artifacts in
multi-language repos. Change the example to use the same language selector as
the surrounding flow, referencing the code-ranker report invocation in the run
steps and keeping it aligned with the earlier code-ranker docs <lang> ai / docs
<lang> <FOCUS> commands.
In `@crates/code-ranker-cli/src/docs.rs`:
- Around line 415-441: The new docs headers in render_metrics_index,
render_principles_index, and render_category are formatting lang directly, which
bypasses the placeholder-preserving behavior expected for the base locale.
Update these helpers to use the same localized language value that
localize_lang() provides for base so the rendered commands keep `<lang>` generic
in the base docs flow, while still showing the real language for non-base
locales.
---
Nitpick comments:
In `@crates/code-ranker-cli/src/docs_test.rs`:
- Line 57: The docs tests using render_category, render_name, and render_spec
should assert the full rendered docs command text including the language-scoped
header, not just pass "rust" as an argument. Update the affected assertions to
verify the output contains the expected "docs <lang>" hint from the lang-aware
helpers, so a regression that drops the language placeholder would fail. Use the
existing render_category and related test cases in docs_test.rs to locate the
checks that need strengthening.
In `@crates/code-ranker-cli/src/recommend_test.rs`:
- Around line 944-945: The alias test in resolve_language_snap is only checking
the returned snap and currently drops the resolved language key, which could
miss a regression back to raw py. Update the assertion in recommend_test.rs to
keep validating the canonical resolved key from resolve_language_snap for the py
alias, alongside the existing SRP principle check, so the test fails if the
returned key is not python.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e4ec7ea4-02ef-4db4-aaf5-9fbd7058eece
📒 Files selected for processing (37)
contrib/prompting-self-improve.mdcrates/code-ranker-cli/src/config/rules.rscrates/code-ranker-cli/src/docs.rscrates/code-ranker-cli/src/docs_test.rscrates/code-ranker-cli/src/recommend.rscrates/code-ranker-cli/src/recommend/prompt.rscrates/code-ranker-cli/src/recommend/scorecard.rscrates/code-ranker-cli/src/recommend_test.rscrates/code-ranker-cli/src/report.rscrates/code-ranker-cli/src/templates.rscrates/code-ranker-cli/src/templates_test.rscrates/code-ranker-graph/metrics/builtin.tomlcrates/code-ranker-graph/metrics/prompt.mdcrates/code-ranker-graph/src/builtin_test.rscrates/code-ranker-plugins/src/languages/c/mod.rscrates/code-ranker-plugins/src/languages/c/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/cfamily/mod.rscrates/code-ranker-plugins/src/languages/cpp/mod.rscrates/code-ranker-plugins/src/languages/cpp/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/csharp/mod.rscrates/code-ranker-plugins/src/languages/csharp/structure.rscrates/code-ranker-plugins/src/languages/csharp/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/go/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/js/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/md/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/python/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/rust/tests/sample/code-ranker-report.jsoncrates/code-ranker-plugins/src/languages/ts/tests/sample/code-ranker-report.jsoncrates/code-ranker-viewer/src/assets/export-popup.jsdocs/DESIGN.mddocs/ai-skill.mddocs/code-ranker-cli/CLI.mddocs/code-ranker-cli/USE-CASES.mddocs/customization/README.mddocs/templates.mdplugins/base/AI.mdplugins/base/HK.md
… hints generic - contrib: the BEFORE-snapshot step pinned `--plugins <lang>` (was bare `report .`, could auto-detect the wrong language on a multi-language repo). - docs index hints (`docs <lang> metrics/principles/<category>`) print a concrete language for a real plugin but keep the generic `<lang>` for `base`, matching `localize_lang` (via a small `command_lang` helper). Claude-Session: https://claude.ai/code/session_01Jcdvq3iTsqk74KfrXxZzcP
… of command_lang The CodeRabbit fix added a `command_lang` helper (+6 SLOC) that pushed docs.rs to 403 > the repo's own 400 sloc gate, failing the dogfood self-check in CI. Drop the helper: index hints now carry the literal `<lang>` token and are localized once at emit time via `localize_lang` (concrete language for a real plugin, generic for `base`) — same behavior, one substitution point, back under the gate. Claude-Session: https://claude.ai/code/session_01Jcdvq3iTsqk74KfrXxZzcP
Post-v5 follow-ups so generated commands, the scorecard, and language
auto-detection are correct and consistent on multi-language repos. No
format/CLI-surface contract changed → no version bump.
Per-language commands
Docs are
docs <lang> <subject>now (the old--docflag is gone), but severalgenerated/runnable commands still omitted the language — broken on multi-language
repos. Fixed across the board:
compose_prompt), thecheckcycle/metricfix, the scorecardnext-step hint, the
docsindex hints, and the HTML viewer's Prompt Generatornow all name the resolved language (
code-ranker docs rust hk,report --plugins rust --prompt hk).resolve_language_snapreturns the resolved language key (was snapshot only).docs <lang> <subject>localizes<lang>placeholders in served docs to theconcrete language (
docs rust hk,--plugins rust);basekeeps the genericplaceholder. Compact one-line
docs <lang> aicatalog.{lang}placeholder (prompt.md,builtin.tomlremediation).ai-skill.md,USE-CASES.md,CLI.md,templates.md,customization/README.md,plugins/base/{AI,HK}.md,contrib); fixed stale--plugin/plugin = "…"in the AI playbook.Honest scorecard tiers
report --output.scorecard --focus <metric>tagged every ranked modulewarnregardless of threshold. Now each row shows its own tier for that metric
(
warn> warning,info> info,—under both / no threshold). Also the headerand next-step hint name the resolved language, not the alphabetically-first plugin.
Tests-aware auto-detection
Marker-less, extension-detected plugins (
c/cpp/csharp/markdown) now walkwith the same
[ignore] tests/ gitignore filters analysis uses. A repo whose onlysuch files are test fixtures is no longer auto-detected and then warned about as
"produced no nodes".
Validation
make all: PASS (build, test, clippy, lychee + markdownlint, self-check,coverage 96.97% ≥ 90%)
make e2e: PASS (62/62)scorecard_focus_metric_tags_each_module_by_its_actual_tier,localize_lang_substitutes_concrete_language_but_not_base, plus updatedrecommend/docs/templates/builtin tests and the 9 sample goldens.
https://claude.ai/code/session_01Jcdvq3iTsqk74KfrXxZzcP
Summary by CodeRabbit
New Features
code-ranker docs <lang> <subject>/code-ranker docs <lang> ai.Bug Fixes
Documentation
--plugins <lang>command shapes.