harness-everything 0.8.0 → 0.8.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.
Files changed (75) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/workflows/ci.yml +12 -2
  4. package/AGENTS.md +36 -35
  5. package/CHANGELOG.md +17 -0
  6. package/README.md +2 -2
  7. package/benchmarks/results/reviews/pr142-verification.json +95 -0
  8. package/ci/action-gate.test.js +1 -1
  9. package/ci/doc-capability-consistency.test.js +3 -0
  10. package/ci/invariant-routing.test.js +87 -74
  11. package/ci/mechanism-2af-worktree-isolation.test.js +152 -0
  12. package/ci/mechanism-2ag-router-worktree-contract.test.js +44 -0
  13. package/ci/mechanism-2ah-workflow-lifecycle.test.js +140 -0
  14. package/ci/openai-plugin-package.test.js +9 -6
  15. package/ci/workflow-execution-contract.test.js +60 -0
  16. package/docs/architecture.md +111 -114
  17. package/docs/mechanism-first-skill-mesh.md +92 -103
  18. package/docs/openai-plugin.md +1 -1
  19. package/docs/philosophy.md +40 -33
  20. package/docs/platform-capabilities.md +2 -2
  21. package/docs/reviews/pr-142-issue-131.md +89 -0
  22. package/docs/routing.md +61 -124
  23. package/docs/workflow-runtime.md +109 -0
  24. package/fable-mode/CONTRACT-FORMAT.md +3 -1
  25. package/fable-mode/SKILL.md +1 -1
  26. package/fable-mode/execution-guardrails/SKILL.md +1 -1
  27. package/fable-mode/fable-haiku/SKILL.md +1 -1
  28. package/fable-mode/fable-opus/SKILL.md +1 -1
  29. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  30. package/fable-mode/scripts/workflow-plan-consumer.js +3 -1
  31. package/harness-everything/SKILL.md +11 -10
  32. package/harness-everything/references/triage-and-tiers.md +76 -107
  33. package/harness-everything/scripts/kernel-router-core.js +263 -0
  34. package/harness-everything/scripts/kernel-router.js +97 -225
  35. package/harness-everything/scripts/router-contract-core.js +612 -0
  36. package/harness-everything/scripts/router-contract.js +21 -581
  37. package/hooks/hooks.json +22 -1
  38. package/hooks/scripts/contract-test.js +24 -2
  39. package/hooks/scripts/lib/workflow-isolation.js +102 -0
  40. package/hooks/scripts/lib/workflow-runtime.js +102 -0
  41. package/hooks/scripts/state-persist.js +1 -0
  42. package/hooks/scripts/workflow-disposition.js +97 -0
  43. package/hooks/scripts/workflow-gate.js +53 -0
  44. package/hooks/scripts/workflow-stop-gate.js +44 -0
  45. package/opencode-plugin/plugin.json +1 -1
  46. package/package.json +2 -2
  47. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  48. package/plugins/harness-everything/hooks/hooks.json +20 -1
  49. package/plugins/harness-everything/hooks/scripts/contract-test.js +24 -2
  50. package/plugins/harness-everything/hooks/scripts/lib/workflow-isolation.js +102 -0
  51. package/plugins/harness-everything/hooks/scripts/lib/workflow-runtime.js +102 -0
  52. package/plugins/harness-everything/hooks/scripts/state-persist.js +1 -0
  53. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +97 -0
  54. package/plugins/harness-everything/hooks/scripts/workflow-gate.js +53 -0
  55. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +44 -0
  56. package/plugins/harness-everything/plugin.json +1 -1
  57. package/plugins/harness-everything/scripts/lib/advisory-text.js +51 -54
  58. package/plugins/harness-everything/skills/fable-mode/CONTRACT-FORMAT.md +3 -1
  59. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  60. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
  61. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  62. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
  63. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  64. package/plugins/harness-everything/skills/fable-mode/scripts/workflow-plan-consumer.js +3 -1
  65. package/plugins/harness-everything/skills/harness-everything/SKILL.md +11 -10
  66. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +76 -107
  67. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +263 -0
  68. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +97 -225
  69. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +612 -0
  70. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract.js +21 -581
  71. package/plugins/harness-everything/skills/using-git-worktrees/SKILL.md +14 -16
  72. package/plugins/harness-everything/skills/using-git-worktrees/references/workflow-details.md +44 -85
  73. package/scripts/lib/advisory-text.js +51 -54
  74. package/using-git-worktrees/SKILL.md +14 -16
  75. package/using-git-worktrees/references/workflow-details.md +44 -85
@@ -4,46 +4,44 @@ description: Use when starting feature work needing isolation or before implemen
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.4.0
7
+ version: 0.8.1
8
8
  ---
9
9
 
10
10
  # Using Git Worktrees
11
11
 
12
- Use native tools first; git fallback.
12
+ Use native worktree support first; raw Git is the fallback.
13
13
 
14
- ## 📋 Skill Contract
14
+ ## Contract
15
15
 
