Skip to content

Commit 0aae799

Browse files
committed
Introduces 'factory squash' to automate feature branch cleanup via soft reset.
Refactors linter configuration to use embedded assets for strict, security, and complexity modes. Enhances 'product format' with '--remove-directives' and '--strict' flags, including safety guards. Refactors 'setupidentity' to adhere to strict coding standards. Updates .golangci.yml to remove deprecated linters and silence unused rule warnings.
1 parent 86dd8d1 commit 0aae799

79 files changed

Lines changed: 5203 additions & 493 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v6
22+
with:
23+
go-version: stable
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v6
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
.contextvibes.yaml
1818
notes.txt
1919
coverage.out
20-
thea/
2120
context_*.md
2221
.env
2322
!contextvibes.nix
@@ -31,3 +30,4 @@ contextvibes.md
3130
upstream_context.txt
3231
_notes.txt
3332
_contextvibes.md
33+
.idx/local.nix

.golangci.yml

Lines changed: 92 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,111 @@ run:
55
concurrency: 2
66
modules-download-mode: readonly
77

8+
output:
9+
# Satisfies "order the results by file"
10+
sort-order:
11+
- file
12+
- linter
13+
814
linters:
9-
# 1. Enable EVERY available linter
1015
default: all
11-
12-
# 2. Disable specific linters.
1316
disable:
14-
# --- DEPRECATED / REMOVED LINTERS ---
15-
- noinlineerr # Disabled: We prefer the standard idiom 'if err := ...; err != nil' to reduce scope.
16-
- wsl
17-
18-
# --- LEVEL 1: CRITICAL BUGS & SECURITY ---
19-
# - forcetypeassert
20-
# - gosec
21-
22-
# --- LEVEL 2: STYLE & MODERNIZATION ---
23-
# - modernize
24-
# - perfsprint
25-
# - revive
26-
# - unused
27-
# - goconst
28-
29-
# --- LEVEL 3: ERROR HANDLING & BEST PRACTICES ---
30-
# - err113
31-
# - nilerr
32-
# - nlreturn
33-
# - staticcheck
34-
# - errcheck # Unchecked errors
35-
# - nonamedreturns # Named returns usage
36-
37-
# --- LEVEL 4: COMPLEXITY & REFACTORING ---
38-
# - cyclop
39-
# - funlen
40-
# - gocognit
41-
# - maintidx
42-
# - mnd
43-
# - nestif
44-
# - wrapcheck
45-
46-
# --- LEVEL 5: STRICT STANDARDS & OPINIONS ---
47-
# - depguard
48-
# - exhaustruct
49-
# - gochecknoglobals
50-
# - godoclint
51-
# - ireturn
52-
# - lll
53-
# - varnamelen
54-
# - wsl_v5
55-
# - forbidigo # Forbidden identifiers (fmt.Print, etc)
56-
# - funcorder # Function ordering
57-
# - gochecknoinits # Init functions
58-
# - godox # TODOs
59-
# - goprintffuncname # Printf-like naming
60-
# - tagliatelle # JSON struct tags
61-
# - nolintlint
17+
# --- Style & Idiom (Too Opinionated) ---
18+
- wsl # Too strict; conflicts with logical grouping.
6219

63-
# --- TESTING ---
64-
# - testifylint
65-
# - usetesting
66-
# - paralleltest # (Added to ensure tests run without forcing parallel)
20+
# --- Style Preference ---
21+
- noinlineerr # Disabled to allow idiomatic `if err :=...`
22+
- err113
23+
- errcheck
24+
- exhaustruct
25+
- funlen
26+
- gochecknoinits
27+
- gocognit
28+
- gosec
29+
- lll
30+
- mnd
31+
- nestif
32+
- revive
33+
- varnamelen
34+
- cyclop
35+
- gochecknoglobals
36+
- unparam
6737

68-
# --- NOISE / LOW VALUE ---
69-
# - gocritic
70-
# - thelper
71-
# - unparam
72-
# - exhaustive # Exhaustive switch statements
38+
exclusions:
39+
generated: strict
40+
warn-unused: true
41+
presets:
42+
# - comments
43+
# - std-error-handling
44+
# - common-false-positives
45+
# - legacy
46+
rules:
47+
- path: "cmd/version/version.go"
48+
linters:
49+
- gochecknoinits
50+
- exhaustruct
51+
- gochecknoglobals
52+
- errcheck
7353

