Skip to content

fix(cli-pr-monitor): --body 複数行引数の再結合 - #51

Merged
aloekun merged 1 commit into
masterfrom
fix/pr-monitor-body-reassemble
Apr 17, 2026
Merged

fix(cli-pr-monitor): --body 複数行引数の再結合#51
aloekun merged 1 commit into
masterfrom
fix/pr-monitor-body-reassemble

Conversation

@aloekun

@aloekun aloekun commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Windows の pnpm/cmd.exe 経由で --body の複数行テキストが分割される問題を修正
  • reassemble_split_body 前処理を追加: --body の次引数から次の --long-flag までを改行で結合し、単一の body 引数に再構成
  • 再構成後の body は既存の convert_body_to_file--body-file に自動変換される

Test plan

  • reassemble_split_body: 6 tests (分割再結合、末尾body、ショートフラグ混在、is_long_flag)
  • 既存 convert_body_to_file/ensure_head_arg テスト: 全 pass
  • cli-pr-monitor 全体: 65 tests pass (1 ignored)
  • takt pre-push-review: APPROVE (3 iterations)

Summary by CodeRabbit

バグ修正

  • Windowsプラットフォーム上でコマンドラインツール使用時に、複数行のPRボディ説明文が正しく処理されない問題を修正しました
  • 複数行テキストの分割と再統合の処理を改善し、安定性を向上させました
  • テストスイートを拡張し、各種シナリオに対応するテストケースを新たに追加しました

@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@aloekun has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 45 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 45 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3840daf-1623-4ce9-95eb-68f973523f4b

📥 Commits

Reviewing files that changed from the base of the PR and between 82d4305 and aac8a67.

📒 Files selected for processing (1)
  • src/cli-pr-monitor/src/stages/create_pr.rs
📝 Walkthrough

Walkthrough

Windows環境でのpnpm/cmd.exeによる複数行の--bodyテキスト分割に対応するため、引数の前処理ロジックを追加しました。is_long_flagreassemble_split_bodyヘルパー関数を導入し、分割された--bodyフラグメントを検出して再結合します。

Changes

Cohort / File(s) Summary
引数前処理とテスト拡張
src/cli-pr-monitor/src/stages/create_pr.rs
Windows環境での--body引数分割に対応するreassemble_split_bodyis_long_flagヘルパー関数を追加。run_create_prを更新して再結合された引数リストをconvert_body_to_fileに渡すよう修正。複数行テキストの結合、端末値処理、短フラグの扱いなどをカバーする単体テストを追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは Windows の pnpm/cmd.exe で分割される --body の複数行テキストを再結合する処理の追加という主な変更を正確に反映しており、明確で具体的です。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@aloekun
aloekun force-pushed the fix/pr-monitor-body-reassemble branch from 2902515 to 82d4305 Compare April 17, 2026 19:53

@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

🧹 Nitpick comments (1)
src/cli-pr-monitor/src/stages/create_pr.rs (1)

25-35: --body 直後が long フラグの場合の扱いを確認してください。

現状 args[i] == "--body" && i + 1 < args.len() だけで分岐に入り、args[i+1]--title など別の long フラグであっても無条件に body の最初のフラグメントとして取り込みます。結果として --body --title "x" のような (通常は想定されない) 入力で --title が body 内容として消費され、--title の値 "x" だけが argv に残ります。

実運用で発生しにくい入力ではありますが、後段 (convert_body_to_file) の条件 (args[i+1] が存在すれば即採用) と同じ緩さを引き継いでいる点は明示テスト or ガードどちらかで担保しておくと安全です。

