Files
WeKnora/.github/workflows/cli.yml
T
nullkey a39805aa89 feat(cli): scaffold weknora CLI module foundation (PR-1)
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.
2026-05-07 23:19:46 +08:00

53 lines
1.4 KiB
YAML

name: CLI
# Builds and tests the cli/ Go module on every push / PR that touches it.
# Foundation PR (PR-1) gates: 3-platform `go build` + `go test ./...` green.
on:
push:
branches: [main]
paths:
- 'cli/**'
- '.github/workflows/cli.yml'
pull_request:
paths:
- 'cli/**'
- '.github/workflows/cli.yml'
defaults:
run:
working-directory: cli
# Windows default is PowerShell, which tokenizes `go test -coverprofile=coverage.out ./...`
# in a way that detaches `.out` as a separate positional package arg.
# Force bash everywhere so the run lines parse identically across platforms
# (Git Bash is preinstalled on windows-latest runners).
shell: bash
permissions:
contents: read
jobs:
test:
name: test (${{ matrix.os }} / go ${{ matrix.go }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go: ['1.24']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache-dependency-path: cli/go.sum
- name: go build
run: go build ./...
- name: go test
run: go test -race -coverprofile=coverage.out ./...
- name: go vet
run: go vet ./...
- name: coverage report
if: matrix.os == 'ubuntu-latest'
run: go tool cover -func=coverage.out