# harness-engineer **Repository Path**: vince4win/harness-engineer ## Basic Information - **Project Name**: harness-engineer - **Description**: 依赖 Shell 工具链:声明式工作流编排、机械校验闸门、跨会话状态连续性。 - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: main - **Homepage**: https://gitee.com/vince4win/harness-engineer - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-07-11 - **Last Updated**: 2026-09-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: Harness, Agent ## README > 🌐 **Languages**: **English** | [简体中文](./docs/i18n/README.zh-CN.md) # Harness Engineer > Zero-dependency toolkit that gives coding agents structured state, mechanical enforcement, and cross-session continuity. > > **Current version: [4.1.7](./CHANGELOG.md)** — see [CHANGELOG.md](./CHANGELOG.md) for the full release history. ## Quick Start **Install into your project (one command):** ```bash curl -fsSL https://gitee.com/vince4win/harness-engineer/raw/main/install.sh | bash -s -- /your/project ``` **That's it.** Your coding agent now has: - `AGENTS.md` — project context, rules, and a 5-step work cycle it reads every session (project root) - `harness/feature-list.json` — what to build next (prioritized, verifiable) - `harness/progress.md` — what was done last session - `init.sh` — health-check wrapper → `harness/init.sh` (runs at session start) **How your agent uses it (automatically):** 1. Reads `AGENTS.md` → learns project context + rules 2. Reads `progress.md` → picks up where the last session left off 3. Reads `feature-list.json` → finds the next feature to implement 4. Runs `./init.sh` → verifies the environment is healthy 5. Implements one feature, self-verifies, marks it done Works with: ZCode, Claude Code, Cursor, OpenCode, Codex, TraeCN, Pi, and any agent that reads `AGENTS.md`. Per-host starter configurations (including a generic pack for other agents) ship in [`starter-packs/`](./starter-packs/). --- ## What Is This? Harness Engineer is a **toolkit**, not a framework you import. It gives you: - **Structured state** — `AGENTS.md` + `harness/feature-list.json` + `harness/progress.md` + `init.sh`. Four entry points that make your agent stateless-but-coherent across sessions, with all machinery contained in `harness/` (installed shape; this dev repo mirrors files at root for self-dogfooding). - **Mechanical enforcement** — architecture rules encoded as lint checks, not prose instructions the agent might ignore. - **Zero runtime dependencies** — files, markdown, and shell scripts. Any agent environment can consume it. - **Progressive disclosure** — agents see only what they need (5 core files). Advanced capabilities (workflows, evals, multi-agent orchestration) are opt-in. - **Context lifecycle control** (`context-pipeline.sh`) — collect→manage→compress→inject: page bulky artifacts into a hash-chunk store behind stable pointers with mechanically proven lossless round-trips; `fetch` dereferences pointers, `monitor` raises assumption-tagged alerts (see [docs/context-management.md](./docs/context-management.md), benchmark report under `docs/reports/2026-08-27-context-bench/`). - **Lifecycle integrity charter** (install / update / uninstall / reinstall) — knowledge documents are never silently lost: user-modified copies are preserved into `harness/preserved/` before removal and offered back on reinstall; containment keeps exactly one functional root file (`AGENTS.md`) with everything else under `harness/` ([docs/lifecycle-design.md](./docs/lifecycle-design.md), FEAT-035). ## Core Equation ``` Agent = Model + Harness ``` The harness is everything that isn't the model. Harness changes alone can improve benchmark scores by 10+ points without changing the model. See [Methodology](./docs/methodology.md) for the full theory. ## How It Works ### 1. Workflows Define the Process YAML workflow files describe every phase, who acts (human/planner/generator/evaluator), what steps run, what gets produced, and what quality gates must pass before advancing. - [workflows/greenfield-workflow.yaml](./workflows/greenfield-workflow.yaml) — new projects, full Planner→Generator→Evaluator loop - [workflows/brownfield-workflow.yaml](./workflows/brownfield-workflow.yaml) — existing codebases, gradual adoption (audit first, then one harness component at a time) ### 2. Frontmatter Markdown Carries State and Intent All harness artifacts are markdown or JSON with explicit structure, parseable by both humans and agents: | File | Purpose | Format | |---|---|---| | `AGENTS.md` | Agent's map — always loaded, <150 lines, links to deeper docs | Markdown | | `init.sh` | Thin root wrapper → `harness/init.sh` (keeps the `./init.sh` ritual) | Shell | | `harness/feature-list.json` | Structured feature tracking with pass/fail gates | JSON | | `harness/progress.md` | Cross-session handoff log | Markdown | | `harness/init.sh` | Deterministic bootstrap (idempotent, runs every session) | Shell | | `harness/capabilities.yaml` | Capability registry (skills/MCPs + `source: native\|harness\|external`) | YAML | | `harness/agents/*.md` | System prompts for Planner/Generator/Evaluator/Challenger | Markdown with frontmatter | | `harness/evals/rubric.md` | Concrete, gradable scoring criteria + adversarial round protocol | Markdown | | `harness/scripts/*.sh` | Enforcement scripts (verify-feature, arch-check, capability-guard) | Shell with frontmatter | | `harness/docs/*.md` | Architecture, conventions, testing guide, design tokens | Markdown | > **Install layout:** everything the harness installs lives under one `harness/` > directory. The project root keeps only the two agent-facing entry points: > `AGENTS.md` (auto-loaded by every agent) and `init.sh` (a thin wrapper). > Your project's own files — `README.md`, `.gitignore`, `src/`, your > `docs/` — stay at the root, clearly separated from the harness. ### 3. Skills, Plugins, and MCPs Are Orchestrated, Not Ad-Hoc Agent environments come with built-in capabilities (browser tools, code search, file editing, shell access, MCP servers). Harness Engineer doesn't replace them — it **declares when and how they are used** within the workflow: - **Tool scoping per phase**: Planner gets research/browser tools; Generator gets file/edit/shell tools; Evaluator gets test/browser verification tools - **MCP servers are declared in the harness**, not left for the agent to discover randomly - **Skills are mapped to workflow steps**: e.g., "step 3 verify → use browser automation skill", "phase 1 architecture → use codebase analysis skill" - **Tool responses are token-optimized** by the harness — irrelevant tools are masked, responses are compressed - **Unified tools index** (`tools-index.md`, built by `scripts/build-tools-index.sh`) merges agent-native, harness-supplement, and external tools into one registry injected into agent prompts at phase 0 ### 4. Maturity Levels (0–5) | Level | Stage | You Have | |---|---|---| | 0 | Raw Prompting | Single prompt, no structure | | 1 | Instruction File | `AGENTS.md` | | 2 | Structured State | `harness/feature-list.json` + `harness/progress.md` + `init.sh` | | 3 | Mechanical Enforcement | arch-check linting, CI gates, sandboxing | | 4 | Multi-Agent Orchestration | Planner/Generator/Evaluator/Challenger via workflow YAML | | 5 | Self-Improving | Trace-driven Observe→Analyze→Suggest→Change→Validate→Record loop | ### 5. How Harness Participates in Agent Execution Harness does **not** install hooks, inject code, or intercept the agent's runtime. It produces files that the agent's native behavior picks up. The participation model has five layers: ``` ┌─────────────────────────────────────────────────────────────────┐ │ Layer 0: Agent native behavior (host runner) │ │ Trae / Claude Code / Cursor / OpenCode all auto-load an │ │ instructions file (AGENTS.md, CLAUDE.md) at session start. │ │ Harness does NOT inject code or intercept the agent runtime — │ │ its job is to produce the files that get loaded. The one │ │ exception (FEAT-025): an OPTIONAL capture hook registers itself │ │ into the host's workspace hook config (init.sh → .zcode/ │ │ config.json) — only when that host config already exists, so a │ │ generic install never creates agent-specific directories. It is │ │ fail-open, records nothing sensitive, and the host still │ │ drives everything. │ └─────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────────┐ │ Layer 1: Entry map (AGENTS.md) │ │ scaffold.sh fills {{PLACEHOLDERS}} and writes AGENTS.md │ │ to the project root; all other harness files go under harness/. │ │ The agent reads it → learns project name, tech stack, rules. │ │ Hard limit: 150 lines — deep content lives in harness/docs/. │ └─────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────────┐ │ Layer 2: State recovery (harness/feature-list.json + progress) │ │ Agents are stateless across sessions. Two files restore context:│ │ - harness/feature-list.json: roadmap state (per-feature passes) │ │ - harness/progress.md: last session's work + what to do next │ │ Convention: agent reads these at startup (stated in workflow │ │ session_startup block + progress.md header). Not hook-enforced. │ └─────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────────┐ │ Layer 3: Orchestration declaration (workflows/*.yaml) │ │ The YAML declares phases (0–5), roles (Planner/Generator/ │ │ Evaluator/Challenger), steps, and quality gates per phase. │ │ │ │ Two consumers: │ │ 1. run-workflow.sh — mechanically parses the YAML, runs quality │ │ gates via shell exec, blocks advancement on failure, persists│ │ current phase to .harness-workflow-state.json for --resume. │ │ 2. The agent — reads the step descriptions and role assignments │ │ to know what to do; the harness enforces the gates. │ └─────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────────┐ │ Layer 4: Mechanical execution (scripts/*.sh) │ │ The workflow directs the agent to run scripts at specific nodes:│ │ │ │ Toolkit-internal (run on the toolkit repo itself): │ │ - init.sh → environment self-check (run at startup) │ │ - verify-harness.sh → full self-check (frontmatter, YAML, CI) │ │ - run-workflow.sh → phase driver (gate enforcement + roles) │ │ │ │ Scaffolded to target projects (via templates/ci/): │ │ - verify-feature.sh → build/lint/test gate after feature done │ │ - arch-check.sh → architecture rule lint (reads docs/) │ │ - capability-guard.sh → blocks undeclared capability calls │ │ Installed under harness/scripts/, invoked as ./harness/scripts/x │ │ These are real executable scripts — the agent shell-execs them. │ └─────────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────────┐ │ Layer 5: Capability registry (capabilities.yaml) │ │ Declares available tools with source classification: │ │ - native: agent built-in (code-search, file-edit, shell) │ │ - external: MCP servers / plugins (browser-automation) │ │ - harness: supplement wrappers (git-pipeline, feature-toggle)│ │ - harness-sysop: toolkit ops scripts (run-evals, run-workflow) │ │ │ │ capability-guard.sh reads this to gate undeclared tool calls. │ │ workflow_guidance (advisory, keyed by role) tells the agent │ │ when each tool is appropriate — not mechanically enforced. │ └─────────────────────────────────────────────────────────────────┘ ``` **Key principle:** the harness never injects code into the agent runtime. Every layer is a file the agent reads or a script it runs — the agent's native behavior does the rest. ## Installation ### Option A — One-Liner Bootstrap (Recommended) Install Harness Engineer into your project with a single command — no clone needed: ```bash # bash / Git Bash / WSL curl -fsSL https://gitee.com/vince4win/harness-engineer/raw/main/install.sh | bash -s -- /your/project ``` The bootstrap script clones the toolkit to a temp directory, runs `scaffold.sh`, then cleans up. Zero dependencies beyond `git` (bash). ### Option B — Scaffold (from a local clone) ```bash # Interactive (prompts for project name, stack, etc.) ./scripts/scaffold.sh [target_dir] # Non-interactive (for CI, agents, or scripting) ./scripts/scaffold.sh /your/project --name "My App" --stack "React, TypeScript" --desc "A todo app" # Core only (default — AGENTS.md + init.sh wrapper + harness/ enforcement scripts + essential docs) ./scripts/scaffold.sh /your/project --core # Full install (adds workflows, agent prompts, evals, operational templates) ./scripts/scaffold.sh /your/project --full ``` **--core (default)** installs what your agent needs for daily work: `AGENTS.md` + `init.sh` at the root, and `harness/` containing `feature-list.json`, `progress.md`, the real `init.sh`, `verify-feature.sh`, `arch-check.sh`, `check-feature-integrity.js`, essential docs, and rules. ~20 files. **--full** adds everything: multi-agent prompts (Planner/Generator/Evaluator/Challenger), eval pipeline, improvement logs, capability registry templates, operational templates. 35 files total. **Properties:** - **Idempotent** — existing files are never overwritten; re-running preserves your customizations. - **Zero-dependency** — POSIX shell + `sed` (bash). No Node, Python, or package manager required for core files. - **Non-interactive** — all prompts have flag/env-var alternatives (`--name`, `--desc`, `--stack`, `--phase` or `HARNESS_PROJECT_NAME` etc.). ### Option C — Manual Copy ``` 1. Copy templates/core/AGENTS.md → project root; templates/core/init-root.sh → ./init.sh 2. Copy everything else from templates/ + starter-packs/ → your project harness/ 3. Fill in {{PLACEHOLDERS}} manually 4. chmod +x init.sh harness/scripts/*.sh 5. Run ./init.sh, commit the harness ``` ### After Install 1. `cd ` 2. `git init && git add . && git commit -m "chore: scaffold harness engineering infrastructure"` 3. Customize `harness/init.sh` — uncomment your package manager and build/test/lint commands 4. Run `./init.sh` to verify the bootstrap works (must exit 0) 5. Start the Planner agent to generate `harness/feature-list.json` and `harness/docs/architecture.md` --- ## Uninstallation Reverse the scaffold cleanly — only the known harness file manifest is deleted; your project source and customizations are never touched. ```bash # One-liner (no clone needed) curl -fsSL https://gitee.com/vince4win/harness-engineer/raw/main/uninstall.sh | bash -s -- [target_dir] [--force] # Or from a local clone — bash / Git Bash / WSL ./scripts/harness-uninstall.sh [target_dir] [--force] ``` **What gets deleted:** - Scaffolded files (read from `.harness-manifest.json` install record, or `templates/manifest.json` as fallback) — only files that were actually installed (core or full depending on your install mode) - Install record: `.harness-manifest.json` - Auto-generated artifacts: `*.resolved.md`, `tools-index.md`, `.harness-workflow-state.json` - Hook registration: `.zcode/config.json` (removed when it contains the harness capture hook) - Transient directories: `.harness-snapshots/`, `eval-results/` - Empty directories are removed recursively depth-first (`harness/` incl. `docs/rules/` + `docs/memory/`, `scripts/`, `agents/`, `evals/`, `operational/`, `state/`, `.zcode/`) — any user file anywhere keeps its tree with a `[KEEP]` notice. **Safety:** only paths in the install record or source manifest are ever deleted. User files, project source, and non-empty directories are never touched. `--force` skips the `[y/N]` confirmation prompt. --- ## Updating When the toolkit releases a new version, update your installed harness files without losing customizations: ```bash # One-liner (no clone needed) curl -fsSL https://gitee.com/vince4win/harness-engineer/raw/main/update.sh | bash -s -- [target_dir] [--force] # Or from a local clone — bash / Git Bash / WSL ./scripts/harness-update.sh [target_dir] [--force] ``` The update script reads `.harness-manifest.json` (written by `scaffold` at install time) and classifies each file by comparing content hashes: | Classification | Condition | Action | |---|---|---| | **PRISTINE** | Current file hash matches install record | Safe overwrite to new version | | **MODIFIED** | Current file hash differs from install record | Interactive: view diff, keep/overwrite/backup/skip | | **MISSING** | File not found | Install fresh from template | **For MODIFIED files**, you choose per-file: - `[d]` View diff — see what changed between your version and the new template - `[k]` Keep mine — preserve your customizations - `[o]` Overwrite — replace with new version (your changes lost) - `[b]` Backup + Overwrite — save `.bak` then overwrite - `[s]` Skip — defer this file `--force` skips the same-version check and forces re-evaluation of all files. MODIFIED files always prompt regardless of `--force`. > **Requirement:** `.harness-manifest.json` must exist (created by `scaffold`). Projects installed before FEAT-023 need to re-run `scaffold` to generate the record before `harness-update` can be used. --- ## Quick Start ### Greenfield (New Project) After [Installation](#installation), follow `workflows/greenfield-workflow.yaml`: ``` Phase 0 (scaffold) → Phase 1 (Planner) → Phase 2 (Generator loop) → Phase 3 (Evaluator + 3-round Challenger) → Phase 4 (trace-driven improvement) ``` Estimated time to first working feature: **2–3 hours**. ### Brownfield (Existing Codebase) ``` 1. AUDIT first (brownfield-workflow.yaml Phase 0 checklist) 2. Week 1: Add AGENTS.md + harness/feature-list.json (from existing tickets, top 5–10 only) 3. Week 2: Add harness/progress.md + adapt harness/init.sh to your existing commands 4. Week 3: Add harness/scripts/arch-check.sh for rules ALREADY agreed upon but unenforced 5. Week 4+: Add multi-agent prompts only when Phases 1–3 are stable ``` **Rule for brownfield**: document what exists; don't restructure, don't add aspirational rules, don't create parallel pipelines. ## Key Principles 1. **Zero dependencies** — the harness runs on files, markdown, JSON, and shell. No runtime, no framework to install. 2. **Mechanical enforcement over instructions** — if it must always be true, make it impossible to violate (lint, sandbox, CI), don't just ask the model nicely. 3. **Map, not manual** — `AGENTS.md` < 150 lines; link to deeper docs. 4. **JSON over Markdown for state** — structured data is less prone to model corruption. 5. **Verify before declaring done** — every feature has verification steps; all must pass before `passes: true`. 6. **Frequent intentional compaction** — write state to filesystem; don't let context bloat. 7. **Start simple** — add complexity only when specific failure modes are observed. 8. **Unified capability orchestration** — skills, plugins, MCPs are declared in the harness and scoped per workflow phase, not ad-hoc. Harness tools supplement agent-native tools, never replace them. 9. **Never trust the first response** — every Evaluator PASS is subjected to 3-round adversarial challenge by an independent Challenger agent (implementation correctness → grading sufficiency → alternative paths) before the final score is locked. ## Bibliography Synthesized from 15+ sources including OpenAI, Anthropic, LangChain, Thoughtworks, HumanLayer, Manus, Inngest, and OpenHands. Full list in [HARNESS-ENGINEERING-HANDBOOK.md §14](./docs/raw/HARNESS-ENGINEERING-HANDBOOK.md#14-source-bibliography). ## License Dual-licensed under **AGPL v3** (open-source, free) and a **Commercial License**. - **Open-source use** — [AGPL v3](./LICENSE). Free for personal use, open-source projects, and evaluation. All code that interacts with this software over a network must also be open-sourced under AGPL v3. - **Commercial use** — [Commercial License](./COMMERCIAL-LICENSE.md). Required for closed-source products, proprietary SaaS, or any scenario where you cannot comply with AGPL v3 disclosure obligations. Contact the copyright holder to arrange terms. | Use Case | License | |---|---| | Personal / open-source project | AGPL v3 (free) | | Closed-source commercial product | Commercial License | | Proprietary SaaS / cloud service | Commercial License | See [COMMERCIAL-LICENSE.md](./COMMERCIAL-LICENSE.md) for details.