feat: enhance package auto-update with Claude Code focus - #239
Conversation
パッケージ自動更新機能を強化し、特にClaude Codeのバージョンを 簡単に最新に保てるようにしました。 ## 追加機能 ### Claude Code専用更新スクリプト - script/update-claude-code.sh を追加 - @anthropic-ai/claude-code の最新バージョンをチェック - npm/global.json を自動更新 - リリースノートURLを表示 - CI環境では自動更新、ローカルでは確認プロンプト ### npm スクリプト追加 - npm run update:claude: Claude Code専用更新 - /update-claude-code: Claude コマンドで対話的更新 ### update-libraries.sh 改善 - カラー出力を追加(GREEN/YELLOW/BLUE) - 更新されたパッケージの詳細なサマリー表示 - バージョン変更を視覚的に表示(before → after) - Claude Codeバージョンを特別に強調表示 ### GitHub Actions ワークフロー改善 - 更新サマリーの自動生成 - PR本文に詳細な変更内容を含める - global.json と package.json の差分を表示 - Claude Codeバージョンとリリースノートリンクを表示 ### ドキュメント更新 - README.md に新しいコマンドの説明を追加 - Update All Libraries vs Update Claude Code Only を明確化 - 使用方法と注意事項を記載 ## 技術的詳細 - jq と npm を使用してバージョン情報を取得 - 環境変数 AUTO_UPDATE と CI でモード切り替え - エラーハンドリングとログ出力を統一 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces automated tooling and documentation for managing library updates, specifically Claude Code versions. It adds scripts to fetch and update dependencies, enhances CI workflows with dynamic summaries, updates npm scripts, and documents version management practices across the repository. Changes
Sequence DiagramsequenceDiagram
participant User/CI as User or CI System
participant Script as update-claude-code.sh
participant npmReg as npm Registry
participant Manifest as npm/global.json
participant Git as Git/PR
User/CI->>Script: npm run update:claude
Script->>Manifest: Read current version
Script->>npmReg: Query latest `@anthropic-ai/claude-code`
npmReg-->>Script: Return latest version
alt Version is newer
Script->>Manifest: Update version via jq
Manifest-->>Script: Confirm update
Script->>User/CI: Display release notes URL
rect rgba(76, 175, 80, 0.2)
Note over User/CI,Script: In CI: Auto-commit
User/CI->>Git: Create/push commit
end
rect rgba(33, 150, 243, 0.2)
Note over User/CI,Script: Interactive: Prompt user
User/CI-->>User/CI: User commits locally
end
else Version is current
Script->>User/CI: Report: All packages up to date
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
||
| - name: Generate update summary | ||
| id: summary | ||
| run: | |
There was a problem hiding this comment.
📝 [actionlint] reported by reviewdog 🐶
shellcheck reported issue in this script: SC2086:info:32:6: Double quote to prevent globbing and word splitting [shellcheck]
PR Review: Claude Code Auto-Update EnhancementPR #239 の品質レビューを実施しました。全体的に非常に高品質な実装で、CLAUDE.md のガイドラインに準拠しています。 ✅ 高評価ポイント1. コード品質・設計
2. セキュリティ・ベストプラクティス
3. ドキュメント品質
4. CI/CD 統合
5. テスト
🔍 改善提案1. テストカバレッジ不足
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
script/update-claude-code.sh (1)
16-19: Consider unifying logging format across scripts.The logging functions in this script use
[INFO],[SUCCESS],[WARN],[ERROR]prefixes, whilescript/update-libraries.shuses symbols like✓and⚠. For consistency and maintainability across the codebase, consider adopting the same format.🔎 Proposed fix to align with update-libraries.sh format
-log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } -log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; } -log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } -log_error() { echo -e "${RED}[ERROR]${NC} $1"; } +log_info() { printf "${BLUE}==> %s${NC}\n" "$1"; } +log_success() { printf "${GREEN}✓ %s${NC}\n" "$1"; } +log_warn() { printf "${YELLOW}⚠ %s${NC}\n" "$1"; } +log_error() { printf "${RED}✗ %s${NC}\n" "$1"; }.github/workflows/update-libraries.yml (1)
31-65: Dynamic summary generation works well.The summary generation logic correctly handles different file changes and conditionally includes Claude Code version information. The use of
|| echofallbacks prevents grep failures from breaking the workflow.Optional improvement for package.json diff filtering:
Line 51's grep pattern
'^\+.*".*":|^-.*".*":'may be overly broad and could match non-dependency lines. Consider narrowing it to focus on the devDependencies section if you want more precise output in the PR summary:git diff package.json | grep -A999 '"devDependencies"' | grep -E '^\+.*".*":|^-.*".*":' | grep -v '^\+\+\+\|^---' || echo "No changes"However, the current implementation is acceptable and provides useful information.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.claude/commands/update-claude-code.md.github/workflows/update-libraries.ymlREADME.mdpackage.jsonscript/update-claude-code.shscript/update-libraries.sh
🧰 Additional context used
📓 Path-based instructions (2)
.github/workflows/update-libraries.yml
📄 CodeRabbit inference engine (CLAUDE.md)
Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
Files:
.github/workflows/update-libraries.yml
{.codex/**,.devcontainer/codex*,package*.json,npm/global.json}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json
Files:
package.json
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/update-libraries.yml : Execute npm run update:libs on schedule and open pull requests when dependencies or Codex/Claude tooling changes in .github/workflows/update-libraries.yml
Applied to files:
script/update-claude-code.sh.github/workflows/update-libraries.yml.claude/commands/update-claude-code.mdscript/update-libraries.shpackage.jsonREADME.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to .github/workflows/claude.yml : Trigger automatic AI assistance on claude mentions in issues, PRs, and comments using .github/workflows/claude.yml
Applied to files:
script/update-claude-code.sh.claude/commands/update-claude-code.mdpackage.json
📚 Learning: 2025-12-09T08:39:14.049Z
Learnt from: CR
Repo: keito4/config PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-09T08:39:14.049Z
Learning: Follow development quality standards defined in `CLAUDE.md` when using Claude Code for development assistance
Applied to files:
script/update-claude-code.shscript/update-libraries.shREADME.md
📚 Learning: 2025-12-01T03:45:17.253Z
Learnt from: CR
Repo: keito4/config PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-01T03:45:17.253Z
Learning: Applies to {.codex/**,.devcontainer/codex*,package*.json,npm/global.json} : Use Conventional Commits format with release-triggering types (feat/fix/perf/revert/docs) for commits touching .codex/**, .devcontainer/codex*, package*.json, or npm/global.json
Applied to files:
README.md
🧬 Code graph analysis (2)
script/update-claude-code.sh (1)
script/update-libraries.sh (2)
log_success(18-20)log_warn(22-24)
script/update-libraries.sh (1)
script/update-claude-code.sh (2)
log_warn(18-18)log_success(17-17)
🪛 LanguageTool
README.md
[uncategorized] ~244-~244: The official name of this software platform is spelled with a capital “H”.
Context: ...r Node.js releases (semantic-release, @semantic-release/github) are excluded by default. Override the...
(GITHUB)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
🔇 Additional comments (17)
script/update-claude-code.sh (5)
21-26: LGTM!Path resolution logic correctly determines the script directory and project root using standard Bash idioms.
30-46: LGTM!Dependency checks are comprehensive with clear error messages and appropriate exit codes. The installation hint for jq is helpful.
48-69: LGTM!Version retrieval and comparison logic is correct. The simple string equality check is sufficient since the script only needs to detect differences, not determine ordering. The npm registry always returns the absolute latest version, so any difference indicates an update is needed.
71-79: LGTM!User confirmation logic correctly handles CI and AUTO_UPDATE modes. The safe default (cancel on non-Y) and single-character input provide good user experience.
81-93: LGTM!The JSON update uses proper atomic write pattern with a temporary file. The jq command correctly updates the specific package version while preserving the rest of the file structure. Success messages and release notes URL provide good feedback.
package.json (1)
22-22: LGTM!The new
update:claudescript follows the existing naming convention and correctly references the newly added update script. This change aligns with the coding guidelines requirement for release-triggering commit types when modifyingpackage.json..claude/commands/update-claude-code.md (3)
1-17: LGTM!The documentation clearly describes the purpose, execution steps, and usage of the update command. The structure is well-organized and aligns with the actual script implementation.
20-51: LGTM!The implementation example correctly demonstrates how to invoke the update script non-interactively. The path resolution, environment variable setup, and post-update git diff check are all appropriate. The manual commit instructions provide clear guidance for users.
53-57: LGTM!The notes section clearly documents important constraints and behavior differences between local and CI environments, helping users understand when manual intervention is required.
script/update-libraries.sh (3)
5-24: LGTM!The colored logging functions improve readability and provide visual feedback. The use of symbols (=>, ✓, ⚠) and
printfwith format strings is consistent and maintainable.
49-78: LGTM - Great improvement!The package tracking logic significantly improves visibility by collecting and displaying all updates in a summary. The fallback pattern for version retrieval (
|| echo "$current_version") is good defensive coding that prevents failures when npm view encounters issues.
89-95: LGTM!The Claude Code version highlight aligns with the PR's objective to enhance Claude Code update visibility. The conditional check ensures graceful handling when jq or the manifest file is unavailable.
README.md (4)
240-246: LGTM!The documentation accurately describes the library update workflow, including the exclusion mechanism and automated weekly PR process. Clear and helpful for users.
247-253: LGTM!The documentation clearly describes the Claude Code-specific update workflow and its relationship to the general library update process. The mention of both the npm script and Claude command provides complete usage guidance.
254-256: LGTM!The commit requirements section correctly documents the Conventional Commits enforcement for release-critical files, aligning with the coding guidelines and ensuring proper semantic-release automation.
258-263: LGTM!This section clearly documents the architectural decision to use
npm/global.jsonas the single source of truth for CLI versions. The explanation of DevContainer integration and rebuild requirements helps users maintain environment consistency..github/workflows/update-libraries.yml (1)
67-87: LGTM!The PR body template effectively incorporates the dynamically generated summary and provides clear context about what gets updated. The workflow file link adds transparency and helps maintainers understand the automation.
|
🎉 This PR is included in version 1.32.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
パッケージ自動更新機能を強化し、特にClaude Codeのバージョンを簡単に最新に保てるようにしました。
追加機能
🤖 Claude Code専用更新機能
新しいスクリプト:
script/update-claude-code.sh@anthropic-ai/claude-codeの最新バージョンをチェックnpm/global.jsonを自動更新npm スクリプト:
npm run update:claudenpm run update:libsとの使い分けが可能Claude コマンド:
/update-claude-code📊 update-libraries.sh 改善
🔄 GitHub Actions ワークフロー改善
npm/global.jsonとpackage.jsonの変更を表示📚 ドキュメント更新
使用例
Claude Code のみを更新
すべてのパッケージを更新
Claude コマンドで更新
Test Plan
npm run update:claudeの動作確認技術的詳細
jqを使用してJSON解析npm viewで最新バージョン取得AUTO_UPDATEとCIでモード切り替え影響範囲
npm run update:libsの動作は変更なし🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
update:claudecommand with automatic release notesDocumentation
✏️ Tip: You can customize this high-level summary in your review settings.