You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(isolation): per-project worktree.path + collapse to two layouts
Adds an opt-in `worktree.path` to .archon/config.yaml so a repo can co-locate
worktrees with its own checkout (`<repoRoot>/<path>/<branch>`) instead of the
default `~/.archon/workspaces/<owner>/<repo>/worktrees/<branch>`. Requested in
joelsb's #1117.
Primitive changes (clean up the graveyard rather than add parallel code paths):
- Collapse worktree layouts from three to two. The old "legacy global" layout
(`~/.archon/worktrees/<owner>/<repo>/<branch>`) is gone — every repo resolves
to the workspace-scoped layout (`~/.archon/workspaces/<owner>/<repo>/worktrees/<branch>`),
whether it was archon-cloned or locally registered. `extractOwnerRepo()` on
the repo path is the stable identity fallback. Ends the divergence where
workspace-cloned and local repos had visibly different worktree trees.
- `getWorktreeBase()` in @archon/git now returns `{ base, layout }` and accepts
an optional `{ repoLocal }` override. The layout value replaces the old
`isProjectScopedWorktreeBase()` classification at the call sites
(`isProjectScopedWorktreeBase` stays exported as deprecated back-compat).
- `WorktreeCreateConfig.path` carries the validated override from repo config.
`resolveRepoLocalOverride()` fails loudly on absolute paths, `..` escapes,
and resolve-escape edge cases (Fail Fast — no silent default fallback when
the config is syntactically wrong).
- `WorktreeProvider.create()` now loads repo config exactly once and threads it
through `getWorktreePath()` + `createWorktree()`. Replaces the prior
swallow-then-retry pattern flagged on #1117. `generateEnvId()` is gone —
envId is assigned directly from the resolved path (the invariant was already
documented on `destroy(envId)`).
Tests (packages/git + packages/isolation):
- Update the pre-existing `getWorktreeBase` / `isProjectScopedWorktreeBase`
suite for the new two-layout return shape and precedence.
- Add 8 tests for `worktree.path`: default fallthrough, empty/whitespace
ignored, override wins for workspace-scoped repos, rejects absolute, rejects
`../` escapes (three variants), accepts nested relative paths.
Docs: add `worktree.path` to the repo config reference with explicit precedence
and the `.gitignore` responsibility note.
Co-authored-by: Joel Bastos <joelsb2001@gmail.com>
* feat(workflows): per-workflow worktree.enabled policy
Introduces a declarative top-level `worktree:` block on a workflow so
authors can pin isolation behavior regardless of invocation surface. Solves
the case where read-only workflows (e.g. `repo-triage`) should always run in
the live checkout, without every CLI/web/scheduled-trigger caller having to
remember to set the right flag.
Schema (packages/workflows/src/schemas/workflow.ts + loader.ts):
- New optional `worktree.enabled: boolean` on `workflowBaseSchema`. Loader
parses with the same warn-and-ignore discipline used for `interactive`
and `modelReasoningEffort` — invalid shapes log and drop rather than
killing workflow discovery.
Policy reconciliation (packages/cli/src/commands/workflow.ts):
- Three hard-error cases when YAML policy contradicts invocation flags:
• `enabled: false` + `--branch` (worktree required by flag, forbidden by policy)
• `enabled: false` + `--from` (start-point only meaningful with worktree)
• `enabled: true` + `--no-worktree` (policy requires worktree, flag forbids it)
- `enabled: false` + `--no-worktree` is redundant, accepted silently.
- `--resume` ignores the pinned policy (it reuses the existing run's worktree
even when policy would disable — avoids disturbing a paused run).
Orchestrator wiring (packages/core/src/orchestrator/orchestrator-agent.ts):
- `dispatchOrchestratorWorkflow` short-circuits `validateAndResolveIsolation`
when `workflow.worktree?.enabled === false` and runs directly in
`codebase.default_cwd`. Web chat/slack/telegram callers have no flag
equivalent to `--no-worktree`, so the YAML field is their only control.
- Logged as `workflow.worktree_disabled_by_policy` for operator visibility.
First consumer (.archon/workflows/repo-triage.yaml):
- `worktree: { enabled: false }` — triage reads issues/PRs and writes gh
labels; no code mutations, no reason to spin up a worktree per run.
Tests:
- Loader: parses `worktree.enabled: true|false`, omits block when absent.
- CLI: four new integration tests for the reconciliation matrix (skip when
policy false, three hard-error cases, redundant `--no-worktree` accepted,
`--no-worktree` + `enabled: true` rejected).
Docs: authoring-workflows.md gets the new top-level field in the schema
example with a comment explaining the precedence and the `enabled: true|false`
semantics.
* fix(isolation): use path.sep for repo-containment check on Windows
resolveRepoLocalOverride was hardcoding '/' as the separator in the
startsWith check, so on Windows (where `resolve()` returns backslash
paths like `D:\Users\dev\Projects\myapp`) every otherwise-valid
relative `worktree.path` was rejected with "resolves outside the repo
root". Fixed by importing `path.sep` and using it in the sentinel.
Fixes the 3 Windows CI failures in `worktree.path repo-local override`.
---------
Co-authored-by: Joel Bastos <joelsb2001@gmail.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
-**`'global'` variant on `WorkflowSource`** — workflows at `~/.archon/workflows/` and commands at `~/.archon/commands/` now render with a distinct source label (no longer coerced to `'project'`). Web UI badges updated.
16
16
-**`getHomeWorkflowsPath()`, `getHomeCommandsPath()`, `getHomeScriptsPath()`, `getLegacyHomeWorkflowsPath()`** helpers in `@archon/paths`, exported for both internal discovery and external callers that want to target the home scope directly.
17
17
-**`discoverScriptsForCwd(cwd)`** in `@archon/workflows/script-discovery` — merges home-scoped + repo-scoped scripts with repo winning on name collisions. Used by the DAG executor and validator; callers no longer need to know about the two-scope shape.
18
+
-**Workflow-level worktree policy (`worktree.enabled` in workflow YAML).** A workflow can now pin whether its runs use isolation regardless of how they were invoked: `worktree.enabled: false` always runs in the live checkout (CLI `--branch` / `--from` hard-error; web/chat/orchestrator short-circuits `validateAndResolveIsolation`), `worktree.enabled: true` requires isolation (CLI `--no-worktree` hard-errors). Omit the block to let the caller decide (current default). First consumer: `.archon/workflows/repo-triage.yaml` pinned to `enabled: false` since it's read-only.
19
+
-**Per-project worktree path (`worktree.path` in `.archon/config.yaml`).** Opt-in repo-relative directory (e.g. `.worktrees`) where Archon places worktrees for that repo, instead of the default `~/.archon/workspaces/<owner>/<repo>/worktrees/`. Co-locates worktrees with the project so they appear in the IDE file tree. Validated as a safe relative path (no absolute, no `..`); malformed values fail loudly at worktree creation. Users opting in are responsible for `.gitignore`ing the directory themselves — no automatic file mutation. Credits @joelsb for surfacing the need in #1117.
18
20
-**Three-path env model with operator-visible log lines.** The CLI and server now load env vars from `~/.archon/.env` (user scope) and `<cwd>/.archon/.env` (repo scope, overrides user) at boot, both with `override: true`. A new `[archon] loaded N keys from <path>` line is emitted per source (only when N > 0). `[archon] stripped N keys from <cwd> (...)` now also prints when stripCwdEnv removes target-repo env keys, replacing the misleading `[dotenv@17.3.1] injecting env (0) from .env` preamble that always reported 0. The `quiet: true` flag suppresses dotenv's own output. (#1302)
19
21
-**`archon setup --scope home|project` and `--force` flags.** Default is `--scope home` (writes `~/.archon/.env`). `--scope project` targets `<cwd>/.archon/.env` instead. `--force` overwrites the target wholesale rather than merging; a timestamped backup is still written. (#1303)
20
22
-**Merge-only setup writes with timestamped backups.**`archon setup` now reads the existing target file, preserves non-empty values, carries user-added custom keys forward, and writes a `<target>.archon-backup-<ISO-ts>` before every rewrite. Fixes silent PostgreSQL→SQLite downgrade and silent token loss on re-run. (#1303)
# `git submodule update --init --recursive`. Set false to opt out.
130
+
path: .worktrees # Optional: co-locate worktrees with the repo at
131
+
# <repoRoot>/.worktrees/<branch> instead of under
132
+
# ~/.archon/workspaces/<owner>/<repo>/worktrees/.
133
+
# Must be relative; no absolute, no `..` segments.
130
134
131
135
# Documentation directory
132
136
docs:
@@ -180,6 +184,8 @@ This is useful when you maintain coding style or identity preferences in `~/.cla
180
184
181
185
**Docs path behavior:** The `docs.path` setting controls where the `$DOCS_DIR` variable points. When not configured, `$DOCS_DIR` defaults to `docs/`. Unlike `$BASE_BRANCH`, this variable always has a safe default and never throws an error. Configure it when your documentation lives outside the standard `docs/` directory (e.g., `packages/docs-web/src/content/docs`).
182
186
187
+
**Worktree path behavior:** By default, every repo's worktrees live under `~/.archon/workspaces/<owner>/<repo>/worktrees/<branch>` — outside the repo, invisible to the IDE. Set `worktree.path` to opt in to a **repo-local** layout instead: worktrees are created at `<repoRoot>/<worktree.path>/<branch>` so they show up in the file tree and editor workspace. A common choice is `.worktrees`. Because worktrees now live inside the repository tree, you should add the directory to your `.gitignore` (Archon does not modify user-owned files). The configured path must be relative to the repo root; absolute paths and paths containing `..` segments fail loudly at worktree creation rather than silently falling back.
188
+
183
189
## Environment Variables
184
190
185
191
Environment variables override all other configuration. They are organized by category below.
0 commit comments