Format markdown and YAML files with deno fmt
This commit is contained in:
21
AGENTS.md
21
AGENTS.md
@ -3,19 +3,26 @@
|
||||
- Go 1.25; modules in `go.mod`; binary name `statusline`.
|
||||
- Build: `task build` (stripped) or `go build -o bin/statusline .`.
|
||||
- Run fixture: `task run` or `cat test/fixture.json | ./bin/statusline`.
|
||||
- Tests: `task test` (`go test -v ./...`); single test: `go test -v -run 'TestName' ./...`.
|
||||
- Tests: `task test` (`go test -v ./...`); single test:
|
||||
`go test -v -run 'TestName' ./...`.
|
||||
- Coverage: `task test:cover`; benchmarks: `task bench` or `task bench:go`.
|
||||
- Lint: `task lint` (`golangci-lint run`); auto-fix: `task lint:fix`.
|
||||
- Formatting: `gofumpt` + `goimports` via golangci-lint; keep `go fmt`/gofumpt style.
|
||||
- Imports: organize with `goimports`; stdlib first, then third-party, then local.
|
||||
- Formatting: `gofumpt` + `goimports` via golangci-lint; keep `go fmt`/gofumpt
|
||||
style.
|
||||
- Imports: organize with `goimports`; stdlib first, then third-party, then
|
||||
local.
|
||||
- Types: prefer explicit types; avoid unused code (lint-enforced).
|
||||
- Naming: follow Go conventions (ExportedCamelCase for exported, lowerCamelCase for unexported); no stutter.
|
||||
- Errors: check and return errors; wrap or format with context; no silent ignores.
|
||||
- Naming: follow Go conventions (ExportedCamelCase for exported, lowerCamelCase
|
||||
for unexported); no stutter.
|
||||
- Errors: check and return errors; wrap or format with context; no silent
|
||||
ignores.
|
||||
- Security: `gosec` enabled; avoid leaking secrets; handle paths carefully.
|
||||
- Tests should avoid external deps; skip when environment-dependent.
|
||||
- Modernization helpers: `task modernize` / `task modernize:test` (gopls).
|
||||
- Clean artifacts: `task clean`; binary lives in `bin/`.
|
||||
- Git info and gitea checks rely on `go-git` and `gopsutil`; keep deps updated via `go mod tidy`.
|
||||
- Keep ANSI handling via `stripANSI` regex in `main.go`; adjust carefully if changing.
|
||||
- Git info and gitea checks rely on `go-git` and `gopsutil`; keep deps updated
|
||||
via `go mod tidy`.
|
||||
- Keep ANSI handling via `stripANSI` regex in `main.go`; adjust carefully if
|
||||
changing.
|
||||
- No Cursor/Copilot rules present as of this file.
|
||||
- No emojis in code or docs unless explicitly requested.
|
||||
|
||||
16
CLAUDE.md
16
CLAUDE.md
@ -1,10 +1,14 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with
|
||||
code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a custom status line binary for Claude Code, written in Go. It replaces shell-based status line scripts with a compiled binary for better performance. The binary reads JSON from stdin (provided by Claude Code) and outputs a formatted status line with ANSI colors.
|
||||
This is a custom status line binary for Claude Code, written in Go. It replaces
|
||||
shell-based status line scripts with a compiled binary for better performance.
|
||||
The binary reads JSON from stdin (provided by Claude Code) and outputs a
|
||||
formatted status line with ANSI colors.
|
||||
|
||||
## Build and Development Commands
|
||||
|
||||
@ -35,7 +39,8 @@ task clean # Remove bin/ directory
|
||||
|
||||
Single-file Go application (`main.go`) that:
|
||||
|
||||
1. **Reads JSON from stdin** - Parses Claude Code's status hook payload (`StatusInput` struct)
|
||||
1. **Reads JSON from stdin** - Parses Claude Code's status hook payload
|
||||
(`StatusInput` struct)
|
||||
2. **Gathers system state**:
|
||||
- Gitea process status via gopsutil (cross-platform process listing)
|
||||
- Git repository info via go-git (branch name, dirty state)
|
||||
@ -43,6 +48,7 @@ Single-file Go application (`main.go`) that:
|
||||
3. **Outputs formatted status line** with ANSI colors, padding to terminal width
|
||||
|
||||
Key functions:
|
||||
|
||||
- `formatContextInfo()` - Formats token usage as "Xk/Yk"
|
||||
- `getGiteaStatus()` - Returns green/red dot based on gitea process running
|
||||
- `getGitInfo()` - Returns git branch and dirty indicator
|
||||
@ -50,7 +56,9 @@ Key functions:
|
||||
|
||||
## JSON Input Format
|
||||
|
||||
The binary expects Claude Code's status hook JSON via stdin. See `test/fixture.json` for the complete structure. Key fields used:
|
||||
The binary expects Claude Code's status hook JSON via stdin. See
|
||||
`test/fixture.json` for the complete structure. Key fields used:
|
||||
|
||||
- `model.display_name` - Model name to display
|
||||
- `workspace.current_dir` - Current directory path
|
||||
- `context_window.context_window_size` - Total context window tokens
|
||||
|
||||
16
Taskfile.yml
16
Taskfile.yml
@ -1,6 +1,6 @@
|
||||
# https://taskfile.dev
|
||||
|
||||
version: '3'
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
BINARY: statusline
|
||||
@ -59,11 +59,11 @@ tasks:
|
||||
deps: [build]
|
||||
cmds:
|
||||
- |
|
||||
echo "=== Pure Go (100 runs) ==="
|
||||
time for i in $(seq 1 100); do cat test/fixture.json | ./bin/{{.BINARY}} >/dev/null; done
|
||||
# echo ""
|
||||
# echo "=== Shell (100 runs) ==="
|
||||
# time for i in $(seq 1 100); do cat test/fixture.json | ./statusline.sh >/dev/null; done
|
||||
echo "=== Pure Go (100 runs) ==="
|
||||
time for i in $(seq 1 100); do cat test/fixture.json | ./bin/{{.BINARY}} >/dev/null; done
|
||||
# echo ""
|
||||
# echo "=== Shell (100 runs) ==="
|
||||
# time for i in $(seq 1 100); do cat test/fixture.json | ./statusline.sh >/dev/null; done
|
||||
silent: false
|
||||
|
||||
bench:go:
|
||||
@ -71,8 +71,8 @@ tasks:
|
||||
deps: [build]
|
||||
cmds:
|
||||
- |
|
||||
echo "=== Pure Go (100 runs) ==="
|
||||
time for i in $(seq 1 100); do cat test/fixture.json | ./bin/{{.BINARY}} >/dev/null; done
|
||||
echo "=== Pure Go (100 runs) ==="
|
||||
time for i in $(seq 1 100); do cat test/fixture.json | ./bin/{{.BINARY}} >/dev/null; done
|
||||
|
||||
tidy:
|
||||
desc: Run go mod tidy
|
||||
|
||||
Reference in New Issue
Block a user