harness-everything 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/build-multi-agent-system/SKILL.md +68 -68
- package/create-agent-launcher/SKILL.md +48 -48
- package/docs/workflows/build-multi-agent-system.md +62 -62
- package/docs/workflows/create-agent-launcher.md +62 -62
- package/docs/workflows/environment-detection.md +63 -63
- package/docs/workflows/eval-harness.md +57 -57
- package/docs/workflows/fable-discipline.md +59 -59
- package/docs/workflows/fable-mode.md +32 -32
- package/docs/workflows/git-commit.md +62 -62
- package/docs/workflows/grill-me.md +62 -62
- package/docs/workflows/grill-with-docs.md +62 -62
- package/docs/workflows/improve-codebase-architecture.md +60 -60
- package/docs/workflows/repo-docs.md +59 -59
- package/docs/workflows/rewrite-commits.md +60 -60
- package/docs/workflows/security-review.md +58 -58
- package/docs/workflows/self-evolve.md +59 -59
- package/docs/workflows/tdd.md +39 -39
- package/docs/workflows/todo-driven-workflow.md +36 -36
- package/docs/workflows/using-git-worktrees.md +63 -63
- package/docs/workflows/verification-loop.md +69 -69
- package/docs/workflows/verify-before-claim.md +60 -60
- package/docs/workflows/zoom-out.md +62 -62
- package/environment-detection/SKILL.md +77 -77
- package/eval-framework/behavioral-test.js +105 -105
- package/eval-framework/mechanism-test.js +251 -251
- package/eval-harness/SKILL.md +59 -59
- package/fable-discipline/SKILL.md +38 -38
- package/fable-mode/SKILL.md +51 -51
- package/git-commit/SKILL.md +55 -55
- package/grill-me/SKILL.md +36 -36
- package/grill-with-docs/SKILL.md +99 -99
- package/harness-everything/SKILL.md +141 -141
- package/harness-everything/examples/README.md +9 -9
- package/harness-everything/examples/todo-workflow.md +22 -22
- package/harness-everything/scripts/todo-cli.js +157 -157
- package/harness-everything/scripts/verify-gate.js +31 -31
- package/hooks/scripts/atomic-commit-check.js +68 -68
- package/hooks/scripts/context-compact.js +114 -114
- package/hooks/scripts/lib/harness-state.js +29 -3
- package/hooks/scripts/lib/platforms/claude.js +42 -42
- package/hooks/scripts/lib/platforms/codex.js +46 -46
- package/hooks/scripts/lib/platforms/continue.js +41 -41
- package/hooks/scripts/lib/platforms/copilot.js +41 -41
- package/hooks/scripts/lib/platforms/cursor.js +41 -41
- package/hooks/scripts/rule-of-3.js +176 -176
- package/improve-codebase-architecture/SKILL.md +44 -44
- package/install-cognitive-os/SKILL.md +95 -95
- package/package.json +1 -1
- package/repo-docs/SKILL.md +45 -45
- package/rewrite-commits/SKILL.md +32 -32
- package/scripts/installer.js +649 -649
- package/scripts/lib/advisory-text.js +163 -163
- package/scripts/lib/claude-hooks.js +71 -71
- package/scripts/lib/gitignore.js +80 -58
- package/scripts/lib/manifest.js +82 -82
- package/scripts/lib/prompts.js +241 -241
- package/scripts/lib/skills.js +172 -172
- package/scripts/lib/workspace.js +28 -28
- package/security-review/SKILL.md +510 -510
- package/self-evolve/SKILL.md +54 -54
- package/skill-creator/SKILL.md +91 -91
- package/skill-creator/references/testing-workflow.md +32 -32
- package/skill-style/SKILL.md +48 -48
- package/tdd/SKILL.md +53 -53
- package/todo-driven-workflow/SKILL.md +54 -54
- package/using-git-worktrees/SKILL.md +161 -161
- package/verification-loop/SKILL.md +138 -138
- package/verify-before-claim/SKILL.md +86 -86
- package/zoom-out/SKILL.md +90 -90
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: todo-driven-workflow
|
|
3
|
-
description: Enforces a deliberate, step-by-step execution loop.
|
|
4
|
-
author: Miya Daniel | Harness Core Team
|
|
5
|
-
version: 1.1.0
|
|
6
|
-
metadata:
|
|
7
|
-
type: harness-discipline
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# Todo-Driven Workflow (以 TODO 驅動的自動化工作流)
|
|
11
|
-
|
|
12
|
-
## 📋 Skill Contract
|
|
13
|
-
|
|
14
|
-
| Component | Specification |
|
|
15
|
-
| :--- | :--- |
|
|
16
|
-
| **Trigger / Input** | Tier 2/3 Task Identification. Input: High-level task description. |
|
|
17
|
-
| **Expected Output** | Granular execution state. A series of terminal calls to `todo-cli.js`. |
|
|
18
|
-
| **State Mutations** | MUST write to `.claude/harness-state/todo-state.json` via CLI. |
|
|
19
|
-
| **Enforcement Gate** | `node harness-everything/scripts/todo-cli.js`. Exits with Code 1 if multitasking, bypassing initialization, or skipping `verify-gate.js`. |
|
|
20
|
-
|
|
21
|
-
This skill enforces a disciplined execution loop. It prevents "hallucinated progress" by forcing the Agent to track exact state and prove completion before moving to the next step.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## ⚡ Core Trigger (觸發時機)
|
|
26
|
-
This workflow is **the default operating behavior** for any complex, multi-step, or multi-file development tasks (Tier 2 and Tier 3).
|
|
27
|
-
|
|
28
|
-
## ⚙️ Execution Method
|
|
29
|
-
|
|
30
|
-
| Environment | Primary Task Tracker | Implementation Method |
|
|
31
|
-
| :--- | :--- | :--- |
|
|
32
|
-
| **All Environments** | `todo-cli.js` | You MUST use `node harness-everything/scripts/todo-cli.js` for all state transitions. Do NOT rely on prompt text. |
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## 🔄 Execution Loop: Think > Try > Summarize > Record
|
|
37
|
-
|
|
38
|
-
### 1. Analyze and Plan (Think)
|
|
39
|
-
Break the high-level goal into **3 to 7 concrete, verifiable sub-tasks**.
|
|
40
|
-
|
|
41
|
-
### 2. Initialize the Todo List (Record)
|
|
42
|
-
- **CRITICAL ACTION**: You MUST use the `run_in_terminal` tool to run `node harness-everything/scripts/todo-cli.js init "Task 1" "Task 2"` BEFORE modifying any code.
|
|
43
|
-
- *Rule*: The terminal output will confirm the list is initialized.
|
|
44
|
-
|
|
45
|
-
### 3. Step-by-Step Execution
|
|
46
|
-
1. **Start**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js start <id>`. **If you try to start two tasks, the script will crash and block you.**
|
|
47
|
-
2. **Execute**: Perform the necessary actions (read files, grep, run terminal commands, edit files).
|
|
48
|
-
3. **Verify**: The validation gate is hardcoded into the completion step.
|
|
49
|
-
4. **Complete**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js complete <id>`. If the internal `verify-gate.js` check fails, this command will Exit 1 and block you.
|
|
50
|
-
|
|
51
|
-
### 4. Handling Blocker Failures (Dynamic Adaptation)
|
|
52
|
-
If a step fails:
|
|
53
|
-
- Use `node harness-everything/scripts/todo-cli.js add "Fix specific error"` to insert a blocker.
|
|
54
|
-
- Do NOT silently ignore or bypass the error.
|
|
1
|
+
---
|
|
2
|
+
name: todo-driven-workflow
|
|
3
|
+
description: Enforces a deliberate, step-by-step execution loop.
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 1.1.0
|
|
6
|
+
metadata:
|
|
7
|
+
type: harness-discipline
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Todo-Driven Workflow (以 TODO 驅動的自動化工作流)
|
|
11
|
+
|
|
12
|
+
## 📋 Skill Contract
|
|
13
|
+
|
|
14
|
+
| Component | Specification |
|
|
15
|
+
| :--- | :--- |
|
|
16
|
+
| **Trigger / Input** | Tier 2/3 Task Identification. Input: High-level task description. |
|
|
17
|
+
| **Expected Output** | Granular execution state. A series of terminal calls to `todo-cli.js`. |
|
|
18
|
+
| **State Mutations** | MUST write to `.claude/harness-state/todo-state.json` via CLI. |
|
|
19
|
+
| **Enforcement Gate** | `node harness-everything/scripts/todo-cli.js`. Exits with Code 1 if multitasking, bypassing initialization, or skipping `verify-gate.js`. |
|
|
20
|
+
|
|
21
|
+
This skill enforces a disciplined execution loop. It prevents "hallucinated progress" by forcing the Agent to track exact state and prove completion before moving to the next step.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## ⚡ Core Trigger (觸發時機)
|
|
26
|
+
This workflow is **the default operating behavior** for any complex, multi-step, or multi-file development tasks (Tier 2 and Tier 3).
|
|
27
|
+
|
|
28
|
+
## ⚙️ Execution Method
|
|
29
|
+
|
|
30
|
+
| Environment | Primary Task Tracker | Implementation Method |
|
|
31
|
+
| :--- | :--- | :--- |
|
|
32
|
+
| **All Environments** | `todo-cli.js` | You MUST use `node harness-everything/scripts/todo-cli.js` for all state transitions. Do NOT rely on prompt text. |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🔄 Execution Loop: Think > Try > Summarize > Record
|
|
37
|
+
|
|
38
|
+
### 1. Analyze and Plan (Think)
|
|
39
|
+
Break the high-level goal into **3 to 7 concrete, verifiable sub-tasks**.
|
|
40
|
+
|
|
41
|
+
### 2. Initialize the Todo List (Record)
|
|
42
|
+
- **CRITICAL ACTION**: You MUST use the `run_in_terminal` tool to run `node harness-everything/scripts/todo-cli.js init "Task 1" "Task 2"` BEFORE modifying any code.
|
|
43
|
+
- *Rule*: The terminal output will confirm the list is initialized.
|
|
44
|
+
|
|
45
|
+
### 3. Step-by-Step Execution
|
|
46
|
+
1. **Start**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js start <id>`. **If you try to start two tasks, the script will crash and block you.**
|
|
47
|
+
2. **Execute**: Perform the necessary actions (read files, grep, run terminal commands, edit files).
|
|
48
|
+
3. **Verify**: The validation gate is hardcoded into the completion step.
|
|
49
|
+
4. **Complete**: Use `run_in_terminal` to run `node harness-everything/scripts/todo-cli.js complete <id>`. If the internal `verify-gate.js` check fails, this command will Exit 1 and block you.
|
|
50
|
+
|
|
51
|
+
### 4. Handling Blocker Failures (Dynamic Adaptation)
|
|
52
|
+
If a step fails:
|
|
53
|
+
- Use `node harness-everything/scripts/todo-cli.js add "Fix specific error"` to insert a blocker.
|
|
54
|
+
- Do NOT silently ignore or bypass the error.
|
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: using-git-worktrees
|
|
3
|
-
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
|
|
4
|
-
author: Miya Daniel | Harness Core Team
|
|
5
|
-
version: 0.2.0
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Using Git Worktrees
|
|
9
|
-
|
|
10
|
-
## 📋 Skill Contract
|
|
11
|
-
|
|
12
|
-
| Component | Specification |
|
|
13
|
-
| :--- | :--- |
|
|
14
|
-
| **Trigger / Input** | Starting feature work that needs isolation from the current workspace, or before executing an implementation plan. |
|
|
15
|
-
| **Expected Output** | An isolated workspace (native worktree tool preferred, `git worktree add` fallback) with dependencies installed and a clean baseline test run confirmed. |
|
|
16
|
-
| **State Mutations** | May create a new worktree directory/branch (`.worktrees/<branch>` by default) and add it to `.gitignore` if not already ignored. |
|
|
17
|
-
| **Enforcement Gate** | **MUST** detect an already-isolated workspace first (`GIT_DIR != GIT_COMMON`, excluding submodules) and skip creating a redundant one. **MUST** verify the worktree directory is gitignored before creating it. **MUST** get human consent before creating a new worktree if no preference was already declared. |
|
|
18
|
-
|
|
19
|
-
## Overview
|
|
20
|
-
|
|
21
|
-
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
|
|
22
|
-
|
|
23
|
-
**Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.
|
|
24
|
-
|
|
25
|
-
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
|
|
26
|
-
|
|
27
|
-
## Step 0: Detect Existing Isolation
|
|
28
|
-
|
|
29
|
-
**Before creating anything, check if you are already in an isolated workspace.**
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
|
|
33
|
-
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
|
|
34
|
-
BRANCH=$(git branch --show-current)
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
**Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
|
|
41
|
-
git rev-parse --show-superproject-working-tree 2>/dev/null
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree.
|
|
45
|
-
|
|
46
|
-
Report with branch state:
|
|
47
|
-
- On a branch: "Already in isolated workspace at `<path>` on branch `<name>`."
|
|
48
|
-
- Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time."
|
|
49
|
-
|
|
50
|
-
**If `GIT_DIR == GIT_COMMON` (or in a submodule):** You are in a normal repo checkout.
|
|
51
|
-
|
|
52
|
-
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
|
|
53
|
-
|
|
54
|
-
> "Would you like me to set up an isolated worktree? It protects your current branch from changes."
|
|
55
|
-
|
|
56
|
-
Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
|
|
57
|
-
|
|
58
|
-
## Step 1: Create Isolated Workspace
|
|
59
|
-
|
|
60
|
-
**You have two mechanisms. Try them in this order.**
|
|
61
|
-
|
|
62
|
-
### 1a. Native Worktree Tools (preferred)
|
|
63
|
-
|
|
64
|
-
The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 2.
|
|
65
|
-
|
|
66
|
-
Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage.
|
|
67
|
-
|
|
68
|
-
Only proceed to Step 1b if you have no native worktree tool available.
|
|
69
|
-
|
|
70
|
-
### 1b. Git Worktree Fallback
|
|
71
|
-
|
|
72
|
-
**Only use this if Step 1a does not apply** — you have no native worktree tool available. Create a worktree manually using git.
|
|
73
|
-
|
|
74
|
-
#### Directory Selection
|
|
75
|
-
|
|
76
|
-
Follow this priority order. Explicit user preference always beats observed filesystem state.
|
|
77
|
-
|
|
78
|
-
1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking.
|
|
79
|
-
|
|
80
|
-
2. **Check for an existing project-local worktree directory:**
|
|
81
|
-
```bash
|
|
82
|
-
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
|
83
|
-
ls -d worktrees 2>/dev/null # Alternative
|
|
84
|
-
```
|
|
85
|
-
If found, use it. If both exist, `.worktrees` wins.
|
|
86
|
-
|
|
87
|
-
3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
|
|
88
|
-
|
|
89
|
-
#### Safety Verification (project-local directories only)
|
|
90
|
-
|
|
91
|
-
**MUST verify directory is ignored before creating worktree:**
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**If NOT ignored:** Add to .gitignore, commit the change, then proceed.
|
|
98
|
-
|
|
99
|
-
**Why critical:** Prevents accidentally committing worktree contents to repository.
|
|
100
|
-
|
|
101
|
-
#### Create the Worktree
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# Determine path based on chosen location
|
|
105
|
-
path="$LOCATION/$BRANCH_NAME"
|
|
106
|
-
|
|
107
|
-
git worktree add "$path" -b "$BRANCH_NAME"
|
|
108
|
-
cd "$path"
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**Sandbox fallback:** If `git worktree add` fails with a permission error (sandbox denial), tell the user the sandbox blocked worktree creation and you're working in the current directory instead. Then run setup and baseline tests in place.
|
|
112
|
-
|
|
113
|
-
## Step 2: Project Setup
|
|
114
|
-
|
|
115
|
-
Auto-detect and run appropriate setup:
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
# Node.js
|
|
119
|
-
if [ -f package.json ]; then npm install; fi
|
|
120
|
-
|
|
121
|
-
# Rust
|
|
122
|
-
if [ -f Cargo.toml ]; then cargo build; fi
|
|
123
|
-
|
|
124
|
-
# Python
|
|
125
|
-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
126
|
-
if [ -f pyproject.toml ]; then poetry install; fi
|
|
127
|
-
|
|
128
|
-
# Go
|
|
129
|
-
if [ -f go.mod ]; then go mod download; fi
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Step 3: Verify Clean Baseline
|
|
133
|
-
|
|
134
|
-
Run tests to ensure workspace starts clean:
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
# Use project-appropriate command
|
|
138
|
-
npm test / cargo test / pytest / go test ./...
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**If tests fail:** Report failures, ask whether to proceed or investigate.
|
|
142
|
-
|
|
143
|
-
**If tests pass:** Report ready.
|
|
144
|
-
|
|
145
|
-
### Report
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
Worktree ready at <full-path>
|
|
149
|
-
Tests passing (<N> tests, 0 failures)
|
|
150
|
-
Ready to implement <feature-name>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Quick Reference
|
|
154
|
-
|
|
155
|
-
| Situation | Action |
|
|
156
|
-
|-----------|--------|
|
|
157
|
-
| Already in linked worktree | Skip creation (Step 0) |
|
|
158
|
-
| In a submodule | Treat as normal repo (Step 0 guard) |
|
|
159
|
-
| Native worktree tool available | Use it (Step 1a) |
|
|
160
|
-
| No native tool | Git worktree fallback (Step 1b) |
|
|
161
|
-
| `.worktrees/` exists | Use it (verify ignored) |
|
|
1
|
+
---
|
|
2
|
+
name: using-git-worktrees
|
|
3
|
+
description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Using Git Worktrees
|
|
9
|
+
|
|
10
|
+
## 📋 Skill Contract
|
|
11
|
+
|
|
12
|
+
| Component | Specification |
|
|
13
|
+
| :--- | :--- |
|
|
14
|
+
| **Trigger / Input** | Starting feature work that needs isolation from the current workspace, or before executing an implementation plan. |
|
|
15
|
+
| **Expected Output** | An isolated workspace (native worktree tool preferred, `git worktree add` fallback) with dependencies installed and a clean baseline test run confirmed. |
|
|
16
|
+
| **State Mutations** | May create a new worktree directory/branch (`.worktrees/<branch>` by default) and add it to `.gitignore` if not already ignored. |
|
|
17
|
+
| **Enforcement Gate** | **MUST** detect an already-isolated workspace first (`GIT_DIR != GIT_COMMON`, excluding submodules) and skip creating a redundant one. **MUST** verify the worktree directory is gitignored before creating it. **MUST** get human consent before creating a new worktree if no preference was already declared. |
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available.
|
|
22
|
+
|
|
23
|
+
**Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness.
|
|
24
|
+
|
|
25
|
+
**Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
|
|
26
|
+
|
|
27
|
+
## Step 0: Detect Existing Isolation
|
|
28
|
+
|
|
29
|
+
**Before creating anything, check if you are already in an isolated workspace.**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
|
|
33
|
+
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
|
|
34
|
+
BRANCH=$(git branch --show-current)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# If this returns a path, you're in a submodule, not a worktree — treat as normal repo
|
|
41
|
+
git rev-parse --show-superproject-working-tree 2>/dev/null
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**If `GIT_DIR != GIT_COMMON` (and not a submodule):** You are already in a linked worktree. Skip to Step 2 (Project Setup). Do NOT create another worktree.
|
|
45
|
+
|
|
46
|
+
Report with branch state:
|
|
47
|
+
- On a branch: "Already in isolated workspace at `<path>` on branch `<name>`."
|
|
48
|
+
- Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time."
|
|
49
|
+
|
|
50
|
+
**If `GIT_DIR == GIT_COMMON` (or in a submodule):** You are in a normal repo checkout.
|
|
51
|
+
|
|
52
|
+
Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
|
|
53
|
+
|
|
54
|
+
> "Would you like me to set up an isolated worktree? It protects your current branch from changes."
|
|
55
|
+
|
|
56
|
+
Honor any existing declared preference without asking. If the user declines consent, work in place and skip to Step 2.
|
|
57
|
+
|
|
58
|
+
## Step 1: Create Isolated Workspace
|
|
59
|
+
|
|
60
|
+
**You have two mechanisms. Try them in this order.**
|
|
61
|
+
|
|
62
|
+
### 1a. Native Worktree Tools (preferred)
|
|
63
|
+
|
|
64
|
+
The user has asked for an isolated workspace (Step 0 consent). Do you already have a way to create a worktree? It might be a tool with a name like `EnterWorktree`, `WorktreeCreate`, a `/worktree` command, or a `--worktree` flag. If you do, use it and skip to Step 2.
|
|
65
|
+
|
|
66
|
+
Native tools handle directory placement, branch creation, and cleanup automatically. Using `git worktree add` when you have a native tool creates phantom state your harness can't see or manage.
|
|
67
|
+
|
|
68
|
+
Only proceed to Step 1b if you have no native worktree tool available.
|
|
69
|
+
|
|
70
|
+
### 1b. Git Worktree Fallback
|
|
71
|
+
|
|
72
|
+
**Only use this if Step 1a does not apply** — you have no native worktree tool available. Create a worktree manually using git.
|
|
73
|
+
|
|
74
|
+
#### Directory Selection
|
|
75
|
+
|
|
76
|
+
Follow this priority order. Explicit user preference always beats observed filesystem state.
|
|
77
|
+
|
|
78
|
+
1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking.
|
|
79
|
+
|
|
80
|
+
2. **Check for an existing project-local worktree directory:**
|
|
81
|
+
```bash
|
|
82
|
+
ls -d .worktrees 2>/dev/null # Preferred (hidden)
|
|
83
|
+
ls -d worktrees 2>/dev/null # Alternative
|
|
84
|
+
```
|
|
85
|
+
If found, use it. If both exist, `.worktrees` wins.
|
|
86
|
+
|
|
87
|
+
3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
|
|
88
|
+
|
|
89
|
+
#### Safety Verification (project-local directories only)
|
|
90
|
+
|
|
91
|
+
**MUST verify directory is ignored before creating worktree:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**If NOT ignored:** Add to .gitignore, commit the change, then proceed.
|
|
98
|
+
|
|
99
|
+
**Why critical:** Prevents accidentally committing worktree contents to repository.
|
|
100
|
+
|
|
101
|
+
#### Create the Worktree
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Determine path based on chosen location
|
|
105
|
+
path="$LOCATION/$BRANCH_NAME"
|
|
106
|
+
|
|
107
|
+
git worktree add "$path" -b "$BRANCH_NAME"
|
|
108
|
+
cd "$path"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Sandbox fallback:** If `git worktree add` fails with a permission error (sandbox denial), tell the user the sandbox blocked worktree creation and you're working in the current directory instead. Then run setup and baseline tests in place.
|
|
112
|
+
|
|
113
|
+
## Step 2: Project Setup
|
|
114
|
+
|
|
115
|
+
Auto-detect and run appropriate setup:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Node.js
|
|
119
|
+
if [ -f package.json ]; then npm install; fi
|
|
120
|
+
|
|
121
|
+
# Rust
|
|
122
|
+
if [ -f Cargo.toml ]; then cargo build; fi
|
|
123
|
+
|
|
124
|
+
# Python
|
|
125
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
126
|
+
if [ -f pyproject.toml ]; then poetry install; fi
|
|
127
|
+
|
|
128
|
+
# Go
|
|
129
|
+
if [ -f go.mod ]; then go mod download; fi
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Step 3: Verify Clean Baseline
|
|
133
|
+
|
|
134
|
+
Run tests to ensure workspace starts clean:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Use project-appropriate command
|
|
138
|
+
npm test / cargo test / pytest / go test ./...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**If tests fail:** Report failures, ask whether to proceed or investigate.
|
|
142
|
+
|
|
143
|
+
**If tests pass:** Report ready.
|
|
144
|
+
|
|
145
|
+
### Report
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
Worktree ready at <full-path>
|
|
149
|
+
Tests passing (<N> tests, 0 failures)
|
|
150
|
+
Ready to implement <feature-name>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Quick Reference
|
|
154
|
+
|
|
155
|
+
| Situation | Action |
|
|
156
|
+
|-----------|--------|
|
|
157
|
+
| Already in linked worktree | Skip creation (Step 0) |
|
|
158
|
+
| In a submodule | Treat as normal repo (Step 0 guard) |
|
|
159
|
+
| Native worktree tool available | Use it (Step 1a) |
|
|
160
|
+
| No native tool | Git worktree fallback (Step 1b) |
|
|
161
|
+
| `.worktrees/` exists | Use it (verify ignored) |
|