Skip to content

Commit ba4b9b4

Browse files
authored
docs(worktree): fix stale rename example + document copyFiles properly (#1328)
Three related fixes around the `worktree.copyFiles` primitive: 1. Remove the `.env.example -> .env` rename example from reference/configuration.md and getting-started/overview.md. The `->` parser was removed in #739 (2026-03-19) because it caused the stale-credentials production bug in #228 — but the docs kept advertising it. A user writing `.env.example -> .env` today gets `parseCopyFileEntry` returning `{source: '.env.example -> .env', destination: '.env.example -> .env'}`, stat() fails with ENOENT, and the copy silently no-ops at debug level. 2. Replace the single-line "Default behavior: .archon/ is always copied" note with a proper "Worktree file copying" subsection that explains: - Why this exists (git worktree add = tracked files only; gitignored workflow inputs need this hook) - The `.archon/` default (no config needed for the common case) - Common entries: .env, .vscode/, .claude/, plans/, reports/, data fixtures - Semantics: source=destination, ENOENT silently skipped, per-entry error isolation, path-traversal rejected - Interaction with `worktree.path` (both layouts get the same treatment) 3. Update the overview example to drop the `.env.example + .env` pair (which implied rename semantics) in favor of `.env + plans/`, and call out that `.archon/` is auto-copied so users don't list it. No code changes. `bun run format:check` and `bun run lint` green.
1 parent 08de8ee commit ba4b9b4

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

packages/docs-web/src/content/docs/getting-started/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,9 @@ assistant: claude
383383
commands:
384384
folder: .claude/commands/archon # additional command search path
385385
worktree:
386-
copyFiles:
387-
- .env.example # copy into worktrees (same filename)
388-
- .env
386+
copyFiles: # gitignored files/dirs to copy into worktrees
387+
- .env # (`.archon/` is copied automatically — no need to list it)
388+
- plans/
389389
```
390390
391391
Without any `.archon/` config, the platform uses sensible defaults (bundled commands and workflows).

packages/docs-web/src/content/docs/reference/configuration.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ commands:
122122
# Worktree settings
123123
worktree:
124124
baseBranch: main # Optional: auto-detected from git when not set
125-
copyFiles: # Optional: Additional files to copy to worktrees
126-
- .env.example -> .env # Rename during copy
125+
copyFiles: # Optional: Gitignored files/dirs to copy into new worktrees.
126+
# `.archon/` is always copied automatically — don't list it.
127+
- .env
127128
- .vscode # Copy entire directory
129+
- plans/ # Local plans not committed to the team repo
128130
initSubmodules: true # Optional: default true — auto-detects .gitmodules and runs
129131
# `git submodule update --init --recursive`. Set false to opt out.
130132
path: .worktrees # Optional: co-locate worktrees with the repo at
@@ -171,7 +173,34 @@ assistants:
171173
172174
This is useful when you maintain coding style or identity preferences in `~/.claude/CLAUDE.md` and want Archon sessions to respect them.
173175

174-
**Default behavior:** The `.archon/` directory is always copied to worktrees automatically (contains artifacts, plans, workflows). Use `copyFiles` only for additional files like `.env` or `.vscode`.
176+
### Worktree file copying (`worktree.copyFiles`)
177+
178+
`git worktree add` only copies **tracked** files into a new worktree. Anything gitignored — secrets, local planning docs, agent reports, IDE settings, data fixtures — is absent by default. Archon's `worktree.copyFiles` closes that gap: after the worktree is created, each listed path is copied from the canonical repo into the worktree via raw filesystem copy (not git), so gitignored content comes along for the ride.
179+
180+
**Defaults — no config needed for the common case.** `.archon/` is always copied automatically. If you gitignore `.archon/` (or it's just not committed), your custom commands, workflows, and scripts still reach every worktree. You do not need to list `.archon/` in `copyFiles` — it's merged in for you.
181+
182+
**Common entries:**
183+
184+
```yaml
185+
worktree:
186+
copyFiles:
187+
- .env # local secrets
188+
- .vscode/ # editor settings
189+
- .claude/ # per-repo Claude Code config (agents, skills, hooks)
190+
- plans/ # working docs that aren't committed
191+
- reports/ # agent-generated markdown reports
192+
- data/fixtures/ # local-only test data
193+
```
194+
195+
**Semantics:**
196+
197+
- Each entry is a path (file or directory) relative to the repo root — source and destination are always identical. No rename syntax.
198+
- Missing files are silently skipped (`ENOENT` at debug level), so you can list "optional" entries without bookkeeping.
199+
- Directories are copied recursively.
200+
- Per-entry failures are isolated — one bad entry won't abort the rest. Non-ENOENT failures (permissions, disk full) are surfaced as warnings on the environment.
201+
- Path-traversal attempts (entries resolving outside the repo root, or absolute paths on a different drive) are rejected — the entry is logged and skipped.
202+
203+
**Interaction with `worktree.path`:** The copy step runs identically whether worktrees live under `~/.archon/workspaces/<owner>/<repo>/worktrees/` (default) or inside the repo at `<repoRoot>/<worktree.path>/` (repo-local). Both layouts get the same gitignored-file treatment.
175204

176205
**Defaults behavior:** The app's bundled default commands and workflows are loaded at runtime and merged with repo-specific ones. Repo commands/workflows override app defaults by name. Set `defaults.loadDefaultCommands: false` or `defaults.loadDefaultWorkflows: false` to disable runtime loading.
177206

0 commit comments

Comments
 (0)