Skip to content

chore(ruler): Ruler の運用方針を AGENTS.md 集約型に変更#46

Merged
HappyOnigiri merged 7 commits intomainfrom
chore/update-ruler-workflow
Mar 11, 2026
Merged

chore(ruler): Ruler の運用方針を AGENTS.md 集約型に変更#46
HappyOnigiri merged 7 commits intomainfrom
chore/update-ruler-workflow

Conversation

@HappyOnigiri
Copy link
Owner

@HappyOnigiri HappyOnigiri commented Mar 11, 2026

概要

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

  • 新機能

    • 追加のエージェント設定をサポートしました。
    • エージェント情報を自動同期する新しい同期コマンドを追加しました。
  • ドキュメント

    • エージェント一覧ドキュメントに同期コマンドを追記し、表の整列を改善しました。
  • その他

    • 一部の以前は無視されていた設定ファイルを追跡対象に変更しました。

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fec449ed-e73d-4adc-b1c8-d4d288d5fec8

📥 Commits

Reviewing files that changed from the base of the PR and between 632c8f5 and eed66e8.

📒 Files selected for processing (1)
  • scripts/sync_ruler.py

📝 Walkthrough

Walkthrough

.rulerに2つのエージェント設定を追加し、AGENTS.mdの表を調整。scripts/sync_ruler.pyを追加しMakefileにsync-rulerターゲットを追加。.gitignoreの複数エントリを削除して該当ファイルをトラッキング対象に変更。

変更内容

コホート / ファイル(s) サマリー
Ruler 設定
\.ruler/ruler.toml, \.ruler/AGENTS.md
ruler.tomlagents.cursoragents.antigravity(enabled=true、output_path指定)を追加。AGENTS.mdmake sync-ruler行を追加しテーブル列幅を調整。
スクリプト実装
scripts/sync_ruler.py
新規スクリプトを追加:既存AGENTS.mdの削除、npx --yes @intellectronica/ruler apply実行、特定のソースコメント行除去、Prettierで整形、エラーハンドリングとログ出力を実装。
ビルドシステム
Makefile
sync-rulerターゲットを追加し.PHONYに登録。既存のPYTHON呼び出しパターンを使用。
バージョン管理設定
.gitignore
START Ruler Generated Filesセクション内のエントリ(例:/.agent/rules/ruler.md, /.agent/rules/ruler.md.bak, /.agent/skills, /.claude/skills, /.cursor/skills)を削除し、これらがトラッキング対象となるよう変更。

推定レビュー工数

🎯 3 (Moderate) | ⏱️ ~20 分

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 PRタイトルは、Ruler の運用方針を AGENTS.md 集約型に変更するという、このPRの主要な目的を明確に表しており、変更内容の中核を正確に要約しています。

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/update-ruler-workflow

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

@HappyOnigiri HappyOnigiri added the refix:running Refix is currently processing review fixes. label Mar 11, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 829b27f and a91e21b.

📒 Files selected for processing (5)
  • .gitignore
  • .ruler/AGENTS.md
  • .ruler/ruler.toml
  • Makefile
  • scripts/sync_ruler.py
💤 Files with no reviewable changes (1)
  • .gitignore

@HappyOnigiri
Copy link
Owner Author

HappyOnigiri commented Mar 11, 2026

🤖 Auto Review Fixer Status

処理済みレビュー一覧 (System Use Only)
Comment ID 処理日時 (UTC)
r3929341912 2026-03-11 12:52:44
discussion_r2918131230 2026-03-11 12:52:45
discussion_r2918131253 2026-03-11 12:52:45
discussion_r2918131257 2026-03-11 12:52:46
discussion_r2918131259 2026-03-11 12:52:46
r3929409041 2026-03-11 13:01:52
discussion_r2918195962 2026-03-11 13:01:53
r3929455838 2026-03-11 13:11:27

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 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

📥 Commits

Reviewing files that changed from the base of the PR and between a91e21b and 8b3ec57.

📒 Files selected for processing (3)
  • .ruler/AGENTS.md
  • .ruler/ruler.toml
  • scripts/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) による即時失敗に修正。
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3ec57 and 632c8f5.

📒 Files selected for processing (1)
  • scripts/sync_ruler.py

@HappyOnigiri HappyOnigiri added refix:done Refix finished review checks/fixes for now. and removed refix:running Refix is currently processing review fixes. labels Mar 11, 2026
@HappyOnigiri HappyOnigiri merged commit 5b1d72f into main Mar 11, 2026
2 checks passed
@HappyOnigiri HappyOnigiri deleted the chore/update-ruler-workflow branch March 11, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refix:done Refix finished review checks/fixes for now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant