Skip to content

Commit 34c22ee

Browse files
committed
skills and formatting
1 parent 02607ad commit 34c22ee

File tree

13 files changed

+150
-237
lines changed

13 files changed

+150
-237
lines changed

.claude/shared/rust-and-go.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!-- This is referenced from the rust and go skills -->
2+
3+
## Rust and Go Implementation Guidelines
4+
5+
The `rust/` and `go/` directories contain parallel re-implementations of beachball's `check` and `change` commands and the corresponding tests.
6+
7+
### Scope
8+
9+
Implemented:
10+
11+
- CLI args (as relevant for supported commands)
12+
- JSON config loading (`.beachballrc.json` and `package.json` `"beachball"` field)
13+
- workspaces detection (npm, yarn, pnpm, rush, lerna)
14+
- `getChangedPackages` (git diff + file-to-package mapping + change file dedup)
15+
- `validate()` (minus `bumpInMemory`/dependency validation)
16+
- non-interactive `change` command (`--type` + `--message`)
17+
- `check` command.
18+
19+
Not implemented:
20+
21+
- JS config files
22+
- interactive prompts
23+
- all bumping and publishing operations
24+
- sync
25+
26+
### Implementation requirements
27+
28+
The behavior, log messages, and tests as specified in the TypeScript code MUST BE MATCHED in the Go/Rust code.
29+
30+
- Do not change behavior or logs or remove tests, unless it's exclusively related to features which you've been asked not to implement yet.
31+
- If a different pattern would be more idiomatic in the target language, or it's not possible to implement the exact same behavior in the target language, ask the user before changing anything.
32+
- Don't make assumptions about the implementation of functions from `workspace-tools`. Check the JS implementation in `node_modules` and exactly follow that.
33+
34+
When porting tests, add a comment by each Rust/Go test with the name of the corresponding TS test. If any TS tests have been omitted or combined, add a comment indicating which tests and why.
35+
36+
Use syntax and helpers from the newest version of the language where it makes sense. If a particular scenario is most commonly handled in this language by some external library, and the library would meaningfully simplify the code, ask the user about adding the library as a dependency.
37+
38+
After making changes, run the commands to build, test, lint, and format.
39+
40+
### Key Implementation Details
41+
42+
**Git commands**: Both shell out to `git` (matching the TS approach via workspace-tools). The git flags used should exactly match the workspace-tools code. Three-dot range (`branch...`) is used for diffs.
43+
44+
**Config loading**: Searches `.beachballrc.json` then `package.json` `"beachball"` field, walking up from cwd but stopping at git root.
45+
46+
**Glob matching**: Two modes matching the TS behavior — `matchBase` (patterns without `/` match basename) for `ignorePatterns`, full path matching for `scope`/`groups`.
47+
48+
### Known Gotchas
49+
50+
- **macOS `/tmp` symlink**: `/tmp` is a symlink to `/private/tmp`. `git rev-parse --show-toplevel` resolves symlinks but `tempfile`/`os.MkdirTemp` does not. Both implementations canonicalize paths (`std::fs::canonicalize` in Rust, `filepath.EvalSymlinks` in Go) when comparing git-returned paths with filesystem paths.
51+
- **Default branch name**: Modern git defaults to `main`. Test fixtures use `--initial-branch=master` for bare repo init to match the `origin/master` refs used in tests.

