@mechasm/cli 0.1.2 → 0.1.4

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/AGENT_GUIDE.md CHANGED
@@ -5,11 +5,38 @@ Use Node.js 22 or newer. Install `@mechasm/cli`, sign in with `mechasm login`, t
5
5
  Keep each test request in Markdown. Name the project ID, target URL, expected result, and limits. Reuse configured test accounts; do not ask agents to expose credentials or change data outside the named test scope.
6
6
 
7
7
  ```sh
8
- mechasm tests create --project PROJECT_ID --name "Sign-in" --prompt-file prompt.md --wait --json
8
+ mechasm tests create --project PROJECT_ID --name "Sign-in" --prompt-file prompt.md --json
9
9
  ```
10
10
 
11
- Use explicit project, test, and run IDs. Do not assume a default project. Use `--json` for scripts; stdout contains JSON and errors go to stderr. Save run IDs and log cursors in workflow state. Resume logs with `--after CURSOR` after reconnecting.
11
+ Save the returned `testId`, `runId` and `runUrl`. Follow execution using the run ID:
12
12
 
13
- Exit code `5` means the run failed or was stopped. Code `2` means invalid arguments, `3` authentication failed, and `4` permission was denied. The optional npm update notice runs only in interactive non-JSON sessions; CI skips it.
13
+ ```sh
14
+ mechasm runs logs RUN_ID --project PROJECT_ID --follow --json
15
+ ```
16
+
17
+ When the stream finishes, check the final result:
18
+
19
+ ```sh
20
+ mechasm runs status RUN_ID --project PROJECT_ID --json
21
+ ```
22
+
23
+ Log streaming alone does not report pass/fail through its exit code. Do not infer success from a closed stream or an individual log line. For scripts that only need the final result, `--wait` on create/edit/run or `runs wait` waits silently and returns the final result without displaying live logs. With `--json`, it returns one final JSON result.
24
+
25
+ Let Mechasm's healer work while the run is active. Failed actions, unexpected pages and recovery attempts can be corrected automatically. Wait for the overall run to reach `passed` or `failed`; do not cancel because a few minutes passed or one step failed. Stop when the user requests it, or when you deliberately need to change the prompt before continuing. `runs status` includes `terminal`, the current `progress` phase/start time when available, and safe failure details with a suggested next step. Missing progress is not proof the run is stuck.
26
+
27
+ Before reporting the outcome, review the logs and available evidence against the user's intended result:
28
+
29
+ ```sh
30
+ mechasm runs trace RUN_ID --project PROJECT_ID --out run-trace.zip
31
+ mechasm runs video RUN_ID --project PROJECT_ID --out run.webm
32
+ ```
33
+
34
+ Check artifact availability in `runs status`; uploads can finish after the run result. Inspect trace screenshots/page snapshots, actions and errors, using video as supporting evidence. Verify that the expected behavior really happened; do not treat an existing file as proof of success. If evidence is unavailable or cannot be opened, report that limit.
35
+
36
+ If evidence shows a genuine failure of the user's requirement, accept and report the failure. If your prompt introduced an unsupported assumption or was ambiguous, clarify it without weakening the user's requirement, then use `tests edit --prompt-file FILE` and inspect the new run. Ask the user if their intended result is unclear. Do not repeatedly rerun or remove assertions just to get a pass. A manually stopped run proves cancellation, not what the natural result would have been.
37
+
38
+ Use explicit project, test, and run IDs. Do not assume a default project. Use `--json` for scripts; stdout contains JSON and errors go to stderr. Log following emits JSON lines. Save run IDs and log cursors in workflow state. Resume logs with `--after CURSOR` after reconnecting.
39
+
40
+ Exit code `5` from a status/get/wait command or a test command using `--wait` means the run failed or was stopped. Code `2` means invalid arguments, `3` authentication failed, and `4` permission was denied. The optional npm update notice runs only in interactive non-JSON sessions; CI skips it.
14
41
 
