create-harness-vibe-coding 0.8.13 → 0.8.17

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 (133) hide show
  1. package/CHANGELOG.md +174 -0
  2. package/README-CN.md +110 -107
  3. package/README.md +93 -44
  4. package/package.json +2 -1
  5. package/src/generator.js +609 -489
  6. package/src/index.js +5 -5
  7. package/templates/common/.claude/agents/architect-manager.md +1 -0
  8. package/templates/common/.claude/agents/architect.md +2 -1
  9. package/templates/common/.claude/agents/codebase-explorer.md +1 -0
  10. package/templates/common/.claude/agents/context-master.md +2 -1
  11. package/templates/common/.claude/agents/debugger.md +1 -0
  12. package/templates/common/.claude/agents/docs-researcher.md +2 -1
  13. package/templates/common/.claude/agents/explore-manager.md +1 -0
  14. package/templates/common/.claude/agents/implement-manager.md +1 -0
  15. package/templates/common/.claude/agents/implementer.md +1 -0
  16. package/templates/common/.claude/agents/memory-master.md +2 -1
  17. package/templates/common/.claude/agents/planner.md +3 -2
  18. package/templates/common/.claude/agents/reflector.md +1 -0
  19. package/templates/common/.claude/agents/researcher.md +1 -0
  20. package/templates/common/.claude/agents/review-manager.md +1 -0
  21. package/templates/common/.claude/agents/reviewer.md +2 -1
  22. package/templates/common/.claude/agents/task-scribe.md +1 -0
  23. package/templates/common/.claude/agents/tdd-guide.md +5 -4
  24. package/templates/common/.claude/agents/test-writer.md +6 -5
  25. package/templates/common/.claude/agents/verifier.md +1 -0
  26. package/templates/common/.claude/commands/wf-auto-spark.md +16 -0
  27. package/templates/common/.claude/commands/wf-auto.md +16 -0
  28. package/templates/{optional/skills/browser-e2e/.opencode → common/.claude}/commands/wf-browser.md +3 -2
  29. package/templates/common/.claude/commands/wf-help.md +9 -5
  30. package/templates/common/.claude/commands/wf-learn.md +16 -0
  31. package/templates/common/.claude/commands/wf-max.md +20 -0
  32. package/templates/common/.claude/commands/wf-readme.md +16 -0
  33. package/templates/common/.claude/commands/wf-remove.md +16 -0
  34. package/templates/common/.claude/commands/wf-review.md +16 -0
  35. package/templates/common/.claude/commands/wf-update.md +68 -10
  36. package/templates/common/.claude/commands/wf.md +16 -0
  37. package/templates/common/.claude/rules/ecc/common.md +6 -5
  38. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +12 -6
  39. package/templates/common/.claude/skills/tdd/SKILL.md +5 -5
  40. package/templates/common/.claude/skills/wf/SKILL.md +13 -5
  41. package/templates/common/.claude/skills/wf-agents-docs/SKILL.md +119 -0
  42. package/templates/common/.claude/skills/wf-auto/SKILL.md +27 -7
  43. package/templates/common/.claude/skills/wf-auto-spark/SKILL.md +12 -5
  44. package/templates/common/.claude/skills/wf-browser/SKILL.md +176 -0
  45. package/templates/common/.claude/skills/wf-help/SKILL.md +30 -0
  46. package/templates/common/.claude/skills/wf-learn/SKILL.md +6 -0
  47. package/templates/common/.claude/skills/wf-max/SKILL.md +43 -14
  48. package/templates/common/.claude/skills/wf-readme/SKILL.md +8 -2
  49. package/templates/common/.claude/skills/wf-remove/SKILL.md +6 -0
  50. package/templates/common/.claude/skills/wf-review/SKILL.md +10 -3
  51. package/templates/common/.claude/skills/wf-update/SKILL.md +41 -4
  52. package/templates/common/.codex/config.toml +3 -5
  53. package/templates/common/.harness-version +326 -131
  54. package/templates/common/.opencode/agents/architect-manager.md +8 -1
  55. package/templates/common/.opencode/agents/architect.md +2 -1
  56. package/templates/common/.opencode/agents/codebase-explorer.md +1 -0
  57. package/templates/common/.opencode/agents/context-master.md +2 -1
  58. package/templates/common/.opencode/agents/debugger.md +1 -0
  59. package/templates/common/.opencode/agents/docs-researcher.md +2 -1
  60. package/templates/common/.opencode/agents/explore-manager.md +11 -1
  61. package/templates/common/.opencode/agents/implement-manager.md +6 -3
  62. package/templates/common/.opencode/agents/implementer.md +1 -0
  63. package/templates/common/.opencode/agents/memory-master.md +2 -1
  64. package/templates/common/.opencode/agents/planner.md +3 -2
  65. package/templates/common/.opencode/agents/reflector.md +1 -0
  66. package/templates/common/.opencode/agents/researcher.md +1 -0
  67. package/templates/common/.opencode/agents/review-manager.md +6 -2
  68. package/templates/common/.opencode/agents/reviewer.md +2 -1
  69. package/templates/common/.opencode/agents/task-scribe.md +1 -0
  70. package/templates/common/.opencode/agents/tdd-guide.md +5 -4
  71. package/templates/common/.opencode/agents/test-writer.md +6 -5
  72. package/templates/common/.opencode/agents/verifier.md +1 -0
  73. package/templates/common/.opencode/commands/wf-auto-spark.md +3 -2
  74. package/templates/common/.opencode/commands/wf-auto.md +3 -2
  75. package/templates/common/.opencode/commands/wf-browser.md +16 -0
  76. package/templates/common/.opencode/commands/wf-help.md +9 -5
  77. package/templates/common/.opencode/commands/wf-learn.md +3 -2
  78. package/templates/common/.opencode/commands/wf-max.md +12 -6
  79. package/templates/common/.opencode/commands/wf-readme.md +3 -2
  80. package/templates/common/.opencode/commands/wf-remove.md +3 -2
  81. package/templates/common/.opencode/commands/wf-review.md +3 -2
  82. package/templates/common/.opencode/commands/wf-update.md +68 -10
  83. package/templates/common/.opencode/commands/wf.md +3 -2
  84. package/templates/common/CLAUDE.md +15 -13
  85. package/templates/common/Harness/MEMORY.md +24 -21
  86. package/templates/common/Harness/README.md +50 -47
  87. package/templates/common/Harness/ownership.manifest.json +878 -0
  88. package/templates/common/Harness/{architecture.md → project/architecture.md} +1 -1
  89. package/templates/common/Harness/research/README.md +3 -3
  90. package/templates/common/Harness/scripts/archive-tasks.mjs +12 -220
  91. package/templates/common/Harness/scripts/context-budget.mjs +95 -0
  92. package/templates/common/Harness/scripts/l2-cache-telemetry.mjs +703 -0
  93. package/templates/common/Harness/scripts/scan-clean.mjs +16 -12
  94. package/templates/common/Harness/scripts/task-state.mjs +889 -0
  95. package/templates/common/Harness/scripts/validate-harness.mjs +553 -191
  96. package/templates/common/Harness/scripts/wf-remove.mjs +61 -35
  97. package/templates/common/Harness/scripts/wf-update-check.mjs +358 -45
  98. package/templates/common/Harness/settings.json +43 -0
  99. package/templates/common/Harness/{ECC-GUIDE.md → specs/guides/ECC-GUIDE.md} +4 -4
  100. package/templates/common/Harness/{SETUP.md → specs/guides/SETUP.md} +34 -37
  101. package/templates/common/Harness/{extension.md → specs/guides/extension.md} +3 -3
  102. package/templates/common/Harness/{lifecycle.md → specs/guides/lifecycle.md} +2 -2
  103. package/templates/common/Harness/specs/protocols/TASK_ARCHIVE.md +76 -0
  104. package/templates/common/Harness/{agent-workflow.md → specs/runtime/agent-workflow.md} +6 -6
  105. package/templates/common/Harness/{context-loading.md → specs/runtime/context-loading.md} +85 -21
  106. package/templates/common/Harness/{dispatch.md → specs/runtime/dispatch.md} +4 -3
  107. package/templates/common/Harness/{subagents.md → specs/runtime/subagents.md} +19 -10
  108. package/templates/common/Harness/{WF-AUTO-SPARK.md → specs/workflows/WF-AUTO-SPARK.md} +2 -2
  109. package/templates/common/Harness/{WF-AUTO.md → specs/workflows/WF-AUTO.md} +12 -7
  110. package/templates/common/Harness/{WF-KERNEL.md → specs/workflows/WF-KERNEL.md} +11 -1
  111. package/templates/common/Harness/{WF-MAX.md → specs/workflows/WF-MAX.md} +40 -7
  112. package/templates/common/Harness/specs/workflows/WF-STATE.md +141 -0
  113. package/templates/common/Harness/{WF.md → specs/workflows/WF.md} +12 -1
  114. package/templates/common/README.md +8 -6
  115. package/templates/common/memory/startup-hints.md +19 -17
  116. package/templates/common/opencode.json +1 -0
  117. package/templates/optional/catalog.json +2 -9
  118. package/templates/optional/skills/github-pr-review/.claude/skills/github-pr-review/SKILL.md +1 -1
  119. package/templates/optional/skills/python-backend/.claude/skills/python-backend/SKILL.md +1 -1
  120. package/templates/optional/skills/ts-react-frontend/.claude/skills/ts-react-frontend/SKILL.md +1 -1
  121. package/templates/optional/skills/ui-ux-review/.claude/skills/ui-ux-review/SKILL.md +1 -1
  122. package/templates/common/Harness/TASK_ARCHIVE.md +0 -56
  123. package/templates/common/Harness/WF-STATE.md +0 -83
  124. package/templates/optional/skills/browser-e2e/.claude/skills/browser-e2e/SKILL.md +0 -42
  125. package/templates/optional/skills/browser-e2e/.claude/skills/wf-browser/SKILL.md +0 -194
  126. package/templates/optional/skills/browser-e2e/Harness/workflows/browser-e2e.md +0 -119
  127. /package/templates/common/Harness/{ACCEPTANCE_PROTOCOL.md → specs/protocols/ACCEPTANCE_PROTOCOL.md} +0 -0
  128. /package/templates/common/Harness/{AGENT_ISOLATION.md → specs/protocols/AGENT_ISOLATION.md} +0 -0
  129. /package/templates/common/Harness/{DEBUG_PROTOCOL.md → specs/protocols/DEBUG_PROTOCOL.md} +0 -0
  130. /package/templates/common/Harness/{HARNESS_BRIDGE.md → specs/protocols/HARNESS_BRIDGE.md} +0 -0
  131. /package/templates/common/Harness/{MEMORY_PROTOCOL.md → specs/protocols/MEMORY_PROTOCOL.md} +0 -0
  132. /package/templates/common/Harness/{TDD-GUIDE.md → specs/protocols/TDD-GUIDE.md} +0 -0
  133. /package/templates/common/Harness/{WF-AUTO-ANGLES.md → specs/workflows/WF-AUTO-ANGLES.md} +0 -0
@@ -1,56 +0,0 @@
1
- # TASK_ARCHIVE — Task Archive Mechanism
2
-
3
- Purpose: keep `Harness/tasks/` lean by archiving completed/abandoned tasks while preserving all evidence.
4
-
5
- ## Archive Location
6
-
7
- Active tasks stay in `Harness/tasks/<task-id>/`.
8
- Archived tasks move to `Harness/tasks/_archive/YYYY/<task-id>/`.
9
-
10
- ## What Is Never Archived
11
-
12
- - `Harness/tasks/_template/` — scaffold template, never moved.
13
- - `Harness/tasks/auto/` — WF-AUTO permanent state capsule, never moved unless explicitly allowed by WF-AUTO docs.
14
- - `Harness/tasks/_archive/` — the archive directory itself.
15
- - Active, blocked, in-progress, or needs-user-decision tasks.
16
- - Tasks whose STATE.json status is `active`, `blocked`, `in_progress`, `running`, `pending`, or `needs-user-decision`.
17
-
18
- ## What May Be Archived
19
-
20
- Tasks whose STATE.json or PROGRESS.md status is: `complete`, `verified`, `archived`, `abandoned`, `obsolete`, `done`, `closed`, or `closeout`.
21
-
22
- The script reads STATE.json `status`/`phase` first, then falls back to the first `- Phase:`, `Phase:`, or `Current:` marker in the task's PROGRESS.md (first word wins). Ambiguous phases are never auto-archived.
23
-
24
- ## Archive Process
25
-
26
- 1. Verify the task is not active/blocked.
27
- 2. Ensure `Harness/tasks/_archive/YYYY/` exists.
28
- 3. Move `Harness/tasks/<task-id>/` → `Harness/tasks/_archive/YYYY/<task-id>/`.
29
- 4. Update the moved STATE.json: `status` → `archived`, `phase` → `archived`.
30
- 5. Update `Harness/tasks/_archive/INDEX.md`.
31
- 6. Update `Harness/PROGRESS.md` Task Index — remove or annotate `(archived)`.
32
-
33
- ## Retention
34
-
35
- - Archived tasks retain: PLAN, PROGRESS, STATE, ARTIFACTS, NOTES.
36
- - Do NOT delete historical evidence.
37
- - `Harness/PROGRESS.md` keeps the last 5 non-archived task entries in the Task Index.
38
- - When outer task capsules exceed 5 completed/abandoned/obsolete, archive the oldest.
39
- - The validator (`Harness/scripts/validate-harness.mjs`) warns when `Harness/tasks/` holds more than 5 outer task capsules (excluding `_archive`, `_template`, `auto`) and fails in `--strict` mode.
40
-
41
- ## Script
42
-
43
- Use `Harness/scripts/archive-tasks.mjs`:
44
- - Default: dry-run
45
- - `--apply` to execute
46
- - `--keep 5` to set the non-archived task threshold
47
- - `--task <task-id>` to archive a specific task
48
- - `--json` for machine-readable output
49
- - `node Harness/scripts/archive-tasks.mjs --dry-run --json` must always run
50
-
51
- ## Safety Rules
52
-
53
- - Windows path safe. Use `path.resolve()` before moving.
54
- - Confirm target is within `Harness/tasks/` before any move.
55
- - Do NOT recursively delete.
56
- - Tasks with `needs-user-decision` status are never auto-archived.
@@ -1,83 +0,0 @@
1
- # WF-STATE — Lightweight Resumable State Machine
2
-
3
- Purpose: persist resumable workflow state across compaction, new Claude Code windows, new terminals, and project reopen. It is NOT a scheduler, daemon, lock manager, async runtime, or graph framework.
4
-
5
- ## State Files
6
-
7
- | File | Role |
8
- |------|------|
9
- | `Harness/PROGRESS.md` | Global active pointer — which task is current |
10
- | `Harness/tasks/<task-id>/STATE.json` | Machine-readable resume truth |
11
- | `Harness/tasks/<task-id>/PROGRESS.md` | Human-readable summary |
12
- | `Harness/tasks/<task-id>/PLAN.md` | Plan, decisions, scope context |
13
-
14
- ## Enums
15
-
16
- ### phase
17
- `intake`, `clarify`, `requirements`, `prd`, `acceptance`, `plan`, `explore`, `implement`, `verify`, `review`, `fix`, `reflect`, `closeout`, `blocked`, `archived`
18
-
19
- ### item status (queues)
20
- `pending`, `ready`, `running`, `done`, `blocked`, `skipped`, `failed`
21
-
22
- ### mode
23
- `direct`, `wf`, `wf-max`, `wf-auto`, `wf-auto-spark`, `wf-review`, `wf-browser`
24
-
25
- ### tier
26
- `none`, `light`, `standard`, `full`, `max-useful`, `max-strict`
27
-
28
- ## Rules
29
-
30
- 1. **STATE.json is machine-readable resume truth.** On session start, the agent reads it to know where it left off.
31
- 2. **PROGRESS.md is human-readable summary.** It mirrors key state but is secondary for machine reasoning.
32
- 3. **PLAN.md is plan/decision context.** Load only when decisions or scope need review.
33
- 4. **On every phase transition, dispatch return, blocker, verification result, review finding, or closeout, update STATE.json.** task-scribe or controller writes; production agents never write task state.
34
- 5. **Long logs/transcripts never go into STATE.json.** Store paths only.
35
- 6. **task-scribe may update STATE.json and task summaries; production agents may not.**
36
- 7. **If STATE.json conflicts with PLAN/PROGRESS, controller stops and reconciles before continuing.**
37
-
38
- ## Resume Protocol
39
-
40
- New window / session start:
41
- 1. Read `CLAUDE.md`.
42
- 2. If user says "continue", "resume", "last task", "current task", "status", or the work is not a simple direct task:
43
- - Read `Harness/PROGRESS.md` → find Active Task
44
- - If Active Task exists, read `Harness/tasks/<active-task>/STATE.json`
45
- - Read `Harness/tasks/<active-task>/PROGRESS.md`
46
- - Read `Harness/tasks/<active-task>/PLAN.md` only if decisions/scope need review
47
- 3. From STATE.json, determine:
48
- - Current phase, gate, tier
49
- - activeQuestion (needs user answer before proceeding)
50
- - Queues: ready (can dispatch immediately), running (awaiting results), blocked (needs resolution), done
51
- - nextAction (what to do next)
52
- 4. Do NOT bulk-read `Harness/tasks/` to find context. Use the active pointer.
53
- 5. Direct simple tasks may skip STATE/PLAN/PROGRESS unless the user says "continue"/"resume".
54
-
55
- ## State Transitions
56
-
57
- ```
58
- intake → clarify → requirements → prd → acceptance → plan
59
- → explore → implement → verify → review
60
- → (fix → verify → review loop)
61
- → reflect → closeout
62
- ```
63
-
64
- Any phase may transition to `blocked` if a dependency, user decision, or external input is required.
65
-
66
- ## Dispatch Ledger
67
-
68
- Every dispatch packet MUST have an `id`. On return, controller or task-scribe updates the ledger item:
69
- - `id`, `agent`, `role`, `phase`, `status` (pending/ready/running/done/blocked/skipped/failed), `evidence`
70
-
71
- See [WF-KERNEL.md](WF-KERNEL.md) for the dispatch packet format.
72
-
73
- ## Integration with /wf and /wf-max
74
-
75
- - `/wf` uses the STATE ready queue for dynamic orchestration.
76
- - `/wf-max` uses the SAME STATE ready queue for maximum safe fan-out.
77
- - When a subagent returns or goes idle, controller immediately dispatches the next ready item.
78
- - task-scribe is the exception for task-state writes.
79
- - Production source agents do not write STATE/PLAN/PROGRESS unless explicitly dispatched as task-scribe.
80
-
81
- ## Template
82
-
83
- See `Harness/tasks/_template/STATE.json` for the canonical template. On task creation, copy and populate from the template.
@@ -1,42 +0,0 @@
1
- ---
2
- name: browser-e2e
3
- description: Mandatory real-browser smoke and end-to-end verification using Playwright, Chrome DevTools/CDP, or documented manual browser evidence.
4
- ---
5
-
6
- # Browser E2E
7
-
8
- ## When To Use
9
-
10
- Use this skill when a change affects browser-visible behavior, navigation, forms, routing, layout, or client-side integration. Web/UI acceptance requires loading the app in a real browser before claiming the UI is done.
11
-
12
- ## Docs To Load
13
-
14
- - `Harness/workflows/browser-e2e.md`
15
- - `Harness/PROGRESS.md` and current task `tasks/<id>/PLAN.md`
16
- - Existing project test, build, and run instructions.
17
-
18
- ## Required Inputs
19
-
20
- - Target URL or command to start the app.
21
- - User flows or pages to verify.
22
- - Expected behavior and supported viewport/browser scope.
23
- - Selector contract: stable accessible labels/roles and `data-testid` hooks for critical inputs, buttons, filters, rows, empty/error/loading states, and other targetable UI states.
24
-
25
- ## Allowed Writes
26
-
27
- - Browser test files in the project's existing test locations.
28
- - Evidence artifacts such as screenshots, traces, or reports in existing artifact folders.
29
- - Notes in current task plan when the active task asks for plan tracking.
30
-
31
- ## Output Format
32
-
33
- Return changed files, commands run, browser evidence paths, verified flows, failures, and follow-up risks.
34
- Include the selectors used for CDP/Playwright/manual verification.
35
-
36
- ## PROGRESS.md & Task PLAN.md Updates
37
-
38
- Update `Harness/tasks/<task-id>/PLAN.md` only when executing a tracked plan item or recording evidence requested by the current task.
39
-
40
- ## dispatch.md Usage
41
-
42
- Use `Harness/dispatch.md` only when splitting independent browser checks across workers is explicitly useful.
@@ -1,194 +0,0 @@
1
- ---
2
- name: wf-browser
3
- description: AI-driven browser automation for E2E testing, web scraping, form filling, and UI verification. Powered by Browser Use (89.1% WebVoyager benchmark). Use for Claude /wf-browser, Codex $wf-browser, browser testing, web automation, page interaction, form filling, screenshot verification, or any task requiring real browser control. Dual mode: CLI (fast iteration, no LLM needed) + Python Agent API (complex multi-step workflows with AI reasoning).
4
- ---
5
-
6
- # WF Browser — AI Browser Automation
7
-
8
- Load:
9
-
10
- - `Harness/workflows/browser-e2e.md`
11
- - Official `browser-use` skill at `~/.claude/skills/browser-use/SKILL.md` (auto-installed if missing)
12
- - `Harness/PROGRESS.md` when work is active
13
-
14
- ## Modes
15
-
16
- Choose based on task complexity:
17
-
18
- ### Mode 1: CLI (fast iteration, ~50ms per call)
19
-
20
- Best for: single-page checks, quick screenshots, form fills, element inspection. No LLM needed — Claude Code reasons and issues CLI commands.
21
-
22
- ```bash
23
- browser-use --headed open https://example.com # Open page (headed = visible browser)
24
- browser-use state # Get page title, text, interactive elements with indices
25
- browser-use screenshot evidence.png # Capture screenshot as evidence
26
- browser-use click 5 # Click element by index from state output
27
- browser-use input 3 "user@example.com" # Fill input field by index
28
- browser-use eval "document.title" # Run JavaScript in page
29
- browser-use close # Close browser when done
30
- ```
31
-
32
- Daemon keeps the browser open between commands — no cold-start per action.
33
-
34
- ### Mode 2: Python Agent API (multi-step AI reasoning)
35
-
36
- Best for: complex multi-page workflows, dynamic navigation, data extraction across pages. Needs LLM API key.
37
-
38
- ```python
39
- from browser_use.beta import Agent, BrowserProfile
40
- from browser_use.llm import ChatAnthropic
41
-
42
- agent = Agent(
43
- task="Go to github.com, search for 'browser-use', click the first result, and report the star count",
44
- llm=ChatAnthropic(model="claude-haiku-4-5-20251001"),
45
- browser_profile=BrowserProfile(headless=False),
46
- )
47
- history = await agent.run()
48
- print(history.final_result())
49
- ```
50
-
51
- ## Environment Setup
52
-
53
- Run once per machine:
54
-
55
- ```bash
56
- # 1. Install browser-use with CLI extras
57
- pip install "browser-use[cli]"
58
-
59
- # 2. Install Chromium browser
60
- browser-use install
61
-
62
- # 3. Verify installation
63
- browser-use doctor
64
-
65
- # 4. (Optional) Set LLM API key for Agent mode
66
- # Create .env file with: ANTHROPIC_API_KEY=sk-ant-...
67
- # Or: OPENAI_API_KEY=sk-...
68
- # Or: BROWSER_USE_API_KEY=bu-...
69
- ```
70
-
71
- ### Windows GBK Encoding Fix
72
-
73
- If you see `UnicodeEncodeError: 'gbk' codec can't encode character`, the install is auto-patched. If not, set env var before commands:
74
-
75
- ```bash
76
- set PYTHONIOENCODING=utf-8
77
- ```
78
-
79
- ### Windows Daemon Patches
80
-
81
- Browser Use v0.13.1 has two known issues on Windows that are auto-patched on install. If `browser-use open` fails with "Failed to start daemon" or socket timeout, re-apply:
82
-
83
- ```bash
84
- python -c "
85
- import browser_use.skill_cli.main as m
86
- p = m.__file__
87
- c = open(p, encoding='utf-8').read()
88
- # Patch 1: auto-clean stale state on dead PID
89
- c = c.replace(
90
- 'probe = _probe_session(session)\n\n\t# Socket reachable',
91
- 'probe = _probe_session(session)\n\n\t# Auto-clean stale state\n\tif not probe.socket_reachable and not probe.pid_alive and probe.phase:\n\t\t_clean_session_files(session)\n\t\tprobe = _probe_session(session)\n\n\t# Socket reachable'
92
- )
93
- # Patch 2: auto-recover from stale session instead of erroring
94
- c = c.replace(
95
- \"f'Error: Session {session!r} is alive (phase={probe.phase}) but socket unreachable.\",\"
96
- \"f'Warning: Session {session!r} has stale state (phase={probe.phase}), auto-cleaning...\",\"
97
- )
98
- c = c.replace(
99
- \"sys.exit(1)\n\n\t\telif probe.phase == 'shutting_down'\",
100
- \"_terminate_pid(probe.pid)\n\t\t\t_clean_session_files(session)\n\n\t\telif probe.phase == 'shutting_down'\"
101
- )
102
- # Patch 3: extend daemon startup timeout (15s -> 30s)
103
- c = c.replace('deadline = time.time() + 15', 'deadline = time.time() + 30')
104
- open(p, 'w', encoding='utf-8').write(c)
105
- print('Patches applied')
106
- "
107
- ```
108
-
109
- ### Requirements
110
-
111
- | Requirement | Version | Check |
112
- |-------------|---------|-------|
113
- | Python | >= 3.11 | `python --version` |
114
- | pip | any | `pip --version` |
115
- | Chromium | auto-installed | `browser-use doctor` |
116
- | LLM API key | for Agent mode only | check `.env` |
117
-
118
- ## Common Patterns
119
-
120
- ### Login Persistence
121
-
122
- ```bash
123
- # Use real Chrome profile (preserves cookies/logins)
124
- browser-use --profile "Default" open https://app.target.com
125
- # Or connect to running Chrome with remote debugging
126
- browser-use connect
127
- ```
128
-
129
- ### E2E Test Flow
130
-
131
- ```bash
132
- browser-use --headed open https://yourapp.local
133
- browser-use state # Verify page loaded
134
- browser-use screenshot step1-landing.png # Evidence
135
- browser-use input 3 "test@email.com" # Fill email
136
- browser-use input 5 "password123" # Fill password
137
- browser-use click 8 # Click login button
138
- browser-use wait text "Dashboard" # Wait for navigation text
139
- browser-use state # Verify logged in
140
- browser-use screenshot step2-dashboard.png # Evidence
141
- browser-use close
142
- ```
143
-
144
- ### Console & Network Log Capture
145
-
146
- ```bash
147
- browser-use eval "console.log('checkpoint');" # Inject log marker
148
- browser-use eval "document.title" # Read page state via JS
149
- browser-use get text 5 # Get text of element index 5
150
- browser-use get value 3 # Get value of input element index 3
151
- # For full console/network: use Python Agent mode with Playwright's page.on('console') and page.on('request')
152
- ```
153
-
154
- ### Error Recovery
155
-
156
- ```bash
157
- # If daemon crashes or gets stuck:
158
- browser-use close # Clean shutdown
159
- # Then restart:
160
- browser-use open <url> # Fresh daemon starts automatically
161
- ```
162
-
163
- ## Verification Contract
164
-
165
- Every browser task must produce:
166
-
167
- 1. **State evidence**: `browser-use state` output or screenshot
168
- 2. **Action log**: sequence of commands issued
169
- 3. **Result assertion**: explicit before/after state comparison
170
-
171
- No browser/UI claim without real-browser evidence.
172
-
173
- ## Architecture Note
174
-
175
- Browser Use wraps Playwright with AI reasoning. The daemon keeps Chromium running between CLI commands (~50ms latency). The Agent mode adds an LLM observation→decision→action loop on top. This replaces fragile CSS-selector scripts with semantic element targeting via accessibility tree snapshots.
176
-
177
- Benchmarks: 89.1% WebVoyager (SOTA), 78k+ GitHub stars, MIT license.
178
-
179
- ## Security
180
-
181
- - **Never log or screenshot credentials** — redact password fields, API keys, tokens before capturing evidence
182
- - **Chrome profiles contain sensitive data** — only use `--profile` with explicit user approval; never share profile data
183
- - **Screenshots may capture PII** — review before saving to task evidence directory
184
- - **Scraping targets need approval** — confirm the target site's ToS allow automated access before scraping
185
- - **`browser-use input` commands with passwords** — use placeholder values in documentation; never hardcode real credentials
186
- - **Agent mode sandbox** — run Agent API with `allowed_domains` restriction when possible
187
-
188
- ## Return
189
-
190
- - CLI commands issued and their output
191
- - screenshot paths
192
- - agent history (if Agent mode used)
193
- - verification pass/fail with evidence
194
- - remaining risks (flaky selectors, auth issues, CAPTCHAs)
@@ -1,119 +0,0 @@
1
- # Browser E2E Workflow
2
-
3
- Optional workflow for browser-visible testing and automation. Installed when `browser-use` CLI is available.
4
-
5
- ## When Active
6
-
7
- This workflow is active when:
8
- 1. `browser-use` CLI is installed and `browser-use doctor` passes
9
- 2. `Harness/workflows/browser-e2e.md` exists (this file)
10
- 3. A task explicitly references `/wf-browser`, `$wf-browser`, or browser E2E testing
11
-
12
- ## Contract
13
-
14
- Browser evidence in this project follows the contract:
15
-
16
- 1. **Every browser claim needs real-browser evidence** - screenshot, state snapshot, or console output
17
- 2. **CLI mode is preferred for deterministic steps** - use `browser-use open/state/click/screenshot` for predictable flows
18
- 3. **Agent mode is for dynamic exploration** - use Browser Use Agent API when the page structure is unknown or changing
19
- 4. **Evidence goes to the task directory** - `Harness/tasks/<task-id>/evidence/*.png`
20
-
21
- ### Harness Bridge
22
-
23
- For frontend-backend flows, use `Harness/HARNESS_BRIDGE.md` to validate UI
24
- selectors, API payloads, seeded data, runtime state probes, and CDP/network
25
- traces. Browser validation must produce an AC-by-AC result matrix when the task
26
- has acceptance criteria.
27
-
28
- ### Stable UI Selector Contract
29
-
30
- All browser automation and E2E tests in this project use a stable selector contract. Selectors must be written against **public, stable attributes** that survive refactors, not against ephemeral class names or DOM indices.
31
-
32
- **Required selector priority (most stable first):**
33
-
34
- 1. **`data-testid`** - the primary stable anchor for automated tests
35
- 2. **accessible labels/roles** - `getByRole`, `getByLabelText`, `getByPlaceholderText` (ARIA roles, `<label>` associations, placeholder text)
36
- 3. **Text content** - `getByText` for visible user-facing strings
37
-
38
- **Required coverage targets.** Every interactive page tested by browser automation must cover: inputs, buttons, filters, rows, empty/error/loading states.
39
-
40
- | Category | Examples |
41
- |---|---|
42
- | **Inputs** | text fields, textareas, selects, checkboxes, radios, file uploads |
43
- | **Buttons** | submit buttons, icon-only buttons, toggle buttons, CTA buttons |
44
- | **Filters** | search inputs, dropdown filters, date range pickers, filter chips/tags |
45
- | **Rows** | table rows, list items, card containers - the repeating data unit |
46
- | **Empty state** | "no results" message, empty illustration, zero-state CTA |
47
- | **Error state** | inline validation errors, toast notifications, server error banners |
48
- | **Loading state** | spinners, skeletons, progress bars, "Loading..." text |
49
-
50
- **Selector format examples:**
51
-
52
- ```
53
- data-testid="search-input"
54
- data-testid="submit-btn"
55
- data-testid="filter-status"
56
- data-testid="result-row"
57
- data-testid="empty-state"
58
- data-testid="error-banner"
59
- data-testid="loading-spinner"
60
- ```
61
-
62
- **Rationale:** `data-testid` attributes are decoupled from styling and layout - they survive CSS refactors, component renames, and DOM restructuring. Accessible labels and roles are the fallback when `data-testid` is not available, and they double as a11y coverage. Class-name and XPath selectors are not accepted in test automation because they break on cosmetic changes.
63
-
64
- ## Chrome DevTools / CDP / MCP Checklist
65
-
66
- - [ ] record the URL and port
67
- - [ ] Verify available CDP, MCP, browser automation, or manual tooling
68
- - [ ] Check not just HTTP 200
69
- - [ ] Verify no runtime exceptions, console errors, and failed network requests
70
- - [ ] Confirm stable accessible labels/roles or `data-testid` on interactive elements
71
- - [ ] Test critical flow end-to-end
72
- - [ ] Capture screenshot, trace, video, or result artifact paths
73
- - [ ] Produce an AC-by-AC validation matrix
74
- - [ ] Clean up any dev server or browser processes
75
-
76
- ## Quick Install
77
-
78
- ```bash
79
- # One-time setup
80
- pip install "browser-use[cli]"
81
- browser-use install
82
- browser-use doctor
83
-
84
- # Windows: if you see GBK encoding errors, set:
85
- set PYTHONIOENCODING=utf-8
86
-
87
- # Verify
88
- browser-use open https://example.com
89
- browser-use state
90
- browser-use screenshot test.png
91
- browser-use close
92
- ```
93
-
94
- ## Fallback
95
-
96
- If `browser-use` is not installed, fall back to:
97
-
98
- 1. Playwright/Puppeteer MCP server (if configured)
99
- 2. Chrome DevTools Protocol (CDP) manual inspection
100
- 3. `Harness/WF.md#Browser And API Evidence` manual check contract
101
-
102
- ## Integration Points
103
-
104
- - **WF mode**: when browser-visible changes are made, follow the evidence contract in `Harness/WF.md#Browser And API Evidence`
105
- - **Harness Bridge**: use `Harness/HARNESS_BRIDGE.md` for UI contract, API contract, seeded test data, runtime state probes, and network trace collection.
106
- - **wf-browser**: Claude Code uses `.claude/skills/wf-browser/SKILL.md`; Codex uses `.agents/skills/wf-browser/SKILL.md`. Both load this workflow.
107
- - **MEMORY.md**: registered as optional workflow skill
108
- - **README.md**: routing table row "Browser E2E testing or automation" -> browser-e2e
109
-
110
- ## File Locations
111
-
112
- | File | Purpose |
113
- |------|---------|
114
- | `.claude/skills/wf-browser/SKILL.md` | Claude Code skill adapter |
115
- | `.agents/skills/wf-browser/SKILL.md` | Codex repo skill adapter |
116
- | `Harness/workflows/browser-e2e.md` | This file - workflow contract and install guide |
117
- | `~/.claude/skills/browser-use/SKILL.md` | Official Browser Use skill (user-level, auto-downloaded) |
118
- | `pip show browser-use \| findstr Location` | Python package install location (run to find) |
119
- | `~/.browser-use/` | Daemon state and browser profiles |