@osfactory/har 0.10.0 → 0.12.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.
@@ -311,14 +311,43 @@ escape_step_output() {
311
311
  printf '%s' "$1" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const s=d.trim().split('\n').slice(0,50).join('\n');process.stdout.write(JSON.stringify(s))})" 2>/dev/null || echo '""'
312
312
  }
313
313
 
314
- # Run browser-e2e on verify --full when the Playwright stage template is installed.
315
- run_browser_e2e_if_present() {
314
+ # Emit "<id>\t<command>" for each registered stage listed in stages.json
315
+ # verificationStages (used by verify --full). Ids without a matching registered
316
+ # stage are inline verify.sh steps and skipped here; lifecycle stages
317
+ # (setup/launch/reset/teardown/inspect) and the verify stage itself never run.
318
+ # Authoring contract: .har/STAGES.md
319
+ list_registered_verification_stage_commands() {
316
320
  local script_dir="$1"
317
321
  local agent_id="$2"
318
- local e2e="$script_dir/stages/browser-e2e.sh"
319
- if [ -x "$e2e" ]; then
320
- "$e2e" "$agent_id"
321
- fi
322
+ local registry="$script_dir/stages.json"
323
+ [ -f "$registry" ] || return 0
324
+ HAR_STAGE_REGISTRY="$registry" HAR_SCRIPT_DIR="$script_dir" HAR_AGENT_ID="$agent_id" node <<'NODE' 2>/dev/null || true
325
+ const fs = require('fs');
326
+ const { HAR_STAGE_REGISTRY, HAR_SCRIPT_DIR, HAR_AGENT_ID } = process.env;
327
+ const shq = (s) => "'" + String(s).replace(/'/g, "'\\''") + "'";
328
+ let reg;
329
+ try { reg = JSON.parse(fs.readFileSync(HAR_STAGE_REGISTRY, 'utf8')); } catch { process.exit(0); }
330
+ const ids = Array.isArray(reg.verificationStages) ? reg.verificationStages : [];
331
+ const stages = Array.isArray(reg.stages) ? reg.stages : [];
332
+ const runnable = new Set(['test', 'custom']);
333
+ for (const id of ids) {
334
+ const stage = stages.find((s) => s && s.id === id);
335
+ if (!stage || stage.id === 'verify' || !runnable.has(stage.kind)) continue;
336
+ const needsAgent = stage.requiresAgentId !== false;
337
+ let cmd;
338
+ if (stage.script) {
339
+ cmd = shq(HAR_SCRIPT_DIR + '/' + stage.script) + (needsAgent ? ' ' + shq(HAR_AGENT_ID) : '');
340
+ } else if (stage.command) {
341
+ cmd = stage.command.split('{agentId}').join(HAR_AGENT_ID);
342
+ } else {
343
+ continue;
344
+ }
345
+ if (stage.cwd) cmd = 'cd ' + shq(stage.cwd) + ' && ' + cmd;
346
+ const env = stage.env && typeof stage.env === 'object' ? stage.env : {};
347
+ const prefix = Object.entries(env).map(([k, v]) => k + '=' + shq(v)).join(' ');
348
+ process.stdout.write(id + '\t' + (prefix ? prefix + ' ' : '') + cmd + '\n');
349
+ }
350
+ NODE
322
351
  }
323
352
 
324
353
  # Optional project-owned "agent usable" smoke beyond health.
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env bash
2
- # Optional per-stage scripts live here.
3
- # Example: ./.har/stages/rocketsim-flows.sh <agent-id>
2
+ # Per-stage scripts live here (e.g. ./.har/stages/browser-e2e.sh <agent-id>).
4
3
  #
5
- # Register custom stages in .har/stages.json with a project-owned command:
6
- # "command": "./.har/stages/rocketsim-flows.sh {agentId}"
4
+ # Read .har/STAGES.md for the authoring guide: the stage script contract,
5
+ # command vs script stages, and how verificationStages controls verify --full.
7
6
  #
8
- # To add the RocketSim user-flow stage template:
9
- # har env add-stage rocketsim
7
+ # Scaffold a new one with:
8
+ # har env add-stage <id> --custom --script
10
9
 
11
- echo "Add stage scripts under .har/stages/ and register them in stages.json." >&2
10
+ echo "Add stage scripts under .har/stages/ and register them in stages.json — see .har/STAGES.md." >&2
12
11
  exit 1
@@ -5,7 +5,8 @@
5
5
  # Usage: ./.har/verify.sh <agent-id> [--full]
6
6
  #
7
7
  # Quick (default): build smoke (compile-only)
8
- # Full (--full): + unit tests, lint (SwiftLint), rocketsim-flows (if installed)
8
+ # Full (--full): + unit tests, lint (SwiftLint), and every registered stage
9
+ # in stages.json verificationStages (see .har/STAGES.md)
9
10
  # Step lists are examples — not exhaustive. Adapt commands to this repo's stack.
10
11
  set -euo pipefail
11
12
 
@@ -150,8 +151,13 @@ if [ -n "$FULL" ]; then
150
151
 
151
152
  run_step "readiness" "run_readiness_if_configured \"$AGENT_ID\"" || true
152
153
 
153
- # RocketSim user-flow validation installed via: har env add-stage rocketsim
154
- run_rocketsim_flows_if_present "$SCRIPT_DIR" "$AGENT_ID" || true
154
+ # Registered verification stages from .har/stages.json (see .har/STAGES.md).
155
+ # Every stage listed in verificationStages with a registered script/command
156
+ # runs here -- stage templates and custom stages alike.
157
+ while IFS=$'\t' read -r STAGE_ID STAGE_CMD; do
158
+ [ -n "$STAGE_ID" ] || continue
159
+ run_step "$STAGE_ID" "$STAGE_CMD" || true
160
+ done < <(list_registered_verification_stage_commands "$SCRIPT_DIR" "$AGENT_ID")
155
161
  fi
156
162
 
157
163
  END_TOTAL=$(now_ms)
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env bash
2
+ # __STAGE_DESCRIPTION__
3
+ # Custom HAR stage: __STAGE_ID__ (kind: __STAGE_KIND__)
4
+ #
5
+ # Stage script contract (full reference: .har/STAGES.md):
6
+ # - stdout: a single JSON result object (status, stageId, agent_id, ...)
7
+ # - stderr: human-readable progress
8
+ # - $1: agent slot id; extra args may follow
9
+ # - artifacts: write reports/screenshots/logs under .har/artifacts/__STAGE_ID__/
10
+ # - exit code: the real status (0 = pass)
11
+ #
12
+ # Usage: ./.har/stages/__STAGE_ID__.sh <agent-id> [extra args...]
13
+ set -euo pipefail
14
+
15
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
+ HARNESS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
17
+ REPO_ROOT="$(cd "$HARNESS_DIR/.." && pwd)"
18
+
19
+ # shellcheck source=/dev/null
20
+ source "$HARNESS_DIR/harness.env"
21
+ # shellcheck source=/dev/null
22
+ source "$HARNESS_DIR/agent-slot.sh"
23
+
24
+ AGENT_ID="${1:?Usage: __STAGE_ID__.sh <agent-id> [extra args...]}"
25
+ validate_agent_id "$AGENT_ID"
26
+
27
+ ENV_FILE="$(resolve_agent_env_file "$AGENT_ID" "$REPO_ROOT")" || {
28
+ echo "No .env.agent.${AGENT_ID} found. Run: ./.har/launch.sh ${AGENT_ID}" >&2
29
+ exit 1
30
+ }
31
+ set -a
32
+ # shellcheck source=/dev/null
33
+ source "$ENV_FILE"
34
+ set +a
35
+
36
+ WORK_DIR="$(resolve_agent_work_dir "$ENV_FILE")"
37
+ ARTIFACTS_DIR="$HARNESS_DIR/artifacts/__STAGE_ID__"
38
+ mkdir -p "$ARTIFACTS_DIR"
39
+
40
+ echo "==> [__STAGE_ID__ agent-${AGENT_ID}] running in ${WORK_DIR}" >&2
41
+ START=$(now_ms)
42
+
43
+ # ── TODO: implement the stage ────────────────────────────────────────────────
44
+ # Run your checks from $WORK_DIR (the agent's isolated checkout); the slot's
45
+ # ports and env are loaded from $ENV_FILE. Save artifacts to $ARTIFACTS_DIR.
46
+ set +e
47
+ OUTPUT=$(cd "$WORK_DIR" && echo "TODO: implement .har/stages/__STAGE_ID__.sh" && false)
48
+ EXIT_CODE=$?
49
+ set -e
50
+
51
+ END=$(now_ms)
52
+ STATUS="fail"
53
+ [ "$EXIT_CODE" = "0" ] && STATUS="pass"
54
+ OUTPUT_JSON=$(escape_step_output "$OUTPUT")
55
+
56
+ node -e "process.stdout.write(JSON.stringify({
57
+ status: '$STATUS',
58
+ stageId: '__STAGE_ID__',
59
+ kind: '__STAGE_KIND__',
60
+ agent_id: $AGENT_ID,
61
+ total_ms: $(( END - START )),
62
+ output: $OUTPUT_JSON
63
+ }, null, 2) + '\n');"
64
+
65
+ exit "$EXIT_CODE"
@@ -40,5 +40,13 @@
40
40
  ],
