-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add AI-powered changeset workflow for monorepo releases #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add AI-powered changeset workflow for monorepo releases #13
Conversation
## AI-Powered Changesets Workflow ### Files Created | File | Purpose | |------|---------| | actions/changeset/action.yml | Composite action that sets up OpenCode and runs the AI skill | | actions/changeset/skill.md | AI behavior instructions for generating changesets | | scripts/write-changeset.ts | OpenCode tool to write .changeset/*.md files | | src/cli/templates/changeset.ts | Workflow template for CLI installer | | .github/workflows/changeset.yml | Dogfooding workflow for this repo | ### Files Updated | File | Changes | |------|---------| | src/cli/templates/index.ts | Added changeset export and file mapping | | src/cli/installer.ts | Added CHANGESET generator | | src/cli/index.ts | Added changeset option to multiselect | | test/installer.test.js | Added 6 tests for changeset workflow | | README.md | Documented new action with usage example | | AGENTS.md | Updated structure and actions table | ### How It Works 1. **PR triggers workflow** → AI analyzes diff, commits, PR description 2. **Detects affected packages** → Parses monorepo config (pnpm/npm/yarn workspaces) 3. **Infers version bump** → From conventional commits (feat: → minor, fix: → patch) 4. **Generates changeset Attempt: att-78a8e1a2-339c-4c3e-85ef-2ae316b5e426 Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
1. **Commit instruction** now shows: git commit -m "chore: add changeset for PR #<number> [skip ci]" 2. **Added critical note** emphasizing [skip ci] is required to prevent infinite loops 3. **Added to "Common Mistakes"** section as a reminder 4. **Added to checklist** for commit mode Attempt: att-78a8e1a2-339c-4c3e-85ef-2ae316b5e426 Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
Attempt: att-78a8e1a2-339c-4c3e-85ef-2ae316b5e426 Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
|
Warning Rate limit exceeded@activadee has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 7 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces an AI-powered changeset generation workflow for monorepos. It adds a new GitHub Action that analyzes pull requests to automatically generate changeset files, including the underlying script for creating changesets and CLI integration to enable the feature during setup. Changes
Pre-merge checks✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
scripts/write-changeset.ts (1)
44-47: Minor modulo bias in random selection (optional improvement).Using modulo on random bytes introduces a small statistical bias when the range doesn't evenly divide 256 or 65536. For example, with 30 adjectives, indices 0-15 appear slightly more often than 16-29.
This is not a security concern for human-readable changeset IDs and the bias is negligible in practice. However, if you want perfectly uniform distribution, consider rejection sampling or using a library like
crypto.randomInt()(Node.js 14.10+).🔎 Optional refactor using crypto.randomInt for uniform distribution
- const randomBytes = crypto.randomBytes(4); - const adjIndex = randomBytes[0] % adjectives.length; - const nounIndex = randomBytes[1] % nouns.length; - const number = ((randomBytes[2] << 8) | randomBytes[3]) % 1000; + const adjIndex = crypto.randomInt(0, adjectives.length); + const nounIndex = crypto.randomInt(0, nouns.length); + const number = crypto.randomInt(0, 1000);
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
AGENTS.mdREADME.mdactions/changeset/action.ymlactions/changeset/skill.mdexamples/README.mdscripts/write-changeset.tssrc/cli/index.tssrc/cli/installer.tssrc/cli/templates/changeset.tssrc/cli/templates/index.tstest/installer.test.js
🧰 Additional context used
🧬 Code graph analysis (3)
src/cli/templates/changeset.ts (2)
src/cli/templates/index.ts (1)
CHANGESET(5-5)src/cli/templates/shared.ts (2)
ENV_OPENCODE_AUTH(1-2)ENV_API_KEY(4-5)
test/installer.test.js (1)
src/cli/installer.ts (1)
installWorkflows(63-136)
src/cli/installer.ts (2)
src/cli/templates/changeset.ts (1)
CHANGESET(3-27)src/cli/templates/index.ts (1)
CHANGESET(5-5)
🔇 Additional comments (29)
src/cli/index.ts (2)
45-45: LGTM! Clean integration into the help text.The changeset workflow file is properly documented alongside the existing workflows in the help output.
71-71: LGTM! Clear and informative option.The changeset option follows the established pattern with an appropriate label and helpful hint that clearly communicates its purpose for monorepo versioning.
src/cli/installer.ts (1)
8-8: LGTM! Consistent integration with existing workflows.The CHANGESET import and generator mapping follow the established pattern, properly integrating the new workflow into the installation flow.
Also applies to: 18-18
src/cli/templates/index.ts (1)
5-5: LGTM! Type-safe integration of the changeset workflow.The export, type extension, and file mapping are all consistent with the existing workflow patterns, properly extending the type system to include the new changeset workflow.
Also applies to: 7-7, 14-14
examples/README.md (2)
7-7: LGTM! Accurate prerequisites update.Correctly includes changeset in the list of AI-powered actions that require API key configuration.
105-143: LGTM! Clear and comprehensive documentation.The changeset workflow documentation follows the established pattern and provides helpful context about the action's capabilities. The workflow example matches the template implementation and includes a useful comment about the alternative
commentmode.src/cli/templates/changeset.ts (1)
1-27: LGTM! Well-structured changeset workflow template.The template follows the established patterns and implements the changeset workflow correctly:
- Properly imports authentication environment variables for conditional OAuth/API key usage
- Checkout configuration with
fetch-depth: 0,ref: github.head_ref, and token properly enables committing changeset files to the PR branch- Appropriate permissions granted for both committing and PR operations
- Defaults to
mode: commitfor automatic changeset generation, which aligns with reducing manual friction per the PR objectivesThe workflow will run on every PR update (synchronize), which is expected behavior to keep changesets current as changes evolve.
AGENTS.md (3)
24-26: LGTM! Structure documentation is accurate.The new changeset action and write-changeset script are correctly documented in the project structure, following the established pattern for AI-powered actions.
Also applies to: 32-33
50-50: LGTM! Actions table correctly updated.The changeset action is properly documented in the actions table with appropriate AI classification and description.
72-72: LGTM! OpenCode tools table updated correctly.The write-changeset.ts script is properly documented with a clear purpose statement.
test/installer.test.js (2)
167-181: LGTM! Comprehensive test correctly updated.The changeset workflow is properly integrated into the comprehensive test case, with correct count update and existence check.
183-253: LGTM! Comprehensive test coverage for changeset workflow.The new test suite provides thorough coverage of the changeset workflow including:
- File creation verification
- Composite action reference validation
- OAuth vs API key authentication modes
- Required write permissions (contents and pull-requests)
All tests follow established patterns and include proper assertions.
actions/changeset/skill.md (8)
1-13: LGTM! Clear introduction and purpose statement.The skill metadata and capabilities are well-documented, providing a clear overview of the AI changeset generation functionality.
14-41: LGTM! Well-structured workflow documentation.The workflow steps are clearly defined with appropriate shell commands and logical flow from PR analysis to changeset generation.
42-78: LGTM! Comprehensive package detection strategy.The documentation covers all major monorepo tools (pnpm, npm/yarn, lerna) with practical examples and sensible root-level file handling guidance.
79-111: LGTM! Solid version inference logic.The version bump inference follows conventional commit standards with sensible fallbacks and a conservative default to patch when uncertain.
112-142: LGTM! Clear changeset format specification.The format documentation aligns with Changesets standards and includes helpful examples contrasting developer-focused vs user-facing language.
143-216: LGTM! Clear tool usage and mode documentation.Both commit and comment modes are well-documented. The critical emphasis on
[skip ci]in commit messages is essential to prevent infinite workflow loops—good call-out.
217-243: LGTM! Practical edge case handling.The edge cases cover important scenarios with sensible guidance, particularly the check for existing changesets to prevent duplicates.
244-285: LGTM! Comprehensive guidance and checklist.The common mistakes section, non-monorepo fallback, example output, and submission checklist provide excellent operational guidance for AI agents and human reviewers.
actions/changeset/action.yml (3)
18-39: LGTM! Composite action steps are well-structured.The setup sequence correctly:
- Installs Bun runtime
- Conditionally configures OpenCode authentication
- Installs OpenCode via official script
- Copies skill and tools to appropriate directories with correct path traversal
40-46: LGTM! Changeset generation step is correctly configured.The OpenCode invocation properly:
- Loads the changeset skill
- Passes model and mode inputs
- References the correct PR number
- Provides GITHUB_TOKEN for GitHub API access
6-9: No issues found. The model identifieranthropic/claude-sonnet-4-5is valid and correctly formatted for OpenCode AI, which uses theprovider/model_idformat.README.md (3)
20-20: LGTM! Actions table correctly updated.The changeset action is properly documented in the Available Actions table with appropriate classification and description.
76-107: LGTM! Complete and correct changeset workflow example.The workflow example demonstrates proper configuration including:
- Appropriate PR event triggers
- Required write permissions for committing changesets
- Correct checkout configuration for PR branch with full history
- Proper authentication setup with both GITHUB_TOKEN and ANTHROPIC_API_KEY
The accompanying description accurately explains the changeset action's capabilities.
143-154: LGTM! Documentation correctly explains changeset workflow.The "How It Works" section accurately describes the changeset action's trigger, analysis, generation, and delivery process, consistent with the implementation.
scripts/write-changeset.ts (3)
1-8: LGTM!The imports and type definitions are appropriate for the changeset generation functionality.
52-71: LGTM!The changeset content format correctly follows the Changesets markdown structure with YAML frontmatter. Sorting packages alphabetically ensures deterministic output, which is helpful for version control.
119-125: LGTM!The return message provides clear feedback about the created changeset, including the file path, affected packages, and summary. The export structure correctly implements the plugin interface expected by the broader tooling.
1. **Imperative mood regex** → Replaced with lookup map for correct suggestions: - updated → update (not updat) - changed → change (not chang) - removed → remove (not remov) 2. **Schema version** → Updated from @changesets/config@3.0.0 to @3.1.1 3. **Retry exhaustion** → Added error handling that throws if collision still exists after 5 attempts instead of silently overwriting Attempt: att-78a8e1a2-339c-4c3e-85ef-2ae316b5e426 Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
Attempt: att-78a8e1a2-339c-4c3e-85ef-2ae316b5e426 Profile: apg-70541e2b-d01c-4d50-a814-7025ac222ebe
Summary
write-changeset.ts) that leverages OpenCode/Anthropic AI to intelligently write changelog entriescloses #12