cursortoys 0.2.0 → 0.4.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/README.md +100 -107
- package/dist/assertionParser.d.ts.map +1 -1
- package/dist/assertionParser.js +2 -3
- package/dist/assertionParser.js.map +1 -1
- package/dist/assertionValidator.d.ts +1 -0
- package/dist/assertionValidator.d.ts.map +1 -1
- package/dist/assertionValidator.js +7 -57
- package/dist/assertionValidator.js.map +1 -1
- package/dist/banner.d.ts +7 -0
- package/dist/banner.d.ts.map +1 -0
- package/dist/banner.js +60 -0
- package/dist/banner.js.map +1 -0
- package/dist/cli.js +76 -9
- package/dist/cli.js.map +1 -1
- package/dist/commands/http-test.d.ts +2 -1
- package/dist/commands/http-test.d.ts.map +1 -1
- package/dist/commands/http-test.js +307 -178
- package/dist/commands/http-test.js.map +1 -1
- package/dist/commands/skill-add.d.ts.map +1 -1
- package/dist/commands/skill-add.js +14 -23
- package/dist/commands/skill-add.js.map +1 -1
- package/dist/commands/skill-install.d.ts +25 -0
- package/dist/commands/skill-install.d.ts.map +1 -0
- package/dist/commands/skill-install.js +116 -0
- package/dist/commands/skill-install.js.map +1 -0
- package/dist/projectEnv.d.ts +19 -0
- package/dist/projectEnv.d.ts.map +1 -0
- package/dist/projectEnv.js +80 -0
- package/dist/projectEnv.js.map +1 -0
- package/dist/responseChain.d.ts +25 -0
- package/dist/responseChain.d.ts.map +1 -0
- package/dist/responseChain.js +86 -0
- package/dist/responseChain.js.map +1 -0
- package/dist/responseChainParser.d.ts +22 -0
- package/dist/responseChainParser.d.ts.map +1 -0
- package/dist/responseChainParser.js +94 -0
- package/dist/responseChainParser.js.map +1 -0
- package/dist/responseExpression.d.ts +15 -0
- package/dist/responseExpression.d.ts.map +1 -0
- package/dist/responseExpression.js +59 -0
- package/dist/responseExpression.js.map +1 -0
- package/dist/skillsPaths.d.ts +22 -0
- package/dist/skillsPaths.d.ts.map +1 -0
- package/dist/skillsPaths.js +78 -0
- package/dist/skillsPaths.js.map +1 -0
- package/llms.txt +68 -104
- package/package.json +3 -1
- package/resources/skills/cursor-toys-http/SKILL.md +208 -0
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ Command-line utilities for CursorToys: HTTP testing, skill management, automatio
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- **HTTP Testing**: Run `.req` / `.request` files as automated tests
|
|
8
|
+
- **Skill Management**: Create and manage AI agent skills
|
|
9
|
+
- **LLM Instructions**: Built-in usage guide for LLMs
|
|
10
|
+
- **Productivity Tools**: Utilities for development workflow
|
|
11
11
|
|
|
12
12
|
## Requirements
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ npm install -g cursortoys-cli
|
|
|
25
25
|
### Use with npx (no installation)
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
npx cursortoys
|
|
28
|
+
npx cursortoys http test
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### Local Development
|
|
@@ -41,9 +41,7 @@ npm link
|
|
|
41
41
|
|
|
42
42
|
### HTTP Testing
|
|
43
43
|
|
|
44
|
-
Run HTTP request files (`.req` / `.request`) from the project's `http` folder as automated tests. Uses the same format and behavior as the CursorToys VS Code extension (REST Client format, `# @var`, `# @env`, `{{VAR}}`, `.env` files)
|
|
45
|
-
|
|
46
|
-
### HTTP Testing
|
|
44
|
+
Run HTTP request files (`.req` / `.request`) from the project's `http` folder as automated tests. Uses the same format and behavior as the CursorToys VS Code extension (REST Client format, `# @var`, `# @env`, `{{VAR}}`, project-root `.env` files).
|
|
47
45
|
|
|
48
46
|
#### Run all HTTP tests
|
|
49
47
|
|
|
@@ -53,13 +51,15 @@ From the project root (where `.cursor/http/` or your configured base folder live
|
|
|
53
51
|
cursortoys http test
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
Discovers all `.req` and `.request` files under the `http` folder (
|
|
54
|
+
Discovers all `.req` and `.request` files under the `http` folder (recursively), runs every request block in each file, and reports pass/fail. A request **passes** when status is 2xx, or when all `@assert` blocks pass (assertions override status).
|
|
57
55
|
|
|
58
|
-
#### Run a single file
|
|
56
|
+
#### Run a single file or folder
|
|
59
57
|
|
|
60
58
|
```bash
|
|
61
59
|
cursortoys http test --file path/to/file.req
|
|
62
60
|
cursortoys http test -f .cursor/http/api.req
|
|
61
|
+
cursortoys http test -f .cursor/http/auth
|
|
62
|
+
cursortoys http test --folder auth
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
#### HTTP Test Options
|
|
@@ -68,28 +68,36 @@ cursortoys http test -f .cursor/http/api.req
|
|
|
68
68
|
|-------|-------------|
|
|
69
69
|
| `-p, --project <dir>` | Project directory (default: current working directory) |
|
|
70
70
|
| `--base-folder <name>` | Base folder name (default: `cursor`; or set `CURSORTOYS_BASE_FOLDER`) |
|
|
71
|
-
|
|
|
72
|
-
| `-e, --env <name>` | Environment to use; overrides `# @env` in the file (default when not set: `dev`) |
|
|
71
|
+
| `-e, --env <name>` | Environment to use; overrides `# @env` in the file (default: `dev`) |
|
|
73
72
|
| `-t, --timeout <seconds>` | Request timeout in seconds (default: `10`) |
|
|
74
|
-
| `-f, --file <path>` | Run a single
|
|
75
|
-
|
|
|
76
|
-
|
|
|
73
|
+
| `-f, --file <path>` | Run a single file or all request files in a directory |
|
|
74
|
+
| `--folder <path>` | Run all request files under a subfolder of the http directory |
|
|
75
|
+
| `-V, --verbose` | Show request and response for each test |
|
|
76
|
+
| `--var <key=value>` | Override a variable; can be repeated |
|
|
77
77
|
|
|
78
|
-
####
|
|
78
|
+
#### Paths (no VS Code)
|
|
79
79
|
|
|
80
|
-
- **Workspace**: `process.cwd()` or `--project <dir
|
|
81
|
-
- **Base folder**: `CURSORTOYS_BASE_FOLDER` or `--base-folder` (default: `cursor`)
|
|
82
|
-
- **HTTP folder**: `{workspace}/.{baseFolder}/http/` (e.g. `.cursor/http/`)
|
|
83
|
-
- **Environments**:
|
|
80
|
+
- **Workspace**: `process.cwd()` or `--project <dir>`
|
|
81
|
+
- **Base folder**: `CURSORTOYS_BASE_FOLDER` or `--base-folder` (default: `cursor`)
|
|
82
|
+
- **HTTP folder**: `{workspace}/.{baseFolder}/http/` (e.g. `.cursor/http/`)
|
|
83
|
+
- **Environments**: project root — `.env`, `.env.dev`, `.env.staging`, etc. (not inside `http/`)
|
|
84
84
|
|
|
85
85
|
#### HTTP Request File Format
|
|
86
86
|
|
|
87
87
|
Same as in the CursorToys extension:
|
|
88
88
|
|
|
89
|
-
- **REST Client**: `METHOD URL` then optional headers and body; multiple requests separated by `###`
|
|
90
|
-
- **Variables**: `# @var VAR_NAME=value
|
|
91
|
-
- **Substitution**: `{{VAR_NAME}}`
|
|
92
|
-
- **Delay**: `# @delay(milliseconds)`
|
|
89
|
+
- **REST Client**: `METHOD URL` then optional headers and body; multiple requests separated by `###` or `##` sections
|
|
90
|
+
- **Variables**: `# @var VAR_NAME=value`; `# @env name` to select environment (`default` uses `.env`)
|
|
91
|
+
- **Substitution**: `{{VAR_NAME}}` resolved from `# @var`, then from `.env.{name}` at project root
|
|
92
|
+
- **Delay**: `# @delay(milliseconds)` before executing a block
|
|
93
|
+
- **Assertions**: block comments with `@assert(...)` — when present, all must pass
|
|
94
|
+
- **Chained response** (`@SETTER` / `@GETTER`): capture a value from one response and use it in the next block (or file in the same run)
|
|
95
|
+
|
|
96
|
+
Reserved hook files (directory-level setup/teardown):
|
|
97
|
+
|
|
98
|
+
- `__before__.req` / `__before__.request`: runs **before** other request files in that directory
|
|
99
|
+
- `__after__.req` / `__after__.request`: runs **after** other request files in that directory
|
|
100
|
+
- Hook files are **not** treated as normal tests (they don't get discovered twice).
|
|
93
101
|
|
|
94
102
|
Example:
|
|
95
103
|
|
|
@@ -97,149 +105,134 @@ Example:
|
|
|
97
105
|
# @env dev
|
|
98
106
|
# @var BASE_URL=https://api.example.com
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
## Get health
|
|
101
109
|
GET {{BASE_URL}}/health
|
|
102
110
|
Accept: application/json
|
|
103
111
|
|
|
104
112
|
###
|
|
105
113
|
|
|
106
|
-
|
|
114
|
+
## Create user
|
|
107
115
|
# @delay(1000)
|
|
108
116
|
POST {{BASE_URL}}/users
|
|
109
117
|
Content-Type: application/json
|
|
110
118
|
|
|
111
|
-
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
{"name": "John Doe"}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Chained response example** (profile → repos using `avatar_url`):
|
|
123
|
+
|
|
124
|
+
```http
|
|
125
|
+
# @var GITHUB_API=https://api.github.com
|
|
126
|
+
# @var GITHUB_USER=octocat
|
|
127
|
+
|
|
128
|
+
## Public user profile
|
|
129
|
+
GET {{GITHUB_API}}/users/{{GITHUB_USER}}
|
|
130
|
+
Accept: application/vnd.github+json
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* @assert("Avatar URL is set", "res.body.avatar_url", "contains", "avatars")
|
|
134
|
+
* @SETTER("VALUE", "res.body.avatar_url")
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
###
|
|
138
|
+
|
|
139
|
+
## Public user repositories
|
|
140
|
+
# @getter VALUE
|
|
141
|
+
GET {{GITHUB_API}}/users/{{GITHUB_USER}}/repos?per_page=5&ref={{VALUE}}
|
|
142
|
+
Accept: application/vnd.github+json
|
|
143
|
+
|
|
144
|
+
/*
|
|
145
|
+
* @getter("VALUE")
|
|
146
|
+
* @assert("repos ok", "res.status", "equals", 200)
|
|
147
|
+
*/
|
|
115
148
|
```
|
|
116
149
|
|
|
117
|
-
|
|
150
|
+
- `@SETTER("KEY", "res.body.field")` — after the block's request, stores the value in `KEY` (same map as `# @var`)
|
|
151
|
+
- `# @getter KEY` or `/* @getter("KEY") */` — fails early if `KEY` is not defined
|
|
152
|
+
- Use `{{KEY}}` in URL, headers, body, or assertion expected values
|
|
153
|
+
- Variables persist across blocks in the file and across files in the same `http test` run
|
|
118
154
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
155
|
+
Project root `.env.dev`:
|
|
156
|
+
|
|
157
|
+
```env
|
|
158
|
+
BASE_URL=https://api.dev.example.com
|
|
159
|
+
API_KEY=dev-key
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Verbose Mode and Overrides
|
|
163
|
+
|
|
164
|
+
- **Verbose** (`-V`): prints request (method, URL, headers, body) and response
|
|
165
|
+
- **Environment** (`-e`): uses `.env.{name}` at project root; `# @env default` maps to `.env`
|
|
166
|
+
- **Variable overrides** (`--var KEY=value`): override file and env values for the run
|
|
122
167
|
|
|
123
168
|
Examples:
|
|
124
169
|
|
|
125
170
|
```bash
|
|
126
171
|
cursortoys http test -V
|
|
127
|
-
cursortoys http test -e
|
|
172
|
+
cursortoys http test -e staging --var BASE_URL=https://staging.example.com
|
|
128
173
|
cursortoys http test -f .cursor/http/api.req --verbose --var API_KEY=xxx
|
|
174
|
+
cursortoys http test --folder integrations
|
|
129
175
|
```
|
|
130
176
|
|
|
131
177
|
### Skill Management
|
|
132
178
|
|
|
133
179
|
Create and manage AI agent skills for Cursor AI.
|
|
134
180
|
|
|
135
|
-
#### Create a new skill
|
|
136
|
-
|
|
137
181
|
```bash
|
|
138
182
|
cursortoys skill add my-skill
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### Create with description
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
183
|
cursortoys skill add http-testing -d "Skill for testing HTTP APIs"
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Create project-specific skill
|
|
148
|
-
|
|
149
|
-
```bash
|
|
150
184
|
cursortoys skill add api-docs -t project -p /path/to/project
|
|
151
185
|
```
|
|
152
186
|
|
|
153
|
-
#### Skill Options
|
|
154
|
-
|
|
155
187
|
| Option | Description |
|
|
156
188
|
|-------|-------------|
|
|
157
189
|
| `-d, --description <text>` | Skill description |
|
|
158
|
-
| `-t, --target <type>` |
|
|
190
|
+
| `-t, --target <type>` | `personal` or `project` (default: `personal`) |
|
|
159
191
|
| `-p, --project <dir>` | Project directory (required if target is `project`) |
|
|
160
|
-
| `--base-folder <name>` | Base folder name (default: `cursor
|
|
192
|
+
| `--base-folder <name>` | Base folder name (default: `cursor`) |
|
|
161
193
|
|
|
162
|
-
|
|
194
|
+
**Install bundled HTTP skill** (same as CursorToys extension — hooks, `@SETTER`/`@GETTER`, CLI docs):
|
|
163
195
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
196
|
+
```bash
|
|
197
|
+
cursortoys skill install # default: http
|
|
198
|
+
cursortoys skill install http -t project -p .
|
|
199
|
+
cursortoys skill install http --force # reinstall
|
|
200
|
+
cursortoys skill list
|
|
201
|
+
```
|
|
168
202
|
|
|
169
203
|
### LLM Instructions
|
|
170
204
|
|
|
171
|
-
Display instructions for LLMs on how to use the CLI:
|
|
172
|
-
|
|
173
205
|
```bash
|
|
174
206
|
cursortoys --llm
|
|
175
207
|
```
|
|
176
208
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
## HTTP Test Output (Jest/Vitest style)
|
|
180
|
-
|
|
181
|
-
The CLI uses a visual style similar to Jest/Vitest: checkmarks for pass, crosses for fail, and a short summary with duration.
|
|
182
|
-
|
|
183
|
-
**Example when all tests pass:**
|
|
209
|
+
## HTTP Test Output
|
|
184
210
|
|
|
185
211
|
```
|
|
186
212
|
✓ .cursor/http/health.req 200 OK
|
|
187
|
-
✓ .cursor/http/users.req 201 Created
|
|
213
|
+
✓ .cursor/http/users.req (2/3) 201 Created
|
|
188
214
|
|
|
189
215
|
Tests: 2 passed, 2 total
|
|
190
216
|
Time: 1.23s
|
|
191
217
|
```
|
|
192
218
|
|
|
193
|
-
**Example when some tests fail:**
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
✓ .cursor/http/health.req 200 OK
|
|
197
|
-
✗ .cursor/http/users.req 404 Not Found
|
|
198
|
-
Failed to parse HTTP request (check METHOD URL and format)
|
|
199
|
-
|
|
200
|
-
Tests: 1 passed, 1 failed, 2 total
|
|
201
|
-
Time: 2.45s
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
**Example when using `-f` and the file is not found:**
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
FAIL No file found at: /path/to/missing.req
|
|
208
|
-
|
|
209
|
-
Tests: 0 total
|
|
210
|
-
Time: 0.01s
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
**Example with `--verbose` (request and response shown):**
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
✓ .cursor/http/health.req 200 OK
|
|
217
|
-
Request: GET https://api.example.com/health
|
|
218
|
-
Response: 200 OK
|
|
219
|
-
Body: {"status":"ok"}
|
|
220
|
-
|
|
221
|
-
Tests: 1 passed, 1 total
|
|
222
|
-
Time: 0.45s
|
|
223
|
-
```
|
|
224
|
-
|
|
225
219
|
Exit code is `0` if all tests passed, `1` if any failed or no files were run.
|
|
226
220
|
|
|
227
221
|
## Environment Variables
|
|
228
222
|
|
|
229
|
-
|
|
230
|
-
|
|
223
|
+
| Variable | Description |
|
|
224
|
+
|----------|-------------|
|
|
225
|
+
| `CURSORTOYS_BASE_FOLDER` | Default base folder (default: `cursor`) |
|
|
226
|
+
| `CURSORTOYS_DEFAULT_ENV` | Default environment when not set in file (default: `dev`) |
|
|
231
227
|
|
|
232
228
|
## Integration with CursorToys Extension
|
|
233
229
|
|
|
234
|
-
The CLI
|
|
230
|
+
The CLI matches the CursorToys VS Code extension:
|
|
231
|
+
|
|
235
232
|
- Same `.req` / `.request` file format
|
|
236
|
-
-
|
|
233
|
+
- Project-root `.env*` files (not under `http/`)
|
|
237
234
|
- Same base folder configuration
|
|
238
|
-
-
|
|
239
|
-
|
|
240
|
-
## Contributing
|
|
241
|
-
|
|
242
|
-
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
235
|
+
- Compatible with Cursor AI Agent Skills
|
|
243
236
|
|
|
244
237
|
## License
|
|
245
238
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertionParser.d.ts","sourceRoot":"","sources":["../src/assertionParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"assertionParser.d.ts","sourceRoot":"","sources":["../src/assertionParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,kBAAkB,CAAC;AAGhE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,CAiB9D;AAuMD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAgC/F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D"}
|
package/dist/assertionParser.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.extractAssertions = extractAssertions;
|
|
4
4
|
exports.validateAssertionSyntax = validateAssertionSyntax;
|
|
5
5
|
exports.removeAssertionBlocks = removeAssertionBlocks;
|
|
6
|
+
const responseChainParser_1 = require("./responseChainParser");
|
|
6
7
|
/**
|
|
7
8
|
* Extracts assertions from HTTP request file content.
|
|
8
9
|
* Looks for comment blocks containing @assert() annotations.
|
|
@@ -227,8 +228,6 @@ function validateAssertionSyntax(content) {
|
|
|
227
228
|
* @returns Content with assertion blocks removed
|
|
228
229
|
*/
|
|
229
230
|
function removeAssertionBlocks(content) {
|
|
230
|
-
|
|
231
|
-
const blockRegex = /\/\*[\s\S]*?@assert[\s\S]*?\*\//g;
|
|
232
|
-
return content.replace(blockRegex, '').trim();
|
|
231
|
+
return (0, responseChainParser_1.removeAnnotationBlocks)(content);
|
|
233
232
|
}
|
|
234
233
|
//# sourceMappingURL=assertionParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertionParser.js","sourceRoot":"","sources":["../src/assertionParser.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"assertionParser.js","sourceRoot":"","sources":["../src/assertionParser.ts"],"names":[],"mappings":";;AASA,8CAiBC;AA4MD,0DAgCC;AAOD,sDAEC;AA9QD,+DAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,OAAe;IAC/C,MAAM,UAAU,GAAgB,EAAE,CAAC;IAEnC,4BAA4B;IAC5B,MAAM,UAAU,GAAG,mBAAmB,CAAC;IACvC,IAAI,KAA6B,CAAC;IAElC,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACnD,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC;QAEpC,mCAAmC;QACnC,MAAM,eAAe,GAAG,mBAAmB,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QACpF,UAAU,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAC1B,YAAoB,EACpB,eAAuB,EACvB,WAAmB;IAEnB,MAAM,UAAU,GAAgB,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAE7B,wCAAwC;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,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAE7B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9B,SAAS;YACX,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAEhD,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAChD,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClG,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,2BAA2B,SAAS,EAAE;iBAC9C,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,OAAO,IAAA,4CAAsB,EAAC,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Assertion, AssertionResult } from './assertionTypes';
|
|
2
2
|
import { HttpRequestResult } from './httpRunner';
|
|
3
|
+
export { buildResponseData, resolveExpression } from './responseExpression';
|
|
3
4
|
/**
|
|
4
5
|
* Validates assertions against HTTP response
|
|
5
6
|
* @param assertions Array of assertions to validate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertionValidator.d.ts","sourceRoot":"","sources":["../src/assertionValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"assertionValidator.d.ts","sourceRoot":"","sources":["../src/assertionValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,eAAe,EAAE,CAmBnB;AA6KD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAgCzE"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveExpression = exports.buildResponseData = void 0;
|
|
3
4
|
exports.validateAssertions = validateAssertions;
|
|
4
5
|
exports.formatAssertionResults = formatAssertionResults;
|
|
6
|
+
const responseExpression_1 = require("./responseExpression");
|
|
7
|
+
var responseExpression_2 = require("./responseExpression");
|
|
8
|
+
Object.defineProperty(exports, "buildResponseData", { enumerable: true, get: function () { return responseExpression_2.buildResponseData; } });
|
|
9
|
+
Object.defineProperty(exports, "resolveExpression", { enumerable: true, get: function () { return responseExpression_2.resolveExpression; } });
|
|
5
10
|
/**
|
|
6
11
|
* Validates assertions against HTTP response
|
|
7
12
|
* @param assertions Array of assertions to validate
|
|
@@ -10,12 +15,7 @@ exports.formatAssertionResults = formatAssertionResults;
|
|
|
10
15
|
*/
|
|
11
16
|
function validateAssertions(assertions, response, headers) {
|
|
12
17
|
const results = [];
|
|
13
|
-
|
|
14
|
-
const responseData = {
|
|
15
|
-
status: response.statusCode,
|
|
16
|
-
headers: headers || {},
|
|
17
|
-
body: parseResponseBody(response.body),
|
|
18
|
-
};
|
|
18
|
+
const responseData = (0, responseExpression_1.buildResponseData)(response, headers);
|
|
19
19
|
for (const assertion of assertions) {
|
|
20
20
|
try {
|
|
21
21
|
const result = evaluateAssertion(assertion, responseData);
|
|
@@ -31,22 +31,6 @@ function validateAssertions(assertions, response, headers) {
|
|
|
31
31
|
}
|
|
32
32
|
return results;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Parses response body to JSON if possible, otherwise returns raw string
|
|
36
|
-
* @param body Response body string
|
|
37
|
-
* @returns Parsed JSON object or raw string
|
|
38
|
-
*/
|
|
39
|
-
function parseResponseBody(body) {
|
|
40
|
-
if (!body || body.trim() === '') {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
return JSON.parse(body);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return body;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
34
|
/**
|
|
51
35
|
* Evaluates a single assertion
|
|
52
36
|
* @param assertion The assertion to evaluate
|
|
@@ -55,7 +39,7 @@ function parseResponseBody(body) {
|
|
|
55
39
|
*/
|
|
56
40
|
function evaluateAssertion(assertion, responseData) {
|
|
57
41
|
// Resolve the expression to get actual value
|
|
58
|
-
const actualValue = resolveExpression(assertion.expression, responseData);
|
|
42
|
+
const actualValue = (0, responseExpression_1.resolveExpression)(assertion.expression, responseData);
|
|
59
43
|
// Evaluate based on operator
|
|
60
44
|
const passed = evaluateOperator(assertion.operator, actualValue, assertion.expected);
|
|
61
45
|
return {
|
|
@@ -64,40 +48,6 @@ function evaluateAssertion(assertion, responseData) {
|
|
|
64
48
|
actualValue,
|
|
65
49
|
};
|
|
66
50
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Resolves an expression like "res.status" or "res.body.userId" to its actual value
|
|
69
|
-
* @param expression Expression to resolve
|
|
70
|
-
* @param responseData Response data
|
|
71
|
-
* @returns Resolved value
|
|
72
|
-
*/
|
|
73
|
-
function resolveExpression(expression, responseData) {
|
|
74
|
-
// Split expression by dots, but handle bracket notation too
|
|
75
|
-
// e.g., "res.body.users[0].name" -> ["res", "body", "users[0]", "name"]
|
|
76
|
-
const parts = expression.split('.');
|
|
77
|
-
let current = { res: responseData };
|
|
78
|
-
for (const part of parts) {
|
|
79
|
-
if (current === null || current === undefined) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
// Handle array indexing: "users[0]" -> access users then [0]
|
|
83
|
-
const arrayMatch = part.match(/^([^\[]+)\[(\d+)\]$/);
|
|
84
|
-
if (arrayMatch) {
|
|
85
|
-
const propName = arrayMatch[1];
|
|
86
|
-
const index = parseInt(arrayMatch[2], 10);
|
|
87
|
-
current = current[propName];
|
|
88
|
-
if (Array.isArray(current)) {
|
|
89
|
-
current = current[index];
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
current = current[part];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return current;
|
|
100
|
-
}
|
|
101
51
|
/**
|
|
102
52
|
* Evaluates operator against actual and expected values
|
|
103
53
|
* @param operator Assertion operator
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertionValidator.js","sourceRoot":"","sources":["../src/assertionValidator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertionValidator.js","sourceRoot":"","sources":["../src/assertionValidator.ts"],"names":[],"mappings":";;;AAYA,gDAuBC;AAkLD,wDAgCC;AAnPD,6DAA4E;AAE5E,2DAA4E;AAAnE,uHAAA,iBAAiB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAE7C;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,UAAuB,EACvB,QAA2B,EAC3B,OAAgC;IAEhC,MAAM,OAAO,GAAsB,EAAE,CAAC;IA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AAI,YAAY,MAAM,CAAC,KAAK,GAAG,CAAC;YACtC,CAAC;iBAAM,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;gBAC5C,IAAI,IAAI,aAAa,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;YAC1D,CAAC;QACH,CAAC;QAED,MAAM,IAAI,IAAI,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAU;IAC7B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IAC5C,IAAI,KAAK,YAAY,MAAM;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,KAAK,GAAG,CAAC;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AA2CF,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CASxD;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAI5D"}
|
package/dist/banner.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderBanner = renderBanner;
|
|
7
|
+
exports.shouldUseColor = shouldUseColor;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
function colorize(useColor) {
|
|
10
|
+
if (!useColor) {
|
|
11
|
+
return {
|
|
12
|
+
t: (s) => s,
|
|
13
|
+
o: (s) => s,
|
|
14
|
+
y: (s) => s,
|
|
15
|
+
s: (s) => s,
|
|
16
|
+
title: (s) => s,
|
|
17
|
+
dim: (s) => s,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Paleta “cubo mágico” (aproximação): vermelho, verde, amarelo, azul.
|
|
21
|
+
return {
|
|
22
|
+
t: (s) => chalk_1.default.redBright(s),
|
|
23
|
+
o: (s) => chalk_1.default.greenBright(s),
|
|
24
|
+
y: (s) => chalk_1.default.yellowBright(s),
|
|
25
|
+
s: (s) => chalk_1.default.blueBright(s),
|
|
26
|
+
title: (s) => chalk_1.default.whiteBright.bold(s),
|
|
27
|
+
dim: (s) => chalk_1.default.gray(s),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function renderToysAscii(useColor) {
|
|
31
|
+
const c = colorize(useColor);
|
|
32
|
+
const T = (s) => c.t(s);
|
|
33
|
+
const O = (s) => c.o(s);
|
|
34
|
+
const Y = (s) => c.y(s);
|
|
35
|
+
const S = (s) => c.s(s);
|
|
36
|
+
// Mantém o mesmo “desenho” por linha, para ficar alinhado.
|
|
37
|
+
return [
|
|
38
|
+
`${T('TTTT')} ${O('OOO')} ${Y('Y Y')} ${S('SSS')}`,
|
|
39
|
+
`${T(' T ')} ${O('O O')} ${Y(' Y Y ')} ${S('S ')}`,
|
|
40
|
+
`${T(' T ')} ${O('O O')} ${Y(' Y ')} ${S('SSS')}`,
|
|
41
|
+
`${T(' T ')} ${O('O O')} ${Y(' Y ')} ${S(' S')}`,
|
|
42
|
+
`${T(' T ')} ${O('OOO')} ${Y(' Y ')} ${S('SSS')}`,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
function renderBanner(opts) {
|
|
46
|
+
const c = colorize(opts.useColor);
|
|
47
|
+
const lines = [];
|
|
48
|
+
lines.push(c.title('CursorToys'));
|
|
49
|
+
lines.push(...renderToysAscii(opts.useColor));
|
|
50
|
+
lines.push(c.dim(`v${opts.version}`));
|
|
51
|
+
return lines.join('\n');
|
|
52
|
+
}
|
|
53
|
+
function shouldUseColor(streamIsTty) {
|
|
54
|
+
if (!streamIsTty)
|
|
55
|
+
return false;
|
|
56
|
+
if (process.env.NO_COLOR)
|
|
57
|
+
return false;
|
|
58
|
+
return Boolean(chalk_1.default.supportsColor);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.js","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":";;;;;AAgDA,oCASC;AAED,wCAIC;AA/DD,kDAA0B;AAO1B,SAAS,QAAQ,CAAC,QAAiB;IACjC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO;YACL,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;YACnB,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;YACnB,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;YACnB,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;YACnB,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;YACvB,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;SACtB,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,OAAO;QACL,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,eAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QACpC,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE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