Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,30 @@ jobs:
- name: Run tests
run: crystal spec

- name: Build binary (Linux)
- name: Build binaries (Linux)
if: matrix.target == 'linux-x86_64'
run: |
crystal build src/amber_cli.cr -o amber --release --static

- name: Build binary (macOS)
crystal build src/amber_lsp.cr -o amber-lsp --release --static

- name: Build binaries (macOS)
if: matrix.target == 'darwin-arm64'
run: |
crystal build src/amber_cli.cr -o amber --release

- name: Test binary
crystal build src/amber_lsp.cr -o amber-lsp --release

- name: Test binaries
run: |
./amber --version
./amber --help

- name: Upload build artifact
./amber-lsp --help

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
name: amber-cli-${{ matrix.target }}-build
path: amber
path: |
amber
amber-lsp
retention-days: 7
26 changes: 19 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,29 @@ jobs:
run: ./bin/ameba
continue-on-error: true

- name: Compile project
run: crystal build src/amber_cli.cr --no-debug
- name: Compile CLI
run: crystal build src/amber_cli.cr --no-debug -o amber

- name: Compile LSP
run: crystal build src/amber_lsp.cr --no-debug -o amber-lsp

- name: Run tests
run: crystal spec

- name: Build release binary
run: crystal build src/amber_cli.cr --release --no-debug -o amber_cli
- name: Build release binaries
if: matrix.os == 'ubuntu-latest'
run: |
crystal build src/amber_cli.cr --release --no-debug -o amber_cli
crystal build src/amber_lsp.cr --release --no-debug -o amber_lsp

- name: Upload binary artifact (Linux)
- name: Upload binary artifacts (Linux)
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: amber_cli-linux
path: amber_cli
name: amber-cli-linux
path: |
amber_cli
amber_lsp

# Separate job for additional platform-specific tests
platform-specific:
Expand Down Expand Up @@ -113,6 +120,11 @@ jobs:
./amber_cli --help || true
./amber_cli --version || true

- name: Test LSP functionality
run: |
crystal build src/amber_lsp.cr -o amber_lsp
./amber_lsp --help || true

# Job to run integration tests
integration:
runs-on: ubuntu-latest
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,29 @@ jobs:
- name: Install dependencies
run: shards install --production

- name: Build binary (Linux x86_64)
- name: Build binaries (Linux x86_64)
if: matrix.target == 'linux-x86_64'
run: |
crystal build src/amber_cli.cr -o amber --release --static

- name: Build binary (macOS ARM64)
crystal build src/amber_lsp.cr -o amber-lsp --release --static

- name: Build binaries (macOS ARM64)
if: matrix.target == 'darwin-arm64'
run: |
crystal build src/amber_cli.cr -o amber --release

- name: Verify binary
crystal build src/amber_lsp.cr -o amber-lsp --release

- name: Verify binaries
run: |
file amber
./amber --version || echo "Version command may not work in cross-compiled binary"

file amber-lsp
./amber-lsp --help || echo "Help command may not work in cross-compiled binary"

- name: Create archive
run: |
mkdir -p dist
tar -czf dist/amber-cli-${{ matrix.target }}.tar.gz amber
tar -czf dist/amber-cli-${{ matrix.target }}.tar.gz amber amber-lsp

- name: Calculate checksum
id: checksum
Expand Down Expand Up @@ -116,6 +120,6 @@ jobs:
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
repository: crimsonknight/homebrew-amber-cli
repository: crimson-knight/homebrew-amber-cli
event-type: release-published
client-payload: '{"version": "${{ github.event.release.tag_name }}"}'
69 changes: 65 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ The comprehensive documentation includes detailed guides, examples, and API refe

**macOS & Linux via Homebrew:**
```bash
brew install amber
brew tap crimson-knight/amber-cli
brew install amber-cli
```

**From Source:**
```bash
git clone https://github.com/amberframework/amber_cli.git
git clone https://github.com/crimson-knight/amber_cli.git
cd amber_cli
shards install
crystal build src/amber_cli.cr -o amber
sudo mv amber /usr/local/bin/
crystal build src/amber_cli.cr -o amber --release
crystal build src/amber_lsp.cr -o amber-lsp --release
sudo mv amber amber-lsp /usr/local/bin/
```

