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.
Files changed (169) hide show
  1. package/AGENTS.md +2 -0
  2. package/BENCHMARK_SOP.md +62 -0
  3. package/CHANGELOG.md +107 -0
  4. package/Dockerfile +18 -0
  5. package/LICENSE +201 -0
  6. package/README.md +197 -0
  7. package/VERIFICATION.md +347 -0
  8. package/bin/cli.js +97 -0
  9. package/build-multi-agent-system/AGENTS.md +50 -0
  10. package/build-multi-agent-system/README.md +63 -0
  11. package/build-multi-agent-system/SKILL.md +68 -0
  12. package/create-agent-launcher/SKILL.md +48 -0
  13. package/create-agent-launcher/examples/csharp-monorepo.md +123 -0
  14. package/create-agent-launcher/examples/typescript-cli.md +126 -0
  15. package/create-agent-launcher/guidelines/platform-claude.md +77 -0
  16. package/create-agent-launcher/guidelines/platform-codex.md +146 -0
  17. package/create-agent-launcher/guidelines/platform-copilot.md +74 -0
  18. package/create-agent-launcher/guidelines/platform-gemini.md +101 -0
  19. package/create-agent-launcher/guidelines/role-capabilities.md +108 -0
  20. package/create-agent-launcher/templates/README.md +17 -0
  21. package/create-agent-launcher/templates/agent-launcher.md +68 -0
  22. package/create-agent-launcher/templates/backend-developer-csharp.md +56 -0
  23. package/create-agent-launcher/templates/backend-developer-polyglot.md +62 -0
  24. package/create-agent-launcher/templates/backend-developer-ts.md +57 -0
  25. package/create-agent-launcher/templates/memory-keeper.md +37 -0
  26. package/create-agent-launcher/templates/requirement-analyzer.md +66 -0
  27. package/create-agent-launcher/templates/specialist-agent.md +34 -0
  28. package/create-agent-launcher/templates/task-verifier.md +56 -0
  29. package/create-agent-launcher/templates/tool-maker.md +33 -0
  30. package/create-agent-launcher/workflows/01-init.md +22 -0
  31. package/create-agent-launcher/workflows/02-analysis.md +26 -0
  32. package/create-agent-launcher/workflows/03-generation.md +29 -0
  33. package/create-agent-launcher/workflows/04-launcher.md +20 -0
  34. package/docker-verify.sh +266 -0
  35. package/docs/architecture.md +95 -0
  36. package/docs/philosophy.md +45 -0
  37. package/docs/reflection.md +34 -0
  38. package/docs/routing.md +45 -0
  39. package/docs/workflows/build-multi-agent-system.md +62 -0
  40. package/docs/workflows/create-agent-launcher.md +62 -0
  41. package/docs/workflows/environment-detection.md +63 -0
  42. package/docs/workflows/eval-harness.md +57 -0
  43. package/docs/workflows/fable-discipline.md +59 -0
  44. package/docs/workflows/fable-mode.md +32 -0
  45. package/docs/workflows/git-commit.md +62 -0
  46. package/docs/workflows/grill-me.md +62 -0
  47. package/docs/workflows/grill-with-docs.md +62 -0
  48. package/docs/workflows/harness-everything.md +92 -0
  49. package/docs/workflows/improve-codebase-architecture.md +60 -0
  50. package/docs/workflows/install-cognitive-os.md +60 -0
  51. package/docs/workflows/repo-docs.md +59 -0
  52. package/docs/workflows/rewrite-commits.md +60 -0
  53. package/docs/workflows/security-review.md +58 -0
  54. package/docs/workflows/self-evolve.md +59 -0
  55. package/docs/workflows/skill-creator.md +75 -0
  56. package/docs/workflows/skill-style.md +64 -0
  57. package/docs/workflows/tdd.md +39 -0
  58. package/docs/workflows/todo-driven-workflow.md +36 -0
  59. package/docs/workflows/using-git-worktrees.md +63 -0
  60. package/docs/workflows/verification-loop.md +69 -0
  61. package/docs/workflows/verify-before-claim.md +60 -0
  62. package/docs/workflows/zoom-out.md +62 -0
  63. package/environment-detection/SKILL.md +77 -0
  64. package/environment-detection/scripts/preflight.js +93 -0
  65. package/eval-framework/behavioral-test.js +105 -0
  66. package/eval-framework/cases/case1.json +5 -0
  67. package/eval-framework/cases/case2.json +5 -0
  68. package/eval-framework/cases/case3.json +5 -0
  69. package/eval-framework/cases/case4-zh-tier2.json +5 -0
  70. package/eval-framework/cases/case5-zh-tier3.json +5 -0
  71. package/eval-framework/mechanism-test.js +251 -0
  72. package/eval-framework/runner.js +56 -0
  73. package/eval-harness/SKILL.md +59 -0
  74. package/eval-harness/scripts/evaluate.js +61 -0
  75. package/fable-discipline/SKILL.md +38 -0
  76. package/fable-mode/CONTRACT-FORMAT.md +51 -0
  77. package/fable-mode/SKILL.md +51 -0
  78. package/fable-mode/agents/fable-orchestrator.md +92 -0
  79. package/fable-mode/agents/fable-verifier.md +32 -0
  80. package/fable-mode/agents/fable-worker-haiku.md +48 -0
  81. package/fable-mode/agents/fable-worker-sonnet.md +49 -0
  82. package/fable-mode/execution-guardrails/SKILL.md +87 -0
  83. package/fable-mode/fable-haiku/SKILL.md +48 -0
  84. package/git-commit/SKILL.md +55 -0
  85. package/git-commit/guides/ANGULAR_STYLE.md +61 -0
  86. package/git-commit/guides/COMMIT_GENERATION.md +24 -0
  87. package/git-commit/guides/LANGUAGE_DETECTION.md +16 -0
  88. package/git-commit/guides/MAIN_REPO.md +15 -0
  89. package/git-commit/guides/SUBMODULES.md +27 -0
  90. package/grill-me/SKILL.md +36 -0
  91. package/grill-with-docs/ADR-FORMAT.md +47 -0
  92. package/grill-with-docs/CONTEXT-FORMAT.md +63 -0
  93. package/grill-with-docs/SKILL.md +99 -0
  94. package/harness-everything/SKILL.md +141 -0
  95. package/harness-everything/examples/README.md +9 -0
  96. package/harness-everything/examples/todo-workflow.md +22 -0
  97. package/harness-everything/scripts/bootstrap.js +140 -0
  98. package/harness-everything/scripts/self-heal.js +189 -0
  99. package/harness-everything/scripts/tier-router.js +219 -0
  100. package/harness-everything/scripts/todo-cli.js +157 -0
  101. package/harness-everything/scripts/verify-gate.js +31 -0
  102. package/hooks/hooks.json +155 -0
  103. package/hooks/scripts/atomic-commit-check.js +68 -0
  104. package/hooks/scripts/boundary-guard.js +55 -0
  105. package/hooks/scripts/context-compact.js +114 -0
  106. package/hooks/scripts/contract-test.js +79 -0
  107. package/hooks/scripts/depth-guard.js +65 -0
  108. package/hooks/scripts/lib/harness-state.js +202 -0
  109. package/hooks/scripts/lib/platforms/claude.js +42 -0
  110. package/hooks/scripts/lib/platforms/codex.js +46 -0
  111. package/hooks/scripts/lib/platforms/continue.js +41 -0
  112. package/hooks/scripts/lib/platforms/copilot.js +41 -0
  113. package/hooks/scripts/lib/platforms/cursor.js +41 -0
  114. package/hooks/scripts/lib/platforms/hermes.js +32 -0
  115. package/hooks/scripts/lib/platforms/index.js +17 -0
  116. package/hooks/scripts/lib/platforms/worktrees.js +20 -0
  117. package/hooks/scripts/reset-circuit-breaker.js +30 -0
  118. package/hooks/scripts/rule-of-3-tracker.js +91 -0
  119. package/hooks/scripts/rule-of-3.js +176 -0
  120. package/hooks/scripts/state-persist.js +99 -0
  121. package/hooks/scripts/stop-gate.js +80 -0
  122. package/hooks/scripts/subagent-scope-guard.js +88 -0
  123. package/improve-codebase-architecture/SKILL.md +44 -0
  124. package/improve-codebase-architecture/guides/DEEPENING.md +37 -0
  125. package/improve-codebase-architecture/guides/HTML-REPORT.md +123 -0
  126. package/improve-codebase-architecture/guides/INTERFACE-DESIGN.md +44 -0
  127. package/improve-codebase-architecture/guides/LANGUAGE.md +53 -0
  128. package/install-cognitive-os/SKILL.md +95 -0
  129. package/package.json +22 -0
  130. package/repo-docs/SKILL.md +45 -0
  131. package/repo-docs/templates/agents-template.md +264 -0
  132. package/repo-docs/templates/knowledge-agents-template.md +50 -0
  133. package/repo-docs/templates/knowledge-readme-template.md +83 -0
  134. package/repo-docs/templates/manual-recon.md +117 -0
  135. package/repo-docs/templates/multi-skills-readme-template.md +72 -0
  136. package/repo-docs/templates/product-agents-template.md +78 -0
  137. package/repo-docs/templates/product-readme-template.md +95 -0
  138. package/repo-docs/templates/readme-template.md +136 -0
  139. package/repo-docs/templates/single-skill-readme-template.md +70 -0
  140. package/repo-docs/templates/skills-agents-template.md +60 -0
  141. package/rewrite-commits/SKILL.md +32 -0
  142. package/scripts/installer.js +649 -0
  143. package/scripts/lib/advisory-text.js +163 -0
  144. package/scripts/lib/claude-hooks.js +71 -0
  145. package/scripts/lib/gitignore.js +58 -0
  146. package/scripts/lib/manifest.js +82 -0
  147. package/scripts/lib/prompts.js +241 -0
  148. package/scripts/lib/skills.js +172 -0
  149. package/scripts/lib/workspace.js +28 -0
  150. package/security-review/SKILL.md +511 -0
  151. package/self-evolve/SKILL.md +54 -0
  152. package/self-evolve/scripts/persist-memory.js +40 -0
  153. package/self-evolve/scripts/self-regression.js +113 -0
  154. package/skill-creator/SKILL.md +91 -0
  155. package/skill-creator/references/quality-principles.md +81 -0
  156. package/skill-creator/references/testing-workflow.md +32 -0
  157. package/skill-style/SKILL.md +48 -0
  158. package/skill-style/STYLE.md +37 -0
  159. package/tdd/SKILL.md +53 -0
  160. package/tdd/guides/deep-modules.md +33 -0
  161. package/tdd/guides/interface-design.md +31 -0
  162. package/tdd/guides/mocking.md +59 -0
  163. package/tdd/guides/refactoring.md +10 -0
  164. package/tdd/guides/tests.md +61 -0
  165. package/todo-driven-workflow/SKILL.md +54 -0
  166. package/using-git-worktrees/SKILL.md +161 -0
  167. package/verification-loop/SKILL.md +138 -0
  168. package/verify-before-claim/SKILL.md +86 -0
  169. package/zoom-out/SKILL.md +90 -0
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: "Task Verifier"
3
+ description: "Use when: verifying if the implemented changes meet the original requirements and AI implementation document. It checks modifications without editing files and re-dispatches tasks if errors are found."
4
+ {{TOOLS_ARRAY_DECLARATION}}
5
+ ---
6
+
7
+ You are an expert Quality Assurance and Task Verifier for the **{{PROJECT_NAME}}** project. Your responsibility is to inspect the codebase after a task has been implemented to ensure it perfectly matches the requirements.
8
+
9
+ ## Constraints
10
+
11
+ - **NO MODIFICATION**: You are a Read-Only Auditor. DO NOT use `{{EDIT_TOOL_NAME}}` to modify any source code files. If you find an issue, your job is to fail the verification, not to fix it.
12
+ - ONLY use `{{SEARCH_TOOL_NAME}}` and `{{READ_TOOL_NAME}}` to inspect the codebase state. NEVER alter repository state.
13
+ - DO NOT attempt to fix errors yourself.
14
+ - **NO AGENT INVOCATION**: You CANNOT use an `agent` tool to call other agents. Output a Handover Block to request a re-dispatch instead.
15
+
16
+ ## Behavioral Guidelines
17
+
18
+ ### Strict Binary Verification
19
+ *(from Karpathy: Goal-Driven Execution)*
20
+ - Compare actual changes against **each goal** listed in the implementation document.
21
+ - This is a BINARY check. Partial fulfillment is a Fail ❌.
22
+ - DO NOT suggest alternative designs or code improvements. Your only concern is compliance with the document.
23
+ - If a requirement is ambiguous in the document, surface that ambiguity as a Fail ❌.
24
+
25
+ ### Zero Tolerance for Extraneous Code
26
+ *(from Karpathy: Surgical Changes)*
27
+ - Inspect the codebase using your read and search tools to verify what was changed.
28
+ - If you find code that was NOT explicitly requested in the plan (even if it looks like a good refactor or a nice-to-have fix), you MUST fail the verification and instruct the developer to revert the extraneous changes.
29
+
30
+ ### Categorize the Failure
31
+ If verification fails, you MUST categorize the root cause of the failure:
32
+ - `Implementation_Error`: The developer wrote bugged code or didn't follow the clear plan.
33
+ - `Requirement_Ambiguity`: The plan itself is contradictory, missing edge cases, or logically flawed.
34
+ - `Environment_Blocker`: Code seems right, but builds/tests fail due to missing dependencies, config issues, or OS limitations.
35
+ - `Knowledge_Gap`: Missing context about internal libraries or third-party APIs.
36
+
37
+ ## Approach
38
+
39
+ 1. **Check Requirements Document**: Read the AI implementation document in `{{AI_PLAN_PATH}}` to understand the exact scope.
40
+ 2. **Review Modifications**: Review the Handover Block provided by the Developer to get the exact list of modified files and line ranges. Use `{{READ_TOOL_NAME}}` directly on those specific files to inspect their current contents. You do not need to do a blind search unless the Developer's list is incomplete.
41
+ 3. **Verify Compliance**: Cross-check actual code logic against the requirements and documented plan. Ensure no unrequested changes were made.
42
+ 4. **Handle Discrepancies**: Pass ✅ if all requirements are met. Fail ❌ and output a Handover Block with fix instructions if not.
43
+
44
+ ## Output Format
45
+
46
+ ```
47
+ ### 🤝 Handover Block
48
+ - **Verification Status**: `[✅ Pass | ❌ Fail]`
49
+ - **Failure Category**: `<Implementation_Error | Requirement_Ambiguity | Environment_Blocker | Knowledge_Gap | None>`
50
+ - **Verified Against**: `<absolute path to implementation document>`
51
+ - **Errors / Missing Items**: `<concise list, or 'None' if Pass>`
52
+ - **Key Learnings (if any)**: `<Identify any novel problems solved, new architectural patterns used, or critical errors overcome during this task that should be committed to long-term memory. If none, write 'None'.>`
53
+ - **Recommended Agent**: `<Agent Name if Fail, or 'None' if Pass>`
54
+ - **Fix Instructions**: `<specific description of what needs to be fixed if Fail, or 'None' if Pass>`
55
+ - **Action for Orchestrator**: I have completed my verification. Please refer to your central rules to determine the next step in the workflow (e.g. re-invoke developer, invoke memory keeper, or stop).
56
+ ```
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: "Tool Maker"
3
+ description: "Use when: a repetitive or error-prone task (like file parsing, data extraction, or log analysis) needs to be automated via a small script to make the AI's autonomous capabilities more reliable."
4
+ {{TOOLS_ARRAY_DECLARATION}}
5
+ ---
6
+
7
+ You are the Tool Maker Agent for the **{{PROJECT_NAME}}** project. Your job is to create small, reliable, and reusable utility scripts (e.g., Python, Node.js, bash) that help the AI system bypass limitations or handle brittle operations (like complex file reading or text processing).
8
+
9
+ ## Constraints
10
+
11
+ - DO NOT implement core application features.
12
+ - DO NOT modify existing application source code unless it's a dedicated utility script directory (e.g., `scripts/ai_tools/`).
13
+ - Scripts must be self-contained and require minimal external dependencies.
14
+ - Scripts must be designed to be run from a standard terminal (CLI).
15
+ - Output of the scripts must be clean, parsable, and AI-friendly (e.g., JSON or clear structured text).
16
+
17
+ ## Approach
18
+
19
+ 1. **Understand the Bottleneck**: Read the context provided by the Orchestrator regarding what operation is failing or is too repetitive (e.g., "The AI keeps failing to read line ranges in large CSVs").
20
+ 2. **Design the Tool**: Choose the appropriate scripting language (usually Python or Node.js depending on the project stack). Ensure it takes clear command-line arguments.
21
+ 3. **Implement**: Write the script and save it to the project's scripts directory (e.g., `{{SCRIPTS_DIR}}/`).
22
+ 4. **Test**: Run the script using the terminal to verify it works exactly as intended and handles edge cases (like file not found).
23
+ 5. **Document**: Add a brief usage example as a comment at the top of the script so other agents know how to use it.
24
+
25
+ ## Output Format
26
+
27
+ ```
28
+ ### 🛠️ Tool Created
29
+ - **Tool Path**: `<path to the script>`
30
+ - **Usage Command**: `<example command to run it>`
31
+ - **Purpose**: <Brief description of what it solves>
32
+ - **Action for Orchestrator**: Please pass this tool information back to the agent that requested it, or proceed with the workflow.
33
+ ```
@@ -0,0 +1,22 @@
1
+ # Phase 1: Platform & Location Preferences
2
+
3
+ **[State Checkpoint]**
4
+ - MUST verify the `Target Directory` absolute path passed from the previous step.
5
+
6
+ ## [Discovery & Inquiry Phase]
7
+ 1. Target Selection: MUST use `vscode_askQuestions` to ask platform and location in one prompt.
8
+ - Target Platform options MUST include Copilot, Claude, Gemini, and Codex.
9
+ - Target Location options MUST include Project Level and Global Level.
10
+ - MUST NOT auto-detect the platform.
11
+
12
+ ## [Validation & Research Phase]
13
+ 2. Load Guidelines: MUST read `guidelines/platform-<platform>.md` corresponding to the chosen platform. MUST treat this local file as the single source of truth. DO NOT perform web research for platform APIs unless explicitly instructed or if the file contains severe logic gaps.
14
+ 3. Conflict Assessment: MUST use the loaded layout rules to check if existing agents are already present in the target location within the `Target Directory`.
15
+
16
+ ## [Action Phase: Conflict Resolution]
17
+ 4. Preference Gathering: MUST use `vscode_askQuestions` to ask for Resilience Features configuration.
18
+ 5. Conflict Strategy: IF existing agents are found in the previous step, MUST ask for Conflict Resolution strategy (Safe Update, Backup & Overwrite, Smart Merge).
19
+
20
+ ## [Record: Handoff]
21
+ 6. State Packaging: MUST explicitly record the selected `Platform`, `Location`, `Resilience Features`, and `Conflict Strategy`.
22
+ 7. Handoff: MUST execute `workflows/02-analysis.md` and explicitly pass these variables alongside the `Target Directory`.
@@ -0,0 +1,26 @@
1
+ # Phase 2: Project Analysis
2
+
3
+ **[State Checkpoint]**
4
+ - MUST verify the inheritance of `Target Directory`, `Platform`, `Location`, `Resilience Features`, and `Conflict Strategy` from Phase 1.
5
+
6
+ ## [Discovery Phase: Content Extraction]
7
+ 1. Discovery Guide: MUST read `reference.md` for the discovery guide.
8
+ 2. Target Scanning: MUST scan the `Target Directory` for `README.md`, `AGENTS.md` (or `CLAUDE.md`), and build files (e.g., `package.json`, `*.sln`).
9
+ 3. Safe Extraction: For EACH discovered file, MUST read it securely and extract project name, tech stack, build commands, and architectural rules. IF a file does not exist, MUST skip it.
10
+ 4. Abstraction: MUST synthesize the extracted data into a `Context Profile` to prevent context bloat.
11
+
12
+ ## [Elimination & Evaluation Phase]
13
+ 5. Stack Detection: MUST determine the exact tech stack from the gathered signals (e.g., `.csproj` implies C#).
14
+ 6. Scope Limiting: MUST check for monorepo configuration (`pnpm-workspace.yaml`, `nx.json`).
15
+ - IF it IS a monorepo, MUST use `vscode_askQuestions` to ask the user to specify the target package/app. MUST NOT attempt to scaffold agents for the entire monorepo universally.
16
+ 7. Subagent Proposal: MUST propose specialist agents based on detected files (e.g., `.sh` implies Shell Expert). MUST NOT propose agents that duplicate core roles.
17
+
18
+ ## [Action Phase: User Confirmation & Gap Analysis]
19
+ 8. Selection: MUST use `vscode_askQuestions` to present a multi-select checklist of Subagents.
20
+ - MUST include Core agents: Requirement Analyzer, Backend Developer, Task Verifier.
21
+ - MUST include detected Specialist agents in the options.
22
+ 9. Batch Requirements Check: AFTER selection, MUST quickly assess the chosen templates for required Placeholders (e.g., `{{DB_TYPE}}`). IF the `Context Profile` lacks this data, MUST explicitly ask the user in ONE batched question to fill the gaps.
23
+ 10. Wait State: MUST wait for user to complete selection and variable input before proceeding.
24
+
25
+ ## [Record: Handoff]
26
+ 10. Handoff: MUST execute `workflows/03-generation.md` and explicitly pass the `Context Profile`, `Selected Agents`, and ALL Phase 1 variables.
@@ -0,0 +1,29 @@
1
+ # Phase 3: Scaffold Generation
2
+
3
+ **[State Checkpoint]**
4
+ - MUST verify the inheritance of `Target Directory`, `Context Profile`, `Selected Agents`, and Phase 1 variables (`Platform`, `Conflict Strategy`, etc.).
5
+ - MUST ensure terminal is located at the `Target Directory` BEFORE file modifications.
6
+
7
+ ## [Preparation Phase]
8
+ 1. Merge Strategy: MUST NOT overwrite existing agents blindly. MUST apply the `Conflict Strategy` selected in Phase 1.
9
+ - IF `Smart Merge` is selected BUT the target agent belongs to a different platform architecture, MUST downgrade to `Backup & Overwrite` to prevent cross-platform hallucination.
10
+ 2. Semantic Integrity: IF Smart Merge, MUST perform Semantic Refactor aligning with Logical Consistency, Long-Term Memory, Self-Adaptation, and Self-Verification. MUST preserve original YAML Frontmatter.
11
+
12
+ ## [Action Phase: Generation]
13
+ 3. Template Iteration: For EACH selected agent in `Selected Agents`, MUST NOT read all templates at once to prevent context dilution. MUST process them one by one:
14
+ - MUST read the specific template.
15
+ - IF `Conflict Strategy` is Smart Merge AND the target file exists, MUST read the existing file BEFORE merging to prevent hallucination.
16
+ - MUST inject strict Cognitive Guardrails: MUST explicitly define Role Boundaries (refusing out-of-scope tasks), mandate the use of the Shared Memory Space (`memory-keeper`), and mandate deterministic outcome verification (no hallucinating success).
17
+ - MUST align generation with platform-specific capabilities (e.g., VS Code LSP tooltips vs Cursor rules) and inject localized task-tracking/TODO frameworks tailored to the target platform and specific agent role (ensuring each agent and platform gets its own isolated, native TODO tracking system, e.g., mapping to `manage_todo_list` for VS Code, `.cursorrules` checklists for Cursor, or unique agent-scoped status JSONs).
18
+ - MUST substitute placeholders using the `Context Profile`. IF a placeholder cannot be resolved, MUST NOT guess. MUST insert a conspicuous tag (e.g., `<<TODO: MANUAL_INPUT_REQUIRED>>` or localized `// TODO:` structured comments mapping to the active platform's task-tracking schema).
19
+ - MUST write files securely to destination paths from `guidelines/platform-<platform>.md`.
20
+ 4. Orchestrator Gen: MUST consult `guidelines/platform-<platform>.md` for Orchestrator requirements. MUST generate separate Orchestrator Instructions or update the root system prompt IF required.
21
+
22
+ ## [Summarize & Verification Phase]
23
+ 5. Integrity Check: MUST verify the generated files were written correctly to the disk by reading back portions or verifying their existence. Hallucinating success is forbidden.
24
+
25
+ ## [Record: Exit]
26
+ 6. Completion: MUST log successful Subagent generation.
27
+ 7. Handoff: MUST execute `workflows/04-launcher.md` and pass the `Context Profile`, `Selected Agents`, and paths of the newly created files to ensure the entry point is explicitly generated in a dedicated mental phase.
28
+
29
+ [Exit: Await User Instruction]**'launch agent'** or describe your feature/task."
@@ -0,0 +1,20 @@
1
+ # Phase 4: Launcher Bootstrapping
2
+
3
+ **[State Checkpoint]**
4
+ - MUST verify the inheritance of `Target Directory`, `Context Profile`, `Selected Agents`, and paths of the newly created files from Phase 3.
5
+ - MUST ensure terminal is located at the `Target Directory`.
6
+
7
+ ## [Action Phase: Entry Point Generation]
8
+ 1. Entry Point Gen: MUST read `templates/agent-launcher.md`.
9
+ 2. Handoff Integration: MUST substitute placeholders using the `Context Profile`. MUST dynamically inject the paths and roles of the `Selected Agents` into the Launcher, ensuring it accurately serves as the central router for the ecosystem.
10
+ 3. Disk Write: MUST save to the skill entry point path defined in the platform guidelines securely.
11
+
12
+ ## [Summarize: Verification]
13
+ 4. Check: MUST verify the Launcher was written successfully.
14
+
15
+ ## [Record: Exit]
16
+ 5. Completion: MUST report successful scaffold generation to the user. MUST provide a summary table of ALL generated files (including Subagents and the Launcher) and their status.
17
+ 6. UX Handoff: MUST prompt the user to launch their first agent workflow with a suggested message (e.g., "Agentic workflow scaffold is ready. To launch your first agent workflow, use the launcher...").
18
+ 7. Exit: MUST terminate execution.
19
+
20
+ [Exit: Await User Instruction]
@@ -0,0 +1,266 @@
1
+ #!/bin/bash
2
+ set -e # Exit immediately if a command exits with a non-zero status
3
+
4
+ echo "================================================="
5
+ echo " Harness OS - Comprehensive Docker Verification "
6
+ echo "================================================="
7
+
8
+ # 1. Prepare Git Environment (Subagent Scope Guard depends on Git)
9
+ echo -e "\n[Step 1] Initializing local Git repository for tests..."
10
+ if [ ! -d ".git" ]; then
11
+ git init
12
+ git config --global user.email "test@test.com"
13
+ git config --global user.name "Test Bot"
14
+ git add -A
15
+ git commit -m "initial commit for test"
16
+ echo "Git repository initialized and committed."
17
+ else
18
+ echo "Git repository already exists."
19
+ fi
20
+
21
+ # 2. Run Self-Regression Test Suite
22
+ echo -e "\n[Step 2] Running Harness Self-Regression tests..."
23
+ npm test
24
+
25
+ # 3. Mechanism Checks (from VERIFICATION.md Section 2)
26
+ echo -e "\n[Step 3] Running Mechanism Checks..."
27
+
28
+ # 3a. Rule of 3 Circuit Breaker actually blocks
29
+ # Runtime state lives under .claude/harness-state/sessions/<session_id>/;
30
+ # invocations with no session_id (like these bare/manual calls) fall into a
31
+ # fixed sessions/default/ bucket.
32
+ echo -e "\n---> Running 3a: Rule of 3 Circuit Breaker"
33
+ mkdir -p .claude/harness-state/sessions/default
34
+ rm -f .claude/harness-state/sessions/default/zoom-out-report.md
35
+ echo '{"count":3,"lastHash":"verify-test","zoomOutResolved":false}' > .claude/harness-state/sessions/default/rule-of-3-state.json
36
+
37
+ # We expect this to exit with 2 and print CRITICAL trigger message
38
+ set +e
39
+ node hooks/scripts/rule-of-3.js 2>rule-of-3-err.log
40
+ EXIT_CODE=$?
41
+ set -e
42
+
43
+ echo "Exit code: $EXIT_CODE"
44
+ if [ "$EXIT_CODE" -ne 2 ]; then
45
+ echo "❌ FAIL: Rule of 3 did not exit with code 2 (got $EXIT_CODE)"
46
+ exit 1
47
+ fi
48
+
49
+ if ! grep -q "RULE OF 3 CIRCUIT BREAKER TRIGGERED" rule-of-3-err.log; then
50
+ echo "❌ FAIL: Rule of 3 error output did not contain trigger message"
51
+ cat rule-of-3-err.log
52
+ exit 1
53
+ fi
54
+ echo "✅ PASS: Rule of 3 blocked successfully with exit code 2 and correct message."
55
+
56
+ # Reset Rule of 3
57
+ echo "Resetting circuit breaker..."
58
+ npm run harness:reset
59
+ set +e
60
+ node hooks/scripts/rule-of-3.js
61
+ EXIT_CODE=$?
62
+ set -e
63
+ if [ "$EXIT_CODE" -ne 0 ]; then
64
+ echo "❌ FAIL: Rule of 3 reset check failed (expected 0, got $EXIT_CODE)"
65
+ exit 1
66
+ fi
67
+ echo "✅ PASS: Rule of 3 reset check passed."
68
+
69
+ # 3a-bis. Zoom-out reflection report releases the breaker (self-recovery path)
70
+ echo -e "\n---> Running 3a-bis: Zoom-out report releases the breaker"
71
+ echo '{"count":3,"lastHash":"verify-test","zoomOutResolved":false,"lastFailureAt":0,"zoomOutCycles":0}' > .claude/harness-state/sessions/default/rule-of-3-state.json
72
+ printf '## Goal\nx\n## Failed Attempts\nx\n## Verified Facts\nx\n## Diagnosis\nx\n## Decision\nRESUME: new approach\n' > .claude/harness-state/sessions/default/zoom-out-report.md
73
+
74
+ set +e
75
+ node hooks/scripts/rule-of-3.js
76
+ EXIT_CODE=$?
77
+ set -e
78
+ if [ "$EXIT_CODE" -ne 0 ]; then
79
+ echo "❌ FAIL: Valid reflection report did not release the breaker (expected 0, got $EXIT_CODE)"
80
+ exit 1
81
+ fi
82
+ if ! node -e "const s=require('./.claude/harness-state/sessions/default/rule-of-3-state.json'); process.exit(s.count===0 && s.zoomOutResolved===true && s.zoomOutCycles===1 ? 0 : 1)"; then
83
+ echo "❌ FAIL: Breaker state not updated after report release"
84
+ cat .claude/harness-state/sessions/default/rule-of-3-state.json
85
+ exit 1
86
+ fi
87
+ echo "✅ PASS: Valid reflection report released the breaker (self-recovery)."
88
+
89
+ # Second trip on the same signature must hard-lock even though a report exists
90
+ # (the report is stale relative to lastFailureAt, and the cycle budget is spent).
91
+ node -e "require('fs').writeFileSync('.claude/harness-state/sessions/default/rule-of-3-state.json', JSON.stringify({count:3,lastHash:'verify-test',zoomOutResolved:false,lastFailureAt:Date.now()+60000,zoomOutCycles:1}))"
92
+ set +e
93
+ node hooks/scripts/rule-of-3.js 2>rule-of-3-err.log
94
+ EXIT_CODE=$?
95
+ set -e
96
+ if [ "$EXIT_CODE" -ne 2 ]; then
97
+ echo "❌ FAIL: Second trip did not hard-lock (expected 2, got $EXIT_CODE)"
98
+ cat rule-of-3-err.log
99
+ exit 1
100
+ fi
101
+ if ! grep -q "hard lock" rule-of-3-err.log; then
102
+ echo "❌ FAIL: Second-trip output did not contain hard-lock escalation message"
103
+ cat rule-of-3-err.log
104
+ exit 1
105
+ fi
106
+ echo "✅ PASS: Second trip on the same signature hard-locked for human decision."
107
+ npm run harness:reset
108
+
109
+
110
+ # 3b. Boundary Guard blocks oversized read
111
+ echo -e "\n---> Running 3b: Boundary Guard Oversized Read"
112
+ node -e "require('fs').writeFileSync('.verify-big.tmp','x'.repeat(600*1024))"
113
+
114
+ set +e
115
+ echo '{"tool_name":"Read","tool_input":{"file_path":".verify-big.tmp"}}' | node hooks/scripts/boundary-guard.js 2>boundary-guard-err.log
116
+ EXIT_CODE=$?
117
+ set -e
118
+
119
+ rm -f .verify-big.tmp
120
+
121
+ echo "Exit code: $EXIT_CODE"
122
+ if [ "$EXIT_CODE" -ne 2 ]; then
123
+ echo "❌ FAIL: Boundary Guard did not exit with code 2 (got $EXIT_CODE)"
124
+ exit 1
125
+ fi
126
+
127
+ if ! grep -q "BLOCKED" boundary-guard-err.log; then
128
+ echo "❌ FAIL: Boundary Guard error output did not contain BLOCKED"
129
+ cat boundary-guard-err.log
130
+ exit 1
131
+ fi
132
+ echo "✅ PASS: Boundary Guard blocked large read successfully."
133
+
134
+
135
+ # 3c. State persistence (WAL) records failure and handles clear
136
+ echo -e "\n---> Running 3c: State persistence (WAL)"
137
+ rm -f .claude/harness-state/sessions/default/handoff-state.json
138
+
139
+ # Record failure
140
+ echo '{"tool_name":"Bash","tool_response":{"stdout":"","stderr":"npm ERR! verify-test failure"}}' | node hooks/scripts/state-persist.js
141
+
142
+ if [ ! -f ".claude/harness-state/sessions/default/handoff-state.json" ]; then
143
+ echo "❌ FAIL: handoff-state.json was not created"
144
+ exit 1
145
+ fi
146
+
147
+ STATUS=$(node -e "console.log(JSON.parse(require('fs').readFileSync('.claude/harness-state/sessions/default/handoff-state.json','utf8')).status)")
148
+ if [ "$STATUS" != "failed" ]; then
149
+ echo "❌ FAIL: Expected status to be 'failed', got '$STATUS'"
150
+ exit 1
151
+ fi
152
+
153
+ # Bootstrap output verification (pipe {} explicitly - bootstrap.js reads a
154
+ # session_id off stdin same as every other hook, and a bare invocation's
155
+ # stdin isn't guaranteed to close on its own in a non-interactive shell)
156
+ BOOTSTRAP_OUT=$(echo '{}' | node harness-everything/scripts/bootstrap.js)
157
+ if ! echo "$BOOTSTRAP_OUT" | grep -q "Harness OS - Handoff Checkpoint"; then
158
+ echo "❌ FAIL: Bootstrap output did not show handoff checkpoint box"
159
+ echo "$BOOTSTRAP_OUT"
160
+ exit 1
161
+ fi
162
+ echo "✅ PASS: State persistence correctly saved failure status."
163
+
164
+ # Clean run to clear WAL
165
+ echo '{"tool_name":"Bash","tool_response":{"stdout":"ok","exitCode":0}}' | node hooks/scripts/state-persist.js
166
+ BOOTSTRAP_OUT_CLEAN=$(echo '{}' | node harness-everything/scripts/bootstrap.js)
167
+ if echo "$BOOTSTRAP_OUT_CLEAN" | grep -q "Harness OS - Handoff Checkpoint"; then
168
+ echo "❌ FAIL: Bootstrap output still showed checkpoint box after clean run"
169
+ exit 1
170
+ fi
171
+ echo "✅ PASS: State persistence correctly cleared status on successful execution."
172
+
173
+
174
+ # 3d. Fact-audit reminder reaches agent via stdin JSON
175
+ echo -e "\n---> Running 3d: Fact-audit reminder"
176
+ ROUTER_OUT=$(echo '{"prompt":"what exit code does this hook use by default and is it documented"}' | node harness-everything/scripts/tier-router.js)
177
+
178
+ if ! echo "$ROUTER_OUT" | grep -q "FACT-AUDIT REMINDER"; then
179
+ echo "❌ FAIL: tier-router did not output FACT-AUDIT REMINDER on stdin JSON"
180
+ echo "$ROUTER_OUT"
181
+ exit 1
182
+ fi
183
+ echo "✅ PASS: Fact-audit reminder successfully outputted."
184
+
185
+
186
+ # 3e. Subagent scope guard catches out-of-scope change
187
+ echo -e "\n---> Running 3e: Subagent scope guard"
188
+ # PreToolUse
189
+ echo '{"tool_name":"Task","hook_event_name":"PreToolUse","tool_input":{}}' | node hooks/scripts/subagent-scope-guard.js
190
+
191
+ # Make unexpected modification
192
+ echo "unexpected change" >> .verify-scope-test.tmp
193
+
194
+ # PostToolUse expect exit 2
195
+ set +e
196
+ echo '{"tool_name":"Task","hook_event_name":"PostToolUse","tool_input":{}}' | node hooks/scripts/subagent-scope-guard.js 2>scope-guard-err.log
197
+ EXIT_CODE=$?
198
+ set -e
199
+
200
+ rm -f .verify-scope-test.tmp
201
+
202
+ echo "Exit code: $EXIT_CODE"
203
+ if [ "$EXIT_CODE" -ne 2 ]; then
204
+ echo "❌ FAIL: Subagent scope guard did not block out-of-scope changes (expected exit code 2, got $EXIT_CODE)"
205
+ exit 1
206
+ fi
207
+
208
+ if ! grep -q "Subagent Scope Guard" scope-guard-err.log || ! grep -q ".verify-scope-test.tmp" scope-guard-err.log; then
209
+ echo "❌ FAIL: Scope guard did not report the unexpected changed file"
210
+ cat scope-guard-err.log
211
+ exit 1
212
+ fi
213
+ echo "✅ PASS: Subagent scope guard successfully blocked out-of-scope modifications."
214
+
215
+
216
+ # 3f. Stop gate bounces an unverified-edit stop exactly once
217
+ echo -e "\n---> Running 3f: Stop Gate"
218
+ rm -f .claude/harness-state/sessions/default/stop-gate-state.json
219
+ node -e "require('fs').mkdirSync('.claude/harness-state/sessions/default',{recursive:true}); require('fs').writeFileSync('.claude/harness-state/sessions/default/handoff-state.json', JSON.stringify({status:'idle',lastEditAt:Date.now(),lastVerifyAt:0}))"
220
+ echo "dirty" > .verify-dirty.tmp
221
+
222
+ set +e
223
+ echo '{}' | node hooks/scripts/stop-gate.js 2>stop-gate-err.log
224
+ EXIT_CODE=$?
225
+ set -e
226
+ echo "Exit code: $EXIT_CODE"
227
+ if [ "$EXIT_CODE" -ne 2 ]; then
228
+ echo "❌ FAIL: Stop gate did not bounce an unverified-edit stop (expected 2, got $EXIT_CODE)"
229
+ cat stop-gate-err.log
230
+ exit 1
231
+ fi
232
+ if ! grep -q "Stop Gate" stop-gate-err.log; then
233
+ echo "❌ FAIL: Stop gate output did not contain its message"
234
+ cat stop-gate-err.log
235
+ exit 1
236
+ fi
237
+
238
+ # Same edit batch must not bounce twice
239
+ set +e
240
+ echo '{}' | node hooks/scripts/stop-gate.js
241
+ EXIT_CODE=$?
242
+ set -e
243
+ if [ "$EXIT_CODE" -ne 0 ]; then
244
+ echo "❌ FAIL: Stop gate bounced the same edit batch twice (expected 0, got $EXIT_CODE)"
245
+ exit 1
246
+ fi
247
+
248
+ # Loop guard: stop_hook_active always passes
249
+ rm -f .claude/harness-state/sessions/default/stop-gate-state.json
250
+ set +e
251
+ echo '{"stop_hook_active":true}' | node hooks/scripts/stop-gate.js
252
+ EXIT_CODE=$?
253
+ set -e
254
+ if [ "$EXIT_CODE" -ne 0 ]; then
255
+ echo "❌ FAIL: Stop gate blocked despite stop_hook_active (expected 0, got $EXIT_CODE)"
256
+ exit 1
257
+ fi
258
+ rm -f .verify-dirty.tmp .claude/harness-state/sessions/default/handoff-state.json .claude/harness-state/sessions/default/stop-gate-state.json
259
+ echo "✅ PASS: Stop gate bounced once, then respected the batch and loop guards."
260
+
261
+ # Clean up temporary test output logs
262
+ rm -f rule-of-3-err.log boundary-guard-err.log scope-guard-err.log stop-gate-err.log
263
+
264
+ echo -e "\n================================================="
265
+ echo " 🎉 ALL HARNESS MECHANISM CHECKS PASSED SUCCESSFULLY!"
266
+ echo "================================================="
@@ -0,0 +1,95 @@
1
+ # Harness Architecture
2
+
3
+ This document details the internal architecture, lifecycle, and integration touchpoints of the Harness behavior layer.
4
+
5
+ ---
6
+
7
+ ## Architectural Overview
8
+
9
+ Harness acts as a **system supervisor** wrapping around your AI development sessions. Instead of controlling the model's generation directly, it leverages native hook systems (like Claude Code's lifecycle hooks) and instruction files (like `.cursorrules` or `.github/copilot-instructions.md`) to inject contextual guardrails.
10
+
11
+ The diagram below outlines the full lifecycle of a task under Harness:
12
+
13
+ ```mermaid
14
+ flowchart TD
15
+ subgraph User_Session [User Session]
16
+ U([User Request]) --> Boot[bootstrap.js: Session Start]
17
+ end
18
+
19
+ subgraph OS_Kernel [Harness Engine]
20
+ Boot -->|Check Handoff Checkpoint| Preflight[preflight.js: Environment Audit]
21
+ Preflight --> Router{tier-router.js: Task Triage}
22
+
23
+ Router -->|Tier 1: Trivial Task| T1[Direct Execution - No Plans]
24
+ Router -->|Tier 2: Standard Task| T2[tdd: Test-Driven Development]
25
+ Router -->|Tier 3: Macro Task| T3[fable-mode: Multi-Agent Spawn]
26
+ T2 & T3 --> TDW[todo-driven-workflow: Base Execution Checklist]
27
+ end
28
+
29
+ subgraph Defense_Safety [Circuit Breakers]
30
+ T1 & TDW --> Tools[Agent Tool Call]
31
+ Tools -->|PreToolUse| CG[context-compact.js: Bloat Warning]
32
+ Tools -->|PreToolUse| CB{rule-of-3.js: Circuit Breaker}
33
+
34
+ CB -->|Fails 3x| ZO(zoom-out: Halt, Reflect & Fact-Check)
35
+ ZO -->|Fresh diagnosis: RESUME| Tools
36
+ CB -->|Succeeds| Done[Success / Finish]
37
+ end
38
+
39
+ subgraph Continuous_Learning [Continuous Learning]
40
+ ZO -->|Genuine human decision / 2nd trip| Human[Human Decision & Guidance]
41
+ Human --> SE[self-evolve: Deep Reflection]
42
+ Done -->|Complex Breakthrough| SE
43
+ SE --> RunSR[self-regression.js: CI Check]
44
+ RunSR -->|Pass 100%| Mem[(Long-term Memory / RULES.md)]
45
+ Mem -.->|Immunize| Preflight
46
+ end
47
+
48
+ style OS_Kernel fill:#eceff1,stroke:#37474f,stroke-width:2px,color:#000000
49
+ style Defense_Safety fill:#fff9c4,stroke:#fbc02d,stroke-width:2px,color:#000000
50
+ style Continuous_Learning fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px,color:#000000
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Integration touchpoints
56
+
57
+ Harness is designed to align with the unique capabilities of various AI IDEs and CLI tools — but those capabilities are not equivalent across platforms, and this repo does not pretend otherwise.
58
+
59
+ **Self-healing:** integration touchpoints can drift — installed from one editor, opened in another. `harness-everything/scripts/self-heal.js` audits all six touchpoints below and re-runs the idempotent installer to backfill whatever is missing. On Claude Code, `bootstrap.js` performs the audit at SessionStart and reports missing touchpoints (repair is left to the model so an intentionally removed file isn't silently re-created every session); on hook-less platforms, the audit runs when `harness-everything` or `environment-detection`'s Discover phase loads. Only Claude Code has a hook system with exit-code-based blocking; every other platform below gets **advisory text only**, with the same protection level as the "Prompt-Only" column in the README's own comparison table. There is no `preflight.js` audit, no `Rule of 3` circuit breaker, and no WAL on those platforms — nothing runs the `.claude/harness-everything/state/*` runtime-state scripts unless Claude Code (or another hook-capable tool) is also driving the same repo.
60
+
61
+ **Placement rule:** a platform's own native file/folder (`.claude/settings.json`, `.cursorrules`, `.cursor/skills/`, …) is never moved — it lives exactly where that platform expects it. Anything Harness itself needs that has no native home converges into one exclusively-owned subfolder per platform: `<platform-dir>/harness-everything/`. Nothing else ever creates a directory literally named `harness-everything`, which is what lets the installer add or remove it as a unit — including on uninstall — without touching anything else already in that platform's directory (another tool's files, or skills the user installed by hand).
62
+
63
+ **Runtime state vs. installed skill content:** `<platform-dir>/harness-everything/` holds two kinds of content, kept apart by subfolder. `skills/` — Claude only, since Claude has no native project-skill directory to piggyback on — is the installer's local skill-copy target (see `scripts/lib/skills.js`'s `getInstalledSkills`, which is manifest-tracked, not a blind directory scan) — real files, not cache. Every other platform's skills stay at that platform's own established location (`.cursor/skills`, `.github/skills`, `.codex/skills`, `.continue/skills`) and are never moved. `state/` is pure runtime state: hook JSON, circuit-breaker counters, handoff/verification timestamps. It's scoped per Claude Code `session_id` under `sessions/<id>/` so two sessions open on the same repo never share (and stomp) each other's edit/verify timestamps or breaker counts — invocations with no `session_id` (manual runs, tests) fall into a fixed `sessions/default/` bucket. Both are gitignored and safe to delete; `state/` regenerates itself from nothing but in-session state (losing it mid-session just clears breaker/verification history), while deleting `skills/` requires re-running the installer to restore the copied skill files. A `manifest.json` sibling at the `harness-everything/` root records exactly what the installer put where, per platform, so uninstall never has to guess.
64
+
65
+ ### 1. Claude Code (hook-enforced)
66
+ Our installer configures native lifecycle hooks inside `.claude/settings.json`:
67
+ * `SessionStart`: Runs `bootstrap.js` to restore previous handoffs, check environment variables, and initialize session state.
68
+ * `PreToolUse`: Triggers `rule-of-3.js`, `boundary-guard.js`, `depth-guard.js`, `context-compact.js`, and `subagent-scope-guard.js` to intercept tool invocations before they run, and can actually block one (`exit(2)`) — e.g. the Rule of 3 circuit breaker.
69
+ * `PostToolUse`: Records tool outcomes, updates the persistent transaction log (WAL) via `state-persist.js`, tracks repeat failures, and can only add advisory context back (the tool already ran; nothing here blocks it).
70
+ * `Stop`: Runs `stop-gate.js` — when a turn ends with uncommitted edits that were never followed by a successful verification command (test/build/lint), it bounces the stop back once per edit batch. This is the mechanical form of `verification-loop`'s pre-delivery gate; on every other platform that gate remains advisory prose.
71
+
72
+ ### 2. Cursor (advisory only)
73
+ The installer appends guidance to `.cursorrules`. Cursor has no hook/execution mechanism, so nothing in `.claude/harness-state/` gets read or written by Cursor itself, and no tool call can be blocked — the model is simply asked (in the same file, every session) to self-regulate: discover the environment before acting, stop after 3 repeated failures instead of continuing to retry, and prefer small commits.
74
+
75
+ ### 3. Copilot Chat (advisory only)
76
+ Same mechanism and same limits as Cursor, via `.github/copilot-instructions.md`.
77
+
78
+ ### 4. Codex (advisory only)
79
+ Same mechanism and same limits again, via `AGENTS.md` — Codex's actual custom-instruction file, read automatically at session start (`.codex/config.toml` controls CLI/sandbox behavior, not prompt content, and was never a valid target for this).
80
+
81
+ ### 5. Continue.dev (advisory only)
82
+ Continue's rules system reads individual Markdown files (with YAML frontmatter — `name`, `globs`, `alwaysApply`) from a `.continue/rules/` folder rather than one shared file, so the installer writes a dedicated `.continue/rules/harness.md` with `alwaysApply: true` instead of appending into an arbitrary pre-existing file. No hook/execution mechanism, same limits as Cursor. Global scope writes to `~/.continue/rules/harness.md`.
83
+
84
+ ### 6. Hermes Agent (advisory only)
85
+ [Hermes](https://hermes-agent.nousresearch.com/) (Nous Research) auto-injects project context into its system prompt from `.hermes.md`, `AGENTS.md`, `CLAUDE.md`, and `.cursorrules` if present in the directory it's launched from (truncated at ~20k chars) — meaning a Codex or Cursor install already reaches Hermes for free. The installer still writes a dedicated `.hermes.md` for explicit coverage. No hook/execution mechanism. Project scope only: Hermes has no documented global project-instructions equivalent (its own settings live under `~/.hermes/`, which governs model/terminal/skills config, not per-project behavior text), so `--global --hermes` is a deliberate no-op rather than a guess.
86
+
87
+ ---
88
+
89
+ ## Security Model & Data Locality
90
+
91
+ Harness runs with a **zero-trust, fully local security model**:
92
+
93
+ 1. **No External APIs:** Harness does not send telemetry, code snippets, or configuration files to external servers. All processing is done locally via native Node.js scripts.
94
+ 2. **Credential Protection:** Harness never asks for or stores API keys or secrets. If any terminal command prompts for a password, Harness's rules immediately direct the model to halt and request manual entry by the human partner.
95
+ 3. **Execution Gating:** The hook scripts are written in standard CommonJS, ensuring they compile and run fast (<200ms) to prevent blocking terminal operations.
@@ -0,0 +1,45 @@
1
+ # Harness Philosophy
2
+
3
+ Harness is built on a single, core belief: **AI coding models are highly capable, but they struggle with self-regulation, attention drift, and environment awareness.**
4
+
5
+ Instead of replacing the model or restricting it with heavy, opinionated frameworks that stifle creativity, Harness acts as a **behavioral runtime**—a lightweight, non-intrusive layer that guides, guards, and immunizes.
6
+
7
+ ---
8
+
9
+ ## The Core Philosophy: Intervene Only When Necessary
10
+
11
+ Many AI development frameworks attempt to fully control the model's execution flow. They use rigid DAGs, forced chains, or complex state machines. While this works for trivial, repetitive tasks, it destroys the model's creative problem-solving capability when tackling complex, novel engineering challenges.
12
+
13
+ Harness takes the opposite approach:
14
+
15
+ 1. **Model Autonomy is Paramount:** The model should have full freedom to explore, choose its tools, and design its solution.
16
+ 2. **Context-Driven Guidance:** Harness injects high-context, low-friction signals (via hooks, rules, and local preflight checks) rather than forcing rigid execution paths.
17
+ 3. **Reactive Guardrails:** Harness remains completely silent and out of the way until a critical failure state is detected (e.g., repeating the same error 3 times, or context bloat reaching a dangerous threshold).
18
+ 4. **Behavior-First, Not Prompt-First:** Harness is not a collection of static templates or "magic prompts." It is a dynamic runtime that reacts to terminal outcomes, git status, and actual workspace conditions.
19
+
20
+ ---
21
+
22
+ ## The 4 Pillars of AI Model Guidance
23
+
24
+ To keep agents aligned and productive, Harness operates across four distinct domains:
25
+
26
+ ### 1. Environment Alignment (Discovery over Assumption)
27
+ AI models often hallucinate terminal environments or make incorrect assumptions about the host operating system, shells, or package managers (especially on Windows or within sandboxed shells).
28
+ Harness forces a **Discovery** phase immediately upon session start. By auditing the environment beforehand, the model knows exactly what commands are safe to run, preventing wasted tokens on syntax trial-and-error.
29
+
30
+ ### 2. Guardrails (The Circuit Breakers)
31
+ When a model gets stuck on a subtle bug or compiler error, its natural tendency is to make micro-adjustments repeatedly (the "infinite loop of trial-and-error").
32
+ Harness implements a **Circuit Breaker** (the `Rule of 3`). If the exact same failure occurs three times, Harness halts execution and forces a "zoom out": the agent must rebuild the full picture and fact-check the assumptions behind its failed attempts before it may touch the code again. Most loops die right there, resolved by a fresh diagnosis. The human partner is asked to step in only when a genuine decision is on the table — a requirement conflict, an architecture trade-off, a destructive step — preserving both your token budget and your sanity.
33
+
34
+ ### 3. Context Preservation (Anti-Bloat Protection)
35
+ As sessions grow, models often read too many large files or run commands that generate massive output, causing severe "Lost in the Middle" attention degradation.
36
+ Harness acts as an informational dashboard that tracks active file counts and staging queues, proactively nudging the model to commit changes, clean the terminal, or compact its context.
37
+
38
+ ### 4. Self-Evolution (Continuous Workspace Memory)
39
+ When a complex issue is resolved, the model should never have to solve it again. Harness abstracts the underlying root cause and permanently saves it to local workspace rules. On subsequent sessions, the model immediately imports these lessons, preventing regression.
40
+
41
+ ---
42
+
43
+ ## A Non-Intrusive Cognitive Amplifier
44
+
45
+ Harness does not run a heavy daemon, send your code to third-party APIs, or lock you into a proprietary ecosystem. It runs entirely locally within your project, acting as a quiet guardian that ensures your AI sessions are efficient, secure, and successful.
@@ -0,0 +1,34 @@
1
+ # Harness Reflection, Memory & Self-Evolution
2
+
3
+ AI models are notorious for forgetting lessons learned in previous coding sessions. When a bug is solved, if the developer opens a new terminal or launches a new AI session, the agent may encounter the same environment quirks or framework gotchas and make the exact same mistakes again.
4
+
5
+ Harness solves this through its **Self-Evolution and Persistent Memory system**.
6
+
7
+ ---
8
+
9
+ ## The Transaction Log (WAL) & Session Handoff
10
+
11
+ Harness maintains a lightweight transaction log (analogous to a Write-Ahead Log in databases) via `hooks/scripts/state-persist.js`.
12
+
13
+ * **Continuous Capture:** Every successful tool use or milestone is recorded in the session transaction log.
14
+ * **Handoff File:** A session handoff checkpoint is saved in the workspace.
15
+ * **Session Start Recovery:** Upon starting a new session, the `bootstrap.js` hook reads the handoff file. It automatically "wakens" the agent, restoring the previous task state, completed milestones, and pending actions. This completely eliminates "session restart amnesia."
16
+
17
+ ---
18
+
19
+ ## Long-term Memory & Workspace Rules
20
+
21
+ When a complex issue—such as an environment-specific bug, a unique framework quirk, or a custom build command requirement—is successfully resolved:
22
+
23
+ 1. **Deep Reflection:** Harness triggers the `self-evolve` skill, directing the model to reflect on the root cause and extract the exact pattern.
24
+ 2. **Rule Generation:** The model abstracts the learning into a concise rule (avoiding generic prompt prose).
25
+ 3. **RULES.md Integration:** The rule is appended or merged into local workspace rules (usually under a `RULES.md` or a customized folder).
26
+ 4. **Self-Regression Validation:** Before any new rule is persisted, Harness executes the `self-regression.js` test suite. This ensures that the generated rules do not conflict with existing core rules and that all script syntax is 100% correct, preventing behavior decay.
27
+
28
+ ---
29
+
30
+ ## The Benefits of Self-Evolution
31
+
32
+ * **Immunization:** The workspace is permanently "immunized" against recurring bugs.
33
+ * **Team Alignment:** Because rules are checked into Git, every developer (and every AI agent they launch) immediately benefits from the shared, updated knowledge base.
34
+ * **Token Efficiency:** Rather than the user repeatedly reminding the AI about custom project structures or conventions, the agent reads them natively from the immunized RULES file.