@osfactory/har 0.18.1 → 0.20.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.
@@ -67,4 +67,6 @@ git add .har/ AGENT.md CLAUDE.md .claude/ .cursor/ 2>/dev/null || git add .har/
67
67
  git commit -m "chore: add har agent harness"
68
68
  ```
69
69
 
70
- Optionally recommend `har hooks install` (commit gate) and `har hooks install --claude` (worktree guard for Claude Code).
70
+ Init applies the user's `har preferences` commit-gate policy. Confirm with
71
+ `har hooks status`; recommend `har hooks install --claude` separately when the
72
+ Claude Code main-checkout worktree guard is useful.
@@ -15,13 +15,14 @@ work around it with ad-hoc commands.
15
15
 
16
16
  ## Before making changes
17
17
 
18
- 1. **Launch your slot FIRST — before editing any file.** Use `har_launch_environment` with `agentId: 1` (MCP) or `har env launch 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 env restart <id>` or `./.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
18
+ 1. **On the main checkout, switch to the intended base** (usually `main`) — every launch creates a worktree from that HEAD. `--replace` does not select the base.
19
+ 2. **Launch your slot FIRST — before editing any file.** Use `har_launch_environment` with `agentId: 1` (MCP) or `har env launch 1`. Launch always creates a **fresh session worktree** and returns its **work dir**.
20
+ 3. **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 env restart <id>` or `./.har/agent-cli.sh <id> restart` if a change doesn't take.
21
+ 4. Read [AGENT.md](./AGENT.md) at the repo root
22
+ 5. Read [.har/README.md](./.har/README.md) and [.har/stages.json](./.har/stages.json)
23
+ 6. After launch, read [.har/CLAUDE.agent.md](./.har/CLAUDE.agent.md) for slot URLs and definition of done
23
24
 
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
+ When a slot is occupied: prefer `complete` / `teardown` if the previous task is finished, then launch. Use `--replace` / `confirmReplace=true` only to reuse the same slot id immediately (destroys the old worktree; the old branch is kept if committed). If the previous session has uncommitted changes, you must also pass `force`/`--force` after **explicit user approval** — never autonomously. Failed launches: `--resume` / `recover`, not `--replace`.
25
26
 
26
27
  ### Slot safety (read before launch)
27
28
 
@@ -30,7 +31,7 @@ Relaunching a slot **replaces** its previous session (the old branch is kept). R
30
31
  - **Never** set `force`/`confirmReplace` without the user explicitly approving replacement.
31
32
  - **Commit early and often** in the session worktree — teardown keeps the branch, not uncommitted work.
32
33
  - **Gitignored paths are ephemeral** (`state/`, `runs/`, local clones) — they are lost when the worktree is removed.
33
- - Optional: set `har env launch <id> --purpose=label`, `HAR_SESSION_PURPOSE=label`, or `./.har/launch.sh <id> --purpose=label` so occupied-slot warnings show what you were doing.
34
+ - With telemetry prompts enabled, Mission Control derives session purpose from the first captured user prompt.
34
35
 
35
36
  <!-- Monorepo: if this repository contains multiple .har harnesses, list them here
36
37
  and pick by the files you are changing. Example:
@@ -179,15 +179,17 @@ The authoring agent updates scripts and this README. Review changes before commi
179
179
 
180
180
  ## Session lifecycle
181
181
 
182
- Every `launch` starts a **fresh session**: a new git worktree from the current HEAD at
182
+ Every `launch` starts a **fresh session**: a new git worktree from the **main
183
+ checkout's current HEAD** at
183
184
  `~/worktrees/<base-branch>-<sha4>-har-agent-<id>-<rand4>`, on a branch of the same name.
184
- The session is recorded in `.har/slots/agent-<id>.json` (the slot registry) — status,
185
- verify, and teardown resolve the work dir through it. Make ALL file edits under the
186
- work dir printed by launch, never in the main checkout.
187
-
188
- - Relaunching a slot **replaces** its previous session; replacement requires `--replace` /
189
- `confirmReplace=true` (or an interactive prompt). Uncommitted changes also need `--force`
190
- after explicit user approval.
185
+ Switch that checkout to your intended base before launch. The session is recorded in
186
+ `.har/slots/agent-<id>.json` (the slot registry) — status, verify, and teardown resolve
187
+ the work dir through it. Make ALL file edits under the work dir printed by launch,
188
+ never in the main checkout.
189
+
190
+ - Prefer `complete` / `teardown` when a task is finished, then launch.
191
+ - `--replace` destroys the previous worktree (requires confirmation); it does **not**
192
+ choose `main`. Uncommitted changes also need `--force` after explicit user approval.
191
193
  - `teardown` removes the worktree but **keeps the session branch** so you can push it
192
194
  or open a PR (`--delete-branch` to drop it).
193
195
  - If launch fails after creating a worktree/env file, the registry records `status: failed`.
@@ -535,6 +535,17 @@ print_slot_replace_warning() {
535
535
  [ -n "$created" ] && echo " Since: ${created}" >&2
536
536
  echo " Git: ${dirty_summary}" >&2
537
537
  echo "" >&2
538
+ local base_root="${HARNESS_ROOT:-${REPO_ROOT:-}}"
539
+ if [ -n "$base_root" ] && [ -d "$base_root" ]; then
540
+ local base_branch base_sha
541
+ base_branch="$(git -C "$base_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo detached)"
542
+ base_sha="$(git -C "$base_root" rev-parse --short HEAD 2>/dev/null || true)"
543
+ echo " New session will be based on: ${base_branch}${base_sha:+ @ ${base_sha}}" >&2
544
+ echo " (HEAD of ${base_root})" >&2
545
+ echo " --replace does not choose this base — switch that checkout first for a new unrelated task." >&2
546
+ echo "" >&2
547
+ fi
548
+ echo " Prefer complete/teardown when the previous task is finished, then launch." >&2
538
549
  echo " The session branch is kept only if you committed. Gitignored paths" >&2
539
550
  echo " (state/, runs/, local clones, .env.local) are NOT preserved." >&2
540
551
  echo "" >&2
@@ -4,6 +4,11 @@
4
4
  "min": 1,
5
5
  "max": 5
6
6
  },
7
+ "commitGate": {
8
+ "enabled": true,
9
+ "mode": "block",
10
+ "scope": "worktrees"
11
+ },
7
12
  "stages": [
8
13
  {
9
14
  "id": "setup-infra",
@@ -137,15 +137,17 @@ The authoring agent updates scripts and this README. Review changes before commi
137
137
 
138
138
  ## Session lifecycle
139
139
 
140
- Every `launch` starts a **fresh session**: a new git worktree from the current HEAD at
140
+ Every `launch` starts a **fresh session**: a new git worktree from the **main
141
+ checkout's current HEAD** at
141
142
  `~/worktrees/<base-branch>-<sha4>-har-agent-<id>-<rand4>`, on a branch of the same name.
142
- The session is recorded in `.har/slots/agent-<id>.json` (the slot registry) — status,
143
- verify, and teardown resolve the work dir through it. Make ALL file edits under the
144
- work dir printed by launch, never in the main checkout.
145
-
146
- - Relaunching a slot **replaces** its previous session; replacement requires `--replace` /
147
- `confirmReplace=true` (or an interactive prompt). Uncommitted changes also need `--force`
148
- after explicit user approval.
143
+ Switch that checkout to your intended base before launch. The session is recorded in
144
+ `.har/slots/agent-<id>.json` (the slot registry) — status, verify, and teardown resolve
145
+ the work dir through it. Make ALL file edits under the work dir printed by launch,
146
+ never in the main checkout.
147
+
148
+ - Prefer `complete` / `teardown` when a task is finished, then launch.
149
+ - `--replace` destroys the previous worktree (requires confirmation); it does **not**
150
+ choose `main`. Uncommitted changes also need `--force` after explicit user approval.
149
151
  - `teardown` removes the worktree but **keeps the session branch** so you can push it
150
152
  or open a PR (`--delete-branch` to drop it).
151
153
  - If launch fails after creating a worktree/env file, resume with
@@ -515,6 +515,17 @@ print_slot_replace_warning() {
515
515
  [ -n "$created" ] && echo " Since: ${created}" >&2
516
516
  echo " Git: ${dirty_summary}" >&2
517
517
  echo "" >&2
518
+ local base_root="${HARNESS_ROOT:-${REPO_ROOT:-}}"
519
+ if [ -n "$base_root" ] && [ -d "$base_root" ]; then
520
+ local base_branch base_sha
521
+ base_branch="$(git -C "$base_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo detached)"
522
+ base_sha="$(git -C "$base_root" rev-parse --short HEAD 2>/dev/null || true)"
523
+ echo " New session will be based on: ${base_branch}${base_sha:+ @ ${base_sha}}" >&2
524
+ echo " (HEAD of ${base_root})" >&2
525
+ echo " --replace does not choose this base — switch that checkout first for a new unrelated task." >&2
526
+ echo "" >&2
527
+ fi
528
+ echo " Prefer complete/teardown when the previous task is finished, then launch." >&2
518
529
  echo " The session branch is kept only if you committed. Gitignored paths" >&2
519
530
  echo " (state/, runs/, local clones, .env.local) are NOT preserved." >&2
520
531
  echo "" >&2
@@ -4,6 +4,11 @@
4
4
  "min": 1,
5
5
  "max": 3
6
6
  },
7
+ "commitGate": {
8
+ "enabled": true,
9
+ "mode": "block",
10
+ "scope": "worktrees"
11
+ },
7
12
  "stages": [
8
13
  {
9
14
  "id": "setup-infra",
@@ -113,10 +113,14 @@ When your app talks to a local backend, read the resolved host port from `.env.a
113
113
 
