@osfactory/har 0.64.2 → 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 +15675 -6536
  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
@@ -0,0 +1,41 @@
1
+ ## Port & shared services
2
+
3
+ ### Port allocation
4
+
5
+ | Layer | Scope | Rule | On conflict |
6
+ |-------|-------|------|-------------|
7
+ | App — frontend | Per slot | `HARNESS_FE_BASE_PORT + (AGENT_ID × HARNESS_PORT_STEP)` | Scan `STEP` increments within the slot lane |
8
+ | App — API | Per slot | `HARNESS_API_BASE_PORT + (AGENT_ID × STEP)` | Same scan policy |
9
+ | Node debug | Per slot | `9200 + (AGENT_ID × STEP)` | Same scan policy |
10
+ | Shared Postgres | Per machine | `HARNESS_DB_PORT_DEFAULT` | Scan `HARNESS_DB_PORT_SCAN_START..END` |
11
+ | MinIO / S3 | Per machine | `HARNESS_MINIO_PORT_DEFAULT` (+ console port) | Scan configured ranges in `harness.env` |
12
+ | Mailpit | Per machine | `HARNESS_MAILPIT_*_PORT_DEFAULT` | Scan configured ranges |
13
+ | Headless browser | Per machine | `HARNESS_BROWSER_PORT_DEFAULT` | Scan configured ranges |
14
+
15
+ Resolved ports may differ from the formula when something else is already bound. Always use `./.har/agent-cli.sh <id>` or read `.har/slots/agent-<id>.json` — never hardcode `3010`, `15432`, etc. in app code or tests.
16
+
17
+ ### Shared vs per-slot
18
+
19
+ | Resource | Model | Configuration |
20
+ |----------|-------|---------------|
21
+ | Postgres | One shared container; per-slot database `agent_<id>` cloned from template | `HARNESS_INFRA_SERVICES="db"` |
22
+ | MinIO / S3 | One shared container; per-slot bucket `agent-<id>` | `HARNESS_INFRA_SERVICES="... minio"` |
23
+ | Mailpit, Redis, etc. | One shared container on a scanned host port | Listed in `HARNESS_INFRA_SERVICES` |
24
+ | Primary application | One PM2 ecosystem per slot (isolated ports) | `HARNESS_PRIMARY_APP`, `ecosystem.agent.template.cjs` |
25
+ | Internal supporting services | Shared across all slots | `docker-compose.agent.yml` or `ecosystem.shared.config.cjs` |
26
+
27
+ Shared infra starts once via `./.har/setup-infra.sh` (also run automatically by `launch.sh`). Per-slot databases are cloned in `launch.sh`.
28
+
29
+ ### Do not
30
+
31
+ - Hardcode default ports (`3000`, `15432`, `3847`, …) in application code, tests, or agent docs — read from `.env.agent.<id>`, `agent-cli.sh`, or the slot registry
32
+ - Run raw `docker compose` for harness infrastructure — use `setup-infra.sh` / `launch.sh` so ports are scanned and persisted in `.har/state/infra.env`
33
+
34
+ ### Primary app vs shared services
35
+
36
+ Each slot runs **only the primary application** (`HARNESS_PRIMARY_APP` in `harness.env`) — the app agents modify. Everything else runs **once**, shared by all slots on fixed ports:
37
+
38
+ - **External dependencies** (Postgres, Redis, mail, ...): services in `docker-compose.agent.yml`, enabled via the `HARNESS_INFRA_SERVICES` list in `harness.env`, started by `setup-infra.sh`.
39
+ - **Internal supporting services** (other services of a monolith/monorepo the agent depends on but does not change): either compose services in `docker-compose.agent.yml`, or PM2 processes in an optional `.har/ecosystem.shared.config.cjs` (named `har-shared-<name>`, started by `setup-infra.sh`).
40
+
41
+ Isolation still applies where it matters: each slot gets its own database (`agent_<id>`, cloned from the template DB), ports, and git worktree.
@@ -0,0 +1,24 @@
1
+ ## Quick start
2
+
3
+ **har CLI or MCP:**
4
+
5
+ ```bash
6
+ har env launch 1
7
+ har env verify 1
8
+ har env verify 1 --full
9
+ har env teardown 1
10
+ ```
11
+
12
+ In Cursor with HAR MCP configured: use `har_launch_environment`, `har_run_verification`, and `har_teardown_environment`.
13
+
14
+ **Shell shims** (same runtime — each `./.har/*.sh` forwards to `har env`, with a pinned `npx @osfactory/har` fallback):
15
+
16
+ ```bash
17
+ ./.har/setup-infra.sh # when HARNESS_INFRA_SERVICES is non-empty
18
+ ./.har/launch.sh 1
19
+ ./.har/verify.sh 1 # quick: ecosystem smoke + health
20
+ ./.har/verify.sh 1 --full # + conventional tests/lint, browser-e2e (if installed)
21
+ ./.har/teardown.sh 1
22
+ ```
23
+
24
+ Read **`stages.json`** for registered stages and **`verificationStages`** for the expected pass set.
@@ -0,0 +1,16 @@
1
+ ## Readiness layers
2
+
3
+ Do not treat a health endpoint as the whole definition of success. Adapt this
4
+ section for the repository:
5
+
6
+ | Layer | What it means | Where to encode it |
7
+ |-------|---------------|--------------------|
8
+ | Infra ready | Shared services and template data stores exist | `setup-infra.sh`, `docker-compose.agent.yml` |
9
+ | Slot data ready | Every per-slot data store is created/cloned | `launch.sh` |
10
+ | Process ready | Primary app is running and health passes | `launch.sh`, `verify.sh` |
11
+ | Agent usable | Login/API/UI smoke works with documented data | `HARNESS_READINESS_CMD`, browser-e2e, `CLAUDE.agent.md` |
12
+
13
+ If full local-dev setup is too heavy to run in the harness, document the skipped
14
+ steps and add the minimum substitute directly in `.har/` scripts (for example an
15
+ idempotent bootstrap for required users/tenants/settings). Health alone is not
16
+ enough for UI/auth apps.
@@ -0,0 +1,17 @@
1
+ ## Verification contract
2
+
3
+ Steps in `verify.sh` are **project-specific examples** — adapt them to your stack
4
+ during `har env init` / `har env maintain`. The table describes each tier's intent,
5
+ not a fixed command list.
6
+
7
+ | Mode | Command | Typical steps |
8
+ |------|---------|---------------|
9
+ | Quick | `har env verify <id>` or `verify.sh <id>` | Stock ecosystem smoke + health (stops early on failure) |
10
+ | Full | `har env verify <id> --full` or `verify.sh <id> --full` | Stock conventional tests/lint, optional readiness smoke + **`browser-e2e`** when `.har/stages/browser-e2e.sh` exists |
11
+
12
+ The stock commands are deliberately generic conventions keyed by
13
+ `HARNESS_ECOSYSTEM`. Replace them with the repository's real commands during
14
+ adaptation; do not leave Node/npm, Python, Go, Rust, Java, or Ruby defaults in
15
+ place when they do not match the project.
16
+
17
+ Install Playwright plugin: `har env add-plugin playwright` (optional). UI changes should add or update specs under `tests/`.
@@ -0,0 +1,28 @@
1
+ ## What's in here
2
+
3
+ **Yours — the configuration surface** (edit freely; drift tracking records adaptations):
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `README.md` | This file — index of the harness |
8
+ | `harness.env` | Schema-validated config: primary app, ports, agent slot limits, `HARNESS_INFRA_SERVICES`, toolchain provisioning, migrate/seed commands |
9
+ | `stages.json` | Registered stages, verification tiers, artifacts, slot limits, gate policy |
10
+ | `stages/` | Project-owned stage scripts registered from `stages.json` |
11
+ | `hooks/` | Optional lifecycle hooks (`pre-launch.sh`, `post-launch.sh`, `pre-verify.sh`, `pre-teardown.sh`, `post-teardown.sh`) |
12
+ | `plugins/` | Optional local plugins (`har plugin create <id>`) |
13
+ | `env.template` | Per-agent env vars (expanded into `.env.agent.<id>` at launch) |
14
+ | `ecosystem.agent.template.cjs` | PM2 processes for the **primary app only** (expanded at launch) |
15
+ | `ecosystem.shared.config.cjs` | Optional — shared app services started once with the infra (only when the repo has supporting services) |
16
+ | `docker-compose.agent.yml` | Shared infrastructure containers (services listed in `HARNESS_INFRA_SERVICES`) |
17
+ | `CLAUDE.agent.md` | Detailed instructions for coding agents |
18
+ | `STAGES.md` | Stage registry and script-contract guide |
19
+ | `justfile` | Optional shortcuts (requires `just`) |
20
+
21
+ **Generated shims and state** (don't edit — `har env eject` for full ownership):
22
+
23
+ | File | Purpose |
24
+ |------|---------|
25
+ | `launch.sh` / `verify.sh` / `teardown.sh` / `setup-infra.sh` / `preflight.sh` / `agent-cli.sh` / `attach.sh` | Thin shims forwarding to the packaged runtime (`har env …`); same run records on every surface |
26
+ | `manifest.json` | Runtime version, profile, checksums — managed by the har CLI |
27
+ | `runs/` | Run history from every entry point — `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json` (gitignored) |
28
+ | `artifacts/` | Stage outputs: reports, traces, screenshots, logs |
@@ -5,5 +5,66 @@
5
5
  { "id": "shared-kernel", "path": "runtime-bundles/shared-kernel" },
6
6
  { "id": "pm2-runtime", "path": "runtime-bundles/pm2-runtime" },
7
7
  { "id": "runtime-default", "path": "har-boilerplate" }
8
- ]
8
+ ],
9
+ "capabilities": {
10
+ "processManager": "pm2",
11
+ "appPortLanes": true,
12
+ "infra": {
13
+ "defaultServices": ["db"],
14
+ "portLanes": "db=15432:15432-15499 minio=19000:19000-19049 minio-console=19050:19050-19099 browser=13001:13001-13099 mailpit-web=18025:18025-18099 mailpit-smtp=11025:11025-11099"
15
+ },
16
+ "defaultStages": [
17
+ "setup-infra",
18
+ "launch",
19
+ "verify",
20
+ "status",
21
+ "logs",
22
+ "teardown",
23
+ "typecheck",
24
+ "api-health",
25
+ "unit-tests",
26
+ "lint",
27
+ "readiness"
28
+ ],
29
+ "defaultEnvKeys": [
30
+ "HARNESS_PROJECT_NAME",
31
+ "HARNESS_USE_WORKTREE",
32
+ "HARNESS_PRIMARY_APP",
33
+ "HARNESS_TEMPLATE_DB",
34
+ "HARNESS_FE_BASE_PORT",
35
+ "HARNESS_API_BASE_PORT",
36
+ "HARNESS_PORT_STEP",
37
+ "HARNESS_HEALTH_CHECK_PATH",
38
+ "HARNESS_INFRA_PORT_LANES",
39
+ "HARNESS_AGENT_SLOT_MIN",
40
+ "HARNESS_AGENT_SLOT_MAX",
41
+ "HARNESS_ECOSYSTEM",
42
+ "HARNESS_INFRA_SERVICES",
43
+ "HARNESS_DB_MIGRATE_CMD",
44
+ "HARNESS_DB_SEED_CMD"
45
+ ]
46
+ },
47
+ "docs": {
48
+ "README.md": [
49
+ "intro",
50
+ "what-s-in-here",
51
+ "quick-start",
52
+ "verification-contract",
53
+ "readiness-layers",
54
+ "run-history",
55
+ "for-coding-agents",
56
+ "architecture",
57
+ "port-shared-services",
58
+ "maintaining-this-harness",
59
+ "session-lifecycle"
60
+ ],
61
+ "CLAUDE.agent.md": [
62
+ "intro",
63
+ "environment",
64
+ "readiness",
65
+ "definition-of-done",
66
+ "project-commands",
67
+ "do-not"
68
+ ]
69
+ }
9
70
  }
@@ -0,0 +1,23 @@
1
+ ## Definition of done
2
+
3
+ - [ ] 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`)
4
+ - [ ] The slot is agent-usable for this repo's documented smoke workflow when runtime services are involved
5
+ - [ ] When `stages/rocketsim-flows.sh` exists, full verify includes user-flow validation — add or update flow scripts in `flows/` for UI changes
6
+ - [ ] New behavior has automated test coverage (unit tests via XCTest)
7
+ - [ ] Changes committed **in the session worktree** with a clear message
8
+ - [ ] Present session handoff (summary, branch, preview URLs) and **wait for user** before `complete`, push, or PR
9
+ - [ ] 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
10
+
11
+ ### Session handoff
12
+
13
+ After full verify and commit, stop and propose next steps. Never autonomously run
14
+ `complete`, `teardown`, `git push`, or open a PR. **Default recommendation:** when
15
+ `gh` or GitHub MCP is available, complete the slot **and** open a PR (push → PR →
16
+ `har env complete` / `har_complete_environment`). Offer complete-only or something
17
+ else as alternatives. If PR tooling is unavailable, recommend complete and report
18
+ the session branch for a manual push. Prefer `complete` over bare `teardown` when
19
+ the work succeeded. See `.cursor/rules/har-workflow.mdc` for the handoff shape.
20
+
21
+ Quick loop: MCP `har_run_verification`, `har env verify ${AGENT_ID}`, or `./.har/verify.sh ${AGENT_ID}`
22
+
23
+ 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`.
@@ -0,0 +1,6 @@
1
+ ## Do not
2
+
3
+ - Work around a failing harness command with ad-hoc setup — fix the harness or report the failure
4
+ - Edit `.env.agent.${AGENT_ID}` by hand
5
+ - Run verify before launch (the simulator and worktree must be set up first)
6
+ - Edit the main checkout — all edits go under the session work dir
@@ -0,0 +1,14 @@
1
+ ## Environment
2
+
3
+ | | |
4
+ |--|--|
5
+ | **Agent ID** | ${AGENT_ID} |
6
+ | **Work dir** | Fresh session worktree per launch — see the launch output or `.har/slots/agent-${AGENT_ID}.json` |
7
+ | **Simulator** | Created for this slot at launch — `HARNESS_SIMULATOR_UDID` in `.env.agent.${AGENT_ID}` |
8
+ | **Scheme** | Configured in `.har/harness.env` — `HARNESS_XCODE_SCHEME` |
9
+
10
+ **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.
11
+
12
+ ```bash
13
+ ./.har/agent-cli.sh ${AGENT_ID} status
14
+ ```
@@ -0,0 +1,3 @@
1
+ # Agent ${AGENT_ID} — iOS Development Environment
2
+
3
+ > [`AGENTS.md`](../AGENTS.md) · [`.har/README.md`](./README.md) · [`stages.json`](./stages.json)
@@ -0,0 +1,21 @@
1
+ ## Project commands
2
+
3
+ Target **this slot's** simulator, never `booted` — another agent's device may also
4
+ be booted. `HARNESS_IOS_DESTINATION` and `HARNESS_SIMULATOR_UDID` come from
5
+ `.env.agent.${AGENT_ID}`.
6
+
7
+ ```bash
8
+ source .env.agent.${AGENT_ID}
9
+
10
+ # Build
11
+ xcodebuild build -scheme MyApp -destination "$HARNESS_IOS_DESTINATION" CODE_SIGNING_ALLOWED=NO
12
+
13
+ # Run unit tests — signed, or an app with entitlements traps at launch
14
+ xcodebuild test -scheme MyApp -destination "$HARNESS_IOS_DESTINATION"
15
+
16
+ # Install and launch on this slot's device
17
+ ./.har/agent-cli.sh ${AGENT_ID} install path/to/MyApp.app
18
+ ./.har/agent-cli.sh ${AGENT_ID} launch-app
19
+ ```
20
+
21
+ Adapt for your scheme — see `.har/harness.env`.
@@ -0,0 +1,6 @@
1
+ ## Readiness
2
+
3
+ Adapt this section for the repository. A successful build/test run does not
4
+ always mean an agent can use the app. If the app needs a backend, credentials,
5
+ seeded data, or a simulator flow, document it here and wire the smoke into
6
+ `HARNESS_READINESS_CMD`, RocketSim flows, or full verify.
@@ -0,0 +1,11 @@
1
+ ## User-flow validation (RocketSim)
2
+
3
+ If the RocketSim plugin is installed (`har env add-plugin rocketsim`):
4
+
5
+ ```bash
6
+ ./.har/stages/rocketsim-flows.sh ${AGENT_ID}
7
+ # included in:
8
+ ./.har/verify.sh ${AGENT_ID} --full
9
+ ```
10
+
11
+ Add and edit user flow scripts in `flows/`. Read `.har/stages/ROCKETSIM.md` for the full authoring guide.
@@ -0,0 +1,7 @@
1
+ ## Configuration
2
+
3
+ Edit **`harness.env`** to set:
4
+ - `HARNESS_XCODE_SCHEME` — your app's shared Xcode scheme
5
+ - `HARNESS_XCODE_WORKSPACE` or `HARNESS_XCODE_PROJECT` — path to the project file
6
+ - `HARNESS_SIMULATOR_NAME` — preferred simulator, matched by exact name
7
+ - `HARNESS_BUNDLE_ID` — app bundle identifier
@@ -0,0 +1,7 @@
1
+ # .har — Agent Harness (iOS mobile app profile)
2
+
3
+ This directory is the **agent harness** for this iOS mobile app repository. It lets AI coding agents build, test, and validate the app in isolated git worktrees against a running iOS Simulator.
4
+
5
+ Generated and maintained by [`har`](https://github.com/os-factory/har). Run `har env maintain` when the repo stack changes.
6
+
7
+ **The harness is how you run this project.** Launch a slot to exercise the code in isolation; don't hand-roll Xcode/simulator setup. If a harness command fails, fix the harness or report it — don't silently fall back to ad-hoc commands.
@@ -0,0 +1,25 @@
1
+ ## Port & shared services (iOS profile)
2
+
3
+ Pure iOS apps have **no per-slot TCP ports** — agents build and run on a shared iOS Simulator. Optional backend containers (mock API, etc.) use the same shared-infra model as other profiles.
4
+
5
+ ### Port allocation
6
+
7
+ | Layer | Scope | Rule | On conflict |
8
+ |-------|-------|------|-------------|
9
+ | Optional backend (compose) | Per machine | `HARNESS_*_PORT_DEFAULT` for that service | Scan configured ranges in `harness.env` |
10
+ | iOS Simulator | Per slot | One device created per agent — no harness port | None: `har-<project>-agent-<id>-<model>` is unique per slot |
11
+
12
+ When your app talks to a local backend, read the resolved host port from `.env.agent.<id>` (set by `setup-infra.sh`) — never hardcode `15432` or similar in tests or flow scripts.
13
+
14
+ ### Shared vs per-slot
15
+
16
+ | Resource | Model | Configuration |
17
+ |----------|-------|---------------|
18
+ | iOS Simulator | One device created per slot, deleted at teardown | `HARNESS_SIMULATOR_*`, `launch.sh` |
19
+ | Optional backend | One shared compose service | `HARNESS_INFRA_SERVICES` (e.g. `"mock-server"`) |
20
+ | Application code | Isolated git worktree per slot | `HARNESS_USE_WORKTREE=true` |
21
+
22
+ ### Do not
23
+
24
+ - Hardcode backend ports in RocketSim flows or unit tests — read from agent env
25
+ - Run raw `docker compose` for harness infrastructure — use `setup-infra.sh`
@@ -0,0 +1,22 @@
1
+ ## Quick start
2
+
3
+ **har CLI or MCP:**
4
+
5
+ ```bash
6
+ har env launch 1
7
+ har env verify 1
8
+ har env verify 1 --full
9
+ har env teardown 1
10
+ ```
11
+
12
+ In Cursor with HAR MCP configured: use `har_launch_environment`, `har_run_verification`, and `har_teardown_environment`.
13
+
14
+ **Shell shims** (same runtime — each `./.har/*.sh` forwards to `har env`, with a pinned `npx @osfactory/har` fallback):
15
+
16
+ ```bash
17
+ ./.har/setup-infra.sh # boots the iOS Simulator
18
+ ./.har/launch.sh 1
19
+ ./.har/verify.sh 1 # quick: build smoke (compile-only)
20
+ ./.har/verify.sh 1 --full # + unit tests, lint, rocketsim-flows (if installed)
21
+ ./.har/teardown.sh 1
22
+ ```
@@ -0,0 +1,45 @@
1
+ ## Simulators
2
+
3
+ Slots do not share a simulator. Each launch **creates**
4
+ `har-<project>-agent-<id>-<model>` — `har-storefront-agent-2-iPhone-17`, say — and
5
+ teardown deletes it, so two agents never collide on a destination, on an installed
6
+ bundle id, or on a UI session, and the simulators you use by hand are never touched.
7
+ Every launch also starts from a pristine device: no app installed, no leftover
8
+ store, nothing carried over from the previous session.
9
+
10
+ | Setting | Effect |
11
+ |---------|--------|
12
+ | `HARNESS_SIMULATOR_NAME` | The model to create — `iPhone 16`, `iPhone 17 Pro`, `iPad Air 11-inch (M2)`. Empty means the newest model of the family. See `xcrun simctl list devicetypes`. |
13
+ | `HARNESS_SIMULATOR_FAMILY` | `auto` (read from the name) \| `iPhone` \| `iPad`. An iPad is only created when this resolves to iPad. |
14
+ | `HARNESS_SIMULATOR_UDID` | Run every slot on one existing device instead. Slots then share it — for one-off debugging. |
15
+ | `HARNESS_SIMULATOR_SHARED` | `true` restores one shared simulator for all slots, booted by `setup-infra.sh`. |
16
+
17
+ The runtime is the newest installed iOS that supports the model — a model retired
18
+ from recent runtimes still resolves against an older one. When nothing matches,
19
+ launch fails and lists the models this machine can create.
20
+
21
+ If `HARNESS_SIMULATOR_NAME` is not a model but names an existing device, that
22
+ device is used as-is and never deleted — how a hand-renamed simulator is targeted.
23
+
24
+ ### Running from an agent sandbox
25
+
26
+ `xcrun simctl` reaches CoreSimulatorService over XPC. Coding agents that sandbox
27
+ their shell (Codex, Claude Code and others) usually deny that lookup, so `simctl`
28
+ fails while `xcodebuild` keeps working — every simulator command then dies with
29
+ `CoreSimulatorService connection became invalid`. Nothing is missing on the machine.
30
+
31
+ Launch and teardown say so when it happens. Either run `har env launch <id>` and
32
+ `har env teardown <id>` from a normal terminal and let the agent work in the
33
+ worktree, or grant the agent unsandboxed access to `xcrun simctl` — the escalation
34
+ must cover every subcommand the harness uses (`list`, `create`, `boot`,
35
+ `bootstatus`, `shutdown`, `delete`), not just `list`.
36
+
37
+ The same messages distinguish a second cause: if `xcrun simctl` is missing from
38
+ the selected developer directory — no Xcode, or `xcode-select` pointing at the
39
+ Command Line Tools — they say so and print the current selection instead of
40
+ blaming a sandbox.
41
+
42
+ The device lands in `.env.agent.<id>` as `HARNESS_SIMULATOR_UDID`,
43
+ `HARNESS_SIMULATOR_DEVICE_NAME` and `HARNESS_IOS_DESTINATION` — the model stays in
44
+ `HARNESS_SIMULATOR_NAME`, so the two never mean the same thing in one place; what a slot holds is tracked in `.har/simulators/`.
45
+ Use `./.har/agent-cli.sh <id> simulator` to see it.
@@ -0,0 +1,9 @@
1
+ ## User-flow validation
2
+
3
+ Add the RocketSim plugin to get reusable UI flow validation:
4
+
5
+ ```bash
6
+ har env add-plugin rocketsim
7
+ ```
8
+
9
+ This installs `.har/stages/rocketsim-flows.sh` and a `flows/` directory. Add flow scripts under `flows/` (see `.har/stages/ROCKETSIM.md`). Full verify automatically runs all flows.
@@ -0,0 +1,13 @@
1
+ ## Verification contract
2
+
3
+ Steps in `verify.sh` are **project-specific examples** — adapt them to your stack.
4
+ The table describes each tier's intent, not a fixed command list.
5
+
6
+ | Mode | Command | Typical steps |
7
+ |------|---------|---------------|
8
+ | Quick | `har env verify <id>` | build smoke (compile-only) |
9
+ | Full | `har env verify <id> --full` | + unit tests, lint, optional readiness smoke, **rocketsim-flows** when installed |
10
+
11
+ For apps that depend on local backends, auth, seeded state, or simulator flows,
12
+ distinguish build/test health from agent usability. Document any skipped full
13
+ dev setup and add a readiness command when agents need a real workflow to pass.
@@ -0,0 +1,27 @@
1
+ ## What's in here
2
+
3
+ **Yours — the configuration surface** (edit freely; drift tracking records adaptations):
4
+
5
+ | File | Purpose |
6
+ |------|---------|
7
+ | `README.md` | This file — index of the harness |
8
+ | `harness.env` | Schema-validated config: Xcode scheme, simulator name, bundle ID, toolchain provisioning, optional infra services |
9
+ | `stages.json` | Registered stages, verification tiers, artifacts, slot limits, gate policy |
10
+ | `stages/` | Project-owned stage scripts registered from `stages.json` |
11
+ | `hooks/` | Optional lifecycle hooks (`pre-launch.sh`, `post-launch.sh`, `pre-verify.sh`, `pre-teardown.sh`, `post-teardown.sh`) |
12
+ | `plugins/` | Optional local plugins (`har plugin create <id>`) |
13
+ | `docker-compose.agent.yml` | Optional shared backend services |
14
+ | `CLAUDE.agent.md` | Detailed instructions for coding agents |
15
+ | `STAGES.md` | Stage registry and script-contract guide |
16
+ | `justfile` | Optional shortcuts (requires `just`) |
17
+
18
+ **Generated shims and state** (don't edit — `har env eject` for full ownership):
19
+
20
+ | File | Purpose |
21
+ |------|---------|
22
+ | `launch.sh` / `verify.sh` / `teardown.sh` / `setup-infra.sh` / `preflight.sh` / `agent-cli.sh` | Thin shims forwarding to the packaged runtime (`har env …`); same run records on every surface |
23
+ | `manifest.json` | Runtime version, profile, checksums — managed by the har CLI |
24
+ | `runs/` | Run history from every entry point — `.har/runs/YYYY-MM-DD/HH-mm-ss_<stageId>_agent-<id>.json` (gitignored) |
25
+ | `artifacts/` | Stage outputs: test results, screenshots, logs |
26
+
27
+ No PM2 or web-port wiring in this profile — agents run xcodebuild commands directly in their worktree.
@@ -1,9 +1,65 @@
1
1
  {
2
2
  "id": "ios",
3
- "description": "iOS — shared kernel + Xcode/Simulator overlay",
3
+ "description": "iOS — shared kernel + Xcode/Simulator overlay (simulator runtime lives in the package)",
4
4
  "bundles": [
5
5
  { "id": "shared-kernel", "path": "runtime-bundles/shared-kernel" },
6
- { "id": "xcode-sim", "path": "runtime-bundles/xcode-sim" },
7
6
  { "id": "runtime-ios", "path": "har-boilerplate-ios" }
8
- ]
7
+ ],
8
+ "capabilities": {
9
+ "processManager": "simulator",
10
+ "appPortLanes": false,
11
+ "infra": {
12
+ "defaultServices": [],
13
+ "portLanes": ""
14
+ },
15
+ "defaultStages": [
16
+ "setup-infra",
17
+ "launch",
18
+ "verify",
19
+ "status",
20
+ "teardown",
21
+ "build",
22
+ "unit-tests",
23
+ "lint",
24
+ "readiness"
25
+ ],
26
+ "defaultEnvKeys": [
27
+ "HARNESS_PROJECT_NAME",
28
+ "HARNESS_USE_WORKTREE",
29
+ "HARNESS_AGENT_SLOT_MIN",
30
+ "HARNESS_AGENT_SLOT_MAX",
31
+ "HARNESS_ECOSYSTEM",
32
+ "HARNESS_XCODE_WORKSPACE",
33
+ "HARNESS_XCODE_PROJECT",
34
+ "HARNESS_XCODE_SCHEME",
35
+ "HARNESS_SIMULATOR_NAME",
36
+ "HARNESS_BUNDLE_ID",
37
+ "HARNESS_SIMULATOR_FAMILY",
38
+ "HARNESS_SIMULATOR_SHARED",
39
+ "HARNESS_IOS_DESTINATION",
40
+ "HARNESS_INFRA_SERVICES"
41
+ ]
42
+ },
43
+ "docs": {
44
+ "README.md": [
45
+ "intro",
46
+ "what-s-in-here",
47
+ "quick-start",
48
+ "user-flow-validation",
49
+ "verification-contract",
50
+ "configuration",
51
+ "simulators",
52
+ "port-shared-services-ios-profile",
53
+ "session-lifecycle"
54
+ ],
55
+ "CLAUDE.agent.md": [
56
+ "intro",
57
+ "environment",
58
+ "readiness",
59
+ "definition-of-done",
60
+ "project-commands",
61
+ "user-flow-validation-rocketsim",
62
+ "do-not"
63
+ ]
64
+ }
9
65
  }
@@ -1,22 +1,15 @@
1
1
  #!/usr/bin/env bash
2
2
  # Attach to the tmux session for an agent.
3
- #
3
+ # The runtime lives in the HAR package (#234) — this file only forwards to it.
4
4
  # Usage: ./.har/attach.sh <agent-id>
5
5
  set -euo pipefail
6
-
7
6
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- # shellcheck source=/dev/null
9
- source "$SCRIPT_DIR/harness.env"
10
- # shellcheck source=/dev/null
11
- source "$SCRIPT_DIR/agent-slot.sh"
12
-
7
+ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13
8
  AGENT_ID="${1:?Usage: attach.sh <agent-id>}"
14
- SESSION="$(har_tmux_session "$AGENT_ID")"
15
-
16
- if ! tmux has-session -t "$SESSION" 2>/dev/null; then
17
- echo "No tmux session found: $SESSION" >&2
18
- echo "Launch with: ./.har/launch.sh ${AGENT_ID} --claude" >&2
19
- exit 1
9
+ if command -v har >/dev/null 2>&1; then
10
+ exec har env agent "$AGENT_ID" attach
11
+ elif [ -x "$REPO_ROOT/node_modules/.bin/har" ]; then
12
+ exec "$REPO_ROOT/node_modules/.bin/har" env agent "$AGENT_ID" attach
20
13
  fi
21
-
22
- exec tmux attach -t "$SESSION"
14
+ echo "Error: the 'har' CLI is not available. Install @osfactory/har (npm i -D @osfactory/har) or run: npx @osfactory/har env agent" >&2
15
+ exit 127
@@ -32,7 +32,7 @@ S3_FORCE_PATH_STYLE=true
32
32
  # Headless browser (if enabled)
33
33
  HEADLESS_BROWSER_URL=http://localhost:${BROWSER_PORT}
34
34
 
35
- # Toolchain paths — appended by provision-toolchain.sh during launch
35
+ # Toolchain paths — appended by the packaged launch provisioning step
36
36
  # NODE_BIN= NPM_BIN= PYTHON_BIN= VIRTUAL_ENV= GO_BIN= CARGO_BIN= JAVA_HOME=
37
37
 
38
38
  # Mail (if enabled)
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ # API health check for the slot's primary application. Registered as the
3
+ # `api-health` verification stage (tier: quick) on web profiles.
4
+ set -euo pipefail
5
+
6
+ AGENT_ID="${1:?Usage: api-health.sh <agent-id>}"
7
+
8
+ PORT="${API_PORT:-$(( ${HARNESS_API_BASE_PORT:?HARNESS_API_BASE_PORT not set} + AGENT_ID * 10 ))}"
9
+ exec curl -sf "http://localhost:${PORT}${HARNESS_HEALTH_CHECK_PATH:-/health}"