Skip to content

fix(cli): per-language commands, honest scorecard tiers, tests-aware detection#20

Merged
ffedoroff merged 3 commits into
mainfrom
fix/per-language-commands-and-scorecard
Jun 28, 2026
Merged

fix(cli): per-language commands, honest scorecard tiers, tests-aware detection#20
ffedoroff merged 3 commits into
mainfrom
fix/per-language-commands-and-scorecard

Conversation

@ffedoroff

@ffedoroff ffedoroff commented Jun 28, 2026

Copy link
Copy Markdown
Owner

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 --doc flag is gone), but several
generated/runnable commands still omitted the language — broken on multi-language
repos. Fixed across the board:

  • 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
    now all name the resolved language (code-ranker docs rust hk,
    report --plugins rust --prompt hk).
  • 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).
  • Doc examples pinned (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 module warn
regardless of threshold. Now each row shows its own tier for that metric
(warn > warning, info > info, under both / no threshold). Also the header
and 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 walk
with the same [ignore] tests / gitignore filters analysis uses. A repo whose only
such 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)
  • New tests: scorecard_focus_metric_tags_each_module_by_its_actual_tier,
    localize_lang_substitutes_concrete_language_but_not_base, plus updated
    recommend/docs/templates/builtin tests and the 9 sample goldens.

https://claude.ai/code/session_01Jcdvq3iTsqk74KfrXxZzcP

Summary by CodeRabbit

  • New Features

    • Language-aware offline docs and remediation guidance are now generated consistently using code-ranker docs <lang> <subject> / code-ranker docs <lang> ai.
    • Scorecards and AI fix-prompts are better aligned to the selected language, with language-pinned next-step hints.
  • Bug Fixes

    • Per-language prompt/doc placeholders are now properly resolved, and scorecard tiering reflects the focused metric’s thresholds (not blanket warnings).
    • Detection now more reliably honors test-skipping settings.
  • Documentation

    • Updated CLI and playbook examples to reflect the language-first docs workflow and --plugins <lang> command shapes.

…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
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 711db63c-b8d7-4539-ae6b-31e0bcee3f88

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb520c and 90be37c.

📒 Files selected for processing (2)
  • crates/code-ranker-cli/src/docs.rs
  • crates/code-ranker-cli/src/docs_test.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/code-ranker-cli/src/docs_test.rs

📝 Walkthrough

Walkthrough

Threads a resolved language key through docs rendering, prompt composition, scorecard output, remediation strings, fixtures, tests, and documentation so code-ranker docs references include <lang>. Also forwards ignore_tests into C, C++, and C# plugin detection so auto-detection matches analysis filtering.

Changes

Language parameter threading