114
114
  ## Session lifecycle
115
115
 
116
- Every `launch` starts a **fresh session**: a new git worktree from the current HEAD at
116
+ Every `launch` starts a **fresh session**: a new git worktree from the **main
117
+ checkout's current HEAD** at
117
118
  `~/worktrees/<base-branch>-<sha4>-har-agent-<id>-<rand4>`, on a branch of the same name.
118
- The session is recorded in `.har/slots/agent-<id>.json`.
119
+ Switch that checkout to your intended base before launch. The session is recorded in
120
+ `.har/slots/agent-<id>.json`.
119
121
 
120
- - Relaunching a slot **replaces** its previous session; uncommitted changes require `--force`.
122
+ - Prefer `complete` / `teardown` when a task is finished, then launch.
123
+ - `--replace` destroys the previous worktree; it does **not** choose `main`.
124
+ Uncommitted changes also require `--force` after explicit approval.
121
125
  - `teardown` removes the worktree but **keeps the session branch** for push / PR.
122
126
  - `har env complete <id>` finishes a session: full verify + teardown, branch kept.
@@ -176,6 +176,17 @@ print_slot_replace_warning() {
176
176
  [ -n "$created" ] && echo " Since: ${created}" >&2
177
177
  echo " Git: ${dirty_summary}" >&2
178
178
  echo "" >&2
179
+ local base_root="${HARNESS_ROOT:-${REPO_ROOT:-}}"
180
+ if [ -n "$base_root" ] && [ -d "$base_root" ]; then
181
+ local base_branch base_sha
182
+ base_branch="$(git -C "$base_root" rev-parse --abbrev-ref HEAD 2>/dev/null || echo detached)"
183
+ base_sha="$(git -C "$base_root" rev-parse --short HEAD 2>/dev/null || true)"
184
+ echo " New session will be based on: ${base_branch}${base_sha:+ @ ${base_sha}}" >&2
185
+ echo " (HEAD of ${base_root})" >&2
186
+ echo " --replace does not choose this base — switch that checkout first for a new unrelated task." >&2
187
+ echo "" >&2
188
+ fi
189
+ echo " Prefer complete/teardown when the previous task is finished, then launch." >&2
179
190
  echo " The session branch is kept only if you committed. Gitignored paths" >&2
180
191
  echo " (state/, runs/, local clones, .env.local) are NOT preserved." >&2
181
192
  echo "" >&2
@@ -4,6 +4,11 @@
4
4
  "min": 1,
5
5
  "max": 3
6
6
  },
7
+ "commitGate": {
8
+ "enabled": true,
9
+ "mode": "block",
10
+ "scope": "worktrees"
11
+ },
7
12
  "stages": [
8
13
  {
9
14
  "id": "setup-infra",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "0.18.1",
3
+ "version": "0.20.0",
4
4
  "description": "LLM-powered CLI for reproducible agent development environments",
5
5
  "keywords": [
6
6
  "har",