@osfactory/har 0.37.0 → 0.38.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.
@@ -158,8 +158,8 @@ slot_dirty_summary() {
158
158
  echo "dirty (${count} changed)"
159
159
  }
160
160
 
161
- # Print a warning before replacing an occupied slot (stdout — visible to agents).
162
- print_slot_replace_warning() {
161
+ # Print details about an occupied slot (stdout — visible to agents).
162
+ print_slot_occupied_warning() {
163
163
  local agent_id="$1"
164
164
  local reg wt branch work_dir created status last_error dirty_summary head
165
165
  reg="$(slot_registry_file "$agent_id")"
@@ -175,7 +175,7 @@ print_slot_replace_warning() {
175
175
  fi
176
176
 
177
177
  echo "" >&2
178
- echo "⚠ Slot ${agent_id} is already in use — replacing will REMOVE the worktree." >&2
178
+ echo "⚠ Slot ${agent_id} is already in use." >&2
179
179
  [ -n "$wt" ] && echo " Worktree: ${wt}" >&2
180
180
  [ -n "$work_dir" ] && echo " Work dir: ${work_dir}" >&2
181
181
  [ -n "$branch" ] && echo " Branch: ${branch}${head:+ @ ${head}}" >&2
@@ -191,54 +191,21 @@ print_slot_replace_warning() {
191
191
  base_sha="$(git -C "$base_root" rev-parse --short HEAD 2>/dev/null || true)"
192
192
  echo " New session will be based on: ${base_branch}${base_sha:+ @ ${base_sha}}" >&2
193
193
  echo " (HEAD of ${base_root})" >&2
194
- echo " --replace does not choose this base — switch that checkout first for a new unrelated task." >&2
194
+ echo " Switch that checkout to your intended base before launching a new session." >&2
195
195
  echo "" >&2
196
196
  fi
197
- echo " Prefer complete/teardown when the previous task is finished, then launch." >&2
198
- echo " The session branch is kept only if you committed. Gitignored paths" >&2
199
- echo " (state/, runs/, local clones, .env.local) are NOT preserved." >&2
200
- echo "" >&2
201
- }
202
-
203
- # Require explicit confirmation before replacing an occupied slot.
204
- # $1 agent_id $2 force(true/false) $3 replace(true/false)
205
- # Exits 1 when replacement must not proceed.
206
- require_slot_replace_confirm() {
207
- local agent_id="$1"
208
- local force="$2"
209
- local replace="$3"
210
- local wt
211
-
212
- slot_is_occupied "$agent_id" || return 0
213
-
214
- print_slot_replace_warning "$agent_id"
215
- wt="$(existing_slot_worktree "$agent_id")"
216
-
217
- if [ -n "$wt" ] && slot_worktree_dirty "$wt" && [ "$force" != true ]; then
218
- echo "ERROR: previous session for slot ${agent_id} has uncommitted changes." >&2
219
- echo " Commit them in the worktree (branch is kept on teardown), or pass --force to discard." >&2
220
- echo " --force destroys uncommitted work — only use after explicit user approval." >&2
221
- exit 1
197
+ if [ "$dirty_summary" != "clean" ] && [ "$dirty_summary" != "unknown" ]; then
198
+ echo " Commit or discard changes in the worktree, then teardown/complete the slot:" >&2
199
+ else
200
+ echo " Free the slot, then launch again:" >&2
222
201
  fi
223
-
224
- if [ "$replace" = true ] || [ "${HAR_CONFIRM_REPLACE:-}" = "1" ]; then
225
- return 0
226
- fi
227
-
228
- if [ -t 0 ] && [ -t 1 ]; then
229
- local answer
230
- read -r -p "Replace slot ${agent_id}? Uncommitted work is lost unless committed. [y/N] " answer
231
- if [[ "$answer" =~ ^[Yy]$ ]]; then
232
- return 0
233
- fi
234
- echo "Aborted — slot ${agent_id} left unchanged." >&2
235
- exit 2
236
- fi
237
-
238
- echo "ERROR: slot ${agent_id} is occupied." >&2
239
- echo " Pass --replace (or set HAR_CONFIRM_REPLACE=1) after reviewing the warning above." >&2
240
- echo " If the worktree is dirty, also pass --force (only after explicit user approval)." >&2
241
- exit 2
202
+ echo " har env complete ${agent_id} # or: har env teardown ${agent_id}" >&2
203
+ echo " har env launch ${agent_id}" >&2
204
+ echo "" >&2
205
+ echo " complete/teardown remove the worktree. The session branch is kept only if" >&2
206
+ echo " you committed. Gitignored paths (state/, runs/, local clones, .env.local)" >&2
207
+ echo " are NOT preserved." >&2
208
+ echo "" >&2
242
209
  }
243
210
 
244
211
  git_common_dir() {
@@ -2,8 +2,9 @@
2
2
  # Launch an agent slot for iOS mobile app repos (git worktree by default).
3
3
  # Every launch starts a FRESH session: any previous session for the slot is torn
4
4
  # down (its branch is kept) and a new suffixed worktree is created from HEAD.
5
+ # Occupied slots always block: run ./.har/teardown.sh (or complete it) first, then relaunch.
5
6
  #
6
- # Usage: ./.har/launch.sh <agent-id> [--no-worktree] [--replace] [--force]
7
+ # Usage: ./.har/launch.sh <agent-id> [--no-worktree]
7
8
  set -euo pipefail
8
9
 
9
10
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -16,8 +17,6 @@ source "$SCRIPT_DIR/agent-slot.sh"
16
17
 
17
18
  AGENT_ID="${1:-}"
18
19
  USE_WORKTREE="${HARNESS_USE_WORKTREE:-true}"
19
- FORCE=false
20
- REPLACE=false
21
20
  WORK_UNIT_ID="${HAR_WORK_UNIT_ID:-}"
22
21
  ATTEMPT_ID="${HAR_ATTEMPT_ID:-}"
23
22
 
@@ -25,8 +24,6 @@ for arg in "$@"; do
25
24
  case "$arg" in
26
25
  --no-worktree) USE_WORKTREE=false ;;
27
26
  --worktree) USE_WORKTREE=true ;;
28
- --replace) REPLACE=true ;;
29
- --force) FORCE=true ;;
30
27
  --work-id=*) WORK_UNIT_ID="${arg#*=}" ;;
