@mechasm/cli 0.1.4 → 0.1.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/AGENT_GUIDE.md +12 -0
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/api-client.js +13 -1
package/AGENT_GUIDE.md
CHANGED
|
@@ -2,8 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Use Node.js 22 or newer. Install `@mechasm/cli`, sign in with `mechasm login`, then check `mechasm doctor`.
|
|
4
4
|
|
|
5
|
+
When signing in again with a valid session and the same account, review the preselected project and team approvals before approving.
|
|
6
|
+
|
|
5
7
|
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
8
|
|
|
9
|
+
Before creating a test, list the project's existing tests and inspect likely matches. If the target and requirements match, run the existing test and inspect the new run. An app change alone does not require a new test. Edit a test when its requirements change; create one only for missing coverage. Never reuse an old result as verification of a new app version.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
mechasm tests list --project PROJECT_ID --json
|
|
13
|
+
mechasm tests get TEST_ID --project PROJECT_ID --json
|
|
14
|
+
mechasm tests run TEST_ID --project PROJECT_ID --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For missing coverage:
|
|
18
|
+
|
|
7
19
|
```sh
|
|
8
20
|
mechasm tests create --project PROJECT_ID --name "Sign-in" --prompt-file prompt.md --json
|
|
9
21
|
```
|
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ mechasm projects list
|
|
|
31
31
|
|
|
32
32
|
Approve the existing projects and actions this device needs. Project access and permission to create projects in a team are separate. Team project-creation access does not grant access to existing projects in that team. If a project or team is missing, sign in again and approve access; your account must already have access to it.
|
|
33
33
|
|
|
34
|
+
When signing in again with a valid session and the same account, your previous approvals are preselected. Review them before approving. If your session has expired or was revoked, select access again.
|
|
35
|
+
|
|
34
36
|
Pass project IDs explicitly to test, run, variable, and local-app commands. The CLI does not select a default project.
|
|
35
37
|
|
|
36
38
|
## Create a project and run a test
|
|
@@ -43,6 +45,8 @@ mechasm tests create --project PROJECT_ID --name "Home page" --prompt "Open the
|
|
|
43
45
|
|
|
44
46
|
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
47
|
|
|
48
|
+
For later app changes, inspect existing tests and run matching ones with `mechasm tests run TEST_ID --project PROJECT_ID`. Edit tests when requirements change; create tests only for missing coverage. Always inspect the new run's result. See the bundled [Agent Guide](./AGENT_GUIDE.md) for the full workflow.
|
|
49
|
+
|
|
46
50
|
Commands that start a run return its `runId` and workspace `runUrl`. Use the returned run ID to follow execution:
|
|
47
51
|
|
|
48
52
|
```sh
|
package/package.json
CHANGED
package/src/api-client.js
CHANGED
|
@@ -228,7 +228,19 @@ export function createCliClient(rawApiUrl) {
|
|
|
228
228
|
async login({ deviceName = hostname().slice(0, 120), noBrowser = false, json = false } = {}) {
|
|
229
229
|
deviceName = String(deviceName).trim();
|
|
230
230
|
if (!deviceName || deviceName.length > 120) throw new CliError('--device-name must be 1 to 120 characters.', 2);
|
|
231
|
-
|
|
231
|
+
let previousToken;
|
|
232
|
+
try {
|
|
233
|
+
if (await readCredentials(path)) previousToken = (await accessToken()).token;
|
|
234
|
+
} catch (error) {
|
|
235
|
+
if (error.exitCode !== 3) throw error;
|
|
236
|
+
}
|
|
237
|
+
let device;
|
|
238
|
+
try {
|
|
239
|
+
device = (await request('/auth/device', { method: 'POST', body: { deviceName }, token: previousToken })).data;
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (!previousToken || error.exitCode !== 3) throw error;
|
|
242
|
+
device = (await request('/auth/device', { method: 'POST', body: { deviceName } })).data;
|
|
243
|
+
}
|
|
232
244
|
if (typeof device?.deviceCode !== 'string' || !/^mcd_[A-Za-z0-9_-]{43}$/.test(device.deviceCode) ||
|
|
233
245
|
typeof device?.userCode !== 'string' || !device.userCode || typeof device?.verificationUrl !== 'string' ||
|
|
234
246
|
!Number.isInteger(device.expiresIn) || device.expiresIn < 1 || device.expiresIn > 1800) {
|