16
- | Component | Specification |
17
- | :--- | :--- |
18
- | **Trigger / Input** | Isolation-needing feature work; pre-plan setup. |
19
- | **Expected Output** | Isolated workspace plus clean test baseline. |
20
- | **State Mutations** | Creates `.worktrees/<branch>`; updates `.gitignore` if needed. |
21
- | **Enforcement Gate** | Detect existing isolation first; seamless sandbox fallback. |
16
+ - **Major workflow mode** — Tier 3 / Fable-class engineering must be isolated before source/artifact mutation. Reuse an existing linked worktree or create one. If isolation cannot be established, stop `BLOCKED`; never fall back to the primary working tree.
17
+ - **Ordinary mode** — isolation-needing feature work may honor an explicit user preference to stay in place.
18
+ - Never nest a worktree inside an already isolated worktree.
22
19
 
23
20
  ## Workflow
24
21
 
25
- **Step 0 — Detect existing isolation** (adapt per `environment-detection`):
22
+ **Step 0 — Detect isolation** (adapt per `environment-detection`):
26
23
  ```bash
27
24
  git rev-parse --git-dir
28
25
  git rev-parse --git-common-dir
29
26
  git branch --show-current
30
27
  git rev-parse --show-superproject-working-tree
31
28
  ```
32
- Dirs differ and no superproject → already isolated; skip to Step 2; never nest. Superproject → submodule (normal repo). Else honor declared preference or ask consent; declined → in place.
29
+ Different git/common dirs and no superproject => already isolated; continue to Step 2. A submodule is a normal repo for this check.
33
30
 
34
- **Step 1 — Create**: native tool (`EnterWorktree`, `/worktree`, `--worktree`) first — raw git creates phantom state. Else verify ignored via `git check-ignore -q .worktrees || git check-ignore -q worktrees`; unignored → add to .gitignore and commit. Then `git worktree add "$path" -b "$BRANCH_NAME"` at declared preference, existing `.worktrees/`/`worktrees/`, or default `.worktrees/`. Sandbox denial → work in place.
31
+ **Step 1 — Create/enter**: prefer native `EnterWorktree`, `/worktree`, or `--worktree`. Otherwise use `git worktree add "$path" -b "$BRANCH_NAME"`. For major mode, choose an already-ignored or external/sibling path so setup does not require modifying the primary tree first. Creation/entry failure => `BLOCKED`. Only ordinary mode may continue in place after an explicit decline/unsupported environment.
35
32
 
36
- **Step 2 — Setup**: npm/cargo/pip/poetry/go.
33
+ **Step 2 — Setup**: install project dependencies as needed.
37
34
 
38
- **Step 3 — Baseline**: run tests (`npm test`/`cargo test`/`pytest`/`go test ./...`); failures → report, ask.
35
+ **Step 3 — Baseline**: run the relevant tests/build in the isolated tree before implementation; existing failures must be surfaced before mutation proceeds.
39
36
 
40
37
  Deep dive: <this-skill-dir>/references/workflow-details.md
41
38
 
42
39
  ## USE FOR:
40
+ - Tier 3 / Fable-class mutable engineering
43
41
  - feature work needing isolation
44
42
  - pre-implementation-plan setup
45
- - native vs manual `git worktree add`
46
43
 
47
44
  ## DO NOT USE FOR:
48
45
  - nesting inside an existing worktree
49
- - branch/merge workflows
46
+ - read-only analysis with no mutation
47
+ - branch/merge workflows unrelated to workspace isolation
@@ -1,108 +1,67 @@
1
1
  # Using Git Worktrees — Full Workflow Reference
2
2
 
3
- ## Decision Flow
3
+ ## Decide whether isolation is mandatory
4
4
 
5
- ```mermaid
6
- flowchart TD
7
- Start[Trigger: Need Workspace Isolation] --> CheckIso{1. Already in Worktree?}
5
+ Tier 3 / Fable-class engineering requires Git isolation before the first source
6
+ or artifact mutation. Read-only discovery may remain in the bound repository.
7
+ Durable multi-agent workspace state is separate: a staged run may need no
8
+ multi-agent workspace and still require Git isolation.
8
9
 
9
- CheckIso -- Yes (GIT_DIR != GIT_COMMON) --> Setup[3. Run Project Setup & Dependencies]
10
- CheckIso -- No (Normal Repo) --> CheckNative{2. Native Worktree Tool Available?}
10
+ Ordinary feature work may honor an explicit preference to stay in place.
11
+ Mandatory mode has no in-place fallback for a declined helper, unavailable
12
+ native tool, sandbox denial, or creation failure; report `blocked`.
11
13
 
12
- CheckNative -- Yes --> RunNative[Use Native Worktree Tool] --> Setup
13
- CheckNative -- No --> RunGit[Try git worktree add .worktrees/branch]
14
+ ## Detect existing isolation
14
15
 
15
- RunGit -- Success --> Setup
16
- RunGit -- Fails / Denied --> WorkInPlace[Fallback: Work in Place in Current Directory] --> Setup
17
-
18
- Setup --> RunBaseline[4. Verify Clean Test Baseline]
19
- RunBaseline --> Done[Isolated Workspace Ready]
20
- ```
21
-
22
- ## Step 0 detail
23
-
24
- **Submodule guard:** `git-dir` differs from `git-common-dir` inside git submodules as well. Before concluding "already in a worktree," verify you are not in a submodule:
16
+ Inspect absolute Git paths and the registered worktree list:
25
17
 
