Skip to content

Commit e0ba11e

Browse files
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents c08ac12 + ec6c38e commit e0ba11e

20 files changed

Lines changed: 811 additions & 104 deletions

File tree

‎AGENTS.md‎

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Development Rules
22

3-
Agent-facing rules for working on Coven Code. Mirrors and extends `src-rust/.claude/CLAUDE.md`; when the two disagree, the rule closer to the code wins.
3+
Agent-facing rules for working on Coven Code. `CLAUDE.md` points here; there is no other rules file.
44

55
## Conversational Style
66

@@ -30,7 +30,7 @@ Agent-facing rules for working on Coven Code. Mirrors and extends `src-rust/.cla
3030

3131
## Commands
3232

33-
Run from `src-rust/` unless noted.
33+
Run from `src-rust/` unless noted, using the toolchain CI pins (`rustup run 1.100.0 cargo ...`; see Parallel Worktrees).
3434

3535
- After Rust changes (not docs): `cargo check --workspace` — fix every error and warning before committing.
3636
- Clippy: `cargo clippy --workspace --all-targets -- -D warnings`. Fix lints; do not `#[allow(...)]` without justification.
@@ -49,20 +49,22 @@ The ratatui frontend is sensitive to terminal size and key encoding. For repeata
4949
# Build a debug binary once
5050
cargo build
5151

52-
# 80×24 session
53-
tmux new-session -d -s coven-code-test -x 80 -y 24
54-
tmux send-keys -t coven-code-test "./target/debug/coven-code" Enter
52+
# 80×24 session on a tmux server of your own (see Parallel Worktrees). Pick one
53+
# socket name, such as coven-code-<worktree>, and repeat it in every command: a
54+
# shell variable does not survive between separate agent shell calls.
55+
tmux -L coven-code-mywt new-session -d -s test -x 80 -y 24
56+
tmux -L coven-code-mywt send-keys -t test "./target/debug/coven-code" Enter
5557

5658
# Give it time to redraw, then capture
57-
sleep 2 && tmux capture-pane -t coven-code-test -p
59+
sleep 2 && tmux -L coven-code-mywt capture-pane -t test -p
5860

5961
# Drive input
60-
tmux send-keys -t coven-code-test "your prompt here" Enter
61-
tmux send-keys -t coven-code-test Escape
62-
tmux send-keys -t coven-code-test C-o # ctrl+o
62+
tmux -L coven-code-mywt send-keys -t test "your prompt here" Enter
63+
tmux -L coven-code-mywt send-keys -t test Escape
64+
tmux -L coven-code-mywt send-keys -t test C-o # ctrl+o
6365

64-
# Cleanup
65-
tmux kill-session -t coven-code-test
66+
# Cleanup: only your own server
67+
tmux -L coven-code-mywt kill-server
6668
```
6769

6870
On Windows hosts, prefer `cargo run -- --print "..."` against the headless path. The Windows console has known quirks with the kitty keyboard protocol — see `crates/tui` for the push/pop workaround.
@@ -127,11 +129,11 @@ Coven Code uses a **single workspace version** stamped across every surface (Car
127129

128130
## **CRITICAL** Git Rules for Parallel Agents
129131

130-
This repo runs parallel agents in worktrees under `.claude/worktrees/`. Multiple agents may be modifying different files in the same checkout simultaneously. You MUST follow these rules:
132+
This repo runs parallel agents in worktrees under `.claude/worktrees/` (see Parallel Worktrees). Several agents work in the same clone at once, and a checkout may still be shared, so you MUST follow these rules:
131133

132134
### Committing
133135

134-
- **ONLY commit files YOU changed in THIS session.** Never commit unless the user has explicitly asked you to commit (see `src-rust/.claude/CLAUDE.md` — the rule is "NEVER EVER commit").
136+
- **ONLY commit files YOU changed in THIS session.** Commit only when the user has asked you to.
135137
- ALWAYS include `fixes #<number>` or `closes #<number>` in the commit message when there is a related issue or PR.
136138
- NEVER use `git add -A` or `git add .` — these sweep up changes from other agents.
137139
- ALWAYS use `git add <specific-file-paths>` listing only files you modified.
@@ -149,7 +151,8 @@ These can destroy other agents' work:
149151
- `git stash` — stashes ALL changes including other agents' work
150152
- `git add -A` / `git add .` — stages other agents' uncommitted work
151153
- `git commit --no-verify` — bypasses required checks; never allowed
152-
- Force-push to `main` — never allowed; the patch-release workflow is the only thing that may force-move tags, and it does so via the workflow runner, not from your shell
154+
- `git rebase` onto `main` — merge `origin/main` instead; rebasing a pushed branch rewrites history other agents and reviewers have fetched
155+
- Force-push (`--force`, `--force-with-lease`) to any branch — never allowed; the patch-release workflow is the only thing that may force-move tags, and it does so via the workflow runner, not from your shell
153156

