Skip to content
Open
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
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,26 @@ updates:
prefix: "ci"
include: "scope"
open-pull-requests-limit: 5

# Go modules. Grouped so a week's worth of patch bumps arrives as one PR
# rather than a dozen: the point is that a security fix lands quickly, not
# that every module gets its own review.
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:37"
timezone: "UTC"
labels:
- "dependencies"
- "go"
commit-message:
prefix: "build"
include: "scope"
open-pull-requests-limit: 5
groups:
go-minor-and-patch:
update-types:
- "minor"
- "patch"
112 changes: 112 additions & 0 deletions .github/scripts/release-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
4. Bumps the version (patch by default)
5. Rewrites CHANGELOG.md and cmd/cube/main.go
6. Creates (or updates) a release/vX.Y.Z PR against main
7. Triggers CI on the release branch via workflow_dispatch (PRs created
with GITHUB_TOKEN are approval-gated, workflow_dispatch is not)
8. Waits for CI to pass, then requests review from REVIEW_REQUESTEE
(a single OWNERS member — pinging the whole team is noisy)

Usage from GitHub Actions workflow:
python3 .github/scripts/release-bot.py
Expand All @@ -24,12 +28,17 @@
import re
import subprocess
import sys
import time
from datetime import datetime, timezone, date, timedelta
from pathlib import Path

REPO = "suanova/cube"
MAIN_BRANCH = "main"

# Only this OWNERS member gets a review request on release PRs — pinging
# the whole team on every weekly release is noisy.
REVIEW_REQUESTEE = "yanmxa"

# ── helpers ──────────────────────────────────────────────────────────────


Expand Down Expand Up @@ -207,6 +216,92 @@ def read_version_from_main_go():
return m.group(1) if m else None


def read_owners():
"""
Parse reviewer usernames from the OWNERS file — the YAML `reviewers:`
list, falling back to `approvers:`, then plain line-per-username.
"""
try:
raw = Path("OWNERS").read_text()
except FileNotFoundError:
return []
for key in ("reviewers", "approvers"):
m = re.search(rf"^{key}:\s*$([\s\S]*?)(?=^[a-z]+:\s*$|\Z)", raw, re.MULTILINE)
if m:
users = re.findall(r"^\s*-\s*(\S+)", m.group(1), re.MULTILINE)
if users:
return users
# Plain text: one username per line, skip empty lines, comments, and keys
return [
line.strip()
for line in raw.splitlines()
if line.strip() and not line.strip().startswith("#") and ":" not in line
]


def wait_for_ci_and_request_review(pr_number, branch, owners):
"""
Poll the dispatched CI run on the release branch until it finishes.
When it passes, request review from the designated OWNERS member so
the release PR gets noticed.
"""
deadline = time.time() + 30 * 60 # give CI up to 30 minutes
state = None
while time.time() < deadline:
query = subprocess.run(
[
"gh", "run", "list", "--repo", REPO, "--workflow", "ci.yml",
"--branch", branch,
"--json", "databaseId,event,status,conclusion",
"--limit", "5",
],
capture_output=True,
text=True,
)
if query.returncode == 0 and query.stdout.strip():
runs = json.loads(query.stdout)
# Only the run we dispatched — pull_request runs on this branch
# may exist and are approval-gated, so ignore them.
mine = [r for r in runs if r.get("event") == "workflow_dispatch"]
if mine:
state = mine[0]
if state["status"] == "completed":
break
time.sleep(30)

if not state or state["status"] != "completed":
print(f"::warning:: Timed out waiting for CI on {branch} — review not requested")
return
if state["conclusion"] != "success":
print(
f"::warning:: CI on {branch} concluded {state['conclusion']} "
f"— review not requested"
)
return
if not owners:
print("::warning:: OWNERS list is empty — no reviewers to request")
return
if REVIEW_REQUESTEE not in owners:
print(
f"::warning:: {REVIEW_REQUESTEE} is not in OWNERS "
f"— review not requested"
)
return

edit = subprocess.run(
[
"gh", "pr", "edit", str(pr_number), "--repo", REPO,
"--add-reviewer", REVIEW_REQUESTEE,
],
capture_output=True,
text=True,
)
if edit.returncode != 0:
print(f"::warning:: Failed to request review: {edit.stderr.strip()}")
return
print(f"Requested review from {REVIEW_REQUESTEE} on PR #{pr_number}")


def main():
dry_run = os.environ.get("DRY_RUN", "false").lower() == "true"
bump_type = os.environ.get("VERSION_BUMP", "patch")
Expand Down Expand Up @@ -364,6 +459,23 @@ def main():
])
print(f"\n✅ Release PR created: {result}")

