mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-08-31 00:50:02 +08:00
a39805aa89
Empty cli/ Go module with Factory + Options skeleton that all v0.x commands plug into. Foundation packages (10 internal/): - cmdutil: Factory(3 closure: Config/Client/Prompter) + Options + Errors with namespaced ErrorCode + typed predicates (IsAuthError / IsNotFound / IsTransient / IsAuthExpired) + Exporter + AddJSONFlags + ExitCode/PrintError - iostreams: package singleton with TTY detection; ColorEnabled honors NO_COLOR / TERM=dumb on demand - agent: mode + detect + annotations (Stripe pkg/useragent pattern; CLAUDECODE / CURSOR_AGENT / CODEX_* / AIDER_* / CONTINUE_* / OPENCODE_* / GEMINICODER env detection) - build: ldflags-injected version/commit/date - safepaths: separator-aware path-traversal protection - config: yaml.v3 schema + atomic save 0600 (XDG-style) - format: success/failure envelope (code/hint/request_id/risk/retryable/ console_url) with typed RiskLevel - prompt: Prompter interface + AgentPrompter (rejects in agent mode) - secrets: file 0600 store with weknora:<context>:<key> namespace - testutil: XDGTempDir(t) test helper Smoke command: weknora version (-/--json). Build/test/vet matrix in .github/workflows/cli.yml across linux x macos x windows x Go 1.24. Factory.Client returns CodeLocalUnimplemented until PR-3 wires the SDK adapter; PR-1 commands (version) don't need it.
48 lines
1.3 KiB
Makefile
48 lines
1.3 KiB
Makefile
# Makefile for the WeKnora CLI (cli/ Go module).
|
|
#
|
|
# Usage:
|
|
# make build compile to ./bin/weknora with version metadata
|
|
# make test go test ./...
|
|
# make test-coverage same with coverage report
|
|
# make lint go vet (golangci-lint added in PR-9)
|
|
# make tidy go mod tidy
|
|
# make clean remove ./bin
|
|
|
|
BINARY := weknora
|
|
BUILD_DIR := bin
|
|
PKG := github.com/Tencent/WeKnora/cli
|
|
|
|
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
|
|
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
LDFLAGS := -s -w \
|
|
-X $(PKG)/internal/build.Version=$(VERSION) \
|
|
-X $(PKG)/internal/build.Commit=$(COMMIT) \
|
|
-X $(PKG)/internal/build.Date=$(DATE)
|
|
|
|
.PHONY: build test test-coverage lint tidy clean help
|
|
|
|
build:
|
|
@mkdir -p $(BUILD_DIR)
|
|
go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) .
|
|
|
|
test:
|
|
go test ./...
|
|
|
|
test-coverage:
|
|
go test -coverprofile=coverage.out ./...
|
|
go tool cover -func=coverage.out
|
|
|
|
lint:
|
|
go vet ./...
|
|
|
|
tidy:
|
|
go mod tidy
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR) coverage.out
|
|
|
|
help:
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|