154157
### Safe Workflow
155158

@@ -164,15 +167,16 @@ git add docs/providers.md
164167
# 3. Commit (only when the user has asked)
165168
git commit -m "feat(api): add foo provider"
166169

167-
# 4. Push (pull --rebase if needed, but NEVER reset/checkout)
168-
git pull --rebase && git push
170+
# 4. Bring in main by merging (never rebase), then push
171+
git fetch origin && git merge --no-edit origin/main
172+
git push -u origin HEAD
169173
```
170174

171-
### If Rebase Conflicts Occur
175+
### If Merge Conflicts Occur
172176

173177
- Resolve conflicts in YOUR files only.
174-
- If a conflict touches a file you didn't modify, abort the rebase and ask the user.
175-
- NEVER force-push.
178+
- If a conflict touches a file you didn't modify, run `git merge --abort` and ask the user.
179+
- Never rebase onto `main`; merge `origin/main` instead. Never force-push.
176180

177181
### Contributor Attribution
178182

@@ -187,6 +191,39 @@ Co-authored-by: Name <ID+username@users.noreply.github.com>
187191
- When a squash-merge collapses a contributor's PR into an internal branch, preserve their `Co-authored-by:` line in the squash commit message.
188192
- This applies to human contributors only. Do not add trailers or credit lines naming an AI model, assistant, vendor, or coding harness.
189193

194+
## Parallel Worktrees
195+
196+
Several agents share one host and one clone. Give each change its own worktree, build directory and processes.
197+
198+
- One worktree per change, under `.claude/worktrees/`, from `origin/main`. From the clone's top-level directory: `git fetch origin && git worktree add --no-track -b <branch> .claude/worktrees/<name> origin/main`. Never edit the main checkout; another session may have it on its own branch with staged files.
199+
- One `CARGO_TARGET_DIR` per worktree; never share one. Cargo's fingerprints for workspace path crates do not include the worktree path, so a shared target directory reuses units another branch built, judged by mtime, and you test code that is not in your tree. Each worktree's default `src-rust/target` is separate; a `CARGO_TARGET_DIR` exported globally is how one gets shared by accident.
200+
- On a shared host set `CARGO_BUILD_JOBS` (for example `4`) and check `uptime` before a build. When the load is high, run the gates on hosted CI instead (below).
201+
- Toolchain: CI pins `dtolnay/rust-toolchain@1.100.0` in `rust-ci.yml`, `tui-tests.yml` and `release-build.yml` under `.github/workflows/` (there is no `rust-toolchain` file). Run `rustup run 1.100.0 cargo <command>` from `src-rust/` (install it once with `rustup toolchain install 1.100.0 -c clippy -c rustfmt`), and follow the pin when it changes. With a scratch `HOME`, also set `RUSTUP_HOME` and `CARGO_HOME` to your real ones, or rustup cannot find the toolchain.
202+
- The binary walks up from its working directory and uses the first `.coven-code/settings.json` (or `.jsonc`) it finds (`Settings::find_project_settings`). It skips only its own config home's `settings.json`, and `COVEN_CODE_HOME`, `COVEN_HOME` or `COVEN_PARENT` override that home. A scratch `HOME` with a working directory inside your real home therefore still picks up your real `~/.coven-code/settings.json`. For manual runs, use a scratch `HOME`, unset those three variables, and work from a directory outside your real home with no `.coven-code` above it.
203+
- `scripts/tui-tests/run.sh` does this itself: it makes a scratch directory under `TMPDIR`, unsets those variables, gives cases 01-07 a scratch `HOME` and working directory (the other cases make theirs under a `TMPDIR` inside it, except on macOS, where a bare `mktemp -d` ignores `TMPDIR`), and refuses to start (exit `2`) when that directory is inside your home or a directory above it holds a `.coven-code`. If it refuses, set `TMPDIR` to a directory outside your home. See `scripts/tui-tests/README.md`.
204+
- Kill only process IDs you started and recorded (`$!`, a pid file, a tmux server on a socket you named with `-L`). Never `pkill -f` or `killall` by pattern, and never run `tmux kill-server` or `kill-session` without `-L <your socket>`; that kills other agents' tmux servers and builds.
205+
- Never edit a shell script while it runs. Bash reads a script as it goes, so the running copy executes your edit. Run long scripts from a copy you leave alone.
206+
207+
### Reading Hosted Checks
208+
209+
- Count only the latest run for each check name on the head SHA. Cancelled duplicates can appear on the same SHA; a later run of the same name supersedes them.
210+
- `mergeable` reads `null` (and `mergeable_state` `unknown`) for up to about two minutes after the PR or `main` moves. Poll again instead of treating it as a conflict.
211+
- Which workflows run is set by the `pull_request` `paths` filters in `.github/workflows/*.yml`:
212+
213+
| A PR that touches | Runs |
214+
| --- | --- |
215+
| `src-rust/**` | Rust CI (8 check runs) and TUI Tests (2); also Version stamp tests for the workspace `Cargo.toml`/`Cargo.lock`, Viewer tests for `crates/core/src/share_export/**`, Version stamp tests and Release candidate for `crates/acp/registry-template/agent.json` |
216+
| `scripts/tui-tests/**` | TUI Tests |
217+
| `install.sh`, `install.ps1`, `scripts/*checksums*`, `scripts/package-release.py`, `patch-release.yml`, `release.yml`, `release-build.yml` | Rust CI, plus the installer or release test workflows that name those files |
218+
| `.github/workflows/<name>.yml` | that workflow if it has a `pull_request` trigger, plus any other whose `paths` names the file |
219+
| files under `npm/`, `session/**`, `marketplace/**` | the npm, Viewer or Marketplace tests whose `paths` name them (`npm/package.json` also runs Version stamp tests) |
220+
| `README.md`, `docs/index.md`, `docs/installation.md` | Version stamp tests |
221+
| any other `scripts/` file | the workflows whose `paths` name it (several `scripts/*.py` trigger Rust CI); check with `grep -l <file> .github/workflows/*.yml`, and the glob entries such as `scripts/*checksums*` |
222+
| other docs, `AGENTS.md`, `CLAUDE.md` | none |
223+
224+
- Every PR also gets CodeQL code scanning (four `Analyze (...)` jobs and `CodeQL`) and a Vercel status. A `src-rust/` PR therefore shows at least 15 check runs, plus the Vercel status. Recount from the workflow files when they change.
225+
- Rust CI and TUI Tests also run on `workflow_dispatch`, so `gh workflow run rust-ci.yml --ref <branch>` (or `tui-tests.yml`) runs them on a pushed branch without a PR. Use that for hosted fail-first evidence, or when the local host is too loaded to build.
226+
190227
## User Override
191228

192229
If the user's instructions conflict with the rules above, ask for confirmation that they want to override the rules. Only then execute their instructions.

‎CLAUDE.md‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22

33
Read [`AGENTS.md`](AGENTS.md). It is the canonical agent-facing ruleset for this
44
repo: code quality bar, commands, CI gates, issue/PR-comment conventions, git
5-
workflow, and contributor attribution.
6-
7-
The Rust-scoped rules in `src-rust/.claude/CLAUDE.md` extend these; when the two
8-
disagree, the rule closer to the code wins. There is no separate Claude-only
9-
workflow at the repo root — follow `AGENTS.md`.
5+
workflow, parallel worktrees, and contributor attribution. There is no separate
6+
Claude-only workflow; follow `AGENTS.md`.

‎docs/commands.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,12 @@ Enable or disable sandboxed execution of shell commands. When sandbox mode is on
11071107
## Coven Substrate
11081108

11091109
These commands integrate Coven Code with the local Coven daemon
1110-
(`~/.coven/coven.sock`, contract `coven.daemon.v1`). They degrade
1110+
(the socket `$COVEN_HOME/coven.sock`, or `~/.coven/coven.sock` when
1111+
`COVEN_HOME` is unset or empty; contract `coven.daemon.v1`). They degrade
11111112
gracefully when the daemon is absent — the daemon makes coven-code
1112-
richer; it is not required.
1113+
richer; it is not required. Coven Code has a daemon client only on Unix
1114+
platforms (macOS, Linux); on Windows it never connects, so the commands that
1115+
need the daemon report it as absent.
11131116

11141117
### /coven
11151118

@@ -1191,8 +1194,11 @@ the slash invocation acts as the confirmation).
11911194

11921195
#### Offline behaviour
11931196

1194-
When `~/.coven/coven.sock` is missing, every `/coven` subcommand
1195-
returns the same hint:
1197+
When the daemon socket is missing, `/coven` and `/coven status` name
1198+
the path they checked:
1199+
`Coven daemon socket not found at <path>.`
1200+
followed by `Start it with /coven daemon start (or coven daemon start).`
1201+
The other subcommands that need the daemon return:
11961202
`Coven daemon offline. Try /coven daemon start.`
11971203
The rest of coven-code keeps working — you just lose substrate
11981204
integration.
@@ -1210,7 +1216,7 @@ for the canonical error code list.
12101216
### /handoff
12111217

12121218
Hand off the current session context to a Coven familiar. Sends the
1213-
recent transcript to `~/.coven/coven.sock` as a new session under
1219+
recent transcript to the Coven daemon (see [Coven Substrate](#coven-substrate)) as a new session under
12141220
the named familiar, returning the session id.
12151221

12161222
```

‎docs/familiars.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ access = "read-only"
169169

170170
`~/.coven/familiars.toml` is **owned by the Coven daemon** when it is running. In that mode coven-code treats the roster as read-only and directs all edits to the daemon.
171171

172-
**Standalone mode** (no daemon socket at `~/.coven/coven.sock`) is different: coven-code owns the file and can write it directly.
172+
**Standalone mode** (no daemon socket at `$COVEN_HOME/coven.sock`, default `~/.coven/coven.sock`) is different: coven-code owns the file and can write it directly.
173173

174174
- **First-run bootstrap.** Press **F2** with no familiars configured and coven-code writes a starter `~/.coven/familiars.toml` (a `read-only` guide and a `full`-access builder) and opens the switcher so you have something to pick and a template to edit.
175175
- **Create / rename / remove** from the prompt:

‎docs/installation.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,52 @@ The local-binary path does not authenticate the file for you. Verify its origin
8686
and digest before installing it. The shell installer may still resolve the
8787
latest release if no `--version` is supplied, even with `--binary`.
8888

89+
### Windows PowerShell 5.1: 'Get-FileHash' is not recognized
90+
91+
`install.ps1` runs under PowerShell 7 (`pwsh`) and under Windows PowerShell 5.1
92+
(`powershell`). Typing `powershell` at a PowerShell 7 prompt is fine: PowerShell
93+
7 removes its own module paths from `PSModulePath` for a Windows PowerShell it
94+
starts directly. A Windows PowerShell started through another program that
95+
PowerShell 7 launched, such as `cmd.exe`, Python, a build tool or an editor
96+
task, inherits PowerShell 7's `PSModulePath` unchanged. It then finds PowerShell
97+
7's copies of built-in modules first, cannot load them, and cannot auto-load some
98+
commands, including `Get-FileHash`. See
99+
[about_PSModulePath](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psmodulepath).
100+
101+
The installer then fails at the checksum step with output such as:
102+
103+
```
104+
Download failed: The term 'Get-FileHash' is not recognized as the name of a cmdlet, ...
105+
Check that release v<version> exists for windows-x86_64:
106+
https://github.com/OpenCoven/coven-code/releases/tag/v<version>
107+
```
108+
109+
The release exists; the shell is the problem. The installer stops before it
110+
extracts the archive: no executable is installed, an existing install is left
111+
as it was, and the user PATH is not changed (the install directory may be left
112+
behind, empty). Run it in one of these ways instead:
113+
114+
- Run it under PowerShell 7: `pwsh -NoProfile -File .\install.ps1`.
115+
- Start Windows PowerShell 5.1 from the Start menu, or from a Command Prompt
116+
that was not started from PowerShell 7, directly or through another program,
117+
and run it there.
118+
- Clear the variable for the Windows PowerShell you start, so it builds its own
119+
module path. This works from a Command Prompt or PowerShell, run in the folder
120+
that holds `install.ps1` (not a `\\server\share` path):
121+
122+
```
123+
cmd /c "set PSModulePath=&& powershell -NoProfile -File .\install.ps1"
124+
```
125+
126+
Pass the installer's parameters after `.\install.ps1`. If running scripts is
127+
disabled, and you have inspected the script, put `-ExecutionPolicy Bypass`
128+
before `-File` (for example `pwsh -NoProfile -ExecutionPolicy Bypass -File
129+
.\install.ps1`); at an interactive prompt, run
130+
`Set-ExecutionPolicy -Scope Process Bypass` first. Installs with `-Binary` do
131+
not use `Get-FileHash` and are not affected, but check that binary's digest in
132+
a shell that can load `Get-FileHash`, such as PowerShell 7, or with
133+
`certutil -hashfile <file> SHA256`.
134+
89135
### Archive verification
90136

91137
For releases with `SHA256SUMS`, obtain the archive and manifest from the same

‎install.sh‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ install_binary_and_alias() (
233233
committed=1
234234
)
235235

236-
mkdir -p "$INSTALL_DIR"
236+
if ! mkdir -p "$INSTALL_DIR"; then
237+
print_message error "Could not create the install directory ${INSTALL_DIR}" >&2
238+
exit 1
239+
fi
237240

238241
if [[ -n "$local_binary" ]]; then
239242
print_message info "Using local binary: $local_binary"
@@ -295,7 +298,12 @@ if [[ "${SHELL:-}" == */fish ]]; then
295298
path_check="$path_line"
296299
fi
297300
if [[ -n "$shell_rc" ]] && ! grep -qF "$path_check" "$shell_rc" 2>/dev/null; then
298-
mkdir -p "$(dirname "$shell_rc")"
301+
# Name the directory ourselves: some mkdir builds (uutils on Ubuntu 26.04)
302+
# report only "Not a directory" without the path.
303+
if ! mkdir -p "$(dirname "$shell_rc")"; then
304+
print_message error "Could not create $(dirname "$shell_rc") for ${shell_rc}" >&2
305+
exit 1
306+
fi
299307
echo "" >> "$shell_rc"
300308
echo "# Coven Code" >> "$shell_rc"
301309
echo "$path_line" >> "$shell_rc"

0 commit comments

Comments
 (0)