Skip to content

feat: add --translate option to lint command#35

Merged
abechan1 merged 2 commits into
mainfrom
translate
Jun 30, 2026
Merged

feat: add --translate option to lint command#35
abechan1 merged 2 commits into
mainfrom
translate

Conversation

@abechan1

@abechan1 abechan1 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Allow users to specify a target language (e.g. --translate Japanese)
so the LLM writes each finding's message in the requested language.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • 新機能

    • slidict lint に翻訳オプションを追加し、結果を指定言語で表示できるようになりました。
    • ヘルプに --translate の説明が追加されました。
  • 改善

    • 解析時に翻訳指定を正しく引き継ぐようになり、入力内容に応じて出力を切り替えられます。
    • 翻訳指定がない場合は、従来どおり通常の出力を維持します。

abechan1 and others added 2 commits June 29, 2026 21:35
Allow users to specify a target language (e.g. --translate Japanese)
so the LLM writes each finding's message in the requested language.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@abechan1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2eeb09b0-7dad-4976-95c4-3403838f8a51

📥 Commits

Reviewing files that changed from the base of the PR and between 1c60587 and 63e58e6.

📒 Files selected for processing (1)
  • lib/slidict/version.rb
📝 Walkthrough

Walkthrough

slidict lint コマンドに --translate LANG オプションを追加。CLI のオプション解析から Linter#lintLlm::Client#lint_slideslint_prompt_for まで translate パラメータを伝播させ、指定時は LLM プロンプト末尾に出力言語指示を付与する。関連するテストも更新・追加された。

Changes

--translate オプションの追加

Layer / File(s) Summary
LLM クライアントへの translate 伝播とプロンプト生成
lib/slidict/llm/client.rb, spec/slidict/llm/client_spec.rb
lint_slideslint_prompt_fortranslate: nil キーワード引数を追加。translate 指定時はプロンプト末尾に出力言語指示文を付与。テストでは translate: "Japanese" 時に言語名がプロンプトに含まれること、nil 時に指示文が含まれないことを検証。
Linter と CLI への translate 伝播
lib/slidict/lint/linter.rb, lib/slidict/cli/lint.rb, spec/slidict/lint/linter_spec.rb, spec/slidict/cli/lint_spec.rb
Linter#linttranslate: nil を追加して lint_slides へ渡す。CLI の parse_options!--translate LANG を受け付け、ヘルプ行も追加。lint 呼び出し時に translate: options[:translate] を渡すよう変更。CLI・Linter テストともに translate: キーワード引数の期待値を更新。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 ぴょんと跳ねて --translate を追加したよ
プロンプトの末尾に言語の旗を立てて
Japanese、English、どこへでも届け
LLM がうさぎ語も翻訳するかも?
lint の結果が世界中へ広がれ 🌍

🚥 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 lint コマンドに --translate オプションを追加する変更内容を的確に要約しており、タイトルとして適切です。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch translate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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: 1

🤖 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 `@lib/slidict/llm/client.rb`:
- Around line 96-99: The translate instruction in lint_prompt_for allows the
model to localize fields beyond message, which can alter severity values and
other fixed keys. Update lint_prompt_for so the translate guidance explicitly
limits translation to message only, while keeping slide, severity, and all field
names unchanged; refer to lint_prompt_for and normalize_severity when making the
prompt wording safer.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 00bb220c-fe49-459a-8fe5-513bbdef9055

📥 Commits

Reviewing files that changed from the base of the PR and between c158b6c and 1c60587.

📒 Files selected for processing (6)
  • lib/slidict/cli/lint.rb
  • lib/slidict/lint/linter.rb
  • lib/slidict/llm/client.rb
  • spec/slidict/cli/lint_spec.rb
  • spec/slidict/lint/linter_spec.rb
  • spec/slidict/llm/client_spec.rb

Comment thread lib/slidict/llm/client.rb
Comment on lines +96 to +99
def lint_prompt_for(slide_texts, translate: nil)
numbered = slide_texts.each_with_index.map { |text, i| "--- Slide #{i + 1} ---\n#{text}" }.join("\n\n")
format(LINT_PROMPT_TEMPLATE, numbered: numbered)
prompt = format(LINT_PROMPT_TEMPLATE, numbered: numbered)
translate ? "#{prompt}\nWrite each message field in #{translate}." : prompt

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

severity の契約まで翻訳される余地があります。

Line 99 の指示だと、モデルが message 以外の文字列値までローカライズする余地が残ります。ここで "warning" / "info" が翻訳されると、normalize_severity 側で未知の値がすべて "info" に丸められ、警告が静かに弱まります。message だけを翻訳し、キー・slideseverity は固定のままにする文面へ寄せたほうが安全です。

修正案
       def lint_prompt_for(slide_texts, translate: nil)
         numbered = slide_texts.each_with_index.map { |text, i| "--- Slide #{i + 1} ---\n#{text}" }.join("\n\n")
         prompt = format(LINT_PROMPT_TEMPLATE, numbered: numbered)
-        translate ? "#{prompt}\nWrite each message field in #{translate}." : prompt
+        return prompt unless translate
+
+        [
+          prompt,
+          %(Translate only the value of each "message" field into #{translate}.),
+          %(Keep the JSON keys, slide numbers, and severity values exactly as specified above.)
+        ].join("\n")
       end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def lint_prompt_for(slide_texts, translate: nil)
numbered = slide_texts.each_with_index.map { |text, i| "--- Slide #{i + 1} ---\n#{text}" }.join("\n\n")
format(LINT_PROMPT_TEMPLATE, numbered: numbered)
prompt = format(LINT_PROMPT_TEMPLATE, numbered: numbered)
translate ? "#{prompt}\nWrite each message field in #{translate}." : prompt
def lint_prompt_for(slide_texts, translate: nil)
numbered = slide_texts.each_with_index.map { |text, i| "--- Slide #{i + 1} ---\n#{text}" }.join("\n\n")
prompt = format(LINT_PROMPT_TEMPLATE, numbered: numbered)
return prompt unless translate
[
prompt,
%(Translate only the value of each "message" field into #{translate}.),
%(Keep the JSON keys, slide numbers, and severity values exactly as specified above.)
].join("\n")
end
🤖 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 `@lib/slidict/llm/client.rb` around lines 96 - 99, The translate instruction in
lint_prompt_for allows the model to localize fields beyond message, which can
alter severity values and other fixed keys. Update lint_prompt_for so the
translate guidance explicitly limits translation to message only, while keeping
slide, severity, and all field names unchanged; refer to lint_prompt_for and
normalize_severity when making the prompt wording safer.

@abechan1 abechan1 merged commit 60e1bc7 into main Jun 30, 2026
5 checks passed
@abechan1 abechan1 deleted the translate branch June 30, 2026 00:56
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