26
18
  ```bash
27
- # If this returns a path, you're in a submodule, not a worktree — treat as normal repo
19
+ git rev-parse --absolute-git-dir
20
+ git rev-parse --path-format=absolute --git-common-dir
28
21
  git rev-parse --show-superproject-working-tree
22
+ git worktree list --porcelain
29
23
  ```
30
24
 
31
- Report with branch state:
32
- - On a branch: "Already in isolated workspace at `<path>` on branch `<name>`."
33
- - Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time."
34
-
35
- Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
36
-
37
- > "Would you like me to set up an isolated worktree? It protects your current branch from changes."
38
-
39
- Honor any existing declared preference without asking. If the user declines consent, work in place and skip to project setup.
40
-
41
- ## Step 1a detail — native tools
42
-
43
- The user has asked for an isolated workspace. 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 setup.
44
-
45
- 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.
46
-
47
- Only use the git fallback if you have no native worktree tool available.
48
-
49
- ## Step 1b detail — directory selection priority
50
-
51
- Follow this priority order. Explicit user preference always beats observed filesystem state.
52
-
53
- 1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking.
54
- 2. **Check for an existing project-local worktree directory:** Check if `.worktrees/` or `worktrees/` exists using cross-platform file system tools (`read_file` / `list_dir` or native shell test commands). If found, use it. If both exist, `.worktrees` wins.
55
- 3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
56
-
57
- ### Safety verification (project-local directories only)
58
-
59
- **MUST verify directory is ignored before creating worktree:**
60
-
61
- ```bash
62
- git check-ignore -q .worktrees || git check-ignore -q worktrees
63
- ```
64
-
65
- **If NOT ignored:** Add to .gitignore, commit the change, then proceed.
25
+ Reuse a registered linked checkout of the bound repository; never nest another
26
+ worktree inside it. A submodule or unrelated repository is not sufficient proof.
27
+ Record the resolved directory and branch (or detached HEAD) in the handoff.
66
28
 
67
- **Why critical:** Prevents accidentally committing worktree contents to repository.
29
+ ## Create and enter
68
30
 
69
- ### Create the worktree
31
+ Honor an existing directory preference. Prefer a host-native worktree facility
32
+ when available, then verify that it is backed by a registered Git worktree.
33
+ Otherwise use Git:
70
34
 
71
35
  ```bash
72
- # Determine path based on chosen location
73
- path="$LOCATION/$BRANCH_NAME"
74
-
75
- git worktree add "$path" -b "$BRANCH_NAME"
76
- cd "$path"
36
+ git worktree add "<isolated-path>" -b "<task-branch>"
77
37
  ```
78
38
 
79
- **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.
39
+ For mandatory mode, choose an already-ignored project-local path or an external
40
+ sibling path. Verify the exact project-local candidate with `git check-ignore`.
41
+ Do not edit/commit the primary tree's ignore file just to permit worktree setup.
42
+ If the native facility fails, a permitted Git fallback is valid; if neither can
43
+ establish isolation, stop mutable work as blocked.
80
44
 
81
- ## Step 2 detail — project setup
45
+ Set each subsequent tool's working-directory field to the isolated path and
46
+ keep artifact targets inside it. Entering a worktree does not authorize an
47
+ absolute edit, patch move, or shell target back into the primary checkout.
48
+ Resolve symlinks/junctions when verifying target scope.
82
49
 
83
- Auto-detect and run appropriate setup:
50
+ ## Setup and baseline
84
51
 
85
- ```bash
86
- # Node.js
87
- if [ -f package.json ]; then npm install; fi
88
-
89
- # Rust
90
- if [ -f Cargo.toml ]; then cargo build; fi
52
+ Install the detected dependencies inside the isolated checkout, then run the
53
+ relevant baseline tests/build before implementation. Surface existing failures
54
+ with exact output and distinguish them from regressions introduced by the task.
55
+ Continue fixing task-relevant failures within the user's authorized scope.
91
56
 
92
- # Python
93
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
94
- if [ -f pyproject.toml ]; then poetry install; fi
95
-
96
- # Go
97
- if [ -f go.mod ]; then go mod download; fi
98
- ```
57
+ For active Fable workflows, enter the correlated run through the router's
58
+ displayed controller before dependency installation or artifact mutation. The
59
+ session's `workflow-stages.json` bootstrap file is runtime state; it is not an
60
+ exception for source changes.
99
61
 
100
- ## Step 3 detail — baseline report
62
+ ## Evidence boundary
101
63
 
102
- If tests fail: report failures, ask whether to proceed or investigate. If tests pass:
103
-
104
- ```
105
- Worktree ready at <full-path>
106
- Tests passing (<N> tests, 0 failures)
107
- Ready to implement <feature-name>
108
- ```
64
+ The workflow gate checks registered Git identity, direct/patch target paths,
65
+ known shell side effects, and explicit outside paths. It is not a filesystem
66
+ sandbox for arbitrary script bodies or indirect side effects. Preserve the
67
+ platform capability boundary and report unsupported hook/metadata paths.
@@ -1,6 +1,5 @@
1
- // Prompt-injection-only guidance for platforms with no hook/execution
2
- // mechanism (Cursor, Copilot, Codex, Continue, Hermes). Single source of
3
- // truth for the advisory block.
1
+ // Prompt-injection guidance for integration paths where Harness cannot prove
2
+ // lifecycle-hook enforcement. Single source of truth for advisory blocks.
4
3
  const fs = require('fs');
