@osfactory/har 0.43.2 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +32073 -41708
- package/dist/templates/AGENTS.md.template +78 -0
- package/dist/templates/CLAUDE.md.template +1 -1
- package/dist/templates/adaptation-prompt-init.md +12 -6
- package/dist/templates/adaptation-prompt-maintain.md +18 -6
- package/dist/templates/agent-skills/har-maintain.md +2 -2
- package/dist/templates/agent-skills/har-wt.md +8 -3
- package/dist/templates/agent-skills/setup-har.md +2 -2
- package/dist/templates/cursor-rule.mdc.template +3 -2
- package/dist/templates/har-boilerplate/CLAUDE.agent.md +1 -1
- package/dist/templates/har-boilerplate/README.md +1 -1
- package/dist/templates/har-boilerplate/gitignore.template +2 -0
- package/dist/templates/har-boilerplate-cli/CLAUDE.agent.md +1 -1
- package/dist/templates/har-boilerplate-cli/README.md +1 -1
- package/dist/templates/har-boilerplate-cli/gitignore.template +2 -0
- package/dist/templates/har-boilerplate-ios/ADAPT-PROMPT.md +2 -2
- package/dist/templates/har-boilerplate-ios/CLAUDE.agent.md +1 -1
- package/dist/templates/har-boilerplate-ios/gitignore.template +2 -0
- package/package.json +3 -5
- package/dist/prompts/system-authoring.md +0 -155
- package/dist/templates/AGENT.md.template +0 -46
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Agent Environment
|
|
2
|
+
|
|
3
|
+
This repository uses a **`.har/` harness** for isolated agent development.
|
|
4
|
+
|
|
5
|
+
<!-- har:agent-environment:start -->
|
|
6
|
+
## HAR / agent environment
|
|
7
|
+
|
|
8
|
+
The harness is not just a verification gate — it is **how you run this project**.
|
|
9
|
+
To see the app live (manual testing, browser sessions, screenshots, driving the UI),
|
|
10
|
+
use `har env launch <id>` or `./.har/launch.sh <id>`. It already encodes database
|
|
11
|
+
setup, ports, env vars, and process management — never hand-roll `docker` / dev-server
|
|
12
|
+
startup, and never claim a task "can't be verified live" without launching a slot first.
|
|
13
|
+
|
|
14
|
+
If a harness command fails, fix the harness (or report the failure) — do not quietly
|
|
15
|
+
fall back to ad-hoc commands.
|
|
16
|
+
|
|
17
|
+
### Before making changes
|
|
18
|
+
|
|
19
|
+
1. On the **main checkout**, switch to the intended base (usually `main`) — launch
|
|
20
|
+
creates a worktree from that HEAD.
|
|
21
|
+
2. **Launch first** — MCP `har_launch_environment` / `har env launch 1`. Use the
|
|
22
|
+
returned **work dir** for ALL edits (never the main checkout).
|
|
23
|
+
**Bind tracker work** when the task names a durable issue or ticket (GitHub,
|
|
24
|
+
Linear, etc.): pass a short repo-scoped `--work-id` / `workUnitId` (e.g.
|
|
25
|
+
`widget-123`), `--work-source` / `source`, `--work-url` / `sourceUrl`, and
|
|
26
|
+
`--work-title` / `title` when known. Skip binding for ad-hoc work with no
|
|
27
|
+
tracker identity.
|
|
28
|
+
3. Read [`.har/README.md`](.har/README.md), [`.har/stages.json`](.har/stages.json), then
|
|
29
|
+
[`.har/CLAUDE.agent.md`](.har/CLAUDE.agent.md) (slot URLs / definition of done).
|
|
30
|
+
4. Hot-reload usually applies; if not, `./.har/agent-cli.sh <id> restart` (no-op on
|
|
31
|
+
cli/ios profiles without managed processes).
|
|
32
|
+
|
|
33
|
+
**Occupied slots always block.** Run `complete` / `teardown`, then `launch`. Resume
|
|
34
|
+
failed/starting launches with `--resume` / `recover`. Prefer a free slot (2+) over
|
|
35
|
+
sharing slot 1 across unrelated chats. Check `har_get_status` / `har env status` first.
|
|
36
|
+
Commit early — teardown keeps the branch, not uncommitted work.
|
|
37
|
+
|
|
38
|
+
### After making changes
|
|
39
|
+
|
|
40
|
+
Prefer MCP → CLI → shell. Quick verify for the loop; **full verify before done**.
|
|
41
|
+
|
|
42
|
+
- MCP: `har_run_verification` / `full: true`; finish with `har_complete_environment`
|
|
43
|
+
(propose; wait for approval) or `har_teardown_environment`
|
|
44
|
+
- CLI: `har env verify 1`, `har env verify 1 --full`, `complete 1`, `teardown 1`
|
|
45
|
+
- Shell: `./.har/verify.sh 1`, `./.har/verify.sh 1 --full`, `./.har/teardown.sh 1`
|
|
46
|
+
|
|
47
|
+
Commit in the session worktree. Run JSON stays in the main checkout `.har/runs/`.
|
|
48
|
+
|
|
49
|
+
### Definition of done
|
|
50
|
+
|
|
51
|
+
- Full verify passes; edits only in the session worktree; tests cover new behavior;
|
|
52
|
+
changes committed; show preview URLs; then **session handoff** (below).
|
|
53
|
+
|
|
54
|
+
### Session handoff (required)
|
|
55
|
+
|
|
56
|
+
After full verify and commit, stop. Include summary, session branch
|
|
57
|
+
(`.har/slots/agent-<id>.json`), and preview URLs. Wait — never autonomously
|
|
58
|
+
complete, teardown, push, or open a PR. **Default:** when `gh`/GitHub MCP is available,
|
|
59
|
+
recommend **Complete + open a PR** (still needs approval). Alternatives: **Complete only**,
|
|
60
|
+
or **Something else**. Without PR tooling, recommend **Complete only** and give the
|
|
61
|
+
session branch for a manual push.
|
|
62
|
+
|
|
63
|
+
### Commit gate
|
|
64
|
+
|
|
65
|
+
Full verify records a tree hash under `.har/validations/`. With `har hooks install`,
|
|
66
|
+
commits must match a passing full verify. Re-verify after any edit; `git add -A`.
|
|
67
|
+
Do not bypass (`--no-verify`, `HAR_SKIP_GATE=1`).
|
|
68
|
+
|
|
69
|
+
### Cursor IDE
|
|
70
|
+
|
|
71
|
+
If `.cursor/rules/har-workflow.mdc` exists, the same harness workflow is injected into
|
|
72
|
+
every Cursor agent session automatically. Run `har env init` or `har env maintain` to
|
|
73
|
+
create or refresh it.
|
|
74
|
+
<!-- har:agent-environment:end -->
|
|
75
|
+
|
|
76
|
+
## Project-specific notes
|
|
77
|
+
|
|
78
|
+
<!-- Adapt when customizing the harness (see .har/ADAPT-PROMPT.md) -->
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# __PROJECT_DISPLAY_NAME__
|
|
2
2
|
|
|
3
|
-
Read [
|
|
3
|
+
Read [AGENTS.md](./AGENTS.md) and [.har/README.md](./.har/README.md) before changing this project.
|
|
4
4
|
Harness workflow is enforced automatically in Cursor via `.cursor/rules/har-workflow.mdc`
|
|
5
5
|
(created by `har env init`).
|
|
@@ -167,14 +167,18 @@ Onboarding may set an initial `agentSlots.max` in `.har/stages.json`. After you
|
|
|
167
167
|
### Git worktree
|
|
168
168
|
`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.
|
|
169
169
|
|
|
170
|
-
## Step 3 — Update repo-root `
|
|
170
|
+
## Step 3 — Update repo-root `AGENTS.md`
|
|
171
171
|
|
|
172
172
|
Coding agents discover the harness through two files:
|
|
173
173
|
|
|
174
|
-
1. **`
|
|
174
|
+
1. **`AGENTS.md`** (repo root) — shared agent instructions (Codex auto-loads this; Claude via `CLAUDE.md` pointer)
|
|
175
175
|
2. **`.har/README.md`** — full index of what's in the harness
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
Do **not** create `AGENT.md` (singular) — that legacy name is obsolete. If `AGENT.md` exists, merge any unique notes into `AGENTS.md` and delete `AGENT.md`.
|
|
178
|
+
|
|
179
|
+
If **`har env init` already created `AGENTS.md`**, refresh the **HAR / agent environment** section and fill in **Project-specific notes** — do not wipe unrelated content.
|
|
180
|
+
|
|
181
|
+
If **no `AGENTS.md` exists**, create one at the repo root using this structure:
|
|
178
182
|
|
|
179
183
|
- Link to `.har/README.md` and `.har/CLAUDE.agent.md`
|
|
180
184
|
- 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)
|
|
@@ -183,14 +187,16 @@ If **no `AGENT.md` exists**, create one at the repo root using this structure:
|
|
|
183
187
|
- Rules (no hardcoded ports, use `./.har/agent-cli.sh`, do not touch other agents' resources)
|
|
184
188
|
- Project-specific notes (stack, credentials, definition of done)
|
|
185
189
|
|
|
186
|
-
If **`
|
|
190
|
+
If **`AGENTS.md` already exists** (project-owned), add or update a concise **HAR / agent environment** section — do not replace unrelated content.
|
|
191
|
+
|
|
192
|
+
Keep **`CLAUDE.md`** as a thin pointer to `AGENTS.md` (Claude Code auto-loads `CLAUDE.md`). Do not paste the full harness workflow into `CLAUDE.md`.
|
|
187
193
|
|
|
188
194
|
### Monorepos / multiple harnesses
|
|
189
195
|
|
|
190
196
|
If this repository contains **more than one project or `.har` harness** (check for `.har/` directories above or below this one):
|
|
191
197
|
|
|
192
|
-
- Maintain a **"Harnesses in this repo"** table in the ROOT `
|
|
193
|
-
- Keep a small `
|
|
198
|
+
- Maintain a **"Harnesses in this repo"** table in the ROOT `AGENTS.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."
|
|
199
|
+
- Keep a small `AGENTS.md` (and `CLAUDE.md` pointer) **inside each project directory** for local discovery, with a back-link to the root index.
|
|
194
200
|
- Keep ONE Cursor rule at the repo root (`.cursor/rules/har-workflow.mdc`) listing all harnesses — not one rule per project.
|
|
195
201
|
|
|
196
202
|
Include a **Run history** subsection:
|
|
@@ -64,6 +64,16 @@ and the repo-specific definition of "agent usable."
|
|
|
64
64
|
|
|
65
65
|
When upgrading `@osfactory/har` or adopting new harness standards:
|
|
66
66
|
|
|
67
|
+
**Generator 0.5.0 — `AGENTS.md` (canonical agent guide):**
|
|
68
|
+
|
|
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`.
|
|
76
|
+
|
|
67
77
|
**Generator 0.4.0 — primary app & shared infra services:**
|
|
68
78
|
|
|
69
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>`.
|
|
@@ -74,17 +84,17 @@ When upgrading `@osfactory/har` or adopting new harness standards:
|
|
|
74
84
|
|
|
75
85
|
**Earlier standards:**
|
|
76
86
|
|
|
77
|
-
- Add **Run history** section to repo-root `
|
|
78
|
-
- Ensure `
|
|
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)
|
|
79
89
|
- Ensure `launch.sh` installs dependencies in fresh worktrees and resolves the project subdirectory inside the worktree (`git rev-parse --show-prefix`) for monorepos
|
|
80
|
-
- If the repo has multiple projects/harnesses, maintain the **"Harnesses in this repo"** table in root `
|
|
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
|
|
81
91
|
- Remove dead boilerplate files (CLI profile: `ecosystem.agent.template.cjs`, `env.template`, `attach.sh`)
|
|
82
92
|
- Align `launch.sh` / `harness.env` with worktree-default standard (`HARNESS_USE_WORKTREE=true`)
|
|
83
93
|
- Do **not** blindly overwrite customized `verify.sh`
|
|
84
94
|
|
|
85
|
-
## Step 3 — Refresh repo-root `
|
|
95
|
+
## Step 3 — Refresh repo-root `AGENTS.md`
|
|
86
96
|
|
|
87
|
-
If harness commands, rules, or workflow changed, update the **HAR / agent environment** section in repo-root `
|
|
97
|
+
If harness commands, rules, or workflow changed, update the **HAR / agent environment** section in repo-root `AGENTS.md`:
|
|
88
98
|
|
|
89
99
|
- Links to `.har/README.md` and `.har/CLAUDE.agent.md`
|
|
90
100
|
- Preferred: HAR MCP tools or `har env …` (persists run history)
|
|
@@ -93,7 +103,9 @@ If harness commands, rules, or workflow changed, update the **HAR / agent enviro
|
|
|
93
103
|
- Agent rules (ports, agent-cli.sh, isolation)
|
|
94
104
|
- Project-specific notes
|
|
95
105
|
|
|
96
|
-
If `
|
|
106
|
+
If `AGENTS.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.
|
|
107
|
+
|
|
108
|
+
Do **not** create `AGENT.md` (singular). If legacy `AGENT.md` exists, merge unique notes into `AGENTS.md` and delete `AGENT.md`. Keep `CLAUDE.md` as a thin pointer to `AGENTS.md`.
|
|
97
109
|
|
|
98
110
|
## Rules
|
|
99
111
|
|
|
@@ -12,7 +12,7 @@ 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 `
|
|
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.
|
|
16
16
|
|
|
17
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.
|
|
18
18
|
|
|
@@ -31,6 +31,6 @@ Fix the harness until launch and full verify pass. Tear down afterwards if the s
|
|
|
31
31
|
After the user confirms:
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
git add .har/
|
|
34
|
+
git add .har/ AGENTS.md
|
|
35
35
|
git commit -m "chore: maintain har harness"
|
|
36
36
|
```
|
|
@@ -21,11 +21,16 @@ har env launch <id> # or ./.har/launch.sh <id>
|
|
|
21
21
|
|
|
22
22
|
Launch creates a fresh session worktree from HEAD and prints its **work dir** (also recorded in `.har/slots/agent-<id>.json`, path like `~/worktrees/<base>-<sha4>-har-agent-<id>-<rand4>`). If a previous launch failed partway, retry with `--resume` instead of starting fresh.
|
|
23
23
|
|
|
24
|
-
If the task already has a stable issue or ticket
|
|
25
|
-
methodology that produced it
|
|
24
|
+
If the task already has a stable issue or ticket, bind it without changing the
|
|
25
|
+
methodology that produced it. Use a short repo-scoped id; put the provider and
|
|
26
|
+
canonical URL in separate fields:
|
|
26
27
|
|
|
27
28
|
```bash
|
|
28
|
-
har env launch <id>
|
|
29
|
+
har env launch <id> \
|
|
30
|
+
--work-id "widget-123" \
|
|
31
|
+
--work-source github \
|
|
32
|
+
--work-url "https://github.com/acme/widget/issues/123" \
|
|
33
|
+
--work-title "<title>"
|
|
29
34
|
```
|
|
30
35
|
|
|
31
36
|
External planning/TDD/review skills remain in control of implementation strategy.
|
|
@@ -36,7 +36,7 @@ If `.har/` already exists, stop and suggest `/har-maintain` instead.
|
|
|
36
36
|
|
|
37
37
|
## 4. Perform the adaptation yourself
|
|
38
38
|
|
|
39
|
-
`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 `
|
|
39
|
+
`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.
|
|
40
40
|
|
|
41
41
|
## 5. Register the project's checks as stages
|
|
42
42
|
|
|
@@ -63,7 +63,7 @@ Fix the harness scripts until both pass. Then tear down or keep the slot as the
|
|
|
63
63
|
After the user confirms, commit the harness:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
git add .har/
|
|
66
|
+
git add .har/ AGENTS.md CLAUDE.md .claude/ .cursor/ 2>/dev/null || git add .har/ AGENTS.md
|
|
67
67
|
git commit -m "chore: add har agent harness"
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -18,8 +18,9 @@ startup. If a harness command fails, fix the harness or surface the failure.
|
|
|
18
18
|
2. **Launch first** — MCP `har_launch_environment` / `har env launch 1`. Use the
|
|
19
19
|
returned **work dir** for ALL edits (never the main checkout). Path looks like
|
|
20
20
|
`~/worktrees/<base>-<sha4>-har-agent-<id>-<rand4>` (see `.har/slots/agent-<id>.json`).
|
|
21
|
-
Bind tracker work
|
|
22
|
-
|
|
21
|
+
**Bind tracker work** when the task names an issue or ticket — short `--work-id`
|
|
22
|
+
(e.g. `widget-123`) plus `--work-source` / `--work-url` / `--work-title`. Skip for ad-hoc work.
|
|
23
|
+
3. Read `AGENTS.md`, `.har/README.md`, `.har/stages.json`, then
|
|
23
24
|
`.har/CLAUDE.agent.md` (slot URLs / definition of done).
|
|
24
25
|
4. Hot-reload usually applies; if not, `./.har/agent-cli.sh <id> restart` (no-op on
|
|
25
26
|
cli/ios profiles without managed processes).
|
|
@@ -103,7 +103,7 @@ With git worktree slots, verification runs code in the worktree but run JSON sta
|
|
|
103
103
|
|
|
104
104
|
## For coding agents
|
|
105
105
|
|
|
106
|
-
1. Read repo [`
|
|
106
|
+
1. Read repo [`AGENTS.md`](../AGENTS.md)
|
|
107
107
|
2. Read this file and `stages.json`
|
|
108
108
|
3. After launch, read `.har/CLAUDE.agent.md` for slot URLs and definition of done
|
|
109
109
|
|
|
@@ -89,7 +89,7 @@ With worktree slots, tests run in the worktree; run JSON lives in the main repo.
|
|
|
89
89
|
|
|
90
90
|
## For coding agents
|
|
91
91
|
|
|
92
|
-
**Start here:** read [`
|
|
92
|
+
**Start here:** read [`AGENTS.md`](../AGENTS.md) at the repo root for a short pointer, then [`.har/CLAUDE.agent.md`](./CLAUDE.agent.md) for full instructions.
|
|
93
93
|
|
|
94
94
|
Prefer HAR MCP tools or `har env …` for launch, verify, and teardown. Use `./.har/*.sh` only when the CLI is not installed.
|
|
95
95
|
|
|
@@ -5,7 +5,7 @@ structure, then make the changes listed below. Commit when done.
|
|
|
5
5
|
|
|
6
6
|
## 1 — Read before editing
|
|
7
7
|
|
|
8
|
-
- `
|
|
8
|
+
- `AGENTS.md` at the repo root (overview and do-nots)
|
|
9
9
|
- `.har/README.md` (harness index)
|
|
10
10
|
- `.har/harness.env` (all config vars)
|
|
11
11
|
- `.har/stages.json` (stage registry)
|
|
@@ -41,7 +41,7 @@ har env add-plugin rocketsim
|
|
|
41
41
|
Then adapt `flows/example-smoke.sh` to navigate to your app's main screen and verify it loads.
|
|
42
42
|
Read `.har/stages/ROCKETSIM.md` for the full authoring guide.
|
|
43
43
|
|
|
44
|
-
## 5 — Update `
|
|
44
|
+
## 5 — Update `AGENTS.md` (repo root)
|
|
45
45
|
|
|
46
46
|
Replace the TODO section with:
|
|
47
47
|
- Which Xcode scheme and simulator are used
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent ${AGENT_ID} — iOS Development Environment
|
|
2
2
|
|
|
3
|
-
> [`
|
|
3
|
+
> [`AGENTS.md`](../AGENTS.md) · [`.har/README.md`](./README.md) · [`stages.json`](./stages.json)
|
|
4
4
|
|
|
5
5
|
## Environment
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osfactory/har",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.45.0",
|
|
4
|
+
"description": "Open harness for reproducible multi-agent coding workflows",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"har",
|
|
7
7
|
"cli",
|
|
8
8
|
"mcp",
|
|
9
9
|
"agent",
|
|
10
10
|
"harness",
|
|
11
|
-
"llm",
|
|
12
11
|
"devops"
|
|
13
12
|
],
|
|
14
13
|
"bin": {
|
|
@@ -21,7 +20,7 @@
|
|
|
21
20
|
"control/docker-compose.build.yml"
|
|
22
21
|
],
|
|
23
22
|
"scripts": {
|
|
24
|
-
"build": "esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.js --banner:js='#!/usr/bin/env node' && rm -rf dist/templates
|
|
23
|
+
"build": "esbuild src/index.ts --bundle --platform=node --target=node20 --outfile=dist/index.js --banner:js='#!/usr/bin/env node' && rm -rf dist/templates && cp -r src/templates dist/templates",
|
|
25
24
|
"dev": "tsx src/index.ts",
|
|
26
25
|
"test": "jest",
|
|
27
26
|
"test:watch": "jest --watch",
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
"release": "semantic-release"
|
|
33
32
|
},
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@anthropic-ai/sdk": "^0.27.0",
|
|
36
34
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
37
35
|
"@pydantic/genai-prices": "^0.0.73",
|
|
38
36
|
"chalk": "^5.3.0",
|
|
@@ -1,155 +0,0 @@
|
|
|
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
|
|
@@ -1,46 +0,0 @@
|
|
|
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/complete`** — they persist run history under `.har/runs/`.
|
|
29
|
-
Use `./.har/*.sh` only when the CLI is not installed.
|
|
30
|
-
|
|
31
|
-
When the work is done: full verify, commit in the session worktree, then present a
|
|
32
|
-
**session handoff** and wait for the user. The **default recommendation** is
|
|
33
|
-
complete + open a PR when `gh`/GitHub MCP is available (still requires approval);
|
|
34
|
-
alternatives are complete-only or something else. See
|
|
35
|
-
`.cursor/rules/har-workflow.mdc` for the handoff template.
|
|
36
|
-
|
|
37
|
-
## Commit gate
|
|
38
|
-
|
|
39
|
-
Full verify records the exact code state it validated (git tree hash in `.har/validations/`).
|
|
40
|
-
If the commit gate is installed (`har hooks install`), commits of unverified changes are blocked:
|
|
41
|
-
run `har env verify <id> --full` after your last edit, then `git add -A` and commit — any edit
|
|
42
|
-
after verify invalidates the batch and requires a re-run. Do not bypass with `--no-verify`.
|
|
43
|
-
|
|
44
|
-
## Project-specific notes
|
|
45
|
-
|
|
46
|
-
<!-- Adapt when customizing the harness (see .har/ADAPT-PROMPT.md) -->
|