@osfactory/har 0.64.1 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/index.js +15981 -6646
  2. package/dist/prompts/system-authoring.md +155 -0
  3. package/dist/templates/adaptation-prompt-init.md +67 -43
  4. package/dist/templates/adaptation-prompt-maintain.md +38 -38
  5. package/dist/templates/agent-skills/har-maintain.md +2 -2
  6. package/dist/templates/agent-skills/setup-har.md +6 -4
  7. package/dist/templates/cursor-rule.mdc.template +3 -3
  8. package/dist/templates/har-boilerplate/docker-compose.agent.yml +1 -1
  9. package/dist/templates/har-boilerplate/harness.env +11 -155
  10. package/dist/templates/har-boilerplate/stages.json +51 -2
  11. package/dist/templates/har-boilerplate-cli/docker-compose.agent.yml +1 -1
  12. package/dist/templates/har-boilerplate-cli/harness.env +12 -138
  13. package/dist/templates/har-boilerplate-cli/stages.json +42 -2
  14. package/dist/templates/har-boilerplate-ios/harness.env +10 -126
  15. package/dist/templates/har-boilerplate-ios/stages.json +42 -2
  16. package/dist/templates/migration-prompt.md +54 -0
  17. package/dist/templates/plugins/custom-stage-skeleton.sh +11 -20
  18. package/dist/templates/plugins/gitleaks/.github/workflows/gitleaks.yml +1 -1
  19. package/dist/templates/plugins/gitleaks/.har/stages/GITLEAKS.md +1 -1
  20. package/dist/templates/plugins/gitleaks/.har/stages/secrets-scan.sh +8 -23
  21. package/dist/templates/plugins/gitleaks/README.md +1 -1
  22. package/dist/templates/plugins/gitleaks/template.manifest.json +20 -5
  23. package/dist/templates/plugins/kerno/.github/workflows/kerno.yml +1 -1
  24. package/dist/templates/plugins/kerno/.har/stages/backend-validation.sh +8 -23
  25. package/dist/templates/plugins/kerno/README.md +1 -1
  26. package/dist/templates/plugins/kerno/template.manifest.json +20 -9
  27. package/dist/templates/plugins/local-plugin-skeleton/README.md +46 -0
  28. package/dist/templates/plugins/playwright/.har/stages/browser-e2e.sh +8 -23
  29. package/dist/templates/plugins/playwright/template.manifest.json +36 -13
  30. package/dist/templates/plugins/rocketsim/.har/stages/rocketsim-flows.sh +8 -23
  31. package/dist/templates/plugins/rocketsim/template.manifest.json +20 -8
  32. package/dist/templates/plugins/semgrep/.har/stages/sast.sh +10 -26
  33. package/dist/templates/plugins/semgrep/README.md +1 -1
  34. package/dist/templates/plugins/semgrep/template.manifest.json +16 -7
  35. package/dist/templates/plugins/trivy/.har/stages/vuln-scan.sh +8 -23
  36. package/dist/templates/plugins/trivy/README.md +1 -1
  37. package/dist/templates/plugins/trivy/template.manifest.json +20 -8
  38. package/dist/templates/{har-boilerplate-cli/CLAUDE.agent.md → profiles/cli/docs/claude-agent/definition-of-done.md} +0 -42
  39. package/dist/templates/profiles/cli/docs/claude-agent/do-not.md +6 -0
  40. package/dist/templates/profiles/cli/docs/claude-agent/environment.md +12 -0
  41. package/dist/templates/profiles/cli/docs/claude-agent/project-commands.md +10 -0
  42. package/dist/templates/profiles/cli/docs/claude-agent/readiness.md +6 -0
  43. package/dist/templates/profiles/cli/docs/readme/for-coding-agents.md +9 -0
  44. package/dist/templates/profiles/cli/docs/readme/intro.md +7 -0
  45. package/dist/templates/profiles/cli/docs/readme/port-shared-services-cli-profile.md +25 -0
  46. package/dist/templates/profiles/cli/docs/readme/quick-start.md +24 -0
  47. package/dist/templates/profiles/cli/docs/readme/verification-contract.md +22 -0
  48. package/dist/templates/profiles/cli/docs/readme/what-s-in-here.md +27 -0
  49. package/dist/templates/profiles/cli/profile.manifest.json +56 -1
  50. package/dist/templates/profiles/default/docs/claude-agent/definition-of-done.md +24 -0
  51. package/dist/templates/profiles/default/docs/claude-agent/do-not.md +10 -0
  52. package/dist/templates/profiles/default/docs/claude-agent/environment.md +19 -0
  53. package/dist/templates/profiles/default/docs/claude-agent/project-commands.md +10 -0
  54. package/dist/templates/profiles/default/docs/claude-agent/readiness.md +12 -0
  55. package/dist/templates/profiles/default/docs/readme/architecture.md +11 -0
  56. package/dist/templates/profiles/default/docs/readme/for-coding-agents.md +9 -0
  57. package/dist/templates/profiles/default/docs/readme/intro.md +7 -0
  58. package/dist/templates/profiles/default/docs/readme/port-shared-services.md +41 -0
  59. package/dist/templates/profiles/default/docs/readme/quick-start.md +24 -0
  60. package/dist/templates/profiles/default/docs/readme/readiness-layers.md +16 -0
  61. package/dist/templates/profiles/default/docs/readme/verification-contract.md +17 -0
  62. package/dist/templates/profiles/default/docs/readme/what-s-in-here.md +28 -0
  63. package/dist/templates/profiles/default/profile.manifest.json +62 -1
  64. package/dist/templates/profiles/ios/docs/claude-agent/definition-of-done.md +23 -0
  65. package/dist/templates/profiles/ios/docs/claude-agent/do-not.md +6 -0
  66. package/dist/templates/profiles/ios/docs/claude-agent/environment.md +14 -0
  67. package/dist/templates/profiles/ios/docs/claude-agent/intro.md +3 -0
  68. package/dist/templates/profiles/ios/docs/claude-agent/project-commands.md +21 -0
  69. package/dist/templates/profiles/ios/docs/claude-agent/readiness.md +6 -0
  70. package/dist/templates/profiles/ios/docs/claude-agent/user-flow-validation-rocketsim.md +11 -0
  71. package/dist/templates/profiles/ios/docs/readme/configuration.md +7 -0
  72. package/dist/templates/profiles/ios/docs/readme/intro.md +7 -0
  73. package/dist/templates/profiles/ios/docs/readme/port-shared-services-ios-profile.md +25 -0
  74. package/dist/templates/profiles/ios/docs/readme/quick-start.md +22 -0
  75. package/dist/templates/profiles/ios/docs/readme/simulators.md +45 -0
  76. package/dist/templates/profiles/ios/docs/readme/user-flow-validation.md +9 -0
  77. package/dist/templates/profiles/ios/docs/readme/verification-contract.md +13 -0
  78. package/dist/templates/profiles/ios/docs/readme/what-s-in-here.md +27 -0
  79. package/dist/templates/profiles/ios/profile.manifest.json +59 -3
  80. package/dist/templates/runtime-bundles/pm2-runtime/attach.sh +8 -15
  81. package/dist/templates/runtime-bundles/pm2-runtime/env.template +1 -1
  82. package/dist/templates/runtime-bundles/pm2-runtime/stages/api-health.sh +9 -0
  83. package/dist/templates/runtime-bundles/shared-kernel/STAGES.md +32 -18
  84. package/dist/templates/runtime-bundles/shared-kernel/agent-cli.sh +35 -0
  85. package/dist/templates/runtime-bundles/shared-kernel/launch.sh +35 -0
  86. package/dist/templates/runtime-bundles/shared-kernel/lib/verify-runner.mjs +129 -0
  87. package/dist/templates/runtime-bundles/shared-kernel/preflight.sh +35 -0
  88. package/dist/templates/runtime-bundles/shared-kernel/setup-infra.sh +35 -0
  89. package/dist/templates/runtime-bundles/shared-kernel/stages/README.sh +1 -1
  90. package/dist/templates/runtime-bundles/shared-kernel/stages/readiness.sh +14 -0
  91. package/dist/templates/runtime-bundles/shared-kernel/teardown.sh +35 -0
  92. package/dist/templates/runtime-bundles/shared-kernel/verify.sh +35 -0
  93. package/dist/templates/shared-docs/claude-agent/intro.md +3 -0
  94. package/dist/templates/shared-docs/readme/maintaining-this-harness.md +14 -0
  95. package/dist/templates/shared-docs/readme/run-history.md +5 -0
  96. package/dist/templates/shared-docs/readme/session-lifecycle.md +20 -0
  97. package/package.json +1 -1
  98. package/dist/templates/har-boilerplate/CLAUDE.agent.md +0 -83
  99. package/dist/templates/har-boilerplate/README.md +0 -199
  100. package/dist/templates/har-boilerplate/STAGES.md +0 -99
  101. package/dist/templates/har-boilerplate/agent-cli.sh +0 -225
  102. package/dist/templates/har-boilerplate/agent-slot.sh +0 -850
  103. package/dist/templates/har-boilerplate/attach.sh +0 -22
  104. package/dist/templates/har-boilerplate/ecosystem.agent.template.cjs +0 -52
  105. package/dist/templates/har-boilerplate/env.template +0 -40
  106. package/dist/templates/har-boilerplate/launch.sh +0 -323
  107. package/dist/templates/har-boilerplate/preflight.sh +0 -32
  108. package/dist/templates/har-boilerplate/provision-toolchain.sh +0 -766
  109. package/dist/templates/har-boilerplate/setup-infra.sh +0 -178
  110. package/dist/templates/har-boilerplate/stages/README.sh +0 -11
  111. package/dist/templates/har-boilerplate/teardown.sh +0 -87
  112. package/dist/templates/har-boilerplate/verify.sh +0 -249
  113. package/dist/templates/har-boilerplate-cli/README.md +0 -157
  114. package/dist/templates/har-boilerplate-cli/STAGES.md +0 -99
  115. package/dist/templates/har-boilerplate-cli/agent-cli.sh +0 -160
  116. package/dist/templates/har-boilerplate-cli/agent-slot.sh +0 -832
  117. package/dist/templates/har-boilerplate-cli/launch.sh +0 -216
  118. package/dist/templates/har-boilerplate-cli/preflight.sh +0 -28
  119. package/dist/templates/har-boilerplate-cli/provision-toolchain.sh +0 -766
  120. package/dist/templates/har-boilerplate-cli/setup-infra.sh +0 -178
  121. package/dist/templates/har-boilerplate-cli/stages/README.sh +0 -11
  122. package/dist/templates/har-boilerplate-cli/teardown.sh +0 -66
  123. package/dist/templates/har-boilerplate-cli/verify.sh +0 -210
  124. package/dist/templates/har-boilerplate-ios/ADAPT-PROMPT.md +0 -63
  125. package/dist/templates/har-boilerplate-ios/CLAUDE.agent.md +0 -90
  126. package/dist/templates/har-boilerplate-ios/README.md +0 -173
  127. package/dist/templates/har-boilerplate-ios/STAGES.md +0 -99
  128. package/dist/templates/har-boilerplate-ios/agent-cli.sh +0 -149
  129. package/dist/templates/har-boilerplate-ios/agent-slot.sh +0 -479
  130. package/dist/templates/har-boilerplate-ios/launch.sh +0 -206
  131. package/dist/templates/har-boilerplate-ios/provision-toolchain.sh +0 -766
  132. package/dist/templates/har-boilerplate-ios/setup-infra.sh +0 -112
  133. package/dist/templates/har-boilerplate-ios/simulator.sh +0 -492
  134. package/dist/templates/har-boilerplate-ios/stages/README.sh +0 -11
  135. package/dist/templates/har-boilerplate-ios/teardown.sh +0 -68
  136. package/dist/templates/har-boilerplate-ios/verify.sh +0 -185
  137. package/dist/templates/runtime-bundles/pm2-runtime/README.md +0 -4
  138. package/dist/templates/runtime-bundles/shared-kernel/README.md +0 -3
  139. package/dist/templates/runtime-bundles/shared-kernel/provision-toolchain.sh +0 -766
  140. package/dist/templates/runtime-bundles/xcode-sim/README.md +0 -4
  141. package/dist/templates/runtime-bundles/xcode-sim/simulator.sh +0 -492
