@osfactory/har 0.34.0 → 0.35.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.
@@ -25,9 +25,14 @@ Run `har env init` or `har env maintain` to create or refresh it.
25
25
 
26
26
  ## Harness workflow
27
27
 
28
- Prefer **HAR MCP tools** (Cursor) or **`har env launch/verify/teardown`** — they persist run history under `.har/runs/`.
28
+ Prefer **HAR MCP tools** (Cursor) or **`har env launch/verify/complete`** — they persist run history under `.har/runs/`.
29
29
  Use `./.har/*.sh` only when the CLI is not installed.
30
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 before `har env complete <id>` /
33
+ `har_complete_environment` (recommended finish: validation + teardown, branch kept),
34
+ push, or opening a PR. See `.cursor/rules/har-workflow.mdc` for the handoff template.
35
+
31
36
  ## Commit gate
32
37
 
33
38
  Full verify records the exact code state it validated (git tree hash in `.har/validations/`).
@@ -55,8 +55,8 @@ Validate through the harness — do not skip verification or substitute ad-hoc n
55
55
 
56
56
  - `har_run_verification` with `agentId: 1` — fast loop (typecheck + unit tests)
57
57
  - `har_run_verification` with `agentId: 1, full: true` — required before declaring work done
58
- - `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
59
- - `har_teardown_environment` with `agentId: 1` — plain cleanup (also keeps the branch; `deleteBranch: true` to drop it)
58
+ - `har_complete_environment` with `agentId: 1` — **recommended finish** (full verify + validation record + teardown, branch kept). **Propose and wait for user approval** before invoking — never run autonomously
59
+ - `har_teardown_environment` with `agentId: 1` — plain cleanup only (also keeps the branch; `deleteBranch: true` to drop it). Prefer `complete` when the work succeeded
60
60
 
61
61
  ### 2. HAR CLI (when `har` is installed)
62
62
 
@@ -88,8 +88,53 @@ When the Playwright stage is installed (`.har/stages/browser-e2e.sh` exists), ad
88
88
  - Full verification returns pass (`har env verify 1 --full`, MCP `har_run_verification` with `full: true`, or `./.har/verify.sh 1 --full`)
89
89
  - All edits live in the session worktree (main checkout untouched: `git status` clean there)
90
90
  - New behavior has automated test coverage
91
+ - Changes committed in the session worktree
91
92
  - Show the user the slot preview URLs so they can test the app themselves
92
93
  - Do not declare work complete without running full verify
94
+ - **Present session handoff and wait for the user's next instruction** — do not end the session without the handoff prompt
95
+
96
+ ## Session handoff (required)
97
+
98
+ After full verify passes and changes are committed, **stop and hand off**. Never
99
+ autonomously run `complete`, `teardown`, `git push`, or create a pull request.
100
+
101
+ Present a handoff that includes:
102
+
103
+ 1. **Summary** of what changed
104
+ 2. **Session branch** name (from launch / `.har/slots/agent-<id>.json`)
105
+ 3. **Preview URLs** when the slot has a running app
106
+ 4. **Numbered next-step options** — then wait for the user
107
+
108
+ Options to offer:
109
+
110
+ 1. **Complete the slot** (recommended) — `har env complete <id>` / MCP
111
+ `har_complete_environment`: full verify + validation record + worktree/runtime
112
+ teardown; **branch kept**. Prefer this over bare `teardown` when the work
113
+ succeeded.
114
+ 2. **Open a PR** — only if `gh` CLI or GitHub MCP is available. Create the PR
115
+ **only after explicit user approval**.
116
+ 3. **Keep the branch only** — if PR tooling is unavailable, report the session
117
+ branch and how to push manually. The branch already exists from launch.
118
+
119
+ Canonical handoff shape:
120
+
121
+ ```markdown
122
+ ## Session handoff
123
+
124
+ **Summary:** …
125
+ **Branch:** `<session-branch>` (session worktree)
126
+ **Preview:** … (if applicable)
127
+
128
+ Next steps — tell me which you want:
129
+ 1. **Complete the slot** — I'll run `har env complete <id>` (full verify + validation record + teardown; branch kept)
130
+ 2. **Open a PR** — I can create one with `gh`/GitHub MCP (requires your approval)
131
+ 3. **Something else** — e.g. keep the slot running, more changes, or push only
132
+
133
+ I'll wait for your instruction before running complete, teardown, push, or PR.
134
+ ```
135
+
136
+ Omit option 2 when neither `gh` nor GitHub MCP is available; replace it with push
137
+ instructions for the session branch.
93
138
 
94
139
  ## Commit gate
95
140
 
@@ -43,7 +43,17 @@ is alive; it does not automatically mean an agent can use the app.
43
43
  - [ ] New behavior has automated test coverage (unit and/or browser as appropriate)
44
44
  - [ ] Changes committed **in the session worktree** with a clear message
45
45
  - [ ] The user got the preview URLs to test the app themselves
46
- - [ ] 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
46
+ - [ ] Present session handoff (summary, branch, preview URLs) and **wait for user** before `complete`, push, or PR
47
+ - [ ] On user approval: `har env complete ${AGENT_ID}` (or MCP `har_complete_environment`) — full verify + validation + teardown, branch kept
48
+
49
+ ### Session handoff
50
+
51
+ After full verify and commit, stop and propose next steps. Never autonomously run
52
+ `complete`, `teardown`, `git push`, or open a PR. Prefer `complete` over bare
53
+ `teardown` when the work succeeded. Offer a PR only if `gh` or GitHub MCP is
54
+ available (and only after explicit approval); otherwise report the session branch
55
+ for a manual push. See `.cursor/rules/har-workflow.mdc` for the canonical handoff
56
+ template.
47
57
 
48
58
  Quick loop during development: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}` (smoke + health only; `--full` adds the registered verification stages).
