Skip to content

Commit d7d7b55

Browse files
committed
add changeset instructions to AGENTS.md
1 parent 8c663a6 commit d7d7b55

File tree

1 file changed

+245
-0
lines changed

1 file changed

+245
-0
lines changed

AGENTS.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,248 @@ The torrents view (`src/views/torrents/`) demonstrates this pattern:
450450
- **Detail View**: `src/views/torrents/torrent.tsx` - Individual torrent details
451451
- **Routes**: `src/views/torrents/routes.tsx` - Route configuration
452452
- **Components**: `src/views/torrents/components/` - Reusable UI components
453+
454+
## Changesets for Version Management
455+
456+
This project uses [Changesets](https://github.com/changesets/changesets) to manage versioning and changelogs. **Only create changesets when user-facing APIs change or break.**
457+
458+
### When to Create a Changeset
459+
460+
**CREATE a changeset when:**
461+
462+
- ✅ Adding new public functions, classes, or methods
463+
- ✅ Modifying signatures of exported functions/methods
464+
- ✅ Adding/removing/changing public exports
465+
- ✅ Fixing bugs that affect user-facing behavior
466+
- ✅ Changing the behavior of existing APIs
467+
- ✅ Adding new features users can utilize
468+
- ✅ Deprecating or removing public APIs
469+
470+
**DO NOT create a changeset for:**
471+
472+
- ❌ Internal refactoring (no API changes)
473+
- ❌ Test-only changes
474+
- ❌ Documentation updates (unless they reflect API changes)
475+
- ❌ Build configuration changes
476+
- ❌ Changes to dev dependencies
477+
- ❌ Code formatting or linting fixes
478+
- ❌ Internal helper functions not exported
479+
480+
### Determining the Bump Type
481+
482+
Follow [Semantic Versioning](https://semver.org/):
483+
484+
**PATCH (0.0.X) - Bug Fixes**
485+
486+
- Bug fixes in existing APIs
487+
- Performance improvements
488+
- Internal refactoring (if it fixes user-facing issues)
489+
490+
```markdown
491+
---
492+
"nostrudel": patch
493+
---
494+
495+
Fix memory leak in event handler cleanup
496+
```
497+
498+
**MINOR (0.X.0) - New Features (Backwards Compatible)**
499+
500+
- New public functions/classes/methods
501+
- New optional parameters
502+
- New exports
503+
- Deprecation warnings (not removal)
504+
505+
```markdown
506+
---
507+
"nostrudel": minor
508+
---
509+
510+
Add `getGroupMembers()` method to retrieve all members in a group
511+
```
512+
513+
**MAJOR (X.0.0) - Breaking Changes**
514+
515+
- Removing public APIs
516+
- Changing required parameters
517+
- Removing/renaming exports
518+
- Incompatible behavior changes
519+
520+
```markdown
521+
---
522+
"nostrudel": major
523+
---
524+
525+
**Breaking:** Remove deprecated `sendMessage()` method. Use `send()` instead.
526+
```
527+
528+
### One Changeset Per Logical Change
529+
530+
**IMPORTANT: When a single PR or commit contains multiple distinct user-facing changes, create one changeset per change — not one combined changeset.**
531+
532+
Each changeset should describe exactly one thing. This keeps the generated changelog readable: entries map to individual features, fixes, or breaking changes rather than a mixed list.
533+
534+
```bash
535+
# Example: a PR that adds a new method AND removes a deprecated one
536+
pnpm changeset add --empty # changeset 1: minor — Add foo() method
537+
pnpm changeset add --empty # changeset 2: major — Remove deprecated bar() method
538+
```
539+
540+
Multiple changesets are combined automatically at release time; separate entries produce cleaner per-item changelog lines.
541+
542+
### How to Create a Changeset
543+
544+
**IMPORTANT: Always use the CLI to create changesets. Never manually create changeset files.**
545+
546+
Use the `pnpm changeset add` command with the `--empty` flag to create a changeset template:
547+
548+
```bash
549+
pnpm changeset add --empty
550+
```
551+
552+
This will:
553+
554+
1. Create a new changeset file with a randomly generated name (e.g., `.changeset/funny-cats-smile.md`)
555+
2. Generate an empty template that you can then edit
556+
557+
After the file is created, you'll see output like:
558+
559+
```
560+
🦋 Empty Changeset added! - you can now commit it
561+
🦋 info /home/user/project/.changeset/funny-cats-smile.md
562+
```
563+
564+
Then, edit the generated file to add the package name, bump type, and **a single line description**:
565+
566+
```markdown
567+
---
568+
"nostrudel": minor
569+
---
570+
571+
Add support for encrypted group messaging
572+
```
573+
574+
**Important Guidelines:**
575+
576+
- Keep the description to a **single line of text**
577+
- This ensures it fits cleanly into the changelog
578+
- Be concise but descriptive
579+
580+
**Why use the CLI?**
581+
582+
- Ensures correct file naming and format
583+
- Prevents formatting errors
584+
- Follows the project's changeset conventions
585+
586+
### Changeset Writing Guidelines
587+
588+
**User-Facing Language:** Write for library users, not developers:
589+
590+
- ✅ "Add `maxRetries` option to connection configuration"
591+
- ❌ "Implement retry logic in ConnectionManager class"
592+
593+
**Action-Oriented:** Start with a verb:
594+
595+
- **Add:** New features
596+
- **Fix:** Bug fixes
597+
- **Update:** Improvements
598+
- **Remove:** Deleted features
599+
- **Change:** Modified behavior
600+
601+
**Be Specific:**
602+
603+
- ✅ "Fix reconnection failure after network timeout"
604+
- ❌ "Fix bug"
605+
606+
**Single Line Only:**
607+
608+
- ✅ "Add group management methods including mute, pin, and stats"
609+
- ❌ Multi-line descriptions with bullet points (these don't format well in changelogs)
610+
611+
### Workflow Integration
612+
613+
When making changes that affect the public API:
614+
615+
1. Make your code changes
616+
2. Run `pnpm format` to format code
617+
3. Run `pnpm test` to ensure tests pass
618+
4. Run `pnpm build` to verify compilation
619+
5. **Create a changeset using `pnpm changeset add --empty`** if the change is user-facing
620+
6. Edit the generated changeset file to add package name, bump type, and **a single line description**
621+
7. Commit both your changes AND the changeset file
622+
623+
```bash
624+
# After making changes to public API
625+
pnpm changeset add --empty
626+
# This creates .changeset/some-random-name.md
627+
628+
# Edit the file to add your changeset details
629+
# Then commit everything together
630+
git add .
631+
git commit -m "Add group encryption feature"
632+
# Both code changes and the changeset file are committed together
633+
```
634+
635+
### Example Scenarios
636+
637+
**Scenario 1: Adding a new public method**
638+
639+
```typescript
640+
// In src/client/marmot-client.ts
641+
export class MarmotClient {
642+
// New method added
643+
public async getGroupInfo(groupId: string): Promise<GroupInfo> {}
644+
}
645+
```
646+
647+
Run `pnpm changeset add --empty`, then edit the generated file:
648+
649+
```markdown
650+
---
651+
"nostrudel": minor
652+
---
653+
654+
Add getGroupInfo() method to retrieve group metadata
655+
```
656+
657+
**Scenario 2: Fixing a bug**
658+
659+
```typescript
660+
// Fixed: Connection now properly retries on timeout
661+
```
662+
663+
Run `pnpm changeset add --empty`, then edit the generated file:
664+
665+
```markdown
666+
---
667+
"nostrudel": patch
668+
---
669+
670+
Fix connection retry logic to handle network timeouts
671+
```
672+
673+
**Scenario 3: Breaking change**
674+
675+
```typescript
676+
// Changed signature from:
677+
// createGroup(name: string, relays: string[])
678+
// to:
679+
// createGroup(options: CreateGroupOptions)
680+
```
681+
682+
Run `pnpm changeset add --empty`, then edit the generated file:
683+
684+
```markdown
685+
---
686+
"nostrudel": major
687+
---
688+
689+
Change createGroup() to accept options object instead of positional arguments
690+
```
691+
692+
### Additional Notes
693+
694+
- Changeset files are consumed during the release process by maintainers
695+
- Multiple changesets can exist and will be combined during version bumping
696+
- See `.changeset/README.md` for comprehensive documentation
697+
- The configuration uses `master` as the base branch

0 commit comments

Comments
 (0)