**Windows:**
Expand Down Expand Up @@ -64,6 +66,7 @@ Your application will be available at `http://localhost:3000`
| `exec` | Execute Crystal code in app context | `amber exec 'puts User.count'` |
| `encrypt` | Manage encrypted environment files | `amber encrypt production` |
| `pipelines` | Show pipeline configuration | `amber pipelines` |
| `setup:lsp` | Configure the Amber LSP for Claude Code | `amber setup:lsp` |

Run `amber --help` or `amber [command] --help` for detailed usage information.

Expand All @@ -87,6 +90,12 @@ Run `amber --help` or `amber [command] --help` for detailed usage information.
- Route analysis and pipeline inspection
- Environment file encryption for security

### **Amber LSP — AI-Assisted Development**
- Built-in Language Server Protocol (LSP) server for Claude Code integration
- 15 convention rules that catch framework mistakes as you type
- Custom YAML-based rules for project-specific conventions
- One command to set up: `amber setup:lsp`

### **Extensible Architecture**
- Plugin system for extending functionality
- Command registration system for custom commands
Expand All @@ -112,6 +121,58 @@ Run `amber --help` or `amber [command] --help` for detailed usage information.
- Conditional file generation
- Post-generation command execution

## 🤖 Amber LSP — The Default Development Workflow

Amber ships with a diagnostics-only Language Server that integrates with [Claude Code](https://claude.ai/claude-code). When you develop with Claude Code, the LSP runs in the background and automatically catches framework convention violations — wrong controller names, missing methods, bad inheritance, file naming issues, and more. Claude sees these diagnostics and self-corrects without you having to notice or intervene.

**This is the recommended way to develop with Amber.** The LSP turns Claude Code from a general-purpose coding assistant into one that understands Amber's conventions natively.

### Quick Setup

```bash
# From your Amber project directory:
amber setup:lsp
```

This creates three files:

| File | Purpose |
|------|---------|
| `.lsp.json` | Tells Claude Code where the LSP binary is and what files it handles |
| `.claude-plugin/plugin.json` | Plugin manifest so Claude Code discovers the LSP |
| `.amber-lsp.yml` | Rule configuration — customize severity, disable rules, add custom rules |

Then open Claude Code in your project. The LSP activates automatically.

### What It Checks

The LSP ships with 15 built-in rules covering controllers, jobs, channels, pipes, mailers, schemas, routing, file naming, directory structure, and more. Every rule maps to an Amber convention — if Claude generates a controller that doesn't end with `Controller`, or a job without a `perform` method, the LSP flags it immediately.

### Custom Rules

You can define project-specific rules in `.amber-lsp.yml` using regex patterns. No recompilation needed:

```yaml
custom_rules:
- id: "project/no-puts"
description: "Do not use puts in production code"
severity: warning
applies_to: ["src/**"]
pattern: "^\\s*puts\\b"
message: "Avoid 'puts' in production code. Use Log.info instead."
```

### Building the LSP Binary

If `amber-lsp` is not on your PATH, the `setup:lsp` command will offer to build it:

```bash
cd ~/open_source_coding_projects/amber_cli
crystal build src/amber_lsp.cr -o bin/amber-lsp --release
```

For full documentation on all 15 rules, configuration options, and custom rule syntax, see the [LSP Setup Guide](https://github.com/crimson-knight/amber/blob/master/docs/guides/lsp-setup.md).

## 📚 Examples

### Generate a Blog Post Resource
Expand Down
24 changes: 24 additions & 0 deletions TASKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Amber CLI Tasks

## Completed (2025-12-26)
- [x] Changed default template from slang to ECR
- [x] Removed recipes feature (deprecated liquid.cr)
- [x] Verified CLI builds successfully
- [x] Tested --version flag
- [x] Tested new command (generates ECR templates)
- [x] Tested generate model command
- [x] Tested generate controller command
- [x] Tested generate scaffold command (generates ECR views)
- [x] GitHub Actions CI/CD already configured for Ubuntu + macOS

## Remaining Work
- [ ] Run full test suite: `crystal spec`
- [ ] Update homebrew-amber formula after publishing
- [ ] Create GitHub release for v2.0.0
- [ ] Add integration tests that validate generated app compiles
- [ ] Consider Docker testing for Linux validation

## Notes
- CI workflow exists at `.github/workflows/ci.yml`
- Runs on ubuntu-latest and macos-latest
- Integration test job will skip if no spec/integration folder exists
32 changes: 21 additions & 11 deletions scripts/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ ARCH=$(uname -m)
case "${OS}" in
"darwin")
TARGET="darwin-arm64"
BUILD_CMD="crystal build src/amber_cli.cr -o amber --release"
BUILD_CLI="crystal build src/amber_cli.cr -o amber --release"
BUILD_LSP="crystal build src/amber_lsp.cr -o amber-lsp --release"
CHECKSUM_CMD="shasum -a 256"
if [ "${ARCH}" != "arm64" ]; then
echo "⚠️ Warning: Building for ARM64 on ${ARCH} architecture"
echo " This will create a native build for your current architecture"
fi
;;
"linux")
TARGET="linux-x86_64"
BUILD_CMD="crystal build src/amber_cli.cr -o amber --release --static"
BUILD_CLI="crystal build src/amber_cli.cr -o amber --release --static"
BUILD_LSP="crystal build src/amber_lsp.cr -o amber-lsp --release --static"
CHECKSUM_CMD="sha256sum"
;;
*)
echo "❌ Unsupported OS: ${OS}"
Expand All @@ -43,24 +47,29 @@ echo "🎯 Building for target: ${TARGET}"
echo "📦 Installing dependencies..."
shards install --production

