Debug Backend API
Quick Start
Use go run ./script/request to send authenticated HTTP requests to the local server (port 23712).
bash
# GET request
go run ./script/request /api/checkpoints?project=myproject
# POST request with JSON body
go run ./script/request /api/checkpoints '{"project_dir":"/path/to/project","name":"test","file_paths":["file.txt"]}'
The tool automatically reads .ai-critic/server-credentials for auth (cookie: ai-critic-token).
Usage
code
go run ./script/request <path> [body]
- •No body → GET request
- •With body → POST request with
Content-Type: application/json - •Status line printed to stderr, response body to stdout
- •Pipe to
jqfor formatted output:go run ./script/request /api/xxx | jq .
Common Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/auth/check | GET | Verify auth is working |
/api/checkpoints?project=NAME | GET | List checkpoints |
/api/checkpoints?project=NAME | POST | Create checkpoint |
/api/checkpoints/ID?project=NAME | GET | Get checkpoint detail |
/api/checkpoints/current-changes?project=NAME&project_dir=DIR | GET | Get current changes |
/api/checkpoints/diff?project=NAME&project_dir=DIR | GET | Get current diffs |
/api/files?dir=DIR | GET | List files in directory |
/api/files/content?dir=DIR&path=FILE | GET | Read file content |
/api/port-forwards | GET | List port forwards |
/api/agents | GET | List agents |
/api/terminal/sessions | GET | List terminal sessions |
Debugging Workflow
- •Identify the endpoint: Check the frontend API call in
ai-critic-react/src/api/to find the endpoint path and parameters. - •Send a test request: Use
go run ./script/requestwith the endpoint. - •Inspect the response: Check status code and response body.
- •Find the handler: Backend handlers are registered in
server/server.go(main routes) or in sub-packages likeserver/checkpoint/,server/portforward/,server/terminal/. - •Add debug logging: Add
fmt.Printf("DEBUG ...")lines in the handler, rebuild withgo run ./script/server/run, and re-test.
Important Notes
- •Server must be running (
go run ./script/server/run) before sending requests. - •The
.ai-critic/server-credentialsfile must exist if auth is enabled; each line is a valid token. - •Always limit output when piping:
go run ./script/request /api/xxx | head -c 4096.