diff --git a/docs/commands.md b/docs/commands.md index 8c63f24..3a9f53b 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1018,10 +1018,11 @@ Use this checklist when a change adds a command or subcommand. Each step names t - Update the exact group help in the tests: `HELP` in `test/cli.test.js`, `PLAN_HELP` in `test/plan-init.test.js`, `GENERATE_HELP` in `test/generate-uuid.test.js`, or `MAINTAIN_HELP` in `test/maintain.test.js`. No test asserts the whole `compilation` group help. - - Append a command that calls the Service to `REMOTE_COMMANDS` in `test/api-environments.test.js`. Some tests - there select entries by index, so add it at the end. The command's first request must reach the pinned origin - with that origin's token, and one `401` must produce `authentication_required`. A command not tied to a Project, - such as `account`, selects its origin as `login` does; test that in its own file instead. + - Add a command that calls the Service to `REMOTE_COMMANDS` in `test/api-environments.test.js`. Tests there + pick entries by group or with `remoteCommand(group, command)`, never by index. The command's first request + must reach the pinned origin with that origin's token, and one `401` must produce `authentication_required`. A + command not tied to a Project, such as `account`, selects its origin as `login` does; test that in its own file + instead. - Add packed-package cases to `scripts/smoke-package.js`, including at least an invalid-arguments case. 4. **Package it.** Add each new `src/` file to the exact list in `scripts/check-pack.js`. `firstdraft/skills` keeps a copy of that list as `packedFileAllowlist` in `script/cli-contract/config.mjs`. The copy must change when diff --git a/docs/errors.md b/docs/errors.md index 5333d8a..d6f7beb 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -252,8 +252,9 @@ resolve an item that is still resolved, with `maintain_rejected` and `409 item_a 1,000 characters. - `maintain_unavailable` means a network failure, timeout, server error, or error response without a problem body left the result unconfirmed. Retry a read. After a resolution, check the item with `maintain show` and reassess it - before resolving again. A `404` with no `response` usually - means the pinned origin's Service has no maintenance routes, so retrying will not help until it is upgraded. + before resolving again. A `404` with no `response` usually means the Service at the origin the command used has + no maintenance routes: the pinned origin, or in a fresh clone the one `login` would select. Retrying will not help + until that Service is upgraded. - `invalid_maintain_response` means a success response violated the contract; retrying the unchanged request will not repair it. After a resolution, check the item with `maintain show`. - The index reads the account first. When that read fails, it reads no items and ends with `account_unavailable`, diff --git a/test/api-environments.test.js b/test/api-environments.test.js index 38f0cb4..a960be3 100644 --- a/test/api-environments.test.js +++ b/test/api-environments.test.js @@ -60,6 +60,23 @@ const REMOTE_COMMANDS = [ ], ]; +/** + * The REMOTE_COMMANDS entry for `group command`. Tests name the commands they + * need instead of indexing the list, which shifts whenever a command is added + * or removed. + * + * @param {string} group + * @param {string} command + */ +function remoteCommand(group, command) { + const argv = REMOTE_COMMANDS.find( + ([candidateGroup, candidateCommand]) => + candidateGroup === group && candidateCommand === command, + ); + assert(argv, `REMOTE_COMMANDS has no ${group} ${command}`); + return argv; +} + test("production and staging credentials follow the pinned origin on every remote command", async (context) => { for (const argv of REMOTE_COMMANDS) { for (const [origin, token] of [ @@ -120,8 +137,10 @@ test("staging accepts a root or remote-command flag and a matching URL override" }); test("the first remote request defaults to production or explicitly selects staging", async (context) => { - for (const command of [REMOTE_COMMANDS[0], REMOTE_COMMANDS[2]]) { - assert(command); + for (const command of [ + remoteCommand("plan", "push"), + remoteCommand("plan", "compile"), + ]) { for (const staging of [false, true]) { const cwd = projectDirectory(context); let requests = 0; @@ -193,13 +212,11 @@ test("staging rejects a conflicting URL or pinned origin before any request", as test("status, retained Compilation, and maintain commands ignore an initial URL override when selecting staging credentials", async (context) => { for (const argv of [ - REMOTE_COMMANDS[1], - REMOTE_COMMANDS[4], - REMOTE_COMMANDS[5], - REMOTE_COMMANDS[6], - ...REMOTE_COMMANDS.filter(([group]) => group === "maintain"), + remoteCommand("plan", "status"), + ...REMOTE_COMMANDS.filter( + ([group]) => group === "compilation" || group === "maintain", + ), ]) { - assert(argv); let requests = 0; const result = await invoke(argv, { cwd: projectDirectory(context, STAGING),