Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.6.2

- Fix incorrect version string.

## 0.6.1

### Features
Expand Down
10 changes: 5 additions & 5 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
4 changes: 2 additions & 2 deletions chat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chat",
"version": "0.6.1",
"version": "0.6.2",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down Expand Up @@ -45,4 +45,4 @@
"tw-animate-css": "^1.3.0",
"typescript": "^5"
}
}
}
25 changes: 25 additions & 0 deletions check_unstaged.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (

"github.com/coder/agentapi/cmd/attach"
"github.com/coder/agentapi/cmd/server"
"github.com/coder/agentapi/internal/version"
"github.com/spf13/cobra"
)

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() {
Expand Down
4 changes: 4 additions & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// package version defines the current version of agentapi.

package version

var Version = "0.6.2"
3 changes: 2 additions & 1 deletion lib/httpapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions lib/logctx/logctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -497,4 +497,4 @@
}
}
}
}
}
13 changes: 13 additions & 0 deletions set_version.sh
Original file line number Diff line number Diff line change
@@ -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