Skip to content

Commit 44f9706

Browse files
ghuntleyampcode-com
andcommitted
Initial commit with all project files
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-d3c212af-37b5-4ba3-a1a1-bc907841f35d
0 parents  commit 44f9706

21 files changed

+2507
-0
lines changed

.envrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export DIRENV_WARN_TIMEOUT=20s
2+
3+
eval "$(devenv direnvrc)"
4+
5+
# The use_devenv function supports passing flags to the devenv command
6+
# For example: use devenv --impure --option services.postgres.enable:bool true
7+
use devenv

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Devenv
2+
.devenv*
3+
devenv.local.nix
4+
5+
# direnv
6+
.direnv
7+
8+
# pre-commit
9+
.pre-commit-config.yaml
10+
11+
# Go binaries
12+
bash_tool
13+
chat
14+
chat_verbose
15+
edit_tool
16+
list_files
17+
read
18+
read_verbose
19+
20+
# demo files
21+
fizzbuzz.js

AGENT.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Agent Instructions
2+
3+
## Development Environment
4+
This project uses [devenv](https://devenv.sh/) for reproducible development environments with Nix.
5+
6+
## Commands
7+
- `devenv shell` - Enter the development shell
8+
- `devenv test` - Run tests (currently runs git version check)
9+
- `go build` - Build Go project
10+
- `go run main.go` - Run the chat application
11+
- `go test ./...` - Run all Go tests
12+
- `go test <package>` - Run tests for specific package
13+
- `go mod tidy` - Download dependencies
14+
- `hello` - Custom script that greets from the development environment
15+
16+
### Application Commands
17+
- `go run chat.go` - Simple chat interface with Claude
18+
- `go run read.go` - Chat with file reading capabilities
19+
- `go run list_files.go` - Chat with file listing and reading capabilities
20+
- `go run bash_tool.go` - Chat with file operations and bash command execution
21+
- `go run edit_tool.go` - Chat with full file operations (read, list, edit, bash)
22+
23+
### Verbose Logging
24+
All Go applications support a `--verbose` flag for detailed execution logging:
25+
- `go run chat.go --verbose` - Enable verbose logging for debugging
26+
- `go run read.go --verbose` - See detailed tool execution and API calls
27+
- `go run edit_tool.go --verbose` - Debug file operations and tool usage
28+
29+
## Architecture
30+
- **Environment**: Nix-based development environment using devenv
31+
- **Shell**: Includes Git, Go toolchain, and custom greeting script
32+
- **Structure**: Chat application with terminal interface to Claude via Anthropic API
33+
34+
## Code Style Guidelines
35+
- Follow Nix conventions for devenv.nix configuration
36+
- Use standard Git workflows
37+
- Development environment configuration should be reproducible
38+
39+
## Troubleshooting
40+
41+
### Verbose Logging
42+
When debugging issues with the chat applications, use the `--verbose` flag to get detailed execution logs:
43+
44+
```bash
45+
go run edit_tool.go --verbose
46+
```
47+
48+
**What verbose logging shows:**
49+
- API calls to Claude (model, timing, success/failure)
50+
- Tool execution details (which tools are called, input parameters, results)
51+
- File operations (reading, writing, listing files with sizes/counts)
52+
- Bash command execution (commands run, output, errors)
53+
- Conversation flow (message processing, content blocks)
54+
- Error details with stack traces
55+
56+
**Log output locations:**
57+
- **Verbose mode**: Detailed logs go to stderr with timestamps and file locations
58+
- **Normal mode**: Only essential output goes to stdout
59+
60+
**Common troubleshooting scenarios:**
61+
- **API failures**: Check verbose logs for authentication errors or rate limits
62+
- **Tool failures**: See exactly which tool failed and why (file not found, permission errors)
63+
- **Unexpected responses**: View full conversation flow and Claude's reasoning
64+
- **Performance issues**: See API call timing and response sizes
65+
66+
### Environment Issues
67+
- Ensure `ANTHROPIC_API_KEY` environment variable is set
68+
- Run `devenv shell` to ensure proper development environment
69+
- Use `go mod tidy` to ensure dependencies are installed
70+
71+
## Notes
72+
- Requires ANTHROPIC_API_KEY environment variable to be set
73+
- Chat application provides a simple terminal interface to Claude
74+
- Use ctrl-c to quit the chat session

Makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.PHONY: build fmt check clean all
2+
3+
# Go binaries to build
4+
BINARIES := bash_tool chat edit_tool list_files read
5+
6+
# Build all binaries
7+
build:
8+
@echo "Building binaries..."
9+
go build -o bash_tool bash_tool.go
10+
go build -o chat chat.go
11+
go build -o edit_tool edit_tool.go
12+
go build -o list_files list_files.go
13+
go build -o read read.go
14+
15+
# Format all Go files
16+
fmt:
17+
@echo "Formatting Go files..."
18+
go fmt ./...
19+
20+
# Check (lint and vet) all Go files
21+
check:
22+
@echo "Running go vet on individual files..."
23+
go vet bash_tool.go
24+
go vet chat.go
25+
go vet edit_tool.go
26+
go vet list_files.go
27+
go vet read.go
28+
@echo "Running go mod tidy..."
29+
go mod tidy
30+
31+
# Clean built binaries
32+
clean:
33+
@echo "Cleaning binaries..."
34+
rm -f $(BINARIES)
35+
36+
# Build everything and run checks
37+
all: fmt check build
38+
39+
# Default target
40+
.DEFAULT_GOAL := all

0 commit comments

Comments
 (0)