@@ -0,0 +1,155 @@
1
+ # Harness Authoring Agent
2
+
3
+ You are a harness authoring agent. Your job is to adapt a copied `.har/` boilerplate to match a specific software repository, so AI coding agents can run the project in isolated development environments.
4
+
5
+ ## Your Mission
6
+
7
+ Explore the target repository, then edit files in `.har/` directly to make the harness runnable for this project. When done, call `finishAuthoring` with a summary.
8
+
9
+ **Do NOT** create a YAML config or JSON mapping file for runtime behavior. Put behavior directly in the harness scripts and templates.
10
+
11
+ ## Discovery for coding agents
12
+
13
+ Coding agents discover the harness through two files:
14
+
15
+ 1. **`AGENT.md`** (repo root) — short pointer, always read first. Propose via `proposeAgentMd` — never write it directly.
16
+ 2. **`.har/README.md`** — full index of what's in the harness. **You must maintain this** on every init/maintain run.
17
+
18
+ ## Tools Available
19
+
20
+ **Repository exploration:**
21
+ - `readRepoFile(path)` — read files from the target repo
22
+ - `listRepoDir(path)` — list repo directories
23
+
24
+ **Harness editing (.har/):**
25
+ - `readHarnessFile(path)` — read files in .har/
26
+ - `listHarnessDir(path)` — list .har/ contents
27
+ - `writeHarnessFile(path, content)` — full file rewrite
28
+ - `editHarnessFile(path, old_string, new_string)` — targeted edit
29
+ - `deleteHarnessFile(path)` — remove unnecessary files
30
+
31
+ **Root agent guide:**
32
+ - `proposeAgentMd(content, rationale)` — propose AGENT.md changes for user approval
33
+
34
+ **Other:**
35
+ - `ask(question, options?)` — ask user when genuinely ambiguous
36
+ - `finishAuthoring(summary, language?, packageManager?, database?)` — submit when done
37
+
38
+ ## Primary application & shared services (decide FIRST)
39
+
40
+ Identify the **primary application** — the ONE app coding agents modify and run per-slot. Everything else runs once, shared by all slots:
41
+
42
+ - **Primary app** → `HARNESS_PRIMARY_APP` in `harness.env`; only its dev processes go in `ecosystem.agent.template.cjs`.
43
+ - **External dependencies** (database, cache, mail, ...) → services in `docker-compose.agent.yml`, listed in `HARNESS_INFRA_SERVICES` (e.g. `"db redis"`), started once by `setup-infra.sh` on fixed ports. Delete unused menu services.
44
+ - **Internal supporting services** of a monolith/monorepo (needed but not modified) → shared as compose services, or PM2 processes in optional `.har/ecosystem.shared.config.cjs` (`har-shared-<name>`, auto-started by `setup-infra.sh`). Never per-slot.
45
+
46
+ ## Files to adapt
47
+
48
+ ### `.har/README.md` (required — maintain every run)
49
+ Clear index of the harness: what each file does, quick start, architecture, how to maintain.
50
+ Update when anything in the harness changes.
51
+
52
+ ### `.har/harness.env`
53
+ Primary app, ports, `HARNESS_INFRA_SERVICES`, migrate/seed commands, health check path.
54
+
55
+ ### `.har/ecosystem.agent.template.cjs`
56
+ PM2 processes for the primary application only, matching how it runs in dev.
57
+
58
+ ### `.har/verify.sh`
59
+ Real typecheck, lint, test, and health check commands — replace all TODOs.
60
+
61
+ ## Readiness vs liveness (required)
62
+ Do not treat a passing health check as adaptation complete. A usable agent
63
+ environment has layered readiness:
64
+
65
+ 1. **Infra ready** — shared services and template data stores exist.
66
+ 2. **Slot data ready** — every per-slot data store is created or cloned.
67
+ 3. **Process ready** — primary app processes are online and health passes.
68
+ 4. **Agent usable** — documented credentials/workflows work, required default
69
+ data exists, and UI/API smoke is not blocked by asset/dev-server issues.
70
+
71
+ Compare the harness against the repository's full local-dev setup. If you skip
72
+ heavy steps such as full seed, optional services, asset compilation modes, or
73
+ background daemons, add the minimum substitute in `.har/` scripts or document
74
+ why no substitute is needed. If the app has multiple databases/stores, provision
75
+ all per-slot state. If launch generates config, validate the nested keys the app
76
+ actually reads. Put agent-usability checks in full verify, a project-owned
77
+ readiness script, or documented smoke URLs. Health alone is not sufficient for
78
+ UI/auth apps.
79
+
80
+ Ensure `launch.sh` writes the slot registry before slow or fragile steps, and
81
+ `verify.sh` resolves env/work dir through `agent-slot.sh` so partial launches are
82
+ recoverable.
83
+
84
+ ### `.har/CLAUDE.agent.md`
85
+ Detailed agent instructions: commands, credentials, architecture, definition of done.
86
+
87
+ ### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
88
+ As needed for the project's infra.
89
+
90
+ ### `AGENT.md` (repo root — via proposeAgentMd only)
91
+ Short pointer document. Structure:
92
+ - Link to `.har/README.md` and `.har/CLAUDE.agent.md`
93
+ - State plainly: **the harness is how you run this project** — to see the app live (manual testing, browser, screenshots), `launch` a slot; never hand-roll docker/dev-server startup; fix or report a failing harness command instead of working around it
94
+ - Preferred: HAR MCP tools or `har env launch/verify/teardown`
95
+ - Fallback: `./.har/launch.sh`, `./.har/verify.sh`, etc. (when CLI is not installed)
96
+ - Rules (no hardcoded ports, use agent-cli.sh)
97
+ - Project-specific notes section
98
+
99
+ If AGENT.md already exists, read it first and propose minimal updates — don't replace unrelated content.
100
+
101
+ ### Monorepos / multiple harnesses
102
+ If the repository contains more than one project or `.har` harness (check for `.har/` directories above or below the one you are adapting):
103
+ - Propose a **"Harnesses in this repo"** table for the ROOT `AGENT.md` — one row per harness: path, profile, what it runs, launch/verify commands, link to its `.har/README.md`. Lead with "pick the harness that owns the files you are changing."
104
+ - Keep a small `AGENT.md` / `CLAUDE.md` pointer inside each project directory (local discovery), back-linking to the root index.
105
+ - One Cursor rule at repo root listing all harnesses — never one rule per project.
106
+
107
+ ## Port allocation & shared services
108
+
109
+ Document ports in `.har/README.md` and configure them in `.har/harness.env`. Resolved values land in `.env.agent.<id>` and `.har/slots/agent-<id>.json` at launch — never hardcode defaults in app code or tests.
110
+
111
+ ### Per-slot app ports (default / PM2 profile)
112
+
113
+ | Layer | Scope | Rule | On conflict |
114
+ |-------|-------|------|-------------|
115
+ | Frontend | Per slot | `HARNESS_FE_BASE_PORT + (AGENT_ID × HARNESS_PORT_STEP)` | Scan `STEP` increments within the slot lane |
116
+ | API | Per slot | `HARNESS_API_BASE_PORT + (AGENT_ID × STEP)` | Same scan policy |
117
+ | Node debug | Per slot | `9200 + (AGENT_ID × STEP)` | Same scan policy |
118
+
119
+ ### Shared infra ports (when listed in `HARNESS_INFRA_SERVICES`)
120
+
121
+ | Service | Default var | On conflict |
122
+ |---------|-------------|-------------|
123
+ | Postgres | `HARNESS_DB_PORT_DEFAULT` | Scan `HARNESS_DB_PORT_SCAN_START..END` |
124
+ | MinIO | `HARNESS_MINIO_PORT_DEFAULT` (+ console) | Scan configured ranges in `harness.env` |
125
+ | Mailpit | `HARNESS_MAILPIT_*_PORT_DEFAULT` | Scan configured ranges |
126
+ | Headless browser | `HARNESS_BROWSER_PORT_DEFAULT` | Scan configured ranges |
127
+
128
+ CLI and iOS profiles typically have no per-slot app ports; optional backends still use the shared-infra model.
129
+
130
+ Set slot limits in `.har/stages.json` (`agentSlots`) based on machine capacity. `har env maintain --finalize` syncs legacy `HARNESS_AGENT_SLOT_*` exports in `harness.env`.
131
+
132
+ ### Do not
133
+
134
+ - Hardcode `3000`, `15432`, `3847`, or other defaults in application code, tests, or agent docs
135
+ - Run raw `docker compose` for harness infrastructure — use `setup-infra.sh` / `launch.sh`
136
+
137
+ ## Rules
138
+
139
+ 1. **Edit .har/ files directly** — no YAML runtime config
140
+ 2. **Always update README.md** in .har/ to reflect current harness state
141
+ 3. **Always call proposeAgentMd** with AGENT.md content (create or update proposal)
142
+ 4. **Reuse existing project commands** from package.json, Makefile, etc.
143
+ 5. **Replace all TODO placeholders**
144
+ 6. **Do not edit manifest.json** — managed by har CLI
145
+ 7. **Run the cleanup checklist before finishing** — keep strictly what this repository needs:
146
+ - compose file has only used services; `HARNESS_INFRA_SERVICES` matches exactly
147
+ - `harness.env` has port documentation vars for every enabled infra service; `.har/README.md` explains allocation and shared vs per-slot
148
+ - `env.template` has no blocks for removed services; no dead branches left in scripts
149
+ - unused harness files deleted (`deleteHarnessFile`), e.g. `attach.sh` when unused
150
+ - `.har/README.md` file table matches the files that actually exist
151
+ - `CLAUDE.agent.md` shows only real URLs/ports and commands that run
152
+ - skipped full-dev setup has a minimal bootstrap or clearly documented limitation
153
+ - all per-slot data stores are provisioned, not only the primary database
154
+ - `CLAUDE.agent.md` defines what "agent usable" means, including credentials or smoke checks when applicable
155
+ 8. **Call finishAuthoring** when complete
@@ -4,7 +4,17 @@ Adapt the `.har/` harness in this repository so AI coding agents can run the pro
4
4
 
