From 26ad537417fca9b6c11f08dc4b31d5e6a0e2b644 Mon Sep 17 00:00:00 2001 From: 35C4n0r <70096901+35C4n0r@users.noreply.github.com> Date: Tue, 26 Aug 2025 15:33:57 +0530 Subject: [PATCH 1/6] chore: update version to 0.6.1 (#68) --- CHANGELOG.md | 5 +++++ chat/package.json | 2 +- lib/httpapi/server.go | 2 +- openapi.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f956c6c..626fd5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.6.1 + +### Features +- Handle animation on Amp cli start screen. + ## v0.6.0 ### Features diff --git a/chat/package.json b/chat/package.json index 32b6684..d6411ce 100644 --- a/chat/package.json +++ b/chat/package.json @@ -1,6 +1,6 @@ { "name": "chat", - "version": "0.6.0", + "version": "0.6.1", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index fb45ad4..2d25fca 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -188,7 +188,7 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) { }) router.Use(corsMiddleware.Handler) - humaConfig := huma.DefaultConfig("AgentAPI", "0.6.0") + humaConfig := huma.DefaultConfig("AgentAPI", "0.6.1") humaConfig.Info.Description = "HTTP API for Claude Code, Goose, and Aider.\n\nhttps://github.com/coder/agentapi" api := humachi.New(router, humaConfig) formatMessage := func(message string, userInput string) string { diff --git a/openapi.json b/openapi.json index 19c4961..d87c9b0 100644 --- a/openapi.json +++ b/openapi.json @@ -307,7 +307,7 @@ "info": { "description": "HTTP API for Claude Code, Goose, and Aider.\n\nhttps://github.com/coder/agentapi", "title": "AgentAPI", - "version": "0.6.0" + "version": "0.6.1" }, "openapi": "3.1.0", "paths": { From 7aa0cc805133257727405193a9f4f8cc8136e244 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 3 Sep 2025 09:30:25 +0100 Subject: [PATCH 2/6] fix: set version in one place (#73) --- .github/workflows/go-test.yml | 5 +++++ .github/workflows/release.yml | 5 +++++ CHANGELOG.md | 4 ++++ MAINTAINERS.md | 10 +++++----- Makefile | 6 +++++- chat/package.json | 4 ++-- check_unstaged.sh | 25 +++++++++++++++++++++++++ cmd/root.go | 3 ++- cmd/server/server.go | 4 ++++ internal/version/version.go | 5 +++++ lib/httpapi/server.go | 3 ++- lib/logctx/logctx.go | 11 +++++++++++ main.go | 2 ++ openapi.json | 4 ++-- set_version.sh | 13 +++++++++++++ 15 files changed, 92 insertions(+), 12 deletions(-) create mode 100755 check_unstaged.sh create mode 100644 internal/version/version.go create mode 100755 set_version.sh diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index c38c6ff..5e10425 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -33,3 +33,8 @@ jobs: uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: version: v2.1 + + - name: Check for unstaged changes + run: | + make gen + ./check_unstaged.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ac9b26..10e2ba2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,6 +33,11 @@ jobs: - name: Install Chat Dependencies run: cd chat && bun install + - name: Run make gen and check for unstaged changes + run: | + make gen + ./check_unstaged.sh + - name: Build and Upload env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 626fd5a..85eae6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.6.2 + +- Fix incorrect version string. + ## 0.6.1 ### Features diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 3fbc5af..5e8f39f 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -5,15 +5,15 @@ Before performing a release, perform a local "smoke-test". If everything seems OK, you can proceed to do the following: -1. Update the version string in the following places: - - `openapi.json` - - `chat/package.json` - - `lib/httpapi/server.go` +1. Update the version string in `internal/version/version.go` and run `make gen`. 2. Add details in `CHANGELOG.md` on what changed. 3. Create a PR with the subject `chore: update version to X.Y.Z` -4. Once the above PR is approved and merged, create a new git tag `vX.Y.Z` pointing to the commit of the above PR merged to `main`:S +4. Once the above PR is approved and merged, create a new git tag `vX.Y.Z` pointing to the commit of the above PR merged to `main`: ```shell + # Ensure your local copy is up to date with main. Be sure to stash any changes first. + git fetch origin + git reset --hard origin/main # Fetch existing tags first! git fetch --tags git tag -a vX.Y.Z -m 'vX.Y.Z' diff --git a/Makefile b/Makefile index 1692d07..e74757c 100644 --- a/Makefile +++ b/Makefile @@ -16,5 +16,9 @@ embed: $(CHAT_SOURCES_STAMP) @echo "Chat build is up to date." .PHONY: build -build: embed +build: gen embed CGO_ENABLED=0 go build -o ${BINPATH} main.go + +.PHONY: gen +gen: + go generate ./... diff --git a/chat/package.json b/chat/package.json index d6411ce..e6e79e0 100644 --- a/chat/package.json +++ b/chat/package.json @@ -1,6 +1,6 @@ { "name": "chat", - "version": "0.6.1", + "version": "0.6.2", "private": true, "scripts": { "dev": "next dev --turbopack", @@ -45,4 +45,4 @@ "tw-animate-css": "^1.3.0", "typescript": "^5" } -} \ No newline at end of file +} diff --git a/check_unstaged.sh b/check_unstaged.sh new file mode 100755 index 0000000..98cd3cd --- /dev/null +++ b/check_unstaged.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +FILES=() +IFS=$'\n' read -r -d '' -a FILES < <(git ls-files --other --modified --exclude-standard && printf '\0') +if [[ ${#FILES[@]} -gt 0 ]]; then + + echo + echo "The following files contain unstaged changes:" + echo + for file in "${FILES[@]}"; do + echo " - $file" + done + + echo + echo "These are the changes:" + echo + for file in "${FILES[@]}"; do + git --no-pager diff -- "$file" 1>&2 + done + + echo + echo "ERROR: Unstaged changes, see above for details." + exit 1 +fi diff --git a/cmd/root.go b/cmd/root.go index 9f7ac65..2980d19 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,6 +6,7 @@ import ( "github.com/coder/agentapi/cmd/attach" "github.com/coder/agentapi/cmd/server" + "github.com/coder/agentapi/internal/version" "github.com/spf13/cobra" ) @@ -13,7 +14,7 @@ var rootCmd = &cobra.Command{ Use: "agentapi", Short: "AgentAPI CLI", Long: `AgentAPI - HTTP API for Claude Code, Goose, Aider, Gemini and Codex`, - Version: "0.4.1", + Version: version.Version, } func Execute() { diff --git a/cmd/server/server.go b/cmd/server/server.go index 33c294e..912ab66 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -184,6 +184,10 @@ func CreateServerCmd() *cobra.Command { return } logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) + if viper.GetBool(FlagPrintOpenAPI) { + // We don't want log output here. + logger = slog.New(logctx.DiscardHandler) + } ctx := logctx.WithLogger(context.Background(), logger) if err := runServer(ctx, logger, cmd.Flags().Args()); err != nil { fmt.Fprintf(os.Stderr, "%+v\n", err) diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..cb53b66 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,5 @@ +// package version defines the current version of agentapi. + +package version + +var Version = "0.6.2" diff --git a/lib/httpapi/server.go b/lib/httpapi/server.go index 2d25fca..e8abab9 100644 --- a/lib/httpapi/server.go +++ b/lib/httpapi/server.go @@ -13,6 +13,7 @@ import ( "time" "unicode" + "github.com/coder/agentapi/internal/version" "github.com/coder/agentapi/lib/logctx" mf "github.com/coder/agentapi/lib/msgfmt" st "github.com/coder/agentapi/lib/screentracker" @@ -188,7 +189,7 @@ func NewServer(ctx context.Context, config ServerConfig) (*Server, error) { }) router.Use(corsMiddleware.Handler) - humaConfig := huma.DefaultConfig("AgentAPI", "0.6.1") + humaConfig := huma.DefaultConfig("AgentAPI", version.Version) humaConfig.Info.Description = "HTTP API for Claude Code, Goose, and Aider.\n\nhttps://github.com/coder/agentapi" api := humachi.New(router, humaConfig) formatMessage := func(message string, userInput string) string { diff --git a/lib/logctx/logctx.go b/lib/logctx/logctx.go index 8f820fc..7280dab 100644 --- a/lib/logctx/logctx.go +++ b/lib/logctx/logctx.go @@ -23,3 +23,14 @@ func From(ctx context.Context) *slog.Logger { } panic("no logger found in context") } + +// plucked from log/slog +// remove once we update to go 1.24 +var DiscardHandler slog.Handler = discardHandler{} + +type discardHandler struct{} + +func (dh discardHandler) Enabled(context.Context, slog.Level) bool { return false } +func (dh discardHandler) Handle(context.Context, slog.Record) error { return nil } +func (dh discardHandler) WithAttrs(attrs []slog.Attr) slog.Handler { return dh } +func (dh discardHandler) WithGroup(name string) slog.Handler { return dh } diff --git a/main.go b/main.go index ad53ab8..571cf32 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,7 @@ package main +//go:generate sh -c "go run main.go server --print-openapi dummy > openapi.json" +//go:generate ./set_version.sh import "github.com/coder/agentapi/cmd" func main() { diff --git a/openapi.json b/openapi.json index d87c9b0..c0ee716 100644 --- a/openapi.json +++ b/openapi.json @@ -307,7 +307,7 @@ "info": { "description": "HTTP API for Claude Code, Goose, and Aider.\n\nhttps://github.com/coder/agentapi", "title": "AgentAPI", - "version": "0.6.1" + "version": "0.6.2" }, "openapi": "3.1.0", "paths": { @@ -497,4 +497,4 @@ } } } -} \ No newline at end of file +} diff --git a/set_version.sh b/set_version.sh new file mode 100755 index 0000000..d31c32b --- /dev/null +++ b/set_version.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +if ! command -v go >/dev/null 2>&1; then + echo "go is required to run this script" && exit 1 +elif ! command -v jq >/dev/null 2>&1; then + echo "jq is required to run this script" && exit 1 +fi + +version=$(go run main.go --version | awk '{print $3}') + +jq --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json +jq --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json From 76da286f93f117abf0daf89918f36445cc10fcac Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 3 Sep 2025 12:02:41 +0100 Subject: [PATCH 3/6] chore: add release automation script (#74) Co-authored-by: Mathias Fredriksson --- MAINTAINERS.md | 21 ++++---------------- main.go | 2 +- release.sh | 38 ++++++++++++++++++++++++++++++++++++ set_version.sh => version.sh | 2 ++ 4 files changed, 45 insertions(+), 18 deletions(-) create mode 100755 release.sh rename set_version.sh => version.sh (96%) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 5e8f39f..32954b3 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -8,24 +8,11 @@ If everything seems OK, you can proceed to do the following: 1. Update the version string in `internal/version/version.go` and run `make gen`. 2. Add details in `CHANGELOG.md` on what changed. 3. Create a PR with the subject `chore: update version to X.Y.Z` -4. Once the above PR is approved and merged, create a new git tag `vX.Y.Z` pointing to the commit of the above PR merged to `main`: +4. Once the above PR is approved and merged, update your local branch and run `release.sh`. + If the script reports errors, fix them before continuing. + If there are no issues, it will output the Github tag URL. - ```shell - # Ensure your local copy is up to date with main. Be sure to stash any changes first. - git fetch origin - git reset --hard origin/main - # Fetch existing tags first! - git fetch --tags - git tag -a vX.Y.Z -m 'vX.Y.Z' - ``` - -5. Push the tag: - - ```shell - git push origin tag vX.Y.Z - ``` - -6. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag". +5. Visit `https://github.com/coder/agentapi/releases/tag/vX.Y.Z` and "Create release from tag". - Select the tag you pushed previously. - Select the previous tag and "Generate release notes". Amend as required. diff --git a/main.go b/main.go index 571cf32..67fe4f3 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main //go:generate sh -c "go run main.go server --print-openapi dummy > openapi.json" -//go:generate ./set_version.sh +//go:generate ./version.sh import "github.com/coder/agentapi/cmd" func main() { diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..75bab1f --- /dev/null +++ b/release.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -euo pipefail + +GIT_BRANCH="${GIT_BRANCH:-main}" +echo "GIT_BRANCH=${GIT_BRANCH}" +LOCAL_HEAD=$(git rev-parse --short "${GIT_BRANCH}") +echo "LOCAL_HEAD=${LOCAL_HEAD}" +REMOTE_HEAD=$(git rev-parse --short origin/"${GIT_BRANCH}") +echo "REMOTE_HEAD=${REMOTE_HEAD}" +if [[ "${LOCAL_HEAD}" != "${REMOTE_HEAD}" ]]; then + echo "Please ensure your local branch is up to date before continuing." + exit 1 +fi + +VERSION="" +if ! VERSION=$(./version.sh); then + echo "version.sh exited with a non-zero status code. Fix this before continuing." + exit 1 +elif [[ -z "${VERSION}" ]]; then + echo "Version reported by version.sh was empty. Fix this before continuing." + exit 1 +fi + +echo "VERSION=${VERSION}" +./check_unstaged.sh || exit 1 + +if ! grep -q "## v${VERSION}" CHANGELOG.md; then + echo "Please update CHANGELOG.md with details for ${VERSION} before continuing." + exit 1 +fi + +TAG_NAME="v${VERSION}" +echo "TAG_NAME=${TAG_NAME}" +git fetch --tags +git tag -a "${TAG_NAME}" -m "${TAG_NAME}" +git push origin tag "${TAG_NAME}" + +echo "https://github.com/coder/agentapi/releases/new?tag=${TAG_NAME}" diff --git a/set_version.sh b/version.sh similarity index 96% rename from set_version.sh rename to version.sh index d31c32b..7a0d187 100755 --- a/set_version.sh +++ b/version.sh @@ -11,3 +11,5 @@ version=$(go run main.go --version | awk '{print $3}') jq --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json jq --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json + +echo -n "${version}" From 7b32e00df2a37abb1bb60fd498252fc59d988efd Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 3 Sep 2025 12:05:27 +0100 Subject: [PATCH 4/6] chore: fix changelog (#75) --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85eae6a..99b4e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # Changelog -## 0.6.2 +## v0.6.2 - Fix incorrect version string. -## 0.6.1 +## v0.6.1 ### Features - Handle animation on Amp cli start screen. From 66713c74a37050671853bbbe87b3e7d135df7d14 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 3 Sep 2025 12:22:37 +0100 Subject: [PATCH 5/6] ci: fix release build step (#76) --- CHANGELOG.md | 4 ++++ Makefile | 2 +- chat/package.json | 2 +- internal/version/version.go | 2 +- openapi.json | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b4e19..30dd0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.6.3 + +- CI fixes. + ## v0.6.2 - Fix incorrect version string. diff --git a/Makefile b/Makefile index e74757c..97d78c2 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ embed: $(CHAT_SOURCES_STAMP) @echo "Chat build is up to date." .PHONY: build -build: gen embed +build: embed CGO_ENABLED=0 go build -o ${BINPATH} main.go .PHONY: gen diff --git a/chat/package.json b/chat/package.json index e6e79e0..8729700 100644 --- a/chat/package.json +++ b/chat/package.json @@ -1,6 +1,6 @@ { "name": "chat", - "version": "0.6.2", + "version": "0.6.3", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/internal/version/version.go b/internal/version/version.go index cb53b66..9111af5 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -2,4 +2,4 @@ package version -var Version = "0.6.2" +var Version = "0.6.3" diff --git a/openapi.json b/openapi.json index c0ee716..5df99c5 100644 --- a/openapi.json +++ b/openapi.json @@ -307,7 +307,7 @@ "info": { "description": "HTTP API for Claude Code, Goose, and Aider.\n\nhttps://github.com/coder/agentapi", "title": "AgentAPI", - "version": "0.6.2" + "version": "0.6.3" }, "openapi": "3.1.0", "paths": { From 2c4fccbad1e5de3a8e7dae7bca764ba6aeab02d8 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 3 Sep 2025 13:35:12 +0100 Subject: [PATCH 6/6] chore: ensure sorted jq output (#77) --- chat/package.json | 30 +++++++++++++++--------------- version.sh | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/chat/package.json b/chat/package.json index 8729700..fec1ebc 100644 --- a/chat/package.json +++ b/chat/package.json @@ -1,18 +1,4 @@ { - "name": "chat", - "version": "0.6.3", - "private": true, - "scripts": { - "dev": "next dev --turbopack", - "build": "next build", - "start": "next start", - "lint": "next lint", - "export": "GITHUB_PAGES=true next build", - "serve-static": "npx serve out", - "deploy-gh-pages": "GITHUB_PAGES=true next build && gh-pages -d out --nojekyll -e chat -f", - "storybook": "storybook dev -p 6006", - "build-storybook": "storybook build" - }, "dependencies": { "@radix-ui/react-dropdown-menu": "^2.1.14", "@radix-ui/react-slot": "^1.2.2", @@ -44,5 +30,19 @@ "tailwindcss": "^4", "tw-animate-css": "^1.3.0", "typescript": "^5" - } + }, + "name": "chat", + "private": true, + "scripts": { + "build": "next build", + "build-storybook": "storybook build", + "deploy-gh-pages": "GITHUB_PAGES=true next build && gh-pages -d out --nojekyll -e chat -f", + "dev": "next dev --turbopack", + "export": "GITHUB_PAGES=true next build", + "lint": "next lint", + "serve-static": "npx serve out", + "start": "next start", + "storybook": "storybook dev -p 6006" + }, + "version": "0.6.3" } diff --git a/version.sh b/version.sh index 7a0d187..a3fda1a 100755 --- a/version.sh +++ b/version.sh @@ -9,7 +9,7 @@ fi version=$(go run main.go --version | awk '{print $3}') -jq --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json -jq --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json +jq --sort-keys --arg version "${version}" '.info.version = $version' openapi.json > openapi.json.tmp && mv openapi.json.tmp openapi.json +jq --sort-keys --arg version "${version}" '.version = $version' chat/package.json > chat/package.json.tmp && mv chat/package.json.tmp chat/package.json echo -n "${version}"