@osfactory/har 0.1.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.
- package/LICENSE +674 -0
- package/README.md +208 -0
- package/control/docker-compose.build.yml +7 -0
- package/control/docker-compose.yml +31 -0
- package/dist/index.js +41753 -0
- package/dist/prompts/system-authoring.md +104 -0
- package/dist/templates/AGENT.md.template +40 -0
- package/dist/templates/CLAUDE.md.template +5 -0
- package/dist/templates/adaptation-prompt-init.md +124 -0
- package/dist/templates/adaptation-prompt-maintain.md +73 -0
- package/dist/templates/cursor-rule.mdc.template +101 -0
- package/dist/templates/har-boilerplate/CLAUDE.agent.md +54 -0
- package/dist/templates/har-boilerplate/README.md +134 -0
- package/dist/templates/har-boilerplate/agent-cli.sh +172 -0
- package/dist/templates/har-boilerplate/agent-slot.sh +270 -0
- package/dist/templates/har-boilerplate/attach.sh +16 -0
- package/dist/templates/har-boilerplate/docker-compose.agent.yml +66 -0
- package/dist/templates/har-boilerplate/ecosystem.agent.template.cjs +44 -0
- package/dist/templates/har-boilerplate/env.template +37 -0
- package/dist/templates/har-boilerplate/harness.env +50 -0
- package/dist/templates/har-boilerplate/justfile +39 -0
- package/dist/templates/har-boilerplate/launch.sh +229 -0
- package/dist/templates/har-boilerplate/setup-infra.sh +102 -0
- package/dist/templates/har-boilerplate/stages/README.sh +9 -0
- package/dist/templates/har-boilerplate/stages.json +67 -0
- package/dist/templates/har-boilerplate/teardown.sh +86 -0
- package/dist/templates/har-boilerplate/verify.sh +163 -0
- package/dist/templates/har-boilerplate-cli/CLAUDE.agent.md +41 -0
- package/dist/templates/har-boilerplate-cli/README.md +112 -0
- package/dist/templates/har-boilerplate-cli/agent-cli.sh +162 -0
- package/dist/templates/har-boilerplate-cli/agent-slot.sh +270 -0
- package/dist/templates/har-boilerplate-cli/docker-compose.agent.yml +64 -0
- package/dist/templates/har-boilerplate-cli/harness.env +40 -0
- package/dist/templates/har-boilerplate-cli/justfile +27 -0
- package/dist/templates/har-boilerplate-cli/launch.sh +132 -0
- package/dist/templates/har-boilerplate-cli/setup-infra.sh +102 -0
- package/dist/templates/har-boilerplate-cli/stages/README.sh +9 -0
- package/dist/templates/har-boilerplate-cli/stages.json +61 -0
- package/dist/templates/har-boilerplate-cli/teardown.sh +66 -0
- package/dist/templates/har-boilerplate-cli/verify.sh +113 -0
- package/dist/templates/har-boilerplate-ios/ADAPT-PROMPT.md +57 -0
- package/dist/templates/har-boilerplate-ios/CLAUDE.agent.md +65 -0
- package/dist/templates/har-boilerplate-ios/README.md +88 -0
- package/dist/templates/har-boilerplate-ios/agent-cli.sh +125 -0
- package/dist/templates/har-boilerplate-ios/agent-slot.sh +270 -0
- package/dist/templates/har-boilerplate-ios/docker-compose.agent.yml +17 -0
- package/dist/templates/har-boilerplate-ios/harness.env +42 -0
- package/dist/templates/har-boilerplate-ios/justfile +33 -0
- package/dist/templates/har-boilerplate-ios/launch.sh +132 -0
- package/dist/templates/har-boilerplate-ios/setup-infra.sh +84 -0
- package/dist/templates/har-boilerplate-ios/stages/README.sh +12 -0
- package/dist/templates/har-boilerplate-ios/stages.json +61 -0
- package/dist/templates/har-boilerplate-ios/teardown.sh +64 -0
- package/dist/templates/har-boilerplate-ios/verify.sh +165 -0
- package/dist/templates/stage-templates/playwright/.github/workflows/playwright.yml +30 -0
- package/dist/templates/stage-templates/playwright/.har/stages/PLAYWRIGHT.md +21 -0
- package/dist/templates/stage-templates/playwright/.har/stages/browser-e2e.sh +83 -0
- package/dist/templates/stage-templates/playwright/README.md +14 -0
- package/dist/templates/stage-templates/playwright/package.fragment.json +14 -0
- package/dist/templates/stage-templates/playwright/playwright.config.js +30 -0
- package/dist/templates/stage-templates/playwright/template.manifest.json +44 -0
- package/dist/templates/stage-templates/playwright/tests/a11y/smoke.spec.js +14 -0
- package/dist/templates/stage-templates/playwright/tests/api/health.spec.js +10 -0
- package/dist/templates/stage-templates/playwright/tests/frontend/smoke.spec.js +9 -0
- package/dist/templates/stage-templates/rocketsim/.har/stages/ROCKETSIM.md +126 -0
- package/dist/templates/stage-templates/rocketsim/.har/stages/rocketsim-flows.sh +188 -0
- package/dist/templates/stage-templates/rocketsim/README.md +66 -0
- package/dist/templates/stage-templates/rocketsim/flows/README.md +36 -0
- package/dist/templates/stage-templates/rocketsim/flows/example-smoke.sh +60 -0
- package/dist/templates/stage-templates/rocketsim/template.manifest.json +38 -0
- package/package.json +78 -0
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
### `.har/CLAUDE.agent.md`
|
|
62
|
+
Detailed agent instructions: commands, credentials, architecture, definition of done.
|
|
63
|
+
|
|
64
|
+
### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
|
|
65
|
+
As needed for the project's infra.
|
|
66
|
+
|
|
67
|
+
### `AGENT.md` (repo root — via proposeAgentMd only)
|
|
68
|
+
Short pointer document. Structure:
|
|
69
|
+
- Link to `.har/README.md` and `.har/CLAUDE.agent.md`
|
|
70
|
+
- 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
|
|
71
|
+
- Preferred: HAR MCP tools or `har env launch/verify/teardown`
|
|
72
|
+
- Fallback: `./.har/launch.sh`, `./.har/verify.sh`, etc. (when CLI is not installed)
|
|
73
|
+
- Rules (no hardcoded ports, use agent-cli.sh)
|
|
74
|
+
- Project-specific notes section
|
|
75
|
+
|
|
76
|
+
If AGENT.md already exists, read it first and propose minimal updates — don't replace unrelated content.
|
|
77
|
+
|
|
78
|
+
### Monorepos / multiple harnesses
|
|
79
|
+
If the repository contains more than one project or `.har` harness (check for `.har/` directories above or below the one you are adapting):
|
|
80
|
+
- 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."
|
|
81
|
+
- Keep a small `AGENT.md` / `CLAUDE.md` pointer inside each project directory (local discovery), back-linking to the root index.
|
|
82
|
+
- One Cursor rule at repo root listing all harnesses — never one rule per project.
|
|
83
|
+
|
|
84
|
+
## Port allocation
|
|
85
|
+
|
|
86
|
+
Agents run in parallel on configurable slot ids. Ports: `BASE + (AGENT_ID × 10)`.
|
|
87
|
+
|
|
88
|
+
Set slot limits in `.har/stages.json` (`agentSlots`) and `.har/harness.env` (`HARNESS_AGENT_SLOT_MIN` / `HARNESS_AGENT_SLOT_MAX`) based on machine capacity.
|
|
89
|
+
|
|
90
|
+
## Rules
|
|
91
|
+
|
|
92
|
+
1. **Edit .har/ files directly** — no YAML runtime config
|
|
93
|
+
2. **Always update README.md** in .har/ to reflect current harness state
|
|
94
|
+
3. **Always call proposeAgentMd** with AGENT.md content (create or update proposal)
|
|
95
|
+
4. **Reuse existing project commands** from package.json, Makefile, etc.
|
|
96
|
+
5. **Replace all TODO placeholders**
|
|
97
|
+
6. **Do not edit manifest.json** — managed by har CLI
|
|
98
|
+
7. **Run the cleanup checklist before finishing** — keep strictly what this repository needs:
|
|
99
|
+
- compose file has only used services; `HARNESS_INFRA_SERVICES` matches exactly
|
|
100
|
+
- `env.template` has no blocks for removed services; no dead branches left in scripts
|
|
101
|
+
- unused harness files deleted (`deleteHarnessFile`), e.g. `attach.sh` when unused
|
|
102
|
+
- `.har/README.md` file table matches the files that actually exist
|
|
103
|
+
- `CLAUDE.agent.md` shows only real URLs/ports and commands that run
|
|
104
|
+
8. **Call finishAuthoring** when complete
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Agent Environment
|
|
2
|
+
|
|
3
|
+
This repository uses a **`.har/` harness** for isolated agent development.
|
|
4
|
+
|
|
5
|
+
The harness is not just a verification gate — it is **how you run this project**.
|
|
6
|
+
To see the app live (manual testing, browser sessions, screenshots, driving the UI),
|
|
7
|
+
use `har env launch <id>` or `./.har/launch.sh <id>`. It already encodes database
|
|
8
|
+
setup, ports, env vars, and process management — never hand-roll `docker` / dev-server
|
|
9
|
+
startup, and never claim a task "can't be verified live" without launching a slot first.
|
|
10
|
+
|
|
11
|
+
If a harness command fails, fix the harness (or report the failure) — do not quietly
|
|
12
|
+
fall back to ad-hoc commands.
|
|
13
|
+
|
|
14
|
+
## Cursor IDE
|
|
15
|
+
|
|
16
|
+
If `.cursor/rules/har-workflow.mdc` exists, the harness workflow (read-before-change, verify-before-done)
|
|
17
|
+
is injected into every Cursor agent session automatically.
|
|
18
|
+
Run `har env init` or `har env maintain` to create or refresh it.
|
|
19
|
+
|
|
20
|
+
## Start here (all IDEs / first time)
|
|
21
|
+
|
|
22
|
+
1. [`.har/README.md`](.har/README.md) — stages, verification, how to run
|
|
23
|
+
2. [`stages.json`](.har/stages.json) — machine-readable stage registry
|
|
24
|
+
3. [`.har/CLAUDE.agent.md`](.har/CLAUDE.agent.md) — definition of done (after `launch`)
|
|
25
|
+
|
|
26
|
+
## Harness workflow
|
|
27
|
+
|
|
28
|
+
Prefer **HAR MCP tools** (Cursor) or **`har env launch/verify/teardown`** — they persist run history under `.har/runs/`.
|
|
29
|
+
Use `./.har/*.sh` only when the CLI is not installed.
|
|
30
|
+
|
|
31
|
+
## Commit gate
|
|
32
|
+
|
|
33
|
+
Full verify records the exact code state it validated (git tree hash in `.har/validations/`).
|
|
34
|
+
If the commit gate is installed (`har hooks install`), commits of unverified changes are blocked:
|
|
35
|
+
run `har env verify <id> --full` after your last edit, then `git add -A` and commit — any edit
|
|
36
|
+
after verify invalidates the batch and requires a re-run. Do not bypass with `--no-verify`.
|
|
37
|
+
|
|
38
|
+
## Project-specific notes
|
|
39
|
+
|
|
40
|
+
<!-- Adapt when customizing the harness (see .har/ADAPT-PROMPT.md) -->
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Adapt the `.har/` harness in this repository so AI coding agents can run the project in isolated development environments.
|
|
2
|
+
|
|
3
|
+
## Your mission
|
|
4
|
+
|
|
5
|
+
Explore this repository, then edit files in `.har/` directly to make the harness runnable for this project.
|
|
6
|
+
|
|
7
|
+
**Do NOT** create a YAML config or JSON mapping file for runtime behavior. Put behavior directly in the harness scripts and templates.
|
|
8
|
+
|
|
9
|
+
## Profile: {{PROFILE}}
|
|
10
|
+
|
|
11
|
+
{{PROFILE_HINT}}
|
|
12
|
+
|
|
13
|
+
## Step 1 — Explore the repository
|
|
14
|
+
|
|
15
|
+
Read key files to understand the stack and how developers run the project today:
|
|
16
|
+
|
|
17
|
+
- Root manifests (`package.json`, `go.mod`, `pyproject.toml`, `Cargo.toml`, `Makefile`, etc.)
|
|
18
|
+
- Docker / compose files, CI config, README
|
|
19
|
+
- Existing test, lint, and build commands
|
|
20
|
+
|
|
21
|
+
## Step 2 — Adapt `.har/` files
|
|
22
|
+
|
|
23
|
+
Replace all TODO placeholders. Key files:
|
|
24
|
+
|
|
25
|
+
### Primary application & shared services (decide this FIRST)
|
|
26
|
+
|
|
27
|
+
Identify the **primary application** — the ONE app coding agents will modify and run per-slot. Everything else is shared and runs once for all slots:
|
|
28
|
+
|
|
29
|
+
1. **Primary app** → set `HARNESS_PRIMARY_APP` in `harness.env`; wire ONLY its dev processes into `ecosystem.agent.template.cjs` (a primary app may still need several processes, e.g. api + frontend of the same app).
|
|
30
|
+
2. **External dependencies** (database, cache, queue, mail, ...) → keep/add them as services in `docker-compose.agent.yml`, delete the menu entries the project doesn't use, and list the needed ones in `HARNESS_INFRA_SERVICES` (e.g. `"db redis"`). They start once via `setup-infra.sh` on fixed ports and serve every slot.
|
|
31
|
+
3. **Internal supporting services** (a monolith/monorepo's other services the agent depends on but is not changing) → do NOT start them per-slot. Run them once and shared: as compose services in `docker-compose.agent.yml`, or as PM2 processes in `.har/ecosystem.shared.config.cjs` (processes named `har-shared-<name>`, started automatically by `setup-infra.sh` when the file exists). Point the primary app at them through `env.template`.
|
|
32
|
+
|
|
33
|
+
Simple single-app repos need none of the extra machinery: one primary app, usually one `db` in `HARNESS_INFRA_SERVICES`, no shared ecosystem file.
|
|
34
|
+
|
|
35
|
+
### `.har/README.md` (required)
|
|
36
|
+
Clear index of the harness: what each file does, quick start, architecture, how to maintain. Update when anything in the harness changes.
|
|
37
|
+
|
|
38
|
+
### `.har/harness.env`
|
|
39
|
+
Primary app, ports, `HARNESS_INFRA_SERVICES`, migrate/seed commands, health check path.
|
|
40
|
+
|
|
41
|
+
### `.har/ecosystem.agent.template.cjs` (default profile only)
|
|
42
|
+
PM2 processes for the primary application only, matching how it runs in dev. Skip entirely for the CLI profile.
|
|
43
|
+
|
|
44
|
+
### `.har/verify.sh`
|
|
45
|
+
Real typecheck, lint, test, and health check commands — replace all TODOs.
|
|
46
|
+
|
|
47
|
+
### Optional Playwright stage
|
|
48
|
+
If the user ran `har env add-stage playwright` (or `@playwright/test` is in package.json):
|
|
49
|
+
|
|
50
|
+
- Adapt `tests/**` selectors and API paths for this stack
|
|
51
|
+
- Ensure `HARNESS_HEALTH_CHECK_PATH` matches the app health route used in API smoke tests
|
|
52
|
+
- `verify --full` runs `browser-e2e` automatically when `.har/stages/browser-e2e.sh` exists
|
|
53
|
+
- Do not wire Playwright into quick `verify` unless the team wants e2e on every loop
|
|
54
|
+
|
|
55
|
+
See `.har/stages/PLAYWRIGHT.md` when present.
|
|
56
|
+
|
|
57
|
+
### `.har/CLAUDE.agent.md`
|
|
58
|
+
Detailed agent instructions: commands, credentials, architecture, definition of done.
|
|
59
|
+
|
|
60
|
+
### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
|
|
61
|
+
Adapt as needed for the project's infra.
|
|
62
|
+
|
|
63
|
+
### Port allocation
|
|
64
|
+
Agents run in parallel on configurable slot ids. Ports: `BASE + (AGENT_ID × 10)`.
|
|
65
|
+
Set slot limits in `.har/stages.json` (`agentSlots`) and `.har/harness.env` (`HARNESS_AGENT_SLOT_MIN` / `HARNESS_AGENT_SLOT_MAX`) based on machine capacity.
|
|
66
|
+
|
|
67
|
+
### Git worktree
|
|
68
|
+
`launch.sh` creates an isolated worktree at `~/worktrees/<project>-agent-<id>` by default (`HARNESS_USE_WORKTREE=true`). Agents should commit from that worktree, not the main checkout.
|
|
69
|
+
|
|
70
|
+
## Step 3 — Update repo-root `AGENT.md`
|
|
71
|
+
|
|
72
|
+
Coding agents discover the harness through two files:
|
|
73
|
+
|
|
74
|
+
1. **`AGENT.md`** (repo root) — short pointer, always read first
|
|
75
|
+
2. **`.har/README.md`** — full index of what's in the harness
|
|
76
|
+
|
|
77
|
+
If **no `AGENT.md` exists**, create one at the repo root using this structure:
|
|
78
|
+
|
|
79
|
+
- Link to `.har/README.md` and `.har/CLAUDE.agent.md`
|
|
80
|
+
- 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)
|
|
81
|
+
- Preferred commands: HAR MCP tools or `har env launch/verify/teardown` (persists run history)
|
|
82
|
+
- Shell fallback: `./.har/launch.sh`, `./.har/verify.sh`, `./.har/teardown.sh` (when CLI is not installed)
|
|
83
|
+
- Rules (no hardcoded ports, use `./.har/agent-cli.sh`, do not touch other agents' resources)
|
|
84
|
+
- Project-specific notes (stack, credentials, definition of done)
|
|
85
|
+
|
|
86
|
+
If **`AGENT.md` already exists**, add or update a concise **HAR / agent environment** section — do not replace unrelated content.
|
|
87
|
+
|
|
88
|
+
### Monorepos / multiple harnesses
|
|
89
|
+
|
|
90
|
+
If this repository contains **more than one project or `.har` harness** (check for `.har/` directories above or below this one):
|
|
91
|
+
|
|
92
|
+
- Maintain a **"Harnesses in this repo"** table in 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."
|
|
93
|
+
- Keep a small `AGENT.md` (and `CLAUDE.md` pointer) **inside each project directory** for local discovery, with a back-link to the root index.
|
|
94
|
+
- Keep ONE Cursor rule at the repo root (`.cursor/rules/har-workflow.mdc`) listing all harnesses — not one rule per project.
|
|
95
|
+
|
|
96
|
+
Include a **Run history** subsection:
|
|
97
|
+
|
|
98
|
+
- `./.har/*.sh` does not write run records
|
|
99
|
+
- `har env …` and MCP write to `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json`
|
|
100
|
+
- With worktrees, code runs in the worktree but run JSON lives in the main checkout `.har/runs/`
|
|
101
|
+
- Document MCP/CLI as the preferred agent interface; shell scripts as fallback
|
|
102
|
+
|
|
103
|
+
## Step 4 — Cleanup checklist (required)
|
|
104
|
+
|
|
105
|
+
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:
|
|
106
|
+
|
|
107
|
+
- [ ] `docker-compose.agent.yml` contains ONLY services this project uses (menu entries and their volumes deleted); `HARNESS_INFRA_SERVICES` lists exactly those services
|
|
108
|
+
- [ ] `env.template` has no env blocks for removed services (MinIO/S3, mailpit, headless browser, ...) and no vars the app never reads
|
|
109
|
+
- [ ] `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)
|
|
110
|
+
- [ ] 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
|
|
111
|
+
- [ ] No `TODO` placeholders remain anywhere in `.har/`
|
|
112
|
+
- [ ] 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`)
|
|
113
|
+
- [ ] `.har/README.md` file table lists exactly the files that exist — no more, no less
|
|
114
|
+
- [ ] `.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
|
|
115
|
+
|
|
116
|
+
## Rules
|
|
117
|
+
|
|
118
|
+
1. Edit `.har/` files directly — no YAML runtime config
|
|
119
|
+
2. Always update `.har/README.md` to reflect current harness state
|
|
120
|
+
3. Reuse existing project commands from package.json, Makefile, CI, etc.
|
|
121
|
+
4. Replace all TODO placeholders
|
|
122
|
+
5. Do not edit `.har/manifest.json` — managed by the har CLI
|
|
123
|
+
|
|
124
|
+
When finished, summarize what you changed, confirm verification commands (`har env verify 1 --full` or `./.har/verify.sh 1 --full`) are correct for this stack, and record the adaptation with `har env maintain --finalize --summary "<what changed>"`.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Update the `.har/` harness in this repository to reflect current codebase changes.
|
|
2
|
+
|
|
3
|
+
## Your mission
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
**Do NOT** create a YAML config or JSON mapping file for runtime behavior. Put behavior directly in the harness scripts and templates.
|
|
8
|
+
|
|
9
|
+
## Step 1 — Inspect the repository
|
|
10
|
+
|
|
11
|
+
Compare the current repo against the existing harness:
|
|
12
|
+
|
|
13
|
+
- Root manifests, CI, Docker, README
|
|
14
|
+
- New or changed test, lint, build, migrate, or seed commands
|
|
15
|
+
- New services, ports, or environment variables
|
|
16
|
+
- Run `har env maintain` drift report (generator version, template checksum mismatches)
|
|
17
|
+
|
|
18
|
+
## Step 2 — Update `.har/` files
|
|
19
|
+
|
|
20
|
+
Prefer targeted edits over full rewrites. Key files to review:
|
|
21
|
+
|
|
22
|
+
### `.har/README.md` (required)
|
|
23
|
+
Keep this accurate — it is the harness index. Update whenever scripts, stages, or workflow change.
|
|
24
|
+
|
|
25
|
+
### `.har/harness.env`, `verify.sh`, `ecosystem.agent.template.cjs`, `CLAUDE.agent.md`
|
|
26
|
+
Align commands and instructions with the current stack.
|
|
27
|
+
|
|
28
|
+
### `.har/env.template`, `setup-infra.sh`, `docker-compose.agent.yml`
|
|
29
|
+
Update only if infra changed.
|
|
30
|
+
|
|
31
|
+
### HAR platform upgrades checklist
|
|
32
|
+
|
|
33
|
+
When upgrading `@osfactory/har` or adopting new harness standards:
|
|
34
|
+
|
|
35
|
+
**Generator 0.4.0 — primary app & shared infra services:**
|
|
36
|
+
|
|
37
|
+
- 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 the bundled template. 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>`.
|
|
38
|
+
- 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).
|
|
39
|
+
- Prune `docker-compose.agent.yml` to only the services this project uses; delete unused menu services and volumes.
|
|
40
|
+
- 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.
|
|
41
|
+
|
|
42
|
+
**Earlier standards:**
|
|
43
|
+
|
|
44
|
+
- Add **Run history** section to repo-root `AGENT.md` if missing (shell vs `har env`, worktree vs runs location)
|
|
45
|
+
- Ensure `AGENT.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)
|
|
46
|
+
- Ensure `launch.sh` installs dependencies in fresh worktrees and resolves the project subdirectory inside the worktree (`git rev-parse --show-prefix`) for monorepos
|
|
47
|
+
- If the repo has multiple projects/harnesses, maintain the **"Harnesses in this repo"** table in root `AGENT.md`, per-project pointer docs, and a single root Cursor rule
|
|
48
|
+
- Remove dead boilerplate files (CLI profile: `ecosystem.agent.template.cjs`, `env.template`, `attach.sh`)
|
|
49
|
+
- Align `launch.sh` / `harness.env` with worktree-default standard (`HARNESS_USE_WORKTREE=true`)
|
|
50
|
+
- Do **not** blindly overwrite customized `verify.sh`
|
|
51
|
+
|
|
52
|
+
## Step 3 — Refresh repo-root `AGENT.md`
|
|
53
|
+
|
|
54
|
+
If harness commands, rules, or workflow changed, update the **HAR / agent environment** section in repo-root `AGENT.md`:
|
|
55
|
+
|
|
56
|
+
- Links to `.har/README.md` and `.har/CLAUDE.agent.md`
|
|
57
|
+
- Preferred: HAR MCP tools or `har env …` (persists run history)
|
|
58
|
+
- Fallback: `./.har/*` shell scripts (when CLI is not installed)
|
|
59
|
+
- Run history rules (shell vs CLI/MCP, worktree vs `.har/runs/` location)
|
|
60
|
+
- Agent rules (ports, agent-cli.sh, isolation)
|
|
61
|
+
- Project-specific notes
|
|
62
|
+
|
|
63
|
+
If `AGENT.md` does not mention HAR yet, add a concise section. If it already has a HAR section, update it minimally — do not replace unrelated content.
|
|
64
|
+
|
|
65
|
+
## Rules
|
|
66
|
+
|
|
67
|
+
1. Prefer targeted edits — keep working harness behavior where still valid
|
|
68
|
+
2. Always update `.har/README.md` when anything in the harness changes
|
|
69
|
+
3. Reuse existing project commands from package.json, Makefile, CI, etc.
|
|
70
|
+
4. Replace any remaining TODO placeholders
|
|
71
|
+
5. Do not edit `.har/manifest.json` — managed by the har CLI
|
|
72
|
+
|
|
73
|
+
When finished, summarize what you changed, confirm verification commands still match the repo, and record the adaptation with `har env maintain --finalize --summary "<what changed>"` (updates the manifest's generator version and checksums).
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: HAR harness workflow — read before change, verify before done
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# HAR Harness Workflow
|
|
7
|
+
|
|
8
|
+
This repository uses a `.har/` agent harness. Follow this workflow on every change.
|
|
9
|
+
|
|
10
|
+
The harness is **how you run the project**, not only how you verify it. To see the app
|
|
11
|
+
live (manual testing, browser sessions, screenshots), launch a slot — never hand-roll
|
|
12
|
+
docker/dev-server startup; the harness already encodes DB setup, ports, and env.
|
|
13
|
+
If a harness command fails, fix the harness or surface the failure — do not quietly
|
|
14
|
+
work around it with ad-hoc commands.
|
|
15
|
+
|
|
16
|
+
## Before making changes
|
|
17
|
+
|
|
18
|
+
1. **Launch your slot FIRST — before editing any file.** Use `har_launch_environment` with `agentId: 1` (MCP), `har env launch 1`, or `./.har/launch.sh 1`. Launch always creates a **fresh session worktree** from the current HEAD and returns its **work dir**.
|
|
19
|
+
2. **Make ALL file edits under the returned work dir — never in the main checkout.** The work dir looks like `~/worktrees/<base-branch>-<sha4>-har-agent-<id>-<rand4>` (recorded in `.har/slots/agent-<id>.json`). Edits there hot-reload in the running slot; use `./.har/agent-cli.sh <id> restart` if a change doesn't take.
|
|
20
|
+
3. Read [AGENT.md](./AGENT.md) at the repo root
|
|
21
|
+
4. Read [.har/README.md](./.har/README.md) and [.har/stages.json](./.har/stages.json)
|
|
22
|
+
5. After launch, read [.har/CLAUDE.agent.md](./.har/CLAUDE.agent.md) for slot URLs and definition of done
|
|
23
|
+
|
|
24
|
+
Relaunching a slot **replaces** its previous session (the old branch is kept). Replacement requires explicit confirmation (`--replace`, `confirmReplace=true`, or an interactive prompt). If the previous session has uncommitted changes, you must also pass `force`/`--force` after **explicit user approval** — never autonomously.
|
|
25
|
+
|
|
26
|
+
### Slot safety (read before launch)
|
|
27
|
+
|
|
28
|
+
- **One slot ≈ one task** — do not share slot 1 across unrelated chats; use slot 2+ for parallel work.
|
|
29
|
+
- **Call `har_get_status` / `./.har/agent-cli.sh <id> status`** before launch when a slot may be occupied.
|
|
30
|
+
- **Never** set `force`/`confirmReplace` without the user explicitly approving replacement.
|
|
31
|
+
- **Commit early and often** in the session worktree — teardown keeps the branch, not uncommitted work.
|
|
32
|
+
- **Gitignored paths are ephemeral** (`state/`, `runs/`, local clones) — they are lost when the worktree is removed.
|
|
33
|
+
- Optional: set `HAR_SESSION_PURPOSE=label` or `--purpose=label` on launch so occupied-slot warnings show what you were doing.
|
|
34
|
+
|
|
35
|
+
<!-- Monorepo: if this repository contains multiple .har harnesses, list them here
|
|
36
|
+
and pick by the files you are changing. Example:
|
|
37
|
+
|
|
38
|
+
## Harnesses in this repo
|
|
39
|
+
|
|
40
|
+
| Path | Runs | Use when changing |
|
|
41
|
+
|------|------|-------------------|
|
|
42
|
+
| `.har/` | backend + frontend | `src/`, `packages/` |
|
|
43
|
+
| `apps/admin/.har/` | admin dashboard | `apps/admin/` |
|
|
44
|
+
|
|
45
|
+
Run harness commands from the directory that owns the harness (e.g. `cd apps/admin`).
|
|
46
|
+
-->
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## After making changes
|
|
50
|
+
|
|
51
|
+
Validate through the harness — do not skip verification or substitute ad-hoc npm/test commands.
|
|
52
|
+
|
|
53
|
+
### 1. HAR MCP (preferred in Cursor when `.cursor/mcp.json` has the har server)
|
|
54
|
+
|
|
55
|
+
- `har_run_verification` with `agentId: 1` — fast loop (typecheck + unit tests)
|
|
56
|
+
- `har_run_verification` with `agentId: 1, full: true` — required before declaring work done
|
|
57
|
+
- `har_complete_environment` with `agentId: 1` — when the work is done: full verify + validation record + teardown, **keeping the session branch** so the user can push it / open a PR
|
|
58
|
+
- `har_teardown_environment` with `agentId: 1` — plain cleanup (also keeps the branch; `deleteBranch: true` to drop it)
|
|
59
|
+
|
|
60
|
+
### 2. HAR CLI (when `har` is installed)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
har env launch 1 # FIRST, before editing — prints the work dir
|
|
64
|
+
har env verify 1
|
|
65
|
+
har env verify 1 --full
|
|
66
|
+
har env complete 1 # done: verify + validate + teardown, branch kept for PR
|
|
67
|
+
har env teardown 1 # plain cleanup (--delete-branch to drop the branch)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3. Shell fallback (no CLI/MCP installed)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
./.har/launch.sh 1
|
|
74
|
+
./.har/verify.sh 1
|
|
75
|
+
./.har/verify.sh 1 --full
|
|
76
|
+
./.har/teardown.sh 1
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Commit your work **inside the session worktree** on its session branch. After completion the branch survives teardown — the user decides whether to push it and open a PR. Run JSON stays in the main checkout `.har/runs/`.
|
|
80
|
+
|
|
81
|
+
## UI changes
|
|
82
|
+
|
|
83
|
+
When the Playwright stage is installed (`.har/stages/browser-e2e.sh` exists), add or update specs under `tests/`. Full verify includes browser-e2e.
|
|
84
|
+
|
|
85
|
+
## Definition of done
|
|
86
|
+
|
|
87
|
+
- Full verification returns pass (`har env verify 1 --full`, MCP `har_run_verification` with `full: true`, or `./.har/verify.sh 1 --full`)
|
|
88
|
+
- All edits live in the session worktree (main checkout untouched: `git status` clean there)
|
|
89
|
+
- New behavior has automated test coverage
|
|
90
|
+
- Show the user the slot preview URLs so they can test the app themselves
|
|
91
|
+
- Do not declare work complete without running full verify
|
|
92
|
+
|
|
93
|
+
## Commit gate
|
|
94
|
+
|
|
95
|
+
Each full verify records the exact code state it validated (a git tree hash under
|
|
96
|
+
`.har/validations/`). When the har commit gate is installed (`har hooks install`),
|
|
97
|
+
`git commit` is blocked unless the staged changes match a state that passed full verify.
|
|
98
|
+
|
|
99
|
+
- Any edit after verify — even one character — requires re-running `har env verify <id> --full`
|
|
100
|
+
- Stage everything you verified (`git add -A`); partially staged trees were never verified and will be rejected
|
|
101
|
+
- Do not bypass the gate (`--no-verify`, `HAR_SKIP_GATE=1`) — bypasses are recorded and visible in Mission Control
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Agent ${AGENT_ID} — Development Environment
|
|
2
|
+
|
|
3
|
+
> [`AGENT.md`](../AGENT.md) · [`.har/README.md`](./README.md) · [`stages.json`](./stages.json)
|
|
4
|
+
|
|
5
|
+
## Environment
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
|--|--|
|
|
9
|
+
| **Agent ID** | ${AGENT_ID} |
|
|
10
|
+
| **Frontend** | http://localhost:${FE_PORT} |
|
|
11
|
+
| **API** | http://localhost:${API_PORT} |
|
|
12
|
+
| **Database** | `agent_${AGENT_ID}` on `localhost:${DB_PORT}` (when `db` is in `HARNESS_INFRA_SERVICES`) |
|
|
13
|
+
| **Work dir** | Fresh session worktree per launch — see the launch output or `.har/slots/agent-${AGENT_ID}.json` |
|
|
14
|
+
|
|
15
|
+
**Never edit the main checkout** — launch FIRST, then make ALL file edits under the work dir from the launch output. Edits there hot-reload in the running slot; use `./.har/agent-cli.sh ${AGENT_ID} restart` if a change doesn't take. Relaunching replaces the session (branch kept) and requires explicit confirmation; dirty worktrees also need `--force` after user approval.
|
|
16
|
+
|
|
17
|
+
This slot runs **only the primary application** (`HARNESS_PRIMARY_APP`). External dependencies and any supporting services run once, shared by all slots — `setup-infra.sh` manages them; never start them yourself.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
./.har/agent-cli.sh ${AGENT_ID} status
|
|
21
|
+
./.har/agent-cli.sh ${AGENT_ID} logs api
|
|
22
|
+
./.har/agent-cli.sh ${AGENT_ID} health
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Definition of done
|
|
26
|
+
|
|
27
|
+
- [ ] Full verification returns `"status": "pass"` (`har env verify ${AGENT_ID} --full`, MCP `har_run_verification` with `full: true`, or `./.har/verify.sh ${AGENT_ID} --full`)
|
|
28
|
+
- [ ] When `stages/browser-e2e.sh` exists, full verify includes Playwright — adapt specs under `tests/` for UI changes
|
|
29
|
+
- [ ] New behavior has automated test coverage (unit and/or browser as appropriate)
|
|
30
|
+
- [ ] Changes committed **in the session worktree** with a clear message
|
|
31
|
+
- [ ] The user got the preview URLs to test the app themselves
|
|
32
|
+
- [ ] Finish with `har env complete ${AGENT_ID}` (or MCP `har_complete_environment`) — records the validation and tears down while **keeping the session branch** for the user to push / open a PR
|
|
33
|
+
|
|
34
|
+
Quick loop during development: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}` (stops before lint and browser-e2e).
|
|
35
|
+
|
|
36
|
+
## Project commands
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# TODO: adapt for this repository (see package.json, Makefile, etc.)
|
|
40
|
+
# npm run typecheck
|
|
41
|
+
# npm test
|
|
42
|
+
# npm run lint
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Do not
|
|
46
|
+
|
|
47
|
+
- Hand-roll docker/dev-server startup — `launch` is how you run the app (manual testing, browser, screenshots included)
|
|
48
|
+
- Work around a failing harness command with ad-hoc setup — fix the harness or report the failure
|
|
49
|
+
- Hardcode ports — use agent env / `agent-cli.sh url`
|
|
50
|
+
- Run raw `docker compose` for shared harness infra — use `setup-infra.sh`
|
|
51
|
+
- Start other services of the repo in your slot — only the primary app runs per-slot; shared services are already running
|
|
52
|
+
- Edit `.env.agent.${AGENT_ID}` or PM2 ecosystem files by hand
|
|
53
|
+
- Run `verify` before `launch` when health or e2e steps need a running server
|
|
54
|
+
- Edit the main checkout — all edits go under the session work dir
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# .har — Agent Harness
|
|
2
|
+
|
|
3
|
+
This directory is the **agent harness** for this repository. It lets AI coding agents (Cursor, Claude Code, etc.) run the project in isolated environments with their own ports, database, and verification workflow.
|
|
4
|
+
|
|
5
|
+
Generated and maintained by [`har`](https://github.com/antoineFrau/har). Run `har env maintain` when the repo stack changes.
|
|
6
|
+
|
|
7
|
+
**The harness is how you run this project.** Need the app live — manual testing, a browser session, screenshots? `launch` a slot; don't hand-roll docker/dev-server startup. If a harness command fails, fix the harness or report it — don't silently fall back to ad-hoc commands.
|
|
8
|
+
|
|
9
|
+
## What's in here
|
|
10
|
+
|
|
11
|
+
| File | Purpose |
|
|
12
|
+
|------|---------|
|
|
13
|
+
| `README.md` | This file — index of the harness |
|
|
14
|
+
| `manifest.json` | Generator metadata (version, checksums) — do not edit |
|
|
15
|
+
| `harness.env` | Shared config: primary app, ports, agent slot limits, `HARNESS_INFRA_SERVICES`, migrate/seed commands |
|
|
16
|
+
| `stages.json` | Machine-readable registry of runnable harness stages |
|
|
17
|
+
| `stages/` | Optional custom stage scripts registered from `stages.json` |
|
|
18
|
+
| `runs/` | Run history from `har env` / MCP only — `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json` (gitignore) |
|
|
19
|
+
| `artifacts/` | Stage outputs: reports, traces, screenshots, logs |
|
|
20
|
+
| `agent-slot.sh` | Shared agent-id validation (reads limits from `harness.env`) |
|
|
21
|
+
| `setup-infra.sh` | Start shared Docker infra + create template database |
|
|
22
|
+
| `launch.sh` | Launch one agent slot (ports, DB clone, PM2 processes) |
|
|
23
|
+
| `verify.sh` | Verification pipeline (typecheck, tests, health) |
|
|
24
|
+
| `teardown.sh` | Tear down one agent slot |
|
|
25
|
+
| `agent-cli.sh` | Manage a running agent (status, logs, psql, health) |
|
|
26
|
+
| `attach.sh` | Attach to agent tmux session |
|
|
27
|
+
| `env.template` | Per-agent env vars (expanded by `launch.sh`) |
|
|
28
|
+
| `ecosystem.agent.template.cjs` | PM2 processes for the **primary app only** (expanded by `launch.sh`) |
|
|
29
|
+
| `ecosystem.shared.config.cjs` | Optional — shared app services started once by `setup-infra.sh` (only when the repo has supporting services) |
|
|
30
|
+
| `docker-compose.agent.yml` | Shared infrastructure containers |
|
|
31
|
+
| `CLAUDE.agent.md` | Detailed instructions for coding agents |
|
|
32
|
+
| `justfile` | Optional shortcuts (requires `just`) |
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
**Preferred — har CLI or MCP** (persists run history under `.har/runs/`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
har env launch 1
|
|
40
|
+
har env verify 1
|
|
41
|
+
har env verify 1 --full
|
|
42
|
+
har env teardown 1
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
In Cursor with HAR MCP configured: use `har_launch_environment`, `har_run_verification`, and `har_teardown_environment`.
|
|
46
|
+
|
|
47
|
+
**Shell fallback** (no CLI/MCP installed):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
./.har/setup-infra.sh # when HARNESS_INFRA_SERVICES is non-empty
|
|
51
|
+
./.har/launch.sh 1
|
|
52
|
+
./.har/verify.sh 1 # quick: typecheck, tests, health
|
|
53
|
+
./.har/verify.sh 1 --full # done gate: + lint + browser-e2e (if Playwright stage installed)
|
|
54
|
+
./.har/teardown.sh 1
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Read **`stages.json`** for registered stages and **`verificationStages`** for the expected pass set.
|
|
58
|
+
|
|
59
|
+
## Verification contract
|
|
60
|
+
|
|
61
|
+
| Mode | Command | Typical steps |
|
|
62
|
+
|------|---------|---------------|
|
|
63
|
+
| Quick | `har env verify <id>` or `verify.sh <id>` | Project checks in `verify.sh` (stops early on failure) |
|
|
64
|
+
| Full | `har env verify <id> --full` or `verify.sh <id> --full` | Quick steps + lint + **`browser-e2e`** when `.har/stages/browser-e2e.sh` exists |
|
|
65
|
+
|
|
66
|
+
Install Playwright stage: `har env add-stage playwright` (optional). UI changes should add or update specs under `tests/`.
|
|
67
|
+
|
|
68
|
+
## Run history
|
|
69
|
+
|
|
70
|
+
| Entry point | Writes `.har/runs/`? |
|
|
71
|
+
|-------------|------------------------|
|
|
72
|
+
| `./.har/*.sh` | No — same scripts, no run record |
|
|
73
|
+
| `har env …` / MCP | Yes — under main checkout `.har/runs/YYYY-MM-DD/` |
|
|
74
|
+
|
|
75
|
+
With git worktree slots, verification runs code in the worktree but run JSON stays in the main repo `.har/runs/`. Each record includes `workDir` when a slot is active.
|
|
76
|
+
|
|
77
|
+
## For coding agents
|
|
78
|
+
|
|
79
|
+
1. Read repo [`AGENT.md`](../AGENT.md)
|
|
80
|
+
2. Read this file and `stages.json`
|
|
81
|
+
3. After launch, read `.har/CLAUDE.agent.md` for slot URLs and definition of done
|
|
82
|
+
|
|
83
|
+
Prefer HAR MCP tools or `har env …` for launch, verify, and teardown. Use `./.har/*.sh` only when the CLI is not installed.
|
|
84
|
+
|
|
85
|
+
Always use `./.har/agent-cli.sh <id> ...` — never hardcoded ports.
|
|
86
|
+
|
|
87
|
+
## Architecture
|
|
88
|
+
|
|
89
|
+
Each agent slot gets isolated ports: `BASE + (AGENT_ID × 10)`.
|
|
90
|
+
|
|
91
|
+
Configure how many slots your machine can run in parallel in `stages.json` (`agentSlots`) and `harness.env` (`HARNESS_AGENT_SLOT_MIN` / `HARNESS_AGENT_SLOT_MAX`). Keep both in sync.
|
|
92
|
+
|
|
93
|
+
| Service | Agent 1 | Agent 2 |
|
|
94
|
+
|---------|---------|---------|
|
|
95
|
+
| Frontend | 3010 | 3020 |
|
|
96
|
+
| API | 8010 | 8020 |
|
|
97
|
+
|
|
98
|
+
### Primary app vs shared services
|
|
99
|
+
|
|
100
|
+
Each slot runs **only the primary application** (`HARNESS_PRIMARY_APP` in `harness.env`) — the app agents modify. Everything else runs **once**, shared by all slots on fixed ports:
|
|
101
|
+
|
|
102
|
+
- **External dependencies** (Postgres, Redis, mail, ...): services in `docker-compose.agent.yml`, enabled via the `HARNESS_INFRA_SERVICES` list in `harness.env`, started by `setup-infra.sh`.
|
|
103
|
+
- **Internal supporting services** (other services of a monolith/monorepo the agent depends on but does not change): either compose services in `docker-compose.agent.yml`, or PM2 processes in an optional `.har/ecosystem.shared.config.cjs` (named `har-shared-<name>`, started by `setup-infra.sh`).
|
|
104
|
+
|
|
105
|
+
Isolation still applies where it matters: each slot gets its own database (`agent_<id>`, cloned from the template DB), ports, and git worktree.
|
|
106
|
+
|
|
107
|
+
## Maintaining this harness
|
|
108
|
+
|
|
109
|
+
When the project stack changes (new services, different test commands, new env vars):
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
har env maintain
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The authoring agent updates scripts and this README. Review changes before committing.
|
|
116
|
+
|
|
117
|
+
**Do not** put runtime behavior in YAML — edit the scripts directly.
|
|
118
|
+
|
|
119
|
+
## Session lifecycle
|
|
120
|
+
|
|
121
|
+
Every `launch` starts a **fresh session**: a new git worktree from the current HEAD at
|
|
122
|
+
`~/worktrees/<base-branch>-<sha4>-har-agent-<id>-<rand4>`, on a branch of the same name.
|
|
123
|
+
The session is recorded in `.har/slots/agent-<id>.json` (the slot registry) — status,
|
|
124
|
+
verify, and teardown resolve the work dir through it. Make ALL file edits under the
|
|
125
|
+
work dir printed by launch, never in the main checkout.
|
|
126
|
+
|
|
127
|
+
- Relaunching a slot **replaces** its previous session; replacement requires `--replace` /
|
|
128
|
+
`confirmReplace=true` (or an interactive prompt). Uncommitted changes also need `--force`
|
|
129
|
+
after explicit user approval.
|
|
130
|
+
- `teardown` removes the worktree but **keeps the session branch** so you can push it
|
|
131
|
+
or open a PR (`--delete-branch` to drop it).
|
|
132
|
+
- `har env complete <id>` finishes a session: full verify (recorded as a validation),
|
|
133
|
+
then teardown — branch kept.
|
|
134
|
+
- `--no-worktree` runs the slot from the repo root instead (single-agent mode).
|