## Machine-Readable Contract ```yaml contract_schema_version: v1 issue_kind: implementation parent_issue: "none" goal_ref: "agent ops 監査用の compact audit bundle を生成し、root thread の初期読込量を削減する" change_kind: code ``` ## Background agent ops 監査では `AGENTS.md` / `CLAUDE.md` / `.claude/skills/**` / hooks / subagents / scripts を広く読む必要があるが、毎回 raw file を大量に読むと token 消費と context pollution が大きい。 既に `scripts/agent_ops_inventory.py` は metadata-only inventory を生成できるが、監査者が次に読むべき要約 bundle までは作らない。 ## Outcome `scripts/agent_ops_audit_bundle.py` が存在し、`agent_ops_inventory.py` の artifact を入力として path / kind / line_count / sha / owner role / risk flags / recommended reader を JSON と Markdown で出力する。agent ops 監査の初期読込が bundle 1 個で開始できる。 ## In Scope - `scripts/agent_ops_audit_bundle.py` を追加する - 入力: `agent_ops_inventory.py --task-kind agent-ops-review` の artifact JSON - 出力: JSON と Markdown の 2 形式 - 含める情報: path / kind / line_count / sha / owner role / risk flags / recommended reader のみ - file body 全文は含めない - secret-like path は inventory と同じルールで除外する - critical surface missing / warn / ok が一目でわかる - `tests/test_agent_ops_audit_bundle.py` を追加する - bundle が 2048〜8192 bytes に収まること - `.claude/skills/**` や hooks の全文を出力しないこと - CI で snapshot test が通ること ## Allowed Paths - `scripts/agent_ops_audit_bundle.py` - `tests/test_agent_ops_audit_bundle.py` ## Acceptance Criteria - [ ] AC1: agent ops 監査の初期読込が bundle 1 個で開始できる(README またはヘルプに手順が記載されている) - [ ] AC2: bundle は 2048〜8192 bytes 程度に収まる(snapshot test で固定) - [ ] AC3: `.claude/skills/**` や hooks の全文は bundle に出力されない - [ ] AC4: critical surface の missing / warn / ok が出力に含まれる - [ ] AC5: CI で snapshot test が通る ## Verification Commands ```bash # AC1 / AC2 / AC3 / AC4 / AC5 uv run python3 scripts/agent_ops_inventory.py --task-kind agent-ops-review --artifact-out /tmp/inv.json uv run python3 scripts/agent_ops_audit_bundle.py --inventory /tmp/inv.json --format markdown uv run pytest tests/test_agent_ops_audit_bundle.py -v # bundle サイズ確認 uv run python3 scripts/agent_ops_audit_bundle.py --inventory /tmp/inv.json --format json | wc -c pnpm typecheck pnpm lint ``` ## Non-Goals - `agent_ops_inventory.py` 本体の変更 - agent 設定ファイルの自動修正 - 全文 body の bundle 化
Activity