# 11. The PR was created with GITHUB_TOKEN, so its pull_request event
# does not trigger CI (approval-gated). Dispatch CI on the release
# branch explicitly, wait for it to finish, then request review
# from the designated OWNERS member.
pr_number = result.rstrip("/").split("/")[-1]
dispatch = subprocess.run(
["gh", "workflow", "run", "ci.yml", "--repo", REPO, "--ref", branch],
capture_output=True,
text=True,
)
if dispatch.returncode != 0:
print(
f"::warning:: Failed to dispatch CI on {branch}: "
f"{dispatch.stderr.strip()}"
)
wait_for_ci_and_request_review(pr_number, branch, read_owners())


if __name__ == "__main__":
main()
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [main]
pull_request:
branches: [main]
# The release bot triggers CI on release/vX.Y.Z branches this way:
# workflow_dispatch runs always execute, unlike pull_request runs on
# GITHUB_TOKEN-created PRs (which are gated behind manual approval).
workflow_dispatch:

permissions:
contents: read
Expand All @@ -18,15 +22,15 @@ jobs:
with:
go-version: '1.25.8'
cache: true
- name: Install format tools
run: make install-format-tools
- name: Install dev tools
run: make install-format-tools install-lint-tools
- name: Format check
run: make format-check
- name: Build
run: make build-all
- name: Unit + integration tests (merged coverage)
run: make cover
- name: Vet
- name: Vet + lint + layer check
run: make lint

test-windows:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-go@v7
with:
go-version: '1.25.8'
go-version: '1.25.13'

- name: Install format tools
run: make install-format-tools
Expand Down
60 changes: 60 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# golangci-lint configuration.
#
# `make lint` runs this alongside go vet, the format check, and layercheck.
#
# The linter set is deliberately narrow: every linter here reports a defect, not
# a style preference, so a finding is always worth acting on and the gate never
# turns into noise a contributor learns to ignore. Style is already settled by
# gofmt + goimports.
#
# errcheck — a discarded error is a failure the code decided not to
# notice. This is how config saves silently overwrote user
# files (#480): the parse error was never looked at.
# ineffassign — a value assigned and then overwritten before any read is
# either dead code or a missing use of the first value.
#
# Adding a linter means fixing its findings in the same change, so the tree
# stays clean and `make lint` keeps a zero-tolerance meaning.
version: "2"

linters:
default: none
enable:
- errcheck
- ineffassign

settings:
errcheck:
# Cleanup calls whose failure the caller genuinely cannot act on: the
# write already happened (or is being abandoned), and the process is on
# its way out of the scope. Everything not listed here must be handled.
exclude-functions:
- (io.Closer).Close
- (io.ReadCloser).Close
- (io.WriteCloser).Close
- (*os.File).Close
- (net.Listener).Close
- (*net/http.Server).Close
- (*compress/gzip.Reader).Close
- (*archive/zip.ReadCloser).Close
- os.Remove
- os.RemoveAll
# os.Setenv/Unsetenv only fail on a name containing "=" or NUL, which no
# caller here can produce — every name is a fixed provider env var.
- os.Setenv
- os.Unsetenv
# Writers to stdout/stderr and to in-memory builders. A failed write to
# a closed terminal is not something the TUI can report anywhere.
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
- io.WriteString

exclusions:
rules:
# Test helpers set up state whose failure surfaces as the test failing.
- path: _test\.go
linters: [errcheck]

formatters:
enable: []
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to San are documented here.
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/).

## [v1.22.4] - 2026-08-18

### Added
- Rename bypass permissions to YOLO mode, gate it from /config ([@yanmxa](https://github.com/yanmxa) in [#470](https://github.com/genai-io/san/pull/470))
### Fixed
- Derive current version from main.go to avoid re-releasing old versions ([@hchenxa](https://github.com/hchenxa) in [#476](https://github.com/genai-io/san/pull/476))
- Correct V4 pricing and default to the API's own thinking effort ([@yanmxa](https://github.com/yanmxa) in [#473](https://github.com/genai-io/san/pull/473))
## [v1.22.3] - 2026-08-11

### Added
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.sync.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Upstream Sync Changelog

## 2026-09-28 — 8 commits from san#main

| SHA | Intent | Type | Risk |
|-----|--------|------|------|
| `84528e211ff2` | Fix the release bot so it derives the current version from the max of the latest git tag and cmd/san/main.go, skips already-changelogged versions, and drops already-listed PRs, preventing duplicate release PRs from regression. | bugfix | low |
| `981c9b44d165` | Release version 1.22.4: bump the version constant in cmd/san/main.go and add the corresponding CHANGELOG entry documenting prior features and fixes. | internal | low |
| `7bce5d7cb47d` | Make the weekly release bot trigger CI automatically on its release PR via workflow_dispatch (bypassing GITHUB_TOKEN approval gating), wait for CI to pass, then request review from a single designated OWNERS member (yanmxa). | internal | low |
| `67f8090eb8f8` | Mechanically modernize Go idioms across the whole tree by applying the x/tools modernize analyzer (slices.Backward, strings SplitSeq/FieldsSeq, maps.Copy, min/max builtins, range-over-int, any, etc.) and drop misleading no-op `omitempty` tags on non-pointer struct fields — all rewrites are behavior-preserving. | refactor | low |
| `9c8d3b8dd54c` | Fix Anthropic Claude 4.6+ adaptive thinking payloads and correct stale model catalog limits/pricing/defaults across LLM providers against vendor docs. | bugfix | medium |
| `49824b98a769` | Add golangci-lint (errcheck + ineffassign) as a zero-tolerance CI gate and fix all previously discarded errors it exposed — false TaskCreate success on dependency failure, silently dropped tracker storage/lock setup, ignored MCP removal failures, and version --json exiting 0 after a failed encode. | bugfix | medium |
| `91c5b4172fae` | Add reachable-vulnerability scanning (govulncheck) as a gating weekly CI job, bump the Go toolchain pin and two vulnerable modules, and have Dependabot track Go module updates | internal | low |
| `1233c6e9f58f` | Dependabot batch bump of 11 Go module dependencies (minor/patch) with a compensating test fix that trims full-width padding in scrollback rendering assertions after ultraviolet#128 started emitting trailing blank cells as spaces. | internal | low |
## 2026-08-16 — 3 commits from san#main

| SHA | Intent | Type | Risk |
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ LDFLAGS := -ldflags "-s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILDT
export CGO_ENABLED := 0
GOFILES := $(shell find . -path './vendor' -prune -o -path './.git' -prune -o -name '*.go' -print)
GOIMPORTS_VERSION := v0.43.0
GOLANGCI_VERSION := v2.12.2
GOVULNCHECK_VERSION := v1.7.0

.PHONY: build build-all install clean release release-push test cover format format-check lint install-format-tools check-format-tools
.PHONY: build build-all install clean release release-push test cover format format-check lint lint-go install-format-tools install-lint-tools check-format-tools check-lint-tools

build: format
@mkdir -p $(BINDIR)
Expand All @@ -32,9 +34,15 @@ install: build
install-format-tools:
go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)

install-lint-tools:
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_VERSION)

check-format-tools:
@command -v goimports >/dev/null || go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)

check-lint-tools:
@command -v golangci-lint >/dev/null || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_VERSION)

format: check-format-tools
@gofmt -w $(GOFILES)
@goimports -w $(GOFILES)
Expand All @@ -56,8 +64,15 @@ format-check: check-format-tools
lint:
go vet ./...
@$(MAKE) format-check
@$(MAKE) lint-go
@$(MAKE) lint-layers

# lint-go runs the linters configured in .golangci.yml. They report defects, not
# style, so the tree is expected to be clean — see the config for the rule on
# adding one.
lint-go: check-lint-tools
golangci-lint run --timeout 5m ./...

lint-layers:
@go run ./tools/layercheck

Expand Down Expand Up @@ -89,6 +104,15 @@ ci: format-check build-all lint
clean:
rm -rf $(BINDIR)

# vulncheck reports known vulnerabilities in the dependency graph that this
# code can actually reach. Reachability is what makes it worth gating on: an
# advisory in a package nobody calls is not reported, so a finding here is
# always a real exposure. CI runs the same command.
.PHONY: vulncheck
vulncheck:
@command -v govulncheck >/dev/null || go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)
govulncheck ./...

# Serve the website locally for testing. Opens http://localhost:8080 in the
# default browser. Requires Python 3 (available on macOS and most Linux distros
# by default). Stop with Ctrl-C.
Expand Down
5 changes: 4 additions & 1 deletion cmd/cube/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ var versionCmd = &cobra.Command{
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(info)
if err := enc.Encode(info); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
return
}

Expand Down
5 changes: 1 addition & 4 deletions cmd/cube/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,7 @@ func (pw *progressWriter) spin() {

func (pw *progressWriter) printBar(width int) {
pct := float64(pw.written) / float64(pw.total)
filled := int(pct * float64(width))
if filled > width {
filled = width
}
filled := min(int(pct*float64(width)), width)
bar := strings.Repeat("█", filled) + strings.Repeat("░", width-filled)
fmt.Fprintf(os.Stderr, "\r downloading [%s] %3.0f%%", bar, pct*100)
}
Expand Down
Loading
Loading