prompttest 1.3.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.
- package/CONTRIBUTING.md +80 -0
- package/LICENSE +36 -0
- package/LICENSES.md +81 -0
- package/README.md +402 -0
- package/SECURITY.md +56 -0
- package/dist/bin/prompttest.d.ts +2 -0
- package/dist/bin/prompttest.js +1020 -0
- package/dist/constants/commands.d.ts +125 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.js +862 -0
- package/dist/lib/adb.d.ts +394 -0
- package/dist/lib/ai/heuristic-resolver.d.ts +19 -0
- package/dist/lib/ai/index.d.ts +16 -0
- package/dist/lib/ai/llm-provider.d.ts +40 -0
- package/dist/lib/ai/types.d.ts +64 -0
- package/dist/lib/baseline.d.ts +111 -0
- package/dist/lib/benchmark.d.ts +100 -0
- package/dist/lib/checkpoint.d.ts +61 -0
- package/dist/lib/config-loader.d.ts +87 -0
- package/dist/lib/config.d.ts +136 -0
- package/dist/lib/crawler.d.ts +335 -0
- package/dist/lib/data-loader.d.ts +53 -0
- package/dist/lib/dfs-engine.d.ts +106 -0
- package/dist/lib/dictionary.d.ts +41 -0
- package/dist/lib/doctor.d.ts +45 -0
- package/dist/lib/driver-interface.d.ts +50 -0
- package/dist/lib/enterprise.d.ts +71 -0
- package/dist/lib/errors.d.ts +68 -0
- package/dist/lib/explorer.d.ts +121 -0
- package/dist/lib/form-filler.d.ts +101 -0
- package/dist/lib/ios-driver.d.ts +38 -0
- package/dist/lib/live-server.d.ts +47 -0
- package/dist/lib/lock.d.ts +30 -0
- package/dist/lib/logger.d.ts +68 -0
- package/dist/lib/memory.d.ts +259 -0
- package/dist/lib/patterns.d.ts +202 -0
- package/dist/lib/prompt-runner.d.ts +100 -0
- package/dist/lib/recorder.d.ts +115 -0
- package/dist/lib/repl.d.ts +29 -0
- package/dist/lib/reporter.d.ts +253 -0
- package/dist/lib/runner-utils.d.ts +290 -0
- package/dist/lib/step-handlers.d.ts +388 -0
- package/docs/ARCHITECTURE.md +154 -0
- package/docs/USER_MANUAL.md +765 -0
- package/package.json +90 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Contributing to PromptTest
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to **PromptTest**!
|
|
4
|
+
|
|
5
|
+
PromptTest is an ultra-fast, zero-code autonomous mobile testing & visual QA brain designed for Android. We welcome contributions from the community.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ๐ Getting Started
|
|
10
|
+
|
|
11
|
+
1. **Fork and Clone the Repository**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone https://github.com/<your-username>/prompttest.git
|
|
15
|
+
cd prompttest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. **Install Dependencies**:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
3. **Verify Build**:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm run build
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
4. **Connect an Android Device or Emulator**:
|
|
31
|
+
Ensure `adb` is in your system PATH and run:
|
|
32
|
+
```bash
|
|
33
|
+
npm run devices
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## ๐ Project Structure
|
|
39
|
+
|
|
40
|
+
- `bin/prompttest.ts`: CLI entry point and command router (`run`, `explore`, `status`, `devices`).
|
|
41
|
+
- `lib/adb.ts`: High-performance ADB driver for fast XML hierarchy dumping, input dispatching, and screenshot capture.
|
|
42
|
+
- `lib/prompt-runner.ts`: Core test execution engine with expectation-driven polling, auto-scroll triage, and collision disambiguation.
|
|
43
|
+
- `lib/patterns.ts`: Plain-English DSL parser and step tokenizers.
|
|
44
|
+
- `lib/memory.ts`: Persistent autonomous knowledge engine and fast-forward cache.
|
|
45
|
+
- `lib/dictionary.ts`: Standard UI component vocabulary and intent mapping heuristics.
|
|
46
|
+
- `lib/crawler.ts` & `lib/explorer.ts`: Autonomous screen exploration and dynamic component graph discovery.
|
|
47
|
+
- `lib/reporter.ts`: Markdown & JSON QA test report generator with visual blackbox capture.
|
|
48
|
+
- `specs/`: Sample test spec files written in plain English.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## ๐ Adding New Prompt Grammar / Verbs
|
|
53
|
+
|
|
54
|
+
If you want to introduce a new plain-English command:
|
|
55
|
+
|
|
56
|
+
1. Update `PromptStepType` and parser regex in [`lib/patterns.ts`](lib/patterns.ts).
|
|
57
|
+
2. Add execution handler in `PromptRunner.executeStep()` inside [`lib/prompt-runner.ts`](lib/prompt-runner.ts).
|
|
58
|
+
3. Add corresponding unit or integration tests in `specs/`.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ๐งช Testing Guidelines
|
|
63
|
+
|
|
64
|
+
Before opening a pull request:
|
|
65
|
+
|
|
66
|
+
1. Ensure TypeScript compiles with zero errors:
|
|
67
|
+
```bash
|
|
68
|
+
npm run build
|
|
69
|
+
```
|
|
70
|
+
2. Test against a connected Android device or emulator:
|
|
71
|
+
```bash
|
|
72
|
+
npm run test:teacher
|
|
73
|
+
```
|
|
74
|
+
3. Keep code modular, universal (no hardcoded application-specific coordinates or package IDs), and well-documented.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## ๐ Code of Conduct & Licensing
|
|
79
|
+
|
|
80
|
+
By contributing, you agree that your contributions will be licensed under the project's [MIT License](LICENSE).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor:
|
|
6
|
+
PromptTest (Shriram Singh)
|
|
7
|
+
|
|
8
|
+
Licensed Work:
|
|
9
|
+
PromptTest (including its command-line interface, autonomous state-graph exploration engine,
|
|
10
|
+
heuristic gesture systems, and programmatic SDK), in source code, binary, and bundled distribution forms.
|
|
11
|
+
|
|
12
|
+
Additional Use Grant:
|
|
13
|
+
You may use the Licensed Work free of charge for:
|
|
14
|
+
1. Non-commercial, educational, academic, and open-source purposes.
|
|
15
|
+
2. Personal and evaluation use.
|
|
16
|
+
3. Internal software testing within organizations that have an annual gross revenue of less
|
|
17
|
+
than $100,000 USD (or equivalent) and fewer than 10 employees.
|
|
18
|
+
|
|
19
|
+
Commercial License Requirement:
|
|
20
|
+
Any use within organizations exceeding the revenue or employee threshold, any use by testing
|
|
21
|
+
agencies providing commercial QA services to third-party clients, or any deployment into production
|
|
22
|
+
commercial CI/CD pipelines requires a commercial license from the Licensor.
|
|
23
|
+
|
|
24
|
+
Hosting & Managed Service Restriction:
|
|
25
|
+
You may not provide the Licensed Work, whether modified or unmodified, as a hosted service,
|
|
26
|
+
managed QA service, or cloud testing platform to third parties without prior written consent.
|
|
27
|
+
|
|
28
|
+
Change Date:
|
|
29
|
+
2030-09-14
|
|
30
|
+
|
|
31
|
+
Change License:
|
|
32
|
+
Apache License, Version 2.0
|
|
33
|
+
|
|
34
|
+
Notice:
|
|
35
|
+
For commercial licensing inquiries, enterprise agreements, or custom SLAs, contact:
|
|
36
|
+
PromptTest (https://github.com/shriramsingh/promptTest)
|
package/LICENSES.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Open Source Software Licenses & Bill of Materials (SBOM)
|
|
2
|
+
|
|
3
|
+
PromptTest is licensed under the [Business Source License 1.1 (BSL 1.1)](LICENSE).
|
|
4
|
+
|
|
5
|
+
This document catalogs third-party dependencies utilized by PromptTest, their licenses, and compliance attestations.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## License Compliance Attestation
|
|
10
|
+
|
|
11
|
+
- **Zero Copyleft / Zero GPL**: PromptTest does **not** link against or distribute any code licensed under GPL, LGPL, AGPL, or other reciprocal copyleft licenses.
|
|
12
|
+
- **Enterprise Friendly**: All runtime dependencies use widely accepted permissive licenses (MIT, ISC, Apache-2.0), making PromptTest safe for commercial and proprietary enterprise deployments.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Production Runtime Dependencies
|
|
17
|
+
|
|
18
|
+
| Package | Version | License | Primary Purpose | Home / Repository |
|
|
19
|
+
| :------------- | :------- | :------ | :--------------------------------------------- | :----------------------------------- |
|
|
20
|
+
| **chalk** | `^5.3.0` | MIT | Terminal colorization and CLI styling | https://github.com/chalk/chalk |
|
|
21
|
+
| **pixelmatch** | `^7.2.0` | ISC | Visual pixel-by-pixel regression image diffing | https://github.com/mapbox/pixelmatch |
|
|
22
|
+
| **pngjs** | `^7.0.0` | MIT | PNG image encoding and decoding | https://github.com/lukeapage/pngjs |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Development & Build Dependencies
|
|
27
|
+
|
|
28
|
+
| Package | Version | License | Purpose |
|
|
29
|
+
| :---------------------- | :--------- | :--------- | :------------------------------------ |
|
|
30
|
+
| **typescript** | `^5.7.2` | Apache-2.0 | Static type checking and compiler |
|
|
31
|
+
| **vitest** | `^5.0.0` | MIT | Fast unit and integration test runner |
|
|
32
|
+
| **eslint** | `^10.10.0` | MIT | Code quality and lint analysis |
|
|
33
|
+
| **prettier** | `^3.9.6` | MIT | Opinionated code formatter |
|
|
34
|
+
| **tsx** | `^4.19.2` | MIT | TypeScript execution engine |
|
|
35
|
+
| **@vitest/coverage-v8** | `^5.0.0` | MIT | V8 code coverage provider |
|
|
36
|
+
| **typescript-eslint** | `^8.70.0` | MIT | TypeScript ESLint tooling |
|
|
37
|
+
| **@types/node** | `^22.10.2` | MIT | Node.js TypeScript definitions |
|
|
38
|
+
| **@types/pixelmatch** | `^5.2.6` | MIT | Pixelmatch TypeScript definitions |
|
|
39
|
+
| **@types/pngjs** | `^6.0.5` | MIT | PNGjs TypeScript definitions |
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Full License Texts
|
|
44
|
+
|
|
45
|
+
### MIT License
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
49
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
50
|
+
in the Software without restriction, including without limitation the rights
|
|
51
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
52
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
53
|
+
furnished to do so, subject to the following conditions:
|
|
54
|
+
|
|
55
|
+
The above copyright notice and this permission notice shall be included in all
|
|
56
|
+
copies or substantial portions of the Software.
|
|
57
|
+
|
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
59
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
60
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
61
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
62
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
63
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
64
|
+
SOFTWARE.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### ISC License
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
71
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
72
|
+
copyright notice and this permission notice appear in all copies.
|
|
73
|
+
|
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
75
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
76
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
77
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
78
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
79
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
80
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
81
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# โก PromptTest
|
|
2
|
+
|
|
3
|
+
> **Ultra-fast, zero-code autonomous mobile testing & visual QA brain for Android.**
|
|
4
|
+
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](https://developer.android.com/tools/adb)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
**PromptTest** allows QA engineers, developers, and autonomous agents to test Android applications using **plain-English natural language scripts**. It eliminates heavy frameworks like Appium, Selenium, or WebDriver in favor of high-performance native ADB streams, expectation-driven polling, and a self-learning autonomous memory engine.
|
|
11
|
+
|
|
12
|
+
๐ **[Read the Full User Manual (docs/USER_MANUAL.md)](docs/USER_MANUAL.md)** โข ๐ฏ **[Mode Expectations & Limits (docs/MODE_EXPECTATIONS.md)](docs/MODE_EXPECTATIONS.md)** โข ๐ **[Interactive Web Manual (docs/index.html)](docs/index.html)** โข ๐ **[System Architecture (docs/ARCHITECTURE.md)](docs/ARCHITECTURE.md)**
|
|
13
|
+
|
|
14
|
+
> โ ๏ธ **Honest expectations:** PromptTest is a fast UIโtree automation engine over ADB. It excels on standard, accessibilityโexposed screens (React Native, Expo, Flutter, Native/Compose); fullyโdrawn games/canvas and unlabeled iconโonly controls are platformโlimited. See **[docs/MODE_EXPECTATIONS.md](docs/MODE_EXPECTATIONS.md)** for exactly what each mode can and cannot do.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ๐ Why PromptTest?
|
|
19
|
+
|
|
20
|
+
- ๐ **Plain-English Test Scripts**: Write tests in human language without writing selectors, XPath, or glue code.
|
|
21
|
+
- โก **Sub-Second per-step Execution**: Direct native ADB hierarchy streaming and dynamic expectation polling (no blind `sleep()` timeouts).
|
|
22
|
+
- ๐ง **Autonomous Knowledge Engine**: Remembers element mappings, accessibility descriptors, and screen transitions to fast-forward future test runs.
|
|
23
|
+
- ๐ **Universal Across Frameworks**: Works on React Native, Expo, Flutter, Native Android (Kotlin/Java), and Jetpack Compose โ for standard, accessibility-exposed UI (games/canvas are platform-limited).
|
|
24
|
+
- ๐ก **Smart Pre-Fail Triage**: Automatically resolves modal dialog collisions, auto-scrolls when elements are below the fold, and handles Android gesture insets.
|
|
25
|
+
- ๐ธ **Failure-Only Blackbox Diagnostics**: Keeps test runs ultra-fast and lightweight while capturing high-resolution visual evidence and actionable diffs upon assertion failures.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## ๐ Quick Start
|
|
30
|
+
|
|
31
|
+
### Prerequisites
|
|
32
|
+
|
|
33
|
+
1. **Node.js 18.0.0+** (Required for ES2022 features, native module resolution, and Unicode property escapes `\p{Extended_Pictographic}`).
|
|
34
|
+
2. **Android ADB** installed and accessible in your system `PATH`.
|
|
35
|
+
3. An Android device or emulator with **USB Debugging** enabled.
|
|
36
|
+
4. _Language Support_: The default seed dictionary covers English mobile UI interactions. Applications localized in other languages work via direct label matching or custom specifications.
|
|
37
|
+
|
|
38
|
+
### Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Clone the repository
|
|
42
|
+
git clone https://github.com/<your-username>/prompttest.git
|
|
43
|
+
cd prompttest
|
|
44
|
+
|
|
45
|
+
# Install dependencies
|
|
46
|
+
npm install
|
|
47
|
+
|
|
48
|
+
# Build TypeScript
|
|
49
|
+
npm run build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Connect Your Device
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Verify device connection
|
|
56
|
+
npm run devices
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## โ๏ธ Writing Plain-English Tests
|
|
62
|
+
|
|
63
|
+
Test specs are simple text files containing numbered steps written in conversational English.
|
|
64
|
+
|
|
65
|
+
### Example Spec (`specs/login_and_dashboard.txt`)
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
# 1. Authentication
|
|
69
|
+
1. Type 'ramesh@coachconnect.app' into 'Email Address'
|
|
70
|
+
2. Type 'Teacher@1234' into 'Password'
|
|
71
|
+
3. Tap 'Sign In'
|
|
72
|
+
4. Wait 3s
|
|
73
|
+
|
|
74
|
+
# 2. Dashboard Verification
|
|
75
|
+
5. Verify 'Apex Coaching Academy' is visible
|
|
76
|
+
6. Verify 'Dr. Ramesh Sharma' is visible
|
|
77
|
+
7. Verify 'My Batches' is visible
|
|
78
|
+
|
|
79
|
+
# 3. Batches Module
|
|
80
|
+
8. Tap 'Batches'
|
|
81
|
+
9. Verify 'Batches & Schedules' is visible
|
|
82
|
+
10. Tap 'Grade 10 Mathematics'
|
|
83
|
+
11. Verify 'Weekly Schedule' is visible
|
|
84
|
+
12. Press back
|
|
85
|
+
|
|
86
|
+
# 4. Sign Out Flow
|
|
87
|
+
13. Tap 'Profile'
|
|
88
|
+
14. Tap 'Sign Out'
|
|
89
|
+
15. Tap 'Sign Out'
|
|
90
|
+
16. Verify 'Welcome Back' is visible
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## ๐ Plain-English & AST Syntax Reference
|
|
96
|
+
|
|
97
|
+
### Primitive Actions & UI Interactions
|
|
98
|
+
|
|
99
|
+
| Action | Example Syntax | Description |
|
|
100
|
+
| :----------------- | :------------------------------------ | :---------------------------------------------------------------- |
|
|
101
|
+
| **Type / Input** | `Type 'user@domain.com' into 'Email'` | Clears existing text and types the value into the matching input. |
|
|
102
|
+
| **Tap / Click** | `Tap 'Sign In'` | Clicks button, tab, link, or icon with exact boundary resolution. |
|
|
103
|
+
| **Long Press** | `Long press 'Student Card'` | Long presses an element for 1000ms. |
|
|
104
|
+
| **Verify Visible** | `Verify 'Dashboard' is visible` | Polls until the text or accessibility label appears on screen. |
|
|
105
|
+
| **Verify State** | `Verify 'Submit' is disabled` | Verifies element enablement state (`enabled` / `disabled`). |
|
|
106
|
+
| **Press Back** | `Press back` | Emits Android system `KEYCODE_BACK`. |
|
|
107
|
+
| **Scroll / Swipe** | `Scroll down` or `Scroll up` | Proportional responsive swipe along the screen viewport. |
|
|
108
|
+
| **Relative Tap** | `Tap 'Delete' next to 'Rohan Gupta'` | Disambiguates duplicate elements using spatial proximity. |
|
|
109
|
+
| **Wait** | `Wait 3s` or `Wait 1500ms` | Pauses execution for custom animation delays. |
|
|
110
|
+
|
|
111
|
+
### Flow Control, Subflows & Programmatic Logic
|
|
112
|
+
|
|
113
|
+
| Feature | Example Syntax | Description |
|
|
114
|
+
| :------------------ | :----------------------------------------- | :----------------------------------------------------- |
|
|
115
|
+
| **Conditional** | `IF 'Promo' is visible ... ELSE ... ENDIF` | Executes branch based on live element presence. |
|
|
116
|
+
| **Loop** | `LOOP 3 ... ENDLOOP` | Repeats child step block N times. |
|
|
117
|
+
| **Wait Until** | `WAIT_UNTIL 'Ready' is visible (10s)` | Explicit polling wait with max timeout budget. |
|
|
118
|
+
| **Subflow Include** | `#include <specs/login.txt>` | Inlines modular specs with circular dependency guards. |
|
|
119
|
+
| **Variables** | `SET $token = 'xyz'` | Sets local variable for interpolation (`$token`). |
|
|
120
|
+
| **Sandboxed JS** | `RUN_JS return { status: 200 }` | Executes deterministic JavaScript expressions. |
|
|
121
|
+
|
|
122
|
+
### Data-Driven Testing & Dynamic Generators
|
|
123
|
+
|
|
124
|
+
Embed inline JSON datasets using `#!data` or load via CSV/JSON:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
#!data [
|
|
128
|
+
{"user": "Alice", "email": "$random.email"},
|
|
129
|
+
{"user": "Bob", "email": "$random.email"}
|
|
130
|
+
]
|
|
131
|
+
1. Type '$user' into 'Username'
|
|
132
|
+
2. Type '$email' into 'Email'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Supported Generators**:
|
|
136
|
+
|
|
137
|
+
- Synthetic Data: `$random.firstName`, `$random.lastName`, `$random.email`, `$random.phone`, `$random.string(8)`
|
|
138
|
+
- Sequences & UUIDs: `$seq.id`, `$uuid`
|
|
139
|
+
- Date & Time: `$date.now`, `$date.iso`, `$date.format('YYYY-MM-DD')`
|
|
140
|
+
- Math Evaluation: `$calc($count + 1)`
|
|
141
|
+
|
|
142
|
+
### Integration Assertions & Device State
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
# OTP & API Verification
|
|
146
|
+
1. CAPTURE OTP from SMS into $code
|
|
147
|
+
2. Type '$code' into 'Verification Code'
|
|
148
|
+
3. API GET 'https://api.example.com/user/profile' EXPECT status 200
|
|
149
|
+
4. VERIFY EMAIL to 'test@domain.com' subject 'Welcome'
|
|
150
|
+
|
|
151
|
+
# Device Simulation
|
|
152
|
+
5. Set network to offline
|
|
153
|
+
6. Set battery level to 20
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## ๐ฅ CLI Usage
|
|
159
|
+
|
|
160
|
+
### Run a Test Spec
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Run a test script against an app package
|
|
164
|
+
npx prompttest run specs/my_suite.txt host.exp.exponent
|
|
165
|
+
|
|
166
|
+
# Run with full visual screenshots on every step
|
|
167
|
+
npx prompttest run specs/my_suite.txt host.exp.exponent --screenshots all
|
|
168
|
+
|
|
169
|
+
# Run data-driven iterations
|
|
170
|
+
npx prompttest run specs/checkout.txt host.exp.exponent --iterations 5 --only-row 2
|
|
171
|
+
|
|
172
|
+
# Run against a managed device pool with concurrency leasing
|
|
173
|
+
npx prompttest run specs/suite.txt host.exp.exponent --device-pool emulator-5554,emulator-5556 --device-timeout-secs 30
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### CLI Flags Reference
|
|
177
|
+
|
|
178
|
+
| Flag | Description |
|
|
179
|
+
| :--------------------------------------- | :-------------------------------------------------------------------------- |
|
|
180
|
+
| `--fresh` | Force-stops and restarts target app before test begins. |
|
|
181
|
+
| `--device-pool <d1,d2>` | Executes against the first available device from pool using atomic locking. |
|
|
182
|
+
| `--device-timeout-secs <n>` | Maximum seconds to wait for a free device lock (default: 60s). |
|
|
183
|
+
| `--iterations <n>` | Executes spec across N dynamic data iterations. |
|
|
184
|
+
| `--only-row <n>` | Filters execution to a specific 1-indexed data row. |
|
|
185
|
+
| `--continue` / `--continue-on-failure` | Continues running remaining steps after failure instead of fast-failing. |
|
|
186
|
+
| `--screenshots <all\|failure\|none>` | Controls screenshot capture policy (default: `failure`). |
|
|
187
|
+
| `--save-baseline` / `--update-baselines` | Saves gold reference baseline images for visual regression. |
|
|
188
|
+
| `--compare-baseline` | Compares execution screens against reference baseline. |
|
|
189
|
+
| `--baseline-threshold <n>` | Sets allowable perceptual diff tolerance (e.g. 0.02 = 2%). |
|
|
190
|
+
| `--format <html,json,junit,markdown>` | Comma-separated output report formats. |
|
|
191
|
+
| `-s <serial>` | Targets a specific connected device serial. |
|
|
192
|
+
| `--version` / `-v` | Prints current PromptTest version. |
|
|
193
|
+
|
|
194
|
+
### Other Commands
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Connect to a device wirelessly over Wi-Fi
|
|
198
|
+
npx prompttest wifi 192.168.1.50
|
|
199
|
+
|
|
200
|
+
# Disconnect wireless device
|
|
201
|
+
npx prompttest disconnect
|
|
202
|
+
|
|
203
|
+
# Interactive record-and-play session
|
|
204
|
+
npx prompttest record specs/login.txt
|
|
205
|
+
|
|
206
|
+
# Inspect foreground app and active components on screen
|
|
207
|
+
npx prompttest status
|
|
208
|
+
|
|
209
|
+
# Run comprehensive environment and ADB readiness diagnostics
|
|
210
|
+
npx prompttest doctor
|
|
211
|
+
|
|
212
|
+
# Start interactive live REPL sandbox for prototyping test steps
|
|
213
|
+
npx prompttest repl
|
|
214
|
+
|
|
215
|
+
# Merge multi-device test results and generate Atto-inspired release confidence dashboard
|
|
216
|
+
npx prompttest merge-reports output
|
|
217
|
+
|
|
218
|
+
# Automatically crawl and map the app (Autonomous State-Graph Crawler v3)
|
|
219
|
+
npx prompttest explore host.exp.exponent
|
|
220
|
+
|
|
221
|
+
# Run autonomous crawl with strict safety policy and custom domain blacklist
|
|
222
|
+
npx prompttest explore host.exp.exponent --safety-mode=strict --safety-blacklist="Transfer,Revoke,Publish"
|
|
223
|
+
|
|
224
|
+
# Deep exploration with custom screen/step budgets and lazy failure-only screenshots
|
|
225
|
+
npx prompttest explore host.exp.exponent --max-screens=30 --step-budget=60 --screenshots=failure-only
|
|
226
|
+
|
|
227
|
+
# View learned component aliases & confidence
|
|
228
|
+
npx prompttest memory host.exp.exponent
|
|
229
|
+
|
|
230
|
+
# Generate GitHub Actions CI workflow
|
|
231
|
+
npx prompttest init-ci
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Autonomous Exploration Flags (`explore`)
|
|
235
|
+
|
|
236
|
+
| Flag | Default | Description | Example |
|
|
237
|
+
| :------------------------- | :------------- | :----------------------------------------------------------------------------------------------------------------- | :--------------------------------- |
|
|
238
|
+
| `--safety-mode=<mode>` | `strict` | Policy level: `strict` (all deletions blocked), `moderate` (drafts permitted), `interactive` (prompts), `disabled` | `--safety-mode=moderate` |
|
|
239
|
+
| `--safety-blacklist="..."` | `[]` | Comma-separated custom keywords to protect as destructive actions | `--safety-blacklist="Revoke,Wipe"` |
|
|
240
|
+
| `--max-screens=N` | `20` | Maximum unique screen states to discover and index | `--max-screens=50` |
|
|
241
|
+
| `--max-depth=N` | `3` | Maximum recursion depth for nested screen diving | `--max-depth=5` |
|
|
242
|
+
| `--step-budget=N` | `40` | Total interaction steps before completing exploration | `--step-budget=100` |
|
|
243
|
+
| `--screenshots=<mode>` | `state-change` | Image capture policy: `state-change`, `failure-only`, or `all` | `--screenshots=failure-only` |
|
|
244
|
+
| `-s <serial>` | auto | Target specific connected device serial | `-s GEVKDEUWOJWC89OR` |
|
|
245
|
+
|
|
246
|
+
### CLI Execution Flags (`run`)
|
|
247
|
+
|
|
248
|
+
| Flag | Description | Example |
|
|
249
|
+
| :--------------- | :----------------------------------------------------------- | :----------------------------------------------- |
|
|
250
|
+
| `--dry-run` | Validates and parses spec steps with 0 device execution | `prompttest run specs/flow.txt --dry-run` |
|
|
251
|
+
| `--list-steps` | Prints a formatted table of all parsed steps in the spec | `prompttest run specs/flow.txt --list-steps` |
|
|
252
|
+
| `--only=<range>` | Executes only specific step numbers or ranges (e.g. `2-5,8`) | `prompttest run specs/flow.txt --only="1-3,5"` |
|
|
253
|
+
| `--tags=<tags>` | Filters execution by tags declared via `# @tag: <name>` | `prompttest run specs/flow.txt --tags="smoke"` |
|
|
254
|
+
| `--json` | Outputs machine-readable run summary JSON to stdout | `prompttest run specs/flow.txt --json` |
|
|
255
|
+
| `--benchmark` | Profiles and logs execution duration for each step | `prompttest run specs/flow.txt --benchmark` |
|
|
256
|
+
| `--watch` | Watches spec file for changes and re-executes automatically | `prompttest run specs/flow.txt --watch` |
|
|
257
|
+
| `--fresh` | Force-stops and restarts target app before execution | `prompttest run specs/flow.txt --fresh` |
|
|
258
|
+
| `--all-devices` | Concurrently executes spec across all connected devices | `prompttest run specs/flow.txt --all-devices` |
|
|
259
|
+
| `--continue` | Continues executing remaining steps if a step fails | `prompttest run specs/flow.txt --continue` |
|
|
260
|
+
| `--var:K=V` | Injects runtime variable overrides into the test context | `prompttest run specs/flow.txt --var:USER=Alice` |
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## ๐ณ Docker Container Deployment
|
|
265
|
+
|
|
266
|
+
PromptTest is fully containerized with Android platform-tools and headless runtime support:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Build Docker image
|
|
270
|
+
docker build -t prompttest .
|
|
271
|
+
|
|
272
|
+
# Run test spec inside container sharing host ADB daemon
|
|
273
|
+
docker run --rm --net=host \
|
|
274
|
+
-v $(pwd)/specs:/app/specs \
|
|
275
|
+
-v $(pwd)/output:/app/output \
|
|
276
|
+
prompttest run specs/my_suite.txt com.example.app
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## ๐ Architecture & Execution Pipeline
|
|
282
|
+
|
|
283
|
+
```mermaid
|
|
284
|
+
flowchart TD
|
|
285
|
+
A[Plain-English Spec .txt] --> B[DSL Parser & Tokenizer]
|
|
286
|
+
B --> C[PromptRunner Engine]
|
|
287
|
+
C --> D{Expectation Poller}
|
|
288
|
+
D -->|Match Found| E[ADB Fast Native Driver]
|
|
289
|
+
D -->|Not Found| F[Pre-Fail Triage / Auto-Scroll]
|
|
290
|
+
F -->|Recovered| E
|
|
291
|
+
F -->|Failed| G[Diagnostic Blackbox Snapshot]
|
|
292
|
+
E --> H[Screen Execution & Settle]
|
|
293
|
+
H --> I[Autonomous Knowledge Memory Engine]
|
|
294
|
+
I --> J[Markdown & JSON QA Reports]
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Key Components
|
|
298
|
+
|
|
299
|
+
1. **High-Performance ADB Driver (`lib/adb.ts`)**: Native process streaming for zero-latency screen hierarchy dumps and coordinate dispatching.
|
|
300
|
+
2. **Dynamic Expectation Poller (`lib/prompt-runner.ts`)**: Instant 0ms cache pass when screens match, dynamically polling for state transitions without rigid sleep constants.
|
|
301
|
+
3. **Autonomous Knowledge Engine (`lib/memory.ts`)**: Persists successful UI mappings into `memory/<package>.json` to accelerate future runs.
|
|
302
|
+
4. **Visual QA Sentinel (`lib/crawler.ts`)**: Scans for layout overflow, overlapping views, and unlabelled accessibility nodes.
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## ๐ Real-World Verification Benchmarks
|
|
307
|
+
|
|
308
|
+
Tested and verified against live physical Android devices running complex multi-role enterprise apps (React Native / Expo):
|
|
309
|
+
|
|
310
|
+
| Test Suite | Total Steps | Passed | Failed | Pass Rate | Execution Time |
|
|
311
|
+
| :--------------------- | :---------: | :----: | :----: | :-------: | :------------: |
|
|
312
|
+
| **Teacher Role Suite** | 36 | 36 | 0 | **100%** | 64.0s |
|
|
313
|
+
| **Student Role Suite** | 24 | 24 | 0 | **100%** | 44.6s |
|
|
314
|
+
| **Total Benchmark** | **60** | **60** | **0** | **100%** | **108.6s** |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## ๐ Repository Structure
|
|
319
|
+
|
|
320
|
+
```text
|
|
321
|
+
prompttest/
|
|
322
|
+
โโโ bin/
|
|
323
|
+
โ โโโ prompttest.ts # CLI Entrypoint & Argument Router
|
|
324
|
+
โโโ constants/
|
|
325
|
+
โ โโโ commands.ts # ADB Commands & Keycode Constants
|
|
326
|
+
โโโ docs/
|
|
327
|
+
โ โโโ ACTION_ITEMS.md # Working fix backlog (Phase 23 findings)
|
|
328
|
+
โ โโโ MODE_EXPECTATIONS.md # Realistic capabilities, limits & boundaries per mode
|
|
329
|
+
โ โโโ ARCHITECTURE.md # System Architecture & Design
|
|
330
|
+
โ โโโ USER_MANUAL.md # Comprehensive User Guide
|
|
331
|
+
โ โโโ adr/ # Architecture Decision Records
|
|
332
|
+
โ โโโ IMPLEMENTATION_PLAN.md
|
|
333
|
+
โโโ lib/
|
|
334
|
+
โ โโโ adb.ts # ADB Interface & Streaming Driver
|
|
335
|
+
โ โโโ baseline.ts # Visual Baseline Diffing & Masking
|
|
336
|
+
โ โโโ checkpoint.ts # Test Progress Checkpointing
|
|
337
|
+
โ โโโ config.ts # Configuration Constants
|
|
338
|
+
โ โโโ crawler.ts # Visual Defect Detection & Screen Crawling
|
|
339
|
+
โ โโโ data-loader.ts # Data-Driven Iterations & Dynamic Generators
|
|
340
|
+
โ โโโ dictionary.ts # UI Taxonomy & Intent Dictionary
|
|
341
|
+
โ โโโ explorer.ts # Autonomous Exploration Graph
|
|
342
|
+
โ โโโ form-filler.ts # Smart Form Filling Engine
|
|
343
|
+
โ โโโ live-monitor.ts # Real-Time Event Streaming Server
|
|
344
|
+
โ โโโ lock.ts # File-Locking Device Leasing Mutex
|
|
345
|
+
โ โโโ logger.ts # Structured Logging
|
|
346
|
+
โ โโโ memory.ts # Persistent Knowledge & Fast-Forward Engine
|
|
347
|
+
โ โโโ patterns.ts # Plain-English Grammar Parser
|
|
348
|
+
โ โโโ prompt-runner.ts # Orchestration Engine (<1000 lines)
|
|
349
|
+
โ โโโ recorder.ts # Autonomous Record & Replay
|
|
350
|
+
โ โโโ reporter.ts # Multi-Format Report Generator (HTML/JSON/JUnit)
|
|
351
|
+
โ โโโ runner-utils.ts # AST Parsing, Modular Includes, Diagnostic Errors
|
|
352
|
+
โ โโโ step-handlers.ts # Decoupled Step Execution Handlers
|
|
353
|
+
โโโ memory/ # Autonomous Learned Knowledge Mappings
|
|
354
|
+
โโโ output/ # Generated Test Reports & Artifacts
|
|
355
|
+
โโโ specs/ # Plain-English Test Specification Files
|
|
356
|
+
โโโ tests/ # Vitest Automated Test Suites
|
|
357
|
+
โโโ index.ts # Programmatic API Entrypoint
|
|
358
|
+
โโโ package.json
|
|
359
|
+
โโโ tsconfig.json
|
|
360
|
+
โโโ CONTRIBUTING.md
|
|
361
|
+
โโโ LICENSE
|
|
362
|
+
โโโ README.md
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## ๐ป Programmatic SDK & Cross-Platform Drivers
|
|
368
|
+
|
|
369
|
+
You can use PromptTest programmatically within your own Node.js scripts using the unified `DriverInterface`:
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { createPromptRunner, createAndroidDriver, createIosDriver } from 'prompttest';
|
|
373
|
+
|
|
374
|
+
// ๐ค Android Native Execution
|
|
375
|
+
const androidDriver = createAndroidDriver('DEVICE_SERIAL');
|
|
376
|
+
const androidRunner = createPromptRunner(androidDriver);
|
|
377
|
+
const androidReport = await androidRunner.runSpec('specs/login.txt', 'com.example.app');
|
|
378
|
+
|
|
379
|
+
// ๐ iOS Execution (Simulator or Physical Device)
|
|
380
|
+
const iosDriver = createIosDriver({ udid: 'SIMULATOR_UDID', bundleId: 'com.example.app' });
|
|
381
|
+
const iosRunner = createPromptRunner(iosDriver);
|
|
382
|
+
const iosReport = await iosRunner.runSpec('specs/login.txt', 'com.example.app');
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## โ๏ธ Environment Variables
|
|
388
|
+
|
|
389
|
+
- `LOG_LEVEL`: Controls the verbosity of logs. Set to `DEBUG`, `INFO`, `WARN`, `ERROR`, or `SILENT`.
|
|
390
|
+
- `PROMPTTEST_DATA`: Overrides the default directory for PromptTest artifacts, memory, and outputs.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## ๐ค Contributing
|
|
395
|
+
|
|
396
|
+
Contributions, bug reports, and feature requests are welcome! Please check out [CONTRIBUTING.md](CONTRIBUTING.md) to get started.
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## ๐ License
|
|
401
|
+
|
|
402
|
+
This project is open source and available under the [MIT License](LICENSE).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Security & Compliance Policy
|
|
2
|
+
|
|
3
|
+
PromptTest is built with enterprise security, local execution privacy, and data isolation at its foundation.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Local-First Architecture Guarantee
|
|
8
|
+
|
|
9
|
+
- **Zero Telemetry**: PromptTest does **not** collect, phone-home, or transmit usage metrics, telemetry, crash reports, or device serials to external cloud servers.
|
|
10
|
+
- **Offline By Default**: Core test execution, OCR/UI parsing, accessibility hierarchy processing, and self-healing memory operate 100% locally via ADB and offline deterministic heuristics.
|
|
11
|
+
- **Opt-in AI**: External LLM providers (OpenAI, Anthropic) are strictly opt-in and disabled by default. When enabled, only stripped element text fragments necessary for intent matching are transmitted; full app memory or credential payloads are never forwarded. Local model inference (e.g. Ollama via `PROMPTTEST_AI_BASE_URL`) is fully supported for air-gapped environments.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 2. Reporting Vulnerabilities
|
|
16
|
+
|
|
17
|
+
If you discover a security vulnerability within PromptTest or its dependencies, please disclose it responsibly.
|
|
18
|
+
|
|
19
|
+
- **Security Contact**: Email security reports privately to `security@prompttest.dev` (or open a confidential security advisory on GitHub).
|
|
20
|
+
- **Response SLA**:
|
|
21
|
+
- Initial acknowledgment: within **24 hours**.
|
|
22
|
+
- Triage and impact assessment: within **72 hours**.
|
|
23
|
+
- Remediation patch release: within **7 days** for critical/high vulnerabilities.
|
|
24
|
+
- **Public Disclosure**: We kindly ask that you do not disclose the vulnerability publicly until a patch has been published.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 3. Secret & Credential Handling Best Practices
|
|
29
|
+
|
|
30
|
+
When writing PromptTest specifications and configuring CI/CD pipelines:
|
|
31
|
+
|
|
32
|
+
1. **Never Hardcode Secrets in Specs**:
|
|
33
|
+
Use runtime variables (`--var:KEY=VAL`) or environment variables instead of hardcoding API keys, OTP codes, or passwords directly in `.txt` test files.
|
|
34
|
+
```bash
|
|
35
|
+
npx prompttest run specs/login.txt --var:USER=$TEST_USER --var:PASS=$TEST_PASS
|
|
36
|
+
```
|
|
37
|
+
2. **Sanitize Data-Driven Test Fixtures**:
|
|
38
|
+
Store data files in `.gitignore` if they contain sensitive real-world records. Ensure `test-data.json` and credentials are never checked into version control.
|
|
39
|
+
3. **Automated Secret Masking**:
|
|
40
|
+
PromptTest automatically masks input values targeting elements associated with passwords, PINs, auth tokens, or private secrets in execution logs and HTML reports.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 4. Execution Sandboxing
|
|
45
|
+
|
|
46
|
+
- **JavaScript Execution**: Custom JS hooks (`run js: ...`) execute in an isolated V8 context without direct access to Node.js `child_process`, `fs`, or network APIs.
|
|
47
|
+
- **ADB Boundaries**: ADB execution is strictly scoped to test automation verbs (`shell input`, `shell uiautomator`, `shell am`, `shell pm`). Arbitrary device shell injection is prohibited.
|
|
48
|
+
- **Concurrency Mutex**: Device-level file locking ensures concurrent test jobs cannot collide, cross-contaminate device states, or intercept parallel device streams.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 5. Dependency & Supply Chain Security
|
|
53
|
+
|
|
54
|
+
- **Strict Audit Gate**: CI enforces `npm audit --audit-level=high` on every pull request and build.
|
|
55
|
+
- **Zero Copyleft**: All runtime dependencies are strictly licensed under permissive open-source licenses (MIT / ISC / Apache-2.0).
|
|
56
|
+
- **Minimal Surface**: Production dependencies are strictly minimized (`chalk`, `pixelmatch`, `pngjs`) to minimize supply chain exposure.
|