Skip to content

Commit a5e94cf

Browse files
committed
build: add beta distribution pipeline
1 parent 12a5580 commit a5e94cf

19 files changed

Lines changed: 551 additions & 1558 deletions

.DS_Store

-8 KB
Binary file not shown.

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
workflow_call:
6+
permissions:
7+
contents: read
8+
jobs:
9+
test:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
go: ['1.25.x', '1.26.x']
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version: ${{ matrix.go }}
21+
- run: go test -timeout 5m ./...
22+
- run: go vet ./...
23+
- run: go test -race -timeout 5m ./...
24+
- run: go build ./cmd/ctxt
25+
analysis:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-go@v5
30+
with:
31+
go-version: '1.26.x'
32+
- run: go install honnef.co/go/tools/cmd/staticcheck@v0.7.0
33+
- run: staticcheck ./...
34+
- run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.10.1
35+
- run: golangci-lint run
36+
- run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
37+
- run: govulncheck ./...

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
on:
3+
push:
4+
tags: ['v*']
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: Existing version tag to package
9+
required: true
10+
permissions:
11+
contents: read
12+
jobs:
13+
gate:
14+
uses: ./.github/workflows/ci.yml
15+
package:
16+
needs: gate
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Resolve release tag
25+
env:
26+
REQUESTED_TAG: ${{ inputs.tag || github.ref_name }}
27+
run: |
28+
if ! [[ "$REQUESTED_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$ ]]; then
29+
exit 1
30+
fi
31+
test "$(git rev-parse "$REQUESTED_TAG^{commit}")" = "$(git rev-parse HEAD)"
32+
echo "RELEASE_TAG=$REQUESTED_TAG" >> "$GITHUB_ENV"
33+
- uses: actions/setup-go@v5
34+
with:
35+
go-version: '1.26.x'
36+
- run: go run ./internal/dist -version "$RELEASE_TAG"
37+
- name: Create draft release
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: gh release create "$RELEASE_TAG" dist/* --verify-tag --draft --prerelease --title "$RELEASE_TAG" --notes-file CHANGELOG.md

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,12 @@ contexting
44
ctx.json
55
syns.json
66
/.ctxt
7+
/.ctxt-writer/
8+
/dist/
9+
/bin/
10+
/ctxt
11+
/ctxt.exe
12+
/context.json
13+
/context.toml
14+
.DS_Store
15+
.picode/

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- govet
6+
- ineffassign
7+
- staticcheck
8+
- unused
9+
run:
10+
timeout: 5m

AGENTS.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ This file is for developers and AI agents working on the codebase. For user-faci
1919

2020
## Versioning
2121

22-
- **Hardcoded fallback**: `main.go` line ~3: `var Version = "0.0.1"`
22+
- **Local fallback**: untagged direct builds report `dev`
23+
- **Tagged Go installs**: derive the module version from Go build metadata
2324
- **`make install`**: Overrides via `-ldflags "-X github.com/ktappdev/contexting.Version=..."` using `git describe --tags`
2425
- **Without tags**: Falls back to commit hash (e.g., `af85edb-dirty`)
2526

2627
### Bumping Version
2728

2829
```bash
2930
git tag v0.0.2 && make install
30-
ctxt version # → 0.0.2
31+
ctxt version # → 0.0.2 (ctxt --version also works)
3132
```
3233

3334
## Project Structure
@@ -97,8 +98,9 @@ ctxt version # → 0.0.2
9798
| Config format | TOML (`.ctxt/ctx_config.toml`) |
9899
| Output format | JSON (`.ctxt/ctx_index.json`) |
99100
| Atomic writes | Temp file + rename (see `io_atomic.go`) |
100-
| No file locking | Between processes (init vs watch can conflict) |
101+
| Writer guard | CLI writers are serialized per project via `.ctxt-writer/` |
101102
| Default model | `deepseek/deepseek-v4-flash` |
103+
| Supported release targets | Linux/macOS/Windows on amd64 and arm64 |
102104
| Synonyms | 5–12 per name |
103105
| Temperature | `0.9` |
104106
| Parallel requests | `10` |
@@ -110,7 +112,8 @@ ctxt version # → 0.0.2
110112
### Flag Defaults
111113

112114
- `--verbose` (default: false) — gates steady-state change summaries
113-
- `--search-log` (default: true) — gates search query logging
115+
- `--llm-on-watch` (default: false) — opts into LLM calls during watch
116+
- `--search-log` (default: false) — gates potentially sensitive query logging
114117
- `--by-category` (default: true) — group bench results by category
115118
- `--engines` (default: `"ctxt,find,grep"`) — engines to benchmark. Also available: `fd`, `rg`, `hybrid`, `combined`
116119
- `--hybrid` (search flag, default: false) — enable content fallback via ripgrep when index results are sparse
@@ -132,7 +135,7 @@ Default ignores: `.venv`, `site-packages`, `__pycache__`, `node_modules`, `.env*
132135
## Key Conventions for AI Agents
133136

134137
1. **Naming — The CLI binary and command is `ctxt` (lowercase), not `contexting`. The project name is Contexting (capitalized). All user-facing command strings, error messages, help text, MCP server names, bench engine names, and doc examples MUST use `ctxt`. Only use `Contexting` when referring to the project in prose.**
135-
2. **Never assume file locking**`init` and `watch` can conflict
138+
2. **Writer guard scope**CLI writers are serialized locally; library callers and network filesystems require their own coordination
136139
3. **Atomic writes only** — use temp+rename pattern in `io_atomic.go`
137140
4. **Config precedence** — CLI flags > `.ctxt/ctx_config.toml` > hardcoded defaults
138141
5. **Config paths** — Relative paths resolve from config file location
@@ -143,6 +146,8 @@ Default ignores: `.venv`, `site-packages`, `__pycache__`, `node_modules`, `.env*
143146
10. **Scoring** — Exact basename +15 (highest), confidence gap truncation reduces noise
144147
11. **Hybrid search** — Use `--hybrid` on `search-hints` to fill gaps in index results. Ripgrep scans file contents for query tokens and merges unmatched files at score=1. Useful when the index misses files whose content literally contains the query words but whose symbols/synonyms don't connect. Add `--memory=false` if using a snapshot (non-watch) index.
145148
12. **`--agent` flag** — Blocks `init`/`watch`/`sync`/`clean` for safety in automated flows
149+
13. **Symlinks** — Entries are excluded; directory symlinks are never followed
150+
14. **Index size** — Initial indexing fails above 10,000 files rather than saving a partial index
146151

147152
## Bench Engines
148153

@@ -156,4 +161,4 @@ Default ignores: `.venv`, `site-packages`, `__pycache__`, `node_modules`, `.env*
156161
| **hybrid** | ctxt + content fallback via ripgrep. Content matches at score=1. | When index might have blind spots. Slower (7ms avg). |
157162
| **combined** | Union of find + grep. Alphabetical. | Maximum recall at cost of noise. |
158163

159-
Run: `ctxt bench --cases docs/bench_cases.json --engines ctxt,hybrid,find,grep,rg`
164+
Run: `ctxt bench --cases docs/bench_cases.json --engines ctxt,hybrid,find,grep,rg`

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Changelog
2+
3+
## 0.1.0-beta.1 — Unreleased
4+
5+
- Consistent parent/file synonym keys during indexing and live updates.
6+
- Watch detects children of newly populated directories.
7+
- Explicit shutdown-only persistence contract; unsupported modes fail.
8+
- HTTPS public LLM defaults, opt-in query logs and an explicit offline mode.
9+
- Remote LLM endpoints require HTTPS; loopback development endpoints may use HTTP.
10+
- Config-aware API-key diagnostics without printing key fragments.
11+
- Bounded, cancellable transient HTTP retries and reported partial failures.
12+
- Project single-writer guard and versioned index schema.
13+
- File-limit failures instead of silently truncated initial indexes.
14+
- Symlink exclusion, bounded local HTTP requests and atomic file syncing.
15+
- CLI/watch/MCP regression tests and cross-platform CI.
16+
- Versioned platform archives, SHA-256 checksums and draft release workflow.
17+
18+
### Upgrading
19+
20+
Back up `.ctxt/` before upgrading. Unversioned indexes (schema 0) remain readable;
21+
the next save writes schema 1. Unknown newer schemas fail with an upgrade/rebuild
22+
message. Run `ctxt init . --offline` to rebuild; the synonym cache is reused.
23+
Search ranking and JSON output may evolve during the beta series.
24+
25+
Existing config files are not rewritten. Replace private HTTP defaults if you
26+
want OpenRouter, set `watch.search_log = false`, and use `persist = "shutdown"`.
27+
Remove obsolete interval settings. Repeated parent/file suffixes can still
28+
share synonym cache entries; this key format is retained for compatibility.

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Contributing
2+
3+
Use Go 1.25 or newer. Keep changes small and include regression coverage for
4+
behavior changes. Run:
5+
6+
```sh
7+
go test ./...
8+
go test -race ./...
9+
go vet ./...
10+
staticcheck ./...
11+
golangci-lint run
12+
govulncheck ./...
13+
```
14+
15+
The CI workflow installs pinned analysis tools. Tests use local fake LLM
16+
servers and do not require API credentials. Full tests build a CLI and exercise
17+
MCP and watch subprocesses; `go test -short ./...` skips that lifecycle test.
18+
19+
Do not commit generated indexes, binaries, API keys or private fixtures.
20+
See SECURITY.md for data handling and AGENTS.md for architecture.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Ken Taylor
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo "0.0.1")
22

3-
.PHONY: build install test
3+
.PHONY: build install test check dist
44

55
build:
66
go build -ldflags "-X github.com/ktappdev/contexting.Version=$(VERSION)" -o bin/ctxt ./cmd/ctxt
@@ -10,3 +10,14 @@ install:
1010

1111
test:
1212
go test ./...
13+
14+
check:
15+
go test ./...
16+
go test -race ./...
17+
go vet ./...
18+
staticcheck ./...
19+
golangci-lint run
20+
govulncheck ./...
21+
22+
dist:
23+
go run ./internal/dist -version v$(VERSION)

0 commit comments

Comments
 (0)