15
- See [CLI documentation](https://mechasm.ai/docs/mechasm-cli/getting-started) for full command details.
42
+ See [CLI documentation](https://mechasm.ai/docs/mechasm-cli/getting-started) and [agent workflows](https://mechasm.ai/docs/mechasm-cli/agent-workflows) for full command details.
package/README.md CHANGED
@@ -38,12 +38,24 @@ Pass project IDs explicitly to test, run, variable, and local-app commands. The
38
38
  ```sh
39
39
  mechasm teams list
40
40
  mechasm projects create --name "Store QA" --url https://app.example.com --team TEAM_ID
41
- mechasm tests create --project PROJECT_ID --name "Home page" --prompt "Open the home page and check that it loads." --wait --json
41
+ mechasm tests create --project PROJECT_ID --name "Home page" --prompt "Open the home page and check that it loads." --json
42
42
  ```
43
43
 
44
44
  Replace `TEAM_ID`, `PROJECT_ID`, and the example URL with your values. `--team` is optional when exactly one team is approved. The project creation response contains the project ID to use in later commands.
45
45
 
46
- Commands that start a run return its `runId` and workspace `runUrl`. `--wait` waits for the final result. Failed or stopped runs exit with code 5.
46
+ Commands that start a run return its `runId` and workspace `runUrl`. Use the returned run ID to follow execution:
47
+
48
+ ```sh
49
+ mechasm runs logs RUN_ID --project PROJECT_ID --follow
50
+ ```
51
+
52
+ After the log stream finishes, check the final result:
53
+
54
+ ```sh
55
+ mechasm runs status RUN_ID --project PROJECT_ID --json
56
+ ```
57
+
58
+ Log streaming alone does not report pass/fail through its exit code. Status/get commands return exit code 5 for failed or stopped runs. For scripts that only need the final result, add the optional `--wait` to create/edit/run, or use `runs wait`. Waiting is silent until completion and does not display live logs. With `--json`, it returns one final JSON result; failed or stopped runs exit with code 5.
47
59
 
48
60
  ## Manage variables safely
49
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mechasm/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Mechasm command line client",
5
5
  "homepage": "https://mechasm.ai/docs/mechasm-cli/getting-started",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/src/cli.js CHANGED
@@ -60,14 +60,19 @@ Options:
60
60
  --idempotency-key KEY Reuse key after an unknown mutation result
61
61
  --url URL Project or local app URL
62
62
  --ports LIST Comma-separated local ports
63
- --wait Wait for test generation or run completion; metadata-only operations return immediately
63
+ --wait Wait silently for the final result; metadata-only edits return immediately
64
64
  --follow Follow run logs until it finishes
65
65
  --after CURSOR Resume run log history
66
66
  --out FILE Save video or trace to a new file
67
67
  --json JSON output on stdout; errors on stderr
68
68
 
69
- Commands that start a run return its workspace URL; plain output shows it as "View run".
69
+ Commands that start a run return runId and runUrl; --wait delays output until completion.
70
+ To watch progress, start without --wait, then use: mechasm runs logs RUN_ID --project ID --follow
71
+ After following logs, use runs status to check the result. Log streaming alone does not report pass/fail via its exit code.
70
72
  No command opens a local public listener. Project IDs are required for test and run operations.
73
+
74
+ Documentation: https://mechasm.ai/docs/mechasm-cli/getting-started
75
+ Agent workflows: https://mechasm.ai/docs/mechasm-cli/agent-workflows
71
76
  `;
72
77
  const RUNNER_MANAGED_VARIABLES = new Set(['CI_TOKEN', 'RUN_WS_TOKEN', 'WS_AUTH_COOKIE']);
73
78
 
@@ -176,7 +181,10 @@ function output(value, json) {
176
181
  console.log(`Signed in${identity ? ` as ${identity}` : ''}${value.deviceName ? ` (${value.deviceName})` : ''}.`);
177
182
  }
178
183
  else if (Array.isArray(value?.projects)) {
179
- if (!value.projects.length) console.log('No projects available.');
184
+ if (!value.projects.length) {
185
+ console.log(value.message || 'No projects available to this device.');
186
+ if (value.suggestedNextStep) console.log(value.suggestedNextStep);
187
+ }
180
188
  else for (const project of value.projects) console.log(`${project.id} ${project.name} ${project.url}`);
181
189
  } else if (Array.isArray(value?.tests)) {
182
190
  if (!value.tests.length) console.log('No tests found.');