mmt-testlight 0.4.4 → 0.4.5
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 +1 -1
- package/dist/cli.js +26648 -9539
- package/dist/guides/agent-workflow.md +75 -0
- package/dist/guides/general.md +64 -0
- package/dist/guides/generate-api.md +221 -0
- package/dist/guides/generate-doc.md +103 -0
- package/dist/guides/generate-env.md +147 -0
- package/dist/guides/generate-loadtest.md +55 -0
- package/dist/guides/generate-suite.md +167 -0
- package/dist/guides/generate-test-skill.md +60 -0
- package/dist/guides/generate-test.md +335 -0
- package/dist/guides/generate.md +60 -0
- package/dist/guides/golden-smoke.md +52 -0
- package/dist/guides/min/api.md +29 -0
- package/dist/guides/min/constraints.md +9 -0
- package/dist/guides/min/doc.md +17 -0
- package/dist/guides/min/env.md +26 -0
- package/dist/guides/min/loadtest.md +17 -0
- package/dist/guides/min/overview.md +25 -0
- package/dist/guides/min/suite.md +18 -0
- package/dist/guides/min/test.md +42 -0
- package/dist/guides/min/workflow.md +16 -0
- package/dist/guides/offline-agent.md +46 -0
- package/esbuild.mjs +25 -0
- package/package.json +2 -1
- package/src/aiDocs.ts +88 -0
- package/src/cli.ts +283 -7
- package/src/pathNormalize.cjs +16 -0
- package/src/pathNormalize.test.ts +8 -0
- package/src/selfUpdate.test.ts +79 -0
- package/src/selfUpdate.ts +471 -0
- package/src/validateMmt.ts +45 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Multimeter agent workflow (MCP-first)
|
|
2
|
+
|
|
3
|
+
When the user asks to **create, modify, validate, format, or run** any `.mmt` file, use the **Multimeter MCP server tools first**. Do not explore npm packages, CLIs, or shell workarounds before calling MCP. Do not web-search Multimeter syntax.
|
|
4
|
+
|
|
5
|
+
## Golden rule
|
|
6
|
+
|
|
7
|
+
**If the task involves a `.mmt` file, start with Multimeter MCP tools in the first tool-call batch.**
|
|
8
|
+
|
|
9
|
+
Do **not** first try:
|
|
10
|
+
- `testlight`, `npx testlight`, or npm install/run (unless MCP is unavailable — then use `testlight scaffold` / docs)
|
|
11
|
+
- `node dist/mcp/server.js` or the `mmt-mcp` binary
|
|
12
|
+
- Reading Multimeter source, tarball contents, or package.json to find a runner
|
|
13
|
+
- Guessing YAML syntax from memory or random repo files
|
|
14
|
+
- Inventing a new test from blank without `scaffold_test`
|
|
15
|
+
- Rewriting an entire `.mmt` file when the user asked to change one part
|
|
16
|
+
|
|
17
|
+
## Decision tree
|
|
18
|
+
|
|
19
|
+
| User intent | First MCP tool(s) | Then |
|
|
20
|
+
|-------------|-------------------|------|
|
|
21
|
+
| Generate test from API | **`scaffold_test`** | Write yaml → minimal edits → **`validate` → `format`** |
|
|
22
|
+
| Need few-shot shape | **`list_examples`** (see `goldenSmoke`) | Mirror pair; still call `scaffold_test` |
|
|
23
|
+
| Inspect one API | **`api_card`** | Prefer over full file / OpenAPI dump |
|
|
24
|
+
| Tighten asserts (after run or from outputs) | **`suggest_assertions`** | Patch only → **`validate` → `format`** |
|
|
25
|
+
| Create or change other types | `read_documentation(topic)` (pack **min**) | Patch → **`validate` → `format`** |
|
|
26
|
+
| Change existing `.mmt` file | (docs only if needed) | **Patch only** → **`validate` → `format`** |
|
|
27
|
+
| List APIs | `discover_api` | Then `api_card` / `scaffold_test` |
|
|
28
|
+
| Run or execute `.mmt` | `run({ file, workspaceRoot })` | Report tool JSON; if user wants stronger asserts → `suggest_assertions` |
|
|
29
|
+
| Unsure of syntax | `read_documentation` (min; `pack: full` if needed) | Local docs only — no web |
|
|
30
|
+
| Offline / no MCP | see `offline-agent.md` | `testlight docs` → `scaffold` → `validate` |
|
|
31
|
+
|
|
32
|
+
## Generate test from API (required)
|
|
33
|
+
|
|
34
|
+
1. Optional: `list_examples` and mirror **`goldenSmoke`** (do not invent a different structure).
|
|
35
|
+
2. `scaffold_test({ workspaceRoot, apiPath, strategy?: "smoke"|"example" })`
|
|
36
|
+
3. Write `yaml` to `suggestedPath` (or user path).
|
|
37
|
+
4. Apply **only minimal** edits (asserts, inputs, title).
|
|
38
|
+
5. **`validate({ file, workspaceRoot })` until `valid: true`.**
|
|
39
|
+
6. **`format({ file, workspaceRoot })` after validate passes** (required on generate).
|
|
40
|
+
7. `run` only when the user asks to execute.
|
|
41
|
+
8. If the user then wants stronger asserts from a response: `suggest_assertions` → patch → validate → format.
|
|
42
|
+
|
|
43
|
+
## Modify workflow (required)
|
|
44
|
+
|
|
45
|
+
When the user asks to **modify**, **update**, **fix**, or **add steps** to a `.mmt` `file:`
|
|
46
|
+
|
|
47
|
+
1. `read_documentation(topic: "<type>")` only when syntax is unclear (pack **min**).
|
|
48
|
+
2. If helpful, `api_card` / `discover_api`.
|
|
49
|
+
3. **Patch only** — change the few lines needed. **Do not rewrite the whole file** unless the user explicitly asks for a rewrite/regenerate.
|
|
50
|
+
4. **`validate` immediately after every edit** until `valid: true`.
|
|
51
|
+
5. **`format` after validate passes.**
|
|
52
|
+
6. Only call `run` when the user asks to execute.
|
|
53
|
+
|
|
54
|
+
## Run → tighten asserts (optional)
|
|
55
|
+
|
|
56
|
+
When the user wants better assertions after a successful (or inspected) run:
|
|
57
|
+
|
|
58
|
+
1. `suggest_assertions` with `apiPath` and/or response `body` / `bodyFile`
|
|
59
|
+
2. Patch `expect` / `assert` lines only
|
|
60
|
+
3. `validate` → `format`
|
|
61
|
+
|
|
62
|
+
## Validation + format are mandatory
|
|
63
|
+
|
|
64
|
+
After **every** generate or modify on `.mmt` files:
|
|
65
|
+
|
|
66
|
+
1. `validate` until valid
|
|
67
|
+
2. `format`
|
|
68
|
+
before telling the user the task is done.
|
|
69
|
+
|
|
70
|
+
## YAML rules (always)
|
|
71
|
+
|
|
72
|
+
- Output valid Multimeter YAML only.
|
|
73
|
+
- First non-comment line must be `type: <api|test|env|...>`.
|
|
74
|
+
- Never add YAML comments (`#`).
|
|
75
|
+
- Use snake_case tokens: `e:api_url`, `i:user_id`, `r:uuid`, `c:epoch_ms`.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
This folder teaches an AI how to **answer questions** about Multimeter and decide **when to generate or edit** `.mmt` files.
|
|
2
|
+
|
|
3
|
+
**When using VS Code Copilot with the Multimeter extension:** call Multimeter **MCP tools first** (`read_documentation`, `discover_api`, `validate`, `format`, `run`). See `AI/agent-workflow.md`.
|
|
4
|
+
|
|
5
|
+
For actual YAML generation or modification, always go through `AI/generate.md`.
|
|
6
|
+
|
|
7
|
+
The AI should:
|
|
8
|
+
- Understand what each `type` (`api`, `test`, `env`, `doc`, `suite`) is for.
|
|
9
|
+
- Decide whether the user needs **an explanation** or **new/edited YAML**.
|
|
10
|
+
- Minimize tokens by reading only the specific generator file it needs.
|
|
11
|
+
|
|
12
|
+
Short mental model of file types:
|
|
13
|
+
- `type: api` → describe one HTTP/WebSocket endpoint.
|
|
14
|
+
- `type: test` → describe flows that call APIs/tests and assert behavior.
|
|
15
|
+
- `type: env` → define environment variables and presets.
|
|
16
|
+
- `type: doc` → describe documentation over existing `.mmt` files.
|
|
17
|
+
- `type: suite` → group and run multiple tests, APIs, or other suites.
|
|
18
|
+
- `type: server` → define a mock server with endpoints, matching, and responses.
|
|
19
|
+
- `type: report` → structured test results (generated by runs, viewable in the editor).
|
|
20
|
+
|
|
21
|
+
When you are the AI, follow these rules:
|
|
22
|
+
|
|
23
|
+
1. **Decide intent first**
|
|
24
|
+
- If the user asks "how" or "why" (no explicit request to create/edit a file):
|
|
25
|
+
- Explain concepts in plain language.
|
|
26
|
+
- Use small inline examples.
|
|
27
|
+
- Do **not** open generator files unless you need exact shapes.
|
|
28
|
+
- If the user explicitly asks to create/edit a `.mmt` `file:`
|
|
29
|
+
- Open **`AI/generate.md`**.
|
|
30
|
+
- Follow its instructions to choose the type and generator.
|
|
31
|
+
|
|
32
|
+
2. **Token conventions (snake_case)**
|
|
33
|
+
- Always show environment tokens in **snake_case**, for example:
|
|
34
|
+
- `e:api_url`, `e:auth_token`, `e:user_id`.
|
|
35
|
+
- Embedded: `<<e:api_url>>/users`, `Bearer <<e:auth_token>>`.
|
|
36
|
+
- Inputs: `i:user_id`, `<<i:user_id>>`.
|
|
37
|
+
- Random values: `r:uuid`, `r:first_name`, `r:last_name`, `r:epoch_ms`.
|
|
38
|
+
- Current/time values: `c:date`, `c:epoch`, `c:epoch_ms`.
|
|
39
|
+
- Use bare tokens as standalone YAML values; use `<< >>` only when embedding inside larger strings.
|
|
40
|
+
|
|
41
|
+
3. **Answering common question types**
|
|
42
|
+
- "How do I call this endpoint?"
|
|
43
|
+
- Explain briefly.
|
|
44
|
+
- If the user wants a file, go to `generate.md` and build a `type: api` example.
|
|
45
|
+
- "How do I write a test that does X then Y?"
|
|
46
|
+
- Explain tests and flows.
|
|
47
|
+
- If a file is requested, go to `generate.md` and build a `type: test` example.
|
|
48
|
+
- "How do I manage/dev/prod environments?"
|
|
49
|
+
- Explain env files and presets.
|
|
50
|
+
- If a file is requested, go to `generate.md` and build a `type: env` example.
|
|
51
|
+
- "How do I generate API docs?"
|
|
52
|
+
- Explain doc files.
|
|
53
|
+
- If a file is requested, go to `generate.md` and build a `type: doc` example.
|
|
54
|
+
- "How do I run multiple tests together?"
|
|
55
|
+
- Explain suite files.
|
|
56
|
+
- If a file is requested, go to `generate.md` and build a `type: suite` example.
|
|
57
|
+
|
|
58
|
+
4. **Safety and style**
|
|
59
|
+
- Use 2‑space indentation in all YAML examples.
|
|
60
|
+
- Prefer small, focused examples.
|
|
61
|
+
- Do not invent new fields or token formats.
|
|
62
|
+
- When unsure, propose the **minimal valid change** and explain it.
|
|
63
|
+
|
|
64
|
+
Your goal here is to **decide what to do** and provide good explanations; when it is time to actually write YAML, defer to `AI/generate.md` and the more detailed `AI/generate-*.md` files.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
This file tells the AI how to generate **`type: api`** `.mmt` files.
|
|
2
|
+
|
|
3
|
+
Always follow these rules:
|
|
4
|
+
- Output must be valid YAML.
|
|
5
|
+
- The **first non-comment line** must be `type: api`.
|
|
6
|
+
- Prefer explicit, descriptive names and short, readable examples.
|
|
7
|
+
- Only include fields that make sense for the user’s request.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Schema (mental model for the AI)
|
|
12
|
+
|
|
13
|
+
These fields mirror the internal `api` data model.
|
|
14
|
+
|
|
15
|
+
Top‑level keys and types (with descriptions the AI should remember):
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
type: api # REQUIRED. Declares this file as an API description.
|
|
19
|
+
|
|
20
|
+
# Documentation / metadata (optional but recommended)
|
|
21
|
+
title: string # Short human title, e.g. "Login API" or "List users".
|
|
22
|
+
description: string # 1–3 sentence explanation of what this endpoint does.
|
|
23
|
+
tags: # Optional tags for search/filters (e.g. [auth, smoke]).
|
|
24
|
+
- string
|
|
25
|
+
|
|
26
|
+
# Reuse / composition
|
|
27
|
+
import: # Optional. Map of aliases to other .mmt files this API depends on.
|
|
28
|
+
<alias>: path/to/file.mmt
|
|
29
|
+
inputs: # Optional. Input parameters for this API, with default values.
|
|
30
|
+
<name>: JSON value # string | number | boolean | null | object.
|
|
31
|
+
outputs: # Optional. Named values extracted from the response (body/headers/cookies).
|
|
32
|
+
<name>: string # Extractor expression, e.g. body[token] or body[/regex_pattern/]
|
|
33
|
+
setenv: # Optional. Promote response values into env vars after a run (same extraction DSL as outputs).
|
|
34
|
+
<env_name>: <expression> # e.g. body[token] or body.access_token (legacy: outputs key name still works).
|
|
35
|
+
|
|
36
|
+
# Request description (REQUIRED)
|
|
37
|
+
url: string # REQUIRED. Full or relative URL; may include env/input tokens like <<e:api_url>>.
|
|
38
|
+
query: # Optional. Query parameters appended to url; merged with any inline query string.
|
|
39
|
+
<name>: string # Value is always a string expression (can contain tokens).
|
|
40
|
+
protocol: http | ws # Optional. "http" for HTTP(S); "ws" for WebSocket.
|
|
41
|
+
# Inferred from URL if omitted: ws:// or wss:// → ws, otherwise http.
|
|
42
|
+
format: json | text | xml | xmle | urlencoded | { request, response }
|
|
43
|
+
method: # HTTP method (REQUIRED when protocol is http).
|
|
44
|
+
get | post | put | delete | patch | head | options | trace
|
|
45
|
+
headers: # Optional. HTTP/WS headers to send with the request.
|
|
46
|
+
<Header-Name>: string # Values can include tokens; header names are case-insensitive.
|
|
47
|
+
cookies: # Optional. HTTP cookies to send.
|
|
48
|
+
<cookie_name>: string
|
|
49
|
+
body: object | string | null # Optional. Request body (HTTP) or initial WS message; type depends on format.
|
|
50
|
+
|
|
51
|
+
# Examples (optional)
|
|
52
|
+
examples: # Optional. Example invocations for smoke tests / documentation.
|
|
53
|
+
- name: string # REQUIRED per example. Identifier used in UI/CLI.
|
|
54
|
+
description?: string # Optional explanation for this example.
|
|
55
|
+
inputs?: object # JSON record overriding top-level inputs for this example.
|
|
56
|
+
outputs?: object # JSON record of expected outputs for this example.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Notes for the AI:
|
|
60
|
+
- `inputs`, `setenv`, and `examples` are optional but powerful when the user wants reusable APIs or smoke‑testable examples.
|
|
61
|
+
- `import` is rarely needed when the user only describes a single endpoint.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## When to use which fields
|
|
66
|
+
|
|
67
|
+
- Use **`title`** and **`description`** whenever the user describes intent or business meaning (`"login endpoint"`, `"create user"`, etc.).
|
|
68
|
+
- Use **`tags`** when the user mentions categories like "smoke", "load", "auth", "payments".
|
|
69
|
+
- Use **`inputs`** when the user expects to change parameters between runs (username, pagination, filters, ids, etc.).
|
|
70
|
+
- Use **`outputs`** + **`setenv`** when the user wants to **capture response data** for later steps (e.g. tokens, IDs).
|
|
71
|
+
- Use **`examples`** when the user asks for **examples, smoke tests, or sample calls**.
|
|
72
|
+
- Use **`protocol: ws`** when the user asks for **websocket api**. For **REST or SOAP api**, protocol can be omitted (defaults to http based on URL).
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
If the user gives:
|
|
76
|
+
- **Only URL + method** → make a minimal `file:` `type`, `title`, `format`, `method`, `url` (protocol is inferred).
|
|
77
|
+
- **Request + response contract** → also add `inputs`, `outputs`, maybe `setenv`.
|
|
78
|
+
- **Multiple usage scenarios** → use `examples` to capture them.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Tokens the AI can use
|
|
83
|
+
|
|
84
|
+
The API body, headers, query, cookies, and url can contain tokens:
|
|
85
|
+
|
|
86
|
+
- Environment `variables:` `e:api_url`, `e:auth_token`, etc., or `<<e:api_url>>`
|
|
87
|
+
- Test/API `inputs:` `i:var` or `<<i:var>>`
|
|
88
|
+
- Random values: `r:name` or `<<r:name>>`
|
|
89
|
+
- Current/time values: `c:name` or `<<c:name>>`
|
|
90
|
+
|
|
91
|
+
Guidelines:
|
|
92
|
+
- If a value **is exactly** a single token (e.g. `username: i:user` or `id: r:int`), do **not** quote it unless the surrounding examples already use quotes.
|
|
93
|
+
- If a token is used **inside text**, wrap it as `<<token>>`, for example:
|
|
94
|
+
- `url: <<e:api_url>>/users/<<i:user_id>>`
|
|
95
|
+
- `x-request-id: req-<<r:uuid>>`
|
|
96
|
+
|
|
97
|
+
Common random tokens: `r:uuid`, `r:int`, `r:bool`, `r:email`, `r:phone`, `r:first_name`, `r:last_name`, `r:full_name`, `r:epoch`, `r:epoch_ms`.
|
|
98
|
+
Common current tokens: `c:date`, `c:time`, `c:epoch`, `c:epoch_ms`.
|
|
99
|
+
|
|
100
|
+
Do **not** invent new token syntaxes.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Authoring patterns for common requests
|
|
105
|
+
|
|
106
|
+
### 1. Simple GET with query and headers
|
|
107
|
+
|
|
108
|
+
Use when the user asks for something like “GET `/users` with pagination and auth header”.
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
type: api
|
|
112
|
+
title: List users
|
|
113
|
+
description: Returns a paginated list of users.
|
|
114
|
+
tags: [users, list]
|
|
115
|
+
inputs:
|
|
116
|
+
limit: 20
|
|
117
|
+
page: 1
|
|
118
|
+
url: <<e:api_url>>/users
|
|
119
|
+
protocol: http
|
|
120
|
+
format: json
|
|
121
|
+
method: get
|
|
122
|
+
headers:
|
|
123
|
+
authorization: Bearer <<e:auth_token>>
|
|
124
|
+
query:
|
|
125
|
+
limit: "<<i:limit>>"
|
|
126
|
+
page: "<<i:page>>"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 2. Login POST with JSON body and extracted token
|
|
130
|
+
|
|
131
|
+
Use when the user describes a login/auth endpoint that returns a token.
|
|
132
|
+
|
|
133
|
+
```yaml
|
|
134
|
+
type: api
|
|
135
|
+
title: Login
|
|
136
|
+
description: Authenticate user and return a session token.
|
|
137
|
+
tags: [auth, login]
|
|
138
|
+
inputs:
|
|
139
|
+
username: user@example.com
|
|
140
|
+
password: string
|
|
141
|
+
outputs:
|
|
142
|
+
token: body[token]
|
|
143
|
+
status: body[status]
|
|
144
|
+
setenv:
|
|
145
|
+
auth_token: body[token]
|
|
146
|
+
url: <<e:api_url>>/login
|
|
147
|
+
protocol: http
|
|
148
|
+
method: post
|
|
149
|
+
format: json
|
|
150
|
+
headers:
|
|
151
|
+
content-type: application/json
|
|
152
|
+
body:
|
|
153
|
+
username: i:username
|
|
154
|
+
password: i:password
|
|
155
|
+
examples:
|
|
156
|
+
- name: valid-user
|
|
157
|
+
description: Login with a valid account.
|
|
158
|
+
inputs:
|
|
159
|
+
username: alice@example.com
|
|
160
|
+
password: secret
|
|
161
|
+
- name: invalid-password
|
|
162
|
+
description: Login with wrong password.
|
|
163
|
+
inputs:
|
|
164
|
+
username: alice@example.com
|
|
165
|
+
password: wrong
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 3. Raw text or XML body
|
|
169
|
+
|
|
170
|
+
Use `format: text`, `format: xml`, `format: xmle`, or `format: urlencoded` when the user explicitly mentions plain text, HTML, XML, or form URL-encoded bodies. Use `xmle` when expanded empty tags are required. Use `urlencoded` for `application/x-www-form-urlencoded` key/value bodies.
|
|
171
|
+
|
|
172
|
+
```yaml
|
|
173
|
+
type: api
|
|
174
|
+
title: Echo text
|
|
175
|
+
description: Send and echo back a plain text payload.
|
|
176
|
+
protocol: http
|
|
177
|
+
format: text
|
|
178
|
+
method: post
|
|
179
|
+
url: <<e:api_url>>/echo
|
|
180
|
+
body: |
|
|
181
|
+
hello world
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
type: api
|
|
186
|
+
title: Submit XML payload
|
|
187
|
+
description: Send an XML document as the request body.
|
|
188
|
+
protocol: http
|
|
189
|
+
format: xml
|
|
190
|
+
method: post
|
|
191
|
+
url: <<e:api_url>>/xml
|
|
192
|
+
body: |
|
|
193
|
+
<root>
|
|
194
|
+
<value>42</value>
|
|
195
|
+
</root>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 4. WebSocket connection description
|
|
199
|
+
|
|
200
|
+
Use when the user describes WS endpoints (chat, notifications, streams). Actual send/receive flows are usually defined in `type: test` files calling this API.
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
type: api
|
|
204
|
+
title: Notifications stream
|
|
205
|
+
description: WebSocket stream of user notifications.
|
|
206
|
+
protocol: ws
|
|
207
|
+
format: json
|
|
208
|
+
url: wss://example.com/notifications
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Style rules for the AI
|
|
214
|
+
|
|
215
|
+
- Prefer **2 spaces** for indentation.
|
|
216
|
+
- Avoid trailing spaces.
|
|
217
|
+
- Prefer lower‑case, hyphen‑separated tags (e.g. `smoke`, `auth`, `user-profile`).
|
|
218
|
+
- Keep titles short (3–6 words) and descriptions 1–3 sentences.
|
|
219
|
+
- Do **not** rely on YAML comments (`#`) for important docs — prefer `description`. Format Document preserves comments, but UI form sync may still rebuild YAML without them.
|
|
220
|
+
|
|
221
|
+
When unsure, **favor simpler files** with fewer fields rather than guessing complex outputs or headers.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
This file tells the AI how to generate **`type: doc`** `.mmt` files.
|
|
2
|
+
|
|
3
|
+
Doc files describe how to build HTML/Markdown documentation from existing `.mmt` API files.
|
|
4
|
+
|
|
5
|
+
Always follow these rules:
|
|
6
|
+
- Output must be valid YAML.
|
|
7
|
+
- The first non-comment line must be `type: doc`.
|
|
8
|
+
- Do **not** redefine APIs here; instead, point to files/folders containing `type: api` definitions.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Schema (mental model for the AI)
|
|
13
|
+
|
|
14
|
+
This matches `DocData` in `core/src/DocData.ts` and `docs/files/doc/index.md`.
|
|
15
|
+
|
|
16
|
+
Top-level keys and types:
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
type: doc # REQUIRED, must be exactly "doc"
|
|
20
|
+
|
|
21
|
+
title?: string # title of the documentation page
|
|
22
|
+
description?: string # optional description or intro text
|
|
23
|
+
logo?: string # optional path/URL to a logo image
|
|
24
|
+
sources?: # list of folders/files to scan for APIs
|
|
25
|
+
- string
|
|
26
|
+
services?: # optional logical groupings
|
|
27
|
+
- name?: string
|
|
28
|
+
description?: string
|
|
29
|
+
sources?:
|
|
30
|
+
- string
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Notes:
|
|
34
|
+
- `sources` and each service’s `sources` can include:
|
|
35
|
+
- Direct paths to `.mmt` files.
|
|
36
|
+
- Folders containing `.mmt` files (recursively scanned).
|
|
37
|
+
- Only `type: api` entries discovered in those paths are rendered as API boxes.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Common patterns the AI should generate
|
|
42
|
+
|
|
43
|
+
### 1. Single-folder API catalog
|
|
44
|
+
|
|
45
|
+
User asks: "Generate docs for all APIs in `./apis`."
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
type: doc
|
|
49
|
+
title: API Catalog
|
|
50
|
+
sources:
|
|
51
|
+
- ./apis
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Multi-service catalog with groupings
|
|
55
|
+
|
|
56
|
+
User asks: "We have user and order services under different folders; build docs for both."
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
type: doc
|
|
60
|
+
title: Platform APIs
|
|
61
|
+
description: Documentation for core platform services.
|
|
62
|
+
sources:
|
|
63
|
+
- ./shared
|
|
64
|
+
services:
|
|
65
|
+
- name: Users
|
|
66
|
+
description: User registration, login, and profile APIs.
|
|
67
|
+
sources:
|
|
68
|
+
- ./services/users
|
|
69
|
+
- name: Orders
|
|
70
|
+
description: Order creation, tracking, and status APIs.
|
|
71
|
+
sources:
|
|
72
|
+
- ./services/orders
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Mixed single files and folders
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
type: doc
|
|
79
|
+
title: Authentication APIs
|
|
80
|
+
sources:
|
|
81
|
+
- ./auth/login.mmt
|
|
82
|
+
- ./auth/refresh.mmt
|
|
83
|
+
- ./auth
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## How the AI should answer doc-related questions
|
|
89
|
+
|
|
90
|
+
- If the user mentions **"generate documentation"**, **"API catalog"**, or similar, prefer `type: doc`.
|
|
91
|
+
- If the user provides a list of API files or folders, put them in `sources` and optionally group them under `services` if they describe separate domains.
|
|
92
|
+
- If the user wants a **logo** or branding, set `logo` to a relative path or URL (do not invent images; reuse what they mention).
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Style rules for the AI
|
|
97
|
+
|
|
98
|
+
- Use 2-space indentation.
|
|
99
|
+
- Keep titles short and descriptive.
|
|
100
|
+
- Keep service names in Title Case (e.g. `Users`, `Billing`).
|
|
101
|
+
- Prefer concise descriptions (1–2 sentences per service).
|
|
102
|
+
|
|
103
|
+
When unsure, generate a **small doc file** that points to the most obvious folder(s) the user mentioned (such as `./apis` or `./examples`).
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
This file tells the AI how to generate **`type: env`** `.mmt` files.
|
|
2
|
+
|
|
3
|
+
Environment files define variables and presets used by APIs and tests.
|
|
4
|
+
|
|
5
|
+
Always follow these rules:
|
|
6
|
+
- Output must be valid YAML.
|
|
7
|
+
- The first non-comment line must be `type: env`.
|
|
8
|
+
- Favor clear, descriptive variable names (snake_case or SCREAMING_SNAKE_CASE), for example:
|
|
9
|
+
- `api_url`, `auth_token`, `mode`, or
|
|
10
|
+
- `api_url`, `auth_token`, `mode`.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Schema (mental model for the AI)
|
|
15
|
+
|
|
16
|
+
This matches `EnvironmentData` in `mmtview/src/environment/EnvironmentData.tsx` and `docs/files/env/index.md`.
|
|
17
|
+
|
|
18
|
+
Top-level keys and types:
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
type: env # REQUIRED, must be exactly "env"
|
|
22
|
+
|
|
23
|
+
variables: # REQUIRED
|
|
24
|
+
<name>:
|
|
25
|
+
# One of:
|
|
26
|
+
# 1) mapping of labels -> string values (key-value choices)
|
|
27
|
+
# 2) array of strings (allowed values)
|
|
28
|
+
|
|
29
|
+
presets?: # OPTIONAL
|
|
30
|
+
<presetGroup>:
|
|
31
|
+
<presetName>:
|
|
32
|
+
<env_name>: string # value *must* match one of the variable options
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Interpretation:
|
|
36
|
+
- `variables[NAME]` can be:
|
|
37
|
+
- `{ dev: "http://localhost:8080", prod: "https://test.mmt.dev" }` → named key-value choices.
|
|
38
|
+
- `["debug", "info", "warn"]` → a list of allowed values.
|
|
39
|
+
- `presets[group][name]` tells the UI what to pick for each variable when that preset is active.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Tokens in other files
|
|
44
|
+
|
|
45
|
+
Env variables are **read in APIs/tests**, not stored as tokens here. In `type: api` or `type: test` files, you read them with:
|
|
46
|
+
|
|
47
|
+
- `e:api_url` # standalone value
|
|
48
|
+
- `<<e:api_url>>` # inside strings/URLs
|
|
49
|
+
|
|
50
|
+
The AI should not put `e:` tokens into env files; here we only define raw values or options.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Common patterns the AI should generate
|
|
55
|
+
|
|
56
|
+
### 1. Simple local + prod configuration
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
type: env
|
|
60
|
+
variables:
|
|
61
|
+
api_url:
|
|
62
|
+
local: "http://localhost:8080"
|
|
63
|
+
prod: "https://test.mmt.dev"
|
|
64
|
+
default_user:
|
|
65
|
+
- "alice@example.com"
|
|
66
|
+
default_password:
|
|
67
|
+
- "secret"
|
|
68
|
+
log_level:
|
|
69
|
+
- debug
|
|
70
|
+
- info
|
|
71
|
+
- warn
|
|
72
|
+
- error
|
|
73
|
+
presets:
|
|
74
|
+
runner:
|
|
75
|
+
local:
|
|
76
|
+
api_url: local
|
|
77
|
+
log_level: debug
|
|
78
|
+
prod:
|
|
79
|
+
api_url: prod
|
|
80
|
+
log_level: info
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Testing modes and feature flags
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
type: env
|
|
87
|
+
variables:
|
|
88
|
+
mode:
|
|
89
|
+
dev: dev
|
|
90
|
+
staging: staging
|
|
91
|
+
prod: prod
|
|
92
|
+
feature_x_enabled:
|
|
93
|
+
- "true"
|
|
94
|
+
- "false"
|
|
95
|
+
timeout_ms:
|
|
96
|
+
- "1000"
|
|
97
|
+
- "2000"
|
|
98
|
+
- "5000"
|
|
99
|
+
presets:
|
|
100
|
+
runner:
|
|
101
|
+
dev:
|
|
102
|
+
mode: dev
|
|
103
|
+
feature_x_enabled: "true"
|
|
104
|
+
timeout_ms: "1000"
|
|
105
|
+
prod:
|
|
106
|
+
mode: prod
|
|
107
|
+
feature_x_enabled: "false"
|
|
108
|
+
timeout_ms: "2000"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## How the AI should answer env-related questions
|
|
114
|
+
|
|
115
|
+
- If the user wants to **switch between environments** (local/staging/prod), generate:
|
|
116
|
+
- Variables with **key-value choice mappings**, e.g. `api_url: { local: ..., prod: ... }`.
|
|
117
|
+
- A `runner` preset group with `local`, `staging`, `prod` entries.
|
|
118
|
+
- If the user wants **valid options** for a flag or numeric setting, use **arrays** of strings.
|
|
119
|
+
- If a variable has only a single known value, wrap it in a single-element array (e.g. `token: ["your-token"]`).
|
|
120
|
+
- Always keep values as strings in env files; typing happens when they are read and interpreted.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Style rules for the AI
|
|
125
|
+
|
|
126
|
+
- Use 2-space indentation.
|
|
127
|
+
- Use ALL_CAPS for variable names by convention (not enforced but clearer).
|
|
128
|
+
- Keep presets small and focused; do not create many unused presets.
|
|
129
|
+
- Prefer explicit URLs and modes instead of opaque values.
|
|
130
|
+
|
|
131
|
+
When unsure, generate a **small env file** with the most clearly requested variables and a single preset group named `runner` with 1–2 named presets.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Certificates (optional)
|
|
136
|
+
|
|
137
|
+
Env files can also contain a `certificates` section for SSL/TLS settings. The AI generally does not need to generate this unless the user specifically asks about TLS, mTLS, or client certificates. See `docs/features/certificates/index.md` for full details.
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
certificates:
|
|
141
|
+
server_ca: ./certs/ca.pem
|
|
142
|
+
clients:
|
|
143
|
+
- name: my-client
|
|
144
|
+
host: api.example.com
|
|
145
|
+
cert: ./certs/client.pem
|
|
146
|
+
key: ./certs/client-key.pem
|
|
147
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
This file tells the AI how to generate `type:` loadtest .mmt files.
|
|
2
|
+
|
|
3
|
+
Always follow these rules:
|
|
4
|
+
- Output must be valid YAML.
|
|
5
|
+
- The first non-comment line must be `type:` loadtest.
|
|
6
|
+
- Load tests should reference exactly one existing `type:` test file via the top-level test field.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Schema (mental model for the AI)
|
|
11
|
+
|
|
12
|
+
Top-level keys and types:
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
type: loadtest
|
|
16
|
+
|
|
17
|
+
title: string
|
|
18
|
+
|
|
19
|
+
tags:
|
|
20
|
+
- string
|
|
21
|
+
|
|
22
|
+
description: string
|
|
23
|
+
|
|
24
|
+
environment:
|
|
25
|
+
preset?: string
|
|
26
|
+
file?: string
|
|
27
|
+
variables?:
|
|
28
|
+
<name>: <value>
|
|
29
|
+
|
|
30
|
+
threads: number
|
|
31
|
+
repeat: string | number
|
|
32
|
+
rampup: string
|
|
33
|
+
|
|
34
|
+
export:
|
|
35
|
+
- path/to/report.mmt
|
|
36
|
+
|
|
37
|
+
test: path/to/test.mmt
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Guidelines:
|
|
41
|
+
- Use test, not tests.
|
|
42
|
+
- Do not add servers; load tests do not support suite-level servers.
|
|
43
|
+
- Keep the referenced file a `type:` test document.
|
|
44
|
+
|
|
45
|
+
Example:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
type: loadtest
|
|
49
|
+
title: Login load test
|
|
50
|
+
tags: [load, auth]
|
|
51
|
+
threads: 100
|
|
52
|
+
repeat: 1m
|
|
53
|
+
rampup: 10s
|
|
54
|
+
test: ./tests/login.mmt
|
|
55
|
+
```
|