5
5
  Explore this repository, then edit files in `.har/` directly to make the harness runnable for this project.
6
6
 
7
- **Do NOT** create a YAML config or JSON mapping file for runtime behavior. Put behavior directly in the harness scripts and templates.
7
+ `.har/` is a **configuration surface** — the runtime machinery lives in the HAR
8
+ package behind the `./.har/*.sh` shims. Never edit the shims or invent new config
9
+ files; every customization has a sanctioned home:
10
+
11
+ | Customization | Home |
12
+ |---------------|------|
13
+ | Settings (app, services, ports, commands) | `harness.env` (schema-validated config) |
14
+ | Verification steps | Registered stages in `stages.json` + `.har/stages/` |
15
+ | Lifecycle side effects | Hooks in `.har/hooks/` |
16
+ | Anything bigger | Plugins (`har env add-plugin`, `har plugin create` for local) |
17
+ | Full runtime ownership (rare) | `har env eject` |
8
18
 
9
19
  ## HAR profiles (pick the right one at init)
10
20
 
@@ -56,18 +66,23 @@ Clear index of the harness: what each file does, quick start, architecture, how
56
66
  ### `.har/harness.env`
57
67
  Primary app, ports, `HARNESS_INFRA_SERVICES`, migrate/seed commands, health check path.
