feat(cli): non-interactive mode for add + new changed command - #1890
feat(cli): non-interactive mode for add + new changed command#1890brunorodmoreira wants to merge 7 commits into
Conversation
Enable AI agents, CI pipelines, and scripts to create changesets without interactive prompts by providing all required inputs via CLI flags. New flags for `changeset add`: - `--packages` (`-p`): specify packages with optional bump type (e.g. `pkg:minor`) - `--type` (`-t`): default bump type for all packages (`patch|minor|major`) - `--all`: auto-select all changed packages (git-aware) New command `changeset changed`: - Lists packages changed since base branch (one per line) - `--json` flag for machine-readable output - `--since` flag for custom git ref Non-interactive mode activates when `--packages` (or `--all`) and `--message` are both provided. Falls back to interactive mode otherwise. Closes changesets#979 Closes changesets#1604
🦋 Changeset detectedLatest commit: e443d86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1890 +/- ##
==========================================
- Coverage 84.24% 83.13% -1.12%
==========================================
Files 56 57 +1
Lines 2419 2479 +60
Branches 729 747 +18
==========================================
+ Hits 2038 2061 +23
- Misses 375 412 +37
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…nged command - Rename --packages to --package (singular, repeatable via mri) - Remove colon syntax (pkg:type), stick to --type only - Normalize --package flag early to string[] in run.ts - Move non-interactive tests from nested describe in add.ts to run.test.ts - Use log instead of error for "no changed packages" (valid state) - Add header with resolved since value before listing changed packages
- Update changed command test to expect log instead of error - Run prettier on all affected files
Integrate upstream's dynamic COMMAND_HELP rendering with our new `changed` command and additional `add` flags.
Integrate upstream's refactoring (aliases extraction, COMMAND_HELP moved to help.ts, validateCommandFlags) with our non-interactive add flags and changed command.
|
@brunorodmoreira would love to see this land 🥇 |
|
this PR makes two separate modifications, non-interactive mode and a new command. could these be split up into separate PRs? we have also made major changes to the CLI code in the with these two points in mind, could you split the PR and base it on i am also not sure about having a for example, pnpm already supports filtering with git: this supports everything pnpm related already, something Changesets fails in some regards (#1707) |
|
Surething @beeequeue . I will rework it then and let you know. |
|
closing this based on previous comment |
Summary
Adds non-interactive mode to
changeset addand introduces a newchangeset changedcommand, enabling AI agents, CI pipelines, and automation scripts to create changesets without interactive prompts.Motivation
The current
changeset addflow requires interactive input for package selection, bump type, and summary — making it unusable for AI coding assistants (Claude Code, Cursor, GitHub Copilot, etc.), CI pipelines, and automation scripts. This has been requested across multiple issues (#979, #1604, Discussion #1118).As AI-assisted development becomes the norm, tools like changesets need a programmatic interface so agents can handle the full commit-and-changeset workflow autonomously.
New flags for
changeset add--package-pstring(repeatable)--type-tpatch|minor|major--allbooleanNon-interactive mode activates when
--package(or--all) and--messageare both provided. When any required input is missing, it gracefully falls back to the interactive flow.New command:
changeset changedLists packages that have changed since the base branch — the same detection logic used in the first step of the interactive
addflow, now exposed as a standalone command. This enables a two-step workflow for AI agents: discover → create.Manual Testing
Tested against a real monorepo (private, 27+ packages across
apps/,packages/,libs/).changeset changed$ changeset changed 🦋 Changed packages since "develop": 🦋 @ollie-shop/functions 🦋 hub$ changeset changed --json 🦋 [ 🦋 { 🦋 "name": "@ollie-shop/functions", 🦋 "dir": "/path/to/packages/functions" 🦋 }, 🦋 { 🦋 "name": "hub", 🦋 "dir": "/path/to/apps/hub" 🦋 } 🦋 ]Non-interactive
add— single package$ changeset add --package @ollie-shop/functions --type patch -m "test non-interactive add" 🦋 === Summary of changesets === 🦋 patch: @ollie-shop/functions 🦋 Changeset added and committed 🦋 info /path/to/.changeset/tiny-radios-hide.mdNon-interactive
add— multiple packages$ changeset add --package @ollie-shop/functions --package hub --type minor -m "test multiple packages" 🦋 === Summary of changesets === 🦋 minor: @ollie-shop/functions, hub 🦋 Changeset added and committed 🦋 info /path/to/.changeset/soft-nights-make.mdError: unknown package
Error: missing --type
$ changeset add --package hub -m "no type" 🦋 error --type is required when using non-interactive modeAI Agent Workflow Example
Test Plan
addcommand tests pass (no regressions)run.test.tsfor--packageflag normalization (single → array, multiple, undefined,--allpassthrough)Review Changes Applied
Addressed all feedback from @Andarist:
describeblocks — moved non-interactive tests fromadd/__tests__/add.tstorun.test.tspkg:type) — sticking to--typefor simplicity--packages→--package(singular, repeatable viamri)--packageearly tostring[]inrun.tserror→logfor "no changed packages" (valid state, not an error)sincevalue before listing changed packagesCloses #979
Closes #1604