41
41
  "merge": {
42
42
  "package.json": "package.fragment.json"
43
- }
43
+ },
44
+ "nextSteps": [
45
+ "npm install",
46
+ "npx playwright install",
47
+ "./.har/launch.sh 1",
48
+ "./.har/stages/browser-e2e.sh 1",
49
+ "npx playwright show-report .har/artifacts/browser-e2e/playwright-report"
50
+ ],
51
+ "docsPath": ".har/stages/PLAYWRIGHT.md"
44
52
  }
@@ -34,5 +34,6 @@
34
34
  "./.har/stages/rocketsim-flows.sh 1",
35
35
  "Open .har/artifacts/rocketsim-flows/ for screenshots and per-flow results",
36
36
  "Add new flows in flows/ — read .har/stages/ROCKETSIM.md for the authoring guide"
37
- ]
37
+ ],
38
+ "docsPath": ".har/stages/ROCKETSIM.md"
38
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osfactory/har",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "LLM-powered CLI for reproducible agent development environments",
5
5
  "keywords": [
6
6
  "har",
@@ -67,7 +67,7 @@
67
67
  "type": "git",
68
68
  "url": "https://github.com/os-factory/har"
69
69
  },
70
- "homepage": "https://github.com/os-factory/har#readme",
70
+ "homepage": "https://harproject.cloud/",
71
71
  "bugs": "https://github.com/os-factory/har/issues",
72
72
  "author": "Antoine Frau",
73
73
  "license": "AGPL-3.0-only",