From 308105dd854fd8f0105aba657add76304aa0efa9 Mon Sep 17 00:00:00 2001 From: yamk12nfu Date: Tue, 21 Jul 2026 23:32:47 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20ai-repo-ops=20=E3=82=92=E5=B0=8E?= =?UTF-8?q?=E5=85=A5=20(aro=20init,=20distribution=20base=200.1.5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01DLYNURXo71mPZJUBePwFgr --- .ai/ai-repo-ops.lock.yaml | 80 ++++++++++++++++ .ai/managed/policies/default.yaml | 38 ++++++++ .ai/managed/policies/low-risk.yaml | 36 +++++++ .ai/managed/policies/security.yaml | 41 ++++++++ .ai/managed/prompts/improve.md | 59 ++++++++++++ .ai/managed/prompts/issue-fix.md | 39 ++++++++ .ai/managed/prompts/knowledge-refresh.md | 37 ++++++++ .ai/managed/prompts/release-check.md | 29 ++++++ .ai/managed/prompts/review.md | 40 ++++++++ .ai/managed/schemas/knowledge.schema.json | 51 ++++++++++ .ai/managed/schemas/project.schema.json | 111 ++++++++++++++++++++++ .ai/project.yaml | 43 +++++++++ .gitattributes | 6 ++ .github/workflows/ai-review.yml | 20 ++++ .gitignore | 3 + .prettierignore | 3 + 16 files changed, 636 insertions(+) create mode 100644 .ai/ai-repo-ops.lock.yaml create mode 100644 .ai/managed/policies/default.yaml create mode 100644 .ai/managed/policies/low-risk.yaml create mode 100644 .ai/managed/policies/security.yaml create mode 100644 .ai/managed/prompts/improve.md create mode 100644 .ai/managed/prompts/issue-fix.md create mode 100644 .ai/managed/prompts/knowledge-refresh.md create mode 100644 .ai/managed/prompts/release-check.md create mode 100644 .ai/managed/prompts/review.md create mode 100644 .ai/managed/schemas/knowledge.schema.json create mode 100644 .ai/managed/schemas/project.schema.json create mode 100644 .ai/project.yaml create mode 100644 .gitattributes create mode 100644 .github/workflows/ai-review.yml create mode 100644 .prettierignore diff --git a/.ai/ai-repo-ops.lock.yaml b/.ai/ai-repo-ops.lock.yaml new file mode 100644 index 0000000..9a17b25 --- /dev/null +++ b/.ai/ai-repo-ops.lock.yaml @@ -0,0 +1,80 @@ +schema_version: 1 +source: + repository: yamk12nfu/ai-repo-ops + distribution: base + version: 0.1.5 + commit: null + distribution_content_sha256: b89bd09f27531f15733d306adba73bc7918e6aea8b639058c10a9972c54db94e +checksum: + algorithm: sha256 + mode: canonical_text_lf_utf8bom_strip_v1 +managed_files: + - path: .ai/managed/prompts/review.md + source: distribution/base/files/.ai/managed/prompts/review.md + installed_sha256: 25abc4a2d914dd506a47b0078b263660f265251984d58082df350e303e6f6255 + strategy: managed_overwrite + - path: .ai/managed/prompts/improve.md + source: distribution/base/files/.ai/managed/prompts/improve.md + installed_sha256: 65232e883805072d997e02fc8c9872d56c02c38575cce298a329ca0b48a48945 + strategy: managed_overwrite + - path: .ai/managed/prompts/issue-fix.md + source: distribution/base/files/.ai/managed/prompts/issue-fix.md + installed_sha256: 3db5751b25168aad6677ade62d7370c840fb4b54c784ba1606e880858da4f93d + strategy: managed_overwrite + - path: .ai/managed/prompts/knowledge-refresh.md + source: distribution/base/files/.ai/managed/prompts/knowledge-refresh.md + installed_sha256: 651574fd7a55837d1cd513db5258e52f896bffc6163fdbfeb5d86c423bd517d4 + strategy: managed_overwrite + - path: .ai/managed/prompts/release-check.md + source: distribution/base/files/.ai/managed/prompts/release-check.md + installed_sha256: 34862b7f5bf3a2f6c93b55ea72a2925ff33e7e2711aafed2526fe484e426ffe2 + strategy: managed_overwrite + - path: .ai/managed/policies/default.yaml + source: distribution/base/files/.ai/managed/policies/default.yaml + installed_sha256: 2e49d418d6c6c32dd5e4308790278c143326d3156bcfdd24706634834d3a372d + strategy: managed_overwrite + - path: .ai/managed/policies/low-risk.yaml + source: distribution/base/files/.ai/managed/policies/low-risk.yaml + installed_sha256: 612e55e403e6a769c41993e99681ce7597892c39075177fd3f5885d55e64c379 + strategy: managed_overwrite + - path: .ai/managed/policies/security.yaml + source: distribution/base/files/.ai/managed/policies/security.yaml + installed_sha256: 56925e9f7910e2029c44e5406390c121d67b77c58e476394a8316ef30a50a746 + strategy: managed_overwrite + - path: .ai/managed/schemas/project.schema.json + source: distribution/base/files/.ai/managed/schemas/project.schema.json + installed_sha256: 5bf644018f1157c581f560ce97cca48c654ed2148f9cfadf48b1d203c7873bcf + strategy: managed_overwrite + - path: .ai/managed/schemas/knowledge.schema.json + source: distribution/base/files/.ai/managed/schemas/knowledge.schema.json + installed_sha256: d5c65ca373f81150ffb4ef280cc1942f4335bc04abfb39d92fc79153507be0e5 + strategy: managed_overwrite +seed_files: + - path: .ai/project.yaml + strategy: create_only + - path: .github/workflows/ai-review.yml + strategy: create_only +patches: + - type: append_unique_lines + path: .gitignore + lines: + - .ai/runs/ + - .ai/tmp/ + - .ai/logs/ + - type: append_unique_lines + path: .gitattributes + lines: + - "# ai-repo-ops managed text files" + - .ai/managed/** text eol=lf + - .ai/project.yaml text eol=lf + - .ai/ai-repo-ops.lock.yaml text eol=lf + - .ai/local/knowledge/** text eol=lf + - .github/workflows/ai-*.yml text eol=lf + - type: append_unique_lines + path: .prettierignore + lines: + - "# ai-repo-ops managed files" + - .ai/managed/ + - .ai/ai-repo-ops.lock.yaml +created_at: 2026-07-21T14:31:58.122Z +updated_at: 2026-07-21T14:31:58.122Z diff --git a/.ai/managed/policies/default.yaml b/.ai/managed/policies/default.yaml new file mode 100644 index 0000000..11afc71 --- /dev/null +++ b/.ai/managed/policies/default.yaml @@ -0,0 +1,38 @@ +# ai-repo-ops managed policy: default +# 直接編集しないでください(変更は中央 ai-repo-ops 側で行います)。 +# risk_level: medium のリポジトリ向けの既定ポリシー。 + +schema_version: 1 +name: default +description: medium リスク向けの標準ポリシー。安全側に倒しつつ通常の改善を許可する。 + +change_limits: + max_changed_files: 10 + max_added_lines: 400 + +review: + require_human_review: true + auto_merge: false + block_on: + - failing_required_gates + - secret_detected + - forbidden_path_modified + - managed_file_edited + +allowed_actions: + - fix_bug + - add_test + - update_docs + - refactor_safe + +forbidden_paths: + - ".env" + - ".env.*" + - "secrets/**" + - "infra/prod/**" + - ".github/workflows/**" + +quality_gates: + required: + - lint + - test diff --git a/.ai/managed/policies/low-risk.yaml b/.ai/managed/policies/low-risk.yaml new file mode 100644 index 0000000..8645cd8 --- /dev/null +++ b/.ai/managed/policies/low-risk.yaml @@ -0,0 +1,36 @@ +# ai-repo-ops managed policy: low-risk +# 直接編集しないでください(変更は中央 ai-repo-ops 側で行います)。 +# risk_level: low のリポジトリ向け。実験的 / 影響範囲の小さい repo を想定し緩める。 + +schema_version: 1 +name: low-risk +description: low リスク向けポリシー。変更上限を広げ、安全なリファクタを許可する。 + +change_limits: + max_changed_files: 25 + max_added_lines: 1000 + +review: + require_human_review: true + auto_merge: false + block_on: + - failing_required_gates + - secret_detected + - forbidden_path_modified + +allowed_actions: + - fix_bug + - add_test + - update_docs + - refactor_safe + - refactor_broad + - dependency_bump_patch + +forbidden_paths: + - ".env" + - ".env.*" + - "secrets/**" + +quality_gates: + required: + - test diff --git a/.ai/managed/policies/security.yaml b/.ai/managed/policies/security.yaml new file mode 100644 index 0000000..c177e7a --- /dev/null +++ b/.ai/managed/policies/security.yaml @@ -0,0 +1,41 @@ +# ai-repo-ops managed policy: security +# 直接編集しないでください(変更は中央 ai-repo-ops 側で行います)。 +# risk_level: high / セキュリティ重要 repo 向け。最も厳しい制約を適用する。 + +schema_version: 1 +name: security +description: high リスク向けの厳格ポリシー。変更を最小に抑え、人間レビューを必須にする。 + +change_limits: + max_changed_files: 5 + max_added_lines: 150 + +review: + require_human_review: true + auto_merge: false + block_on: + - failing_required_gates + - secret_detected + - forbidden_path_modified + - managed_file_edited + - dependency_added + - public_api_changed + +allowed_actions: + - fix_bug + - add_test + +forbidden_paths: + - ".env" + - ".env.*" + - "secrets/**" + - "infra/**" + - ".github/workflows/**" + - "**/Dockerfile" + - "**/*.tf" + +quality_gates: + required: + - lint + - typecheck + - test diff --git a/.ai/managed/prompts/improve.md b/.ai/managed/prompts/improve.md new file mode 100644 index 0000000..408e60f --- /dev/null +++ b/.ai/managed/prompts/improve.md @@ -0,0 +1,59 @@ +# AI Improve Prompt(ローカル改善ループ) + +あなたは対象リポジトリを継続的に改善する AI メンテナです。 +このプロンプトは、**開発者のローカル環境(Claude Code 等)で、開発者の同席のもとで実行される** +ことを前提とします(CI の中で自動実行されるものではありません)。 +このプロンプトは ai-repo-ops が配布する managed file です。直接編集しないでください +(変更は中央 `ai-repo-ops` 側で行います)。 + +## 入力 + +- `.ai/project.yaml`: 特に `project.risk_level` / `ai.max_loops` / `ai.max_changed_files` / + `ai.allowed_paths` / `ai.forbidden_paths` / `commands` / `quality_gates` / `review`。 +- `.ai/managed/policies/*.yaml`: 適用ポリシー。`project.risk_level` に対応するものを読む + (`low` → `low-risk.yaml` / `medium` → `default.yaml` / `high` → `security.yaml`)。 +- リポジトリの現状(コード、テスト、CI 結果、未解決の TODO / lint 警告)。 + +## 制約(厳守) + +以下はプロンプト上のお願いではなく、**`aro guard` と CI によって機械的に検証される**。 +違反した変更は PR の required check が落ちるため、merge に至らない。 + +1. 変更してよいのは `ai.allowed_paths` に一致する path のみ。 +2. `ai.forbidden_paths`(および適用 policy の `forbidden_paths`)に一致する path は決して変更しない。 +3. 1 回の改善で触れるファイルは `ai.max_changed_files` と適用 policy の `change_limits.max_changed_files` + の小さい方以下、追加行数は適用 policy の `change_limits.max_added_lines` 以下に収める。 +4. 改善ループは `ai.max_loops` 回までで打ち切る。 +5. `.ai/managed/**` と `.ai/ai-repo-ops.lock.yaml` は編集しない(aro が管理)。 +6. `.github/workflows/**` と `.ai/project.yaml` は編集しない(前者は既定の禁止、 + 後者は変更すると guard が `project_config` violation として必ず表面化させる)。 + +## 進め方 + +0. **開始前の安全確認**: `git status --short` を実行し、clean worktree であること(または専用 + branch / worktree で作業していること)を確認する。**既存の未コミット変更がある場合は、 + 開発者に確認するまで一切の変更・破棄を行わない。** 作業は専用 branch + (例: `git switch -c chore/ai-improve-`)で行う。 +1. 小さく安全な改善を 1 つ選ぶ(lint 修正、テスト追加、デッドコード削除、ドキュメント整備など)。 +2. 変更を実施する。 +3. **自己検証を行う(両方とも通ること)**: + - `git fetch origin ` してから + `aro guard --repo . --base origin/` — policies 違反の機械検証 + (exit 0 であること。fetch 済みの `origin/` を使うと、ローカルの + default branch が古くても CI に近い merge-base で検証できる) + - `quality_gates.required` に対応する `commands.*` のコマンド — すべて緑であること +4. guard 違反・gates 失敗を解消できない、または `max_changed_files` を超える場合は + 変更を破棄し、提案だけを開発者に残す(無理に通そうとしない)。 + **破棄してよいのは、この改善ループで自分が作成・変更したファイルだけ。破棄前に + 対象ファイルの一覧を開発者へ提示して確認を得る。** +5. 自己検証が通ったら、改善内容を開発者に提示する。**PR の作成は開発者の確認を得てから** + 行う(タイトル規約: `chore(ai-improve): <改善の要約>`)。`require_human_review` が + true の間は自動 merge しない(merge は常に人間が判断する)。 + +## 出力 + +- 実施した改善の要約(目的 / 変更ファイル / リスク)。 +- 自己検証の結果(`aro guard` の判定と、実行した quality gate の結果)。 +- 次にやるべき改善候補(実施はしない)。 + +スコープを広げすぎないこと。1 PR = 1 つの明確な改善に保つ。 diff --git a/.ai/managed/prompts/issue-fix.md b/.ai/managed/prompts/issue-fix.md new file mode 100644 index 0000000..041db42 --- /dev/null +++ b/.ai/managed/prompts/issue-fix.md @@ -0,0 +1,39 @@ +# AI Issue Fix Prompt + +あなたは対象リポジトリの GitHub Issue を修正する AI です。 +このプロンプトは ai-repo-ops が配布する managed file です。直接編集しないでください。 + +## 入力 + +- 対象 Issue(タイトル / 本文 / 再現手順 / 受け入れ条件 / ラベル)。 +- `.ai/project.yaml`: `ai.allowed_paths` / `ai.forbidden_paths` / `ai.max_changed_files` / + `commands` / `quality_gates` / `review`。 +- `.ai/managed/policies/*.yaml`: 適用ポリシー。 + +## 制約(厳守) + +- 変更ファイル数は `ai.max_changed_files` と適用 policy の `change_limits.max_changed_files` の + 小さい方以下、追加行数は適用 policy の `change_limits.max_added_lines` 以下に収める。 + +## 進め方 + +0. `git status --short` を実行し、clean worktree であること(または専用 branch / worktree で + 作業していること)を確認する。**既存の未コミット変更がある場合は、開発者に確認するまで + 一切の変更・破棄を行わない。** +1. Issue を再現・特定する。再現できない場合は、必要な情報を明記して修正を保留する。 +2. 根本原因を特定し、最小の変更で修正する。project の `ai.forbidden_paths` と適用 policy の `forbidden_paths` の和集合には触れない。 +3. 修正に対応するテスト(再現テスト → 修正で緑)を追加する。 +4. `git fetch origin ` の後に `aro guard --repo . --base origin/` と + `quality_gates.required` のコマンドを実行し、両方が緑であることを確認する。 +5. guard 違反・gate 失敗を解消できない、または変更上限を超える場合は分割を提案し、 + 無理に 1 PR に詰め込まない。 + +## 出力 + +- 根本原因の説明。 +- 変更内容の要約(ファイル / 方針)。 +- 追加・更新したテストと、その結果。 +- 残課題・フォローアップ(あれば)。 + +Issue の受け入れ条件を満たすことを最優先し、無関係なリファクタを混ぜないこと。 +`review.require_human_review` が true の間は人間レビューを必須とする。 diff --git a/.ai/managed/prompts/knowledge-refresh.md b/.ai/managed/prompts/knowledge-refresh.md new file mode 100644 index 0000000..d34cb72 --- /dev/null +++ b/.ai/managed/prompts/knowledge-refresh.md @@ -0,0 +1,37 @@ +# Repo Knowledge Refresh(ローカル実行) + +あなたは対象リポジトリの固有知識を、根拠付きで最新に保つAIメンテナです。 +この手順は開発者のローカル環境(Claude Code / Codex等)で実行します。CI内でAIを起動しません。 + +## 所有権 + +- 編集してよいのは `.ai/local/knowledge/**` だけです。 +- `.ai/managed/**`、`.ai/project.yaml`、source code、workflowは編集しません。 +- knowledgeはコードや正式ドキュメントの代替ではなく、それらから導いた索引・要約です。 + +## 情報源 + +- 現在のHEADでGit追跡されているローカルのテキストファイルだけを根拠にします。 +- repo root とすべての nested 階層にある `.env`、`.env.*`、`secrets/**`、`.git/**`、`.ai/**` + (次項の既存Knowledgeを除く)、依存物、build生成物は読みません。 +- 既存Knowledgeの状態確認に限り、`.ai/local/knowledge/**` は読み取り専用で参照します。 + `.ai/**` の内容はknowledgeの根拠として使いません。 +- network、GitHub Issue/PR、Slack、Notion、CIログなどの外部情報は使いません。 +- 推測を事実として記録しません。根拠を特定できない内容は提案に留めます。 +- 初回entryでは変化しにくい正式文書を優先し、個別タスク・作業ログ・日次生成物は、明示的に対象指定されない限り根拠から除外します。 +- `aro` がPATHにない場合は、`knowledge init` に使った同じlauncherで各subcommandを実行します。 +- `knowledge init` の成功出力に完全な検証コマンドがある場合は、それを優先します。 + +## 進め方 + +1. `git status --short` が空であること、または専用branch/worktreeであることを確認します。 +2. `.ai/local/knowledge/index.yaml` と既存Markdownを読みます。 +3. `aro knowledge check --repo . --strict` を実行し、stale・欠落・不正な根拠を確認します。 +4. 小さな更新単位を1つ選び、対応するMarkdownとindexだけを更新します。 +5. 各entryに正確なsource pathと、検証に使った完全なlowercase HEAD SHAを記録します。 +6. `aro knowledge check --repo . --strict` を通します。 +7. 未commitの変更は `aro guard` の検証対象外です。差分を開発者へ提示し、人間の確認を得てknowledge変更をcommitします。 +8. commit後に `aro guard --repo . --base ` を通します。 +9. 目的、変更ファイル、根拠、検証結果、残った候補を開発者へ提示します。 + +PR作成とmergeは人間の確認後に行います。自動mergeはしません。 diff --git a/.ai/managed/prompts/release-check.md b/.ai/managed/prompts/release-check.md new file mode 100644 index 0000000..0d8cfb3 --- /dev/null +++ b/.ai/managed/prompts/release-check.md @@ -0,0 +1,29 @@ +# AI Release Check Prompt + +あなたは対象リポジトリのリリース前チェックを行う AI です。 +このプロンプトは ai-repo-ops が配布する managed file です。直接編集しないでください。 + +## 入力 + +- リリース対象の差分(前回リリース tag からの変更)。 +- `.ai/project.yaml`: `project.risk_level` / `commands` / `quality_gates` / `review`。 +- `.ai/managed/policies/*.yaml`: 適用ポリシー。 +- CHANGELOG / リリースノート(あれば)。 + +## チェック項目 + +1. `quality_gates.required` のコマンドがすべて緑であること。 +2. 破壊的変更の有無。ある場合は移行手順とバージョン bump(semver)が妥当か。 +3. 秘密情報・認証情報が差分に混入していないこと。 +4. ドキュメント / CHANGELOG が変更内容に追従していること。 +5. `project.risk_level` が `high` の場合はロールバック手順が用意されていること。 +6. `.github/workflows/**` の変更があれば permissions が過剰でないこと。 + +## 出力 + +- リリース可否の推奨(go / no-go)と根拠。 +- ブロッカー一覧(あれば、`file:line` と根拠)。 +- リリースノートの不足・補足提案。 +- 推奨バージョン(semver)と bump 理由。 + +判断材料が不足している項目は「要確認」と明示し、go を安易に出さないこと。 diff --git a/.ai/managed/prompts/review.md b/.ai/managed/prompts/review.md new file mode 100644 index 0000000..37c5bb5 --- /dev/null +++ b/.ai/managed/prompts/review.md @@ -0,0 +1,40 @@ +# AI Review Prompt + +あなたは対象リポジトリのプルリクエストをレビューする AI レビュアーです。 +このプロンプトは ai-repo-ops が配布する managed file です。直接編集しないでください +(変更は中央 `ai-repo-ops` 側で行います)。 + +## 入力 + +- `.ai/project.yaml`: リポジトリ設定(`project.risk_level` / `commands` / `quality_gates` / `ai` / `review`)。 +- `.ai/managed/policies/*.yaml`: 適用ポリシー。既定は `default.yaml`。`risk_level` に応じて差し替える。 +- 対象 PR の diff、変更ファイル一覧、CI / quality gate の結果。 + +## 方針 + +1. `project.risk_level` に応じてレビューの厳しさを調整する。 + - `low`: 重大な問題に絞る。 + - `medium`: バグ・セキュリティ・可読性・テスト不足を指摘する。 + - `high`: 上記に加え、後方互換・移行・ロールバック手順まで確認する。 +2. project の `ai.forbidden_paths` と適用 policy の `forbidden_paths` の和集合に該当する変更が + 含まれていれば最優先で指摘する。 +3. `quality_gates.required` のコマンドが緑であることを確認する。落ちている場合は merge 不可として扱う。 +4. `.ai/managed/**` または `.ai/ai-repo-ops.lock.yaml` への手編集が含まれていれば、直接編集禁止で + ある旨を指摘し、`git restore -- .ai/managed/ .ai/ai-repo-ops.lock.yaml` と `aro sync` での復旧を + 案内する。 + +## レビュー観点 + +- 正しさ: ロジック誤り、境界条件、例外処理、競合状態。 +- セキュリティ: 入力検証、認証・認可、秘密情報の混入、path traversal。 +- テスト: 変更に対するテストの有無と妥当性。 +- 可読性 / 保守性: 命名、重複、過剰な複雑性。 +- 影響範囲: 公開 API・スキーマ・設定の破壊的変更。 + +## 出力 + +- 概要(merge 可否の推奨と根拠)。 +- 指摘リスト(`file:line` / 深刻度 `blocker|major|minor|nit` / 根拠 / 推奨修正)。 +- 確認した quality gate の結果サマリ。 + +確証のない推測は「要確認」と明示し、断定しないでください。 diff --git a/.ai/managed/schemas/knowledge.schema.json b/.ai/managed/schemas/knowledge.schema.json new file mode 100644 index 0000000..ba5ca6c --- /dev/null +++ b/.ai/managed/schemas/knowledge.schema.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://github.com/yamk12nfu/ai-repo-ops/schemas/knowledge.schema.json", + "title": "ai-repo-ops knowledge index", + "description": "対象repoの .ai/local/knowledge/index.yaml を検証するauthoritative schema。本文はMarkdown、indexは根拠と検証commitだけを保持する。", + "type": "object", + "required": ["schema_version", "entries"], + "additionalProperties": false, + "properties": { + "schema_version": { + "const": 1 + }, + "entries": { + "type": "array", + "items": { + "type": "object", + "required": ["id", "document", "verified_at_commit", "sources"], + "additionalProperties": false, + "properties": { + "id": { + "type": "string", + "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" + }, + "document": { + "type": "string", + "minLength": 1 + }, + "verified_at_commit": { + "type": "string", + "pattern": "^(?:[0-9a-f]{40}|[0-9a-f]{64})$" + }, + "sources": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": ["path"], + "additionalProperties": false, + "properties": { + "path": { + "type": "string", + "minLength": 1 + } + } + } + } + } + } + } + } +} diff --git a/.ai/managed/schemas/project.schema.json b/.ai/managed/schemas/project.schema.json new file mode 100644 index 0000000..9f71988 --- /dev/null +++ b/.ai/managed/schemas/project.schema.json @@ -0,0 +1,111 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://github.com/yamk12nfu/ai-repo-ops/schemas/project.schema.json", + "title": "ai-repo-ops project.yaml", + "description": "対象 repo の .ai/project.yaml を検証する authoritative schema。ai-repo-ops source 側の唯一の正。.ai/managed/schemas/project.schema.json はこの schema から生成されるエディタ補完用コピー。", + "type": "object", + "required": ["schema_version", "project", "commands", "quality_gates", "ai"], + "properties": { + "schema_version": { + "description": "project.yaml schema のバージョン。MVP は 1 のみ。", + "const": 1 + }, + "project": { + "description": "repo 固有のメタ情報。", + "type": "object", + "required": ["name", "type", "risk_level"], + "properties": { + "name": { + "description": "repo 名(init 時に repo ディレクトリ名で埋める)。", + "type": "string", + "minLength": 1 + }, + "type": { + "description": "repo の種別。言語/FW に依存しない汎用識別子(例: generic, node, python, go)。", + "type": "string", + "minLength": 1 + }, + "risk_level": { + "description": "変更リスクレベル。AI ハーネスの慎重さを決める。", + "type": "string", + "enum": ["low", "medium", "high"] + }, + "owner": { + "description": "オーナー(個人 / チーム)。未設定なら unknown。", + "type": "string" + } + } + }, + "runtime": { + "description": "実行環境設定。", + "type": "object", + "properties": { + "devcontainer": { + "description": "devcontainer 設定への参照。未使用なら null。", + "type": ["string", "null"] + } + } + }, + "commands": { + "description": "repo の標準コマンド。空文字は未設定を表し doctor で WARN(init 直後は言語/FW 不明のため FAIL にしない)。", + "type": "object", + "properties": { + "setup": { "type": "string" }, + "lint": { "type": "string" }, + "typecheck": { "type": "string" }, + "test": { "type": "string" }, + "build": { "type": "string" } + }, + "additionalProperties": { "type": "string" } + }, + "quality_gates": { + "description": "PR / 改善で必須にする品質ゲート。required の各要素は commands のキーを指す。", + "type": "object", + "properties": { + "required": { + "type": "array", + "items": { "type": "string", "minLength": 1 } + } + } + }, + "ai": { + "description": "AI ハーネスの動作制約。", + "type": "object", + "properties": { + "max_loops": { + "description": "1 セッションあたりの最大改善ループ回数。", + "type": "integer", + "minimum": 1 + }, + "max_changed_files": { + "description": "1 回の変更で触れてよい最大ファイル数。", + "type": "integer", + "minimum": 1 + }, + "allowed_paths": { + "description": "AI が変更してよい path の glob。", + "type": "array", + "items": { "type": "string", "minLength": 1 } + }, + "forbidden_paths": { + "description": "AI が変更してはいけない path の glob。", + "type": "array", + "items": { "type": "string", "minLength": 1 } + } + } + }, + "review": { + "description": "レビュー / マージ方針。", + "type": "object", + "properties": { + "create_pr": { "type": "boolean" }, + "require_human_review": { "type": "boolean" }, + "auto_merge": { "type": "boolean" } + } + }, + "evals": { + "description": "将来の eval 定義置き場。MVP では空オブジェクト。", + "type": "object" + } + } +} diff --git a/.ai/project.yaml b/.ai/project.yaml new file mode 100644 index 0000000..9cbe14f --- /dev/null +++ b/.ai/project.yaml @@ -0,0 +1,43 @@ +schema_version: 1 + +project: + name: "warikapp" + type: "generic" + risk_level: "medium" + owner: "unknown" + +runtime: + devcontainer: null + +commands: + setup: "" + lint: "" + typecheck: "" + test: "" + build: "" + +quality_gates: + required: + - lint + - test + +ai: + max_loops: 4 + max_changed_files: 10 + allowed_paths: + - "src/**" + - "tests/**" + - "docs/**" + - ".ai/local/knowledge/**" + forbidden_paths: + - ".env" + - "secrets/**" + - "infra/prod/**" + - ".github/workflows/**" + +review: + create_pr: true + require_human_review: true + auto_merge: false + +evals: {} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ca3a724 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +# ai-repo-ops managed text files +.ai/managed/** text eol=lf +.ai/project.yaml text eol=lf +.ai/ai-repo-ops.lock.yaml text eol=lf +.ai/local/knowledge/** text eol=lf +.github/workflows/ai-*.yml text eol=lf diff --git a/.github/workflows/ai-review.yml b/.github/workflows/ai-review.yml new file mode 100644 index 0000000..ef4d697 --- /dev/null +++ b/.github/workflows/ai-review.yml @@ -0,0 +1,20 @@ +name: AI Review + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +concurrency: + group: ai-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + ai_review: + uses: yamk12nfu/ai-repo-ops/.github/workflows/ai-review.reusable.yml@v1 + with: + config_path: ".ai/project.yaml" + lock_path: ".ai/ai-repo-ops.lock.yaml" diff --git a/.gitignore b/.gitignore index 5e4b6d4..6ca66f4 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ next-env.d.ts # Claude Code local settings .claude/settings.local.json +.ai/runs/ +.ai/tmp/ +.ai/logs/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b6a8fa2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# ai-repo-ops managed files +.ai/managed/ +.ai/ai-repo-ops.lock.yaml