@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/README.md CHANGED
@@ -1,3 +1,197 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="docs/public/hero.jpg" alt="monkeytester — an AI agent that uses your site like a real user and reports the bugs" width="820" />
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ <h1 align="center">monkeytester</h1>
6
+
7
+ <p align="center">
8
+ <strong>An AI agent that uses your site like a real user — and reports the bugs.</strong><br />
9
+ Open source. Playwright + your favourite LLM. First result in about a minute, no API key.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://www.npmjs.com/package/@monkeytestai/monkeytester"><img src="https://img.shields.io/npm/v/@monkeytestai/monkeytester" alt="npm @monkeytestai/monkeytester" /></a>
14
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="Node 20+" /></a>
15
+ <a href="https://docs.monkeytest.ai"><img src="https://img.shields.io/badge/docs-docs.monkeytest.ai-7c3aed" alt="Documentation" /></a>
16
+ <a href="https://github.com/monkeytestai/monkeytester/actions/workflows/ci.yml"><img src="https://github.com/monkeytestai/monkeytester/actions/workflows/ci.yml/badge.svg" alt="CI" /></a>
17
+ <a href="https://github.com/monkeytestai/monkeytester/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-64748b" alt="AGPL-3.0" /></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://docs.monkeytest.ai/guide/quick-start">Quick start</a> ·
22
+ <a href="https://docs.monkeytest.ai/guide/why-monkeytest">Why monkeytest</a> ·
23
+ <a href="https://docs.monkeytest.ai/guide/llm-providers">LLM providers</a> ·
24
+ <a href="https://docs.monkeytest.ai/guide/cost-and-depth">Cost & depth</a> ·
25
+ <a href="https://docs.monkeytest.ai/reference/overview">API</a> ·
26
+ <a href="https://monkeytest.ai">Cloud</a>
27
+ </p>
28
+
29
+ ---
30
+
31
+ Most "AI testing" tools stop at *finding* bugs. monkeytester is built around the **full loop**:
32
+
33
+ > **find → fix → re-run the same plan → diff what changed.**
34
+
35
+ Point it at a URL. It crawls a few pages, asks an LLM *"what would a real user try here?"*, runs those flows step by step, and writes a stable, versioned `plan.json` you can commit to git. Tomorrow, after you ship a fix, **`monkeytest rerun`** re-executes the *exact same* plan — no LLM cost for re-planning, no plan drift between runs — and **`monkeytest diff`** tells you what's new, what's fixed, what regressed.
36
+
37
+ ```bash
38
+ npx monkeytest run https://example.com # first run: explore + plan + execute, exit 1 if bugs
39
+ # ...you ship a fix...
40
+ npx monkeytest rerun # re-runs the same plan, exit 1 if any blocking bug remains
41
+ npx monkeytest diff prev latest # 2 fixed, 0 new, 1 still broken, 0 regressed (net -2)
42
+ ```
43
+
44
+ Those subcommands come from `npm install @monkeytestai/monkeytester`. A clone runs them with `node dist/cli.js`.
45
+
46
+ Or programmatically — same primitives:
47
+
48
+ ```ts
49
+ import { Monkey, autoLLMConfig, savePlan, loadPlan, diffRuns, saveRun } from '@monkeytestai/monkeytester';
50
+
51
+ const monkey = new Monkey({ llm: autoLLMConfig({ quality: 'balanced' }) });
52
+
53
+ // Day 1 — discover
54
+ const { plan, run: a } = await monkey.executeAndTriage('https://example.com', {
55
+ run: { screenshotsDir: '.monkeytest/shots' },
56
+ });
57
+ savePlan(plan, { dir: '.monkeytest' });
58
+ saveRun(a, { dir: '.monkeytest' });
59
+
60
+ // Day 2 — verify after fixing
61
+ const stored = loadPlan('.monkeytest');
62
+ const { run: b } = await monkey.runFromPlan(stored.plan, {
63
+ run: { screenshotsDir: '.monkeytest/shots' },
64
+ });
65
+ saveRun(b, { dir: '.monkeytest' });
66
+
67
+ const diff = diffRuns(a, b);
68
+ console.log(`${diff.stats.fixed} fixed, ${diff.stats.regressed} regressed`);
69
+ ```
70
+
71
+ No fixtures, no page objects, no recorders. Read [the bug-finding loop](https://docs.monkeytest.ai/guide/the-bug-finding-loop) for the full story. The import above resolves from [`@monkeytestai/monkeytester`](https://www.npmjs.com/package/@monkeytestai/monkeytester) on npm. See [why monkeytest](https://docs.monkeytest.ai/guide/why-monkeytest) for how it sits next to similar tools.
72
+
73
+ ## Install
74
+
75
+ Node.js 20 or newer.
76
+
77
+ ```bash
78
+ npm install @monkeytestai/monkeytester
79
+ npx playwright install chromium
80
+ ```
81
+
82
+ [@monkeytestai/monkeytester](https://www.npmjs.com/package/@monkeytestai/monkeytester) **0.5.0** is the published package. The CLI is `npx monkeytest`.
83
+
84
+ ```bash
85
+ export GEMINI_API_KEY="paste-your-key"
86
+ npx monkeytest run https://example.com --max 2 --flows 1
87
+ ```
88
+
89
+ Screenshots are written to `.monkeytest/shots/`. A free Gemini key, or Ollama on localhost, is in the [quick start](https://docs.monkeytest.ai/guide/quick-start), including where `plan.json`, `runs/`, and `shots/` show up, and how `rerun` / `diff` work.
90
+
91
+ ### From a clone (contributors)
92
+
93
+ The no-key smoke script lives in the repository. It stubs the LLM, crawls `https://example.com`, and prints `OK — engine pipeline is wired correctly.`
94
+
95
+ ```bash
96
+ git clone https://github.com/monkeytestai/monkeytester.git && cd monkeytester
97
+ npm install && npm run build
98
+ npx playwright install chromium && node scripts/smoke.mjs
99
+ ```
100
+
101
+ `npm run build` writes `dist/cli.js`. The same subcommands are `node dist/cli.js run ...`.
102
+
103
+ ## Docker
104
+
105
+ A multi-stage image compiles this package and leaves it at `/opt/monkeytester` (`dist/`, `package.json`, and production dependencies) so another image can copy it, or so a sibling checkout can satisfy `file:../monkeytester`. `mtaiserver` still uses `file:../monkeytest-core` until that repo is updated. API keys and Playwright browsers are not in the image. Build, the sibling layout, and the pinned hosted SHA are in [DOCKER.md](./DOCKER.md).
106
+
107
+ ```bash
108
+ docker build -t monkeytester:local .
109
+ docker run --rm monkeytester:local --help
110
+ ```
111
+
112
+ ## Why monkeytester?
113
+
114
+ - **Closed loop, not just discovery.** Stable JSON plans + bug fingerprints + a real `rerun` and `diff` — built in, not bolted on.
115
+ - **Drop-in, not framework.** One library, one constructor. No DSL.
116
+ - **Bring your own LLM.** OpenAI, Gemini, Anthropic, Mistral, Groq, or any OpenAI-compatible endpoint (Ollama, vLLM, OpenRouter). Pick a different model **per phase**.
117
+ - **Real evidence.** Per-step screenshots, optional WebM video, console + network failures, and bug reports with stable fingerprints across runs.
118
+ - **Live activity stream.** Subscribe to a typed `EventBus` and pipe explorer / planner / runner / triager events into your own dashboard.
119
+ - **Resilient.** If the planner fails, you still get explorer screenshots. If a flow blows up, you still get the steps that ran. Nothing is all-or-nothing.
120
+ - **Hackable, typed, observable.** Pure TypeScript, zod-validated LLM output, structured `RunResult` you can serialise.
121
+
122
+ ## A comprehensive example
123
+
124
+ ```ts
125
+ import { Monkey, EventBus } from '@monkeytestai/monkeytester';
126
+
127
+ const events = new EventBus();
128
+ events.on(e => console.log(`[${e.phase}] ${e.type}: ${e.message}`));
129
+
130
+ // Mix providers per phase: cheap explorer + smart planner + fast runner
131
+ const monkey = new Monkey({
132
+ llm: {
133
+ explorer: { provider: 'gemini', model: 'gemini-flash-lite-latest' },
134
+ planner: { provider: 'anthropic', model: 'claude-sonnet-4-5' },
135
+ runner: { provider: 'groq', model: 'llama-3.3-70b-versatile' },
136
+ },
137
+ });
138
+
139
+ const { siteMap, plan, run } = await monkey.executeAndTriage('https://app.example.com', {
140
+ events,
141
+ explore: { maxPages: 12, screenshotsDir: '.monkeytest/shots' },
142
+ plan: { maxFlows: 6, includeAuthFlows: false },
143
+ run: { screenshotsDir: '.monkeytest/shots', headless: true, stepTimeoutMs: 20_000 },
144
+ });
145
+
146
+ console.log(`Visited ${siteMap.pages.length} pages, planned ${plan.flows.length} flows.`);
147
+ console.log(`Run: ${run.stats.flowsPassed}/${run.stats.flowsTotal} flows passed.`);
148
+
149
+ for (const bug of run.bugs.filter(b => b.severity !== 'minor')){
150
+ console.error(`- [${bug.severity}] ${bug.title}\n ${bug.observed}`);
151
+ console.error(` evidence: ${bug.evidence.screenshots.length} screenshot(s)`);
152
+ }
153
+ ```
154
+
155
+ ## Where it shines
156
+
157
+ - **Pre-release sanity checks** on staging.
158
+ - **PR previews** — run on Vercel/Netlify preview URLs in CI ([recipe](https://docs.monkeytest.ai/guide/ci)).
159
+ - **Daily smoke runs** against prod with cheap models.
160
+ - **Embedding in your own product** — the engine is a library, not a CLI.
161
+
162
+ ## What it isn't
163
+
164
+ - Not a replacement for **deterministic critical-path E2E tests** — it's a complement.
165
+ - Not a **load tester** or **a11y auditor**.
166
+ - Not magic — quality of bug reports tracks the quality of the LLM you give it.
167
+
168
+ ## Documentation
169
+
170
+ Everything lives at **[docs.monkeytest.ai](https://docs.monkeytest.ai)**:
171
+
172
+ - [Quick start](https://docs.monkeytest.ai/guide/quick-start) — npm install, or a clone for the no-key smoke run, then Gemini or Ollama
173
+ - [Why monkeytest](https://docs.monkeytest.ai/guide/why-monkeytest) — how it compares with nearby tools
174
+ - [The bug-finding loop](https://docs.monkeytest.ai/guide/the-bug-finding-loop) — explore once, run repeatedly, diff
175
+ - [CLI reference](https://docs.monkeytest.ai/reference/cli) — every subcommand and flag
176
+ - [How it works](https://docs.monkeytest.ai/guide/architecture) — the four phases
177
+ - [LLM providers](https://docs.monkeytest.ai/guide/llm-providers) — model picks per provider
178
+ - [Cost & depth](https://docs.monkeytest.ai/guide/cost-and-depth) — what each run costs
179
+ - [Recipes](https://docs.monkeytest.ai/guide/recipes) — battle-tested patterns
180
+ - [Use in CI](https://docs.monkeytest.ai/guide/ci) — GitHub Actions setup
181
+ - [Troubleshooting](https://docs.monkeytest.ai/guide/troubleshooting) — common errors
182
+
183
+ ## MonkeyTest Cloud
184
+
185
+ Don't want to run it yourself? **[MonkeyTest Cloud](https://monkeytest.ai)** is the same engine, fully managed: hosted browsers, history, dashboards, team accounts.
186
+
187
+ ## Contributing
188
+
189
+ PRs and issues welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
190
+
191
+ ## Security
192
+
193
+ Report vulnerabilities privately — see [SECURITY.md](./SECURITY.md).
194
+
195
+ ---
196
+
197
+ <sub>AGPL-3.0 · `SPDX-License-Identifier: AGPL-3.0-only` · See [LICENSE](./LICENSE) for the full text and the [license summary](https://docs.monkeytest.ai/guide/license).</sub>
package/dist/cli.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * monkeytest CLI — the bug-finding loop on the command line.
4
+ *
5
+ * Subcommands:
6
+ *
7
+ * monkeytest init Scaffold a .monkeytest/ directory.
8
+ * monkeytest explore <url> Crawl + plan only. Writes plan.json.
9
+ * monkeytest run <url> Full pipeline: explore + plan + run + triage.
10
+ * Writes plan.json + runs/<id>.json + shots/.
11
+ * monkeytest rerun [<runId>] Replay the recorded action trace (no LLM).
12
+ * --heal re-resolves a step whose locator missed.
13
+ * monkeytest verify [run] Replay each bug trace and report fixed /
14
+ * still_broken / flaky / healed / blocked.
15
+ * monkeytest diff <a> <b> Diff two stored runs by bug fingerprint.
16
+ * "<a>" / "<b>" are run ids or "latest"/"prev".
17
+ * monkeytest report [<runId>] Pretty-print a stored run (flows, bugs, paths).
18
+ *
19
+ * Common flags:
20
+ * --dir <path> Working directory (default ./.monkeytest)
21
+ * --provider <id> openai | gemini | anthropic | mistral | groq | openai_compatible
22
+ * --model <id> Override model id (provider-specific)
23
+ * --quality <preset> cheap | balanced | smart (used by autoLLMConfig)
24
+ * --max <n> Max pages to crawl (explore/run only, default 8)
25
+ * --flows <n> Max flows to plan (explore/run only, default 6)
26
+ * --no-headless Show the browser window
27
+ * --label <text> Free-form label saved on the plan/run
28
+ * --heal Re-resolve a trace step when its locator misses
29
+ * --repeat <n> Replay each bug n times during `verify` (default 1)
30
+ * --bug <fingerprint> Verify a single bug
31
+ * --json Machine-readable output (run/diff/report/verify)
32
+ * --fail-on-5xx Fail a step that saw a same-origin HTTP ≥500 (default)
33
+ * --no-fail-on-5xx Leave those responses as evidence on a passed step
34
+ *
35
+ * Exit codes:
36
+ * 0 success / no blocking bugs / no bug still firing
37
+ * 1 blocking bugs (`run` / `rerun`), new or regressed bugs (`diff`),
38
+ * or any `still_broken` / `flaky` verdict (`verify`)
39
+ * 2 invalid args / setup error
40
+ * 3 engine / runtime error
41
+ */
42
+ export {};
43
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG"}