49
59
 
@@ -29,7 +29,17 @@ workflow, document the required credentials/default data and wire a smoke into
29
29
  - [ ] Full verify runs every registered stage in `stages.json` `verificationStages` (Playwright, custom checks, …) — when `stages/browser-e2e.sh` exists, adapt specs under `tests/` for UI changes
30
30
  - [ ] New behavior has automated test coverage
31
31
  - [ ] Changes committed **in the session worktree** with a clear message
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
32
+ - [ ] Present session handoff (summary, branch, preview URLs) and **wait for user** before `complete`, push, or PR
33
+ - [ ] On user approval: `har env complete ${AGENT_ID}` (or MCP `har_complete_environment`) — full verify + validation + teardown, branch kept
34
+
35
+ ### Session handoff
36
+
37
+ After full verify and commit, stop and propose next steps. Never autonomously run
38
+ `complete`, `teardown`, `git push`, or open a PR. Prefer `complete` over bare
39
+ `teardown` when the work succeeded. Offer a PR only if `gh` or GitHub MCP is
40
+ available (and only after explicit approval); otherwise report the session branch
41
+ for a manual push. See `.cursor/rules/har-workflow.mdc` for the canonical handoff
42
+ template.
33
43
 
34
44
  Quick loop: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}`
35
45
 
@@ -31,7 +31,17 @@ seeded data, or a simulator flow, document it here and wire the smoke into
31
31
  - [ ] When `stages/rocketsim-flows.sh` exists, full verify includes user-flow validation — add or update flow scripts in `flows/` for UI changes
32
32
  - [ ] New behavior has automated test coverage (unit tests via XCTest)
33
33
  - [ ] Changes committed **in the session worktree** with a clear message
34
- - [ ] 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
34
+ - [ ] Present session handoff (summary, branch, preview URLs) and **wait for user** before `complete`, push, or PR
35
+ - [ ] On user approval: `har env complete ${AGENT_ID}` (or MCP `har_complete_environment`) — full verify + validation + teardown, branch kept
36
+
37
+ ### Session handoff
38
+
39
+ After full verify and commit, stop and propose next steps. Never autonomously run
40
+ `complete`, `teardown`, `git push`, or open a PR. Prefer `complete` over bare
41
+ `teardown` when the work succeeded. Offer a PR only if `gh` or GitHub MCP is
42
+ available (and only after explicit approval); otherwise report the session branch
43
+ for a manual push. See `.cursor/rules/har-workflow.mdc` for the canonical handoff
44
+ template.
35
45
 
36
46
  Quick loop: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}`
37
47
 
@@ -18,4 +18,25 @@ After `./.har/launch.sh <id>`:
18
18
  ./.har/verify.sh <id> --full