5
4
  const path = require('path');
6
5
 
@@ -8,34 +7,36 @@ const MARKER = "Harness OS Guidance (Advisory)";
8
7
 
9
8
  const advisoryInstructions = [
10
9
  `\n# ${MARKER}`,
11
- `This file is advisory only - this platform has no hook/execution mechanism to`,
12
- `enforce it mechanically (unlike Claude Code's hook-based circuit breaker). Treat`,
13
- `these as strong defaults, not guarantees.`,
10
+ `This surface cannot be assumed to mechanically enforce every Harness lifecycle transition.`,
11
+ `Treat the workflow contract below as required agent behavior, while keeping enforcement`,
12
+ `claims bounded by the host's verified capabilities.`,
14
13
  ``,
15
- `## 🚦 MANDATORY ENTRY TRIAGE & ROUTING (ALWAYS RUN FIRST)`,
16
- `Every time you receive a new software/project prompt, you MUST load the \`harness-everything\` skill and immediately do the following:`,
17
- `1. Run \`npx github:dyphn1/Harness-everything next "<Brief summary of user's prompt>"\` (this prints the same routing recommendation kernel-router.js produces - it works from any directory and does not depend on where a local copy of the skill was installed). If the terminal is not available yet, apply the same routing contract from the loaded \`harness-everything\` skill instead of skipping this step.`,
18
- `2. For EVERY suggested skill, resolve and read its complete \`SKILL.md\` entry before deciding to skip it. Evaluate \`USE FOR\`, \`DO NOT USE FOR\`, workflow/basic flow, and hard rules against the task. If the entry explicitly requires another document to decide applicability, read that required material too. Do not reject a suggestion from only its name, description, router summary, or because the task seems routine/common.`,
19
- `3. After that evaluation, execution is advisory: use, combine, reorder, or skip skills as justified. Using one suggestion does not waive read-before-skip for the others. If a suggested skill cannot be resolved/read, mark it unresolved/unavailable instead of silently skipping it.`,
20
- `4. Output a clear routing checkpoint near the beginning of your response/update:`,
14
+ `## 🚦 MANDATORY ENTRY TRIAGE & WORKFLOW ROUTING`,
15
+ `For every software/project prompt, load the \`harness-everything\` skill and establish the routing contract before mutation:`,
16
+ `1. Run \`npx github:dyphn1/Harness-everything next "<Brief summary of user's prompt>"\`. If terminal execution is unavailable, apply the same contract from the skill instead of skipping routing.`,
17
+ `2. For EVERY suggested skill, read its complete \`SKILL.md\` entry and resolve applicability from \`USE FOR\`, \`DO NOT USE FOR\`, workflow/basic flow, and hard rules. A name, description, router summary, or "routine/simple/already clear" judgement is not enough to omit it.`,
18
+ `3. The selected workflow topology is mandatory once applicable. Execute it to resolution; choose tools, reasoning, implementation technique, and decomposition freely inside it. Do not replace it with a direct path because you believe you can solve the task without the workflow.`,
19
+ `4. If the selected workflow genuinely cannot cover part of the task, record an explicit escape for the uncovered scope with evidence. Covered obligations remain mandatory. Host-capability loss must be surfaced, not silently converted into optional execution.`,
20
+ `5. Surface a compact checkpoint near the first progress update:`,
21
21
  ` \`\`\`markdown`,
22
22
  ` ## 🚦 Harness OS Routing Checkpoint`,
23
- ` - **Active Tier**: Tier 1 (Trivial) | Tier 2 (Standard) | Tier 3 (Macro)`,
24
- ` - **Rationale**: <1-sentence rationale from the router output>`,
23
+ ` - **Active Tier**: Tier 1 | Tier 2 | Tier 3 | unclassified`,
24
+ ` - **Strategy**: <selected/deferred strategy>`,
25
+ ` - **Workflow State**: <active | deferred | blocked | escaped>`,
25
26
  ` - **Required Invariants**: <router invariants>`,
26
- ` - **Suggested Skills**: <deduplicated router suggestions or none>`,
27
- ` - **Suggestion Evaluation**: <evaluated before skip | pending | unresolved/unavailable>`,
28
- ` - **Disposition**: <skills used, or skipped all after evaluation with a brief flow-grounded reason>`,
27
+ ` - **Suggested Skills**: <deduplicated suggestions or none>`,
28
+ ` - **Applicability**: <use | not-applicable + reason | unresolved/unavailable>`,
29
+ ` - **Escape**: <none | reason + uncovered scope + evidence>`,
29
30
  ` \`\`\``,
30
31
  ``,
31
- `## 🤖 COGNITIVE COMPLIANCE (NO SILENT DEGRADES FOR NEW FEATURES)`,
32
- `- **Newly Added Features / Extensions**: Do not silently collapse a task that introduces new logic, a new API endpoint, or a new file/module into a trivial direct-edit path. Route it first and justify the tier from task evidence.`,
33
- `- **Tier 2 / Tier 3 Suggestions**: There is NO universal TODO/TDD/Fable sequence. Router suggestions are mandatory to evaluate by reading their skill entry, but optional to execute after that evaluation. Choose the smallest applicable set.`,
34
- `- **Pre-Completion Verification Gate**: Before telling the human the task is done, run \`npx github:dyphn1/Harness-everything verify\` in the project root. If it exits non-zero, fix the failures and run it again before declaring completion. On Claude Code this same check can be mechanically enforced by a stop hook; here nothing blocks you from skipping it, so treat it as a real requirement, not a suggestion.`,
35
- `- **Memory Summarization (Self-Evolve)**: When the task produces a reusable verified lesson, use the \`self-evolve\` flow to persist it; do not manufacture memory for routine work.`,
36
- `- **Environment Discovery**: Discover the environment (OS, shell, package manager) before running commands - don't assume.`,
37
- `- **Rule of 3**: If the same error repeats 3 times in a row, STOP retrying. Explain what's failing and use a fresh diagnosis / zoom-out instead of continuing to guess.`,
38
- `- **Prefer Editing**: Prefer editing over rewriting; commit logically complete chunks rather than one giant diff.`,
32
+ `## 🤖 COGNITIVE COMPLIANCE`,
33
+ `- **No universal skill pipeline**: do not force every task through TODO/TDD/Fable. The router selects the smallest sufficient topology; suggested skills are resolved for applicability.`,
34
+ `- **Applicable skill flow**: reading a skill is not permission to discard it when its workflow actually applies.`,
35
+ `- **Pre-completion verification**: before declaring done, run \`npx github:dyphn1/Harness-everything verify\` in the project root and fix failures. An instruction-only host may not block you mechanically, but the requirement remains part of the contract.`,
36
+ `- **Rule of 3**: after 3 same-signature failures, stop micro-retrying and use a fresh diagnosis / zoom-out.`,
37
+ `- **Environment discovery**: discover OS, shell, package manager/runtime, and host capability before relying on them.`,
38
+ `- **Memory / self-evolve**: persist only verified reusable lessons; use escape/replan/recovery evidence to improve workflow coverage rather than bypassing the active workflow.`,
39
+ `- **Prefer editing**: prefer targeted edits and logically complete commits over broad rewrites.`,
39
40
  ``
40
41
  ].join('\n');
