Skip to content

Commit dad7cc3

Browse files
committed
chore: initialize public source
0 parents  commit dad7cc3

94 files changed

Lines changed: 14915 additions & 0 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/ci.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
go:
14+
name: Go
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v6
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v6
23+
with:
24+
go-version-file: go.mod
25+
cache: true
26+
27+
- name: Check formatting
28+
run: |
29+
files="$(gofmt -l $(git ls-files '*.go'))"
30+
if [ -n "$files" ]; then
31+
echo "$files"
32+
exit 1
33+
fi
34+
35+
- name: Check shell syntax
36+
run: git ls-files '*.sh' | xargs -r bash -n
37+
38+
- name: Vet
39+
run: go vet ./...
40+
41+
- name: Test
42+
run: go test ./...
43+
44+
- name: Race test
45+
run: go test -race ./...
46+
47+
- name: Build commands
48+
run: |
49+
go build ./cmd/threadmark
50+
go build ./cmd/threadmarkd

‎.github/workflows/release.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v6
24+
with:
25+
go-version-file: go.mod
26+
cache: true
27+
28+
- name: Vet
29+
run: go vet ./...
30+
31+
- name: Test
32+
run: go test ./...
33+
34+
- name: Run GoReleaser
35+
uses: goreleaser/goreleaser-action@v7
36+
with:
37+
version: "~> v2"
38+
args: release --clean
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}

‎.gitignore‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Go binaries / build output
2+
*.exe
3+
*.dll
4+
*.so
5+
*.dylib
6+
*.test
7+
*.out
8+
*.prof
9+
/bin/
10+
/dist/
11+
12+
# Vendored deps (uncomment if vendoring is adopted)
13+
# vendor/
14+
15+
# Test coverage
16+
coverage.out
17+
coverage.html
18+
19+
# Editor / OS
20+
.DS_Store
21+
*.swp
22+
*~
23+
.idea/
24+
.vscode/
25+
.claude/
26+
.codex/
27+
/planning/
28+
/STATUS.md
29+
/AGENT_BRIDGE.md
30+
31+
# Per-user local config overrides (built-in defaults live in config/triggers.example.yml;
32+
# users override in ~/.threadmark/triggers.yml or <project>/.threadmark/triggers.local.yml).
33+
config/triggers.local.yml
34+
.threadmark/

‎.goreleaser.yaml‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
version: 2
2+
3+
project_name: threadmark
4+
5+
builds:
6+
- id: threadmark
7+
main: ./cmd/threadmark
8+
binary: threadmark
9+
ldflags:
10+
- -s -w -X github.com/thinkwright/threadmark/internal/buildinfo.Version={{.Version}}
11+
env:
12+
- CGO_ENABLED=0
13+
goos:
14+
- linux
15+
- darwin
16+
- windows
17+
goarch:
18+
- amd64
19+
- arm64
20+
21+
- id: threadmarkd
22+
main: ./cmd/threadmarkd
23+
binary: threadmarkd
24+
ldflags:
25+
- -s -w -X github.com/thinkwright/threadmark/internal/buildinfo.Version={{.Version}}
26+
env:
27+
- CGO_ENABLED=0
28+
goos:
29+
- linux
30+
- darwin
31+
- windows
32+
goarch:
33+
- amd64
34+
- arm64
35+
36+
archives:
37+
- id: default
38+
ids:
39+
- threadmark
40+
- threadmarkd
41+
formats:
42+
- tar.gz
43+
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
44+
format_overrides:
45+
- goos: windows
46+
formats:
47+
- zip
48+
49+
checksum:
50+
name_template: "checksums.txt"
51+
52+
changelog:
53+
sort: asc
54+
filters:
55+
exclude:
56+
- "^docs:"
57+
- "^test:"
58+
59+
release:
60+
prerelease: auto
61+
62+
homebrew_casks:
63+
- name: threadmark
64+
ids:
65+
- default
66+
repository:
67+
owner: thinkwright
68+
name: homebrew-tap
69+
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
70+
homepage: "https://github.com/thinkwright/threadmark"
71+
description: "Local handoff and continuity for Claude Code, Codex, and AI coding agents"
72+
license: "MIT"
73+
binaries:
74+
- threadmark
75+
- threadmarkd
76+
hooks:
77+
post:
78+
install: |
79+
if OS.mac?
80+
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/threadmark"]
81+
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/threadmarkd"]
82+
end

