Change summary
AGENTS.md | 20 +++---
Taskfile.yaml | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++
justfile | 57 -----------------
3 files changed, 181 insertions(+), 67 deletions(-)
Detailed changes
@@ -10,22 +10,22 @@ This file provides guidance to AI coding agents when working with code in this r
## Development Commands
-- **Default workflow**: `just` (runs fmt, lint, staticcheck, test, vuln, reuse)
-- **Build**: `just build` (outputs binary as `formatted-commit`)
-- **Run during development**: `just run [flags]`
-- **Format code**: `just fmt` (uses gofumpt)
-- **Lint**: `just lint` (uses golangci-lint)
-- **Static analysis**: `just staticcheck`
-- **Vulnerability check**: `just vuln` (uses govulncheck)
-- **License compliance**: `just reuse` (REUSE specification)
-- **Test**: `just test` or `go test ./...`
+- **Default workflow**: `task` (runs fmt, lint, staticcheck, test, vuln, reuse)
+- **Build**: `task build` (outputs binary as `formatted-commit`)
+- **Run during development**: `task run -- [flags]`
+- **Format code**: `task fmt` (uses gofumpt)
+- **Lint**: `task lint` (uses golangci-lint)
+- **Static analysis**: `task staticcheck`
+- **Vulnerability check**: `task vuln` (uses govulncheck)
+- **License compliance**: `task reuse` (REUSE specification)
+- **Test**: `task test` or `go test ./...`
- **Single test**: `go test -v -run TestName ./...` (no tests exist yet)
- **Update dependencies**: `go mod tidy`
Example usage:
```bash
-just run -t feat -m "add validation" -T "Assisted-by: GLM 4.6 via Crush"
+task run -- -t feat -m "add validation" -T "Assisted-by: GLM 4.6 via Crush"
```
## Project Purpose
@@ -0,0 +1,171 @@
+# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+#
+# SPDX-License-Identifier: CC0-1.0
+
+version: "3"
+
+vars:
+ VERSION:
+ sh: git describe --tags --always 2>/dev/null || echo "v0.0.0"
+ GOOS:
+ sh: go env GOOS
+ GOARCH:
+ sh: go env GOARCH
+
+env:
+ CGO_ENABLED: 0
+
+tasks:
+ default:
+ desc: Run all checks
+ cmds:
+ - task: fmt
+ - task: lint
+ - task: staticcheck
+ - task: test
+ - task: vuln
+ - task: reuse
+
+ fmt:
+ desc: Format all Go source code
+ cmds:
+ - go install mvdan.cc/gofumpt@latest
+ - gofumpt -l -w .
+
+ lint:
+ desc: Lint Go source code
+ cmds:
+ - golangci-lint run
+
+ staticcheck:
+ desc: Perform static analysis
+ cmds:
+ - go install honnef.co/go/tools/cmd/staticcheck@latest
+ - staticcheck ./...
+
+ test:
+ desc: Run tests
+ cmds:
+ - go test -v ./...
+
+ vuln:
+ desc: Check for vulnerabilities
+ cmds:
+ - go install golang.org/x/vuln/cmd/govulncheck@latest
+ - govulncheck ./...
+
+ reuse:
+ desc: Lint licenses and copyright headers
+ cmds:
+ - reuse lint
+
+ build:
+ desc: Build formatted-commit
+ cmds:
+ - go build -o formatted-commit -ldflags "-s -w -X main.version={{.VERSION}}"
+ generates:
+ - formatted-commit
+
+ install:
+ desc: Install formatted-commit
+ cmds:
+ - go install -ldflags "-s -w -X main.version={{.VERSION}}"
+
+ run:
+ desc: Run formatted-commit
+ cmds:
+ - go run -ldflags "-s -w -X main.version={{.VERSION}}" . {{.CLI_ARGS}}
+
+ pack:
+ desc: Pack formatted-commit with UPX
+ cmds:
+ - upx --best -qo formatted-commit.min formatted-commit
+ - mv formatted-commit.min formatted-commit
+ sources:
+ - formatted-commit
+
+ clean:
+ desc: Remove build artifacts
+ cmds:
+ - rm -rf formatted-commit
+
+ clean-all:
+ desc: Remove build artifacts and config.toml
+ cmds:
+ - rm -rf formatted-commit config.toml
+
+ release:
+ desc: Interactive release workflow
+ vars:
+ BUMP:
+ sh: gum choose "major" "minor" "patch" "prerelease"
+ CURRENT_VERSION:
+ sh: git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"
+ IS_CURRENT_PRERELEASE:
+ sh: |
+ current="{{.CURRENT_VERSION}}"
+ if echo "$current" | grep -qE '\-[a-zA-Z]+\.[0-9]+$'; then
+ echo "yes"
+ else
+ echo "no"
+ fi
+ IS_PRERELEASE:
+ sh: |
+ if [ "{{.BUMP}}" = "prerelease" ]; then
+ echo "yes"
+ else
+ gum confirm "Create pre-release?" && echo "yes" || echo "no"
+ fi
+ PRERELEASE_SUFFIX:
+ sh: |
+ if [ "{{.BUMP}}" = "prerelease" ] && [ "{{.IS_CURRENT_PRERELEASE}}" = "yes" ]; then
+ # Extract suffix from current version (e.g., v1.2.3-beta.0 -> beta)
+ echo "{{.CURRENT_VERSION}}" | sed -E 's/.*-([a-zA-Z]+)\.[0-9]+$/\1/'
+ elif [ "{{.IS_PRERELEASE}}" = "yes" ]; then
+ gum input --placeholder "Enter pre-release suffix (e.g., beta, rc)"
+ fi
+ BASE_NEXT:
+ sh: |
+ if [ "{{.BUMP}}" = "prerelease" ] && [ "{{.IS_CURRENT_PRERELEASE}}" = "yes" ]; then
+ # Extract base version from current prerelease (e.g., v1.2.3-beta.0 -> v1.2.3)
+ echo "{{.CURRENT_VERSION}}" | sed -E 's/-[a-zA-Z]+\.[0-9]+$//'
+ else
+ svu {{.BUMP}}
+ fi
+ SUFFIX_VERSION:
+ sh: |
+ if [ "{{.IS_PRERELEASE}}" = "yes" ] && [ -n "{{.PRERELEASE_SUFFIX}}" ]; then
+ if [ "{{.BUMP}}" = "prerelease" ] && [ "{{.IS_CURRENT_PRERELEASE}}" = "yes" ]; then
+ # Increment the current prerelease number
+ current_num=$(echo "{{.CURRENT_VERSION}}" | sed -E 's/.*-[a-zA-Z]+\.([0-9]+)$/\1/')
+ echo $((current_num + 1))
+ else
+ # Find existing tags with this suffix and get the highest version number
+ highest=$(git tag -l "{{.BASE_NEXT}}-{{.PRERELEASE_SUFFIX}}.*" | \
+ sed 's/.*-{{.PRERELEASE_SUFFIX}}\.//' | \
+ sort -n | tail -1)
+ if [ -n "$highest" ]; then
+ echo $((highest + 1))
+ else
+ echo 0
+ fi
+ fi
+ fi
+ NEXT:
+ sh: |
+ if [ "{{.IS_PRERELEASE}}" = "yes" ] && [ -n "{{.PRERELEASE_SUFFIX}}" ]; then
+ echo "{{.BASE_NEXT}}-{{.PRERELEASE_SUFFIX}}.{{.SUFFIX_VERSION}}"
+ else
+ echo "{{.BASE_NEXT}}"
+ fi
+ prompt: "Release {{.NEXT}}?"
+ preconditions:
+ - sh: '[ $(git symbolic-ref --short HEAD) = "main" ] || [ $(git symbolic-ref --short HEAD) = "dev" ]'
+ msg: Not on main or dev branch
+ - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
+ msg: "Git is dirty"
+ cmds:
+ - llm-tag {{.NEXT}}
+ - git push soft {{.NEXT}}
+ - go list -m git.secluded.site/formatted-commit@{{.NEXT}} > /dev/null
+ - echo "Released {{.NEXT}} and notified module proxy"
@@ -1,57 +0,0 @@
-# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
-#
-# SPDX-License-Identifier: CC0-1.0
-
-GOOS := env("GOOS", `go env GOOS`)
-GOARCH := env("GOARCH", `go env GOARCH`)
-VERSION := `git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'`
-
-default: fmt lint staticcheck test vuln reuse
-
-fmt:
- # Formatting all Go source code
- go install mvdan.cc/gofumpt@latest
- gofumpt -l -w .
-
-lint:
- # Linting Go source code
- golangci-lint run
-
-staticcheck:
- # Performing static analysis
- go install honnef.co/go/tools/cmd/staticcheck@latest
- staticcheck ./...
-
-test:
- # Running tests
- go test -v ./...
-
-vuln:
- # Checking for vulnerabilities
- go install golang.org/x/vuln/cmd/govulncheck@latest
- govulncheck ./...
-
-reuse:
- # Linting licenses and copyright headers
- reuse lint
-
-build:
- # Building formatted-commit
- CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go build -o formatted-commit -ldflags "-s -w -X main.version={{VERSION}}"
-
-run *FLAGS:
- # Running formatted-commit
- CGO_ENABLED=0 GOOS={{GOOS}} GOARCH={{GOARCH}} go run -ldflags "-s -w -X main.version={{VERSION}}" . {{FLAGS}}
-
-pack:
- # Packing formatted-commit
- upx --best -qo formatted-commit.min formatted-commit
- mv formatted-commit.min formatted-commit
-
-clean:
- # Removing build artifacts
- rm -rf formatted-commit
-
-clean-all:
- # Removing build artifacts and config.toml
- rm -rf formatted-commit config.toml