diff --git a/.github/README.md b/.github/README.md index 074c511..b5fba6e 100644 --- a/.github/README.md +++ b/.github/README.md @@ -63,7 +63,7 @@ This directory contains the GitHub Actions workflows for the Amber CLI project, ## Caching Strategy The workflows use GitHub Actions caching to speed up builds: -- **Shard cache**: Caches `~/.cache/shards` and `./lib` based on `shard.lock` hash +- **Shard cache**: Caches `~/.cache/shards` based on `shard.lock` hash. `./lib` stays out of it, because Minecart stops on a shard in `lib/` that `shard.lock` does not pin, and an older cache can restore one - **OS-specific**: Separate caches for each operating system ## Usage diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4bf81e5..be4d659 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,6 @@ jobs: with: path: | ~/.cache/shards - ./lib key: ${{ runner.os }}-shards-${{ hashFiles('shard.lock') }} restore-keys: | ${{ runner.os }}-shards- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93c7151..b49cdb7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,6 @@ jobs: with: path: | ~/.cache/shards - ./lib key: ${{ runner.os }}-shards-${{ hashFiles('shard.lock') }} restore-keys: | ${{ runner.os }}-shards- @@ -124,7 +123,6 @@ jobs: with: path: | ~/.cache/shards - ./lib key: ${{ runner.os }}-shards-${{ hashFiles('shard.lock') }} restore-keys: | ${{ runner.os }}-shards- diff --git a/.gitignore b/.gitignore index 20d531f..4b26dac 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ Thumbs.db /dist/ # The CLI is a distributed executable; commit shard.lock for reproducible builds. + +# Lookup cache the specs write +.luna/ diff --git a/README.md b/README.md index 8a66050..539080d 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,16 @@ [![GitHub release](https://img.shields.io/github/release/amberframework/amber_cli.svg)](https://github.com/amberframework/amber_cli/releases) [![Docs](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://amberframework.github.io/amber_cli/) -Amber CLI is the standalone command-line companion for Amber V2. CLI `2.0.9` -creates the supported Amber `2.0.0-beta.9` ECR web application and includes +Amber CLI is the standalone command-line companion for Amber V2. CLI `2.0.10` +creates the supported Amber `2.0.0-beta.10` ECR web application and includes development, generator, database, and LSP tooling. Its agent tooling also works in plain Crystal apps and shards; see [Agent tooling](#agent-tooling-for-any-crystal-project). Amber V2 is a beta. The release-gated path is a web application on Apple Silicon macOS, x86_64 Linux, or ARM64 Linux. Windows x86-64 passes the complete -generated-app smoke in CI, but has no release archive yet. See +generated-app smoke in CI, but has no release archive yet, and its `shard.lock` +checksums differ from those written on macOS and Linux. See [Generator support](docs/GENERATOR_SUPPORT.md) before relying on authentication, API-resource, or native output. @@ -41,13 +42,13 @@ are selected by the installed core catalog, not pinned by this tap. ### Direct release archive -The CLI `2.0.9` release has `darwin-arm64`, `linux-x86_64`, and +The CLI `2.0.10` release has `darwin-arm64`, `linux-x86_64`, and `linux-arm64` binary archives. A direct archive does not install Minecart or the native dependencies, so Homebrew is the beginner path. Windows x86-64 has no release archive. ```bash -version=v2.0.9 +version=v2.0.10 platform=darwin-arm64 asset="amber_cli-${platform}.tar.gz" @@ -78,7 +79,7 @@ amber watch ``` `amber new` runs Minecart by default. It writes exact root dependency pins, -a `shard.lock` with Git tree checksums, `.minecart-policy.yml`, and `.claude/` +a `shard.lock` with SHA-256 checksums, `.minecart-policy.yml`, and `.claude/` assistant files, plus each dependency's guides, then installs the Claude Code and Codex hooks and prints an `amber doctor` summary. Commit the generated files. With `--no-deps`, the first Minecart install and assistant setup are deliberately deferred; run `minecart @@ -89,8 +90,8 @@ or a file under `app/assets/` changes. Open . The web template is deliberately small: -- Amber from `amberframework/amber`, pinned to `2.0.0-beta.9` by commit - (`34a93352eaa89501d24e2b9ff90b058209a22720`), with its git tree (`f1e7332d02229aec58ab5303ade7fc6c9d14fcee`) checked in `shard.lock` +- Amber from `amberframework/amber`, pinned to `2.0.0-beta.10` by commit + (`d291e0930dd22b14a2d10f75a9de063abb0e64e4`), with its checksum (`sha256-v2:8d354db3b41625db0362162a34836fe10a8b11a378f3837d34cc6bbcece1cb94`) checked in `shard.lock` - ECR views (Slang and Kilt are not supported in Amber V2) - typed development, test, and production YAML - branded homepage, controller spec, and fingerprinted CSS, JavaScript, SVG, diff --git a/RELEASE_SETUP.md b/RELEASE_SETUP.md index b8dc394..9b8feb2 100644 --- a/RELEASE_SETUP.md +++ b/RELEASE_SETUP.md @@ -106,7 +106,7 @@ Publishing the release triggers the automated flow: 3. package the tagged source and publish its archive and checksum Before pushing the tap commit, download the published -`amber_cli-source-2.0.9.tar.gz` archive, verify its sidecar checksum, and compare +`amber_cli-source-2.0.10.tar.gz` archive, verify its sidecar checksum, and compare its SHA-256 with `Formula/amber_cli.rb`. The CI-generated gzip archive can have different bytes from a local archive of the same commit, so update the formula to the published asset hash when they differ. Then run the tap smoke diff --git a/docs/BETA_WEB_APP.md b/docs/BETA_WEB_APP.md index 36184b1..7106c7c 100644 --- a/docs/BETA_WEB_APP.md +++ b/docs/BETA_WEB_APP.md @@ -1,8 +1,10 @@ # Amber V2 Beta Web App -This guide is the consumer smoke test for Amber CLI `2.0.9` and Amber -`2.0.0-beta.9`. It is expected to pass on Apple Silicon macOS, x86_64 Linux, -and ARM64 Linux. Windows x86-64 runs the complete generated-app smoke in CI. +This guide is the consumer smoke test for Amber CLI `2.0.10` and Amber +`2.0.0-beta.10`. It is expected to pass on Apple Silicon macOS, x86_64 Linux, +and ARM64 Linux. Windows x86-64 runs the complete generated-app smoke in CI. A +`shard.lock` written on Windows records different `sha256-v2:` values from one +written on macOS or Linux, so a team on both needs a lock for each. ## 1. Verify the toolchain @@ -12,7 +14,7 @@ minecart --version amber --version ``` -Crystal must be at least 1.20 and earlier than 2.0. Amber CLI must be 2.0.9 or +Crystal must be at least 1.20 and earlier than 2.0. Amber CLI must be 2.0.10 or newer. ## 2. Generate the web app @@ -33,7 +35,7 @@ grep -E '^(template|database|model):' .amber.yml ``` The dependency must be `amberframework/amber` at commit -`34a93352eaa89501d24e2b9ff90b058209a22720` (`v2.0.0-beta.9`); the +`d291e0930dd22b14a2d10f75a9de063abb0e64e4` (`v2.0.0-beta.10`); the template must be `ecr`, the database must be `sqlite`, and the model layer must be `grant`. `shard.yml` must include Grant, Asset Pipeline, and `crystal-sqlite3`, but it must not include Gemma, Slang, PostgreSQL, or MySQL diff --git a/docs/ONBOARDING.md b/docs/ONBOARDING.md index c7f458f..790b921 100644 --- a/docs/ONBOARDING.md +++ b/docs/ONBOARDING.md @@ -2,8 +2,8 @@ This page takes a new developer from a bare machine to an Amber V2 app with checksum-verified dependencies, and with editor and coding-assistant rules active -from the first edit. It covers Amber CLI 2.0.9, Amber 2.0.0-beta.9 and Minecart -2025.11.25.8 on Apple Silicon macOS and Linux. +from the first edit. It covers Amber CLI 2.0.10, Amber 2.0.0-beta.10 and Minecart +2025.11.25.9 on Apple Silicon macOS and Linux. ## What you get @@ -13,7 +13,7 @@ from the first edit. It covers Amber CLI 2.0.9, Amber 2.0.0-beta.9 and Minecart | `amber-lsp` | Language server, API lookup and rule checks | Same formula | | `minecart` | Installs dependencies and verifies their checksums | Dependency of the formula | | Crystal | Compiles the app | Dependency of the formula | -| Amber 2.0.0-beta.9 | The framework, its rule pack and its guides | Pinned in each new app | +| Amber 2.0.0-beta.10 | The framework, its rule pack and its guides | Pinned in each new app | | Grant | The ORM and its tenancy rule pack | Pinned in each new app | | Asset Pipeline | CSS, JavaScript and image assets | Pinned in each new app | | micrate | Database migrations | Built into `amber database` | @@ -36,9 +36,9 @@ HOMEBREW_NO_AUTO_UPDATE=1 brew install amberframework/amber_cli/amber_cli Check the result: ```bash -amber --version # Amber CLI v2.0.9 -amber-lsp --version # amber-lsp 1.0.0 (amber_cli 2.0.9, ...) -minecart --version # Minecart 2025.11.25.8 +amber --version # Amber CLI v2.0.10 +amber-lsp --version # amber-lsp 1.0.0 (amber_cli 2.0.10, ...) +minecart --version # Minecart 2025.11.25.9 ``` ### Optional: the Crystal Alpha compiler @@ -61,7 +61,7 @@ cd my_app amber doctor ``` -`amber new` pins every dependency, writes a `shard.lock` with Git tree checksums, +`amber new` pins every dependency, writes a `shard.lock` with SHA-256 checksums, installs the assistant guides and connects Claude Code and Codex to `amber-lsp`. SQLite is the default database, and it needs no server. Pass `-d pg` or `-d mysql` to choose another. @@ -187,14 +187,14 @@ Pin the release's commit and move the lock: dependencies: amber: github: amberframework/amber - commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9 + commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10 ``` ```bash minecart update amber -grep -A2 '^ amber:' shard.lock # checksum: git-tree:f1e7332d02229aec58ab5303ade7fc6c9d14fcee +grep -A2 '^ amber:' shard.lock # checksum: sha256-v2:8d354db3b41625db0362162a34836fe10a8b11a378f3837d34cc6bbcece1cb94 amber setup:agent ``` Then read the -[beta.9 release notes](https://github.com/amberframework/amber/blob/v2.0.0-beta.9/RELEASE_NOTES_V2_BETA9.md). +[beta.10 release notes](https://github.com/amberframework/amber/blob/v2.0.0-beta.10/RELEASE_NOTES_V2_BETA10.md). diff --git a/docs/RELEASE_CHECKLIST.md b/docs/RELEASE_CHECKLIST.md index 15e4689..b23d08d 100644 --- a/docs/RELEASE_CHECKLIST.md +++ b/docs/RELEASE_CHECKLIST.md @@ -5,16 +5,16 @@ Homebrew formula pins Amber and Minecart source archives and checksums. ## 1. Framework prerequisite -1. Confirm the published `v2.0.0-beta.9` prerelease has its source archive and +1. Confirm the published `v2.0.0-beta.10` prerelease has its source archive and checksum and matches the generated app's exact framework pin. 2. Check the framework's migration and support-matrix links. ## 2. CLI release -1. Confirm `shard.yml` and `AmberCLI::VERSION` both say `2.0.9`. +1. Confirm `shard.yml` and `AmberCLI::VERSION` both say `2.0.10`. 2. Generate a web app and verify it pins the framework prerelease. 3. Verify the generated app pins the reviewed Asset Pipeline release exactly, - has a Minecart Git tree checksum for every dependency, and has assistant + has a Minecart SHA-256 checksum for every dependency, and has assistant files. 4. On macOS, x86-64 Linux, and ARM64 Linux, run `minecart install --frozen`; run `amber assets build` and `amber assets check`; run app specs; build and start @@ -27,7 +27,7 @@ Homebrew formula pins Amber and Minecart source archives and checksums. 7. Confirm the Windows x86-64 generated app passes its full CI smoke, including launch and asset probes. This is a generated-app release gate, with no Windows archive yet. -8. Tag `v2.0.9`, publish the release, and wait for the binary and source +8. Tag `v2.0.10`, publish the release, and wait for the binary and source archives and checksum files to upload. Compare the published source archive hash with the reviewed Homebrew formula before pushing the tap. diff --git a/scripts/check_beta_contract.sh b/scripts/check_beta_contract.sh index dcac74a..e8c0e62 100755 --- a/scripts/check_beta_contract.sh +++ b/scripts/check_beta_contract.sh @@ -3,13 +3,14 @@ set -euo pipefail shard_version="$(awk '/^version:/ { print $2; exit }' shard.yml)" cli_version="$(sed -n 's/.*VERSION = "\([^"]*\)".*/\1/p' src/amber_cli.cr | head -1)" -test "$shard_version" = "2.0.9" +test "$shard_version" = "2.0.10" test "$cli_version" = "$shard_version" grep -F 'github: amberframework/amber' src/amber_cli/commands/new_command.cr -grep -F 'commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9' src/amber_cli/commands/new_command.cr -grep -F 'COMMIT = "34a93352eaa89501d24e2b9ff90b058209a22720"' src/amber_cli/amber_release.cr -grep -F 'TREE = "f1e7332d02229aec58ab5303ade7fc6c9d14fcee"' src/amber_cli/amber_release.cr +grep -F 'commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10' src/amber_cli/commands/new_command.cr +grep -F 'COMMIT = "d291e0930dd22b14a2d10f75a9de063abb0e64e4"' src/amber_cli/amber_release.cr +grep -F 'TREE = "fb4574c6b15b60357abd43ed0a1a8d7a0957e574"' src/amber_cli/amber_release.cr +grep -F 'CHECKSUM = "sha256-v2:8d354db3b41625db0362162a34836fe10a8b11a378f3837d34cc6bbcece1cb94"' src/amber_cli/amber_release.cr grep -F 'template: ecr' src/amber_cli/commands/new_command.cr grep -F 'model: grant' src/amber_cli/commands/new_command.cr grep -F 'database: #{database}' src/amber_cli/commands/new_command.cr @@ -19,7 +20,7 @@ grep -F 'version: 0.37.1' src/amber_cli/commands/new_command.cr grep -F 'github: amberframework/asset_pipeline' src/amber_cli/templates/app/shard.yml.ecr grep -F 'version: 0.37.1' src/amber_cli/templates/app/shard.yml.ecr grep -F 'github: amberframework/amber' src/amber_cli/generators/native_app.cr -grep -F 'commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9' src/amber_cli/generators/native_app.cr +grep -F 'commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10' src/amber_cli/generators/native_app.cr grep -F 'version: ~> 0.37.1' src/amber_cli/generators/native_app.cr if grep -F 'branch:' src/amber_cli/generators/native_app.cr; then echo "native app template contains a mutable dependency branch" >&2 diff --git a/scripts/install_pinned_minecart.ps1 b/scripts/install_pinned_minecart.ps1 index 486da0f..998ed66 100644 --- a/scripts/install_pinned_minecart.ps1 +++ b/scripts/install_pinned_minecart.ps1 @@ -1,7 +1,7 @@ $ErrorActionPreference = "Stop" -$minecartCommit = "0ffac921c68774ea143aeaa83c369d0a38c2d3e5" -$minecartTree = "f0e8a69bffe22afd0cee9b24994bde629384f093" +$minecartCommit = "ec4ec4d4434a92308f99de11ac907fc8a21e7a79" +$minecartTree = "dd6c0d1cfdfe1c1b78dd515a3117088b31416f2e" $installRoot = Join-Path $env:RUNNER_TEMP "amber-pinned-minecart" New-Item -ItemType Directory -Force $installRoot | Out-Null @@ -24,7 +24,7 @@ try { & crystal build src/shards.cr -o bin/minecart.exe if ($LASTEXITCODE -ne 0) { throw "Minecart build failed" } $minecartVersion = (& ./bin/minecart.exe --version).Trim() - if ($minecartVersion -notlike "Minecart 2025.11.25.8*") { + if ($minecartVersion -notlike "Minecart 2025.11.25.9*") { throw "Built Minecart version did not match the pin: $minecartVersion" } } finally { diff --git a/scripts/install_pinned_minecart.sh b/scripts/install_pinned_minecart.sh index ccbdcac..3f99d5f 100755 --- a/scripts/install_pinned_minecart.sh +++ b/scripts/install_pinned_minecart.sh @@ -2,10 +2,10 @@ set -euo pipefail # The source commit is verified by its Git tree before it can run the web smoke. -minecart_commit=0ffac921c68774ea143aeaa83c369d0a38c2d3e5 -minecart_tree=f0e8a69bffe22afd0cee9b24994bde629384f093 +minecart_commit=ec4ec4d4434a92308f99de11ac907fc8a21e7a79 +minecart_tree=dd6c0d1cfdfe1c1b78dd515a3117088b31416f2e minecart_repository="${MINECART_SOURCE_REPOSITORY:-https://github.com/crimson-knight/shards.git}" -minecart_source_ref="${MINECART_SOURCE_REF:-refs/tags/v2025.11.25.8}" +minecart_source_ref="${MINECART_SOURCE_REF:-refs/tags/v2025.11.25.9}" install_root="${RUNNER_TEMP:-${TMPDIR:-/tmp}}/amber-pinned-minecart" mkdir -p "$install_root" @@ -27,8 +27,8 @@ fi make -C "$install_root" bin/minecart bin/shards-alpha CRYSTAL="$CRYSTAL" test -x "$install_root/bin/minecart" test -x "$install_root/bin/shards-alpha" -"$install_root/bin/minecart" --version | grep -F "Minecart 2025.11.25.8" -"$install_root/bin/shards-alpha" --version | grep -F "Minecart 2025.11.25.8" +"$install_root/bin/minecart" --version | grep -F "Minecart 2025.11.25.9" +"$install_root/bin/shards-alpha" --version | grep -F "Minecart 2025.11.25.9" if [[ -n "${GITHUB_PATH:-}" ]]; then echo "$install_root/bin" >> "$GITHUB_PATH" diff --git a/scripts/smoke_generated_web.ps1 b/scripts/smoke_generated_web.ps1 index cb415e0..0ca98e9 100644 --- a/scripts/smoke_generated_web.ps1 +++ b/scripts/smoke_generated_web.ps1 @@ -43,7 +43,7 @@ $amberConfig = [System.IO.File]::ReadAllText($amberConfigPath) if (-not $manifest.Contains("github: amberframework/amber")) { throw "Generated shard.yml does not include Amber" } -if (-not $manifest.Contains("commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9")) { +if (-not $manifest.Contains("commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10")) { throw "Generated shard.yml does not pin the supported Amber beta" } if (-not $manifest.Contains("github: crimson-knight/grant")) { @@ -74,7 +74,7 @@ if (-not $amberConfig.Contains("database: sqlite") -or -not $amberConfig.Contain if ($FrameworkCommit) { $releasedRepository = " github: amberframework/amber" - $releasedFramework = " commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9" + $releasedFramework = " commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10" if (-not $manifest.Contains($releasedRepository)) { throw "Generated shard.yml does not contain the expected Amber repository" } @@ -103,11 +103,11 @@ try { $lock = [System.IO.File]::ReadAllText((Join-Path $appPath "shard.lock")) $entries = @([regex]::Split($lock, '(?m)^(?= [A-Za-z0-9_-]+:\r?$)') | Where-Object { $_ -match '^ [A-Za-z0-9_-]+:' }) if ($entries.Count -eq 0) { - throw "Minecart lock is missing a git-tree checksum for a dependency" + throw "Minecart lock is missing a checksum for a dependency" } foreach ($entry in $entries) { - if ([regex]::Matches($entry, '(?m)^ checksum: git-tree:[0-9a-f]{40}\r?$').Count -ne 1) { - throw "Minecart lock is missing a git-tree checksum for a dependency" + if ([regex]::Matches($entry, '(?m)^ checksum: sha256-v2:[0-9a-f]{64}\r?$').Count -ne 1) { + throw "Minecart lock is missing a checksum for a dependency" } } $amberEntry = $entries | Where-Object { $_ -match '^ amber:' } | Select-Object -First 1 @@ -118,7 +118,7 @@ try { $expectedAmberCommit = $FrameworkCommit $expectedAmberGit = "https://github.com/$FrameworkRepository.git" } else { - $expectedAmberCommit = "34a93352eaa89501d24e2b9ff90b058209a22720" + $expectedAmberCommit = "d291e0930dd22b14a2d10f75a9de063abb0e64e4" $expectedAmberGit = "https://github.com/amberframework/amber.git" } if ($amberEntry -notmatch "(?m)^ git: $([regex]::Escape($expectedAmberGit))\r?$") { @@ -127,9 +127,6 @@ try { if ($amberEntry -notmatch "(?m)^ version: \S+\+git\.commit\.$expectedAmberCommit\r?$") { throw "Minecart locked Amber at a commit other than $expectedAmberCommit" } - if (-not $FrameworkCommit -and $amberEntry -notmatch '(?m)^ checksum: git-tree:f1e7332d02229aec58ab5303ade7fc6c9d14fcee\r?$') { - throw "Minecart locked Amber with a tree other than f1e7332d02229aec58ab5303ade7fc6c9d14fcee" - } Invoke-Checked -Command $cliPath -Arguments @("assets", "build") Invoke-Checked -Command $cliPath -Arguments @("assets", "check") diff --git a/scripts/smoke_generated_web.sh b/scripts/smoke_generated_web.sh index e371cb9..46dc307 100755 --- a/scripts/smoke_generated_web.sh +++ b/scripts/smoke_generated_web.sh @@ -40,13 +40,13 @@ test -s "$app_path/shard.lock" grep -F 'minecart install --frozen' "$app_path/README.md" grep -F 'crystal spec' "$app_path/README.md" -grep -F 'git-tree:' "$app_path/README.md" +grep -F 'sha256-v2:' "$app_path/README.md" ! grep -F 'crystal-alpha' "$app_path/.amber.yml" grep -F 'AMBER_ENV=test crystal spec' "$script_dir/../src/amber_cli/templates/app/.amber.yml.ecr" ! grep -F 'crystal-alpha' "$script_dir/../src/amber_cli/templates/app/.amber.yml.ecr" grep -F "github: amberframework/amber" "$app_path/shard.yml" -grep -F "commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9" "$app_path/shard.yml" +grep -F "commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10" "$app_path/shard.yml" grep -F "github: crimson-knight/grant" "$app_path/shard.yml" grep -F "github: amberframework/asset_pipeline" "$app_path/shard.yml" grep -F "version: 0.37.1" "$app_path/shard.yml" @@ -68,7 +68,7 @@ fi if [[ -n "$framework_commit" ]]; then sed -i.bak -E "s# github: amberframework/amber# github: ${framework_repository}#" "$app_path/shard.yml" - sed -i.bak -E "s/ commit: 34a93352eaa89501d24e2b9ff90b058209a22720( # v[^ ]+)?$/ commit: ${framework_commit}/" "$app_path/shard.yml" + sed -i.bak -E "s/ commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4( # v[^ ]+)?$/ commit: ${framework_commit}/" "$app_path/shard.yml" rm -f "$app_path/shard.yml.bak" fi @@ -88,10 +88,10 @@ fi test -s shard.lock grep -F "version: 0.23.4+git.commit.6c9da3c8180e612f76ff9ad9c76242a0402ce6d9" shard.lock grep -F "version: 0.14.0" shard.lock -# Each shard entry carries exactly one git-tree checksum. +# Each shard entry carries exactly one checksum. awk ' /^ [[:alnum:]_-]+:$/ { if (entries > 0 && checksums != 1) bad = 1; entries++; checksums = 0; next } - /^ checksum: git-tree:[0-9a-f]{40}$/ { checksums++ } + /^ checksum: sha256-v2:[0-9a-f]{64}$/ { checksums++ } END { if (entries == 0 || checksums != 1 || bad) exit 1 } ' shard.lock # The Amber entry is the repository and commit this run asked for. @@ -100,14 +100,14 @@ if [[ -n "$framework_commit" ]]; then expected_amber_commit="$framework_commit" expected_amber_git="https://github.com/${framework_repository}.git" else - expected_amber_commit="34a93352eaa89501d24e2b9ff90b058209a22720" + expected_amber_commit="d291e0930dd22b14a2d10f75a9de063abb0e64e4" expected_amber_git="https://github.com/amberframework/amber.git" fi grep -qxF " git: ${expected_amber_git}" <<<"$amber_entry" grep -qE "^ version: [^ ]+\+git\.commit\.${expected_amber_commit}$" <<<"$amber_entry" if [[ -z "$framework_commit" ]]; then - grep -qxF " version: 2.0.0-beta.9+git.commit.34a93352eaa89501d24e2b9ff90b058209a22720" <<<"$amber_entry" - grep -qxF " checksum: git-tree:f1e7332d02229aec58ab5303ade7fc6c9d14fcee" <<<"$amber_entry" + grep -qxF " version: 2.0.0-beta.10+git.commit.d291e0930dd22b14a2d10f75a9de063abb0e64e4" <<<"$amber_entry" + grep -qxF " checksum: sha256-v2:8d354db3b41625db0362162a34836fe10a8b11a378f3837d34cc6bbcece1cb94" <<<"$amber_entry" fi "$cli_path" assets build "$cli_path" assets check diff --git a/shard.yml b/shard.yml index 2ffb6ac..55af3c8 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: amber_cli -version: 2.0.9 +version: 2.0.10 authors: - crimson-knight diff --git a/spec/commands/doctor_spec.cr b/spec/commands/doctor_spec.cr index a4a2e18..7310c0a 100644 --- a/spec/commands/doctor_spec.cr +++ b/spec/commands/doctor_spec.cr @@ -17,7 +17,7 @@ module DoctorCommandSpecHelper File.write(File.join(project_root, ".claude/settings.json"), claude_settings) File.write(File.join(project_root, ".codex/hooks.json"), codex_settings) setup_manifest = AmberCLI::Agent::AgentSetupManifest.new( - "2.0.9", + "2.0.10", "1.0.0", AmberCLI::Agent::AgentSetupGuidance::GENERATED_HOOK_VERSION, ) @@ -153,7 +153,7 @@ describe "amber doctor" do Dir.mkdir_p(File.join(project_root, ".amber")) old_guidance = "Before using a library API you are not sure of, run `amber-lsp lookup 'Type.method'`." File.write(File.join(project_root, ".amber/agent_setup.json"), <<-JSON) - {"amber_cli_version":"2.0.9","minimum_amber_lsp_version":"1.0.0","generated_hook_version":"5"} + {"amber_cli_version":"2.0.10","minimum_amber_lsp_version":"1.0.0","generated_hook_version":"5"} JSON File.write(File.join(project_root, ".amber/amber-agent-hook"), "#!/bin/sh\n#{old_guidance}\n") File.write(File.join(project_root, "CLAUDE.md"), "\n#{old_guidance}\n\n") diff --git a/spec/commands/new_command_spec.cr b/spec/commands/new_command_spec.cr index 98363da..3cbb0c5 100644 --- a/spec/commands/new_command_spec.cr +++ b/spec/commands/new_command_spec.cr @@ -30,7 +30,7 @@ describe AmberCLI::Commands::NewCommand do amber: git: https://github.com/amberframework/amber.git version: #{AmberCLI::AmberRelease::VERSION}+git.commit.#{AmberCLI::AmberRelease::COMMIT} - checksum: git-tree:#{AmberCLI::AmberRelease::TREE} + checksum: #{AmberCLI::AmberRelease::CHECKSUM} LOCK it "accepts a lock with Amber at the pinned commit and tree" do @@ -38,14 +38,22 @@ describe AmberCLI::Commands::NewCommand do AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).should be_nil end - it "rejects a lock whose Amber tree differs from the pinned release" do - other_tree = "0" * 40 - lock = "version: 2.0\nshards:\n#{amber_lock_entry.sub(AmberCLI::AmberRelease::TREE, other_tree)}\n" - problem = AmberCLI::Commands::NewCommand.minecart_lock_problem(lock) - problem.should_not be_nil - problem.to_s.should contain(AmberCLI::AmberRelease::TREE) + it "accepts the git-tree checksum an older Minecart records" do + older_entry = amber_lock_entry.sub(AmberCLI::AmberRelease::CHECKSUM, "git-tree:#{AmberCLI::AmberRelease::TREE}") + lock = "version: 2.0\nshards:\n#{older_entry}\n" + AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).should be_nil end + {% unless flag?(:win32) %} + it "rejects a lock whose Amber checksum differs from the pinned release" do + other_checksum = "sha256-v2:#{"0" * 64}" + lock = "version: 2.0\nshards:\n#{amber_lock_entry.sub(AmberCLI::AmberRelease::CHECKSUM, other_checksum)}\n" + problem = AmberCLI::Commands::NewCommand.minecart_lock_problem(lock) + problem.should_not be_nil + problem.to_s.should contain(AmberCLI::AmberRelease::CHECKSUM) + end + {% end %} + it "rejects a lock with Amber at another commit" do other_commit = "1" * 40 lock = "version: 2.0\nshards:\n#{amber_lock_entry.sub(AmberCLI::AmberRelease::COMMIT, other_commit)}\n" @@ -55,12 +63,12 @@ describe AmberCLI::Commands::NewCommand do it "rejects a lock where one entry has two checksums and another has none" do amber_with_two_checksums = amber_lock_entry + "\n checksum: git-tree:#{AmberCLI::AmberRelease::TREE}" lock = "version: 2.0\nshards:\n#{amber_with_two_checksums}\n grant:\n git: https://github.com/crimson-knight/grant.git\n version: 0.23.4\n" - AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).to_s.should contain("git-tree checksum") + AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).to_s.should contain("exactly one checksum") end - it "rejects a dependency without a git-tree checksum" do + it "rejects a dependency without a checksum" do lock = "version: 2.0\nshards:\n#{amber_lock_entry}\n grant:\n git: https://github.com/crimson-knight/grant.git\n version: 0.23.4\n" - AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).to_s.should contain("git-tree checksum") + AmberCLI::Commands::NewCommand.minecart_lock_problem(lock).to_s.should contain("exactly one checksum") end end @@ -182,7 +190,7 @@ describe AmberCLI::Commands::NewCommand do readme.should contain("minecart install --frozen") readme.should_not contain("--skip-ai-docs") readme.should contain("crystal spec") - readme.should contain("git-tree:") + readme.should contain("sha256-v2:") readme.should_not contain("shards install") amber_config_template = File.read(File.expand_path("../../src/amber_cli/templates/app/.amber.yml.ecr", __DIR__)) diff --git a/src/amber_cli.cr b/src/amber_cli.cr index 614a90d..ea149cf 100644 --- a/src/amber_cli.cr +++ b/src/amber_cli.cr @@ -42,7 +42,7 @@ end Log.builder.bind "*", :info, backend module AmberCLI - VERSION = "2.0.9" + VERSION = "2.0.10" def self.run(args = ARGV) if args.empty? diff --git a/src/amber_cli/amber_release.cr b/src/amber_cli/amber_release.cr index 38ca7e9..192405d 100644 --- a/src/amber_cli/amber_release.cr +++ b/src/amber_cli/amber_release.cr @@ -1,11 +1,13 @@ module AmberCLI # The Amber release that `amber new` writes into a new application's - # `shard.yml`, pinned by commit, and the git tree minecart must record as - # its checksum. A release of Amber CLI that moves to a new Amber release - # changes all three together. + # `shard.yml`, pinned by commit, and the checksums Minecart must record for + # it. A release of Amber CLI that moves to a new Amber release changes all of + # them together. module AmberRelease - VERSION = "2.0.0-beta.9" - COMMIT = "34a93352eaa89501d24e2b9ff90b058209a22720" - TREE = "f1e7332d02229aec58ab5303ade7fc6c9d14fcee" + VERSION = "2.0.0-beta.10" + COMMIT = "d291e0930dd22b14a2d10f75a9de063abb0e64e4" + TREE = "fb4574c6b15b60357abd43ed0a1a8d7a0957e574" + # What Minecart 2025.11.25.9 and newer record for this tree in `shard.lock`. + CHECKSUM = "sha256-v2:8d354db3b41625db0362162a34836fe10a8b11a378f3837d34cc6bbcece1cb94" end end diff --git a/src/amber_cli/commands/generate.cr b/src/amber_cli/commands/generate.cr index 5c66058..4b6f742 100644 --- a/src/amber_cli/commands/generate.cr +++ b/src/amber_cli/commands/generate.cr @@ -305,7 +305,7 @@ RETRIES # #{class_name}.new.enqueue(delay: 5.minutes) # #{class_name}.new.enqueue(queue: "critical") # -# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/guides/background-jobs.md +# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/guides/background-jobs.md class #{class_name} < Amber::Jobs::Job include JSON::Serializable @@ -403,7 +403,7 @@ METHOD # .subject("Welcome!") # .deliver # -# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/guides/mailer.md +# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/guides/mailer.md class #{class_name}Mailer < Amber::Mailer::Base def initialize(@user_name : String, @user_email : String) end @@ -609,7 +609,7 @@ SPEC # Clients subscribe to this channel through a ClientSocket. # Messages sent to this channel are handled by `handle_message`. # -# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/guides/websockets.md +# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/guides/websockets.md class #{class_name}Channel < Amber::WebSockets::Channel # Called when a client subscribes to this channel. # Use this for authorization or sending initial state. @@ -640,7 +640,7 @@ CHANNEL # Configure in config/routes.cr: # websocket "/#{file_name}", #{class_name}Socket # -# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/guides/websockets.md +# See: https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/guides/websockets.md struct #{class_name}Socket < Amber::WebSockets::ClientSocket channel "#{file_name}:*", #{class_name}Channel diff --git a/src/amber_cli/commands/new_command.cr b/src/amber_cli/commands/new_command.cr index 15b7157..4338386 100644 --- a/src/amber_cli/commands/new_command.cr +++ b/src/amber_cli/commands/new_command.cr @@ -285,29 +285,42 @@ module AmberCLI::Commands end end + private LOCK_CHECKSUM_LINE = /^ checksum: (?:sha256-v2:[0-9a-f]{64}|git-tree:[0-9a-f]{40})$/ + # Describes what is wrong with a generated application's `shard.lock`, or - # returns nil when each dependency entry carries exactly one git-tree - # checksum and Amber is locked at `AmberRelease::COMMIT` with the tree - # `AmberRelease::TREE`. + # returns nil when each dependency entry carries exactly one checksum and + # Amber is locked at `AmberRelease::COMMIT` with `AmberRelease::CHECKSUM`, + # or `AmberRelease::TREE` from a Minecart older than 2025.11.25.9. def self.minecart_lock_problem(lock : String) : String? entries = lock_entries(lock) - if entries.empty? || entries.values.any? { |entry_lines| entry_lines.count { |line| /^ checksum: git-tree:[0-9a-f]{40}$/.matches?(line) } != 1 } - return "Minecart did not lock every dependency with a git-tree checksum" + if entries.empty? || entries.values.any? { |entry_lines| entry_lines.count { |line| LOCK_CHECKSUM_LINE.matches?(line) } != 1 } + return "Minecart did not lock every dependency with exactly one checksum" end amber_entry = entries["amber"]? return "Minecart did not lock Amber" unless amber_entry expected_version = " version: #{AmberRelease::VERSION}+git.commit.#{AmberRelease::COMMIT}" - expected_checksum = " checksum: git-tree:#{AmberRelease::TREE}" - unless amber_entry.includes?(expected_version) && amber_entry.includes?(expected_checksum) + unless amber_entry.includes?(expected_version) && records_the_release_checksum?(amber_entry) return "Minecart locked Amber at a revision other than v#{AmberRelease::VERSION} " \ - "(commit #{AmberRelease::COMMIT}, tree #{AmberRelease::TREE})" + "(commit #{AmberRelease::COMMIT}, checksum #{AmberRelease::CHECKSUM})" end nil end + # A Windows checkout can rewrite line endings and has no executable bit, so it + # hashes differently from the release. There the commit in the version line is + # the pin, and the entry still has to carry exactly one checksum. + private def self.records_the_release_checksum?(amber_entry : Array(String)) : Bool + {% if flag?(:win32) %} + true + {% else %} + amber_entry.includes?(" checksum: #{AmberRelease::CHECKSUM}") || + amber_entry.includes?(" checksum: git-tree:#{AmberRelease::TREE}") + {% end %} + end + # Groups a `shard.lock` into its entries: each shard name maps to the # indented lines that follow it. private def self.lock_entries(lock : String) : Hash(String, Array(String)) @@ -394,7 +407,7 @@ targets: dependencies: amber: github: amberframework/amber - commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9 + commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10 grant: github: crimson-knight/grant commit: 6c9da3c8180e612f76ff9ad9c76242a0402ce6d9 @@ -426,7 +439,7 @@ AMBER readme_content = <<-README # #{name} -An ECR web application generated by Amber CLI for Amber `2.0.0-beta.9`. +An ECR web application generated by Amber CLI for Amber `2.0.0-beta.10`. ## Run it @@ -440,7 +453,7 @@ amber database migrate amber watch ``` -`amber new` uses Minecart to write a `shard.lock` with `git-tree:` checksums and +`amber new` uses Minecart to write a `shard.lock` with `sha256-v2:` checksums and install `.claude/` assistant files. Commit the lock and `.minecart-policy.yml`. For later installs, use `minecart install --frozen`. If the project was created with `--no-deps`, first run `minecart install --strict-pinning` and @@ -471,7 +484,7 @@ server database. Set `DATABASE_URL` to override the environment YAML URL. ## Production configuration Set at least `AMBER_SERVER_SECRET_KEY_BASE` and `DATABASE_URL`. See the -[Amber V2 beta guide](https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/beta-installation.md). +[Amber V2 beta guide](https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/beta-installation.md). README write_text(File.join(path, "README.md"), readme_content) diff --git a/src/amber_cli/commands/pipelines.cr b/src/amber_cli/commands/pipelines.cr index d2747c6..def0d99 100644 --- a/src/amber_cli/commands/pipelines.cr +++ b/src/amber_cli/commands/pipelines.cr @@ -86,8 +86,9 @@ module AmberCLI::Commands parse_routes print_pipelines rescue ex - if ex.message && ex.message.not_nil!.includes?("Could not parse") - error ex.message.not_nil! + message = ex.message + if message && message.includes?("Could not parse") + error message exit!(error: true) else error "Not valid project root directory." diff --git a/src/amber_cli/commands/setup_lsp_command.cr b/src/amber_cli/commands/setup_lsp_command.cr index 87472b4..273b007 100644 --- a/src/amber_cli/commands/setup_lsp_command.cr +++ b/src/amber_cli/commands/setup_lsp_command.cr @@ -38,7 +38,7 @@ module AmberCLI::Commands content = <<-YAML # Amber LSP Configuration - # See: https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/guides/lsp-setup.md + # See: https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/guides/lsp-setup.md # Override built-in rule settings # rules: diff --git a/src/amber_cli/documentation.cr b/src/amber_cli/documentation.cr index d6ff24f..9a9d287 100644 --- a/src/amber_cli/documentation.cr +++ b/src/amber_cli/documentation.cr @@ -89,7 +89,7 @@ module AmberCLI::Documentation # - **.amber.yml** - Project configuration # - **.gitignore** - Git ignore rules # - # The web template pins Amber `2.0.0-beta.9`, uses ECR, and includes Grant, + # The web template pins Amber `2.0.0-beta.10`, uses ECR, and includes Grant, # Micrate-powered database commands, and the selected database driver. Model, # scaffold, and migration generators are supported. API-resource, # authentication, and native generators are preview surfaces during the beta. diff --git a/src/amber_cli/generators/native_app.cr b/src/amber_cli/generators/native_app.cr index a158a37..f28f60f 100644 --- a/src/amber_cli/generators/native_app.cr +++ b/src/amber_cli/generators/native_app.cr @@ -118,7 +118,7 @@ dependencies: # Amber Framework V2 (patterns only, NO HTTP server for native apps) amber: github: amberframework/amber - commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9 + commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10 # Grant ORM (ActiveRecord-style, replaces Granite in V2) grant: diff --git a/src/amber_cli/templates/app/README.md.ecr b/src/amber_cli/templates/app/README.md.ecr index 6e83c09..4a9c4f8 100644 --- a/src/amber_cli/templates/app/README.md.ecr +++ b/src/amber_cli/templates/app/README.md.ecr @@ -1,6 +1,6 @@ # <%= @name %> -An ECR web application generated by Amber CLI for Amber `2.0.0-beta.9`. +An ECR web application generated by Amber CLI for Amber `2.0.0-beta.10`. ## Run it @@ -30,7 +30,7 @@ the app to target a server database. ## Production configuration Set at least `AMBER_SERVER_SECRET_KEY_BASE` and `AMBER_DATABASE_URL`. See the -[Amber V2 beta guide](https://github.com/amberframework/amber/blob/v2.0.0-beta.9/docs/beta-installation.md). +[Amber V2 beta guide](https://github.com/amberframework/amber/blob/v2.0.0-beta.10/docs/beta-installation.md). ## Tests diff --git a/src/amber_cli/templates/app/shard.yml.ecr b/src/amber_cli/templates/app/shard.yml.ecr index 67df802..1a78c86 100644 --- a/src/amber_cli/templates/app/shard.yml.ecr +++ b/src/amber_cli/templates/app/shard.yml.ecr @@ -15,7 +15,7 @@ targets: dependencies: amber: github: amberframework/amber - commit: 34a93352eaa89501d24e2b9ff90b058209a22720 # v2.0.0-beta.9 + commit: d291e0930dd22b14a2d10f75a9de063abb0e64e4 # v2.0.0-beta.10 grant: github: crimson-knight/grant commit: 6c9da3c8180e612f76ff9ad9c76242a0402ce6d9 diff --git a/src/amber_cli/templates/auth/src/controllers/{{name}}_controller.cr.ecr b/src/amber_cli/templates/auth/src/controllers/{{name}}_controller.cr.ecr index 90ae96e..158a3c3 100644 --- a/src/amber_cli/templates/auth/src/controllers/{{name}}_controller.cr.ecr +++ b/src/amber_cli/templates/auth/src/controllers/{{name}}_controller.cr.ecr @@ -54,6 +54,6 @@ class <%= class_name %>Controller < ApplicationController end private def set_<%= @name %> - @<%= @name %> = current_<%= @name %>.not_nil! + @<%= @name %> = current_<%= @name %> || raise(ArgumentError.new("Sign in before this action.")) end end diff --git a/src/amber_lsp/version.cr b/src/amber_lsp/version.cr index 78d9679..2ad3153 100644 --- a/src/amber_lsp/version.cr +++ b/src/amber_lsp/version.cr @@ -5,8 +5,9 @@ module AmberLSP # Minecart is preferred; shards-alpha or shards answers when Minecart is not installed. RELEASE = {{ `minecart version "#{__DIR__}/../.." 2>/dev/null || shards-alpha version "#{__DIR__}/../.." 2>/dev/null || shards version "#{__DIR__}/../.."`.chomp.stringify.downcase }} - # The git commit the binary was built from, or "unknown" outside a git checkout. - BUILD_COMMIT = {{ `git -C "#{__DIR__}" rev-parse --short=12 HEAD 2>/dev/null || echo unknown`.chomp.stringify }} + # The commit the binary was built from. A build from a source archive has no git + # checkout, so the Homebrew formula names its release commit in AMBER_CLI_BUILD_COMMIT. + BUILD_COMMIT = {{ env("AMBER_CLI_BUILD_COMMIT") || `git -C "#{__DIR__}" rev-parse --short=12 HEAD 2>/dev/null || echo unknown`.chomp.stringify }} # Printed by `amber-lsp --help`. With no arguments amber-lsp runs the language server on stdin. USAGE = <<-TEXT