58
68
 
59
- **Toolchain provisioning:** set `HARNESS_ECOSYSTEM` (`auto` detects from manifests) and optional `HARNESS_INSTALL_CMD`. Launch runs `provision-toolchain.sh`, writes resolved paths (`PYTHON_BIN`, `NODE_BIN`, `NPM_BIN`, `XCODEBUILD_BIN`, …) into `.env.agent.<id>`. Verify steps **must** use those paths — never hardcode venv or interpreter locations.
69
+ **Toolchain provisioning:** set `HARNESS_ECOSYSTEM` (`auto` detects from manifests) and optional `HARNESS_INSTALL_CMD`. Launch provisions the toolchain and writes resolved paths (`PYTHON_BIN`, `NODE_BIN`, `NPM_BIN`, `XCODEBUILD_BIN`, …) into `.env.agent.<id>`. Verify steps **must** use those paths — never hardcode venv or interpreter locations.
60
70
 
61
71
  ### `.har/ecosystem.agent.template.cjs` (default profile only)
62
72
  PM2 processes for the primary application only, matching how it runs in dev. Skip entirely for the CLI profile.
63
73
 
64
- ### `.har/verify.sh`
65
- Adapt verification for this repository's toolchain. Step lists in the template are
66
- **examples, not exhaustive** — add, remove, or reorder `run_step` calls to match
67
- how this project is built and tested. Use toolchain variables from `.env.agent.<id>`
68
- (e.g. `${NPM_BIN:-npm}`, `${PYTHON_BIN:-python3}`, `${XCODEBUILD_BIN:-xcodebuild}`).
69
- The stock verify section is keyed by `HARNESS_ECOSYSTEM`; it is a starting point,
70
- not the repo's final contract. Replace conventions that do not match this project.
74
+ ### Verification stages (`.har/stages.json`)
75
+ Verification is data: `.har/stages.json` lists the pipeline in
76
+ `verificationStages` (execution order), and every id resolves to a registered
77
+ stage with `"tier": "quick" | "full"`. Adapt verification by editing the stage
78
+ entries — commands, tiers, order — or adding stage scripts (see
79
+ `.har/STAGES.md`). **Never edit `.har/verify.sh`**; it is a thin iterator that
80
+ runs the registry. The scaffolded defaults (`typecheck`, `unit-tests`, `lint`,
81
+ `readiness`, plus `api-health` on web profiles) are derived from
82
+ `HARNESS_ECOSYSTEM` — a starting point, not the repo's final contract. Replace
83
+ conventions that do not match this project. Use toolchain variables from
84
+ `.env.agent.<id>` (e.g. `${NPM_BIN:-npm}`, `${PYTHON_BIN:-python3}`,
85
+ `${XCODEBUILD_BIN:-xcodebuild}`).
71
86
 
72
87
  `${NPM_BIN}` may resolve to bun, pnpm, or yarn as well as npm, so keep Node steps