7454
settings:
75-
ireturn:
76-
allow:
77-
- error
78-
- github.com/contextvibes/cli/internal/workitem.Provider
79-
- github.com/contextvibes/cli/internal/exec.CommandExecutor
55+
gofumpt:
56+
extra-rules: true
57+
8058
depguard:
8159
rules:
60+
# Rule 1: Production Code (Main)
8261
main:
83-
list-mode: lax
62+
list-mode: strict
8463
files:
85-
- "!**/*_a _file.go"
64+
- "$all"
65+
- "!$test" # Critical: Exclude test files from this strict rule
8666
allow:
8767
- $gostd
88-
- github.com/OpenPeeDeeP
68+
# Allow SDKs
69+
- golang.org/x/oauth2
70+
- github.com/spf13/cobra
71+
- google.golang.org/grpc
72+
- github.com/charmbracelet/huh
73+
- gopkg.in/yaml.v3
74+
- github.com/denormal/go-gitignore
75+
- github.com/shurcooL/githubv4
76+
- github.com/google/go-github/v74/github
77+
- github.com/fatih/color
78+
- github.com/mattn/go-isatty
79+
# Allow your project imports
80+
- github.com/contextvibes/cli
8981
deny:
9082
- pkg: "math/rand$"
91-
desc: use math/rand/v2
92-
- pkg: "github.com/sirupsen/logrus"
93-
desc: not allowed
83+
desc: "Use math/rand/v2 for safer, faster generation (Go 1.22+)"
9484
- pkg: "github.com/pkg/errors"
95-
desc: Should be replaced by standard lib errors package
85+
desc: "Use stdlib errors.New, fmt.Errorf, and errors.Is/As"
86+
- pkg: "github.com/sirupsen/logrus"
87+
desc: "Use log/slog (stdlib) or uber-go/zap"
88+
89+
ireturn:
90+
allow:
91+
- anon
92+
- error
93+
- empty
94+
- stdlib
95+
# --- Architecture Exemptions (Dependency Injection) ---
96+
- github.com/contextvibes/cli/internal/workitem.Provider
97+
- github.com/contextvibes/cli/internal/exec.CommandExecutor
98+
- github.com/contextvibes/cli/internal/workflow.PresenterInterface
99+
100+
gosec:
101+
excludes:
102+
- G101 # Exclude "Hardcoded Credentials" (false positives with IaC resource names)
103+
104+
errorlint:
105+
errorf: true
106+
asserts: true
107+
108+
testifylint:
109+
enable-all: true
110+
111+
issues:
112+
max-issues-per-linter: 0
113+
max-same-issues: 0
114+
exclude-dirs:
115+
- vendor

.goreleaser.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: 2
2+
3+
project_name: contextvibes
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
9+
builds:
10+
- env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
goarch:
17+
- amd64
18+
- arm64
19+
main: ./cmd/contextvibes
20+
binary: contextvibes
21+
ldflags:
22+
- -s -w
23+
- -X github.com/contextvibes/cli/cmd/version.Version={{.Version}}
24+
- -X github.com/contextvibes/cli/cmd/version.Commit={{.Commit}}
25+
- -X github.com/contextvibes/cli/cmd/version.Date={{.Date}}
26+
- -X github.com/contextvibes/cli/cmd/version.BuiltBy=goreleaser
27+
28+
archives:
29+
- format: tar.gz
30+
# this name template makes the tarballs look like:
31+
# contextvibes_1.0.0_linux_amd64.tar.gz
32+
name_template: >-
33+
{{ .ProjectName }}_
34+
{{- .Version }}_
35+
{{- .Os }}_
36+
{{- .Arch }}
37+
38+
checksum:
39+
name_template: 'checksums.txt'
40+
41+
snapshot:
42+
version_template: "{{ .Tag }}-next"
43+
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- '^docs:'
49+
- '^test:'

.idx/contextvibes.nix

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
1-
# .idx/contextvibes.nix
2-
{ pkgs }:
1+
# -----------------------------------------------------------------------------
2+
# Package: ContextVibes CLI
3+
# Version: Dynamic (Defaults to 0.7.0-alpha.2, overrides via local.nix)
4+
# -----------------------------------------------------------------------------
5+
{ pkgs, overrides ? {} }:
36

4-
pkgs.stdenv.mkDerivation {
7+
let
8+
# --- Defaults (Tracked in Git) ---
9+
defaultVersion = "0.7.0-alpha.2";
10+
defaultHash = "0n1mchl9nphy1q0rxi9468y2hyp6brvf9iisflycvni20w3v4c4i";
11+
12+
# --- Resolution Logic ---
13+
# Use value from local.nix if present, otherwise use default
14+
version = overrides.CONTEXTVIBES_VERSION or defaultVersion;
15+
sha256 = overrides.CONTEXTVIBES_HASH or defaultHash;
16+
17+
# Map Nix system architecture to Go architecture naming
18+
arch = if pkgs.stdenv.hostPlatform.isAarch64 then "arm64" else "amd64";
19+
os = "linux"; # IDX is Linux-based
20+
in
21+
pkgs.stdenv.mkDerivation rec {
522
pname = "contextvibes";
6-
version = "0.5.0";
23+
inherit version;
724

825
src = pkgs.fetchurl {
9-
url = "https://github.com/contextvibes/cli/releases/download/v0.5.0/contextvibes";
10-
sha256 = "sha256:c519ee03b6b77721dfc78bb03b638c3327096affafd8968d49b2bbd9a89ffc10";
26+
# URL format matches GoReleaser: contextvibes_0.7.0-alpha.2_linux_amd64.tar.gz
27+
url = "https://github.com/contextvibes/cli/releases/download/v${version}/contextvibes_${version}_${os}_${arch}.tar.gz";
28+
inherit sha256;
1129
};
1230

13-
dontUnpack = true;
31+
# The archive unpacks into the current directory
32+
sourceRoot = ".";
1433

1534
installPhase = ''
1635
mkdir -p $out/bin
17-
install -m 755 -D $src $out/bin/contextvibes
36+
install -m 755 contextvibes $out/bin/contextvibes
1837
'';
1938
}

0 commit comments

Comments
 (0)