19
19
  ```
20
20
 
21
- Replace TODO selectors and paths in the scaffold specs during harness adaptation.
21
+ Adapt selectors and paths in the scaffold specs during harness adaptation.
22
+
23
+ ## New UI features
24
+
25
+ Add or update Playwright specs so `browser-e2e` covers the change. Prefer one file per feature under `tests/frontend/<feature>.spec.js`. Full verification (`verify --full`) must pass before done.
26
+
27
+ See the header comment in `playwright.config.js` for harness env vars, artifact paths, and the quick vs full verify contract.
28
+
29
+ ## Plugin updates
30
+
31
+ When HAR ships a new plugin template version, merge drift from:
32
+
33
+ ```bash
34
+ har env maintain
35
+ # review .har/maintain/plugins/playwright/
36
+ ```
37
+
38
+ Or refresh all plugin-owned files:
39
+
40
+ ```bash
41
+ har env add-plugin playwright --force
42
+ ```
@@ -1,8 +1,48 @@
1
- // Playwright config tuned for HAR agent slots and CI.
1
+ // Playwright config for the HAR `browser-e2e` verification stage.
2
+ //
3
+ // Harness integration
4
+ // -------------------
5
+ // - Stage id: `browser-e2e` (`.har/stages/browser-e2e.sh`, registered in `stages.json`).
6
+ // - Runs automatically on FULL verify only — not on quick verify:
7
+ // ./.har/verify.sh <id> --full
8
+ // har env verify <id> --full
9
+ // har env complete <id> # always full; required before declaring done
10
+ // - Quick verify (`verify.sh <id>`) stops at typecheck / unit tests / api-health.
11
+ //
12
+ // Prerequisites
13
+ // -------------
14
+ // 1. Launch a slot first: ./.har/launch.sh <id>
15
+ // 2. Install browsers once: npx playwright install chromium
16
+ //
17
+ // Environment (injected by browser-e2e.sh — never hardcode slot ports in specs)
18
+ // ------------------------------------------------------------------------------
19
+ // BASE_URL Frontend origin for page.goto('/') and UI specs
20
+ // API_URL API origin for tests/api (defaults to BASE_URL when FE/API share a port)
21
+ // PW_SCREENSHOT Playwright screenshot mode (default: on)
22
+ // CI Set in CI for retries, worker cap, and forbidOnly
23
+ //
24
+ // Test layout — agents must add or update specs for every UI change
25
+ // ------------------------------------------------------------------
26
+ // tests/frontend/<feature>.spec.js UI flows (prefer one file per feature)
27
+ // tests/api/ HTTP checks via the request fixture
28
+ // tests/a11y/ axe-core on key routes
29
+ //
30
+ // Full verify only proves existing specs pass. New UI behavior needs new or
31
+ // updated specs here — the harness does not auto-generate flows per feature.
32
+ //
33
+ // Artifacts (gitignored under .har/artifacts/)
34
+ // --------------------------------------------
35
+ // browser-e2e/playwright-report/ HTML report after full verify
36
+ // browser-e2e/test-results/ traces, screenshots, videos on failure
37
+ //
38
+ // Local-only (without browser-e2e.sh): npm run test:e2e
39
+ // Set BASE_URL (and API_URL if split) when the app is not on the default below.
2
40
  const { defineConfig, devices } = require('@playwright/test');
3
41
 
42
+ const baseURL = process.env.BASE_URL || 'http://localhost:3000';
43
+ const apiURL = process.env.API_URL || baseURL;
44
+
4
45
  module.exports = defineConfig({
5
- testDir: './tests',
6
46
  timeout: 30 * 1000,
7
47
  expect: { timeout: 5000 },
8
48
  fullyParallel: true,
@@ -15,15 +55,26 @@ module.exports = defineConfig({
15
55
  ],
16
56
  outputDir: '.har/artifacts/browser-e2e/test-results',
17
57
  use: {
18
- baseURL: process.env.BASE_URL || 'http://localhost:3000',
58
+ baseURL,
19
59
  headless: true,
20
- screenshot: 'only-on-failure',
60
+ screenshot: process.env.PW_SCREENSHOT || 'on',
21
61
  video: 'retain-on-failure',
22
62
  trace: 'on-first-retry',
23
63
  },
24
64
  projects: [
25
65
  {
26
- name: 'chromium',
66
+ name: 'frontend',
67
+ testDir: './tests/frontend',
68
+ use: { ...devices['Desktop Chrome'] },
69
+ },
70
+ {
71
+ name: 'api',
72
+ testDir: './tests/api',
73
+ use: { baseURL: apiURL },
74
+ },
75
+ {
76
+ name: 'a11y',
77
+ testDir: './tests/a11y',
27
78
  use: { ...devices['Desktop Chrome'] },
28
79
  },
29
80
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "LLM-powered CLI for reproducible agent development environments",
5
5
  "keywords": [
6
6
  "har",