@osfactory/har 0.64.1 → 1.0.0-rc.1

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.
Files changed (141) hide show
  1. package/dist/index.js +15981 -6646
  2. package/dist/prompts/system-authoring.md +155 -0
  3. package/dist/templates/adaptation-prompt-init.md +67 -43
  4. package/dist/templates/adaptation-prompt-maintain.md +38 -38
  5. package/dist/templates/agent-skills/har-maintain.md +2 -2
  6. package/dist/templates/agent-skills/setup-har.md +6 -4
  7. package/dist/templates/cursor-rule.mdc.template +3 -3
  8. package/dist/templates/har-boilerplate/docker-compose.agent.yml +1 -1
  9. package/dist/templates/har-boilerplate/harness.env +11 -155
  10. package/dist/templates/har-boilerplate/stages.json +51 -2
  11. package/dist/templates/har-boilerplate-cli/docker-compose.agent.yml +1 -1
  12. package/dist/templates/har-boilerplate-cli/harness.env +12 -138
  13. package/dist/templates/har-boilerplate-cli/stages.json +42 -2
  14. package/dist/templates/har-boilerplate-ios/harness.env +10 -126
  15. package/dist/templates/har-boilerplate-ios/stages.json +42 -2
  16. package/dist/templates/migration-prompt.md +54 -0
  17. package/dist/templates/plugins/custom-stage-skeleton.sh +11 -20
  18. package/dist/templates/plugins/gitleaks/.github/workflows/gitleaks.yml +1 -1
  19. package/dist/templates/plugins/gitleaks/.har/stages/GITLEAKS.md +1 -1
  20. package/dist/templates/plugins/gitleaks/.har/stages/secrets-scan.sh +8 -23
  21. package/dist/templates/plugins/gitleaks/README.md +1 -1
  22. package/dist/templates/plugins/gitleaks/template.manifest.json +20 -5
  23. package/dist/templates/plugins/kerno/.github/workflows/kerno.yml +1 -1
  24. package/dist/templates/plugins/kerno/.har/stages/backend-validation.sh +8 -23
  25. package/dist/templates/plugins/kerno/README.md +1 -1
  26. package/dist/templates/plugins/kerno/template.manifest.json +20 -9
  27. package/dist/templates/plugins/local-plugin-skeleton/README.md +46 -0
  28. package/dist/templates/plugins/playwright/.har/stages/browser-e2e.sh +8 -23
  29. package/dist/templates/plugins/playwright/template.manifest.json +36 -13
  30. package/dist/templates/plugins/rocketsim/.har/stages/rocketsim-flows.sh +8 -23
  31. package/dist/templates/plugins/rocketsim/template.manifest.json +20 -8
  32. package/dist/templates/plugins/semgrep/.har/stages/sast.sh +10 -26
  33. package/dist/templates/plugins/semgrep/README.md +1 -1
  34. package/dist/templates/plugins/semgrep/template.manifest.json +16 -7
  35. package/dist/templates/plugins/trivy/.har/stages/vuln-scan.sh +8 -23
  36. package/dist/templates/plugins/trivy/README.md +1 -1
  37. package/dist/templates/plugins/trivy/template.manifest.json +20 -8
  38. package/dist/templates/{har-boilerplate-cli/CLAUDE.agent.md → profiles/cli/docs/claude-agent/definition-of-done.md} +0 -42
  39. package/dist/templates/profiles/cli/docs/claude-agent/do-not.md +6 -0
  40. package/dist/templates/profiles/cli/docs/claude-agent/environment.md +12 -0
  41. package/dist/templates/profiles/cli/docs/claude-agent/project-commands.md +10 -0
  42. package/dist/templates/profiles/cli/docs/claude-agent/readiness.md +6 -0
  43. package/dist/templates/profiles/cli/docs/readme/for-coding-agents.md +9 -0
  44. package/dist/templates/profiles/cli/docs/readme/intro.md +7 -0
  45. package/dist/templates/profiles/cli/docs/readme/port-shared-services-cli-profile.md +25 -0
  46. package/dist/templates/profiles/cli/docs/readme/quick-start.md +24 -0
  47. package/dist/templates/profiles/cli/docs/readme/verification-contract.md +22 -0
  48. package/dist/templates/profiles/cli/docs/readme/what-s-in-here.md +27 -0
  49. package/dist/templates/profiles/cli/profile.manifest.json +56 -1
  50. package/dist/templates/profiles/default/docs/claude-agent/definition-of-done.md +24 -0
  51. package/dist/templates/profiles/default/docs/claude-agent/do-not.md +10 -0
  52. package/dist/templates/profiles/default/docs/claude-agent/environment.md +19 -0
  53. package/dist/templates/profiles/default/docs/claude-agent/project-commands.md +10 -0
  54. package/dist/templates/profiles/default/docs/claude-agent/readiness.md +12 -0
  55. package/dist/templates/profiles/default/docs/readme/architecture.md +11 -0
  56. package/dist/templates/profiles/default/docs/readme/for-coding-agents.md +9 -0
  57. package/dist/templates/profiles/default/docs/readme/intro.md +7 -0
  58. package/dist/templates/profiles/default/docs/readme/port-shared-services.md +41 -0
  59. package/dist/templates/profiles/default/docs/readme/quick-start.md +24 -0
  60. package/dist/templates/profiles/default/docs/readme/readiness-layers.md +16 -0
  61. package/dist/templates/profiles/default/docs/readme/verification-contract.md +17 -0
  62. package/dist/templates/profiles/default/docs/readme/what-s-in-here.md +28 -0
  63. package/dist/templates/profiles/default/profile.manifest.json +62 -1
  64. package/dist/templates/profiles/ios/docs/claude-agent/definition-of-done.md +23 -0
  65. package/dist/templates/profiles/ios/docs/claude-agent/do-not.md +6 -0
  66. package/dist/templates/profiles/ios/docs/claude-agent/environment.md +14 -0
  67. package/dist/templates/profiles/ios/docs/claude-agent/intro.md +3 -0
  68. package/dist/templates/profiles/ios/docs/claude-agent/project-commands.md +21 -0
  69. package/dist/templates/profiles/ios/docs/claude-agent/readiness.md +6 -0
  70. package/dist/templates/profiles/ios/docs/claude-agent/user-flow-validation-rocketsim.md +11 -0
  71. package/dist/templates/profiles/ios/docs/readme/configuration.md +7 -0
  72. package/dist/templates/profiles/ios/docs/readme/intro.md +7 -0
  73. package/dist/templates/profiles/ios/docs/readme/port-shared-services-ios-profile.md +25 -0
  74. package/dist/templates/profiles/ios/docs/readme/quick-start.md +22 -0
  75. package/dist/templates/profiles/ios/docs/readme/simulators.md +45 -0
  76. package/dist/templates/profiles/ios/docs/readme/user-flow-validation.md +9 -0
  77. package/dist/templates/profiles/ios/docs/readme/verification-contract.md +13 -0
  78. package/dist/templates/profiles/ios/docs/readme/what-s-in-here.md +27 -0
  79. package/dist/templates/profiles/ios/profile.manifest.json +59 -3
  80. package/dist/templates/runtime-bundles/pm2-runtime/attach.sh +8 -15
  81. package/dist/templates/runtime-bundles/pm2-runtime/env.template +1 -1
  82. package/dist/templates/runtime-bundles/pm2-runtime/stages/api-health.sh +9 -0
  83. package/dist/templates/runtime-bundles/shared-kernel/STAGES.md +32 -18
  84. package/dist/templates/runtime-bundles/shared-kernel/agent-cli.sh +35 -0
  85. package/dist/templates/runtime-bundles/shared-kernel/launch.sh +35 -0
  86. package/dist/templates/runtime-bundles/shared-kernel/lib/verify-runner.mjs +129 -0
  87. package/dist/templates/runtime-bundles/shared-kernel/preflight.sh +35 -0
  88. package/dist/templates/runtime-bundles/shared-kernel/setup-infra.sh +35 -0
  89. package/dist/templates/runtime-bundles/shared-kernel/stages/README.sh +1 -1
  90. package/dist/templates/runtime-bundles/shared-kernel/stages/readiness.sh +14 -0
  91. package/dist/templates/runtime-bundles/shared-kernel/teardown.sh +35 -0
  92. package/dist/templates/runtime-bundles/shared-kernel/verify.sh +35 -0
  93. package/dist/templates/shared-docs/claude-agent/intro.md +3 -0
  94. package/dist/templates/shared-docs/readme/maintaining-this-harness.md +14 -0
  95. package/dist/templates/shared-docs/readme/run-history.md +5 -0
  96. package/dist/templates/shared-docs/readme/session-lifecycle.md +20 -0
  97. package/package.json +1 -1
  98. package/dist/templates/har-boilerplate/CLAUDE.agent.md +0 -83
  99. package/dist/templates/har-boilerplate/README.md +0 -199
  100. package/dist/templates/har-boilerplate/STAGES.md +0 -99
  101. package/dist/templates/har-boilerplate/agent-cli.sh +0 -225
  102. package/dist/templates/har-boilerplate/agent-slot.sh +0 -850
  103. package/dist/templates/har-boilerplate/attach.sh +0 -22
  104. package/dist/templates/har-boilerplate/ecosystem.agent.template.cjs +0 -52
  105. package/dist/templates/har-boilerplate/env.template +0 -40
  106. package/dist/templates/har-boilerplate/launch.sh +0 -323
  107. package/dist/templates/har-boilerplate/preflight.sh +0 -32
  108. package/dist/templates/har-boilerplate/provision-toolchain.sh +0 -766
  109. package/dist/templates/har-boilerplate/setup-infra.sh +0 -178
  110. package/dist/templates/har-boilerplate/stages/README.sh +0 -11
  111. package/dist/templates/har-boilerplate/teardown.sh +0 -87
  112. package/dist/templates/har-boilerplate/verify.sh +0 -249
  113. package/dist/templates/har-boilerplate-cli/README.md +0 -157
  114. package/dist/templates/har-boilerplate-cli/STAGES.md +0 -99
  115. package/dist/templates/har-boilerplate-cli/agent-cli.sh +0 -160
  116. package/dist/templates/har-boilerplate-cli/agent-slot.sh +0 -832
  117. package/dist/templates/har-boilerplate-cli/launch.sh +0 -216
  118. package/dist/templates/har-boilerplate-cli/preflight.sh +0 -28
  119. package/dist/templates/har-boilerplate-cli/provision-toolchain.sh +0 -766
  120. package/dist/templates/har-boilerplate-cli/setup-infra.sh +0 -178
  121. package/dist/templates/har-boilerplate-cli/stages/README.sh +0 -11
  122. package/dist/templates/har-boilerplate-cli/teardown.sh +0 -66
  123. package/dist/templates/har-boilerplate-cli/verify.sh +0 -210
  124. package/dist/templates/har-boilerplate-ios/ADAPT-PROMPT.md +0 -63
  125. package/dist/templates/har-boilerplate-ios/CLAUDE.agent.md +0 -90
  126. package/dist/templates/har-boilerplate-ios/README.md +0 -173
  127. package/dist/templates/har-boilerplate-ios/STAGES.md +0 -99
  128. package/dist/templates/har-boilerplate-ios/agent-cli.sh +0 -149
  129. package/dist/templates/har-boilerplate-ios/agent-slot.sh +0 -479
  130. package/dist/templates/har-boilerplate-ios/launch.sh +0 -206
  131. package/dist/templates/har-boilerplate-ios/provision-toolchain.sh +0 -766
  132. package/dist/templates/har-boilerplate-ios/setup-infra.sh +0 -112
  133. package/dist/templates/har-boilerplate-ios/simulator.sh +0 -492
  134. package/dist/templates/har-boilerplate-ios/stages/README.sh +0 -11
  135. package/dist/templates/har-boilerplate-ios/teardown.sh +0 -68
  136. package/dist/templates/har-boilerplate-ios/verify.sh +0 -185
  137. package/dist/templates/runtime-bundles/pm2-runtime/README.md +0 -4
  138. package/dist/templates/runtime-bundles/shared-kernel/README.md +0 -3
  139. package/dist/templates/runtime-bundles/shared-kernel/provision-toolchain.sh +0 -766
  140. package/dist/templates/runtime-bundles/xcode-sim/README.md +0 -4
  141. package/dist/templates/runtime-bundles/xcode-sim/simulator.sh +0 -492