# Build binary
echo "🔨 Compiling binary..."
eval "${BUILD_CMD}"
# Build binaries
echo "🔨 Compiling amber CLI..."
eval "${BUILD_CLI}"

# Verify binary
echo "✅ Verifying binary..."
echo "🔨 Compiling amber-lsp..."
eval "${BUILD_LSP}"

# Verify binaries
echo "✅ Verifying binaries..."
file amber
./amber
file amber-lsp
./amber-lsp --help

# Create archive
echo "📦 Creating archive..."
tar -czf "${OUTPUT_DIR}/amber-cli-${TARGET}.tar.gz" amber
tar -czf "${OUTPUT_DIR}/amber-cli-${TARGET}.tar.gz" amber amber-lsp

# Calculate checksum
echo "🔢 Calculating checksum..."
cd "${OUTPUT_DIR}"
sha256sum "amber-cli-${TARGET}.tar.gz" > "amber-cli-${TARGET}.tar.gz.sha256"
SHA256=$(cat "amber-cli-${TARGET}.tar.gz.sha256" | cut -d' ' -f1)
${CHECKSUM_CMD} "amber-cli-${TARGET}.tar.gz" > "amber-cli-${TARGET}.tar.gz.sha256"
SHA256=$(cut -d' ' -f1 < "amber-cli-${TARGET}.tar.gz.sha256")

echo ""
echo "🎉 Build complete!"
Expand All @@ -69,4 +78,5 @@ echo "🔑 SHA256: ${SHA256}"
echo ""
echo "To test the archive:"
echo " tar -xzf ${OUTPUT_DIR}/amber-cli-${TARGET}.tar.gz"
echo " ./amber --version"
echo " ./amber --version"
echo " ./amber-lsp --help"
4 changes: 3 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ version: 2.0.0
authors:
- crimson-knight <crimsonknightstudios@gmail.com>

crystal: ">= 1.0.0, < 2.0"
crystal: ">= 1.10.0, < 2.0"

license: MIT

targets:
amber:
main: src/amber_cli.cr
amber-lsp:
main: src/amber_lsp.cr

dependencies:

Expand Down
3 changes: 3 additions & 0 deletions spec/amber_cli_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require "json"
require "yaml"

# Only require our new core modules directly, avoiding the main amber_cli.cr which has dependencies
require "../src/version"
require "../src/amber_cli/exceptions"
require "../src/amber_cli/core/word_transformer"
require "../src/amber_cli/core/generator_config"
Expand Down Expand Up @@ -56,6 +57,8 @@ require "./core/word_transformer_spec"
require "./core/generator_config_spec"
require "./core/template_engine_spec"
require "./commands/base_command_spec"
require "./commands/new_command_spec"
require "./generators/native_app_spec"
require "./integration/generator_manager_spec"

describe "Amber CLI New Architecture" do
Expand Down
Loading
Loading