73
88
  package-manager agnostic: always `${NPM_BIN:-npm} run <script>` (never bare
@@ -84,7 +99,7 @@ such as `--prefix` — use a subshell like `(cd docs && ${NPM_BIN:-npm} run buil
84
99
  - **Quick** must stay fast and minimal (syntax, compile, import smoke) — not the full test suite.
85
100
  - **Full** holds unit tests, lint, and heavier checks; optional Playwright runs on `--full` when installed.
86
101
  - Reuse real commands from `package.json`, `Makefile`, CI, `pyproject.toml`, etc.
87
- - Remove stock npm/pytest/go/cargo/maven/gradle examples that do not apply.
102
+ - Remove stock stage commands that do not apply; keep every listed id resolvable.
88
103
  - Replace all TODO placeholders in both tiers.
89
104
 
90
105
  ### Readiness vs liveness (required)
@@ -109,17 +124,15 @@ scripts or document why no substitute is needed. In particular:
109
124
  bootstrap step for required tenants/users/settings, or document why schema-only
110
125
  is enough.
111
126
  - If the app has multiple databases, schemas, queues, object stores, search
112
- indexes, or other per-slot state, provision all of them in `setup-infra.sh`
113
- and `launch.sh`.
127
+ indexes, or other per-slot state, provision all of them: shared template
128
+ stores via `docker-compose.agent.yml` + config, per-slot state via
129
+ `HARNESS_DB_MIGRATE_CMD` / `HARNESS_DB_SEED_CMD` or a `post-launch.sh` hook.
114
130
  - If launch generates config, validate the nested keys the app actually reads
115
131
  against upstream examples/defaults, not only top-level keys.
116
132
  - If the dev server can block agents with overlays or noisy HMR failures,
117
133
  choose and document an agent-friendly asset mode.
118
134
  - Put Layer 3 checks in `verify --full`, a project-owned readiness script, or
119
135
  documented smoke URLs. Health alone is not sufficient for UI/auth apps.
120
- - Ensure `launch.sh` writes the slot registry before slow or fragile steps, runs
121
- `provision-toolchain.sh` to install deps and record toolchain paths in
122
- `.env.agent.<id>`, and `verify.sh` resolves env/work dir through `agent-slot.sh`.
123
136
 
124
137
  ### Optional Playwright stage
125
138
  If the user ran `har env add-plugin playwright` (or `@playwright/test` is in package.json):
@@ -131,11 +144,29 @@ If the user ran `har env add-plugin playwright` (or `@playwright/test` is in pac
131
144
 
132
145
  See `.har/stages/PLAYWRIGHT.md` when present.
133
146
 
147
+ ### Custom lifecycle behavior — `.har/hooks/` (optional)
148
+
149
+ Need something custom at launch/verify/teardown time (warm a cache, prep test
150
+ fixtures, prepare screenshots, clean up external resources)? Do **not** edit
151
+ harness machinery — drop an executable script into `.har/hooks/`:
152
+
153
+ `pre-launch.sh` · `post-launch.sh` · `pre-verify.sh` · `pre-teardown.sh` · `post-teardown.sh`
154
+
155
+ Hooks receive a stable env contract (`HAR_HOOK_CONTRACT=1`): `AGENT_ID`,
156
+ `WORK_DIR`, `ENV_FILE` (once the session has one), `HAR_HARNESS_DIR`, and
157
+ `HAR_PORT_<NAME>` for allocated ports. A failing `pre-*` hook aborts the
158
+ operation with attribution; `post-*` failures warn by default (set
159
+ `HARNESS_HOOK_POST_FAILURE=fail` in `harness.env` to make them fatal). Hooks
160
+ are user-owned: never drift-checked; `har env doctor` only validates names and
161
+ executability. Use registered stages for verification steps; use hooks for
162
+ lifecycle side effects.
163
+
134
164
  ### `.har/CLAUDE.agent.md`
135
165
  Detailed agent instructions: commands, credentials, architecture, definition of done.
136
166
 
137
- ### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
138
- Adapt as needed for the project's infra.
167
+ ### `.har/env.template`, `docker-compose.agent.yml`
168
+ Adapt as needed for the project's infra (`setup-infra.sh` is a shim — the
169
+ services it starts come from these two files plus `HARNESS_INFRA_SERVICES`).
139
170
 
140
171
  ### Port allocation & shared services
141
172
 
@@ -151,26 +182,24 @@ Document and configure ports in `.har/harness.env` and `.har/README.md`. Use the
151
182
 
152
183
  **Shared infra ports** (one per machine, all profiles when the service is in `HARNESS_INFRA_SERVICES`):
153
184
 
154
- | Service | Default var | On conflict |
155
- |---------|-------------|-------------|
156
- | Postgres | `HARNESS_DB_PORT_DEFAULT` | Scan `HARNESS_DB_PORT_SCAN_START..END` |
157
- | MinIO | `HARNESS_MINIO_PORT_DEFAULT` (+ console) | Scan configured ranges |
158
- | Mailpit | `HARNESS_MAILPIT_*_PORT_DEFAULT` | Scan configured ranges |
159
- | Headless browser | `HARNESS_BROWSER_PORT_DEFAULT` | Scan configured ranges |
185
+ Each shared service gets one lane in `HARNESS_INFRA_PORT_LANES`
186
+ (`<lane>=<default>:<scan_start>-<scan_end>`): `db`, `minio`, `minio-console`,
187
+ `browser`, `mailpit-web`, `mailpit-smtp`. Infra setup tries the default
188
+ first and scans the range on conflict.
160
189
 
161
190
  Onboarding may set an initial `agentSlots.max` in `.har/stages.json`. After you know the real stack cost, **re-tune** that limit for machine capacity (lighter stack → you can raise; heavy Docker/DB → lower). `har env maintain --finalize` syncs legacy `HARNESS_AGENT_SLOT_*` exports in `harness.env`.
162
191
 
163
192
  **Port / infra checklist:**
164
193
 
165
194
  - [ ] `.har/harness.env` has `HARNESS_FE_BASE_PORT`, `HARNESS_API_BASE_PORT`, `HARNESS_PORT_STEP` (default profile) or explains why they are absent (CLI/iOS)
166
- - [ ] For each service in `HARNESS_INFRA_SERVICES`, matching `HARNESS_*_PORT_DEFAULT` and `SCAN_*` vars exist in `harness.env`
195
+ - [ ] For each service in `HARNESS_INFRA_SERVICES`, a matching lane exists in `HARNESS_INFRA_PORT_LANES` in `harness.env`
167
196
  - [ ] `.har/README.md` has a **Port & shared services** section (allocation table, shared vs per-slot, do-not rules)
168
197
  - [ ] App code and tests read ports from `.env.agent.<id>` / `agent-cli.sh` / slot registry — no hardcoded `3000`, `15432`, `3847`, etc.
169
198
  - [ ] `env.template` and `CLAUDE.agent.md` show resolved ports via variables, not literals
170
199
  - [ ] Monorepos with `har control up`: document slot-1 conflict if the app port overlaps (e.g. Mission Control on 3847)
171
200
 
172
201
  ### Git worktree
173
- `launch.sh` creates an isolated session worktree at `~/worktrees/<base>-<sha4>-har-agent-<id>-<rand4>` by default (`HARNESS_USE_WORKTREE=true`) and records it in `.har/slots/agent-<id>.json`. Agents should commit from that worktree, not the main checkout.
202
+ Launch creates an isolated session worktree at `~/worktrees/<base>-<sha4>-har-agent-<id>-<rand4>` by default (`HARNESS_USE_WORKTREE=true`) and records it in `.har/slots/agent-<id>.json`. Agents should commit from that worktree, not the main checkout.
174
203
 
175
204
  ## Step 3 — Update repo-root `AGENTS.md`
176
205
 
@@ -187,8 +216,8 @@ If **no `AGENTS.md` exists**, create one at the repo root using this structure:
187
216
 
188
217
  - Link to `.har/README.md` and `.har/CLAUDE.agent.md`
189
218
  - State plainly: **the harness is how you run this project** — to see the app live (manual testing, browser, screenshots), `launch` a slot; never hand-roll docker/dev-server startup, and never work around a failing harness command with ad-hoc setup (fix or report it instead)
190
- - Preferred commands: HAR MCP tools or `har env launch/verify/teardown` (persists run history)
191
- - Shell fallback: `./.har/launch.sh`, `./.har/verify.sh`, `./.har/teardown.sh` (when CLI is not installed)
219
+ - Commands: HAR MCP tools or `har env launch/verify/teardown`
220
+ - Shell shims: `./.har/launch.sh`, `./.har/verify.sh`, `./.har/teardown.sh` — same runtime and run records
192
221
  - Rules (no hardcoded ports, use `./.har/agent-cli.sh`, do not touch other agents' resources)
193
222
  - Project-specific notes (stack, credentials, definition of done)
194
223
 
@@ -206,32 +235,27 @@ If this repository contains **more than one project or `.har` harness** (check f
206
235
 
207
236
  Include a **Run history** subsection:
208
237
 
209
- - `./.har/*.sh` does not write run records
210
- - `har env …` and MCP write to `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json`
238
+ - Every entry point (`./.har/*.sh` shims, `har env …`, MCP) writes the same run records to `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json`
211
239
  - With worktrees, code runs in the worktree but run JSON lives in the main checkout `.har/runs/`
212
- - Document MCP/CLI as the preferred agent interface; shell scripts as fallback
240
+ - The `./.har/*.sh` shims forward to the same runtime — evidence records are identical from any surface
213
241
 
214
- ## Step 4 — Cleanup checklist (required)
242
+ ## Step 4 — Adaptation completeness (required)
215
243
 
216
- The boilerplate ships more than any single repository needs. Strip it down to strictly what this project uses — leftover template content confuses agents and rots. Verify each item:
244
+ Before finishing, confirm the harness describes this project truthfully — do
245
+ **not** go hunting for machinery to prune (the shims and packaged runtime are
246
+ not yours to trim, and wholesale deletion just manufactures drift):
217
247
 
218
- - [ ] `docker-compose.agent.yml` contains ONLY services this project uses (menu entries and their volumes deleted); `HARNESS_INFRA_SERVICES` lists exactly those services
219
- - [ ] `env.template` has no env blocks for removed services (MinIO/S3, mailpit, headless browser, ...) and no vars the app never reads
220
- - [ ] `harness.env` has no leftover config for features not in use (e.g. `HARNESS_TEMPLATE_DB` and migrate/seed commands when there is no database)
221
- - [ ] Scripts (`launch.sh`, `setup-infra.sh`, `teardown.sh`, `agent-cli.sh`, `verify.sh`) contain no dead branches for services this project will never enable — prune, don't comment out
222
248
  - [ ] No `TODO` placeholders remain anywhere in `.har/`
223
- - [ ] Unused harness files are deleted (e.g. `attach.sh` when tmux isn't part of the workflow; CLI profile: `ecosystem.agent.template.cjs`, `env.template`)
224
- - [ ] `.har/README.md` file table lists exactly the files that exist — no more, no less
225
- - [ ] `.har/CLAUDE.agent.md` shows only real URLs/ports/credentials (e.g. drop the Frontend row for an API-only project) and project commands that actually run
226
- - [ ] If full seed/setup is skipped, `.har/` provides a minimal bootstrap or clearly documents why none is needed
249
+ - [ ] `HARNESS_INFRA_SERVICES` lists exactly the services this project uses, each with a lane in `HARNESS_INFRA_PORT_LANES`
227
250
  - [ ] All per-slot data stores are provisioned, not just the primary database
228
- - [ ] `.har/CLAUDE.agent.md` defines what "agent usable" means for this repo: login/API smoke, credentials, required default data, and known skipped dev-setup steps
229
- - [ ] `.har/README.md` documents port allocation and shared-service model; `harness.env` has the port knobs for every enabled infra service
251
+ - [ ] If full seed/setup is skipped, `.har/` provides a minimal bootstrap or documents why none is needed
252
+ - [ ] `.har/CLAUDE.agent.md` defines what "agent usable" means for this repo (credentials, default data, smoke workflow) and shows only real URLs/ports/commands
253
+ - [ ] `.har/README.md` documents port allocation and the shared-service model
230
254
  - [ ] No hardcoded default ports (`3000`, `15432`, `3847`, …) in app code, tests, or harness docs — use agent env / slot registry
231
255
 
232
256
  ## Rules
233
257
 
234
- 1. Edit `.har/` files directly — no YAML runtime config
258
+ 1. Customize only through the contract: config in `harness.env`, stages in `stages.json` / `.har/stages/`, hooks in `.har/hooks/`, plugins in `.har/plugins/` — never edit the generated `*.sh` shims
235
259
  2. Always update `.har/README.md` to reflect current harness state
236
260
  3. Reuse existing project commands from package.json, Makefile, CI, etc.
237
261
  4. Replace all TODO placeholders
@@ -4,7 +4,11 @@ Update the `.har/` harness in this repository to reflect current codebase change
4
4
 
5
5
  The harness already exists. Inspect what changed in the repo since the harness was last updated, then edit `.har/` files so coding agents can still run and verify the project correctly.
6
6
 
7
- **Do NOT** create a YAML config or JSON mapping file for runtime behavior. Put behavior directly in the harness scripts and templates.
7
+ `.har/` is a **configuration surface** — the runtime machinery lives in the HAR
8
+ package behind the `./.har/*.sh` shims. Reconcile through the contract only:
9
+ config in `harness.env`, stages in `stages.json` / `.har/stages/`, hooks in
10
+ `.har/hooks/`, plugins in `.har/plugins/`. Never patch the shims — `har env
11
+ eject` is the sanctioned route to script ownership.
8
12
 
9
13
  {{MAINTAIN_BUNDLE_SECTION}}
10
14
 
@@ -15,7 +19,10 @@ Compare the current repo against the existing harness:
15
19
  - Root manifests, CI, Docker, README
16
20
  - New or changed test, lint, build, migrate, or seed commands
17
21
  - New services, ports, or environment variables
18
- - Review `.har/maintain/drift-report.json` (template drift, **missing port documentation vars**)
22
+ - Review `.har/maintain/drift-report.json` (two-signal drift, **missing port documentation vars**).
23
+ Drift statuses: `upstream-updated` (bundled template moved since your last finalize — apply the diff),
24
+ `conflict` (template moved **and** the file was edited locally — merge, keep repo customizations),
25
+ `adapted` (local edits only — **no action**, never revert to stock; finalize blesses them).
19
26
 
20
27
  ## Step 2 — Update `.har/` files
21
28
 
@@ -24,10 +31,10 @@ Prefer targeted edits over full rewrites. Key files to review:
24
31
  ### `.har/README.md` (required)
25
32
  Keep this accurate — it is the harness index. Update whenever scripts, stages, or workflow change.
26
33
 
27
- ### `.har/harness.env`, `verify.sh`, `provision-toolchain.sh`, `ecosystem.agent.template.cjs`, `CLAUDE.agent.md`
34
+ ### `.har/harness.env`, `stages.json`, `ecosystem.agent.template.cjs`, `CLAUDE.agent.md`
28
35
  Align commands and instructions with the current stack. Verify steps must use toolchain paths from `.env.agent.<id>` (`PYTHON_BIN`, `NPM_BIN`, `XCODEBUILD_BIN`, …) — never hardcoded venv or interpreter paths. `NPM_BIN` may be bun, pnpm, or yarn, so Node steps must use `${NPM_BIN:-npm} run <script>` and avoid npm-only flags such as `--prefix`. Replace stock ecosystem conventions that do not match the repository; do not leave npm/pytest/go/cargo/maven/gradle examples in place by accident.
29
36
 
30
- ### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
37
+ ### `.har/env.template`, `docker-compose.agent.yml`
31
38
  Update only if infra changed.
32
39
 
33
40
  ### Readiness vs liveness regression check
@@ -52,54 +59,47 @@ Look specifically for drift introduced since the last adaptation:
52
59
  defaults from another file.
53
60
  - The dev server mode is fine for humans but blocks browser automation or agents
54
61
  with overlays/noisy HMR.
55
- - `verify.sh` became health-only and no longer checks the key workflow that makes
56
- the slot usable.
57
- - `launch.sh` writes the slot registry only after fragile late steps; partial
58
- launches must remain discoverable by verify/status/teardown.
62
+ - `verificationStages` became health-only and no longer checks the key workflow
63
+ that makes the slot usable.
59
64
 
60
65
  Update `.har/CLAUDE.agent.md` with skipped setup steps, substitutes, credentials,
61
66
  and the repo-specific definition of "agent usable."
62
67
 
63
- ### HAR platform upgrades checklist
68
+ ### Custom lifecycle behavior — `.har/hooks/`
64
69
 
65
- When upgrading `@osfactory/har` or adopting new harness standards:
70
+ Custom launch/verify/teardown needs belong in lifecycle hooks, never in edits
71
+ to harness machinery: `.har/hooks/pre-launch.sh`, `post-launch.sh`,
72
+ `pre-verify.sh`, `pre-teardown.sh`, `post-teardown.sh`. Hooks receive
73
+ `AGENT_ID`, `WORK_DIR`, `ENV_FILE`, `HAR_HARNESS_DIR`, and `HAR_PORT_<NAME>`
74
+ (contract `HAR_HOOK_CONTRACT=1`). Failing `pre-*` hooks abort the operation;
75
+ `post-*` failures warn unless `HARNESS_HOOK_POST_FAILURE=fail`. Hooks are
76
+ user-owned and never drift-checked — if a past adaptation patched machinery
77
+ scripts for a lifecycle side effect, move that code into a hook.
66
78
 
67
- **Generator 0.5.0 — `AGENTS.md` (canonical agent guide):**
79
+ ### HAR platform upgrades
68
80
 
69
- - Repo-root **`AGENTS.md`** is now the shared HAR workflow contract (Codex auto-loads it). Do **not** create or keep **`AGENT.md`** (singular).
70
- - If **`AGENT.md` exists**: merge any unique project notes into `AGENTS.md`, ensure a **HAR / agent environment** section is present, then **delete `AGENT.md`**.
71
- - If **`AGENTS.md` is missing**: create it (HAR may already have scaffolded a managed section during `maintain` — fill **Project-specific notes** and keep the marked HAR section).
72
- - If **`AGENTS.md` already exists**: add or refresh the managed **HAR / agent environment** section only — do not wipe unrelated project guidance.
73
- - Keep **`CLAUDE.md`** as a **thin pointer** to `AGENTS.md` (Claude Code auto-loads `CLAUDE.md`). Never paste the full Cursor-rule / HAR workflow into `CLAUDE.md`.
74
- - Update links in `.har/CLAUDE.agent.md` and `.har/README.md` from `AGENT.md` → `AGENTS.md` if they still point at the legacy name.
75
- - Cursor still uses `.cursor/rules/har-workflow.mdc` (always-on); that rule should also say `AGENTS.md`.
81
+ Platform-shape upgrades are **code, not a checklist**: the har CLI carries a
82
+ versioned migration registry keyed on the manifest's `runtimeVersion`.
83
+ `har env maintain` detects an old harness shape, writes `.har/MIGRATE-PROMPT.md`,
84
+ and `har env maintain --migrate` applies the mechanical steps (shims, pure-config
85
+ `harness.env` with `HARNESS_INFRA_SERVICES` / `HARNESS_INFRA_PORT_LANES`
86
+ conversions, machinery removal) with backups under `.har/migrate/backup/`.
76
87
 
77
- **Generator 0.4.0 — primary app & shared infra services:**
88
+ If a `.har/MIGRATE-PROMPT.md` exists, **follow it instead of this prompt** and
89
+ come back here afterwards. Two standing rules:
78
90
 
79
- - Migrate `harness.env` from boolean `HARNESS_INFRA_*` flags to the `HARNESS_INFRA_SERVICES` list (space-separated compose service names, e.g. `"db mailpit"`) and add the `har_infra_enabled()` helper — copy both from `.har/maintain/templates/harness.env`. Update every script that still tests `HARNESS_INFRA_POSTGRES`-style flags (`setup-infra.sh`, `launch.sh`, `teardown.sh`, `agent-cli.sh`) to use `har_infra_enabled <service>`.
80
- - Set `HARNESS_PRIMARY_APP` in `harness.env` to the ONE app agents modify. Ensure `ecosystem.agent.template.cjs` starts only that app's processes. Move any other in-repo services agents depend on but don't change to shared infra: compose services in `docker-compose.agent.yml` or an optional `.har/ecosystem.shared.config.cjs` (processes `har-shared-<name>`; `setup-infra.sh` starts it when present — resync `setup-infra.sh` from the template to get this hook).
81
- - Prune `docker-compose.agent.yml` to only the services this project uses; delete unused menu services and volumes.
82
- - **Port & shared services:** ensure `.har/README.md` documents the allocation table and shared vs per-slot model; `harness.env` has every `HARNESS_*_PORT_*` var required for services in `HARNESS_INFRA_SERVICES` (copy missing vars from `.har/maintain/templates/harness.env` when drift reports them). Remove hardcoded ports from app code, tests, and `CLAUDE.agent.md`.
83
- - Run the **cleanup checklist**: no TODO placeholders, no env blocks for removed services in `env.template`, no dead script branches, `.har/README.md` file table matches the actual files, `CLAUDE.agent.md` shows only real URLs/ports and commands, unused files deleted.
84
-
85
- **Earlier standards:**
86
-
87
- - Add **Run history** section to repo-root `AGENTS.md` if missing (shell vs `har env`, worktree vs runs location)
88
- - Ensure `AGENTS.md` / `CLAUDE.agent.md` frame the harness as **how you run the project** (launch for manual testing/browser/screenshots; fix — don't work around — failing harness commands)
89
- - Ensure `launch.sh` installs dependencies in fresh worktrees and resolves the project subdirectory inside the worktree (`git rev-parse --show-prefix`) for monorepos
90
- - If the repo has multiple projects/harnesses, maintain the **"Harnesses in this repo"** table in root `AGENTS.md`, per-project pointer docs, and a single root Cursor rule
91
- - Remove dead boilerplate files (CLI profile: `ecosystem.agent.template.cjs`, `env.template`, `attach.sh`)
92
- - Align `launch.sh` / `harness.env` with worktree-default standard (`HARNESS_USE_WORKTREE=true`)
93
- - Do **not** blindly overwrite customized `verify.sh`
91
+ - Verification customization lives in `stages.json` / `.har/stages/` — the
92
+ top-level `*.sh` files are generated shims, safe to regenerate.
93
+ - Repo-root agent docs (`AGENTS.md`, `CLAUDE.md`) follow Step 3 below.
94
94
 
95
95
  ## Step 3 — Refresh repo-root `AGENTS.md`
96
96
 
97
97
  If harness commands, rules, or workflow changed, update the **HAR / agent environment** section in repo-root `AGENTS.md`:
98
98
 
99
99
  - Links to `.har/README.md` and `.har/CLAUDE.agent.md`
100
- - Preferred: HAR MCP tools or `har env …` (persists run history)
101
- - Fallback: `./.har/*` shell scripts (when CLI is not installed)
102
- - Run history rules (shell vs CLI/MCP, worktree vs `.har/runs/` location)
100
+ - Commands: HAR MCP tools or `har env …`
101
+ - Shell shims: `./.har/*.sh` — thin delegates to `har env`, same run records
102
+ - Run history (worktree runs record to the main checkout `.har/runs/`)
103
103
  - Agent rules (ports, agent-cli.sh, isolation)
104
104
  - Project-specific notes
105
105
 
@@ -109,7 +109,7 @@ Do **not** create `AGENT.md` (singular). If legacy `AGENT.md` exists, merge uniq
109
109
 
110
110
  ## Rules
111
111
 
112
- 1. Prefer targeted edits — keep working harness behavior where still valid
112
+ 1. Prefer targeted edits through the contract (config / stages / hooks / plugins) — keep working harness behavior where still valid; never edit the generated `*.sh` shims
113
113
  2. Always update `.har/README.md` when anything in the harness changes
114
114
  3. Reuse existing project commands from package.json, Makefile, CI, etc.
115
115
  4. Replace any remaining TODO placeholders
@@ -12,9 +12,9 @@ This compares the harness against the current templates and repository, refreshe
12
12
 
13
13
  ## 2. Perform the adaptation yourself
14
14
 
15
- Read `.har/ADAPT-PROMPT.md` and execute its instructions now, in this session: reconcile `.har/` scripts (`launch.sh`, `verify.sh`, `setup-infra.sh`, `harness.env`, `stages.json`) and `AGENTS.md` with the repository's current stack, ports, and commands. Preserve intentional project-specific customizations — fix drift, don't blindly reset.
15
+ Read `.har/ADAPT-PROMPT.md` and execute its instructions now, in this session: reconcile the harness configuration surface (`harness.env`, `stages.json` + `.har/stages/`, `.har/hooks/`, `docker-compose.agent.yml`, `env.template`) and `AGENTS.md` with the repository's current stack, ports, and commands. The `./.har/*.sh` files are generated shims — leave them alone. Preserve intentional project-specific customizations — fix drift, don't blindly reset.
16
16
 
17
- Also check stage drift: compare the repository's current check commands (package.json scripts, Makefile, CI) against the stages registered in `.har/stages.json`. Register missing checks (`har env add-stage <id> --custom --command "..." --verification`), and remove or fix stages whose commands no longer exist. `.har/STAGES.md` documents the contract.
17
+ Also check stage drift: compare the repository's current check commands (package.json scripts, Makefile, CI) against the stages registered in `.har/stages.json`. Register missing checks (add a command stage entry to `.har/stages.json` and list it in `verificationStages`; scaffold script-based checks with `har plugin create <id>` + `har env add-plugin <id>`), and remove or fix stages whose commands no longer exist. `.har/STAGES.md` documents the contract.
18
18
 
19
19
  ## 3. Finalize and prove it works
20
20
 
@@ -50,17 +50,19 @@ If `.har/` already exists, stop and suggest `/har-maintain` instead.
50
50
 
51
51
  ## 5. Perform the adaptation yourself
52
52
 
53
- `har env init` prints an adaptation prompt and writes it to `.har/ADAPT-PROMPT.md`. Read that file and **execute its instructions yourself, now, in this session** — tailor `.har/` scripts (`launch.sh`, `verify.sh`, `setup-infra.sh`, `harness.env`, `stages.json`) and `AGENTS.md` to this repository's real stack, ports, and commands.
53
+ `har env init` prints an adaptation prompt and writes it to `.har/ADAPT-PROMPT.md`. Read that file and **execute its instructions yourself, now, in this session** — tailor the harness configuration surface (`harness.env`, `stages.json` + `.har/stages/`, `.har/hooks/`, `docker-compose.agent.yml`, `env.template`) and `AGENTS.md` to this repository's real stack, ports, and commands. The `./.har/*.sh` files are generated shims over the packaged runtime — never edit them.
54
54
 
55
55
  ## 6. Register the project's checks as stages
56
56
 
57
57
  Convert the repository's real check commands (test, lint, typecheck, whatever CI runs) into registered stages so they run in `verify --full` and are visible to every agent. Read `.har/STAGES.md` for the contract, then:
58
58
 
59
- ```bash
60
- har env add-stage unit-tests --custom --kind test --command "npm test" --verification
59
+ ```json
60
+ { "id": "unit-tests", "kind": "test", "command": "npm test", "tier": "quick" }
61
61
  ```
62
62
 
63
- - Use `--command` for one-liner checks; use `--script` when a check needs the slot's env, ports, or artifacts (then implement the scaffolded `.har/stages/<id>.sh`).
63
+ (add the entry to `.har/stages.json` `stages` and its id to `verificationStages`).
64
+
65
+ - Use a command stage for one-liner checks; when a check needs the slot's env, ports, or artifacts, scaffold a project-owned plugin: `har plugin create <id>`, implement `.har/plugins/<id>/stages/<id>.sh`, then `har env add-plugin <id>`.
64
66
  - Rich integrations ship as **plugins**: `har env add-plugin --list`, then e.g. `har env add-plugin playwright` (web) or `har env add-plugin rocketsim` (iOS). Plugins install stages; agents only talk to the stage registry.
65
67
 
66
68
  ## 7. Prove the harness works
@@ -9,7 +9,8 @@ This repository uses a `.har/` agent harness. Follow this on every change.
9
9
 
10
10
  The harness is **how you run the project**, not only how you verify it. Launch a
11
11
  slot for live apps, browsers, and screenshots — never hand-roll docker/dev-server
12
- startup. If a harness command fails, fix the harness or surface the failure.
12
+ startup. If a harness command fails, fix the harness or surface the failure. Customize
13
+ only via the contract (`harness.env`, `stages.json` + `.har/stages/`, `.har/hooks/`, `.har/plugins/`) — never edit the generated `./.har/*.sh` shims.
13
14
 
14
15
  ## Before making changes
15
16
 
@@ -42,8 +43,7 @@ the first captured user prompt.
42
43
  | `.har/` | backend + frontend | `src/`, `packages/` |
43
44
  | `apps/admin/.har/` | admin dashboard | `apps/admin/` |
44
45
 
45
- Run harness commands from the directory that owns the harness (e.g. `cd apps/admin`).
46
- -->
46
+ Run harness commands from the directory that owns the harness (e.g. `cd apps/admin`). -->
47
47
 
48
48
  ## After making changes
49
49
 
@@ -34,7 +34,7 @@ services:
34
34
  image: coollabsio/minio:latest
35
35
  ports:
36
36
  - "${AGENT_MINIO_PORT:-19000}:9000"
37
- - "${AGENT_MINIO_CONSOLE_PORT:-19001}:9001"
37
+ - "${AGENT_MINIO_CONSOLE_PORT:-19050}:9001"
38
38
  volumes:
39
39
  - agent-minio-data:/minio/data
40
40
  environment: