@monkeytestai/monkeytester 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/LICENSE +661 -0
  3. package/NOTICE +12 -0
  4. package/README.md +196 -2
  5. package/dist/cli.d.ts +43 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +771 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/diff/index.d.ts +78 -0
  10. package/dist/diff/index.d.ts.map +1 -0
  11. package/dist/diff/index.js +119 -0
  12. package/dist/diff/index.js.map +1 -0
  13. package/dist/events.d.ts +66 -0
  14. package/dist/events.d.ts.map +1 -0
  15. package/dist/events.js +77 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/explorer/index.d.ts +54 -0
  18. package/dist/explorer/index.d.ts.map +1 -0
  19. package/dist/explorer/index.js +491 -0
  20. package/dist/explorer/index.js.map +1 -0
  21. package/dist/explorer/queue.d.ts +94 -0
  22. package/dist/explorer/queue.d.ts.map +1 -0
  23. package/dist/explorer/queue.js +277 -0
  24. package/dist/explorer/queue.js.map +1 -0
  25. package/dist/index.d.ts +36 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +22 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/llm/index.d.ts +79 -0
  30. package/dist/llm/index.d.ts.map +1 -0
  31. package/dist/llm/index.js +392 -0
  32. package/dist/llm/index.js.map +1 -0
  33. package/dist/llm/presets.d.ts +61 -0
  34. package/dist/llm/presets.d.ts.map +1 -0
  35. package/dist/llm/presets.js +101 -0
  36. package/dist/llm/presets.js.map +1 -0
  37. package/dist/monkey.d.ts +151 -0
  38. package/dist/monkey.d.ts.map +1 -0
  39. package/dist/monkey.js +323 -0
  40. package/dist/monkey.js.map +1 -0
  41. package/dist/persistence/index.d.ts +118 -0
  42. package/dist/persistence/index.d.ts.map +1 -0
  43. package/dist/persistence/index.js +196 -0
  44. package/dist/persistence/index.js.map +1 -0
  45. package/dist/planner/faults.d.ts +24 -0
  46. package/dist/planner/faults.d.ts.map +1 -0
  47. package/dist/planner/faults.js +128 -0
  48. package/dist/planner/faults.js.map +1 -0
  49. package/dist/planner/forms.d.ts +33 -0
  50. package/dist/planner/forms.d.ts.map +1 -0
  51. package/dist/planner/forms.js +163 -0
  52. package/dist/planner/forms.js.map +1 -0
  53. package/dist/planner/index.d.ts +31 -0
  54. package/dist/planner/index.d.ts.map +1 -0
  55. package/dist/planner/index.js +250 -0
  56. package/dist/planner/index.js.map +1 -0
  57. package/dist/planner/salvage.d.ts +16 -0
  58. package/dist/planner/salvage.d.ts.map +1 -0
  59. package/dist/planner/salvage.js +89 -0
  60. package/dist/planner/salvage.js.map +1 -0
  61. package/dist/runner/actions.d.ts +85 -0
  62. package/dist/runner/actions.d.ts.map +1 -0
  63. package/dist/runner/actions.js +610 -0
  64. package/dist/runner/actions.js.map +1 -0
  65. package/dist/runner/evidence.d.ts +37 -0
  66. package/dist/runner/evidence.d.ts.map +1 -0
  67. package/dist/runner/evidence.js +122 -0
  68. package/dist/runner/evidence.js.map +1 -0
  69. package/dist/runner/http5xx.d.ts +40 -0
  70. package/dist/runner/http5xx.d.ts.map +1 -0
  71. package/dist/runner/http5xx.js +189 -0
  72. package/dist/runner/http5xx.js.map +1 -0
  73. package/dist/runner/index.d.ts +88 -0
  74. package/dist/runner/index.d.ts.map +1 -0
  75. package/dist/runner/index.js +597 -0
  76. package/dist/runner/index.js.map +1 -0
  77. package/dist/runner/replay.d.ts +42 -0
  78. package/dist/runner/replay.d.ts.map +1 -0
  79. package/dist/runner/replay.js +440 -0
  80. package/dist/runner/replay.js.map +1 -0
  81. package/dist/runner/timeout.d.ts +16 -0
  82. package/dist/runner/timeout.d.ts.map +1 -0
  83. package/dist/runner/timeout.js +38 -0
  84. package/dist/runner/timeout.js.map +1 -0
  85. package/dist/trace/fingerprint.d.ts +78 -0
  86. package/dist/trace/fingerprint.d.ts.map +1 -0
  87. package/dist/trace/fingerprint.js +273 -0
  88. package/dist/trace/fingerprint.js.map +1 -0
  89. package/dist/trace/serialize.d.ts +15 -0
  90. package/dist/trace/serialize.d.ts.map +1 -0
  91. package/dist/trace/serialize.js +86 -0
  92. package/dist/trace/serialize.js.map +1 -0
  93. package/dist/triager/index.d.ts +64 -0
  94. package/dist/triager/index.d.ts.map +1 -0
  95. package/dist/triager/index.js +301 -0
  96. package/dist/triager/index.js.map +1 -0
  97. package/dist/types.d.ts +491 -0
  98. package/dist/types.d.ts.map +1 -0
  99. package/dist/types.js +10 -0
  100. package/dist/types.js.map +1 -0
  101. package/dist/verify/index.d.ts +52 -0
  102. package/dist/verify/index.d.ts.map +1 -0
  103. package/dist/verify/index.js +140 -0
  104. package/dist/verify/index.js.map +1 -0
  105. package/dist/verify/verdict.d.ts +34 -0
  106. package/dist/verify/verdict.d.ts.map +1 -0
  107. package/dist/verify/verdict.js +89 -0
  108. package/dist/verify/verdict.js.map +1 -0
  109. package/package.json +90 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,172 @@
1
+ # Changelog
2
+
3
+ All notable changes to **monkeytester** are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Changed
11
+
12
+ - README and the docs installed from npm as `npm install @monkeytestai/monkeytest-core` (published 0.4.0). A clone remained the contributor path, including the no-key smoke script. 0.5.0 renames that package to `@monkeytestai/monkeytester`.
13
+ - The 0.4.0 package name was `@monkeytestai/monkeytest-core` (it was `@mtai/monkeytest-core`; that npm scope is taken). Imports, install docs, CI, and the Docker image used that name. Runtime behavior and the AGPL-3.0 license were unchanged. 0.5.0 replaces it.
14
+ - **SaaS migration.** `new Monkey()` now defaults `strictOracles` and `failOn5xx` to **on**. A page error, a document HTTP 404, a disabled control a step tries to use, and a same-origin HTTP ≥500 (document, xhr, or fetch) become a failed step and a blocking bug. Bug counts and `flowsFailed` will rise. To keep the previous counts, pass `strictOracles: false` and `failOn5xx: false` on the constructor, or the same fields on one `run` / `replay` / `verify` call. `www` and the apex host still match. Other ports, third-party hosts, and image/font responses stay evidence only.
15
+ - `runPlan`, `replayTraces`, `verifyBugs`, and `triage(run)` still leave those switches off unless the caller passes them, so triaging a run you already built does not rewrite it. `Monkey` passes the constructor values (now on) into the run and into `triage`. `RunResult` fields are unchanged.
16
+ - The planner keeps grounded flows, within `maxFlows`, for a crawled public form, one enabled non-submit button, one same-origin link whose target was not crawled, and one disabled non-submit button. Labels and URLs come from the crawl (`SiteMapPage.controls`, optional). Leftover model flows are the ones replaced when the budget is full.
17
+ - The runner performs `Click "Save order"` and `Fill the "email" field` itself when that label is on the page. Other steps still go to the runner model.
18
+ - `monkeytest run` exits **3** when the explorer visits zero pages, instead of exiting 0 with an empty report.
19
+ - The live e2e script starts the CLI as an asynchronous child. `spawnSync` froze the in-process demo server, the homepage timed out, and the buggy fixture exited 0.
20
+
21
+ ### Added
22
+
23
+ - Multi-stage `Dockerfile` (Node 22, `bookworm-slim`) and [DOCKER.md](./DOCKER.md). `npm ci` and `npm run build` produced `/opt/monkeytest-core` (`dist/`, `package.json`, license files, production dependencies) for a `file:` install or `COPY --from`. 0.5.0 moves that tree to `/opt/monkeytester`. Playwright browsers are not downloaded. Engine audit behavior is unchanged.
24
+ - `--fail-on-5xx` (CLI default on, `--no-fail-on-5xx` opts out) fails a passed or skipped step that observed a same-origin HTTP ≥500 on a document, xhr, or fetch, and the triager files it as a critical bug. `new Monkey()` now defaults this **on** as well. Pass `failOn5xx: false` to opt out. `www` and the apex host match. Other ports, third-party hosts, and image/font responses stay evidence only.
25
+ - The crawler reserves a few `maxPages` slots for help, contact, support, about, and other form-style links it actually saw, and keeps those links even when they sit past the ordinary link cap. `SiteMapPage.forms` records scraped forms (optional; existing readers can ignore it).
26
+ - When the crawl contains a public form and `maxFlows` is at least 1, the planner keeps a form-submit flow grounded in that page's URL, fields, and submit label. A header search box does not take that slot. The model is asked for the same flow; the deterministic pass is the floor.
27
+ - Action traces on each flow and on each bug (locator, value, URL, timing, evidence).
28
+ - `fingerprintV2` and `fingerprintParts` (version 2) from failure category, URL template, element role + name, and a normalised error signal. `fingerprint` stays the legacy v1 hash so stored bugs still match. Diff and verify use v2 only when both sides have it.
29
+ - `monkeytest rerun` replays the stored trace with no LLM calls. `--heal` re-resolves a step whose locator missed and marks that step `healed`.
30
+ - `monkeytest verify` replays each bug trace and reports `fixed`, `still_broken`, `flaky`, `healed`, or `blocked`. Exit `1` when any bug is `still_broken` or `flaky`.
31
+ - Vitest coverage for fingerprints, trace serialisation, verdicts, and `diffRuns`, plus an integration test. CI runs `npm test`.
32
+ - Strict oracles fail a step when the page throws, a document returns HTTP 404, an action returns HTTP 5xx, or the clicked control is disabled. They default **on** for `new Monkey()` and for the CLI. Pass `strictOracles: false` to opt out. Replay uses the same switch. `runPlan` still defaults it off unless the caller passes it.
33
+ - Reusable buggy/fixed demo app under `test/fixtures/demo-app`. `npm test` covers it with a stub LLM. `.github/workflows/e2e-live.yml` runs the same app with a real model (manual, nightly, and pushes to `main`).
34
+
35
+ ### Fixed
36
+
37
+ - The release workflow grants `contents: write` so it can open the GitHub release after npm publish. Provenance still uses `id-token: write`. The release install command uses the package version with the leading `v` removed.
38
+ - A valid planner response can no longer drop a public form the crawl already saw. The form-submit flow is a reserved slot: shopping-only plans, and plans whose only submit is a vague "submit" on that page, still include the grounded flow and its action URL (for example `/api/contact`). Fault-surface flows cannot take that slot. Help, contact, and about reads are dropped only after shop flows. `SiteMapForm.inputs` optionally records label, name, placeholder, and type; `fields` is unchanged. Fill steps use that label, then a `name` CSS selector, instead of an invented placeholder such as `placeholder:Email`.
39
+ - Replay and verify keep going when a step the original run already marked `skipped` has a locator that still misses. A soft skip (for example a placeholder fill that never matched) no longer becomes `locator_mismatch` and hides a later bug, such as a form POST that returned HTTP 500. A step that originally passed or failed still stops the flow. Fingerprints are unchanged.
40
+ - A planner model response that is invalid JSON, fails schema validation, or includes a flow with empty `steps` no longer wipes the plan. Usable model flows are kept. The public-form submit flow and scraped fault-control flows are still added, up to `maxFlows`. `plan()` records the model error on `TestPlan.notes` and emits `engine.error`. `executeAndTriage` runs that plan. An empty plan remains only when the crawl has no public form and no fault control. `RunResult` fields are unchanged. `groundedTestPlan(siteMap, maxFlows)` is the same crawl-only floor, for a host that catches a planner failure itself.
41
+ - The per-flow timeout no longer leaves its timer running after the flow finishes, and it closes the browser context when the budget is exceeded.
42
+
43
+ ## [0.5.0] — 2026-10
44
+
45
+ ### Changed
46
+
47
+ - **Breaking:** the npm package is `@monkeytestai/monkeytester`. It was `@monkeytestai/monkeytest-core`. Update `npm install` and `import` paths. The CLI binary stays `monkeytest` (`npx monkeytest`). The license stays `AGPL-3.0-only`. `publishConfig.access` stays `public`.
48
+ - Repository URLs in this repo now use `https://github.com/monkeytestai/monkeytester` (previously `https://github.com/monkeytestai/monkeytest-core`). The GitHub repository rename follows this release. The homepage stays `https://docs.monkeytest.ai`.
49
+ - Docs and other in-repo wording for this package use **monkeytester**. The product name **monkeytest**, the `monkeytest` CLI, and the `.monkeytest/` directory are unchanged.
50
+ - The Docker install tree is `/opt/monkeytester` (was `/opt/monkeytest-core`). Example tags are `monkeytester:local` and `monkeytester:ci`. `npm pack` tarballs are named `monkeytestai-monkeytester-<version>.tgz`.
51
+ - `monkeytest version`, and the `engine` label on newly saved plans and runs, now report `monkeytester@0.5.0`. On-disk schema stays `1`.
52
+
53
+ ## [0.4.1] — 2026-10
54
+
55
+ ### Fixed
56
+
57
+ - The crawler compared outbound links with `URL.origin`, so a start URL of `http://shop.example/` that redirects to `https://www.shop.example/` never left the homepage: every rewritten link looked off-origin and the queue stopped. Crawl scope now treats the apex host and `www` as one site, and `http` and `https` as one site. Another subdomain, another host, or another explicit port is still skipped. A redirect that stays on the site is stored as the URL the browser landed on; the caller's `startUrl` is unchanged. The fault-surface link check uses the same site rule, so a homepage "Track order" or "Help" link rewritten onto `https://www` is still eligible when that path was not crawled. The public-form floor is unchanged and still requires the form page in the sitemap. `www` / scheme matching for HTTP 5xx oracles is unchanged.
58
+
59
+ ## [0.4.0] — 2026-05
60
+
61
+ The bug-finding loop release. The CLI is now a real product surface with
62
+ `init`, `run`, `rerun`, `diff`, and `report` subcommands; the engine ships
63
+ the primitives those commands stand on (`Monkey.runFromPlan`, `diffRuns`,
64
+ plus `savePlan`/`loadPlan`/`saveRun`/`loadRun`).
65
+
66
+ ### Added
67
+
68
+ - `Monkey.runFromPlan(plan, opts)` — re-execute a stored `TestPlan`
69
+ without re-crawling or re-planning. The deterministic, cheap path for
70
+ verifying that a fix actually landed.
71
+ - `diffRuns(prev, current)` — set diff over `BugReport.fingerprint`s plus
72
+ a severity-rank check. Returns `{ newBugs, fixedBugs, persistingBugs,
73
+ regressedBugs, stats }`. `summariseDiff()` for one-line CLI output.
74
+ - Persistence module: `savePlan` / `loadPlan` / `saveRun` / `loadRun` /
75
+ `listRuns` with versioned `schema` field. Stable on-disk layout under
76
+ `.monkeytest/{plan.json, runs/<id>.json, shots/}`.
77
+ - New CLI subcommands:
78
+ - `monkeytest init` — scaffold `.monkeytest/`.
79
+ - `monkeytest run <url>` — full pipeline + persisted plan + run.
80
+ - `monkeytest rerun [<runId>]` — re-execute the same stored plan.
81
+ - `monkeytest diff <runA> <runB>` — bug-fingerprint diff with shortcuts
82
+ `latest`/`prev`. Exits `1` on new bugs or severity escalations.
83
+ - `monkeytest report [<runId>]` — pretty-print a stored run.
84
+ - Consistent CLI exit codes (`0` ok, `1` bugs/regressions, `2` bad args,
85
+ `3` engine error) so CI can gate on results.
86
+
87
+ ### Changed
88
+
89
+ - CLI rewritten as a subcommand router with per-command help; old
90
+ single-command entrypoint deprecated but `explore` still works.
91
+ - Plan / run JSON gain a `schema: 1` field for forwards-compatibility.
92
+
93
+ ### Docs
94
+
95
+ - New guide: **The bug-finding loop** — explains the find-fix-rerun-diff
96
+ cycle and the SaaS variant.
97
+ - New reference page: **CLI** with every subcommand, flag, env var, exit
98
+ code, and the on-disk layout.
99
+ - Homepage and README updated to lead with the loop story.
100
+
101
+ ## [0.3.0] — 2026-05
102
+
103
+ First public npm release.
104
+
105
+ ### Added
106
+
107
+ - **Anthropic Claude** provider (`provider: 'anthropic'`) with full
108
+ `messages.create` integration and prompted JSON mode.
109
+ - **Mistral** provider (`provider: 'mistral'`) using native
110
+ `responseFormat: { type: 'json_object' }`.
111
+ - **Groq** provider (`provider: 'groq'`) routing through Groq's
112
+ OpenAI-compatible endpoint for low-latency runner calls.
113
+ - **OpenAI-compatible** provider (`provider: 'openai_compatible'`) with
114
+ `baseURL` for Ollama, vLLM, LM Studio, OpenRouter, Together, and any
115
+ other server speaking the OpenAI Chat Completions wire format. JSON mode
116
+ is auto-disabled for `localhost`/`127.0.0.1` endpoints.
117
+ - **Per-phase LLM tiers.** `MonkeyLLMConfig` now exposes a dedicated
118
+ `runner?: LLMConfig` slot so the hot-path per-step calls can use a cheap,
119
+ fast model while the planner uses a smarter one.
120
+ - **Optional triager polish pass.** Set `MonkeyConfig.llm.triager` to have
121
+ the engine rewrite each bug's `title`, `observed`, `expected`, and
122
+ `triageNotes` from the structured evidence the deterministic triager
123
+ already collected. Per-bug try/catch — a bad LLM response on one bug
124
+ never affects the others, and the deterministic copy is always preserved
125
+ on failure.
126
+ - **Prompt caching** for OpenAI (auto, prompt-prefix) and Anthropic
127
+ (`cache_control: { type: 'ephemeral' }` breakpoints on the system block
128
+ and the long stable user block). The planner prompt is restructured into
129
+ `system` + `cacheable` (site map) + `prompt` (per-call constraints) so
130
+ repeat runs against the same site reuse the cached prefix.
131
+ - **`LLM.lastUsage`** — token + cache stats from each call
132
+ (`inputTokens`, `cachedInputTokens`, `outputTokens`, `cacheWrite`).
133
+ Surfaced through the `plan.complete` / `triage.complete` events so SaaS
134
+ dashboards can render "saved $X via prompt cache".
135
+ - **`autoLLMConfig({ quality })`** ergonomic helper — auto-detects a
136
+ provider from env vars and applies `cheap` / `balanced` / `smart`
137
+ presets. Lets users start in two lines.
138
+ - **`detectProviderFromEnv`**, **`CHEAP_FAST_MODEL`**, **`SMART_MODEL`**
139
+ exports for advanced consumers.
140
+
141
+ ### Changed
142
+
143
+ - Planner prompt restructured for cache friendliness; identical behaviour
144
+ for callers using `Monkey` directly.
145
+ - Default Gemini model remains `gemini-flash-lite-latest`. Default OpenAI
146
+ model remains `gpt-4o-mini`. Anthropic defaults to `claude-haiku-4-5`,
147
+ Mistral to `mistral-small-latest`, Groq to `llama-3.3-70b-versatile`.
148
+ - `triage()` is unchanged and remains zero-LLM-cost. The new
149
+ `triagePolished()` is a separate async export for callers that want to
150
+ drive the polish pass directly.
151
+
152
+ ### Documentation
153
+
154
+ - New comprehensive docs site at **docs.monkeytest.ai** with sections:
155
+ Architecture, LLM providers, Cost & depth, Prompt caching, Triager
156
+ polish, Recipes, Use in CI, Troubleshooting.
157
+ - Hero image and value-led README.
158
+
159
+ ## [0.2.0] — 2026
160
+
161
+ ### Added
162
+
163
+ - Explorer, planner, runner, triager pipeline
164
+ - Playwright execution with per-step screenshots and optional flow video
165
+ - `EventBus` for live activity streams
166
+ - OpenAI and Gemini LLM backends
167
+
168
+ [0.5.0]: https://github.com/monkeytestai/monkeytester/releases/tag/v0.5.0
169
+ [0.4.1]: https://github.com/monkeytestai/monkeytester/releases/tag/v0.4.1
170
+ [0.4.0]: https://github.com/monkeytestai/monkeytester/releases/tag/v0.4.0
171
+ [0.3.0]: https://github.com/monkeytestai/monkeytester/releases/tag/v0.3.0
172
+ [0.2.0]: https://github.com/monkeytestai/monkeytester/releases/tag/v0.2.0