Skip to content

Commit caae56e

Browse files
committed
feat(factory): Implement core infrastructure and MCP server
- **MCP Server**: Added `contextvibes mcp` command to expose CLI tools (quality) via JSON-RPC. - **Factory Commands**: - `bootstrap`: Minimal installer and environment setup. - `scaffold`: Generate `.idx` and `firebase` configurations. - `squash`: Automate feature branch squashing (soft reset + commit + force push). - `upgrade-cli`: Update the CLI version in Nix environments. - **Quality Pipeline**: Refactored `product quality` to support MCP, added `GoBuildCheck`, and embedded linter configs. - **Library**: Added `thea get-artifact` and `vendor` commands. - **Internal**: - Implemented asset embedding for linter configs. - Enhanced `git` client with merge-base and reset capabilities. - Added `workflow` steps for new commands. - **Infra**: Added `.goreleaser.yaml` and updated Nix configuration.
1 parent 86dd8d1 commit caae56e

93 files changed

Lines changed: 6709 additions & 1213 deletions

File tree

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: 95 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,114 @@ 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
37+
- wrapcheck
38+
- depguard
6739

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

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ After providing one or more `cat` scripts to modify Go source files, you MUST im
9191
* **Code & Config (`.go`, `.yml`, `.json`, etc.):** ALWAYS use the `cat` script method for creating or updating files.
9292
* **Documents (`.md`, `.txt`):** When creating OR updating, provide the full content in a standard markdown block for manual copy-pasting.
9393

94+
## 10. Error Recovery Protocol
95+
96+
When a verification script (e.g., `go build ./...`) fails, you must perform the following steps in order:
97+
98+
1. **Acknowledge the Error:** Explicitly acknowledge the error and its impact (e.g., "I have introduced a build error.").
99+
2. **Analyze the Error:** Analyze the error message to identify the root cause of the problem.
100+
3. **Formulate a Plan:** Formulate a plan to fix the error.
101+
4. **Execute the Plan:** Execute the plan to fix the error. This may involve reading the file, modifying it, and running the verification script again.
102+
5. **Confirm the Fix:** Once the verification script passes, confirm that the error has been fixed.
94103

95104
<!-- This file contains system prompt instructions specific to the Firebase Studio (IDX) environment. -->
96105
<!-- It is automatically appended to core.md when generating .idx/airules.md. -->

.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)