Skip to content

Conversation

@activadee
Copy link
Owner

Summary

  • Add changeset action: New AI-powered action to generate and manage changesets for semantic versioning in monorepos
  • Add changeset workflow: Integrate changeset generation into GitHub Actions pipeline with automatic commit and skip-ci support
  • Add changeset generation script: TypeScript tool (write-changeset.ts) that leverages OpenCode/Anthropic AI to intelligently write changelog entries
  • Integrate with CLI: Update workflow installer to include changeset template and workflows
  • Update documentation: Extended README and AGENTS.md with changeset action details and usage examples

closes #12

## 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
@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0a29d71 and 1460339.

📒 Files selected for processing (1)
  • scripts/write-changeset.ts
📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Changeset Action (Core Implementation)
open-workflows/actions/changeset/action.yml, open-workflows/actions/changeset/skill.md
Introduces new composite GitHub Action "AI Changeset" that configures automated changeset generation. Accepts model and mode inputs, sets up Bun and OpenCode runtime, and executes changeset generation. Includes detailed skill documentation covering PR analysis, monorepo structure detection, version inference, changeset formatting, and operational modes (commit/comment).
Changeset Script
scripts/write-changeset.ts
New utility script with validation schema for writing changeset files to .changeset directory. Validates package mappings and imperative summaries, generates human-friendly IDs with collision handling, creates .changeset/config.json if needed, and exports public API with execute function.
CLI Templates & Integration
src/cli/templates/changeset.ts, src/cli/templates/index.ts, src/cli/index.ts, src/cli/installer.ts
Adds changeset workflow template that generates GitHub Actions YAML for PR-triggered changeset generation with auth configuration. Updates CLI to include changeset option in installation prompts and workflow generators mapping. Extends WorkflowType union and WORKFLOW_FILE_MAP to support changeset workflows.
Documentation
AGENTS.md, README.md, examples/README.md
Updates documentation to register new changeset action in available actions list, includes dedicated usage section with workflow snippet, explains changeset generation workflow (PR monitoring, file generation, commit/comment delivery), and adds example workflow in examples directory.
Tests
test/installer.test.js
Adds test coverage for changeset workflow installation, verifying workflow file creation, action references, conditional auth configuration (ANTHROPIC\_API\_KEY vs OPENCODE\_AUTH), and required permissions. Updates test counts to account for fifth workflow.

Pre-merge checks

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding an AI-powered changeset workflow for monorepo releases, which is the primary focus of the PR.
Description check ✅ Passed The description comprehensively covers the main changes including the changeset action, workflow, generation script, CLI integration, and documentation updates, all of which are present in the changeset.
Linked Issues check ✅ Passed The PR successfully implements all core requirements from issue #12: scope detection via diff analysis, version bump inference from commit messages, changelog generation, smart batching, and choice between commit vs comment delivery modes.
Out of Scope Changes check ✅ Passed All changes are directly related to the changeset workflow feature. Documentation updates, CLI integration, action definitions, and scripts all support the core objective with no extraneous modifications.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3ffe9 and 0a29d71.

📒 Files selected for processing (11)
  • AGENTS.md
  • README.md
  • actions/changeset/action.yml
  • actions/changeset/skill.md
  • examples/README.md
  • scripts/write-changeset.ts
  • src/cli/index.ts
  • src/cli/installer.ts
  • src/cli/templates/changeset.ts
  • src/cli/templates/index.ts
  • test/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 comment mode.

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: commit for automatic changeset generation, which aligns with reducing manual friction per the PR objectives

The 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 identifier anthropic/claude-sonnet-4-5 is valid and correctly formatted for OpenCode AI, which uses the provider/model_id format.

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
@activadee activadee merged commit 7741df0 into main Jan 4, 2026
2 checks passed
@activadee activadee deleted the OW/OW-7-feat-ai-powered-changesets-workflow-for-monorepo-releases branch January 4, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: AI-powered Changesets workflow for monorepo releases

2 participants