harness-everything 0.2.0
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/AGENTS.md +2 -0
- package/BENCHMARK_SOP.md +62 -0
- package/CHANGELOG.md +107 -0
- package/Dockerfile +18 -0
- package/LICENSE +201 -0
- package/README.md +197 -0
- package/VERIFICATION.md +347 -0
- package/bin/cli.js +97 -0
- package/build-multi-agent-system/AGENTS.md +50 -0
- package/build-multi-agent-system/README.md +63 -0
- package/build-multi-agent-system/SKILL.md +68 -0
- package/create-agent-launcher/SKILL.md +48 -0
- package/create-agent-launcher/examples/csharp-monorepo.md +123 -0
- package/create-agent-launcher/examples/typescript-cli.md +126 -0
- package/create-agent-launcher/guidelines/platform-claude.md +77 -0
- package/create-agent-launcher/guidelines/platform-codex.md +146 -0
- package/create-agent-launcher/guidelines/platform-copilot.md +74 -0
- package/create-agent-launcher/guidelines/platform-gemini.md +101 -0
- package/create-agent-launcher/guidelines/role-capabilities.md +108 -0
- package/create-agent-launcher/templates/README.md +17 -0
- package/create-agent-launcher/templates/agent-launcher.md +68 -0
- package/create-agent-launcher/templates/backend-developer-csharp.md +56 -0
- package/create-agent-launcher/templates/backend-developer-polyglot.md +62 -0
- package/create-agent-launcher/templates/backend-developer-ts.md +57 -0
- package/create-agent-launcher/templates/memory-keeper.md +37 -0
- package/create-agent-launcher/templates/requirement-analyzer.md +66 -0
- package/create-agent-launcher/templates/specialist-agent.md +34 -0
- package/create-agent-launcher/templates/task-verifier.md +56 -0
- package/create-agent-launcher/templates/tool-maker.md +33 -0
- package/create-agent-launcher/workflows/01-init.md +22 -0
- package/create-agent-launcher/workflows/02-analysis.md +26 -0
- package/create-agent-launcher/workflows/03-generation.md +29 -0
- package/create-agent-launcher/workflows/04-launcher.md +20 -0
- package/docker-verify.sh +266 -0
- package/docs/architecture.md +95 -0
- package/docs/philosophy.md +45 -0
- package/docs/reflection.md +34 -0
- package/docs/routing.md +45 -0
- package/docs/workflows/build-multi-agent-system.md +62 -0
- package/docs/workflows/create-agent-launcher.md +62 -0
- package/docs/workflows/environment-detection.md +63 -0
- package/docs/workflows/eval-harness.md +57 -0
- package/docs/workflows/fable-discipline.md +59 -0
- package/docs/workflows/fable-mode.md +32 -0
- package/docs/workflows/git-commit.md +62 -0
- package/docs/workflows/grill-me.md +62 -0
- package/docs/workflows/grill-with-docs.md +62 -0
- package/docs/workflows/harness-everything.md +92 -0
- package/docs/workflows/improve-codebase-architecture.md +60 -0
- package/docs/workflows/install-cognitive-os.md +60 -0
- package/docs/workflows/repo-docs.md +59 -0
- package/docs/workflows/rewrite-commits.md +60 -0
- package/docs/workflows/security-review.md +58 -0
- package/docs/workflows/self-evolve.md +59 -0
- package/docs/workflows/skill-creator.md +75 -0
- package/docs/workflows/skill-style.md +64 -0
- package/docs/workflows/tdd.md +39 -0
- package/docs/workflows/todo-driven-workflow.md +36 -0
- package/docs/workflows/using-git-worktrees.md +63 -0
- package/docs/workflows/verification-loop.md +69 -0
- package/docs/workflows/verify-before-claim.md +60 -0
- package/docs/workflows/zoom-out.md +62 -0
- package/environment-detection/SKILL.md +77 -0
- package/environment-detection/scripts/preflight.js +93 -0
- package/eval-framework/behavioral-test.js +105 -0
- package/eval-framework/cases/case1.json +5 -0
- package/eval-framework/cases/case2.json +5 -0
- package/eval-framework/cases/case3.json +5 -0
- package/eval-framework/cases/case4-zh-tier2.json +5 -0
- package/eval-framework/cases/case5-zh-tier3.json +5 -0
- package/eval-framework/mechanism-test.js +251 -0
- package/eval-framework/runner.js +56 -0
- package/eval-harness/SKILL.md +59 -0
- package/eval-harness/scripts/evaluate.js +61 -0
- package/fable-discipline/SKILL.md +38 -0
- package/fable-mode/CONTRACT-FORMAT.md +51 -0
- package/fable-mode/SKILL.md +51 -0
- package/fable-mode/agents/fable-orchestrator.md +92 -0
- package/fable-mode/agents/fable-verifier.md +32 -0
- package/fable-mode/agents/fable-worker-haiku.md +48 -0
- package/fable-mode/agents/fable-worker-sonnet.md +49 -0
- package/fable-mode/execution-guardrails/SKILL.md +87 -0
- package/fable-mode/fable-haiku/SKILL.md +48 -0
- package/git-commit/SKILL.md +55 -0
- package/git-commit/guides/ANGULAR_STYLE.md +61 -0
- package/git-commit/guides/COMMIT_GENERATION.md +24 -0
- package/git-commit/guides/LANGUAGE_DETECTION.md +16 -0
- package/git-commit/guides/MAIN_REPO.md +15 -0
- package/git-commit/guides/SUBMODULES.md +27 -0
- package/grill-me/SKILL.md +36 -0
- package/grill-with-docs/ADR-FORMAT.md +47 -0
- package/grill-with-docs/CONTEXT-FORMAT.md +63 -0
- package/grill-with-docs/SKILL.md +99 -0
- package/harness-everything/SKILL.md +141 -0
- package/harness-everything/examples/README.md +9 -0
- package/harness-everything/examples/todo-workflow.md +22 -0
- package/harness-everything/scripts/bootstrap.js +140 -0
- package/harness-everything/scripts/self-heal.js +189 -0
- package/harness-everything/scripts/tier-router.js +219 -0
- package/harness-everything/scripts/todo-cli.js +157 -0
- package/harness-everything/scripts/verify-gate.js +31 -0
- package/hooks/hooks.json +155 -0
- package/hooks/scripts/atomic-commit-check.js +68 -0
- package/hooks/scripts/boundary-guard.js +55 -0
- package/hooks/scripts/context-compact.js +114 -0
- package/hooks/scripts/contract-test.js +79 -0
- package/hooks/scripts/depth-guard.js +65 -0
- package/hooks/scripts/lib/harness-state.js +202 -0
- package/hooks/scripts/lib/platforms/claude.js +42 -0
- package/hooks/scripts/lib/platforms/codex.js +46 -0
- package/hooks/scripts/lib/platforms/continue.js +41 -0
- package/hooks/scripts/lib/platforms/copilot.js +41 -0
- package/hooks/scripts/lib/platforms/cursor.js +41 -0
- package/hooks/scripts/lib/platforms/hermes.js +32 -0
- package/hooks/scripts/lib/platforms/index.js +17 -0
- package/hooks/scripts/lib/platforms/worktrees.js +20 -0
- package/hooks/scripts/reset-circuit-breaker.js +30 -0
- package/hooks/scripts/rule-of-3-tracker.js +91 -0
- package/hooks/scripts/rule-of-3.js +176 -0
- package/hooks/scripts/state-persist.js +99 -0
- package/hooks/scripts/stop-gate.js +80 -0
- package/hooks/scripts/subagent-scope-guard.js +88 -0
- package/improve-codebase-architecture/SKILL.md +44 -0
- package/improve-codebase-architecture/guides/DEEPENING.md +37 -0
- package/improve-codebase-architecture/guides/HTML-REPORT.md +123 -0
- package/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -0
- package/improve-codebase-architecture/guides/LANGUAGE.md +53 -0
- package/install-cognitive-os/SKILL.md +95 -0
- package/package.json +22 -0
- package/repo-docs/SKILL.md +45 -0
- package/repo-docs/templates/agents-template.md +264 -0
- package/repo-docs/templates/knowledge-agents-template.md +50 -0
- package/repo-docs/templates/knowledge-readme-template.md +83 -0
- package/repo-docs/templates/manual-recon.md +117 -0
- package/repo-docs/templates/multi-skills-readme-template.md +72 -0
- package/repo-docs/templates/product-agents-template.md +78 -0
- package/repo-docs/templates/product-readme-template.md +95 -0
- package/repo-docs/templates/readme-template.md +136 -0
- package/repo-docs/templates/single-skill-readme-template.md +70 -0
- package/repo-docs/templates/skills-agents-template.md +60 -0
- package/rewrite-commits/SKILL.md +32 -0
- package/scripts/installer.js +649 -0
- package/scripts/lib/advisory-text.js +163 -0
- package/scripts/lib/claude-hooks.js +71 -0
- package/scripts/lib/gitignore.js +58 -0
- package/scripts/lib/manifest.js +82 -0
- package/scripts/lib/prompts.js +241 -0
- package/scripts/lib/skills.js +172 -0
- package/scripts/lib/workspace.js +28 -0
- package/security-review/SKILL.md +511 -0
- package/self-evolve/SKILL.md +54 -0
- package/self-evolve/scripts/persist-memory.js +40 -0
- package/self-evolve/scripts/self-regression.js +113 -0
- package/skill-creator/SKILL.md +91 -0
- package/skill-creator/references/quality-principles.md +81 -0
- package/skill-creator/references/testing-workflow.md +32 -0
- package/skill-style/SKILL.md +48 -0
- package/skill-style/STYLE.md +37 -0
- package/tdd/SKILL.md +53 -0
- package/tdd/guides/deep-modules.md +33 -0
- package/tdd/guides/interface-design.md +31 -0
- package/tdd/guides/mocking.md +59 -0
- package/tdd/guides/refactoring.md +10 -0
- package/tdd/guides/tests.md +61 -0
- package/todo-driven-workflow/SKILL.md +54 -0
- package/using-git-worktrees/SKILL.md +161 -0
- package/verification-loop/SKILL.md +138 -0
- package/verify-before-claim/SKILL.md +86 -0
- package/zoom-out/SKILL.md +90 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grill-with-docs
|
|
3
|
+
description: Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 📋 Skill Contract
|
|
9
|
+
|
|
10
|
+
| Component | Specification |
|
|
11
|
+
| :--- | :--- |
|
|
12
|
+
| **Trigger / Input** | User wants to stress-test a plan against the project's existing domain language and documented decisions (`CONTEXT.md`, ADRs). |
|
|
13
|
+
| **Expected Output** | A one-question-at-a-time interview walking the design tree to resolution; `CONTEXT.md` updated inline as terms resolve; new ADRs created only when a decision is hard-to-reverse, surprising, and a genuine trade-off. |
|
|
14
|
+
| **State Mutations** | Creates/edits `CONTEXT.md` and `docs/adr/*.md` (or the per-context equivalents under a `CONTEXT-MAP.md` layout). |
|
|
15
|
+
| **Enforcement Gate** | `CONTEXT.md` **MUST** stay a pure glossary — no implementation details. An ADR **MUST NOT** be offered unless all three criteria (hard to reverse, surprising without context, real trade-off) hold. |
|
|
16
|
+
|
|
17
|
+
<what-to-do>
|
|
18
|
+
|
|
19
|
+
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
|
20
|
+
|
|
21
|
+
Ask the questions one at a time, waiting for feedback on each question before continuing.
|
|
22
|
+
|
|
23
|
+
If a question can be answered by exploring the codebase, explore the codebase instead.
|
|
24
|
+
|
|
25
|
+
</what-to-do>
|
|
26
|
+
|
|
27
|
+
<supporting-info>
|
|
28
|
+
|
|
29
|
+
## Domain awareness
|
|
30
|
+
|
|
31
|
+
During codebase exploration, also look for existing documentation:
|
|
32
|
+
|
|
33
|
+
### File structure
|
|
34
|
+
|
|
35
|
+
Most repos have a single context:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
/
|
|
39
|
+
├── CONTEXT.md
|
|
40
|
+
├── docs/
|
|
41
|
+
│ └── adr/
|
|
42
|
+
│ ├── 0001-event-sourced-orders.md
|
|
43
|
+
│ └── 0002-postgres-for-write-model.md
|
|
44
|
+
└── src/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
/
|
|
51
|
+
├── CONTEXT-MAP.md
|
|
52
|
+
├── docs/
|
|
53
|
+
│ └── adr/ ← system-wide decisions
|
|
54
|
+
├── src/
|
|
55
|
+
│ ├── ordering/
|
|
56
|
+
│ │ ├── CONTEXT.md
|
|
57
|
+
│ │ └── docs/adr/ ← context-specific decisions
|
|
58
|
+
│ └── billing/
|
|
59
|
+
│ ├── CONTEXT.md
|
|
60
|
+
│ └── docs/adr/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
|
|
64
|
+
|
|
65
|
+
## During the session
|
|
66
|
+
|
|
67
|
+
### Challenge against the glossary
|
|
68
|
+
|
|
69
|
+
When the user uses a term that conflicts with the existing language in `CONTEXT.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
|
|
70
|
+
|
|
71
|
+
### Sharpen fuzzy language
|
|
72
|
+
|
|
73
|
+
When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
|
|
74
|
+
|
|
75
|
+
### Discuss concrete scenarios
|
|
76
|
+
|
|
77
|
+
When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
|
|
78
|
+
|
|
79
|
+
### Cross-reference with code
|
|
80
|
+
|
|
81
|
+
When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
|
|
82
|
+
|
|
83
|
+
### Update CONTEXT.md inline
|
|
84
|
+
|
|
85
|
+
When a term is resolved, update `CONTEXT.md` right there. Don't batch these up — capture them as they happen. Use the format in [CONTEXT-FORMAT.md](./CONTEXT-FORMAT.md).
|
|
86
|
+
|
|
87
|
+
`CONTEXT.md` should be totally devoid of implementation details. Do not treat `CONTEXT.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
|
88
|
+
|
|
89
|
+
### Offer ADRs sparingly
|
|
90
|
+
|
|
91
|
+
Only offer to create an ADR when all three are true:
|
|
92
|
+
|
|
93
|
+
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
|
94
|
+
2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
|
|
95
|
+
3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
|
|
96
|
+
|
|
97
|
+
If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
|
|
98
|
+
|
|
99
|
+
</supporting-info>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harness-everything
|
|
3
|
+
description: The single entry point and dynamic router for the Harness ecosystem. Triage tasks into Tier 1, 2, or 3.
|
|
4
|
+
author: Miya Daniel | Harness Core Team
|
|
5
|
+
version: 0.2.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Harness Everything (System Main Entry & Dynamic Router)
|
|
9
|
+
|
|
10
|
+
## 📋 Skill Contract
|
|
11
|
+
|
|
12
|
+
| Component | Specification |
|
|
13
|
+
| :--- | :--- |
|
|
14
|
+
| **Trigger / Input** | Every new user request where no specific skill is already indicated — the mandatory first load, run via `scripts/tier-router.js "<prompt>"`. |
|
|
15
|
+
| **Expected Output** | A Tier determination (1/2/3) and a mandatory "🚦 Harness OS Routing Checkpoint" block at the very start of the response, listing the tier, rationale, and routed skills/guides. |
|
|
16
|
+
| **State Mutations** | None directly — orchestrates which other skills/guides get loaded and, for Tier 2/3, triggers `todo-driven-workflow` checklist initialization. |
|
|
17
|
+
| **Enforcement Gate** | **MUST** run `scripts/tier-router.js` (or reuse the `UserPromptSubmit` hook's output for the same turn) before deciding the tier — the routing checkpoint output is mandatory, not optional. Rule of 3: 3 consecutive failed fix attempts on the same signature **MUST** stop further edits and force `zoom-out`. |
|
|
18
|
+
|
|
19
|
+
This is the single entry point for the entire Harness Skills ecosystem. When you receive a new request from the user and no specific Skill is indicated, you **MUST** prioritize loading this Skill to perform Task Triage.
|
|
20
|
+
|
|
21
|
+
## 1. Core Rule: Global Underlying OS & Base Execution Loop
|
|
22
|
+
Before taking any action, you must awaken and load the principles of `install-cognitive-os`.
|
|
23
|
+
No matter how simple the task is, your behavior must comply with the **Discover > Think > Try > Summarize > Record** cognitive loop.
|
|
24
|
+
Never rush to act before understanding the environment; establish contextual awareness first.
|
|
25
|
+
|
|
26
|
+
**Base Execution Loop (`todo-driven-workflow`)**: The cognitive loop above defines *how you think*; `todo-driven-workflow` defines *how you execute*. For every **Tier 2 and Tier 3** task, you MUST load `todo-driven-workflow` and initialize its checklist BEFORE editing any file — it is the foundational step-by-step execution layer of this harness (break down into 3-7 verifiable sub-tasks, one `in-progress` at a time, verify with real evidence before marking `completed`). Tier 1 tasks are exempt to avoid checklist bloat.
|
|
27
|
+
|
|
28
|
+
**Always-On Disciplines** (apply on every tier, alongside the loops above):
|
|
29
|
+
- `fable-mode/execution-guardrails` — verify-before-flag, warning batching, find-and-replace safety. These are behavioral contracts, not Tier-3-only rules.
|
|
30
|
+
- `verify-before-claim` — never assert external framework/API behavior or unmeasured performance numbers from training memory; verify against an authoritative source first.
|
|
31
|
+
- `install-cognitive-os`'s Global Output Normalization — lead with direct answers, suppress preambles/recaps/pleasantries, and enforce natural locale terminology (§6).
|
|
32
|
+
|
|
33
|
+
**Self-Healing Toolchain (工欲善其事,必先利其器)**: The harness may have been installed from a different editor than the one currently running (e.g., installed via Claude Code, now opened in Copilot). During the `[Discover]` phase, audit the workspace's integration touchpoints and repair any that are missing — the script is idempotent and delegates to the installer, so re-running is always safe:
|
|
34
|
+
```bash
|
|
35
|
+
node "<this-skill-dir>/scripts/self-heal.js" # audit + auto-repair missing touchpoints
|
|
36
|
+
node "<this-skill-dir>/scripts/self-heal.js" --check # audit only, never writes
|
|
37
|
+
```
|
|
38
|
+
Also run this immediately whenever the `bootstrap.js` SessionStart output shows a `[Self-Heal] Missing integration touchpoints` warning. Exception: if the user says they intentionally removed one of these files, respect that and do not re-create it.
|
|
39
|
+
|
|
40
|
+
## 2. Task Triage
|
|
41
|
+
To avoid "over-engineering" and maximize efficiency, you must categorize the user's task during the `[Think]` phase and take the corresponding action path.
|
|
42
|
+
- **MANDATORY**: Run the Tier Router script before deciding the tier. The script lives at `scripts/tier-router.js` **inside this skill's own directory** — resolve the path from wherever this SKILL.md was loaded (do not guess a hard-coded location):
|
|
43
|
+
```bash
|
|
44
|
+
node "<this-skill-dir>/scripts/tier-router.js" "<Brief summary of the user's prompt>"
|
|
45
|
+
```
|
|
46
|
+
- You MUST follow the `REQUIRED TIER` output by the script.
|
|
47
|
+
- If a `UserPromptSubmit` hook already ran the router this turn (its `[Tier Routing Pre-check]` output is visible in context), reuse that output instead of running it again.
|
|
48
|
+
|
|
49
|
+
### Mandated Routing Checkpoint Output
|
|
50
|
+
At the very beginning of your response to the user, you **MUST** output a clear, stylized routing report. This report is mandatory for all entries via `harness-everything`. It must list the determined Tier and the exact routing targets:
|
|
51
|
+
```markdown
|
|
52
|
+
## 🚦 Harness OS Routing Checkpoint
|
|
53
|
+
- **Active Tier**: Tier X (Tier Name)
|
|
54
|
+
- **Rationale**: Short 1-sentence reason from the tier router.
|
|
55
|
+
- **Routed Skills, Guides & Actions**:
|
|
56
|
+
- `path/to/skill/or/guide.md` (Brief description of why this applies)
|
|
57
|
+
- ...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Proactive Copilot & VS Code Instruction (Avoid Silent Degrades)
|
|
61
|
+
If you are running in VS Code or GitHub Copilot, you do not have automated hooks to run scripts on your behalf.
|
|
62
|
+
- You **MUST** proactively run the tier-router script (`node harness-everything/scripts/tier-router.js "<prompt>"`) or simulate its routing logic manually at the start.
|
|
63
|
+
- **NEVER degrade newly added features or structural extensions to Tier 1.** Copilot is highly prone to treating new feature requests as trivial Tier 1 direct edits. If the request adds *any* new logic, a new API endpoint, or a new file/module, it **MUST** be triaged as **Tier 2 (Standard Task)** or **Tier 3 (Macro Task)**. This activates:
|
|
64
|
+
1. The `todo-driven-workflow` checklist (mandatory step-by-step progress tracking).
|
|
65
|
+
2. Multi-agent spawning / sub-agents via `create-agent-launcher` or macro plan orchestration via `fable-mode`.
|
|
66
|
+
3. The memory summarization & evolution sequence via `self-evolve` upon completion, ensuring new knowledge is registered in workspace memory.
|
|
67
|
+
|
|
68
|
+
### Tier 1: Trivial Tasks & Daily Chores
|
|
69
|
+
- **Characteristics**: Fixing typos, simple modifications to a single function, asking/explaining code, syntax adjustments. Or simple `git-commit` and `rewrite-commits`.
|
|
70
|
+
- **Action Strategy (Direct Execution)**:
|
|
71
|
+
- **PROHIBITED** from writing large plans.
|
|
72
|
+
- **PROHIBITED** from calling `create-agent-launcher` or `fable-mode`.
|
|
73
|
+
- Execute the modification directly based on requirements, or load `git-commit` / `rewrite-commits`. Perform a simple `[Record]` after modifying.
|
|
74
|
+
|
|
75
|
+
### Tier 2: Standard Tasks & Architectural Review
|
|
76
|
+
- **Characteristics**: Adding a single API endpoint, fixing a specific bug, modifications requiring coordination across 2-3 files. Or requiring stress testing and benchmark evaluation for specific designs.
|
|
77
|
+
- **Action Strategy (TDD, Deep Context & Domain Expertise)**:
|
|
78
|
+
- **Initialize the Base Execution Loop**: Load `todo-driven-workflow` and lay out the checklist first (the TDD Red/Green/Refactor phases map naturally onto todo items).
|
|
79
|
+
- **Information Depth Requirement**: Before entering TDD, you MUST perform a deep context trace (find references, call sites, and related interfaces). Superficial fixes that break dependencies are strictly forbidden.
|
|
80
|
+
- **Load Domain Experts (領域專家召喚)**: Based on the tech stack detected in Tier 1, explicitly search for and load the corresponding **Domain Skills** (e.g., `security-review` from this repo, or `frontend-patterns` / `api-design` from the user's legacy skill library) to inject robust expert knowledge into your context.
|
|
81
|
+
- Development tasks: Automatically load and follow the `tdd` (Test-Driven Development) skill. Write tests first (Red) -> Implement (Green) -> Refactor.
|
|
82
|
+
- Before starting feature work on a busy repository, consider loading `using-git-worktrees` to isolate your workspace and prevent workspace pollution.
|
|
83
|
+
- If the user requests grilling or refactoring a plan, load `grill-me` (pure Q&A) or `improve-codebase-architecture` (deep architectural analysis).
|
|
84
|
+
- If the user requests "scoring" or "benchmark comparison", load `eval-harness` for quantitative scoring and summarization.
|
|
85
|
+
- **Pre-Delivery Gate**: Before declaring the task done or creating a PR, load `verification-loop` (build / types / lint / tests / security scan / diff review). For changes touching auth, input handling, secrets, or network boundaries, additionally load `security-review`.
|
|
86
|
+
|
|
87
|
+
### Tier 3: Macro Tasks & Documentation
|
|
88
|
+
- **Characteristics**: New project initialization, low-level architecture refactoring, vague and massive requirements (e.g., "Help me write a user login system"). Or lack of global documentation.
|
|
89
|
+
- **Action Strategy (Multi-Agent Orchestration & Domain Infusion)**:
|
|
90
|
+
- If initializing a multi-agent system workspace, load `build-multi-agent-system` to scaffold the 6 functional zones, memory relational indexes, and immutable routing laws.
|
|
91
|
+
- If project-level documentation needs to be created, load `repo-docs`.
|
|
92
|
+
- If establishing a large system design, strongly recommend loading `grill-with-docs` first to document decisions (ADR, CONTEXT) before proceeding.
|
|
93
|
+
- **Sub-Agent Specialization**: When calling `create-agent-launcher`, you MUST inject robust Domain Skills into the sub-agent's persona (e.g., passing `database-reviewer` and `backend-patterns` to a Backend Sub-Agent). Do not create generic, empty-shell agents.
|
|
94
|
+
- Development execution: Automatically load `fable-mode` and `fable-discipline`. The macro plan produced in fable-mode's Discovery phase MUST be materialized as the `todo-driven-workflow` checklist — sub-agent handoffs and milestone checks are tracked there, not in prose.
|
|
95
|
+
- **Pre-Delivery Gate**: Same as Tier 2 — run `verification-loop` (and `security-review` where applicable) before the final handoff.
|
|
96
|
+
|
|
97
|
+
## 3. Foolproofing & Circuit Breaker Mechanism
|
|
98
|
+
LLMs have a Reasoning Ceiling. To avoid invalid infinite retries, you must strictly obey the following limits:
|
|
99
|
+
- **Rule of 3**: If attempting to fix the same Bug or test failure fails 3 times consecutively, **STOP modifying code immediately**.
|
|
100
|
+
- **Trigger Circuit Breaker**: Forcefully call the `zoom-out` skill — rebuild the full picture, fact-check the assumption behind each failed attempt with read-only tools, and write the reflection report. Most trips should end in **self-recovery on a fresh diagnosis**, not a cry for help.
|
|
101
|
+
- **Seek Human Help — only for genuine decisions**: Escalate when zoom-out concludes the blocker is a human call (requirement conflict, architecture trade-off, destructive action, missing access), or when the breaker hard-locks on a second trip of the same signature. Present verified facts and 2-3 options with a recommendation — never a bare "I'm stuck".
|
|
102
|
+
|
|
103
|
+
## 4. Evolution Loop
|
|
104
|
+
- When the circuit breaker is triggered and the problem is ultimately solved — whether by post-reflection self-recovery or with human intervention.
|
|
105
|
+
- Or, when you have expended great effort to overcome difficulties and complete a complex task.
|
|
106
|
+
- You **MUST** automatically call the `self-evolve` skill to write "human key insights" or "successfully avoided traps" into system memory, ensuring the same blind spots are bypassed next time.
|
|
107
|
+
|
|
108
|
+
## 6. Always-On ADHD-Friendly Output Shaping
|
|
109
|
+
This is the same always-on discipline `install-cognitive-os` defines under its own §"Global Output Normalization" — this router doesn't restate it (that duplication was flagged in a skill quality audit §1.1 and has been removed). Since §1 already sends every task through `install-cognitive-os` before any action, its output-shaping rules are already in effect by the time this router does anything — apply them as written there, on every response, regardless of tier.
|
|
110
|
+
|
|
111
|
+
## 5. Skill Registry (Full Activation Map)
|
|
112
|
+
Every skill in this repository is reachable from this router. If a task matches a trigger below and the skill is not yet loaded, load it.
|
|
113
|
+
|
|
114
|
+
| Skill | Layer | Activated when |
|
|
115
|
+
| :--- | :--- | :--- |
|
|
116
|
+
| `install-cognitive-os` | Foundation | Always, before any action (§1). |
|
|
117
|
+
| `todo-driven-workflow` | Foundation | Every Tier 2/3 task — the base execution loop (§1). |
|
|
118
|
+
| `environment-detection` | Foundation | Session start / `[Discover]` phase, before running shell commands. |
|
|
119
|
+
| `fable-mode/execution-guardrails` | Always-on discipline | Every tier: flagging problems, batching warnings, find-and-replace edits (§1). |
|
|
120
|
+
| `verify-before-claim` | Always-on discipline | Before asserting external-system behavior or unmeasured numbers (§1). |
|
|
121
|
+
| `git-commit` / `rewrite-commits` | Tier 1 | Commit creation / history rewriting. |
|
|
122
|
+
| `tdd` | Tier 2 | Feature/bugfix development (Red-Green-Refactor). |
|
|
123
|
+
| `using-git-worktrees` | Tier 2 | Isolating feature work on a busy repository. |
|
|
124
|
+
| `grill-me` | Tier 2 | User asks to be grilled on a plan (pure Q&A). |
|
|
125
|
+
| `improve-codebase-architecture` | Tier 2 | Deep architectural analysis / refactor planning. |
|
|
126
|
+
| `eval-harness` | Tier 2 | Scoring, stress testing, benchmark comparison. |
|
|
127
|
+
| `verification-loop` | Tier 2/3 gate | Before declaring done or creating a PR. |
|
|
128
|
+
| `security-review` | Tier 2/3 gate | Changes touching auth, input handling, secrets, network boundaries. |
|
|
129
|
+
| `fable-mode` | Tier 3 | Macro task planning & execution engine. |
|
|
130
|
+
| `fable-discipline` | Tier 3 | Risk control paired with fable-mode. |
|
|
131
|
+
| `fable-mode/fable-haiku` | Tier 3 (opt-in) | User explicitly asks for staged execution run cheaply on Haiku. |
|
|
132
|
+
| `create-agent-launcher` | Tier 3 | Spawning specialized sub-agents. |
|
|
133
|
+
| `build-multi-agent-system` | Tier 3 | Scaffolding a multi-agent workspace. |
|
|
134
|
+
| `repo-docs` | Tier 3 | Creating project-level documentation. |
|
|
135
|
+
| `grill-with-docs` | Tier 3 | Documenting decisions (ADR / CONTEXT) before large designs. |
|
|
136
|
+
| `zoom-out` | Circuit breaker | Rule of 3 trips (§3). |
|
|
137
|
+
| `self-evolve` | Evolution | Post-breaker resolution or major breakthrough (§4). |
|
|
138
|
+
| `skill-style` | Meta | Authoring or modifying any SKILL.md in this repository — the terse Skill Contract format spec. |
|
|
139
|
+
| `skill-creator` | Meta | Creating a new skill from scratch, auditing/refactoring an existing SKILL.md, or `self-evolve`'s dynamic skill generation step (§4) — the fuller authoring, quality-checklist, and testing workflow built on `skill-style`. |
|
|
140
|
+
|
|
141
|
+
(`eval-framework/` is internal CI for the router itself — run `node eval-framework/runner.js` after modifying `tier-router.js`; it is not a routable skill. Likewise `scripts/self-heal.js` in this skill is infrastructure, invoked during `[Discover]` per §1.)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Harness Examples
|
|
2
|
+
This directory contains concrete examples of how to use Harness tools and workflows.
|
|
3
|
+
|
|
4
|
+
## tier-router.js Quick Start
|
|
5
|
+
If you are unsure how to use the tier router, you can call it directly:
|
|
6
|
+
`node harness-everything/scripts/tier-router.js "YOUR PROMPT HERE"`
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
`node harness-everything/scripts/tier-router.js "Add a login page"`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Todo-Driven Workflow Example
|
|
2
|
+
Here is a concrete example of how to implement the Todo-Driven Workflow using VS Code's `manage_todo_list` tool.
|
|
3
|
+
|
|
4
|
+
## The Goal: Add a User Authentication Endpoint
|
|
5
|
+
|
|
6
|
+
1. **Initialize the List**: Before writing code, call `manage_todo_list` with these items:
|
|
7
|
+
- ID: 1, Title: "Write auth tests", Status: "not-started"
|
|
8
|
+
- ID: 2, Title: "Implement /login API", Status: "not-started"
|
|
9
|
+
- ID: 3, Title: "Verify DB connection", Status: "not-started"
|
|
10
|
+
|
|
11
|
+
2. **Start Task 1**: Call `manage_todo_list` to set ID 1 to "in-progress".
|
|
12
|
+
|
|
13
|
+
3. **Execute**: Create `tests/auth.test.js` and write the tests.
|
|
14
|
+
|
|
15
|
+
4. **Verify**: Run the tests using `run_in_terminal` (`npm test`). They should fail (Red).
|
|
16
|
+
|
|
17
|
+
5. **Complete Task 1**: Call `manage_todo_list` to set ID 1 to "completed".
|
|
18
|
+
|
|
19
|
+
6. **Start Task 2**: Call `manage_todo_list` to set ID 2 to "in-progress".
|
|
20
|
+
...and so on.
|
|
21
|
+
|
|
22
|
+
**CRITICAL**: Do NOT just type out a checklist in markdown. You MUST call the `manage_todo_list` tool.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const {
|
|
5
|
+
getWorkspaceRoot,
|
|
6
|
+
getSessionDir,
|
|
7
|
+
writeCurrentSession,
|
|
8
|
+
pruneStaleSessions,
|
|
9
|
+
} = require('../../hooks/scripts/lib/harness-state');
|
|
10
|
+
|
|
11
|
+
console.log("Bootstrapping Harness Skills OS...");
|
|
12
|
+
|
|
13
|
+
// SessionStart hooks receive a payload with session_id via stdin, same as
|
|
14
|
+
// every other hook. Read it synchronously up front - bootstrap has no
|
|
15
|
+
// tool-call latency to protect, so there's no fast-path tradeoff here - but
|
|
16
|
+
// skip entirely on an interactive TTY (manual run) where reading fd 0 would
|
|
17
|
+
// just hang waiting for input that's never coming.
|
|
18
|
+
let payload = null;
|
|
19
|
+
if (!process.stdin.isTTY) {
|
|
20
|
+
try {
|
|
21
|
+
const raw = fs.readFileSync(0, 'utf8');
|
|
22
|
+
payload = JSON.parse(raw);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
// No payload piped in, or invalid JSON - fall back to 'default'.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const sessionId = payload && payload.session_id;
|
|
28
|
+
|
|
29
|
+
const root = getWorkspaceRoot();
|
|
30
|
+
|
|
31
|
+
// Nothing purges old session directories the way an OS temp dir would -
|
|
32
|
+
// drop ones untouched for a while so .claude/harness-state/sessions/ doesn't
|
|
33
|
+
// grow forever.
|
|
34
|
+
pruneStaleSessions(root);
|
|
35
|
+
|
|
36
|
+
// The manual escape hatch (reset-circuit-breaker.js) and any CLI tool that
|
|
37
|
+
// can't see a session_id (todo-cli.js) resolve "current session" through
|
|
38
|
+
// this pointer.
|
|
39
|
+
writeCurrentSession(root, sessionId);
|
|
40
|
+
|
|
41
|
+
const harnessDir = getSessionDir(root, sessionId);
|
|
42
|
+
|
|
43
|
+
// The Rule of 3 circuit breaker (hooks/scripts/rule-of-3.js) locks all
|
|
44
|
+
// Bash/Edit/Write calls once tripped; the only in-session exits are a valid
|
|
45
|
+
// zoom-out reflection report or a human reset. A new SessionStart means the
|
|
46
|
+
// human has taken over (new session, /clear, /compact) and reviewed the
|
|
47
|
+
// situation, so it's safe to clear here. The stale reflection report goes
|
|
48
|
+
// with it - it belongs to the previous loop, not this session.
|
|
49
|
+
const circuitBreakerFile = path.join(harnessDir, 'rule-of-3-state.json');
|
|
50
|
+
if (fs.existsSync(circuitBreakerFile)) {
|
|
51
|
+
try {
|
|
52
|
+
fs.unlinkSync(circuitBreakerFile);
|
|
53
|
+
console.log("Rule of 3 circuit breaker state cleared for new session.");
|
|
54
|
+
} catch (err) {
|
|
55
|
+
// Ignore; worst case the breaker stays tripped until manually reset.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const zoomOutReportFile = path.join(harnessDir, 'zoom-out-report.md');
|
|
59
|
+
if (fs.existsSync(zoomOutReportFile)) {
|
|
60
|
+
try {
|
|
61
|
+
fs.unlinkSync(zoomOutReportFile);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
// Ignore; rule-of-3.js already rejects reports older than the last failure.
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Same reasoning: a stale subagent-scope baseline from a previous session
|
|
68
|
+
// would make the first Task burst of this session diff against the wrong
|
|
69
|
+
// starting point.
|
|
70
|
+
const subagentScopeFile = path.join(harnessDir, 'subagent-scope-state.json');
|
|
71
|
+
if (fs.existsSync(subagentScopeFile)) {
|
|
72
|
+
try {
|
|
73
|
+
fs.unlinkSync(subagentScopeFile);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
// Ignore.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Self-heal audit: report missing platform integration touchpoints so the
|
|
80
|
+
// model (per harness-everything SKILL.md) repairs them via self-heal.js.
|
|
81
|
+
// Audit-and-report only - bootstrap never writes these files itself, so a
|
|
82
|
+
// user who intentionally removed one isn't fought every session start.
|
|
83
|
+
try {
|
|
84
|
+
const MARKER = 'Harness OS Guidance (Advisory)';
|
|
85
|
+
const HOOK_ID = 'harness:pre:bootstrap';
|
|
86
|
+
const workspaceRoot = getWorkspaceRoot();
|
|
87
|
+
const contains = (p, needle) => {
|
|
88
|
+
try { return fs.readFileSync(p, 'utf8').includes(needle); } catch (e) { return false; }
|
|
89
|
+
};
|
|
90
|
+
const missing = [
|
|
91
|
+
['.claude/settings.json (Claude Code hooks)', contains(path.join(workspaceRoot, '.claude', 'settings.json'), HOOK_ID)],
|
|
92
|
+
['.cursorrules (Cursor)', contains(path.join(workspaceRoot, '.cursorrules'), MARKER)],
|
|
93
|
+
['.github/copilot-instructions.md (Copilot)', contains(path.join(workspaceRoot, '.github', 'copilot-instructions.md'), MARKER)],
|
|
94
|
+
['AGENTS.md (Codex)', contains(path.join(workspaceRoot, 'AGENTS.md'), MARKER)]
|
|
95
|
+
].filter(([, ok]) => !ok).map(([label]) => label);
|
|
96
|
+
if (missing.length > 0 && path.resolve(workspaceRoot) !== path.resolve(__dirname, '..', '..')) {
|
|
97
|
+
console.log(`\n[Self-Heal] Missing integration touchpoints: ${missing.join(', ')}`);
|
|
98
|
+
console.log(`[Self-Heal] Repair (idempotent): node "${path.join(__dirname, 'self-heal.js')}"`);
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
// Audit is best-effort; never block session start.
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check for handoff/state checkpoint from previous session
|
|
105
|
+
const handoffFile = path.join(harnessDir, 'handoff-state.json');
|
|
106
|
+
if (fs.existsSync(handoffFile)) {
|
|
107
|
+
try {
|
|
108
|
+
const handoff = JSON.parse(fs.readFileSync(handoffFile, 'utf8'));
|
|
109
|
+
if (handoff.status === 'failed') {
|
|
110
|
+
const exitStr = handoff.exitCode ? ` (exit code ${handoff.exitCode})` : '';
|
|
111
|
+
const border = "─".repeat(60);
|
|
112
|
+
console.log(`\n┌${border}┐`);
|
|
113
|
+
console.log(`│ Harness OS - Handoff Checkpoint │`);
|
|
114
|
+
console.log(`├${border}┤`);
|
|
115
|
+
console.log(`│ - Last active action failed${exitStr.padEnd(30)} │`);
|
|
116
|
+
console.log(`│ - Action: ${String(handoff.tool || 'unknown').padEnd(46)} │`);
|
|
117
|
+
console.log(`│ - Last error output snippet: │`);
|
|
118
|
+
|
|
119
|
+
const snippet = handoff.errorSummary || 'No snippet available';
|
|
120
|
+
const lines = snippet.split('\n').map(l => l.trim()).filter(Boolean).slice(-3);
|
|
121
|
+
if (lines.length > 0) {
|
|
122
|
+
lines.forEach(line => {
|
|
123
|
+
const paddedLine = line.slice(0, 54).padEnd(54);
|
|
124
|
+
console.log(`│ > ${paddedLine} │`);
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
console.log(`│ > None │`);
|
|
128
|
+
}
|
|
129
|
+
console.log(`├${border}┤`);
|
|
130
|
+
console.log(`│ Hint: Use this context to continue resolving the issue │`);
|
|
131
|
+
console.log(`│ efficiently or start on a new path. │`);
|
|
132
|
+
console.log(`└${border}┘\n`);
|
|
133
|
+
}
|
|
134
|
+
} catch (err) {
|
|
135
|
+
// Ignore malformed files
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
console.log("Harness OS initialized. Ready for user prompt.");
|
|
140
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Self-healing installation audit for Harness OS.
|
|
4
|
+
*
|
|
5
|
+
* Audits the six platform integration touchpoints in the current workspace
|
|
6
|
+
* and, when any are missing, re-runs the idempotent installer to repair them.
|
|
7
|
+
* This makes the harness portable across editors: install once via Claude
|
|
8
|
+
* Code, then open the same repo in Copilot/Cursor/Codex/Continue/Hermes and
|
|
9
|
+
* the missing advisory instructions are backfilled automatically the first time
|
|
10
|
+
* harness-everything (or the environment-detection Discover phase) runs.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node self-heal.js Audit and repair anything missing.
|
|
14
|
+
* node self-heal.js --check Audit only; report, never write.
|
|
15
|
+
* node self-heal.js --force-self Allow repairing harness-everything repo
|
|
16
|
+
* itself (skipped by default to avoid
|
|
17
|
+
* polluting this repo with generated files).
|
|
18
|
+
*
|
|
19
|
+
* Repair strategy: delegate to scripts/installer.js rather than duplicating
|
|
20
|
+
* its logic - the installer merges hooks by id and appends advisory text only
|
|
21
|
+
* when its marker is absent, so re-running it is always safe.
|
|
22
|
+
*/
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
const { execSync } = require('child_process');
|
|
26
|
+
|
|
27
|
+
const MARKER = 'Harness OS Guidance (Advisory)';
|
|
28
|
+
const HOOK_ID = 'harness:pre:bootstrap';
|
|
29
|
+
|
|
30
|
+
function getWorkspaceRoot() {
|
|
31
|
+
let dir = path.resolve(process.cwd());
|
|
32
|
+
while (dir !== path.parse(dir).root) {
|
|
33
|
+
if (fs.existsSync(path.join(dir, '.git'))) return dir;
|
|
34
|
+
dir = path.dirname(dir);
|
|
35
|
+
}
|
|
36
|
+
return process.cwd();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fileContains(filePath, needle) {
|
|
40
|
+
try {
|
|
41
|
+
return fs.readFileSync(filePath, 'utf8').includes(needle);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Presence of the hook id alone is not enough: the skills repo may have been
|
|
48
|
+
// MOVED since install (it already happened once - harness-everything to
|
|
49
|
+
// miya.daniel/skills), leaving settings.json full of absolute paths to dead
|
|
50
|
+
// scripts while still "containing" the id. Verify every harness hook command
|
|
51
|
+
// points at a script that actually exists on disk.
|
|
52
|
+
function auditClaudeHooks(workspaceRoot) {
|
|
53
|
+
const settingsPath = path.join(workspaceRoot, '.claude', 'settings.json');
|
|
54
|
+
let settings;
|
|
55
|
+
try {
|
|
56
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
57
|
+
} catch (err) {
|
|
58
|
+
return { ok: false, detail: 'not installed' };
|
|
59
|
+
}
|
|
60
|
+
const commands = [];
|
|
61
|
+
for (const list of Object.values(settings.hooks || {})) {
|
|
62
|
+
for (const item of list) {
|
|
63
|
+
if (typeof item.id === 'string' && item.id.startsWith('harness:')) {
|
|
64
|
+
(item.hooks || []).forEach(h => {
|
|
65
|
+
if (h.type === 'command' && h.command) commands.push(h.command);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (commands.length === 0) return { ok: false, detail: 'not installed' };
|
|
71
|
+
for (const cmd of commands) {
|
|
72
|
+
// Our hook commands are exactly `node <script>` with no extra args, in
|
|
73
|
+
// one of three historical quoting styles; stripping the prefix and all
|
|
74
|
+
// quotes yields the script path in every one of them.
|
|
75
|
+
const scriptPath = cmd.replace(/^node\s+/, '').replace(/"/g, '').trim();
|
|
76
|
+
if (!fs.existsSync(scriptPath)) {
|
|
77
|
+
return { ok: false, detail: `stale script path: ${scriptPath}` };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { ok: true };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function auditWorkspace(workspaceRoot) {
|
|
84
|
+
const isClaudeCode = process.env.CLAUDE_CODE === 'true' || process.env.SHELL?.includes('claude-code') || false;
|
|
85
|
+
const isVSCodeCopilot = process.env.VSCODE_PID !== undefined || process.env.TERM_PROGRAM === 'vscode' || process.env.GITHUB_COPILOT_CHAT === 'true' || true; // Fallback default
|
|
86
|
+
|
|
87
|
+
const checks = [];
|
|
88
|
+
|
|
89
|
+
// 根據當前執行環境動態決定審查項目
|
|
90
|
+
if (isClaudeCode) {
|
|
91
|
+
const claudeHooks = auditClaudeHooks(workspaceRoot);
|
|
92
|
+
checks.push({
|
|
93
|
+
label: 'Claude Code hooks (.claude/settings.json)' + (claudeHooks.detail ? ` - ${claudeHooks.detail}` : ''),
|
|
94
|
+
ok: claudeHooks.ok,
|
|
95
|
+
platform: 'claude'
|
|
96
|
+
});
|
|
97
|
+
} else {
|
|
98
|
+
// 處於 VS Code / Copilot 或其他編輯器
|
|
99
|
+
checks.push({
|
|
100
|
+
label: 'Cursor rules (.cursorrules)',
|
|
101
|
+
ok: fileContains(path.join(workspaceRoot, '.cursorrules'), MARKER),
|
|
102
|
+
platform: 'cursor'
|
|
103
|
+
});
|
|
104
|
+
checks.push({
|
|
105
|
+
label: 'Copilot instructions (.github/copilot-instructions.md)',
|
|
106
|
+
ok: fileContains(path.join(workspaceRoot, '.github', 'copilot-instructions.md'), MARKER),
|
|
107
|
+
platform: 'copilot'
|
|
108
|
+
});
|
|
109
|
+
checks.push({
|
|
110
|
+
label: 'Codex instructions (AGENTS.md)',
|
|
111
|
+
ok: fileContains(path.join(workspaceRoot, 'AGENTS.md'), MARKER),
|
|
112
|
+
platform: 'codex'
|
|
113
|
+
});
|
|
114
|
+
checks.push({
|
|
115
|
+
label: 'Continue.dev rules (.continue/rules/harness.md)',
|
|
116
|
+
ok: fileContains(path.join(workspaceRoot, '.continue', 'rules', 'harness.md'), MARKER),
|
|
117
|
+
platform: 'continue'
|
|
118
|
+
});
|
|
119
|
+
checks.push({
|
|
120
|
+
label: 'Hermes Agent instructions (.hermes.md)',
|
|
121
|
+
ok: fileContains(path.join(workspaceRoot, '.hermes.md'), MARKER),
|
|
122
|
+
platform: 'hermes'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return checks;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function printAudit(checks) {
|
|
130
|
+
console.log('[Harness Self-Heal Audit]');
|
|
131
|
+
checks.forEach(c => {
|
|
132
|
+
console.log(` ${c.ok ? 'OK ' : 'MISSING'} ${c.label}`);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function main() {
|
|
137
|
+
const checkOnly = process.argv.includes('--check');
|
|
138
|
+
const forceSelf = process.argv.includes('--force-self');
|
|
139
|
+
|
|
140
|
+
const workspaceRoot = getWorkspaceRoot();
|
|
141
|
+
const harnessSourceDir = path.resolve(__dirname, '..', '..');
|
|
142
|
+
const installerPath = path.join(harnessSourceDir, 'scripts', 'installer.js');
|
|
143
|
+
|
|
144
|
+
console.log(`Workspace: ${workspaceRoot}`);
|
|
145
|
+
const checks = auditWorkspace(workspaceRoot);
|
|
146
|
+
printAudit(checks);
|
|
147
|
+
|
|
148
|
+
const missing = checks.filter(c => !c.ok);
|
|
149
|
+
if (missing.length === 0) {
|
|
150
|
+
console.log('\nAll active integration touchpoints present. Nothing to repair.');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (checkOnly) {
|
|
155
|
+
console.log(`\n${missing.length} active touchpoint(s) missing. Run without --check to repair:`);
|
|
156
|
+
console.log(` node "${path.join(__dirname, 'self-heal.js')}"`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const isSelf = path.resolve(workspaceRoot) === path.resolve(harnessSourceDir);
|
|
161
|
+
if (isSelf && !forceSelf) {
|
|
162
|
+
console.log('\nWorkspace IS the harness-everything repo itself - skipping repair to avoid');
|
|
163
|
+
console.log('polluting it with generated config files. Pass --force-self to override.');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!fs.existsSync(installerPath)) {
|
|
168
|
+
console.error(`\nCannot repair: installer not found at ${installerPath}`);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
console.log(`\nRepairing ${missing.length} missing active touchpoint(s) via installer...\n`);
|
|
173
|
+
|
|
174
|
+
// 構造參數只針對當前環境缺少的平台調用安裝器
|
|
175
|
+
const activeFlags = missing.map(c => `--${c.platform}`).join(' ');
|
|
176
|
+
execSync(`node "${installerPath}" ${activeFlags} --yes`, { cwd: workspaceRoot, stdio: 'inherit' });
|
|
177
|
+
|
|
178
|
+
const after = auditWorkspace(workspaceRoot);
|
|
179
|
+
console.log('');
|
|
180
|
+
printAudit(after);
|
|
181
|
+
const stillMissing = after.filter(c => !c.ok);
|
|
182
|
+
if (stillMissing.length > 0) {
|
|
183
|
+
console.error(`\nSelf-heal incomplete: ${stillMissing.length} touchpoint(s) still missing.`);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
console.log('\nSelf-heal complete. Active platforms are now covered.');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
main();
|