‎AGENTS.md‎

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# Agent Guide
2+
3+
Repository guidance for AI coding assistants and maintainers working on
4+
Threadmark.
5+
6+
**Last updated:** 2026-05-19
7+
8+
## 1. Project Contract
9+
10+
Threadmark is a shared continuity layer for software developers who hand work
11+
off between Claude Code and Codex in the same repository. It runs beside those
12+
harnesses, observes hook events, writes short perspectival journal entries at
13+
useful boundaries, and gives future sessions a compact startup packet for the
14+
same project.
15+
16+
Threadmark is intentionally narrow. It is not a transcript archive, semantic
17+
search layer, sync service, or general-purpose memory system. Its job is to
18+
preserve enough situated context for independent agents to stay on the same
19+
line of work without inheriting one another's entire sessions.
20+
21+
## 2. Reading Order
22+
23+
Use the public repository files as the source of truth:
24+
25+
1. `README.md` - project summary and user-facing flow.
26+
2. `HOW_IT_WORKS.md` - implementation mechanics and architecture.
27+
3. `QUICKSTART.md` - first-use path and common workflows.
28+
4. `INSTALL.md` - install, upgrade, uninstall, and health checks.
29+
5. Source under `cmd/`, `internal/`, `adapters/`, `prompts/`, and `config/`.
30+
6. Tests near the packages they validate.
31+
32+
If behavior and docs disagree, inspect the implementation and tests, then update
33+
the docs as part of the same change when appropriate.
34+
35+
## 3. Architecture Map
36+
37+
- `cmd/threadmark` - user CLI, hook bridge, install, activation, status, doctor,
38+
daemon lifecycle, privacy controls, and startup packet surfacing.
39+
- `cmd/threadmarkd` - per-user daemon process.
40+
- `internal/adapters/claudecode` - Claude Code hook translation.
41+
- `internal/adapters/codex` - Codex hook translation.
42+
- `internal/core` - neutral event schema, thread boundaries, trigger
43+
classification, priority debounce, and checkpoint decisions.
44+
- `internal/daemon` - per-project state, event handling, checkpoint excerpts,
45+
retry behavior, and daemon-side orchestration.
46+
- `internal/ipc` - Unix-socket newline-delimited JSON transport.
47+
- `internal/journal` - project storage, journal frontmatter, append/read logic,
48+
and project ID resolution.
49+
- `internal/reflector` - prompt loading, redaction, Claude CLI subprocess calls,
50+
and reflector recursion guard.
51+
- `adapters/claudecode/hooks` and `adapters/codex/hooks` - shell shims used by
52+
harness hook configuration.
53+
- `prompts/reflector.md` - default reflector prompt.
54+
- `config/triggers.example.yml` - example trigger configuration.
55+
56+
Runtime shape:
57+
58+
```text
59+
coding session -> threadmark hook -> Unix socket -> threadmarkd
60+
threadmarkd -> core engine -> reflector -> journal store
61+
future SessionStart -> startup packet
62+
```
63+
64+
## 4. Product Vocabulary
65+
66+
Use these terms consistently:
67+
68+
- **sidecar** - Threadmark running beside an agent harness.
69+
- **startup packet** - the complete context artifact surfaced on `SessionStart`.
70+
- **Workspace Snapshot** - generated current git/workspace facts inside the
71+
startup packet.
72+
- **Project Card** - optional durable project-authored context inside the
73+
startup packet.
74+
- **Entry N** - selected reflector-written journal entries inside the startup
75+
packet.
76+
77+
Do not introduce `startup card` or `orientation packet` as product primitives.
78+
Orientation is the goal; `startup packet` is the artifact.
79+
80+
## 5. Scope Boundaries
81+
82+
Implemented scope:
83+
84+
- Go module: `github.com/thinkwright/threadmark`.
85+
- Commands: `threadmark` and `threadmarkd`.
86+
- Supported adapters: Claude Code and Codex.
87+
- Hook events include session start, user prompt, tool use, stop, pre-compact,
88+
and post-compact surfaces where supported by the harness.
89+
- Reflector backend: Claude CLI subprocess (`claude -p` by default; bare mode is
90+
available when explicitly configured).
91+
- Startup packets include workspace facts, optional Project Card content, and
92+
selected recent journal entries.
93+
94+
Out of scope for v0:
95+
96+
- OpenCode and Pi adapters.
97+
- Journal sync across machines.
98+
- Semantic retrieval over the journal.
99+
- Raw transcript or raw tool-output persistence.
100+
- Direct Anthropic SDK integration.
101+
- Durable spooling of checkpoint excerpts.
102+
103+
## 6. Engineering Rules
104+
105+
- Preserve the core/adapter split. Adapter packages translate harness payloads
106+
into neutral events; shared behavior belongs in `internal/core`,
107+
`internal/daemon`, `internal/journal`, `internal/ipc`, or
108+
`internal/reflector`.
109+
- Keep hook shims small and fast. Stateful work belongs in `threadmarkd`.
110+
- Do not turn the CLI into the hot path. Normal continuity should flow through
111+
hooks, daemon auto-start, checkpoint triggers, journal writes, and
112+
`SessionStart` startup packets.
113+
- Do not persist raw transcripts, raw tool outputs, or raw hook payloads.
114+
- Redact before reflector calls. Treat redaction as best effort, not a security
115+
guarantee.
116+
- Do not adopt credential scraping, credential pooling, or programmatic loops
117+
through interactive-priced subscription auth.
118+
- Do not add the Anthropic SDK or npm/Node dependencies for v0.
119+
- Keep product examples based on a `threadmark` command available on `PATH`, not
120+
on a maintainer-specific checkout path.
121+
- Do not modify global git config.
122+
- Do not add remotes, change repository visibility, rewrite history, or
123+
force-push unless a maintainer explicitly asks for that operation.
124+
125+
## 7. Editing Workflow
126+
127+
Before editing:
128+
129+
```sh
130+
git status --short --branch
131+
git log --oneline -10
132+
```
133+
134+
Prefer focused changes that match existing package boundaries. Use `rg` for
135+
search. Respect `.gitignore`; generated artifacts, build output, and
136+
machine-local configuration are not source.
137+
138+
When behavior changes, update the relevant public docs in the same unit of work
139+
when user-facing behavior or contributor expectations change. When shared
140+
behavior changes, add or update tests near the package that owns the contract.
141+
142+
When changing public docs, check for:
143+
144+
- first-user clarity
145+
- sidecar/startup-packet vocabulary consistency
146+
- privacy and model-call boundaries
147+
- install and activation steps that match the current implementation
148+
149+
## 8. Validation
150+
151+
Common checks:
152+
153+
```sh
154+
go test ./...
155+
go vet ./...
156+
git diff --check
157+
```
158+
159+
Use broader checks when risk warrants it:
160+
161+
```sh
162+
go test -race ./...
163+
```
164+
165+
For installed workflows:
166+
167+
```sh
168+
threadmark doctor
169+
threadmark status --last 10
170+
```
171+
172+
Do not rely on `codex exec` to validate Codex hooks; configured project hooks
173+
are validated through the interactive Codex workflow.
174+
175+
## 9. Privacy And Continuity Posture
176+
177+
Threadmark's journal entries are perspectival orientation, not ground truth.
178+
The Workspace Snapshot and Project Card are factual/durable context; journal
179+
entries should be verified against code, tests, git history, and public docs.
180+
181+
Journal mode sends a redacted checkpoint excerpt to the configured reflector
182+
model. Use no-journal mode for sensitive sessions.
183+
184+
Threadmark should remain ambient after setup. Diagnostic, lifecycle, disable,
185+
enable, purge, and status commands are control-plane tools; they should not
186+
become the ordinary user workflow.

0 commit comments

Comments
 (0)