@@ -1,178 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Sets up shared infrastructure for all agents.
3
- # Starts the docker compose services listed in HARNESS_INFRA_SERVICES, creates
4
- # the template database (when "db" is enabled), and starts optional shared app
5
- # services (ecosystem.shared.config.cjs). One instance serves every agent slot.
6
- # Idempotent — safe to run multiple times.
7
- #
8
- # Usage: ./.har/setup-infra.sh
9
- set -euo pipefail
10
-
11
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13
- COMPOSE_FILE="$SCRIPT_DIR/docker-compose.agent.yml"
14
- INFRA_STATE="$SCRIPT_DIR/state/infra.env"
15
-
16
- # shellcheck source=/dev/null
17
- source "$SCRIPT_DIR/harness.env"
18
- # shellcheck source=/dev/null
19
- source "$SCRIPT_DIR/agent-slot.sh"
20
-
21
- COMPOSE_PROJECT="har-${HARNESS_PROJECT_NAME}"
22
- PSQL="har_pg psql -d postgres"
23
-
24
- log() { echo "==> $*" >&2; }
25
-
26
- har_compose_service_running() {
27
- local service="$1"
28
- docker ps --filter "name=${COMPOSE_PROJECT}-${service}-1" --format '{{.Names}}' 2>/dev/null \
29
- | grep -q "^${COMPOSE_PROJECT}-${service}-1\$"
30
- }
31
-
32
- har_resolve_infra_port() {
33
- local var_name="$1"
34
- local default_port="$2"
35
- local scan_start="$3"
36
- local scan_end="$4"
37
- local service="${5:-}"
38
- local current="${!var_name:-}"
39
-
40
- if [ -n "$current" ] && { ! port_in_use "$current" || { [ -n "$service" ] && har_compose_service_running "$service"; }; }; then
41
- echo "$current"
42
- return 0
43
- fi
44
- har_allocate_port "$default_port" "$scan_start" "$scan_end"
45
- }
46
-
47
- mkdir -p "$(dirname "$INFRA_STATE")"
48
- if [ -f "$INFRA_STATE" ]; then
49
- # shellcheck source=/dev/null
50
- source "$INFRA_STATE"
51
- fi
52
-
53
- DB_PORT="$(har_resolve_infra_port AGENT_DB_PORT \
54
- "${HARNESS_DB_PORT_DEFAULT:-15432}" \
55
- "${HARNESS_DB_PORT_SCAN_START:-15432}" \
56
- "${HARNESS_DB_PORT_SCAN_END:-15499}" \
57
- db)"
58
- MINIO_PORT="$(har_resolve_infra_port AGENT_MINIO_PORT \
59
- "${HARNESS_MINIO_PORT_DEFAULT:-19000}" \
60
- "${HARNESS_MINIO_PORT_SCAN_START:-19000}" \
61
- "${HARNESS_MINIO_PORT_SCAN_END:-19099}" \
62
- minio)"
63
- MINIO_CONSOLE_PORT="$(har_resolve_infra_port AGENT_MINIO_CONSOLE_PORT \
64
- "${HARNESS_MINIO_CONSOLE_PORT_DEFAULT:-19001}" \
65
- "${HARNESS_MINIO_CONSOLE_PORT_SCAN_START:-19001}" \
66
- "${HARNESS_MINIO_CONSOLE_PORT_SCAN_END:-19099}")"
67
- BROWSER_PORT="$(har_resolve_infra_port AGENT_BROWSER_PORT \
68
- "${HARNESS_BROWSER_PORT_DEFAULT:-13001}" \
69
- "${HARNESS_BROWSER_PORT_SCAN_START:-13001}" \
70
- "${HARNESS_BROWSER_PORT_SCAN_END:-13099}" \
71
- headless-browser)"
72
- MAILPIT_WEB_PORT="$(har_resolve_infra_port AGENT_MAILPIT_WEB_PORT \
73
- "${HARNESS_MAILPIT_WEB_PORT_DEFAULT:-18025}" \
74
- "${HARNESS_MAILPIT_WEB_PORT_SCAN_START:-18025}" \
75
- "${HARNESS_MAILPIT_WEB_PORT_SCAN_END:-18099}" \
76
- mailpit)"
77
- MAILPIT_SMTP_PORT="$(har_resolve_infra_port AGENT_MAILPIT_SMTP_PORT \
78
- "${HARNESS_MAILPIT_SMTP_PORT_DEFAULT:-11025}" \
79
- "${HARNESS_MAILPIT_SMTP_PORT_SCAN_START:-11025}" \
80
- "${HARNESS_MAILPIT_SMTP_PORT_SCAN_END:-11099}")"
81
-
82
- export AGENT_DB_PORT="$DB_PORT"
83
- export AGENT_MINIO_PORT="$MINIO_PORT"
84
- export AGENT_MINIO_CONSOLE_PORT="$MINIO_CONSOLE_PORT"
85
- export AGENT_BROWSER_PORT="$BROWSER_PORT"
86
- export AGENT_MAILPIT_WEB_PORT="$MAILPIT_WEB_PORT"
87
- export AGENT_MAILPIT_SMTP_PORT="$MAILPIT_SMTP_PORT"
88
-
89
- cat > "$INFRA_STATE" <<EOF
90
- # Persisted by setup-infra.sh — host ports for shared docker compose services.
91
- export AGENT_DB_PORT=${DB_PORT}
92
- export AGENT_MINIO_PORT=${MINIO_PORT}
93
- export AGENT_MINIO_CONSOLE_PORT=${MINIO_CONSOLE_PORT}
94
- export AGENT_BROWSER_PORT=${BROWSER_PORT}
95
- export AGENT_MAILPIT_WEB_PORT=${MAILPIT_WEB_PORT}
96
- export AGENT_MAILPIT_SMTP_PORT=${MAILPIT_SMTP_PORT}
97
- EOF
98
-
99
- SERVICES="${HARNESS_INFRA_SERVICES:-}"
100
-
101
- if [ -n "$SERVICES" ]; then
102
- log "Starting shared infrastructure (project: $COMPOSE_PROJECT): $SERVICES"
103
- AGENT_DB_PORT="$DB_PORT" \
104
- AGENT_MINIO_PORT="$MINIO_PORT" \
105
- AGENT_MINIO_CONSOLE_PORT="$MINIO_CONSOLE_PORT" \
106
- AGENT_BROWSER_PORT="$BROWSER_PORT" \
107
- AGENT_MAILPIT_WEB_PORT="$MAILPIT_WEB_PORT" \
108
- AGENT_MAILPIT_SMTP_PORT="$MAILPIT_SMTP_PORT" \
109
- docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" up -d $SERVICES
110
- else
111
- log "No shared infra services enabled in harness.env (HARNESS_INFRA_SERVICES)"
112
- fi
113
-
114
- # Wait for PostgreSQL and prepare the template database
115
- if har_infra_enabled db; then
116
- log "Waiting for PostgreSQL on port $DB_PORT..."
117
- for i in $(seq 1 30); do
118
- if har_pg pg_isready -q 2>/dev/null; then
119
- log "PostgreSQL is ready."
120
- break
121
- fi
122
- if [ "$i" = "30" ]; then
123
- echo "Error: PostgreSQL did not become ready within 30 seconds." >&2
124
- exit 1
125
- fi
126
- sleep 1
127
- done
128
-
129
- log "Enabling pg_stat_statements extension..."
130
- $PSQL -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements" 2>/dev/null || true
131
-
132
- if [ -n "${HARNESS_TEMPLATE_DB:-}" ]; then
133
- if $PSQL -tAc "SELECT 1 FROM pg_database WHERE datname = '$HARNESS_TEMPLATE_DB'" | grep -q 1; then
134
- log "Template database '$HARNESS_TEMPLATE_DB' already exists. Skipping creation."
135
- else
136
- log "Creating template database '$HARNESS_TEMPLATE_DB'..."
137
- $PSQL -c "CREATE DATABASE $HARNESS_TEMPLATE_DB"
138
-
139
- if [ -n "${HARNESS_DB_MIGRATE_CMD:-}" ] && [ "$HARNESS_DB_MIGRATE_CMD" != "echo 'TODO: set migrate command'" ]; then
140
- log "Running migrations..."
141
- PGPASSWORD=password PGHOST=localhost PGPORT="$DB_PORT" PGUSER=postgres \
142
- PGDATABASE="$HARNESS_TEMPLATE_DB" \
143
- bash -c "cd '$REPO_ROOT' && $HARNESS_DB_MIGRATE_CMD"
144
- fi
145
-
146
- if [ -n "${HARNESS_DB_SEED_CMD:-}" ] && [ "$HARNESS_DB_SEED_CMD" != "echo 'TODO: set seed command'" ]; then
147
- log "Running seeds..."
148
- PGPASSWORD=password PGHOST=localhost PGPORT="$DB_PORT" PGUSER=postgres \
149
- PGDATABASE="$HARNESS_TEMPLATE_DB" \
150
- bash -c "cd '$REPO_ROOT' && $HARNESS_DB_SEED_CMD"
151
- fi
152
-
153
- log "Marking '$HARNESS_TEMPLATE_DB' as a PostgreSQL template..."
154
- $PSQL -c "UPDATE pg_database SET datistemplate = true WHERE datname = '$HARNESS_TEMPLATE_DB'"
155
- log "Template database ready: $HARNESS_TEMPLATE_DB"
156
- fi
157
- fi
158
- fi
159
-
160
- # Shared app services — supporting services of a monolith/monorepo that agents
161
- # depend on but do not modify. Started ONCE on fixed ports, shared by all slots.
162
- # Create .har/ecosystem.shared.config.cjs (PM2 format, processes named
163
- # "har-${HARNESS_PROJECT_NAME}-shared-<name>") only when the primary app needs
164
- # sibling services running.
165
- SHARED_ECOSYSTEM="$SCRIPT_DIR/ecosystem.shared.config.cjs"
166
- if [ -f "$SHARED_ECOSYSTEM" ]; then
167
- log "Starting shared app services from ecosystem.shared.config.cjs..."
168
- (cd "$REPO_ROOT" && $(har_pkg_exec) pm2 startOrReload "$SHARED_ECOSYSTEM" >/dev/null)
169
- log "Shared app services running (pm2 ls | grep har-${HARNESS_PROJECT_NAME}-shared-)."
170
- fi
171
-
172
- echo ""
173
- log "Infrastructure is ready."
174
- har_infra_enabled db && log " PostgreSQL: localhost:$DB_PORT"
175
- har_infra_enabled minio && log " MinIO: http://localhost:${MINIO_CONSOLE_PORT}"
176
- har_infra_enabled headless-browser && log " Browser: http://localhost:${BROWSER_PORT}"
177
- har_infra_enabled mailpit && log " Mailpit: http://localhost:${MAILPIT_WEB_PORT}"
178
- exit 0
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Per-stage scripts live here (e.g. ./.har/stages/browser-e2e.sh <agent-id>).
3
- #
4
- # Read .har/STAGES.md for the authoring guide: the stage script contract,
5
- # command vs script stages, and how verificationStages controls verify --full.
6
- #
7
- # Scaffold a new one with:
8
- # har env add-stage <id> --custom --script
9
-
10
- echo "Add stage scripts under .har/stages/ and register them in stages.json — see .har/STAGES.md." >&2
11
- exit 1
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Tear down an agent slot for CLI/library repos.
3
- # The session's git branch is KEPT by default so you can push it / open a PR —
4
- # pass --delete-branch to remove it too.
5
- #
6
- # Usage: ./.har/teardown.sh <agent-id> [--delete-branch]
7
- set -euo pipefail
8
-
9
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
- REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
11
-
12
- # shellcheck source=/dev/null
13
- source "$SCRIPT_DIR/harness.env"
14
- # shellcheck source=/dev/null
15
- source "$SCRIPT_DIR/agent-slot.sh"
16
-
17
- AGENT_ID="${1:?Usage: teardown.sh <agent-id> [--delete-branch]}"
18
- DELETE_BRANCH=false
19
-
20
- for arg in "${@:2}"; do
21
- case "$arg" in
22
- --delete-branch) DELETE_BRANCH=true ;;
23
- esac
24
- done
25
-
26
- validate_agent_id "$AGENT_ID"
27
-
28
- echo "==> Tearing down agent ${AGENT_ID}..."
29
-
30
- # Resolve the session from the registry; fall back to the legacy fixed path so
31
- # pre-registry sessions stay removable.
32
- REGISTRY_FILE="$(slot_registry_file "$AGENT_ID")"
33
- WORKTREE_PATH=""
34
- WORK_DIR=""
35
- BRANCH=""
36
- if [ -f "$REGISTRY_FILE" ]; then
37
- WORKTREE_PATH="$(read_slot_field "$REGISTRY_FILE" worktreePath || true)"
38
- WORK_DIR="$(read_slot_field "$REGISTRY_FILE" workDir || true)"
39
- BRANCH="$(read_slot_field "$REGISTRY_FILE" branch || true)"
40
- fi
41
- [ -n "$WORKTREE_PATH" ] || WORKTREE_PATH="$HOME/worktrees/${HARNESS_PROJECT_NAME}-agent-${AGENT_ID}"
42
-
43
- rm -f "$REPO_ROOT/.env.agent.${AGENT_ID}"
44
- if [ -n "$WORK_DIR" ] && [ -d "$WORK_DIR" ]; then
45
- rm -f "$WORK_DIR/.env.agent.${AGENT_ID}"
46
- fi
47
-
48
- if [ -d "$WORKTREE_PATH" ]; then
49
- rm -f "$WORKTREE_PATH/.env.agent.${AGENT_ID}"
50
- git -C "$REPO_ROOT" worktree remove "$WORKTREE_PATH" --force 2>/dev/null || rm -rf "$WORKTREE_PATH"
51
- echo "✓ Removed worktree: $WORKTREE_PATH"
52
- fi
53
- git -C "$REPO_ROOT" worktree prune 2>/dev/null || true
54
-
55
- if [ -n "$BRANCH" ]; then
56
- if [ "$DELETE_BRANCH" = true ]; then
57
- git -C "$REPO_ROOT" branch -D "$BRANCH" 2>/dev/null || true
58
- echo "✓ Deleted branch: $BRANCH"
59
- else
60
- echo "✓ Kept branch: $BRANCH (push it or delete with: git branch -D $BRANCH)"
61
- fi
62
- fi
63
-
64
- remove_slot_registry "$AGENT_ID"
65
-
66
- echo "✓ Agent ${AGENT_ID} torn down"
@@ -1,210 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Verification pipeline for CLI/library repos.
3
- # Outputs JSON to stdout (machine contract), human-readable progress to stderr.
4
- # Passing steps omit `output`. `har env verify` streams progress only.
5
- #
6
- # Usage: ./.har/verify.sh <agent-id> [--full]
7
- #
8
- # Quick (default): ecosystem smoke — compile/import/build only
9
- # Full (--full): + conventional tests, lint, readiness, and every registered
10
- # stage in stages.json verificationStages (see .har/STAGES.md)
11
- # Stock steps are examples. Replace them during adaptation to match this repo.
12
- set -euo pipefail
13
-
14
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
- REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
16
-
17
- # shellcheck source=/dev/null
18
- source "$SCRIPT_DIR/harness.env"
19
- # shellcheck source=/dev/null
20
- source "$SCRIPT_DIR/agent-slot.sh"
21
-
22
- AGENT_ID="${1:?Usage: verify.sh <agent-id> [--full]}"
23
- FULL=""
24
-
25
- for arg in "${@:2}"; do
26
- [ "$arg" = "--full" ] && FULL=1
27
- done
28
-
29
- validate_agent_id "$AGENT_ID"
30
-
31
- ENV_FILE="$(resolve_agent_env_file "$AGENT_ID" "$REPO_ROOT")" || {
32
- echo "No .env.agent.${AGENT_ID} found." >&2
33
- har_suggest_launch "$AGENT_ID" >&2
34
- exit 1
35
- }
36
-
37
- set -a
38
- # shellcheck source=/dev/null
39
- source "$ENV_FILE"
40
- set +a
41
-
42
- WORK_DIR="$(resolve_agent_work_dir "$ENV_FILE")"
43
-
44
- echo "==> Verifying agent ${AGENT_ID} in ${WORK_DIR}..." >&2
45
- REG_FILE="$(slot_registry_file "$AGENT_ID")"
46
- echo " Work dir: ${WORK_DIR}" >&2
47
- echo " Env file: ${ENV_FILE}" >&2
48
- if [ -f "$REG_FILE" ]; then
49
- echo " Registry: ${REG_FILE}" >&2
50
- else
51
- echo " Registry: missing (${REG_FILE})" >&2
52
- fi
53
-
54
- OVERALL_PASS=true
55
- START_TOTAL=$(now_ms)
56
- RESULTS_JSON="[]"
57
-
58
- run_step() {
59
- local name="$1"
60
- local cmd="$2"
61
- local start end elapsed exit_code output
62
-
63
- printf " → %-40s" "$name..." >&2
64
- start=$(now_ms)
65
-
66
- set +e
67
- output=$(cd "$WORK_DIR" && set -a && . "$ENV_FILE" && set +a && eval "$cmd" 2>&1)
68
- exit_code=$?
69
- set -e
70
-
71
- end=$(now_ms)
72
- elapsed=$(( end - start ))
73
-
74
- local pass_bool
75
- if [ "$exit_code" = "0" ]; then
76
- echo "✓ (${elapsed}ms)" >&2
77
- pass_bool="true"
78
- else
79
- echo "✗ (${elapsed}ms)" >&2
80
- echo "$output" | head -30 | sed 's/^/ /' >&2
81
- pass_bool="false"
82
- OVERALL_PASS=false
83
- fi
84
-
85
- record_step_result "$name" "$pass_bool" "$elapsed" "$output"
86
-
87
- if [ "$pass_bool" = "false" ] && [ -z "$FULL" ]; then
88
- return 1
89
- fi
90
- }
91
-
92
- node_package_script_exists() {
93
- local script="$1"
94
- "${NODE_BIN:-node}" -e "
95
- const fs = require('fs');
96
- const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
97
- const script = process.argv[1];
98
- process.exit(pkg.scripts && pkg.scripts[script] ? 0 : 1);
99
- " "$script"
100
- }
101
-
102
- run_node_script_or_skip() {
103
- local name="$1"
104
- local script="$2"
105
- if node_package_script_exists "$script"; then
106
- run_step "$name" "${NPM_BIN:-npm} run ${script}"
107
- else
108
- run_step "$name" "echo 'No ${script} script configured; skipping.'"
109
- fi
110
- }
111
-
112
- run_node_quick_smoke() {
113
- if node_package_script_exists typecheck; then
114
- run_step "node-typecheck" '${NPM_BIN:-npm} run typecheck'
115
- elif node_package_script_exists build; then
116
- run_step "node-build" '${NPM_BIN:-npm} run build'
117
- else
118
- run_step "node-package-load" '${NODE_BIN:-node} -e "require(\"./package.json\")"'
119
- fi
120
- }
121
-
122
- run_quick_smoke() {
123
- case "${HARNESS_ECOSYSTEM:-none}" in
124
- node)
125
- run_node_quick_smoke
126
- ;;
127
- python)
128
- run_step "python-compile" '${PYTHON_BIN:-python3} -m compileall -q .'
129
- ;;
130
- go)
131
- run_step "go-build" '${GO_BIN:-go} build ./...'
132
- ;;
133
- rust)
134
- run_step "rust-check" '${CARGO_BIN:-cargo} check'
135
- ;;
136
- java)
137
- run_step "java-compile" 'if [ -x ./mvnw ]; then ./mvnw -q -DskipTests compile; elif command -v mvn >/dev/null 2>&1; then mvn -q -DskipTests compile; elif [ -x ./gradlew ]; then ./gradlew classes; elif command -v gradle >/dev/null 2>&1; then gradle classes; else echo "No Maven/Gradle command found; adapt verify.sh for this Java repo."; fi'
138
- ;;
139
- ruby)
140
- run_step "ruby-smoke" '${RUBY_BIN:-ruby} -e "puts RUBY_VERSION"'
141
- ;;
142
- custom|none|*)
143
- run_step "smoke-not-configured" 'echo "No stock smoke for HARNESS_ECOSYSTEM=${HARNESS_ECOSYSTEM:-none}; adapt .har/verify.sh for this repo."'
144
- ;;
145
- esac
146
- }
147
-
148
- run_full_checks() {
149
- case "${HARNESS_ECOSYSTEM:-none}" in
150
- node)
151
- run_node_script_or_skip "unit-tests" test || true
152
- run_node_script_or_skip "lint" lint || true
153
- ;;
154
- python)
155
- run_step "unit-tests" 'if ${PYTHON_BIN:-python3} -c "import pytest" >/dev/null 2>&1; then ${PYTHON_BIN:-python3} -m pytest -q; else echo "pytest not installed; adapt verify.sh for this Python repo."; fi' || true
156
- ;;
157
- go)
158
- run_step "unit-tests" '${GO_BIN:-go} test ./...' || true
159
- ;;
160
- rust)
161
- run_step "unit-tests" '${CARGO_BIN:-cargo} test' || true
162
- ;;
163
- java)
164
- run_step "unit-tests" 'if [ -x ./mvnw ]; then ./mvnw -q test; elif command -v mvn >/dev/null 2>&1; then mvn -q test; elif [ -x ./gradlew ]; then ./gradlew test; elif command -v gradle >/dev/null 2>&1; then gradle test; else echo "No Maven/Gradle command found; adapt verify.sh for this Java repo."; fi' || true
165
- ;;
166
- ruby)
167
- run_step "unit-tests" 'if command -v "${BUNDLE_BIN:-bundle}" >/dev/null 2>&1 && [ -f Gemfile ]; then "${BUNDLE_BIN:-bundle}" exec rake test 2>/dev/null || "${BUNDLE_BIN:-bundle}" exec rspec; else echo "No Ruby test command detected; adapt verify.sh for this Ruby repo."; fi' || true
168
- ;;
169
- custom|none|*)
170
- run_step "unit-tests" 'echo "No stock full checks for HARNESS_ECOSYSTEM=${HARNESS_ECOSYSTEM:-none}; adapt .har/verify.sh for this repo."' || true
171
- ;;
172
- esac
173
- }
174
-
175
- # ── Verification stages ─────────────────────────────────────────────────────
176
- # These stock steps are intentionally generic conventions. Adapt this section
177
- # to the repository's real commands from package.json, Makefile, CI, pyproject,
178
- # Cargo.toml, go.mod, pom.xml, etc.
179
- run_quick_smoke || { [ -z "$FULL" ] && true; }
180
-
181
- if [ -n "$FULL" ]; then
182
- run_full_checks
183
- run_step "readiness" "run_readiness_if_configured \"$AGENT_ID\"" || true
184
- # Registered verification stages from .har/stages.json (see .har/STAGES.md).
185
- # Every stage listed in verificationStages with a registered script/command
186
- # runs here -- plugins and custom stages alike.
187
- while IFS=$'\t' read -r STAGE_ID STAGE_CMD; do
188
- [ -n "$STAGE_ID" ] || continue
189
- run_step "$STAGE_ID" "$STAGE_CMD" || true
190
- done < <(list_registered_verification_stage_commands "$SCRIPT_DIR" "$AGENT_ID")
191
- fi
192
-
193
- END_TOTAL=$(now_ms)
194
- TOTAL_MS=$(( END_TOTAL - START_TOTAL ))
195
-
196
- node -e "
197
- const results = $RESULTS_JSON;
198
- const overall = results.length > 0 && results.every(r => r.pass);
199
- const out = {
200
- status: overall ? 'pass' : 'fail',
201
- agent_id: $AGENT_ID,
202
- total_ms: $TOTAL_MS,
203
- stages: results,
204
- };
205
- process.stdout.write(JSON.stringify(out, null, 2) + '\n');
206
- " 2>/dev/null || echo "{\"status\":\"fail\",\"agent_id\":${AGENT_ID},\"stages\":[]}"
207
-
208
- if [ "$OVERALL_PASS" = "false" ]; then
209
- exit 1
210
- fi
@@ -1,63 +0,0 @@
1
- # Adapt this iOS harness to the project
2
-
3
- You are adapting a freshly scaffolded iOS mobile app harness. Read the existing repo
4
- structure, then make the changes listed below. Commit when done.
5
-
6
- ## 1 — Read before editing
7
-
8
- - `AGENTS.md` at the repo root (overview and do-nots)
9
- - `.har/README.md` (harness index)
10
- - `.har/harness.env` (all config vars)
11
- - `.har/stages.json` (stage registry)
12
- - Root of the repo: look for `*.xcworkspace`, `*.xcodeproj`, `Podfile`, `Package.swift`
13
-
14
- ## 2 — Set Xcode project config in `.har/harness.env`
15
-
16
- | Variable | What to set |
17
- |----------|-------------|
18
- | `HARNESS_XCODE_WORKSPACE` | Relative path to `.xcworkspace` (e.g. `MyApp.xcworkspace`). Use when CocoaPods or a workspace is present. Leave empty otherwise. |
19
- | `HARNESS_XCODE_PROJECT` | Relative path to `.xcodeproj` (e.g. `MyApp.xcodeproj`). Only set when no workspace. |
20
- | `HARNESS_XCODE_SCHEME` | Name of the shared Xcode scheme (must be marked Shared in Xcode → Product → Scheme → Manage Schemes). |
21
- | `HARNESS_SIMULATOR_NAME` | Display name exactly as shown in `xcrun simctl list devices` (e.g. `iPhone 16`). |
22
- | `HARNESS_BUNDLE_ID` | App bundle identifier from the Xcode target (e.g. `com.example.myapp`). |
23
-
24
- If the project is generated (`Project.swift`, `project.yml`, or a `Podfile` with no
25
- tracked `.xcworkspace`), still set the path the generator produces — launch runs
26
- `tuist generate` / `xcodegen generate` / `pod install` when the file is absent from
27
- a fresh worktree. Use `HARNESS_INSTALL_CMD` only when that default is wrong; it then
28
- owns provisioning outright.
29
-
30
- Run `./.har/setup-infra.sh` after editing to confirm the simulator boots.
31
-
32
- ## 3 — Verify `.har/verify.sh` builds and tests correctly
33
-
34
- Run `./.har/launch.sh 1`, then `./.har/verify.sh 1`.
35
-
36
- Common adaptations:
37
- - If the project uses a custom test plan, add `-testPlan MyTests` to the `xcodebuild test` invocation.
38
- - If SwiftLint is not used, remove or comment out the `lint` step.
39
- - If there are UI tests that require a running app, move them to a RocketSim flow (`har env add-plugin rocketsim`) rather than xcodebuild tests.
40
-
41
- ## 4 — Add the RocketSim plugin (recommended)
42
-
43
- ```bash
44
- har env add-plugin rocketsim
45
- ```
46
-
47
- Then adapt `flows/example-smoke.sh` to navigate to your app's main screen and verify it loads.
48
- Read `.har/stages/ROCKETSIM.md` for the full authoring guide.
49
-
50
- ## 5 — Update `AGENTS.md` (repo root)
51
-
52
- Replace the TODO section with:
53
- - Which Xcode scheme and simulator are used
54
- - How to run unit tests manually
55
- - How to add a new RocketSim user flow
56
-
57
- ## 6 — Verify everything passes
58
-
59
- ```bash
60
- ./.har/verify.sh 1 --full
61
- ```
62
-
63
- All steps should return ✓. Commit the adapted harness in the session worktree.
@@ -1,90 +0,0 @@
1
- # Agent ${AGENT_ID} — iOS Development Environment
2
-
3
- > [`AGENTS.md`](../AGENTS.md) · [`.har/README.md`](./README.md) · [`stages.json`](./stages.json)
4
-
5
- ## Environment
6
-
7
- | | |
8
- |--|--|
9
- | **Agent ID** | ${AGENT_ID} |
10
- | **Work dir** | Fresh session worktree per launch — see the launch output or `.har/slots/agent-${AGENT_ID}.json` |
11
- | **Simulator** | Created for this slot at launch — `HARNESS_SIMULATOR_UDID` in `.env.agent.${AGENT_ID}` |
12
- | **Scheme** | Configured in `.har/harness.env` — `HARNESS_XCODE_SCHEME` |
13
-
14
- **Never edit the main checkout** — launch FIRST, then make ALL file edits under the work dir from the launch output. An occupied slot always blocks a new launch — run `har env teardown <id>` (or `complete <id>`) first, then launch again.
15
-
16
- ```bash
17
- ./.har/agent-cli.sh ${AGENT_ID} status
18
- ```
19
-
20
- ## Readiness
21
-
22
- Adapt this section for the repository. A successful build/test run does not
23
- always mean an agent can use the app. If the app needs a backend, credentials,
24
- seeded data, or a simulator flow, document it here and wire the smoke into
25
- `HARNESS_READINESS_CMD`, RocketSim flows, or full verify.
26
-
27
- ## Definition of done
28
-
29
- - [ ] Full verification returns `"status": "pass"` (`har env verify ${AGENT_ID} --full`, MCP `har_run_verification` with `full: true`, or `./.har/verify.sh ${AGENT_ID} --full`)
30
- - [ ] The slot is agent-usable for this repo's documented smoke workflow when runtime services are involved
31
- - [ ] When `stages/rocketsim-flows.sh` exists, full verify includes user-flow validation — add or update flow scripts in `flows/` for UI changes
32
- - [ ] New behavior has automated test coverage (unit tests via XCTest)
33
- - [ ] Changes committed **in the session worktree** with a clear message
34
- - [ ] Present session handoff (summary, branch, preview URLs) and **wait for user** before `complete`, push, or PR
35
- - [ ] On user approval of the default: push + open PR (when `gh`/GitHub MCP available), then `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. **Default recommendation:** when
41
- `gh` or GitHub MCP is available, complete the slot **and** open a PR (push → PR →
42
- `har env complete` / `har_complete_environment`). Offer complete-only or something
43
- else as alternatives. If PR tooling is unavailable, recommend complete and report
44
- the session branch for a manual push. Prefer `complete` over bare `teardown` when
45
- the work succeeded. See `.cursor/rules/har-workflow.mdc` for the handoff shape.
46
-
47
- Quick loop: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}`
48
-
49
- Stages are the harness's single vocabulary for checks: templates and custom stages compile to generic kinds in `.har/stages.json`, and you interact with them only through the registry (`har_run_stage`, `verify`), never stack-specific tooling. Authoring guide: `.har/STAGES.md`.
50
-
51
- ## Project commands
52
-
53
- Target **this slot's** simulator, never `booted` — another agent's device may also
54
- be booted. `HARNESS_IOS_DESTINATION` and `HARNESS_SIMULATOR_UDID` come from
55
- `.env.agent.${AGENT_ID}`.
56
-
57
- ```bash
58
- source .env.agent.${AGENT_ID}
59
-
60
- # Build
61
- xcodebuild build -scheme MyApp -destination "$HARNESS_IOS_DESTINATION" CODE_SIGNING_ALLOWED=NO
62
-
63
- # Run unit tests — signed, or an app with entitlements traps at launch
64
- xcodebuild test -scheme MyApp -destination "$HARNESS_IOS_DESTINATION"
65
-
66
- # Install and launch on this slot's device
67
- ./.har/agent-cli.sh ${AGENT_ID} install path/to/MyApp.app
68
- ./.har/agent-cli.sh ${AGENT_ID} launch-app
69
- ```
70
-
71
- Adapt for your scheme — see `.har/harness.env`.
72
-
73
- ## User-flow validation (RocketSim)
74
-
75
- If the RocketSim plugin is installed (`har env add-plugin rocketsim`):
76
-
77
- ```bash
78
- ./.har/stages/rocketsim-flows.sh ${AGENT_ID}
79
- # included in:
80
- ./.har/verify.sh ${AGENT_ID} --full
81
- ```
82
-
83
- Add and edit user flow scripts in `flows/`. Read `.har/stages/ROCKETSIM.md` for the full authoring guide.
84
-
85
- ## Do not
86
-
87
- - Work around a failing harness command with ad-hoc setup — fix the harness or report the failure
88
- - Edit `.env.agent.${AGENT_ID}` by hand
89
- - Run verify before launch (the simulator and worktree must be set up first)
90
- - Edit the main checkout — all edits go under the session work dir