|
| 1 | +<!-- Read this for the Test Manager (TMS) agent surface — what gets uploaded, where the run lands, the `projects` / `folders` subcommands and their NDJSON wire shape, and the run-startup auto-default event. Non-TTY surface only; the human config flow / interactive picker lives in the public user guide. --> |
| 2 | + |
| 3 | +# Test Manager Reference — Agent Surface |
| 4 | + |
| 5 | +Every kane-cli session uploads to a TestmuAI **Test Manager (TMS)** test case. The session lands inside a **project** (required) and optionally a **folder** inside that project. This page is the agent-facing surface for everything that touches TMS: where the run ends up, how to browse and create projects/folders programmatically, and the event the run-startup gate emits when nothing is configured. |
| 6 | + |
| 7 | +Field names below are for parsing only — translate to plain language for the user, per the §5 rule in `SKILL.md`. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 1. Where a run lands |
| 12 | + |
| 13 | +After a successful upload, the terminal `run_end` event (`testmd_done` for `testmd run`) carries the dashboard link: |
| 14 | + |
| 15 | +```json |
| 16 | +{"type":"run_end","status":"passed", "test_url":"https://test-manager.lambdatest.com/projects/<id>/test-cases/<id>", ...} |
| 17 | +``` |
| 18 | + |
| 19 | +For `testmd run`, the `test_md_summary` / `test_md_done` events also carry a `share_url` — a 7-day, no-login link suitable for CI artifacts. |
| 20 | + |
| 21 | +Surface `test_url` (and `share_url` when present) as a "View in Test Manager" line per the §1.4 results table in `SKILL.md`. Never paste raw URLs into the middle of a summary — they belong in the results table. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 2. Projects & folders — selecting where uploads land |
| 26 | + |
| 27 | +Two ways an agent influences placement: |
| 28 | + |
| 29 | +- **Programmatically**, via the `projects` / `folders` subcommands (§3 + §4) — list, search, create, then persist with `kane-cli config project <id>` / `kane-cli config folder <id>`. |
| 30 | +- **Passively**, by observing the `project_folder_auto_defaulted` event the run-startup gate emits when nothing is configured (§5). |
| 31 | + |
| 32 | +In a non-TTY context (CI, pipes, every `--agent` caller), the no-arg form of `config project` / `config folder` will not prompt — always pass an explicit `<id>`. The interactive picker is the human-facing path and is documented in the user guide. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## 3. Listing — `projects list` / `folders list` |
| 37 | + |
| 38 | +```bash |
| 39 | +kane-cli projects list [--search <q>] [--limit <n>] [--offset <n>] --agent |
| 40 | +kane-cli folders list [--search <q>] [--limit <n>] [--offset <n>] --agent |
| 41 | +``` |
| 42 | + |
| 43 | +| Flag | Purpose | |
| 44 | +|---|---| |
| 45 | +| `--search <q>` | Filter by name (substring match). | |
| 46 | +| `--limit <n>` | Page size. Default is small (~10). Very large values are capped. | |
| 47 | +| `--offset <n>` | Skip the first N rows. | |
| 48 | +| `--agent` | Force NDJSON. Auto-on when stdout is piped/redirected, but pass it explicitly anyway. | |
| 49 | + |
| 50 | +`folders list` operates inside the currently configured project. If none is configured, list projects first or rely on §5. |
| 51 | + |
| 52 | +### Wire shape |
| 53 | + |
| 54 | +Each result line: |
| 55 | + |
| 56 | +```json |
| 57 | +{"id":"01J69X773TSY9TCHZY4VAT9VBH","name":"KaneAI Generated"} |
| 58 | +``` |
| 59 | + |
| 60 | +Just `id` + `name`. The terminal line on every page: |
| 61 | + |
| 62 | +```json |
| 63 | +{"_meta":"page","limit":10,"offset":0,"returned":10,"has_more":true} |
| 64 | +``` |
| 65 | + |
| 66 | +| Field | Meaning | |
| 67 | +|---|---| |
| 68 | +| `_meta: "page"` | Discriminator — distinguishes pagination metadata from a result row. Skip when collecting results. | |
| 69 | +| `limit` / `offset` | Echoed from the request. | |
| 70 | +| `returned` | Number of result rows on this page (≤ `limit`). | |
| 71 | +| `has_more` | `true` if another page exists. There is no `total` — only a "more remaining" signal, so don't promise an exact count to the user. | |
| 72 | + |
| 73 | +### Pagination idiom |
| 74 | + |
| 75 | +```bash |
| 76 | +offset=0; limit=10 |
| 77 | +while :; do |
| 78 | + page=$(kane-cli projects list --limit "$limit" --offset "$offset" --agent) |
| 79 | + echo "$page" | jq -c 'select(._meta != "page")' # result rows |
| 80 | + more=$(echo "$page" | jq -r 'select(._meta == "page") | .has_more') |
| 81 | + [ "$more" = "true" ] || break |
| 82 | + offset=$((offset + limit)) |
| 83 | +done |
| 84 | +``` |
| 85 | + |
| 86 | +Same pattern for `folders list`. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 4. Creating — `projects create` / `folders create` |
| 91 | + |
| 92 | +```bash |
| 93 | +kane-cli projects create "<name>" [--description "<text>"] --agent |
| 94 | +kane-cli folders create "<name>" [--description "<text>"] --agent |
| 95 | +``` |
| 96 | + |
| 97 | +NDJSON: one line describing the new id + name. `folders create` files the folder inside the currently configured project. |
| 98 | + |
| 99 | +To use the result for subsequent runs, persist with `kane-cli config project <id>` / `kane-cli config folder <id>` — non-interactive when called with an explicit `<id>`. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## 5. The run-startup auto-default event |
| 104 | + |
| 105 | +`kane-cli run`, `kane-cli testmd run`, and `kane-cli generate` all validate the cached project/folder before launching anything. Three outcomes: |
| 106 | + |
| 107 | +1. **Cached project/folder still valid** → run proceeds. No event. |
| 108 | +2. **Nothing configured, or the cached IDs are gone / inaccessible** → kane-cli resolves a sensible project/folder headlessly (find-or-create), then emits a typed event before the run starts: |
| 109 | + |
| 110 | + ``` |
| 111 | + {"type": "project_folder_auto_defaulted", ...} |
| 112 | + ``` |
| 113 | + |
| 114 | + The event carries the resolved project + folder so the caller knows what was picked. Translate it for the human user — for example: |
| 115 | + |
| 116 | + > kane-cli auto-selected project **<name>** / folder **<name>** for this run. |
| 117 | +
|
| 118 | + Don't surface raw field names. |
| 119 | + |
| 120 | +3. **No usable credentials in a non-TTY context** → exit code `2` with an auth/setup error. |
| 121 | + |
| 122 | +### Self-healing for stale IDs |
| 123 | + |
| 124 | +If a previously-configured project/folder becomes unusable (deleted, renamed, access revoked, or a typo was saved as the ID), TMS returns a `4xx` for the validation call and the gate treats both as **missing** — it clears the stale value and re-resolves via auto-default. The run is not aborted for this. |
| 125 | + |
| 126 | +Transient validation failures (`5xx`, network, timeout) are treated as **error** and the gate fails open with the cached IDs so brief upstream hiccups don't block a run. |
| 127 | + |
| 128 | +### When you see the event |
| 129 | + |
| 130 | +Surface it as a one-line note, then continue parsing the run normally. If the user wants their runs in a different project, point them at the user guide's project/folder configuration page — the public `kane-cli config project [<id>]` / `kane-cli config folder [<id>]` commands cover the human flow. |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## 6. Exit codes (TMS subcommands only) |
| 135 | + |
| 136 | +| Code | Meaning | |
| 137 | +|---|---| |
| 138 | +| 0 | OK | |
| 139 | +| 2 | Auth/setup error (missing or invalid credentials) or unknown subcommand | |
| 140 | + |
| 141 | +Other codes are run-specific (`run` / `testmd run` / `generate`) and don't apply to `projects` / `folders`. |
0 commit comments