chore(ruler): Ruler の運用方針を AGENTS.md 集約型に変更#46
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
変更内容
推定レビュー工数🎯 3 (Moderate) | ⏱️ ~20 分 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.ruler/AGENTS.md:
- Around line 27-32: Add the missing table row for the new sync flow by
inserting a line for the `make sync-ruler` command into the Command |
Description table, e.g. add a row that follows the same format as other entries
and briefly describes the sync flow (日本語) so the table includes `make
sync-ruler` and its purpose alongside `make setup`, `make test`, `make dry-run`,
and `make run`.
In @.ruler/ruler.toml:
- Around line 15-17: Update the [agents.antigravity] section so Antigravity
writes to its hardcoded rules file: change the output_path value for the
agents.antigravity entry from "AGENTS.md" to ".agent/rules/ruler.md" so
Antigravity can load the rules; confirm the agents.antigravity.enabled flag
remains true and save the TOML change.
In `@scripts/sync_ruler.py`:
- Around line 35-37: 現在のフィルタ `"Source: .ruler/"`
を含む任意の行を除外しており本文中の一致まで消してしまうので、ループ内の判定(for line in
lines)を「生成マーカー行そのものだけ」を除外するよう厳密化してください:具体的には line を trim して完全一致(または行頭一致が仕様なら
startswith)で 'Source: .ruler/' と比較し、等しくない場合のみ f.write(line)
するように修正してください(参照する識別子: lines, line, f.write)。
- Line 53: The subprocess.run call that invokes Prettier uses ["npx",
"prettier", "--write", agents_md] which can prompt interactively when npx must
install a package; update the invocation in scripts/sync_ruler.py (the
subprocess.run call for Prettier) to include the npx "--yes" flag (e.g. ["npx",
"--yes", "prettier", "--write", agents_md]) so the call is non-interactive and
safe for CI/first-run environments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1939e20b-a2ff-4b53-8b96-2585902d1aac
📒 Files selected for processing (5)
.gitignore.ruler/AGENTS.md.ruler/ruler.tomlMakefilescripts/sync_ruler.py
💤 Files with no reviewable changes (1)
- .gitignore
🤖 Auto Review Fixer Status処理済みレビュー一覧 (System Use Only)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/sync_ruler.py`:
- Around line 28-29: The script currently treats a missing AGENTS.md as a
non-fatal warning; change both existence checks around the variable agents_md
(the block at the first check that prints "Removing 'Source: .ruler/' lines from
{agents_md}..." and the similar check at the later lines ~61-62) so that if
AGENTS.md is not present after running `ruler apply` the script logs an error
and immediately calls sys.exit(1). Locate the checks that use
os.path.exists(agents_md) and replace the warning/print path with a process that
writes an error (or use print to stderr) and invokes sys.exit(1) to fail fast on
missing AGENTS.md.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0a516a01-41ce-46c0-bf22-9d32b14deed3
📒 Files selected for processing (3)
.ruler/AGENTS.md.ruler/ruler.tomlscripts/sync_ruler.py
🚧 Files skipped from review as they are similar to previous changes (1)
- .ruler/ruler.toml
ruler apply 後に AGENTS.md が存在しない場合、警告のみで終了コード0になっていたのを エラーメッセージ出力 + sys.exit(1) による即時失敗に修正。
There was a problem hiding this comment.
🧹 Nitpick comments (1)
scripts/sync_ruler.py (1)
44-65: 冗長な存在チェックとデッドコードがあります。Line 28-30 で
AGENTS.mdの存在確認と即時終了を行い、Lines 36-39 でファイルに書き込みを行っているため、Line 45 の時点でファイルは必ず存在します。したがって:
- Line 45 の
if os.path.exists(agents_md)は常にTrue- Lines 63-65 の
elseブロックは到達不能なデッドコードコードの明確さのため、この冗長なチェックを削除することを推奨します。
♻️ 修正案
# 4. Markdownとして整形 (prettierを実行) - if os.path.exists(agents_md): - print(f"Formatting {agents_md} with prettier...") - try: - # 先頭と末尾の余分な改行を削除 - with open(agents_md, "r", encoding="utf-8") as f: - content = f.read().strip() - with open(agents_md, "w", encoding="utf-8") as f: - f.write(content + "\n") - - # prettierによるフォーマット - subprocess.run(["npx", "--yes", "prettier", "--write", agents_md], check=True) - print(f"Successfully formatted {agents_md}") - except subprocess.CalledProcessError as e: - print(f"prettier formatting failed: {e}") - sys.exit(1) - except Exception as e: - print(f"Failed to clean up {agents_md}: {e}") - sys.exit(1) - else: - print(f"Error: {agents_md} not found for formatting.", file=sys.stderr) - sys.exit(1) + print(f"Formatting {agents_md} with prettier...") + try: + # 先頭と末尾の余分な改行を削除 + with open(agents_md, "r", encoding="utf-8") as f: + content = f.read().strip() + with open(agents_md, "w", encoding="utf-8") as f: + f.write(content + "\n") + + # prettierによるフォーマット + subprocess.run(["npx", "--yes", "prettier", "--write", agents_md], check=True) + print(f"Successfully formatted {agents_md}") + except subprocess.CalledProcessError as e: + print(f"prettier formatting failed: {e}") + sys.exit(1) + except Exception as e: + print(f"Failed to clean up {agents_md}: {e}") + sys.exit(1)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/sync_ruler.py` around lines 44 - 65, Remove the redundant existence check around the prettier formatting block: delete the surrounding "if os.path.exists(agents_md):" and its unreachable "else" (the block that prints error and calls sys.exit), then un-indent the inner try/except so the code always attempts to strip trailing/leading newlines, write the file, and call subprocess.run([... "prettier"...], check=True); keep the existing subprocess.CalledProcessError and generic Exception handlers and their prints/sys.exit calls, and reference the agents_md variable and the subprocess.run call to locate the code to modify.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@scripts/sync_ruler.py`:
- Around line 44-65: Remove the redundant existence check around the prettier
formatting block: delete the surrounding "if os.path.exists(agents_md):" and its
unreachable "else" (the block that prints error and calls sys.exit), then
un-indent the inner try/except so the code always attempts to strip
trailing/leading newlines, write the file, and call subprocess.run([...
"prettier"...], check=True); keep the existing subprocess.CalledProcessError and
generic Exception handlers and their prints/sys.exit calls, and reference the
agents_md variable and the subprocess.run call to locate the code to modify.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6273972b-af90-483b-abd7-509ac008cfaa
📒 Files selected for processing (1)
scripts/sync_ruler.py
概要
Ruler の運用設計に基づき、各エージェントのルール出力をプロジェクトルートの
AGENTS.mdに集約し、同期プロセスを自動化しました。変更内容
.ruler/ruler.toml:antigravity,cursor,claudeの全エージェントについて、出力先をAGENTS.mdに統一。scripts/sync_ruler.py:ruler apply後のメタ情報(Source行)削除と Prettier によるフォーマットを自動で行うスクリプトを追加。Makefile:make sync-rulerコマンドを追加。.gitignore: Ruler 構成の変更に伴う自動更新。.ruler/AGENTS.md:ruler applyにより内容が同期され、フォーマットが適用。Summary by CodeRabbit
新機能
ドキュメント
その他