31
28
  --attempt-id=*) ATTEMPT_ID="${arg#*=}" ;;
32
29
  esac
@@ -40,7 +37,7 @@ export SLOT_ATTEMPT_ID="$ATTEMPT_ID"
40
37
 
41
38
  if [[ -z "$AGENT_ID" ]]; then
42
39
  har_load_agent_slot_limits
43
- echo "Usage: $0 <agent-id> [--no-worktree] [--replace] [--force] " >&2
40
+ echo "Usage: $0 <agent-id> [--no-worktree]" >&2
44
41
  echo " agent-id must be between ${HARNESS_AGENT_SLOT_MIN} and ${HARNESS_AGENT_SLOT_MAX}" >&2
45
42
  exit 1
46
43
  fi
@@ -49,11 +46,12 @@ validate_agent_id "$AGENT_ID"
49
46
 
50
47
  log() { echo "==> [agent-$AGENT_ID] $*" >&2; }
51
48
 
52
- # Replace any previous session for this slot — requires explicit confirmation.
49
+ # Occupied slots always block a new launch — teardown/complete first, then relaunch.
53
50
  if slot_is_occupied "$AGENT_ID"; then
54
- require_slot_replace_confirm "$AGENT_ID" "$FORCE" "$REPLACE"
55
- log "Replacing previous session for slot ${AGENT_ID}..."
56
- "$SCRIPT_DIR/teardown.sh" "$AGENT_ID" >&2
51
+ print_slot_occupied_warning "$AGENT_ID"
52
+ echo "ERROR: slot ${AGENT_ID} is occupied." >&2
53
+ echo " Free it first: har env teardown ${AGENT_ID} (or complete ${AGENT_ID}), then har env launch ${AGENT_ID}." >&2
54
+ exit 2
57
55
  fi
58
56
 
59
57
  "$SCRIPT_DIR/setup-infra.sh"
@@ -122,7 +120,7 @@ mark_slot_failed() {
122
120
  write_slot_registry
123
121
  log " Work dir: ${WORK_DIR}"
124
122
  log " Env file: ${ENV_FILE}"
125
- log " Recovery: fix the failure, then relaunch with --replace when ready."
123
+ log " Recovery: fix the failure, then: har env teardown ${AGENT_ID} (or complete), then har env launch ${AGENT_ID}."
126
124
  fi
127
125
  }
128
126
  trap mark_slot_failed EXIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "LLM-powered CLI for reproducible agent development environments",
5
5
  "keywords": [
6
6
  "har",