-        if args[i] == "--body" && i + 1 < args.len() {
+        if args[i] == "--body" && i + 1 < args.len() && !is_long_flag(&args[i + 1]) {
             result.push(args[i].clone());
             let mut body_parts = vec![args[i + 1].clone()];
             i += 2;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/cli-pr-monitor/src/stages/create_pr.rs` around lines 25 - 35, The
body-parsing branch currently treats args[i+1] as body even if it's a long flag,
so change the condition to only enter the "--body" branch when i + 1 <
args.len() AND !is_long_flag(&args[i + 1]); inside the branch push the "--body"
flag then collect body_parts starting from args[i+1] as before, advancing i; if
the next token is a long flag, skip entering the branch (so "--body --title"
leaves "--body" and "--title" intact) and ensure convert_body_to_file (and any
callers) still handle the absence of a body token correctly. Reference symbols:
args, is_long_flag, result, body_parts, convert_body_to_file, and the "--body"
parsing block in create_pr.rs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cli-pr-monitor/src/stages/create_pr.rs`:
- Around line 16-41: The current is_long_flag treats any "--" prefix as a flag
(so lines like "---" or "--=foo" in markdown break reassemble_split_body);
change is_long_flag to require that after the leading "--" the next character
exists and is an ASCII alphabetic character (e.g. arg.starts_with("--") &&
arg.as_bytes().get(2).map_or(false, |b| b.is_ascii_alphabetic())), so
reassemble_split_body will not stop on markdown `---` or similar; update
is_long_flag (and any callers) accordingly and add tests like
reassemble_split_body_preserves_markdown_hr and is_long_flag_rejects_triple_dash
to cover the regression.

---

Nitpick comments:
In `@src/cli-pr-monitor/src/stages/create_pr.rs`:
- Around line 25-35: The body-parsing branch currently treats args[i+1] as body
even if it's a long flag, so change the condition to only enter the "--body"
branch when i + 1 < args.len() AND !is_long_flag(&args[i + 1]); inside the
branch push the "--body" flag then collect body_parts starting from args[i+1] as
before, advancing i; if the next token is a long flag, skip entering the branch
(so "--body --title" leaves "--body" and "--title" intact) and ensure
convert_body_to_file (and any callers) still handle the absence of a body token
correctly. Reference symbols: args, is_long_flag, result, body_parts,
convert_body_to_file, and the "--body" parsing block in create_pr.rs.
🪄 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: 51a6cdd6-0cf9-4c34-9aea-684b722535d3

📥 Commits

Reviewing files that changed from the base of the PR and between 34bf54f and 82d4305.

📒 Files selected for processing (1)
  • src/cli-pr-monitor/src/stages/create_pr.rs

Comment thread src/cli-pr-monitor/src/stages/create_pr.rs
@aloekun
aloekun force-pushed the fix/pr-monitor-body-reassemble branch from 82d4305 to aac8a67 Compare April 17, 2026 20:01
@aloekun
aloekun merged commit fa4cc6d into master Apr 17, 2026
1 check passed
@aloekun
aloekun deleted the fix/pr-monitor-body-reassemble branch April 17, 2026 20:10
aloekun added a commit that referenced this pull request Apr 19, 2026
ADR-028 (外部可視成果物の生成コマンドの実行ゲート) の運用フローを skill として明文化。

`pnpm push` 完了後の PR 作成で以下の 7 ステップを標準化する:

1. jj status + jj log -r master..@ で差分/bookmark 確認
2. commit description から PR title 初稿生成 (70 文字超は短縮、conventional prefix 維持)
3. diff + commit log から PR body 初稿生成 (Summary/Context/Validation/References)
4. Claude が提示 → AskUserQuestion で明示承認 (auto mode でも必須)
5. `pnpm prepare-pr-body` 経由で `.tmp-pr-body.md` に書き出し
6. `pnpm create-pr --title ... --body-file ...` foreground 実行 (permissions.ask で再確認)
7. `pnpm prepare-pr-body:cleanup` で一時ファイル削除

## 設計ハイライト

- **ADR-028 二層防衛の活用**: skill 内の AskUserQuestion (一次) + permissions.ask (二次)
- **user-supplied text の尊重** (ADR-022): 承認済 draft の二重書き換えを禁止
- **body は必ず一時ファイル経由**: `--body "..."` 引数経由の切り詰めリスク回避 (PR #51 / memory `feedback_pnpm_create_pr_body.md`)
- **automated actor から独立**: takt / cli-* の自律ループはこの skill を呼ばない

## ステータス

試験運用 (2026-04-19〜)。発火頻度・UX を半年観察して正式採用 / 改良 / 廃止を判断する。

## ファイル

- `.claude/skills/prepare-pr/SKILL.md` 新設 (178 行)

## docs/todo.md

- PR-D 完了に伴い「セッション 247510ea 由来: 整備タスク群」ブロック全体を削除
- 雑務 task をリナンバー (#8#7)

refs: ADR-028, ADR-022, PR #57 (PR-B body helper), memory `feedback_bookmark_auto_naming.md`
aloekun added a commit that referenced this pull request Apr 19, 2026
ADR-028 (外部可視成果物の生成コマンドの実行ゲート) の運用フローを skill として明文化。

`pnpm push` 完了後の PR 作成で以下の 7 ステップを標準化する:

1. jj status + jj log -r master..@ で差分/bookmark 確認
2. commit description から PR title 初稿生成 (70 文字超は短縮、conventional prefix 維持)
3. diff + commit log から PR body 初稿生成 (Summary/Context/Validation/References)
4. Claude が提示 → AskUserQuestion で明示承認 (auto mode でも必須)
5. `pnpm prepare-pr-body` 経由で `.tmp-pr-body.md` に書き出し
6. `pnpm create-pr --title ... --body-file ...` foreground 実行 (permissions.ask で再確認)
7. `pnpm prepare-pr-body:cleanup` で一時ファイル削除

## 設計ハイライト

- **ADR-028 二層防衛の活用**: skill 内の AskUserQuestion (一次) + permissions.ask (二次)
- **user-supplied text の尊重** (ADR-022): 承認済 draft の二重書き換えを禁止
- **body は必ず一時ファイル経由**: `--body "..."` 引数経由の切り詰めリスク回避 (PR #51 / memory `feedback_pnpm_create_pr_body.md`)
- **automated actor から独立**: takt / cli-* の自律ループはこの skill を呼ばない

## ステータス

試験運用 (2026-04-19〜)。発火頻度・UX を半年観察して正式採用 / 改良 / 廃止を判断する。

## ファイル

- `.claude/skills/prepare-pr/SKILL.md` 新設 (178 行)

## docs/todo.md

- PR-D 完了に伴い「セッション 247510ea 由来: 整備タスク群」ブロック全体を削除
- 雑務 task をリナンバー (#8#7)

refs: ADR-028, ADR-022, PR #57 (PR-B body helper), memory `feedback_bookmark_auto_naming.md`
aloekun added a commit that referenced this pull request Apr 19, 2026
ADR-028 (外部可視成果物の生成コマンドの実行ゲート) の運用フローを skill として明文化。

`pnpm push` 完了後の PR 作成で以下の 7 ステップを標準化する:

1. jj status + jj log -r master..@ で差分/bookmark 確認
2. commit description から PR title 初稿生成 (70 文字超は短縮、conventional prefix 維持)
3. diff + commit log から PR body 初稿生成 (Summary/Context/Validation/References)
4. Claude が提示 → AskUserQuestion で明示承認 (auto mode でも必須)
5. `pnpm prepare-pr-body` 経由で `.tmp-pr-body.md` に書き出し
6. `pnpm create-pr --title ... --body-file ...` foreground 実行 (permissions.ask で再確認)
7. `pnpm prepare-pr-body:cleanup` で一時ファイル削除

## 設計ハイライト

- **ADR-028 二層防衛の活用**: skill 内の AskUserQuestion (一次) + permissions.ask (二次)
- **user-supplied text の尊重** (ADR-022): 承認済 draft の二重書き換えを禁止
- **body は必ず一時ファイル経由**: `--body "..."` 引数経由の切り詰めリスク回避 (PR #51 / memory `feedback_pnpm_create_pr_body.md`)
- **automated actor から独立**: takt / cli-* の自律ループはこの skill を呼ばない

## ステータス

試験運用 (2026-04-19〜)。発火頻度・UX を半年観察して正式採用 / 改良 / 廃止を判断する。

## ファイル

- `.claude/skills/prepare-pr/SKILL.md` 新設 (178 行)

## docs/todo.md

- PR-D 完了に伴い「セッション 247510ea 由来: 整備タスク群」ブロック全体を削除
- 雑務 task をリナンバー (#8#7)

refs: ADR-028, ADR-022, PR #57 (PR-B body helper), memory `feedback_bookmark_auto_naming.md`
aloekun added a commit that referenced this pull request Apr 19, 2026
ADR-028 (外部可視成果物の生成コマンドの実行ゲート) の運用フローを skill として明文化。

`pnpm push` 完了後の PR 作成で以下の 7 ステップを標準化する:

1. jj status + jj log -r master..@ で差分/bookmark 確認
2. commit description から PR title 初稿生成 (70 文字超は短縮、conventional prefix 維持)
3. diff + commit log から PR body 初稿生成 (Summary/Context/Validation/References)
4. Claude が提示 → AskUserQuestion で明示承認 (auto mode でも必須)
5. `pnpm prepare-pr-body` 経由で `.tmp-pr-body.md` に書き出し
6. `pnpm create-pr --title ... --body-file ...` foreground 実行 (permissions.ask で再確認)
7. `pnpm prepare-pr-body:cleanup` で一時ファイル削除

## 設計ハイライト

- **ADR-028 二層防衛の活用**: skill 内の AskUserQuestion (一次) + permissions.ask (二次)
- **user-supplied text の尊重** (ADR-022): 承認済 draft の二重書き換えを禁止
- **body は必ず一時ファイル経由**: `--body "..."` 引数経由の切り詰めリスク回避 (PR #51 / memory `feedback_pnpm_create_pr_body.md`)
- **automated actor から独立**: takt / cli-* の自律ループはこの skill を呼ばない

## ステータス

試験運用 (2026-04-19〜)。発火頻度・UX を半年観察して正式採用 / 改良 / 廃止を判断する。

## ファイル

- `.claude/skills/prepare-pr/SKILL.md` 新設 (178 行)

## docs/todo.md

- PR-D 完了に伴い「セッション 247510ea 由来: 整備タスク群」ブロック全体を削除
- 雑務 task をリナンバー (#8#7)

refs: ADR-028, ADR-022, PR #57 (PR-B body helper), memory `feedback_bookmark_auto_naming.md`
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