From 91b65c537a51ad36d273cc180a6e717337bc7cca Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:06:51 +0000 Subject: [PATCH 1/6] chore(yun-tianming): share the query-string helper between storage and metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - `src/commands/storage.ts` and `src/commands/metrics.ts` each carried a private `qs()` that was byte-for-byte identical (build a `URLSearchParams` from a record, skipping `undefined` and `''`, and prefix `?` when non-empty). The storage copy was added in 8919437 (2026-08) as a second copy of the metrics one from 50fc2e4 (2026-06). The one surviving copy now lives in `src/commands/services.ts` beside `q()`, the branch-only form of the same helper that nine command modules already import from there, and both callers import it. ## Safety - **Duplicate collapse** — the two bodies were identical (confirmed with a 4-line-window scan across `src/`, which reported this as the only cross-file duplicate). The survivor is exercised by `test/storage.test.ts` (`objectsPath`, `objectDownloadPath`, including the encoding and omitted-param cases) and `test/logs-deploy.test.ts` (`deployEventsPath`, including the omitted-param case), all of which ran before and after. No exported symbol of storage.ts or metrics.ts changed name, signature or behaviour; services.ts gains one export (`qs`) and introduces no import cycle (it imports only `../api.js` and `../util.js`). No command or flag changed, so `skills/insta/cli-reference.md` has nothing to mirror. ## Verification ``` npm run typecheck # tsc -p tsconfig.json --noEmit npm test # vitest run ``` - Baseline (untouched `main` @ d075ab7): typecheck exit 0; 107 test files passed, 2124 tests passed, 136 skipped, 31.3s. - Final tree: typecheck exit 0; 107 test files passed, 2124 tests passed, 136 skipped, 33.0s. There is no lint script in `package.json`; CI (`.github/workflows/ci.yml`) runs exactly `tsc --noEmit` and `vitest run` on ubuntu and windows, both of which this machine reproduces (ubuntu side). The 136 skipped tests are pre-existing. No suite needs a database, Docker or credentials. ## Deferred findings - **`src/commands/project.ts:57-58` — `resolveProjectName` splits `cwd` and `homedir()` on `/` only.** On Windows `process.cwd()` is `C:\Users\me\my-app`, so a bare `insta project create` would slugify the whole path to `c-users-me-my-app`, and the "cwd is the home directory" guard can never match. `test/create-name.test.ts` only passes POSIX strings, so the Windows CI job does not catch it. A fix (`path.basename`) changes the project name the command provisions, so it is a product call; not changed. - **`src/commands/postgres.ts:26-33, 126-133, 228-233, 258-263, 292-297`** — five identical blocks build the `?branch=&group=` suffix by hand in `dbAlwaysOn`, `dbLimits`, `dbStats`, `dbVolume` and `dbRestart`; the new shared `qs({ branch, group: service })` would express each in one line. Only the pure line-builders in that module are tested, not these command bodies, so left as is. - **`src/commands/compute.ts`** (`lifecycle`, `computeStatus`, `serviceAlwaysOn`, `computeScale`, `computeRemoveInstance`, `serviceVolume`, `serviceLimits`) — the same load-client / require-project / GET services / `resolveSoleService` prologue is repeated eight times; `storage.ts` already has a `storageTarget` helper for exactly this shape. These command bodies have no test coverage, so not refactored. - **`src/commands/deploy.ts:140` and `:229`** — the identical 409 rewrap `.catch` (`repoConnectedHint`) appears in `prepareSource` (tested) and `deploy()` (not tested). Not extracted because one of the two call sites is uncovered. - **`src/commands/auth.ts:71-75` and `:87-91`** — `loginOauth` and `loginDevice` end in the same five lines (set session, GET `/me`, set session with user, persist, print). Only the dispatch layer is tested (`test/login-dispatch.test.ts`); left. - **`src/commands/mcp.ts:363-371`** — `installFor` parses the existing JSON config once for the "already configured" check and `renderJsonConfig` parses it again. Harmless; folding them would change the exported `renderJsonConfig` contract, so left. Co-Authored-By: Claude (claude-fable-5-1) --- src/commands/metrics.ts | 8 +------- src/commands/services.ts | 7 +++++++ src/commands/storage.ts | 9 +-------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/commands/metrics.ts b/src/commands/metrics.ts index b275987..270c19e 100644 --- a/src/commands/metrics.ts +++ b/src/commands/metrics.ts @@ -1,12 +1,6 @@ import { ApiClient, requireProject } from '../api.js' import { info, printJson } from '../util.js' - -function qs(params: Record): string { - const u = new URLSearchParams() - for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) - const s = u.toString() - return s ? `?${s}` : '' -} +import { qs } from './services.js' // One printed series line. Pure seam so the formatting is testable without a backend. // diff --git a/src/commands/services.ts b/src/commands/services.ts index dae9eae..27ecab7 100644 --- a/src/commands/services.ts +++ b/src/commands/services.ts @@ -10,6 +10,13 @@ export function q(branch?: string): string { return branch ? `?branch=${encodeURIComponent(branch)}` : '' } +export function qs(params: Record): string { + const u = new URLSearchParams() + for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) + const s = u.toString() + return s ? `?${s}` : '' +} + // ---- pure, unit-tested helpers (throw plain Errors; the CLI guard turns them into clean output) ---- // Validate a service-type argument against the allowed set for a command. diff --git a/src/commands/storage.ts b/src/commands/storage.ts index 702effd..a729938 100644 --- a/src/commands/storage.ts +++ b/src/commands/storage.ts @@ -6,18 +6,11 @@ import { Readable } from 'node:stream' import { pipeline } from 'node:stream/promises' import { ApiClient, requireProject } from '../api.js' import { info, printJson, handleApproval } from '../util.js' -import { q, resolveSoleService, parseAccess } from './services.js' +import { q, qs, resolveSoleService, parseAccess } from './services.js' import { fmtBytes } from './postgres.js' // the repo's tested bytes formatter — don't grow a third copy type Common = { branch?: string; service?: string; json?: boolean } -function qs(params: Record): string { - const u = new URLSearchParams() - for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) - const s = u.toString() - return s ? `?${s}` : '' -} - // Page size the listing route accepts. Junk must fail here, not travel as `limit=NaN`. export function parseObjectLimit(raw: string): number { const n = Number(raw) From f7f29fb8f2b6e5943a60bfb06deba6c799ed51d0 Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:16:38 +0000 Subject: [PATCH 2/6] chore(yun-tianming): share the query-string helper between storage and metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 2. Thanks for the independent diff check and the cycle/side-effect verification. **Addressed** - **Direct `qs` unit test** — added `describe('qs')` in `test/services.test.ts` with four cases pinning the shared contract: `{}` and all-absent params return `''` (not a bare `?`); `undefined` and `''` are skipped while remaining keys keep insertion order; values are encoded the `URLSearchParams` way (`'a b+c&d'` → `a+b%2Bc%26d`); and `qs({ branch })` agrees with `q(branch)` for a branch without spaces, so the two adjacent helpers' only divergence is documented in a test. 4 new tests, all pass. - **`q()` / `qs()` encode differently** and **`''`-skipping is now a shared contract** — both now stated in a three-line comment above `qs` in `src/commands/services.ts` (skips `undefined` and `''`, returns `''` when nothing is left, space becomes `+` where `q` emits `%20`). Comment only; the function body is still the verbatim original. **Declined** - **Move `qs` to `util.ts`** — kept beside `q()` in `services.ts`. The helper is now tested and commented in one place, and moving it alone would split the two query builders across modules while eight importers of `q()` stay put. If the pair is ever relocated together, it is a one-commit follow-up; not doing it in a PR that merges unread. - **`String(v)` no-op** — left verbatim so the move stays byte-identical to both originals. Trivially droppable in the same follow-up as the placement question. - **`postgres.ts` / `compute.ts` local `const qs = new URLSearchParams()`** — noted; the `postgres.ts` entry in Deferred findings now implies renaming those locals first. `tsc` would catch a collision, so no risk here. - **CI confirmation** — I cannot query GitHub from this environment (`gh` is not permitted). Both jobs run exactly the two commands reported below, and the ubuntu side is reproduced locally. **Verification** ``` npm run typecheck # tsc -p tsconfig.json --noEmit → exit 0 npm test # vitest run → 107 files passed, 2128 passed, 136 skipped, 29.3s ``` Baseline on `main` @ d075ab7 was 2124 passed / 136 skipped; the delta is the four new `qs` cases. No lint script exists in `package.json`. Co-Authored-By: Claude (claude-fable-5-1) --- src/commands/services.ts | 3 +++ test/services.test.ts | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/commands/services.ts b/src/commands/services.ts index 27ecab7..db76102 100644 --- a/src/commands/services.ts +++ b/src/commands/services.ts @@ -10,6 +10,9 @@ export function q(branch?: string): string { return branch ? `?branch=${encodeURIComponent(branch)}` : '' } +// Multi-param form of `q`, shared by storage and metrics. Skips undefined and '' (so a caller can +// never send an intentionally-empty param) and returns '' rather than a bare '?' when nothing is +// left. Encodes via URLSearchParams, so a space becomes '+' where `q` would emit '%20'. export function qs(params: Record): string { const u = new URLSearchParams() for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) diff --git a/test/services.test.ts b/test/services.test.ts index 3ca3c40..bd16783 100644 --- a/test/services.test.ts +++ b/test/services.test.ts @@ -1,9 +1,29 @@ import { describe, it, expect } from 'vitest' import { assertType, assertServiceName, parseCount, parsePort, parseAccess, resolveServiceId, resolveComputeServiceId, SERVICE_TYPES, - servicesAddRequestBody, servicesAdd, serviceListLine, serviceAddedLine, parsePgVersion, + servicesAddRequestBody, servicesAdd, serviceListLine, serviceAddedLine, parsePgVersion, q, qs, } from '../src/commands/services.js' +// `qs` is shared by storage and metrics, so its contract is pinned here rather than only through +// the path builders of those modules. +describe('qs', () => { + it('returns an empty string, not a bare "?", when every param is absent', () => { + expect(qs({})).toBe('') + expect(qs({ branch: undefined, group: '' })).toBe('') + }) + it('skips undefined and empty-string values, keeping the rest in insertion order', () => { + expect(qs({ branch: 'main', group: undefined, prefix: '', limit: '50' })).toBe('?branch=main&limit=50') + }) + it('encodes values the URLSearchParams way (space becomes "+", "+" and "&" are escaped)', () => { + expect(qs({ prefix: 'a b+c&d' })).toBe('?prefix=a+b%2Bc%26d') + }) + // q() uses encodeURIComponent, so the two helpers only diverge on a literal space. + it('agrees with q() for a branch name without spaces', () => { + expect(qs({ branch: 'feat/x' })).toBe(q('feat/x')) + expect(qs({ branch: undefined })).toBe(q(undefined)) + }) +}) + describe('assertType', () => { it('accepts valid service types', () => { for (const t of SERVICE_TYPES) expect(() => assertType(t)).not.toThrow() From fd9f5023c776385b5968501f5740c68941798a52 Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:19:42 +0000 Subject: [PATCH 3/6] chore(yun-tianming): share the query-string helper between storage and metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 3. **Addressed** - `test/services.test.ts:20` — valid. Checked empirically: `encodeURIComponent` and `URLSearchParams` diverge on space (`%20` vs `+`) and on `!`, `'`, `(`, `)`, `~` (left bare vs percent-encoded). Reworded the comment to name that set instead of claiming space is the only difference, and retitled the test to match. The source comment in `src/commands/services.ts` only gives space as an example, so it was left as is. **Declined** - None. **Verification** - `npm run typecheck` — clean. - `npm test` — 107 files, 2128 passed, 136 skipped (pre-existing skips), 0 failed. - No `lint` script exists in `package.json`, so no lint gate to run. Co-Authored-By: Claude (claude-fable-5-1) --- test/services.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/services.test.ts b/test/services.test.ts index bd16783..c8af9d2 100644 --- a/test/services.test.ts +++ b/test/services.test.ts @@ -17,8 +17,9 @@ describe('qs', () => { it('encodes values the URLSearchParams way (space becomes "+", "+" and "&" are escaped)', () => { expect(qs({ prefix: 'a b+c&d' })).toBe('?prefix=a+b%2Bc%26d') }) - // q() uses encodeURIComponent, so the two helpers only diverge on a literal space. - it('agrees with q() for a branch name without spaces', () => { + // q() uses encodeURIComponent, which differs from URLSearchParams on a space ('%20' vs '+') and on + // the characters it leaves bare (! ' ( ) ~). For everything else the two helpers agree. + it('agrees with q() for a branch name without those characters', () => { expect(qs({ branch: 'feat/x' })).toBe(q('feat/x')) expect(qs({ branch: undefined })).toBe(q(undefined)) }) From 7c886ce1012eb775b472c5cb25b783c13d72f0b5 Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:22:10 +0000 Subject: [PATCH 4/6] chore(yun-tianming): share the query-string helper between storage and metrics Review round 4. **Addressed** - **Divergence comment on `qs` (Suggestion 1, `src/commands/services.ts:13-15`)**: widened the doc comment from "a space becomes `+`" to the real contract: form-urlencoded escapes more than `encodeURIComponent`, so space is `+` not `%20`, and `~ ' ( ) !` are percent-encoded where `q` leaves them bare, with a note that swapping one helper for the other changes the wire format. Verified in Node: `qs({branch:"a~b'c(d)e!f*g h"})` gives `?branch=a%7Eb%27c%28d%29e%21f*g+h`, `q` gives `?branch=a~b'c(d)e!f*g%20h`. - **Test name (Suggestion 1, `test/services.test.ts`)**: renamed to `agrees with q() for an alphanumeric branch path`, since `feat/x` is the only input it covers. Added one test that pins the divergence above for both helpers, so the comment is now backed by an assertion rather than prose. The test comment itself was already corrected in `fd9f502` (cubic thread marked addressed). - **Explicitly-empty params (Suggestion 2)**: added the line to the `qs` comment: skipping `''` means a caller can never send `?prefix=`, and if you need one, don't reach for this helper. Behaviour unchanged. **Declined** - **Information notes** (partial de-dup in `postgres.ts` and friends, placement in `services.ts` vs `util.ts`, dead `String(v)`): no change requested by the reviewer and none made. The `postgres.ts` hand-rolled query strings remain in the PR's Deferred findings; `String(v)` kept verbatim to keep this a pure move. **Verification** ``` npm run typecheck -> tsc --noEmit, exit 0 npx vitest run -> 107 files, 2129 passed | 136 skipped, 0 failed ``` No lint script exists in this repo. Co-Authored-By: Claude (claude-fable-5-1) --- src/commands/services.ts | 9 ++++++--- test/services.test.ts | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/services.ts b/src/commands/services.ts index db76102..273cf9a 100644 --- a/src/commands/services.ts +++ b/src/commands/services.ts @@ -10,9 +10,12 @@ export function q(branch?: string): string { return branch ? `?branch=${encodeURIComponent(branch)}` : '' } -// Multi-param form of `q`, shared by storage and metrics. Skips undefined and '' (so a caller can -// never send an intentionally-empty param) and returns '' rather than a bare '?' when nothing is -// left. Encodes via URLSearchParams, so a space becomes '+' where `q` would emit '%20'. +// Multi-param form of `q`, shared by storage and metrics. Skips undefined and '' and returns '' +// rather than a bare '?' when nothing is left. That means a caller can never send an +// intentionally-empty param (e.g. `?prefix=`); if you need one, don't reach for this helper. +// Encodes via URLSearchParams (form-urlencoded), which escapes more than `q`'s encodeURIComponent +// does: a space becomes '+' rather than '%20', and `~ ' ( ) !` are percent-encoded where `q` leaves +// them bare. Swapping one helper for the other changes the wire format for such values. export function qs(params: Record): string { const u = new URLSearchParams() for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) diff --git a/test/services.test.ts b/test/services.test.ts index c8af9d2..6aa71a2 100644 --- a/test/services.test.ts +++ b/test/services.test.ts @@ -19,10 +19,15 @@ describe('qs', () => { }) // q() uses encodeURIComponent, which differs from URLSearchParams on a space ('%20' vs '+') and on // the characters it leaves bare (! ' ( ) ~). For everything else the two helpers agree. - it('agrees with q() for a branch name without those characters', () => { + it('agrees with q() for an alphanumeric branch path', () => { expect(qs({ branch: 'feat/x' })).toBe(q('feat/x')) expect(qs({ branch: undefined })).toBe(q(undefined)) }) + it('diverges from q() on a space and on the punctuation encodeURIComponent leaves bare', () => { + const v = "a~b'c(d)e!f*g h" + expect(qs({ branch: v })).toBe('?branch=a%7Eb%27c%28d%29e%21f*g+h') + expect(q(v)).toBe("?branch=a~b'c(d)e!f*g%20h") + }) }) describe('assertType', () => { From 4fbc86458a58cf84a045dc0afaa903013ddd837d Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:26:48 +0000 Subject: [PATCH 5/6] chore(yun-tianming): share the query-string helper between storage and metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 5. Thanks for the thorough pass. Two small follow-ups landed this round; the rest is answered below. **Addressed** - **Dead `String(v)` cast** (`src/commands/services.ts:21`): deleted. Under `strict: true` the `v !== undefined && v !== ''` guard narrows `v` to `string`, so `u.set(k, v)` typechecks and the emitted string is identical by construction. Took the "just delete the no-op" branch of your suggestion rather than widening the signature (see Declined). - **Pin the `'0'` case** (`test/services.test.ts`): added `keeps a "0" value rather than treating it as absent`, asserting `qs({ limit: '0' })` → `?limit=0` and `qs({ from: '0', to: '0' })` → `?from=0&to=0`. One correction to the premise, though: a string `'0'` is truthy in JS, so an `if (v)` guard would *not* drop it under the current `string | undefined` signature. I checked the `if (v)` variant directly under Node and it returns `?limit=0`. The test is kept as a contract pin (only `undefined` and `''` count as absent) and its comment says plainly that it only becomes a discriminating case once the parameter accepts numbers. **Declined** - **Move `q`/`qs` to `util.ts`**: agreed it's the better home, but it relocates an export that nine modules import and crosses module boundaries, which is outside what this unread-merge PR should carry. Deferred: move `q` and `qs` together with the divergence comment in a dedicated PR. - **Widen to `string | number | undefined` and drop the call-site ternaries**: changes the helper's signature and three call sites in two other modules. Behaviour would be identical, but it's a cross-module API change, so it goes with the same follow-up as the move. The dead cast is gone in the meantime, so the "cast inside and outside" state no longer exists. - **`qs` local-variable collision in `postgres.ts` / `compute.ts`**: noted and recorded against the deferred `?branch=&group=` collapse; nothing to change here. - **`null` not handled**: agreed it's unreachable under the typed signature; no change. - **cubic inline comment on the test comment**: already fixed in fd9f502. The comment now names the actual divergence set (space plus `! ' ( ) ~`), which matches the `diverges from q()` assertion. **Verification** ``` npm run typecheck # clean npx vitest run # 107 files, 2130 passed | 136 skipped (baseline before this round: 2129 passed | 136 skipped) ``` No lint script exists in `package.json`. Co-Authored-By: Claude (claude-fable-5-1) --- src/commands/services.ts | 2 +- test/services.test.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/commands/services.ts b/src/commands/services.ts index 273cf9a..709c6e3 100644 --- a/src/commands/services.ts +++ b/src/commands/services.ts @@ -18,7 +18,7 @@ export function q(branch?: string): string { // them bare. Swapping one helper for the other changes the wire format for such values. export function qs(params: Record): string { const u = new URLSearchParams() - for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, String(v)) + for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') u.set(k, v) const s = u.toString() return s ? `?${s}` : '' } diff --git a/test/services.test.ts b/test/services.test.ts index 6aa71a2..d118ca0 100644 --- a/test/services.test.ts +++ b/test/services.test.ts @@ -14,6 +14,13 @@ describe('qs', () => { it('skips undefined and empty-string values, keeping the rest in insertion order', () => { expect(qs({ branch: 'main', group: undefined, prefix: '', limit: '50' })).toBe('?branch=main&limit=50') }) + // Only undefined and '' count as absent. '0' is a real value: metrics' `--from` can resolve to epoch 0 + // and arrives here stringified. (The string '0' is truthy, so this does not distinguish the current + // guard from `if (v)`; it pins the contract for whoever widens the signature to numbers later.) + it('keeps a "0" value rather than treating it as absent', () => { + expect(qs({ limit: '0' })).toBe('?limit=0') + expect(qs({ from: '0', to: '0' })).toBe('?from=0&to=0') + }) it('encodes values the URLSearchParams way (space becomes "+", "+" and "&" are escaped)', () => { expect(qs({ prefix: 'a b+c&d' })).toBe('?prefix=a+b%2Bc%26d') }) From 89e072ee6c734656303a03f1ac63f3e0287d798d Mon Sep 17 00:00:00 2001 From: Yun Tianming <32749865+Fermionic-Lyu@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:29:09 +0000 Subject: [PATCH 6/6] chore(yun-tianming): share the query-string helper between storage and metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 6. Thanks for the approval. One cosmetic item taken this round; everything else stays as follow-up. **Addressed** - **`qs` above the "pure, unit-tested helpers" banner** — moved the divider up so `q` and `qs` sit below it (`src/commands/services.ts`). Pure reorder inside one module: exported names, signatures and bodies are unchanged (`git diff --stat`: 2 insertions, 2 deletions, one file). - **cubic inline comment on `test/services.test.ts:20`** — already fixed in fd9f502; the comment now names `! ' ( ) ~` alongside the space, matching the divergence test below it. No further change. **Declined** - **Move `q` + `qs` to `util.ts`** — agreed it's the right destination once a third unrelated group needs it, and agreed with you that it isn't worth churning now. It moves exports across ten importing modules, which is outside what this unread-merge PR may do. Deferred finding: relocate `q`/`qs` together with the divergence comment in a dedicated PR when the next consumer appears. - **Fold the five `postgres.ts` `?branch=&group=` blocks onto `qs`** — those command bodies have no test coverage, so the collapse has no evidence of behaviour preservation. Deferred finding: cover the bodies, rename the six local `const qs = new URLSearchParams()` declarations (and `compute.ts:338`), then fold. Noted as a tracked follow-up per your request rather than only in the PR body. - **Branch prefix** — the sweep's branch name is set by the wrapper, not by this PR; cosmetic under squash merge. - **Test-count delta** — confirmed environment-gated as you described; local run is 2130/136, nothing to chase. **Verification** - `npm run typecheck` → exit 0 - `npx vitest run` → 107 files, 2130 passed, 136 skipped (identical before and after the reorder) - No lint script in `package.json`. Co-Authored-By: Claude (claude-fable-5-1) --- src/commands/services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/services.ts b/src/commands/services.ts index 709c6e3..b1184a2 100644 --- a/src/commands/services.ts +++ b/src/commands/services.ts @@ -6,6 +6,8 @@ export const SERVICE_TYPES = ['postgres', 'storage', 'compute', 'redis', 'mysql' export type ServiceType = (typeof SERVICE_TYPES)[number] const SERVICE_NAME_RE = /^[a-z0-9][a-z0-9-]{0,38}$/ +// ---- pure, unit-tested helpers (throw plain Errors; the CLI guard turns them into clean output) ---- + export function q(branch?: string): string { return branch ? `?branch=${encodeURIComponent(branch)}` : '' } @@ -23,8 +25,6 @@ export function qs(params: Record): string { return s ? `?${s}` : '' } -// ---- pure, unit-tested helpers (throw plain Errors; the CLI guard turns them into clean output) ---- - // Validate a service-type argument against the allowed set for a command. export function assertType(type: string, allowed: readonly string[] = SERVICE_TYPES): asserts type is ServiceType { if (!allowed.includes(type)) throw new Error(`type must be ${allowed.join('|')}`)