41
42
 
@@ -70,30 +71,27 @@ function injectAdvisoryText(targetFile, header, label) {
70
71
  function removeAdvisoryText(targetFile) {
71
72
  if (!fs.existsSync(targetFile)) return;
72
73
  try {
73
- let content = fs.readFileSync(targetFile, 'utf8');
74
+ const content = fs.readFileSync(targetFile, 'utf8');
74
75
  const markerIndex = content.indexOf(MARKER);
75
- if (markerIndex !== -1) {
76
- let cleanContent = content;
77
- const hashMarkerIndex = content.lastIndexOf('#', markerIndex);
78
- if (hashMarkerIndex !== -1) cleanContent = content.substring(0, hashMarkerIndex).trim() + '\n';
79
- else cleanContent = content.substring(0, markerIndex).trim() + '\n';
76
+ if (markerIndex === -1) return;
77
+ let cleanContent = content;
78
+ const hashMarkerIndex = content.lastIndexOf('#', markerIndex);
79
+ if (hashMarkerIndex !== -1) cleanContent = content.substring(0, hashMarkerIndex).trim() + '\n';
80
+ else cleanContent = content.substring(0, markerIndex).trim() + '\n';
80
81
 
81
- const lines = cleanContent.trim().split('\n').map(l => l.trim()).filter(l => l !== '');
82
- if (lines.length === 0 || (lines.length === 1 && (lines[0] === '# Cursor Project Rules' || lines[0] === '# AGENTS.md' || lines[0] === '# Copilot Instructions' || lines[0] === '# .hermes.md'))) {
83
- fs.unlinkSync(targetFile);
84
- console.log(` ✅ Removed empty advisory file: ${targetFile}`);
85
- } else {
86
- fs.writeFileSync(targetFile, cleanContent.trim() + '\n', 'utf8');
87
- console.log(` ✅ Removed Harness guidance from: ${targetFile}`);
88
- }
82
+ const lines = cleanContent.trim().split('\n').map(l => l.trim()).filter(Boolean);
83
+ if (lines.length === 0 || (lines.length === 1 && ['# Cursor Project Rules', '# AGENTS.md', '# Copilot Instructions', '# .hermes.md'].includes(lines[0]))) {
84
+ fs.unlinkSync(targetFile);
85
+ console.log(` ✅ Removed empty advisory file: ${targetFile}`);
86
+ } else {
87
+ fs.writeFileSync(targetFile, cleanContent.trim() + '\n', 'utf8');
88
+ console.log(` ✅ Removed Harness guidance from: ${targetFile}`);
89
89
  }
90
90
  } catch (e) {
91
91
  console.warn(` ⚠️ Error removing advisory text from ${targetFile}: ${e.message}`);
92
92
  }
93
93
  }
94
94
 
95
- // Continue gets a dedicated rule file. If a user already owns that exact
96
- // path, do not replace it just because Harness chose the same filename.
97
95
  function installContinueRule(targetFile, label) {
98
96
  const dir = path.dirname(targetFile);
99
97
  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
@@ -103,7 +101,7 @@ function installContinueRule(targetFile, label) {
103
101
  `---`,
104
102
  `name: Harness OS Guidance`,
105
103
  `alwaysApply: true`,
106
- `description: "Harness OS routing, circuit-breaker awareness, and environment-discovery guidance (advisory only on Continue - no hook mechanism)"`,
104
+ `description: "Harness OS routing and workflow guidance (instruction-governed on Continue unless a lifecycle mechanism is independently verified)"`,
107
105
  `---`,
108
106
  advisoryInstructions.replace(/^\n/, '')
109
107
  ].join('\n');
@@ -139,25 +137,24 @@ function buildCopilotGlobalContent() {
139
137
  function buildCodexGlobalContent() {
140
138
  return [
141
139
  `---`,
142
- `description: "Harness OS Guidance - Global custom agent for orchestrating multi-agent workflows"`,
140
+ `description: "Harness OS Guidance - Global custom agent for orchestrating software workflows"`,
143
141
  `name: "Harness"`,
144
142
  `user-invocable: true`,
145
143
  `---`,
146
144
  `# AGENTS.md`,
147
145
  ``,
148
146
  `# ${MARKER}`,
149
- `This file is advisory only - this platform has no hook/execution mechanism to`,
150
- `enforce it mechanically. Treat these as strong defaults, not guarantees.`,
147
+ `This instruction surface cannot be assumed to provide hard lifecycle blocking.`,
151
148
  ``,
152
- `- Discover the environment (OS, shell, package manager) before running commands - don't assume.`,
149
+ `- Discover the environment and host capabilities before relying on them.`,
153
150
  `- For software/project work, run \`npx github:dyphn1/Harness-everything next "<summary>"\` before mutation and surface the routing checkpoint.`,
154
- `- For EVERY suggested skill, read its complete \`SKILL.md\` entry/basic flow before skipping it. Evaluate \`USE FOR\`, \`DO NOT USE FOR\`, workflow, and hard rules; do not skip from the name/description/router summary alone.`,
155
- `- Suggested-skill execution remains optional after evaluation. Using one suggestion does not waive evaluation of the other omitted suggestions; unreadable suggestions are unresolved/unavailable, not silently skipped.`,
156
- `- Do not impose a universal TODO/TDD/Fable sequence. Choose the smallest applicable skill set after evaluation.`,
157
- `- Before declaring a task done, run \`npx github:dyphn1/Harness-everything verify\` and fix any failures`,
158
- ` it reports - nothing here blocks you from skipping this, so treat it as a real requirement.`,
159
- `- If the same error repeats 3 times in a row, STOP retrying and use a fresh diagnosis / zoom-out.`,
160
- `- Prefer editing over rewriting; commit logically complete chunks rather than one giant diff.`,
151
+ `- Read every suggested skill's complete \`SKILL.md\` entry before resolving applicability; do not omit it from metadata or confidence alone.`,
152
+ `- Execute the selected workflow topology to resolution. The model controls HOW inside the topology, not WHETHER the selected topology exists.`,
153
+ `- Do not impose a universal TODO/TDD/Fable sequence; use the smallest selected topology plus applicable skills.`,
154
+ `- Escape only for genuinely uncovered workflow scope and record reason + scope + evidence.`,
155
+ `- Before declaring done, run \`npx github:dyphn1/Harness-everything verify\` and fix failures.`,
156
+ `- After 3 same-signature failures, stop retrying and use a fresh diagnosis / zoom-out.`,
157
+ `- Prefer targeted edits and logically complete commits.`,
161
158
  ``
162
159
  ].join('\n');
163
160
  }
@@ -173,4 +170,4 @@ module.exports = {
173
170
  removeContinueRule,
174
171
  buildCopilotGlobalContent,
175
172
  buildCodexGlobalContent,
176
- };
173
+ };
@@ -4,46 +4,44 @@ description: Use when starting feature work needing isolation or before implemen
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.4.0
7
+ version: 0.8.1
8
8
  ---
9
9
 
10
10
  # Using Git Worktrees
11
11
 
12
- Use native tools first; git fallback.
12
+ Use native worktree support first; raw Git is the fallback.
13
13
 
14
- ## 📋 Skill Contract
14
+ ## Contract
15
15
 
16
- | Component | Specification |
17
- | :--- | :--- |
18
- | **Trigger / Input** | Isolation-needing feature work; pre-plan setup. |
19
- | **Expected Output** | Isolated workspace plus clean test baseline. |
20
- | **State Mutations** | Creates `.worktrees/<branch>`; updates `.gitignore` if needed. |
21
- | **Enforcement Gate** | Detect existing isolation first; seamless sandbox fallback. |
16
+ - **Major workflow mode** — Tier 3 / Fable-class engineering must be isolated before source/artifact mutation. Reuse an existing linked worktree or create one. If isolation cannot be established, stop `BLOCKED`; never fall back to the primary working tree.
17
+ - **Ordinary mode** — isolation-needing feature work may honor an explicit user preference to stay in place.
18
+ - Never nest a worktree inside an already isolated worktree.
22
19
 
23
20
  ## Workflow
24
21
 
25
- **Step 0 — Detect existing isolation** (adapt per `environment-detection`):
22
+ **Step 0 — Detect isolation** (adapt per `environment-detection`):
26
23
  ```bash
27
24
  git rev-parse --git-dir
28
25
  git rev-parse --git-common-dir
29
26
  git branch --show-current
30
27
  git rev-parse --show-superproject-working-tree
31
28
  ```
32
- Dirs differ and no superproject → already isolated; skip to Step 2; never nest. Superproject → submodule (normal repo). Else honor declared preference or ask consent; declined → in place.
29
+ Different git/common dirs and no superproject => already isolated; continue to Step 2. A submodule is a normal repo for this check.
33
30
 
34
- **Step 1 — Create**: native tool (`EnterWorktree`, `/worktree`, `--worktree`) first — raw git creates phantom state. Else verify ignored via `git check-ignore -q .worktrees || git check-ignore -q worktrees`; unignored → add to .gitignore and commit. Then `git worktree add "$path" -b "$BRANCH_NAME"` at declared preference, existing `.worktrees/`/`worktrees/`, or default `.worktrees/`. Sandbox denial → work in place.
31
+ **Step 1 — Create/enter**: prefer native `EnterWorktree`, `/worktree`, or `--worktree`. Otherwise use `git worktree add "$path" -b "$BRANCH_NAME"`. For major mode, choose an already-ignored or external/sibling path so setup does not require modifying the primary tree first. Creation/entry failure => `BLOCKED`. Only ordinary mode may continue in place after an explicit decline/unsupported environment.
35
32
 
36
- **Step 2 — Setup**: npm/cargo/pip/poetry/go.
33
+ **Step 2 — Setup**: install project dependencies as needed.
37
34
 
38
- **Step 3 — Baseline**: run tests (`npm test`/`cargo test`/`pytest`/`go test ./...`); failures → report, ask.
35
+ **Step 3 — Baseline**: run the relevant tests/build in the isolated tree before implementation; existing failures must be surfaced before mutation proceeds.
39
36
 
40
37
  Deep dive: <this-skill-dir>/references/workflow-details.md
41
38
 
42
39
  ## USE FOR:
40
+ - Tier 3 / Fable-class mutable engineering
43
41
  - feature work needing isolation
44
42
  - pre-implementation-plan setup
45
- - native vs manual `git worktree add`
46
43
 
47
44
  ## DO NOT USE FOR:
48
45
  - nesting inside an existing worktree
49
- - branch/merge workflows
46
+ - read-only analysis with no mutation
47
+ - branch/merge workflows unrelated to workspace isolation
@@ -1,108 +1,67 @@
1
1
  # Using Git Worktrees — Full Workflow Reference
2
2
 
3
- ## Decision Flow
3
+ ## Decide whether isolation is mandatory
4
4
 
5
- ```mermaid
6
- flowchart TD
7
- Start[Trigger: Need Workspace Isolation] --> CheckIso{1. Already in Worktree?}
5
+ Tier 3 / Fable-class engineering requires Git isolation before the first source
6
+ or artifact mutation. Read-only discovery may remain in the bound repository.
7
+ Durable multi-agent workspace state is separate: a staged run may need no
8
+ multi-agent workspace and still require Git isolation.
8
9
 
9
- CheckIso -- Yes (GIT_DIR != GIT_COMMON) --> Setup[3. Run Project Setup & Dependencies]
10
- CheckIso -- No (Normal Repo) --> CheckNative{2. Native Worktree Tool Available?}
10
+ Ordinary feature work may honor an explicit preference to stay in place.
11
+ Mandatory mode has no in-place fallback for a declined helper, unavailable
12
+ native tool, sandbox denial, or creation failure; report `blocked`.
11
13
 
12
- CheckNative -- Yes --> RunNative[Use Native Worktree Tool] --> Setup
13
- CheckNative -- No --> RunGit[Try git worktree add .worktrees/branch]
14
+ ## Detect existing isolation
14
15
 
15
- RunGit -- Success --> Setup
16
- RunGit -- Fails / Denied --> WorkInPlace[Fallback: Work in Place in Current Directory] --> Setup
17
-
18
- Setup --> RunBaseline[4. Verify Clean Test Baseline]
19
- RunBaseline --> Done[Isolated Workspace Ready]
20
- ```
21
-
22
- ## Step 0 detail
23
-
24
- **Submodule guard:** `git-dir` differs from `git-common-dir` inside git submodules as well. Before concluding "already in a worktree," verify you are not in a submodule:
16
+ Inspect absolute Git paths and the registered worktree list:
25
17
 
26
18
  ```bash
27
- # If this returns a path, you're in a submodule, not a worktree — treat as normal repo
19
+ git rev-parse --absolute-git-dir
20
+ git rev-parse --path-format=absolute --git-common-dir
28
21
  git rev-parse --show-superproject-working-tree
22
+ git worktree list --porcelain
29
23
  ```
30
24
 
31
- Report with branch state:
32
- - On a branch: "Already in isolated workspace at `<path>` on branch `<name>`."
33
- - Detached HEAD: "Already in isolated workspace at `<path>` (detached HEAD, externally managed). Branch creation needed at finish time."
34
-
35
- Has the user already indicated their worktree preference in your instructions? If not, ask for consent before creating a worktree:
36
-
37
- > "Would you like me to set up an isolated worktree? It protects your current branch from changes."
38
-
39
- Honor any existing declared preference without asking. If the user declines consent, work in place and skip to project setup.
40
-
41
- ## Step 1a detail — native tools
42
-
43
- The user has asked for an isolated workspace. 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 setup.
44
-
45
- 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.
46
-
47
- Only use the git fallback if you have no native worktree tool available.
48
-
49
- ## Step 1b detail — directory selection priority
50
-
51
- Follow this priority order. Explicit user preference always beats observed filesystem state.
52
-
53
- 1. **Check your instructions for a declared worktree directory preference.** If the user has already specified one, use it without asking.
54
- 2. **Check for an existing project-local worktree directory:** Check if `.worktrees/` or `worktrees/` exists using cross-platform file system tools (`read_file` / `list_dir` or native shell test commands). If found, use it. If both exist, `.worktrees` wins.
55
- 3. **If there is no other guidance available**, default to `.worktrees/` at the project root.
56
-
57
- ### Safety verification (project-local directories only)
58
-
59
- **MUST verify directory is ignored before creating worktree:**
60
-
61
- ```bash
62
- git check-ignore -q .worktrees || git check-ignore -q worktrees
63
- ```
64
-
65
- **If NOT ignored:** Add to .gitignore, commit the change, then proceed.
25
+ Reuse a registered linked checkout of the bound repository; never nest another
26
+ worktree inside it. A submodule or unrelated repository is not sufficient proof.
27
+ Record the resolved directory and branch (or detached HEAD) in the handoff.
66
28
 
67
- **Why critical:** Prevents accidentally committing worktree contents to repository.
29
+ ## Create and enter
68
30
 
69
- ### Create the worktree
31
+ Honor an existing directory preference. Prefer a host-native worktree facility
32
+ when available, then verify that it is backed by a registered Git worktree.
33
+ Otherwise use Git:
70
34
 
71
35
  ```bash
72
- # Determine path based on chosen location
73
- path="$LOCATION/$BRANCH_NAME"
74
-
75
- git worktree add "$path" -b "$BRANCH_NAME"
76
- cd "$path"
36
+ git worktree add "<isolated-path>" -b "<task-branch>"
77
37
  ```
78
38
 
79
- **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.
39
+ For mandatory mode, choose an already-ignored project-local path or an external
40
+ sibling path. Verify the exact project-local candidate with `git check-ignore`.
41
+ Do not edit/commit the primary tree's ignore file just to permit worktree setup.
42
+ If the native facility fails, a permitted Git fallback is valid; if neither can
43
+ establish isolation, stop mutable work as blocked.
80
44
 
81
- ## Step 2 detail — project setup
45
+ Set each subsequent tool's working-directory field to the isolated path and
46
+ keep artifact targets inside it. Entering a worktree does not authorize an
47
+ absolute edit, patch move, or shell target back into the primary checkout.
48
+ Resolve symlinks/junctions when verifying target scope.
82
49
 
83
- Auto-detect and run appropriate setup:
50
+ ## Setup and baseline
84
51
 
85
- ```bash
86
- # Node.js
87
- if [ -f package.json ]; then npm install; fi
88
-
89
- # Rust
90
- if [ -f Cargo.toml ]; then cargo build; fi
52
+ Install the detected dependencies inside the isolated checkout, then run the
53
+ relevant baseline tests/build before implementation. Surface existing failures
54
+ with exact output and distinguish them from regressions introduced by the task.
55
+ Continue fixing task-relevant failures within the user's authorized scope.
91
56
 
92
- # Python
93
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
94
- if [ -f pyproject.toml ]; then poetry install; fi
95
-
96
- # Go
97
- if [ -f go.mod ]; then go mod download; fi
98
- ```
57
+ For active Fable workflows, enter the correlated run through the router's
58
+ displayed controller before dependency installation or artifact mutation. The
59
+ session's `workflow-stages.json` bootstrap file is runtime state; it is not an
60
+ exception for source changes.
99
61
 
100
- ## Step 3 detail — baseline report
62
+ ## Evidence boundary
101
63
 
102
- If tests fail: report failures, ask whether to proceed or investigate. If tests pass:
103
-
104
- ```
105
- Worktree ready at <full-path>
106
- Tests passing (<N> tests, 0 failures)
107
- Ready to implement <feature-name>
108
- ```
64
+ The workflow gate checks registered Git identity, direct/patch target paths,
65
+ known shell side effects, and explicit outside paths. It is not a filesystem
66
+ sandbox for arbitrary script bodies or indirect side effects. Preserve the
67
+ platform capability boundary and report unsupported hook/metadata paths.