Repository navigation
Add amber setup:agent: Claude Code and Codex hooks for the Crystal agent loop - #43
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
amber setup:agent(aliasamber agent), which installs the agent feedback loop into an Amber V2 project. Until now this loop only existed as personal scripts on the maintainer's machine.What it writes (idempotent; existing settings and hooks are kept):
.claude/settings.jsonand.codex/hooks.json:bin/amber-agent-hook preholds the watcher while the agent edits.bin/amber-agent-hook postruns per edited file:crystal-alpha tool formatplusamber-lsp --check. It's fast and never runs a full build.bin/amber-agent-hook stopreleases the hold and runscrystal-alpha watch build. Without a watcher it falls back tobuild --no-codegen <main>. Errors exit 2 so the agent sees them.bin/amber-agent-hook: a POSIX sh script for Linux and macOS with no jq, ruby or python. It handles Claude'sfile_pathand Codex'sapply_patchpayloads. Compiler order:$CRYSTAL_ALPHA,crystal-alpha,acrystal, then stockcrystalwith a warning..lsp.jsonfromsetup:lsp.amber-lsp --check FILE: a one-shot diagnostics mode for hooks.setup:lsp: removes the hardcoded~/open_source_coding_projects/amber_clilookup and uses the same compiler resolution instead of barecrystal.amber newprints a tip to runamber setup:agent.Works with today's compiler: the hook probes
watch statusonce. The installed crystal-alpha (1.21.0-incremental-1) has nowatch hold/buildand exits 1, so the hook skips coordination and type-checks directly. The ported compiler (crimson-knight/crystal#10) exits 0 or 2, so it holds and releases the watcher. Ifamber-lspis missing, the hook warns without blocking; formatting and syntax errors still block.Tests: setup_agent, setup_lsp and new_command specs: 167 examples, 0 failures. amber_lsp specs: 16, 0 failures. shellcheck and
dash -npass. Manually verified in a fixture project against both the installed crystal-alpha and the ported compiler: a clean project exits 0;puts 1 + "x"makesstopexit 2 with the compiler error. With the ported compiler,prerunswatch hold(exit 0).Not verified: a live session against a running
crystal-alpha watch(needs #10 released), and Codex end to end in a real repo.