.claude/skills/go-impl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: go-impl
3+
description: |
4+
Go implementation guide for beachball's Go port.
5+
TRIGGER when: user asks to edit, write, test, or debug Go code under the go/ directory, or opens/references go/*.go files.
6+
DO NOT TRIGGER when: working only with TypeScript or Rust code.
7+
---
8+
9+
!`cat go/README.md`
10+
11+
!`cat .claude/skills/rust-and-go.md`

.claude/skills/rust-impl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: rust-impl
3+
description: |
4+
Rust implementation guide for beachball's Rust port.
5+
TRIGGER when: user asks to edit, write, test, or debug Rust code under the rust/ directory, or opens/references rust/*.rs files.
6+
DO NOT TRIGGER when: working only with TypeScript or Go code.
7+
---
8+
9+
!`cat rust/README.md`
10+
11+
!`cat .claude/skills/rust-and-go.md`

.github/workflows/pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ jobs:
120120
working-directory: ./rust
121121
if: ${{ matrix.os == 'ubuntu-latest' }}
122122

123-
- name: Lint
124-
run: cargo clippy --all-targets -- -D warnings
125-
working-directory: ./rust
126-
127123
- name: Build
128124
run: cargo build
129125
working-directory: ./rust
130126

127+
- name: Lint
128+
run: cargo clippy --all-targets -- -D warnings
129+
working-directory: ./rust
130+
131131
- name: Test
132132
run: cargo test
133133
working-directory: ./rust
@@ -162,14 +162,14 @@ jobs:
162162
working-directory: ./go
163163
if: ${{ matrix.os == 'ubuntu-latest' }}
164164

165-
- name: Lint
166-
run: go vet ./...
167-
working-directory: ./go
168-
169165
- name: Build
170166
run: go build ./...
171167
working-directory: ./go
172168

169+
- name: Lint
170+
run: go vet ./...
171+
working-directory: ./go
172+
173173
- name: Test
174174
run: go test ./...
175175
working-directory: ./go

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package-lock.json
99
# ignore when switching between yarn 1/4 branches
1010
/.yarn
1111
rust/target
12+
go/beachball
1213
.claude/settings.local.json
1314

1415
docs/.vuepress/.cache

.prettierignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ LICENSE
1616
node_modules/
1717
SECURITY.md
1818
yarn.lock
19-
rust/
20-
go/
19+
rust/**
20+
!rust/README.md
21+
go/**
22+
!go/README.md

CLAUDE.md

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,13 @@ Multi-pass algorithm that calculates version bumps. See comments in file.
8787

8888
- Change files stored in `change/` directory track intended version changes
8989
- See `src/types/ChangeInfo.ts` `ChangeFileInfo` for the info stored in each change file. For grouped change files (config has `groupChanges: true`), the type will be `ChangeInfoMultiple`.
90-
- `readChangeFiles()` - Loads and validates from disk
91-
- `writeChangeFiles()` - Persists new change files
92-
- `unlinkChangeFiles()` - Deletes after consumption during bump
90+
- Folder contains helper to read, write, and unlink change files
9391

9492
**Publishing** (`src/publish/`):
9593

9694
- `publishToRegistry()` - Validates, applies publishConfig, runs hooks, publishes (respects dependency order)
9795
- `bumpAndPush()` - Git operations: creates temp `publish_*` branch, fetches, merges, bumps, commits, tags, pushes
98-
- Pre/post hooks available: `prebump`, `postbump`, `prepublish`, `postpublish`, `precommit`
96+
- Pre/post hooks available (see `HooksOptions` in `src/types/BeachballOptions.ts`)
9997

10098
**Context Passing:**
10199
`CommandContext` aggregates reusable data (packages, version groups, change files, and more) to avoid repeated calculations. See source in `src/types/CommandContext.ts`.
@@ -143,7 +141,7 @@ Multi-pass algorithm that calculates version bumps. See comments in file.
143141

144142
**Testing Structure:**
145143

146-
- Fixtures: `__fixtures__` directory
144+
- Fixtures and helpers: `__fixtures__/` directory
147145
- Unit tests: `__tests__/` directory
148146
- Functional tests: `__functional__/` directory
149147
- E2E tests: `__e2e__/` directory
@@ -164,69 +162,4 @@ Multi-pass algorithm that calculates version bumps. See comments in file.
164162

165163
## Experimental: Rust and Go Implementations
166164

167-
The `rust/` and `go/` directories contain parallel re-implementations of beachball's `check` and `change` commands and the corresponding tests.
168-
169-
### Building and Testing
170-
171-
```bash
172-
# Rust (from rust/ directory)
173-
cargo build
174-
cargo test
175-
176-
# Go (from go/ directory)
177-
go build ./...
178-
go test ./...
179-
```
180-
181-
### Scope
182-
183-
Both implement:
184-
185-
- CLI args (as relevant for supported commands)
186-
- JSON config loading (`.beachballrc.json` and `package.json` `"beachball"` field)
187-
- workspaces detection (npm, yarn, pnpm, rush, lerna)
188-
- `getChangedPackages` (git diff + file-to-package mapping + change file dedup)
189-
- `validate()` (minus `bumpInMemory`/dependency validation)
190-
- non-interactive `change` command (`--type` + `--message`)
191-
- `check` command.
192-
193-
Not implemented:
194-
195-
- JS config files
196-
- interactive prompts
197-
- all bumping and publishing operations
198-
- sync
199-
200-
### Implementation requirements
201-
202-
The behavior, log messages, and tests as specified in the TypeScript code MUST BE MATCHED in the Go/Rust code.
203-
204-
- Do not change behavior or logs or remove tests, unless it's exclusively related to features which you've been asked not to implement yet.
205-
- If a different pattern would be more idiomatic in the target language, or it's not possible to implement the exact same behavior in the target language, ask the user before changing anything.
206-
- Don't make assumptions about the implementation of functions from `workspace-tools`. Check the JS implementation in `node_modules` and exactly follow that.
207-
208-
When porting tests, add a comment by each Rust/Go test with the name of the corresponding TS test. If any TS tests have been omitted or combined, add a comment indicating which tests and why.
209-
210-
Use syntax and helpers from the newest version of the language where it makes sense. If a particular scenario is most commonly handled in this language by some external library, and the library would meaningfully simplify the code, ask the user about adding the library as a dependency.
211-
212-
Where possible, use the LSP instead of grep to understand the code. Also use the LSP to check for errors after making changes.
213-
214-
After making changes, run the commands to build, test, lint, and format.
215-
216-
### Structure
217-
218-
- **Rust**: `src/` with nested modules, integration tests in `tests/` with shared helpers in `tests/common/`
219-
- **Go**: `cmd/beachball/` CLI entry, `internal/` packages, test helpers in `internal/testutil/`, tests alongside source (`_test.go`)
220-
221-
### Key Implementation Details
222-
223-
**Git commands**: Both shell out to `git` (matching the TS approach via workspace-tools). The git flags used should exactly match the workspace-tools code. Three-dot range (`branch...`) is used for diffs.
224-
225-
**Config loading**: Searches `.beachballrc.json` then `package.json` `"beachball"` field, walking up from cwd but stopping at git root.
226-
227-
**Glob matching**: Two modes matching the TS behavior — `matchBase` (patterns without `/` match basename) for `ignorePatterns`, full path matching for `scope`/`groups`.
228-
229-
### Known Gotchas
230-
231-
- **macOS `/tmp` symlink**: `/tmp` is a symlink to `/private/tmp`. `git rev-parse --show-toplevel` resolves symlinks but `tempfile`/`os.MkdirTemp` does not. Both implementations canonicalize paths (`std::fs::canonicalize` in Rust, `filepath.EvalSymlinks` in Go) when comparing git-returned paths with filesystem paths.
232-
- **Default branch name**: Modern git defaults to `main`. Test fixtures use `--initial-branch=master` for bare repo init to match the `origin/master` refs used in tests.
165+
The `rust/` and `go/` directories contain experimental parallel re-implementations. See the `go-impl` and `rust-impl` custom skills as relevant.

go/README.md

Lines changed: 16 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
A Go re-implementation of beachball's `check` and `change` commands.
44

5+
<!-- See .claude/shared/rust-and-go.md for details of what's implemented or not -->
6+
57
## Prerequisites
68

7-
- Go 1.23+
9+
- Go 1.26+
810
- `git` on PATH
911

1012
## Building
@@ -68,81 +70,23 @@ Or after building:
6870

6971
## CLI Options
7072

71-
```
72-
beachball check [flags]
73-
beachball change [flags]
74-
75-
Flags:
76-
-b, --branch string Target branch (default: origin/master)
77-
--path string Path to the repository
78-
-t, --type string Change type: patch, minor, major, none, etc.
79-
-m, --message string Change description
80-
--all Include all packages
81-
--verbose Verbose output
82-
--config-path string Path to beachball config
83-
```
84-
85-
## What's Implemented
86-
87-
- CLI parsing (cobra)
88-
- JSON config loading (`.beachballrc.json`, `package.json` `"beachball"` field)
89-
- Workspace detection (npm/yarn `workspaces` field)
90-
- `getChangedPackages` (git diff + file-to-package mapping + change file dedup)
91-
- `validate()` (minus `bumpInMemory`/dependency validation)
92-
- Non-interactive `change` command (`--type` + `--message`)
93-
- `check` command
94-
95-
## What's Not Implemented
96-
97-
- JS config files (`beachball.config.js`)
98-
- Interactive prompts
99-
- `bumpInMemory` / dependency validation
100-
- `publish`, `bump`, `canary`, `sync` commands
101-
- Changelog generation
102-
- pnpm/rush/lerna workspace detection
73+
Currently the `check` command and non-interactive `change` command have been implemented. Options should be the same as JS Beachball.
10374

10475
## Project Structure
10576

77+
Tests (`*_test.go`) live alongside the corresponding files.
78+
10679
```
10780
cmd/beachball/
108-
main.go # CLI entry point (cobra)
81+
main.go # CLI entry point (cobra)
10982
internal/
110-
types/
111-
change_info.go # ChangeType, ChangeFileInfo, ChangeSet
112-
package_info.go # PackageJson, PackageInfo, PackageGroups
113-
options.go # BeachballOptions, CliOptions
114-
options/
115-
get_options.go # Option merging
116-
repo_options.go # Config file loading
117-
git/
118-
commands.go # Git operations (shell out to git)
119-
helpers.go # File/workspace helpers
120-
ensure_shared_history.go # Fetch/deepen for shallow clones
121-
monorepo/
122-
package_infos.go # Package discovery
123-
scoped_packages.go # Scope filtering
124-
package_groups.go # Version group resolution
125-
filter_ignored.go # Ignore pattern matching
126-
changefile/
127-
changed_packages.go # Changed package detection
128-
changed_packages_test.go # 11 tests
129-
read_change_files.go # Read change files from disk
130-
write_change_files.go # Write change files
131-
change_types.go # Disallowed type resolution
132-
validation/
133-
validate.go # Main validation logic
134-
validate_test.go # 3 tests
135-
validators.go # Type/auth validators
136-
are_change_files_deleted.go # Deleted change file detection
137-
commands/
138-
check.go # Check command
139-
change.go # Change command
140-
change_test.go # 2 tests
141-
logging/
142-
logging.go # Output helpers
143-
testutil/
144-
repository.go # Test git repo wrapper
145-
repository_factory.go # Bare repo + clone factory
146-
fixtures.go # Fixture setup helpers
147-
change_files.go # Test change file helpers
83+
types/ # Basic types
84+
options/ # Option merging, config file loading
85+
git/ # Git operations (shell out to git)
86+
monorepo/ # Package discovery, groups, filtering
87+
changefile/ # Change file handling, changed package detection
88+
validation/ # Validation
89+
commands/ # Main commands
90+
logging/ # Output helpers
91+
testutil/ # Test helpers
14892
```

0 commit comments

Comments
 (0)