From c1b2dff28ad2f726c1f3485e878174739e7d4678 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Mar 2026 23:20:55 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20AGENTS.md=20=E8=87=AA=E5=8B=95?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=82=B9=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=20repo-maintenance=20?= =?UTF-8?q?=E3=81=AB=E7=B5=84=E3=81=BF=E8=BE=BC=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AGENTS.md の自動生成セクション更新を実行可能なスクリプトとして実装し、 /repo-maintenance から確実に実行される仕組みにする。 追加: - script/update-agents-md.sh: リポジトリ状態から AGENTS.md を自動再生成 - --check モード: 差分チェックのみ(exit 1 で差分あり) - Prettier 適用後の冪等性を保証 - Tech stack, ディレクトリ, コマンド, ワークフロー, Quality Gates, Hooks を自動収集 変更: - .claude/commands/repo-maintenance.md: Step 3.4.1 を参考ロジックから スクリプト呼び出しに変更し、MODE ごとの動作を明記 Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/commands/repo-maintenance.md | 38 +++- AGENTS.md | 131 ++++++------ script/update-agents-md.sh | 302 +++++++++++++++++++++++++++ 3 files changed, 403 insertions(+), 68 deletions(-) create mode 100755 script/update-agents-md.sh diff --git a/.claude/commands/repo-maintenance.md b/.claude/commands/repo-maintenance.md index e6bde34d..2a5f62f6 100644 --- a/.claude/commands/repo-maintenance.md +++ b/.claude/commands/repo-maintenance.md @@ -807,22 +807,42 @@ echo "$AUTO_CONTENT" >> AGENTS.md echo "$TAIL" >> AGENTS.md ``` -**重要:** 上記のシェルスクリプトは参考ロジック。実際の実行は Claude Code が以下の手順で行う: +**実行スクリプト:** `script/update-agents-md.sh` -1. リポジトリの現在の状態を読み取る(コマンド、ワークフロー、スクリプト、フック) -2. 各セクションの内容を生成 -3. AGENTS.md の `` 〜 `` 間を置換 -4. `CLAUDE.md` が `AGENTS.md` へのシンボリックリンクであることを確認(Step 3.4 で実施済み) +このスクリプトは以下を自動収集し、マーカー間を置換する: -**Hooks の情報取得:** +1. Tech stack(`package.json` の engines、ロックファイルからパッケージマネージャー検出、`nix/flake.nix` の有無) +2. Project Structure(dot ディレクトリ + 通常ディレクトリを列挙し、既知のディレクトリには説明を付与) +3. Available Commands(`.claude/commands/*.md` の frontmatter description を取得) +4. CI/CD Workflows(`.github/workflows/*.yml` の `name:` を取得) +5. Quality Gates(`package.json` scripts から `format:check`, `lint`, `test`, `shellcheck`, `typecheck` 等を検出) +6. Hooks(`.claude/hooks/*.py` のファイル名からトリガーと目的を推定) +7. Development Standards(release-types ルール等の固定セクション) -`.claude/hooks/README.md` が存在する場合はそこから説明を取得。 -存在しない場合はファイル名から推測(`pre_` = Pre trigger, `post_` = Post trigger, `block_` = Pre blocker, `stop_` = Stop trigger)。 +生成後に Prettier でフォーマットし、冪等性を保証する。 + +**実行方法:** + +```bash +# 更新を適用 +bash script/update-agents-md.sh + +# 差分チェックのみ(変更なし、差分があれば exit 1) +bash script/update-agents-md.sh --check +``` + +**MODE ごとの動作:** + +| MODE | 動作 | +| ---------- | ------------------------------------------------------------ | +| full | `bash script/update-agents-md.sh` を実行し、差分があれば更新 | +| quick | `bash script/update-agents-md.sh --check` で差分を報告のみ | +| check-only | `bash script/update-agents-md.sh --check` で差分を報告のみ | **結果:** - ✅ AGENTS.md 自動生成セクション: 最新に更新済み -- 🔧 AGENTS.md 自動生成セクション: X 件のセクションを更新 +- 🔧 AGENTS.md 自動生成セクション: 更新しました - ⏭️ スキップ(AGENTS.md 未対応 / マーカーなし) ### 3.5 CI/CD Setup Check (full mode only) diff --git a/AGENTS.md b/AGENTS.md index c48d4a42..e6c6e6da 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,96 +33,100 @@ Development infrastructure template repository providing DevContainer images, CI - **Package Manager**: npm - **Base Image**: `ghcr.io/keito4/config-base:latest` - **Release**: semantic-release (Conventional Commits) +- **macOS Environment**: nix-darwin + home-manager (`nix/flake.nix`) ## Project Structure | Directory | Purpose | | -------------------- | ------------------------------------------------ | | `.agents/` | AI agent skills and configurations | -| `.claude/commands/` | Claude Code slash commands (28 commands) | +| `.claude/commands/` | Claude Code slash commands | | `.claude/hooks/` | Pre/post hook scripts for quality enforcement | +| `.claude/rules/` | Claude Code rules for development standards | | `.codex/` | Codex AI agent configuration | | `.cursor/` | Cursor editor settings | | `.devcontainer/` | DevContainer configuration and Dockerfile | | `.gemini/` | Gemini AI agent configuration | -| `.github/workflows/` | GitHub Actions CI/CD workflows | +| `.github/workflows/` | GitHub Actions CI/CD workflows (20 workflows) | | `.husky/` | Git hooks (pre-commit, commit-msg) | | `.vscode/` | VS Code workspace settings | | `brew/` | Homebrew package management (Linux only) | | `credentials/` | Credential templates and filtering documentation | -| `docs/` | Documentation | +| `docs/` | Documentation and ADRs | | `dot/` | Dotfiles (DevContainer .zshrc, peco) | | `eslint/` | ESLint configuration and plugins | | `git/` | Git hooks and configuration | +| `next/` | Next.js project templates | | `nix/` | nix-darwin + home-manager (macOS environment) | | `npm/` | npm global configuration and library management | | `script/` | Utility shell scripts | | `templates/` | Workflow, testing, and dotfile templates | | `test/` | Test suites (Jest unit, BATS integration) | +| `vscode/` | VS Code extensions list | ## Available Commands -| Command | Description | -| ------------------------------- | ------------------------------------------------------------------------ | -| `/repo-maintenance` | Comprehensive repository maintenance - run all health checks and updates | -| `/setup-new-repo` | Setup new repository with DevContainer, CI/CD, and development tools | -| `/setup-ci` | Setup comprehensive CI/CD workflows | -| `/setup-tests` | Setup comprehensive testing infrastructure for Next.js projects | -| `/setup-husky` | Husky + lint-staged + commitlint setup | -| `/setup-team-protection` | GitHub repository protection rules | -| `/setup-doppler` | Setup Doppler secret management | -| `/create-pr` | Create PR with latest base branch changes merged | -| `/create-codespace` | Create GitHub Codespace | -| `/config-base-sync-check` | Check current and latest config-base image versions | -| `/config-base-sync-update` | Update DevContainer to latest config-base image and create PR | -| `/config-contribution-discover` | Discover useful features and create issues for config repo | -| `/sync-settings` | Sync Claude & Codex settings to DevContainer configuration | -| `/update-claude-code` | Update Claude Code version | -| `/update-actions` | Update GitHub Actions versions | -| `/container-health` | Container environment health check | -| `/codespaces-secrets` | Codespaces secrets management | -| `/branch-cleanup` | Clean up merged and stale branches | -| `/pre-pr-checklist` | Pre-PR validation checklist | -| `/devcontainer-checklist` | DevContainer restart verification checklist | -| `/git-sync` | Git sync commands | -| `/changelog-generator` | Generate changelog | -| `/dependency-health-check` | Check dependency health | -| `/security-credential-scan` | Scan for leaked credentials | -| `/security-review` | Security review with improvement suggestions | -| `/similarity-analysis` | Detect duplicate code patterns | -| `/code-complexity-check` | Code complexity analysis | -| `/test-coverage-trend` | Test coverage trend analysis | +| Command | Description | +| ------------------------------- | ----------------------------------------------------------------------------------------- | +| `/branch-cleanup` | (no description) | +| `/changelog-generator` | (no description) | +| `/code-complexity-check` | (no description) | +| `/codespaces-secrets` | (no description) | +| `/config-base-sync-check` | Check current and latest config-base image versions | +| `/config-base-sync-update` | Update DevContainer to latest config-base image, sync recommended features, and create PR | +| `/config-contribution-discover` | Discover useful features in current repository and create issues for config repository | +| `/container-health` | (no description) | +| `/create-codespace` | (no description) | +| `/create-pr` | Create PR with latest base branch changes merged | +| `/dependency-health-check` | (no description) | +| `/devcontainer-checklist` | (no description) | +| `/git-sync` | (no description) | +| `/pre-pr-checklist` | (no description) | +| `/repo-maintenance` | Comprehensive repository maintenance - run all health checks and updates | +| `/security-credential-scan` | (no description) | +| `/security-review` | (no description) | +| `/setup-ci` | Setup comprehensive CI/CD workflows for your repository | +| `/setup-doppler` | Setup Doppler secret management with dev/dev_personal configuration | +| `/setup-husky` | (no description) | +| `/setup-new-repo` | Setup new repository with DevContainer, CI/CD, and development tools from config template | +| `/setup-team-protection` | (no description) | +| `/setup-tests` | Setup comprehensive testing infrastructure for Next.js projects | +| `/similarity-analysis` | Analyze code similarity in the repository to detect duplicate functions and patterns | +| `/sync-settings` | Sync Claude & Codex settings from your-org projects to DevContainer configuration | +| `/test-coverage-trend` | (no description) | +| `/update-actions` | (no description) | +| `/update-claude-code` | (no description) | ## CI/CD Workflows -| Workflow | Purpose | -| --------------------------- | ------------------------------------------------------------------------------------------ | -| `ci.yml` | Code quality validation (lint, format, test, build). Required status check: `Quality Gate` | -| `docker-image.yml` | Build and Release DevContainer Image with semantic versioning | -| `security.yml` | Dependency review, license compliance, secret detection, npm audit | -| `claude.yml` | AI assistance triggered by `@claude` mentions in issues/PRs | -| `claude-code-review.yml` | Automated AI code review on PRs | -| `update-libraries.yml` | Scheduled `npm run update:libs` with auto PR | -| `update-dev-tools.yml` | Update development tools | -| `update-claude-plugins.yml` | Update Claude plugins | -| `container-security.yml` | Container security scanning | -| `coverage-report.yml` | Coverage report generation | -| `label-sync.yml` | GitHub label IaC management | -| `dependabot-auto-merge.yml` | Dependabot PR auto-merge | -| `quality-gate-fallback.yml` | CI quality gate fallback for non-code changes | -| `manual-release.yml` | Manual release trigger | -| `rebuild-docker-cache.yml` | Weekly Docker cache rebuild | +| Workflow | Purpose | +| --------------------------- | ------------------------------------ | +| `ci.yml` | CI | +| `claude-code-review.yml` | Claude Code Review | +| `claude.yml` | Claude Code | +| `container-security.yml` | Container Security Scan | +| `coverage-report.yml` | Coverage Report | +| `dependabot-auto-merge.yml` | Dependabot Auto-merge | +| `docker-image.yml` | Build and Release DevContainer Image | +| `label-sync.yml` | Label Sync | +| `manual-release.yml` | Manual Release | +| `quality-gate-fallback.yml` | CI | +| `rebuild-docker-cache.yml` | Rebuild Docker Cache (Weekly) | +| `security.yml` | Security Scans | +| `update-claude-plugins.yml` | Update Claude Plugins | +| `update-dev-tools.yml` | Update Development Tools | +| `update-libraries.yml` | Auto Update Libraries | ## Quality Gates The following scripts are auto-detected and run before git commit/push: -| Script | Command | Purpose | -| -------------- | ----------------------------------------------------- | -------------------------- | -| `format:check` | `prettier --check .` | Code formatting validation | -| `lint` | `eslint . --ext .js` | Code quality validation | -| `test` | `jest --runInBand` | Unit test execution | -| `shellcheck` | `find script -name '*.sh' ... \| xargs shellcheck -x` | Shell script validation | +| Script | Command | Purpose | +| -------------- | ---------------------------------- | ------------------------------------ | ----------------------- | ----------------------- | +| `format:check` | `prettier --check .` | Code formatting validation | +| `lint` | `eslint . --ext .js` | Code quality validation | +| `test` | `jest --runInBand` | Unit test execution | +| `shellcheck` | `find script -name '\*.sh' -type f | grep -vFf script/.shellcheck-exclude | xargs -r shellcheck -x` | Shell script validation | Additional test commands: `test:integration` (BATS), `test:coverage` (Jest + coverage), `test:all` (unit + integration) @@ -130,16 +134,25 @@ Additional test commands: `test:integration` (BATS), `test:coverage` (Jest + cov | Hook | Trigger | Purpose | | ----------------------------- | ------------------- | ------------------------------------ | -| `block_git_no_verify.py` | Pre git commit/push | Block `--no-verify` and `HUSKY=0` | -| `pre_git_quality_gates.py` | Pre git commit/push | Auto-detect and run quality gates | | `block_config_edit.py` | Pre edit | Protect configuration files | | `block_dangerous_commands.py` | Pre Bash | Block destructive commands | +| `block_git_no_verify.py` | Pre git commit/push | Block `--no-verify` and `HUSKY=0` | +| `post_commit_adr_reminder.py` | Post git commit | Remind ADR for architectural changes | | `post_edit_auto_lint.py` | Post edit | Auto-format and lint | | `post_git_push_ci.py` | Post git push | Monitor CI status | | `post_pr_ai_review.py` | Post PR creation | Run AI code review | | `post_pr_ci_watch.py` | Post PR creation | Monitor PR CI status | -| `post_commit_adr_reminder.py` | Post git commit | Remind ADR for architectural changes | | `pre_exit_plan_ai_review.py` | Pre ExitPlanMode | AI review before plan exit | +| `pre_git_quality_gates.py` | Pre git commit/push | Auto-detect and run quality gates | | `stop_test_verification.py` | Stop | Verify test results on session end | +## Development Standards + +### Code Quality Requirements + +- **Test-Driven Development (TDD)**: Red -> Green -> Refactor methodology with 70%+ line coverage requirement +- **Static Quality Gates**: Automated linting, formatting, security analysis, and license checking +- **Git Workflow**: Conventional commits, branch naming conventions, and pull request requirements +- **Release Types Required for Tooling Changes**: Commits that touch `.codex/**`, `.devcontainer/codex*`, `package*.json`, or `npm/global.json` must use release-triggering types (`feat` / `fix` / `perf` / `revert` / `docs`). commitlint blocks `chore` etc. to align with semantic-release. + diff --git a/script/update-agents-md.sh b/script/update-agents-md.sh new file mode 100755 index 00000000..347036fe --- /dev/null +++ b/script/update-agents-md.sh @@ -0,0 +1,302 @@ +#!/usr/bin/env bash +# +# AGENTS.md の自動生成セクションをリポジトリの現在の状態から再生成する。 +# 間を置換。 +# +# Usage: bash script/update-agents-md.sh [--check] +# --check: 差分があるか確認のみ(変更しない)。差分があれば exit 1。 + +set -euo pipefail + +AGENTS_MD="AGENTS.md" +CHECK_ONLY=false +[[ "${1:-}" == "--check" ]] && CHECK_ONLY=true + +# --- Guard --- +if [[ ! -f "$AGENTS_MD" ]] || ! grep -q "BEGIN AUTO-GENERATED" "$AGENTS_MD"; then + echo "⏭️ スキップ($AGENTS_MD に AUTO-GENERATED マーカーなし)" + exit 0 +fi + +# --- 1. Tech stack --- +NODE_VER=$(jq -r '.engines.node // empty' package.json 2>/dev/null) +PM="npm" +[[ -f "pnpm-lock.yaml" ]] && PM="pnpm" +[[ -f "yarn.lock" ]] && PM="yarn" +{ [[ -f "bun.lockb" ]] || [[ -f "bun.lock" ]]; } && PM="bun" + +HAS_NIX=false +[[ -f "nix/flake.nix" ]] && HAS_NIX=true + +# --- 2. Collect directories (dot dirs + regular dirs) --- +collect_dirs() { + local dirs="" + # Dot directories (filtered) + for d in .*/; do + case "$d" in + ./|../|.git/|.git-*/) continue ;; + esac + local name="${d%/}" + # Sub-categorize known dot dirs + case "$name" in + .agents) dirs+="| \`.agents/\` | AI agent skills and configurations |"$'\n' ;; + .claude) + dirs+="| \`.claude/commands/\` | Claude Code slash commands |"$'\n' + dirs+="| \`.claude/hooks/\` | Pre/post hook scripts for quality enforcement |"$'\n' + [[ -d ".claude/rules" ]] && dirs+="| \`.claude/rules/\` | Claude Code rules for development standards |"$'\n' + ;; + .codex) dirs+="| \`.codex/\` | Codex AI agent configuration |"$'\n' ;; + .cursor) dirs+="| \`.cursor/\` | Cursor editor settings |"$'\n' ;; + .devcontainer) dirs+="| \`.devcontainer/\` | DevContainer configuration and Dockerfile |"$'\n' ;; + .gemini) dirs+="| \`.gemini/\` | Gemini AI agent configuration |"$'\n' ;; + .github) + local wf_count + wf_count=$(find .github/workflows -name '*.yml' 2>/dev/null | wc -l | tr -d ' ') + dirs+="| \`.github/workflows/\` | GitHub Actions CI/CD workflows ($wf_count workflows) |"$'\n' + ;; + .husky) dirs+="| \`.husky/\` | Git hooks (pre-commit, commit-msg) |"$'\n' ;; + .vscode) dirs+="| \`.vscode/\` | VS Code workspace settings |"$'\n' ;; + esac + done + + # Regular directories + for d in */; do + case "$d" in node_modules/|coverage/|.git/|reports/|result/) continue ;; esac + local name="${d%/}" + local purpose="" + case "$name" in + brew) purpose="Homebrew package management (Linux only)" ;; + credentials) purpose="Credential templates and filtering documentation" ;; + docs) purpose="Documentation and ADRs" ;; + dot) purpose="Dotfiles (DevContainer .zshrc, peco)" ;; + eslint) purpose="ESLint configuration and plugins" ;; + git) purpose="Git hooks and configuration" ;; + next) purpose="Next.js project templates" ;; + nix) purpose="nix-darwin + home-manager (macOS environment)" ;; + npm) purpose="npm global configuration and library management" ;; + script) purpose="Utility shell scripts" ;; + templates) purpose="Workflow, testing, and dotfile templates" ;; + test) purpose="Test suites (Jest unit, BATS integration)" ;; + vscode) purpose="VS Code extensions list" ;; + *) purpose="$name" ;; + esac + dirs+="| \`$name/\` | $purpose |"$'\n' + done + echo -n "$dirs" +} + +# --- 3. Collect commands --- +collect_commands() { + local cmds="" + for cmd in .claude/commands/*.md; do + [[ ! -f "$cmd" ]] && continue + local base + base=$(basename "$cmd" .md) + [[ "$base" == "README" ]] && continue + local desc + desc=$(awk '/^---$/{n++; next} n==1 && /^description:/{sub(/^description: */, ""); print; exit}' "$cmd") + [[ -z "$desc" ]] && desc="(no description)" + cmds+="| \`/$base\` | $desc |"$'\n' + done + echo -n "$cmds" +} + +# --- 4. Collect workflows --- +collect_workflows() { + local wfs="" + for wf in .github/workflows/*.yml; do + [[ ! -f "$wf" ]] && continue + local base + base=$(basename "$wf") + local name + name=$(grep -m1 '^name:' "$wf" | sed 's/^name: *//' | tr -d "'\"") + [[ -z "$name" ]] && name="(unnamed)" + wfs+="| \`$base\` | $name |"$'\n' + done + echo -n "$wfs" +} + +# --- 5. Collect quality gates --- +collect_quality_gates() { + local gates="" + local scripts=("format:check" "lint" "test" "shellcheck" "typecheck" "type-check" "tsc") + local purposes=("Code formatting validation" "Code quality validation" "Unit test execution" "Shell script validation" "Type checking" "Type checking" "Type checking") + + for i in "${!scripts[@]}"; do + local key="${scripts[$i]}" + local val + val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null) + if [[ -n "$val" ]]; then + gates+="| \`$key\` | \`$val\` | ${purposes[$i]} |"$'\n' + fi + done + echo -n "$gates" +} + +# --- 6. Collect extra test scripts --- +collect_extra_tests() { + local extras="" + for key in "test:integration" "test:coverage" "test:all"; do + local val + val=$(jq -r --arg k "$key" '.scripts[$k] // empty' package.json 2>/dev/null) + [[ -n "$val" ]] && extras+="$key"$'\n' + done + echo -n "$extras" +} + +# --- 7. Collect hooks --- +collect_hooks() { + local hooks_out="" + for hook in .claude/hooks/*.py; do + [[ ! -f "$hook" ]] && continue + local base + base=$(basename "$hook") + local trigger="" purpose="" + + # Determine trigger and purpose from filename pattern + case "$base" in + block_git_no_verify.py) trigger="Pre git commit/push"; purpose="Block \`--no-verify\` and \`HUSKY=0\`" ;; + pre_git_quality_gates.py) trigger="Pre git commit/push"; purpose="Auto-detect and run quality gates" ;; + block_config_edit.py) trigger="Pre edit"; purpose="Protect configuration files" ;; + block_dangerous_commands.py) trigger="Pre Bash"; purpose="Block destructive commands" ;; + post_edit_auto_lint.py) trigger="Post edit"; purpose="Auto-format and lint" ;; + post_git_push_ci.py) trigger="Post git push"; purpose="Monitor CI status" ;; + post_pr_ai_review.py) trigger="Post PR creation"; purpose="Run AI code review" ;; + post_pr_ci_watch.py) trigger="Post PR creation"; purpose="Monitor PR CI status" ;; + post_commit_adr_reminder.py) trigger="Post git commit"; purpose="Remind ADR for architectural changes" ;; + pre_exit_plan_ai_review.py) trigger="Pre ExitPlanMode"; purpose="AI review before plan exit" ;; + stop_test_verification.py) trigger="Stop"; purpose="Verify test results on session end" ;; + *) + # Fallback: infer from prefix + case "$base" in + block_*) trigger="Pre Bash" ;; + pre_*) trigger="Pre" ;; + post_*) trigger="Post" ;; + stop_*) trigger="Stop" ;; + *) trigger="Unknown" ;; + esac + purpose="${base%.py}" + ;; + esac + + hooks_out+="| \`$base\` | $trigger | $purpose |"$'\n' + done + echo -n "$hooks_out" +} + +# --- 8. Build auto-generated content --- +DIRS=$(collect_dirs) +COMMANDS=$(collect_commands) +WORKFLOWS=$(collect_workflows) +QUALITY_GATES=$(collect_quality_gates) +HOOKS=$(collect_hooks) + +# Extra test info +EXTRA_TESTS=$(collect_extra_tests) +EXTRA_LINE="" +if [[ -n "$EXTRA_TESTS" ]]; then + EXTRA_LINE="Additional test commands:" + echo "$EXTRA_TESTS" | while IFS= read -r t; do + [[ -z "$t" ]] && continue + case "$t" in + test:integration) EXTRA_LINE+=" \`$t\` (BATS)," ;; + test:coverage) EXTRA_LINE+=" \`$t\` (Jest + coverage)," ;; + test:all) EXTRA_LINE+=" \`$t\` (unit + integration)," ;; + *) EXTRA_LINE+=" \`$t\`," ;; + esac + done +fi + +# Build the content +AUTO_CONTENT=" + +## Repository Overview + +Development infrastructure template repository providing DevContainer images, CI/CD workflows, Claude Code commands/hooks, and standardized tooling for all repositories. + +- **Tech Stack**: Node.js (${NODE_VER:-N/A}), Jest, BATS, ESLint, Prettier +- **Package Manager**: $PM +- **Base Image**: \`ghcr.io/keito4/config-base:latest\` +- **Release**: semantic-release (Conventional Commits)" + +if [[ "$HAS_NIX" == "true" ]]; then + AUTO_CONTENT+=" +- **macOS Environment**: nix-darwin + home-manager (\`nix/flake.nix\`)" +fi + +AUTO_CONTENT+=" + +## Project Structure + +| Directory | Purpose | +| --- | --- | +${DIRS} +## Available Commands + +| Command | Description | +| --- | --- | +${COMMANDS} +## CI/CD Workflows + +| Workflow | Purpose | +| --- | --- | +${WORKFLOWS} +## Quality Gates + +The following scripts are auto-detected and run before git commit/push: + +| Script | Command | Purpose | +| --- | --- | --- | +${QUALITY_GATES} +Additional test commands: \`test:integration\` (BATS), \`test:coverage\` (Jest + coverage), \`test:all\` (unit + integration) + +## Hooks + +| Hook | Trigger | Purpose | +| --- | --- | --- | +${HOOKS} +## Development Standards + +### Code Quality Requirements + +- **Test-Driven Development (TDD)**: Red -> Green -> Refactor methodology with 70%+ line coverage requirement +- **Static Quality Gates**: Automated linting, formatting, security analysis, and license checking +- **Git Workflow**: Conventional commits, branch naming conventions, and pull request requirements +- **Release Types Required for Tooling Changes**: Commits that touch \`.codex/**\`, \`.devcontainer/codex*\`, \`package*.json\`, or \`npm/global.json\` must use release-triggering types (\`feat\` / \`fix\` / \`perf\` / \`revert\` / \`docs\`). commitlint blocks \`chore\` etc. to align with semantic-release." + +# --- 9. Replace markers --- +# Extract HEAD (up to and including BEGIN marker) and TAIL (from END marker) +HEAD=$(sed '//q' "$AGENTS_MD") +TAIL=$(sed -n '//,$p' "$AGENTS_MD") + +NEW_CONTENT="${HEAD} +${AUTO_CONTENT} + +${TAIL}" + +if [[ "$CHECK_ONLY" == "true" ]]; then + # Write to temp file and format for accurate comparison + TMPFILE=$(mktemp /tmp/agents-md-check-XXXXX.md) + trap 'rm -f "$TMPFILE"' EXIT + echo "$NEW_CONTENT" > "$TMPFILE" + if command -v npx >/dev/null 2>&1; then + npx prettier --write "$TMPFILE" >/dev/null 2>&1 || true + fi + if ! diff -q "$AGENTS_MD" "$TMPFILE" >/dev/null 2>&1; then + echo "⚠️ AGENTS.md 自動生成セクションに差分があります" + diff "$AGENTS_MD" "$TMPFILE" | head -30 + exit 1 + else + echo "✅ AGENTS.md 自動生成セクション: 最新" + exit 0 + fi +fi + +echo "$NEW_CONTENT" > "$AGENTS_MD" + +# Run prettier if available +if command -v npx >/dev/null 2>&1; then + npx prettier --write "$AGENTS_MD" >/dev/null 2>&1 || true +fi + +echo "🔧 AGENTS.md 自動生成セクションを更新しました" From 64b069baf35e46091522873796ecc2971bc4853d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Mar 2026 23:32:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20BATS=20=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=20SHA=20=E5=9B=BA=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=20actions=20=E3=81=AB=E5=AF=BE=E5=BF=9C=E3=81=95=E3=81=9B?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actions を SHA 固定したことにより、`@v6` や `@v7` のタグ参照を 期待していた BATS テストが失敗していた。 `@` の後にタグまたは SHA が続くパターンに変更。 Co-Authored-By: Claude Opus 4.6 (1M context) --- test/integration/coverage-report-workflow.bats | 12 ++++++------ test/integration/workflows.bats | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/integration/coverage-report-workflow.bats b/test/integration/coverage-report-workflow.bats index e59a7b19..f929f816 100644 --- a/test/integration/coverage-report-workflow.bats +++ b/test/integration/coverage-report-workflow.bats @@ -41,7 +41,7 @@ setup() { @test "coverage-report.yml has jacoco report job" { grep -q "report-jacoco:" "$WORKFLOW" - grep -q "madrapps/jacoco-report@v" "$WORKFLOW" + grep -q "madrapps/jacoco-report@" "$WORKFLOW" } @test "coverage-report.yml passes GITHUB_TOKEN to jacoco action" { @@ -50,7 +50,7 @@ setup() { @test "coverage-report.yml has jest report job" { grep -q "report-jest:" "$WORKFLOW" - grep -q "actions/github-script@v" "$WORKFLOW" + grep -q "actions/github-script@" "$WORKFLOW" } @test "coverage-report.yml uses pinned action versions" { @@ -59,7 +59,7 @@ setup() { } @test "coverage-report.yml downloads artifacts before reporting" { - grep -q "actions/download-artifact@v" "$WORKFLOW" + grep -q "actions/download-artifact@" "$WORKFLOW" } @test "coverage-report.yml uses env variables for script inputs" { @@ -71,13 +71,13 @@ setup() { @test "coverage-report.yml has cobertura report job" { grep -q "report-cobertura:" "$WORKFLOW" - grep -q "irongut/CodeCoverageSummary@v" "$WORKFLOW" - grep -q "marocchino/sticky-pull-request-comment@v" "$WORKFLOW" + grep -q "irongut/CodeCoverageSummary@" "$WORKFLOW" + grep -q "marocchino/sticky-pull-request-comment@" "$WORKFLOW" } @test "coverage-report.yml has lcov report job" { grep -q "report-lcov:" "$WORKFLOW" - grep -q "romeovs/lcov-reporter-action@v" "$WORKFLOW" + grep -q "romeovs/lcov-reporter-action@" "$WORKFLOW" } @test "coverage-report.yml passes GITHUB_TOKEN to lcov action" { diff --git a/test/integration/workflows.bats b/test/integration/workflows.bats index 87b4c9c5..402e5c6a 100644 --- a/test/integration/workflows.bats +++ b/test/integration/workflows.bats @@ -34,9 +34,9 @@ load ../test_helper/test_helper # Should use npm ci instead of npm install grep -q "npm ci" "$workflow" - # Should use pinned action versions - grep -q "actions/checkout@v6" "$workflow" - grep -q "actions/setup-node@v6" "$workflow" + # Should use pinned action versions (SHA or tag) + grep -q "actions/checkout@" "$workflow" + grep -q "actions/setup-node@" "$workflow" } @test "docker-image workflow has proper permissions" { @@ -95,8 +95,8 @@ load ../test_helper/test_helper @test "update-libraries workflow uses pinned third-party actions" { local workflow="${REPO_ROOT}/.github/workflows/update-libraries.yml" - # Should use specific version for peter-evans/create-pull-request - grep -q "peter-evans/create-pull-request@v7" "$workflow" + # Should use pinned version for peter-evans/create-pull-request (SHA or tag) + grep -q "peter-evans/create-pull-request@" "$workflow" } @test "update-libraries workflow has safe cron schedule" { @@ -199,8 +199,8 @@ load ../test_helper/test_helper @test "ci workflow uploads coverage reports securely" { local workflow="${REPO_ROOT}/.github/workflows/ci.yml" - # Should upload coverage with token - grep -q "codecov/codecov-action@v5" "$workflow" + # Should upload coverage with token (SHA or tag) + grep -q "codecov/codecov-action@" "$workflow" grep -q "token:.*secrets.CODECOV_TOKEN" "$workflow" # Should not fail CI on coverage upload errors