Layer / File(s) Summary
Language resolution, prompt fill, and scorecard tiering
crates/code-ranker-cli/src/recommend.rs, crates/code-ranker-cli/src/recommend/prompt.rs, crates/code-ranker-cli/src/recommend/scorecard.rs, crates/code-ranker-cli/src/report.rs
resolve_language_snap now returns the language key with the snapshot; compose_prompt accepts lang and fills {id} and {lang}; report wiring passes the resolved language through prompt and scorecard rendering; scorecard rows use Tier values and language-pinned hint text.
Catalog expansion and AI doc rendering
crates/code-ranker-cli/src/templates.rs
Template expansion no longer extracts doc summaries; catalog entries become single-line language-scoped pointers, and AI doc rendering and tldr expansion now take a language parameter.
Docs rendering helpers and localized index text
crates/code-ranker-cli/src/docs.rs, crates/code-ranker-cli/src/docs_test.rs
docs rendering now localizes <lang> placeholders, routes subject output through language-aware helpers, and updates index/category tests for explicit language values.
Report wiring, remediation strings, and viewer prompts
crates/code-ranker-cli/src/config/rules.rs, crates/code-ranker-viewer/src/assets/export-popup.js
Remediation text and the viewer prompt composer now substitute {lang} and updated command wording.
Fixture snapshots and prompt templates
crates/code-ranker-graph/metrics/prompt.md, crates/code-ranker-graph/metrics/builtin.toml, crates/code-ranker-plugins/src/languages/*/tests/sample/code-ranker-report.json
Metric prompt text and all per-language report fixtures update docs commands and doc notes to include {lang}.
Tests and documentation updates
crates/code-ranker-cli/src/recommend_test.rs, crates/code-ranker-cli/src/templates_test.rs, crates/code-ranker-graph/src/builtin_test.rs, docs/*, plugins/base/*, contrib/prompting-self-improve.md
Tests are updated for the new signatures and placeholder behavior, and the CLI docs, playbooks, and reference docs now show language-qualified commands and plugin-selection examples.

ignore_tests propagation into plugin detection

Layer / File(s) Summary
Detection signatures and caller propagation
crates/code-ranker-plugins/src/languages/cfamily/mod.rs, crates/code-ranker-plugins/src/languages/csharp/structure.rs, crates/code-ranker-plugins/src/languages/c/mod.rs, crates/code-ranker-plugins/src/languages/cpp/mod.rs, crates/code-ranker-plugins/src/languages/csharp/mod.rs
cfamily::detect and csharp::structure::detect now accept ignore_tests, forward it to file collection, and the C, C++, and C# plugin detect paths pass input.ignore_tests.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through docs with <lang> in sight,
and every prompt now points just right.
Tier labels gleam: warn, info, below,
while test-ignoring detectors help the right plugins grow.
A tidy trail of words and code —
this bunny’s ears approve the road.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: per-language command generation, truthful scorecard tiers, and test-aware detection.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/per-language-commands-and-scorecard

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.37%. Comparing base (f79d519) to head (90be37c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

code-ranker View diff report ↗

rust: ok
Metric Baseline Current Δ
Complexity
cognitive — Cognitive complexity 21 20.9 $\color{#2a7a30}{-0.087}$
cyclomatic — Cyclomatic complexity 33.7 33.7 $\color{#c0392b}{+0.009}$
Coupling
hk — God-object risk 31.4K 31.5K $\color{#c0392b}{+45.6}$
Halstead
bugs — Estimated bugs 0.898 0.899 $\color{#c0392b}{+0.001}$
effort — Implementation effort 178.1K 178.6K $\color{#c0392b}{+513}$
length — Total tokens 627 628 $\color{#c0392b}{+0.941}$
time — Coding time (s) 9894 9922 $\color{#c0392b}{+28.5}$
volume — Code volume 4372 4379 $\color{#c0392b}{+7.4}$
Lines of Code
blank — Blank lines 13.3 13.3 +0.026
cloc — Comment lines 34 34.3 +0.271
sloc — Source lines 125 125 +0.26
Maintainability
mi — Maintainability index 45.9 46.3 $\color{#2a7a30}{+0.38}$
mi_sei — Maintainability (SEI) 42.7 42.7 $\color{#c0392b}{-0.057}$

baseline main @f79d519 2026-06-28 17:14 UTC · updated 2026-06-28 21:43 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
crates/code-ranker-cli/src/recommend_test.rs (1)

944-945: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep asserting the canonical language key here.

resolve_language_snap now returns the resolved key that prompt/docs output uses. Dropping it from this alias test means a regression from canonical python back to raw py would 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 win

Assert 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

📥 Commits

Reviewing files that changed from the base of the PR and between f79d519 and 9be67d3.

📒 Files selected for processing (37)
  • contrib/prompting-self-improve.md
  • crates/code-ranker-cli/src/config/rules.rs
  • crates/code-ranker-cli/src/docs.rs
  • crates/code-ranker-cli/src/docs_test.rs
  • crates/code-ranker-cli/src/recommend.rs
  • crates/code-ranker-cli/src/recommend/prompt.rs
  • crates/code-ranker-cli/src/recommend/scorecard.rs
  • crates/code-ranker-cli/src/recommend_test.rs
  • crates/code-ranker-cli/src/report.rs
  • crates/code-ranker-cli/src/templates.rs
  • crates/code-ranker-cli/src/templates_test.rs
  • crates/code-ranker-graph/metrics/builtin.toml
  • crates/code-ranker-graph/metrics/prompt.md
  • crates/code-ranker-graph/src/builtin_test.rs
  • crates/code-ranker-plugins/src/languages/c/mod.rs
  • crates/code-ranker-plugins/src/languages/c/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/cfamily/mod.rs
  • crates/code-ranker-plugins/src/languages/cpp/mod.rs
  • crates/code-ranker-plugins/src/languages/cpp/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/csharp/mod.rs
  • crates/code-ranker-plugins/src/languages/csharp/structure.rs
  • crates/code-ranker-plugins/src/languages/csharp/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/go/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/js/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/md/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/python/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/rust/tests/sample/code-ranker-report.json
  • crates/code-ranker-plugins/src/languages/ts/tests/sample/code-ranker-report.json
  • crates/code-ranker-viewer/src/assets/export-popup.js
  • docs/DESIGN.md
  • docs/ai-skill.md
  • docs/code-ranker-cli/CLI.md
  • docs/code-ranker-cli/USE-CASES.md
  • docs/customization/README.md
  • docs/templates.md
  • plugins/base/AI.md
  • plugins/base/HK.md

Comment thread contrib/prompting-self-improve.md
Comment thread crates/code-ranker-cli/src/docs.rs Outdated
… 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
@ffedoroff ffedoroff merged commit 829365e into main Jun 28, 2026
14 checks passed
@ffedoroff ffedoroff deleted the fix/per-language-commands-and-scorecard branch June 28, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant