fusiontest 0.2.44__tar.gz → 0.2.46__tar.gz
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.
- {fusiontest-0.2.44 → fusiontest-0.2.46}/PKG-INFO +16 -4
- {fusiontest-0.2.44 → fusiontest-0.2.46}/README.md +13 -3
- fusiontest-0.2.46/fusiontest/agent/__init__.py +2 -0
- fusiontest-0.2.46/fusiontest/agent/mcp_server.py +236 -0
- fusiontest-0.2.46/fusiontest/agent/verify.py +355 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/__init__.py +196 -22
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/sites/shop/index.html +30 -6
- fusiontest-0.2.46/fusiontest/bench/suites/diffs/order-retry.diff +31 -0
- fusiontest-0.2.46/fusiontest/bench/suites/diffs/sale-banner.diff +10 -0
- fusiontest-0.2.46/fusiontest/bench/suites/diffs/stock-check.diff +22 -0
- fusiontest-0.2.46/fusiontest/bench/suites/shop-hard.yaml +42 -0
- fusiontest-0.2.46/fusiontest/bench/suites/shop-intent.yaml +32 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/cli.py +236 -12
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/action_model.py +75 -3
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/goal_verifier.py +32 -7
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/runner.py +109 -8
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/desktop/playwright_adapter.py +20 -2
- fusiontest-0.2.46/fusiontest/discovery/intent.py +220 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/PKG-INFO +16 -4
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/SOURCES.txt +9 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/requires.txt +3 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/pyproject.toml +5 -2
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/sites/shop/bugs.js +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/sites/shop/help.html +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/suites/shop.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/bench/suites/todomvc.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/app_errors.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/bugs.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/netguard.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/promise_checker.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/replay.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/reproduce.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/screen_parser.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/secrets.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/shared_traces.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/core/tokens.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/github.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/hacker_news.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/httpbin.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/todomvc.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/demos/wikipedia.yaml +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/desktop/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/desktop/macos_adapter.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/desktop/windows_adapter.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/discovery/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/discovery/goal_generator.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/guardrails/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/guardrails/engine.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/mobile/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/mobile/android_adapter.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/mobile/ios_adapter.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/reporting/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/reporting/reporter.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/training/__init__.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/training/data_collector.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/training/dataset_builder.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest/training/trainer.py +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/dependency_links.txt +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/entry_points.txt +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/not-zip-safe +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/fusiontest.egg-info/top_level.txt +0 -0
- {fusiontest-0.2.44 → fusiontest-0.2.46}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fusiontest
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.46
|
|
4
4
|
Summary: AI-powered UI testing for mobile and desktop — by FusionLeap.io
|
|
5
5
|
Author-email: FusionLeap <hello@fusionleap.io>
|
|
6
6
|
License: MIT
|
|
@@ -29,6 +29,8 @@ Requires-Dist: Appium-Python-Client>=3.1; extra == "mobile"
|
|
|
29
29
|
Requires-Dist: selenium>=4.18; extra == "mobile"
|
|
30
30
|
Provides-Extra: desktop
|
|
31
31
|
Requires-Dist: playwright>=1.43; extra == "desktop"
|
|
32
|
+
Provides-Extra: mcp
|
|
33
|
+
Requires-Dist: mcp<3,>=2.3; extra == "mcp"
|
|
32
34
|
Provides-Extra: windows
|
|
33
35
|
Requires-Dist: Appium-Python-Client>=3.1; extra == "windows"
|
|
34
36
|
Requires-Dist: selenium>=4.18; extra == "windows"
|
|
@@ -82,9 +84,13 @@ Requires-Dist: fusiontest[api,claude,desktop,gemini,groq,macos,mobile,mpnet,open
|
|
|
82
84
|
> AI-powered UI testing for web, desktop and mobile — built by [FusionLeap.io](https://fusionleap.io)
|
|
83
85
|
|
|
84
86
|
FusionTest runs UI tests written as plain-English goals. An LLM reads the
|
|
85
|
-
screen and decides what to do,
|
|
86
|
-
|
|
87
|
-
without calling the AI at all.
|
|
87
|
+
screen and decides what to do, an independent judge model confirms each goal
|
|
88
|
+
from the screen, a screenshot and the app's own errors, and goals that pass are
|
|
89
|
+
recorded so later runs replay them without calling the AI at all.
|
|
90
|
+
|
|
91
|
+
Coding agents use it to verify their changes: `fusiontest verify` (or the MCP
|
|
92
|
+
server) reads the diff, checks what it promises in the running app, and keeps
|
|
93
|
+
what passes as regression goals. See [docs/coding-agents.md](docs/coding-agents.md).
|
|
88
94
|
|
|
89
95
|
---
|
|
90
96
|
|
|
@@ -93,6 +99,9 @@ without calling the AI at all.
|
|
|
93
99
|
| Feature | Notes |
|
|
94
100
|
|---|---|
|
|
95
101
|
| Natural-language goals | `"Open the Pricing page and verify all three plans are shown"` |
|
|
102
|
+
| Verify a change | `fusiontest verify` plans checks from a diff and judges them; JSON verdict for agents and CI |
|
|
103
|
+
| MCP server | `fusiontest mcp`: `verify_change`, `run_goals`, `scan_site` for Claude Code and other agents |
|
|
104
|
+
| Independent judge | A stronger model judges pass/fail (Claude or OpenAI when set) while a cheap one clicks |
|
|
96
105
|
| Goal discovery | Crawls a site and proposes goals grounded in its real content |
|
|
97
106
|
| Record & replay | Passing goals replay with no LLM calls; the AI repairs them when the page changes |
|
|
98
107
|
| Honest results | Capacity or infrastructure problems are reported as **errors**, not test failures |
|
|
@@ -144,6 +153,9 @@ export GROQ_API_KEY=gsk_... # or ANTHROPIC_API_KEY / GEMINI_API_KEY / O
|
|
|
144
153
|
fusiontest run --url https://example.com \
|
|
145
154
|
--goal "Verify the page heading says Example Domain" --headless
|
|
146
155
|
|
|
156
|
+
# Changed the UI? Check that the change does what it says (uncommitted changes by default)
|
|
157
|
+
fusiontest verify --url http://localhost:5173
|
|
158
|
+
|
|
147
159
|
# No goals yet? Map what works on a test/staging site, and save the flows that do
|
|
148
160
|
fusiontest scan https://staging.example.com --save fusiontest.goals.yaml
|
|
149
161
|
# Behind a login: EMAIL and PASSWORD come from the environment, never the AI
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
> AI-powered UI testing for web, desktop and mobile — built by [FusionLeap.io](https://fusionleap.io)
|
|
4
4
|
|
|
5
5
|
FusionTest runs UI tests written as plain-English goals. An LLM reads the
|
|
6
|
-
screen and decides what to do,
|
|
7
|
-
|
|
8
|
-
without calling the AI at all.
|
|
6
|
+
screen and decides what to do, an independent judge model confirms each goal
|
|
7
|
+
from the screen, a screenshot and the app's own errors, and goals that pass are
|
|
8
|
+
recorded so later runs replay them without calling the AI at all.
|
|
9
|
+
|
|
10
|
+
Coding agents use it to verify their changes: `fusiontest verify` (or the MCP
|
|
11
|
+
server) reads the diff, checks what it promises in the running app, and keeps
|
|
12
|
+
what passes as regression goals. See [docs/coding-agents.md](docs/coding-agents.md).
|
|
9
13
|
|
|
10
14
|
---
|
|
11
15
|
|
|
@@ -14,6 +18,9 @@ without calling the AI at all.
|
|
|
14
18
|
| Feature | Notes |
|
|
15
19
|
|---|---|
|
|
16
20
|
| Natural-language goals | `"Open the Pricing page and verify all three plans are shown"` |
|
|
21
|
+
| Verify a change | `fusiontest verify` plans checks from a diff and judges them; JSON verdict for agents and CI |
|
|
22
|
+
| MCP server | `fusiontest mcp`: `verify_change`, `run_goals`, `scan_site` for Claude Code and other agents |
|
|
23
|
+
| Independent judge | A stronger model judges pass/fail (Claude or OpenAI when set) while a cheap one clicks |
|
|
17
24
|
| Goal discovery | Crawls a site and proposes goals grounded in its real content |
|
|
18
25
|
| Record & replay | Passing goals replay with no LLM calls; the AI repairs them when the page changes |
|
|
19
26
|
| Honest results | Capacity or infrastructure problems are reported as **errors**, not test failures |
|
|
@@ -65,6 +72,9 @@ export GROQ_API_KEY=gsk_... # or ANTHROPIC_API_KEY / GEMINI_API_KEY / O
|
|
|
65
72
|
fusiontest run --url https://example.com \
|
|
66
73
|
--goal "Verify the page heading says Example Domain" --headless
|
|
67
74
|
|
|
75
|
+
# Changed the UI? Check that the change does what it says (uncommitted changes by default)
|
|
76
|
+
fusiontest verify --url http://localhost:5173
|
|
77
|
+
|
|
68
78
|
# No goals yet? Map what works on a test/staging site, and save the flows that do
|
|
69
79
|
fusiontest scan https://staging.example.com --save fusiontest.goals.yaml
|
|
70
80
|
# Behind a login: EMAIL and PASSWORD come from the environment, never the AI
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"""
|
|
2
|
+
fusiontest/agent/mcp_server.py
|
|
3
|
+
|
|
4
|
+
FusionTest as MCP tools for coding agents (ADR-010): `fusiontest mcp` serves
|
|
5
|
+
them over stdio. A coding agent that changed a web app calls verify_change to
|
|
6
|
+
learn, from an independent judge, whether the running app does what the
|
|
7
|
+
change promised; checks that pass can be kept as regression goals.
|
|
8
|
+
|
|
9
|
+
The tools are thin wrappers over fusiontest.agent.verify, so an agent gets
|
|
10
|
+
exactly what `fusiontest verify --json` prints (schema fusiontest.verify/1).
|
|
11
|
+
|
|
12
|
+
Safety is the CLI's: checks click and type like a user, so a host that isn't
|
|
13
|
+
local needs allow_remote=true; secrets stay {{VAR}} placeholders the models
|
|
14
|
+
never see, filled from the environment or fusiontest.config.yaml.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import logging
|
|
20
|
+
import os
|
|
21
|
+
from collections.abc import Callable
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Any
|
|
24
|
+
from urllib.parse import urlsplit
|
|
25
|
+
|
|
26
|
+
from fusiontest.agent.verify import (
|
|
27
|
+
SCHEMA,
|
|
28
|
+
AdapterFactory,
|
|
29
|
+
VerifyRequest,
|
|
30
|
+
read_change,
|
|
31
|
+
save_passing,
|
|
32
|
+
with_scheme,
|
|
33
|
+
)
|
|
34
|
+
from fusiontest.agent.verify import verify as default_verify
|
|
35
|
+
|
|
36
|
+
logger = logging.getLogger(__name__)
|
|
37
|
+
|
|
38
|
+
INSTRUCTIONS = """\
|
|
39
|
+
FusionTest checks a running web app in a real browser, the way a user would,
|
|
40
|
+
and an independent model judges each check from the screen, a screenshot and
|
|
41
|
+
the app's own errors.
|
|
42
|
+
|
|
43
|
+
Use verify_change after changing a web app's UI, with the app running (e.g. a
|
|
44
|
+
local dev server): it reads the change (your uncommitted git changes by
|
|
45
|
+
default), plans a few checks of what the change promises, runs them, and
|
|
46
|
+
returns a verdict per check with the reason and, for failures, a screenshot
|
|
47
|
+
path. Fix what fails and call it again. Use run_goals for checks you write
|
|
48
|
+
yourself, scan_site to map what works on a site, and pass save_to to keep
|
|
49
|
+
passing checks as regression goals (run on every deploy with
|
|
50
|
+
`fusiontest run -f <file>`).
|
|
51
|
+
|
|
52
|
+
Status: passed | failed (a check failed: likely a bug in the change) | error
|
|
53
|
+
(couldn't evaluate: LLM capacity, browser, sign-in) | nothing_to_verify (the
|
|
54
|
+
change has nothing visible). Checks click and submit forms: use local or
|
|
55
|
+
staging sites; other hosts need allow_remote=true.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def build_server(verify_fn: Callable[..., dict] | None = None,
|
|
60
|
+
adapter_factory: AdapterFactory | None = None,
|
|
61
|
+
cwd: str | None = None):
|
|
62
|
+
"""The MCP server with FusionTest's tools. verify_fn and adapter_factory
|
|
63
|
+
are for tests; cwd is the repository whose changes are verified."""
|
|
64
|
+
from mcp.server.mcpserver import MCPServer
|
|
65
|
+
from mcp.types import ToolAnnotations
|
|
66
|
+
|
|
67
|
+
from fusiontest import __version__
|
|
68
|
+
|
|
69
|
+
verify = verify_fn or default_verify
|
|
70
|
+
repo = cwd or os.getcwd()
|
|
71
|
+
secrets = _config_secrets(repo)
|
|
72
|
+
reports: list[dict] = []
|
|
73
|
+
server = MCPServer("fusiontest", instructions=INSTRUCTIONS, version=__version__)
|
|
74
|
+
acts = ToolAnnotations(read_only_hint=False, destructive_hint=False, idempotent_hint=False,
|
|
75
|
+
open_world_hint=True)
|
|
76
|
+
|
|
77
|
+
def finish(request: VerifyRequest, save_to: str | None) -> dict[str, Any]:
|
|
78
|
+
verdict = verify(request, adapter_factory=adapter_factory)
|
|
79
|
+
if save_to and verdict["checks"]:
|
|
80
|
+
path = Path(save_to) if Path(save_to).is_absolute() else Path(repo) / save_to
|
|
81
|
+
verdict["saved"] = {"path": str(path),
|
|
82
|
+
"added": save_passing(verdict, path, request.login)}
|
|
83
|
+
reports.append(verdict)
|
|
84
|
+
del reports[:-20]
|
|
85
|
+
return verdict
|
|
86
|
+
|
|
87
|
+
def refused(url: str, why: str) -> dict[str, Any]:
|
|
88
|
+
return {"schema": SCHEMA, "status": "error", "exit_code": 2, "summary": why, "url": url,
|
|
89
|
+
"backend": "", "judge": "", "checks": [], "bugs": []}
|
|
90
|
+
|
|
91
|
+
def request_for(url: str, allow_remote: bool, **fields) -> VerifyRequest | str:
|
|
92
|
+
url = with_scheme(url)
|
|
93
|
+
host = urlsplit(url).hostname or url
|
|
94
|
+
if not allow_remote and not _is_local_host(host):
|
|
95
|
+
return (f"Not checking {host}: checks click buttons and submit forms like a user. "
|
|
96
|
+
"Use a local or staging site, and pass allow_remote=true to confirm.")
|
|
97
|
+
return VerifyRequest(url=url, secrets=secrets,
|
|
98
|
+
screenshot_dir=Path(repo) / ".fusiontest" / "screenshots", **fields)
|
|
99
|
+
|
|
100
|
+
@server.tool(annotations=acts)
|
|
101
|
+
def verify_change(url: str, diff: str | None = None, git_range: str | None = None,
|
|
102
|
+
intent: str = "", login: str | None = None, max_checks: int = 6,
|
|
103
|
+
find_bugs: bool = False, save_to: str | None = None,
|
|
104
|
+
allow_remote: bool = False) -> dict[str, Any]:
|
|
105
|
+
"""Check that a code change does what it promises, in the running app.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
url: The running app, e.g. http://localhost:5173 (your dev server).
|
|
109
|
+
diff: The change as a unified diff. Default: `git diff HEAD` in the
|
|
110
|
+
repository (your uncommitted changes), or `git diff <git_range>`.
|
|
111
|
+
git_range: Verify committed changes instead, e.g. "main...HEAD".
|
|
112
|
+
intent: What the change is for (task, PR description). Improves the checks.
|
|
113
|
+
login: A sign-in goal run before each check, with {{VAR}} placeholders
|
|
114
|
+
for secrets, e.g. "Sign in with {{EMAIL}} and {{PASSWORD}}".
|
|
115
|
+
max_checks: At most this many checks (1-12).
|
|
116
|
+
find_bugs: Also report confirmed bugs (crashes, server errors) seen while checking.
|
|
117
|
+
save_to: A goals file to add passing checks to, for regression runs.
|
|
118
|
+
allow_remote: Required to check a host that isn't local.
|
|
119
|
+
"""
|
|
120
|
+
if not diff:
|
|
121
|
+
try:
|
|
122
|
+
diff = read_change(git_range=git_range, cwd=repo)
|
|
123
|
+
except RuntimeError as exc:
|
|
124
|
+
if not intent:
|
|
125
|
+
return refused(url, str(exc))
|
|
126
|
+
diff = ""
|
|
127
|
+
req = request_for(url, allow_remote, diff=diff, intent=intent, login=login,
|
|
128
|
+
max_goals=max(1, min(max_checks, 12)), find_bugs=find_bugs)
|
|
129
|
+
return refused(url, req) if isinstance(req, str) else finish(req, save_to)
|
|
130
|
+
|
|
131
|
+
@server.tool(annotations=acts)
|
|
132
|
+
def run_goals(url: str, goals: list[str], login: str | None = None,
|
|
133
|
+
find_bugs: bool = False, save_to: str | None = None,
|
|
134
|
+
allow_remote: bool = False) -> dict[str, Any]:
|
|
135
|
+
"""Run checks you wrote, each a plain-English goal ending in what to
|
|
136
|
+
verify, e.g. "Add Blue Mug to the cart and verify the cart shows 1 item".
|
|
137
|
+
|
|
138
|
+
Args:
|
|
139
|
+
url: The running app; each goal starts from this page.
|
|
140
|
+
goals: The goals to check, in order.
|
|
141
|
+
login: A sign-in goal run before each check ({{VAR}} placeholders for secrets).
|
|
142
|
+
find_bugs: Also report confirmed bugs seen while checking.
|
|
143
|
+
save_to: A goals file to add passing checks to, for regression runs.
|
|
144
|
+
allow_remote: Required to check a host that isn't local.
|
|
145
|
+
"""
|
|
146
|
+
if not goals:
|
|
147
|
+
return refused(url, "No goals given.")
|
|
148
|
+
req = request_for(url, allow_remote, goals=list(goals), login=login, find_bugs=find_bugs)
|
|
149
|
+
return refused(url, req) if isinstance(req, str) else finish(req, save_to)
|
|
150
|
+
|
|
151
|
+
@server.tool(annotations=acts)
|
|
152
|
+
def scan_site(url: str, max_flows: int = 8, login: str | None = None,
|
|
153
|
+
save_to: str | None = None, allow_remote: bool = False) -> dict[str, Any]:
|
|
154
|
+
"""Map what works on a site: find its main flows from its pages and
|
|
155
|
+
check each one. Useful before changing an app you don't know yet.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
url: The site's start page.
|
|
159
|
+
max_flows: How many flows to find and check (1-20).
|
|
160
|
+
login: A sign-in goal run first ({{VAR}} placeholders for secrets).
|
|
161
|
+
save_to: A goals file to add the flows that work to.
|
|
162
|
+
allow_remote: Required to check a host that isn't local.
|
|
163
|
+
"""
|
|
164
|
+
req = request_for(url, allow_remote, login=login)
|
|
165
|
+
if isinstance(req, str):
|
|
166
|
+
return refused(url, req)
|
|
167
|
+
try:
|
|
168
|
+
flows = _discover(req, max(1, min(max_flows, 20)), adapter_factory)
|
|
169
|
+
except Exception as exc: # noqa: BLE001 — reported, not raised
|
|
170
|
+
return refused(req.url, f"Couldn't find flows: {exc}")
|
|
171
|
+
req.goals = [f.text for f in flows]
|
|
172
|
+
return finish(req, save_to)
|
|
173
|
+
|
|
174
|
+
@server.tool(annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False))
|
|
175
|
+
def last_report(index: int = -1) -> dict[str, Any]:
|
|
176
|
+
"""A verdict this server returned earlier (index -1: the latest), e.g.
|
|
177
|
+
to re-read reasons or screenshot paths."""
|
|
178
|
+
if not reports:
|
|
179
|
+
return {"schema": SCHEMA, "status": "error", "summary": "No checks have run yet."}
|
|
180
|
+
try:
|
|
181
|
+
return reports[index]
|
|
182
|
+
except IndexError:
|
|
183
|
+
return {"schema": SCHEMA, "status": "error",
|
|
184
|
+
"summary": f"No report {index}: {len(reports)} kept."}
|
|
185
|
+
|
|
186
|
+
return server
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _discover(request: VerifyRequest, max_flows: int, adapter_factory: AdapterFactory | None):
|
|
190
|
+
from fusiontest.agent.verify import _playwright, _signed_in_snapshot, _stop
|
|
191
|
+
from fusiontest.core.action_model import resolve_judge_backend
|
|
192
|
+
from fusiontest.discovery.goal_generator import (
|
|
193
|
+
GoalGenerator,
|
|
194
|
+
GoalGeneratorConfig,
|
|
195
|
+
_primary_backend,
|
|
196
|
+
snapshot_site,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
config = GoalGeneratorConfig(max_goals=max_flows)
|
|
200
|
+
factory = adapter_factory or _playwright
|
|
201
|
+
backend = _primary_backend(request.backend)
|
|
202
|
+
if request.login:
|
|
203
|
+
snapshot = _signed_in_snapshot(request, backend, resolve_judge_backend(backend), factory,
|
|
204
|
+
config)
|
|
205
|
+
else:
|
|
206
|
+
adapter = factory(request.url)
|
|
207
|
+
try:
|
|
208
|
+
snapshot = snapshot_site(request.url, config, adapter=adapter)
|
|
209
|
+
snapshot.signed_in = False
|
|
210
|
+
finally:
|
|
211
|
+
_stop(adapter)
|
|
212
|
+
return GoalGenerator(config).generate(request.url, preferred_backend=backend, snapshot=snapshot)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def _config_secrets(repo: str) -> dict[str, str]:
|
|
216
|
+
"""`secrets:` from the repository's fusiontest.config.yaml, as for the CLI."""
|
|
217
|
+
import yaml
|
|
218
|
+
|
|
219
|
+
path = Path(repo) / "fusiontest.config.yaml"
|
|
220
|
+
if not path.exists():
|
|
221
|
+
return {}
|
|
222
|
+
cfg = yaml.safe_load(path.read_text()) or {}
|
|
223
|
+
return {str(k): os.getenv(str(v), str(v)) for k, v in (cfg.get("secrets") or {}).items()}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def _is_local_host(host: str) -> bool:
|
|
227
|
+
host = (host or "").lower().strip("[]")
|
|
228
|
+
return host in ("localhost", "127.0.0.1", "::1") or host.endswith(
|
|
229
|
+
(".localhost", ".test", ".local", ".internal"))
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def serve(cwd: str | None = None) -> None:
|
|
233
|
+
"""Run the server over stdio (what `fusiontest mcp` does)."""
|
|
234
|
+
# stdout is the protocol channel: logs go to stderr.
|
|
235
|
+
logging.basicConfig(level=logging.WARNING, format="%(levelname)s %(name)s: %(message)s")
|
|
236
|
+
build_server(cwd=cwd).run("stdio")
|