Commit graph

1790 commits

Author SHA1 Message Date
A
5dfb91b747
security: fix checksum grep anchoring and tar path traversal in github-auth.sh (#2213)
* security: fix checksum grep anchoring and tar path traversal in github-auth.sh

- Anchor grep with -F " ${tarball}" to prevent partial filename matches
  in checksum validation (e.g. foo.tar.gz matching foo.tar.gz.sig)
- Add pre-extraction validation rejecting tarballs with absolute paths
  or ../ traversal components (CWE-22), cross-platform (GNU + BSD tar)

Fixes #2211
Fixes #2212

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: anchor checksum grep with two-space prefix and EOL to prevent partial match

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-05 05:41:48 -08:00
A
475a1772a7
test: Remove always-pass conditional guards in icon-integrity tests (#2214)
The `if (parsed.success)` and `if (id in SOURCES)` guards inside test
bodies were redundant — an `expect(...).toBe(true)` assertion always
precedes them, so the inner expects would only be skipped if the test
was already failing. Replace with early-return guards that make the
control flow explicit and remove the nested indirection.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 07:51:52 -05:00
A
02931cfa32
security: verify gh binary checksum and safe JSON parsing in github-auth.sh (#2210)
Fixes #2209

- Replace sed-based JSON parsing with jq/bun-eval for safe tag_name extraction
- Add SHA256 checksum verification before extracting gh binary tarball
- Add semver format validation for parsed version strings

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-05 05:49:23 -05:00
A
5cc75eb558
docs: Sync README with source of truth (#2207)
Remove --debug row from commands table: it exists in the codebase
(index.ts) but is not listed in getHelpUsageSection() in help.ts,
which is the source of truth for the README commands table.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
2026-03-05 01:17:56 -08:00
A
a3ddb40f72
test: Remove remaining always-pass patterns in icon-integrity tests (#2208)
Two "is actual PNG data" tests (agent and cloud) silently passed without
asserting anything when the PNG file was missing. The `if (!existsSync)
{ return; }` guard let the test return early with no expectations, so a
missing file would register as a green test instead of a failure.

Fix: replace the early-return guard with an unconditional
`expect(existsSync(pngPath)).toBe(true)` so missing files fail the test
immediately. The "is actual PNG data" test is now self-contained and
does not rely on its sibling "exists" test having already failed.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:50:02 -05:00
Ahmed Abushagur
07c2c08e3a
revert: remove Packer snapshot pipeline (#2205)
DO snapshots are private and account-scoped — users on different
accounts cannot see snapshots built by the CI token. Docker images
are the better approach for cross-account pre-built agents.

Removes: packer/, packer-snapshots workflow, snapshot lookup code,
and snapshot test. Reverts DO CLI to plain cloud-init flow.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 02:48:52 -05:00
Ahmed Abushagur
96ffb3e201
fix(packer): pass var file explicitly to packer build (#2203)
Packer wasn't auto-loading build.auto.pkrvars.json, causing
"Unset variable" errors. Pass it explicitly with -var-file.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 01:16:41 -05:00
A
aa84bcf94c
test: Remove always-pass patterns in icon-integrity tests (#2202)
Three groups of tests in icon-integrity.test.ts silently passed without
asserting anything when their conditional guard was false:

- Agent manifest icon URL test: `if (parsed.success)` wrapped the only
  expect, so a missing `icon` field on any agent would silently pass
- Agent .sources.json ext test: double-conditional (`id in AGENT_SOURCES`
  then `if (parsed.success)`) hid both the membership check and parse
  result, providing zero signal when either condition failed
- Cloud .sources.json ext test: same double-conditional pattern

Fix: add unconditional `expect(...).toBe(true)` assertions before each
guard so failures surface as actual test failures rather than silently
passing. The TypeScript narrowing guards remain for type safety.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-04 21:19:35 -08:00
Ahmed Abushagur
ed98a59318
feat(digitalocean): Packer nightly snapshot pipeline for fast boot (#2198)
* feat(digitalocean): Packer nightly snapshot pipeline for fast boot

Add pre-built Packer snapshots for DigitalOcean droplets. Instead of
10-20 min cloud-init + agent install on every boot, snapshot-based
droplets boot in ~2-3 min (SSH only, agent pre-installed).

- Packer HCL2 template with parametrized agent/tier builds
- Agent build matrix (packer/agents.json) for all 7 agents
- Tier scripts mirroring cloud-init.ts package tiers
- Nightly GitHub Actions workflow (4 AM UTC, max-parallel: 3)
- Automatic cleanup: keeps only latest snapshot per agent
- CLI: findSpawnSnapshot() looks up pre-built images via DO API
- CLI: waitForSshOnly() skips cloud-init when using snapshots
- CLI: createServer() accepts optional snapshotId, skips user_data
- CLI: main.ts routes to fast path when snapshot detected
- Tests for findSpawnSnapshot() (5 cases, all passing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(packer): use var-file for install_commands to avoid shell quoting issues

The previous approach passed install_commands as `-var` inline, but
GitHub Actions expands `${{ }}` before shell evaluation — JSON arrays
with `|`, `&&`, and `"` characters break shell quoting.

Fix: generate a `.auto.pkrvars.json` file (auto-loaded by Packer)
using jq with --argjson for safe JSON handling. Also route all
`${{ inputs }}` and `${{ matrix }}` values through env vars to
prevent script injection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 20:47:46 -08:00
A
3242fa78f1
fix(oauth): URL-encode callback_url query parameter (#2201)
The OAuth callback URL (http://localhost:PORT/callback) was interpolated
directly into the auth URL query string without encoding. The colons and
slashes could cause ambiguous parsing on strict URL parsers or proxies,
potentially breaking the OAuth flow. Other parameters in the same URL
(spawn_agent, spawn_cloud) were already correctly encoded.

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 23:19:15 -05:00
A
701e3af56e
fix: prevent timer leaks and event-loop stalls in SSH timeout handling (#2200)
- Unref the SIGKILL timer in killWithTimeout() so it doesn't keep the
  event loop alive for 5 extra seconds after a timed-out process exits
- Wrap all setTimeout/clearTimeout pairs in try/finally across 6 cloud
  providers (12 call sites) to guarantee cleanup on exceptions
- Add missing 60s timeout guard to runSpriteSilent() which could hang
  indefinitely on unresponsive sprite processes

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 19:04:47 -08:00
A
2fea3de685
refactor: Remove dead exports from delete.ts helper functions (#2199)
ensureDeleteCredentials() and execDeleteServer() were exported but never
imported outside of delete.ts itself. Remove the export keywords to match
their actual internal-only usage. No behavior change.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 22:03:39 -05:00
A
62a904b535
test: Remove duplicate and theatrical tests (#2197)
* test: Consolidate redundant per-property tests in script-failure-guidance

Each describe block for an exit code (127, 126, 1, default, null, 130,
137, 255, 2) and signal (SIGKILL, SIGTERM, SIGINT, SIGHUP) had multiple
separate it() tests all calling the same pure function with the same
arguments — one assertion per test. Since the function is pure and
deterministic, these redundant calls add overhead without adding signal.

Merge per-argument test groups into single tests that check all
properties at once. All 3240 expect() calls are preserved; 38 redundant
test wrappers are removed (1395 → 1357 tests).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: Remove duplicate and theatrical tests

Remove two redundant structural tests from getScriptFailureGuidance:
- "should always return an array of strings" — proven by every
  content-checking test above it (they all call the function and
  assert on its elements)
- "should never return an empty array" — same: every toContain/
  toHaveLength assertion already implies a non-empty result

Keeps the useful "different output per exit code" uniqueness test.

Test count: 1411 → 1409 (2 removed, 0 failures).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: Remove duplicate and theatrical tests

- Remove theatrical "should always return string arrays" test from
  getSignalGuidance: TypeScript already guarantees string[] return type;
  testing it at runtime with Array.isArray/typeof adds zero signal
- Replace 149 (c: any[]) parameter annotations with (c: unknown[])
  across 13 test files to comply with the no-as/no-any policy
- Fix mockSuccessfulFetch(data: any) → (data: unknown) in test-helpers.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-04 18:41:03 -08:00
L
4a3a6ed27f
fix: suppress Claude Code workspace trust prompt on provisioned VMs (#2192)
The "Quick safety check: Is this a project you created or one you trust?"
prompt fires per-workspace and is not suppressed by hasCompletedOnboarding
or --dangerously-skip-permissions (anthropics/claude-code#28506).

Fix: inject a workspace trust entry keyed by $HOME into ~/.claude.json
with hasTrustDialogAccepted: true. The JSON is now constructed on the
remote side so $HOME resolves to the actual path (/root, /home/user, etc).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 17:11:42 -08:00
Ahmed Abushagur
7cb33f9bd6
fix(openclaw): supervise gateway with systemd + cron heartbeat (#2196)
* fix(openclaw): supervise gateway with systemd + cron heartbeat

The OpenClaw gateway daemon (port 18789) was started via setsid/nohup
with zero supervision — if it crashed, got OOM-killed, or exited, the
TUI became useless. This was the root cause of OpenClaw dying on
DigitalOcean and other clouds.

On Linux with systemd:
- Install a systemd service with Restart=always, RestartSec=5
- Add an hourly cron heartbeat that checks port 18789 and restarts
  the service if dead (belt-and-suspenders for edge cases)
- Base64-encode the wrapper script and unit file to avoid
  heredoc/quoting issues across cloud SSH implementations

On macOS/local (no systemd):
- Keep the existing setsid/nohup approach as fallback

Also adds a gateway pre-check to the TUI launch command so the
orchestrate.ts restart loop ensures the gateway is alive before
each TUI restart.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* style: fix biome formatting (prefer single quotes for shell strings)

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
2026-03-04 22:47:18 +00:00
A
49e1c80597
test: Remove duplicate and theatrical tests (#2195)
Remove two redundant structural tests from getScriptFailureGuidance:
- "should always return an array of strings" — proven by every
  content-checking test above it (they all call the function and
  assert on its elements)
- "should never return an empty array" — same: every toContain/
  toHaveLength assertion already implies a non-empty result

Keeps the useful "different output per exit code" uniqueness test.

Test count: 1411 → 1409 (2 removed, 0 failures).

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 15:46:55 -05:00
L
846d655706
perf: fetch SSH key list once before loop in ensureSshKey() (#2194)
Both Hetzner and DigitalOcean were calling GET /ssh_keys inside the
per-key loop, causing N redundant API round-trips when a user had
multiple local SSH keys. Move the fetch outside the loop so it runs
exactly once regardless of how many keys are being registered.

Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 14:47:21 -05:00
A
711ed70b22
feat: propagate host git identity to remote VMs during GitHub setup (#2193)
When users opt into GitHub CLI setup, capture their local git
user.name and user.email and apply them on the remote VM via
git config --global, so spawned machines inherit the correct
identity instead of defaulting to generic values.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 13:50:19 -05:00
A
4d44353464
fix: ensure all icons are PNG and add icon-integrity test (#2191)
- Convert zeroclaw icon from mislabeled JPEG to actual PNG
- Fix zeroclaw .sources.json ext from "jpg" to "png"
- Fix zeroclaw manifest icon URL from .jpg to .png
- Add icon-integrity.test.ts (54 tests) that validates:
  - Every agent/cloud icon exists as .png in assets/
  - Every .png file contains actual PNG data (magic bytes check)
  - Manifest icon URLs end with {id}.png
  - .sources.json ext fields are all "png"
  - No .jpg files exist in asset directories

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 09:38:07 -08:00
A
48da6d8735
refactor: Remove dead code and stale references (#2189)
- Drop unnecessary `export` from `createAgents` and `resolveAgent` in
  agent-setup.ts — both are internal helpers only ever called within the
  same module via `createCloudAgents`; no external caller imports them
- Fix misleading relative-path sourcing example in github-auth.sh header
  comment — the shell-script rules ban relative `source ./` paths, and the
  example is updated to show the correct CDN eval pattern
- Bump CLI patch version 0.12.17 → 0.12.18

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-04 11:56:37 -05:00
A
50b096b02d
test: Consolidate redundant per-property tests in script-failure-guidance (#2190)
Each describe block for an exit code (127, 126, 1, default, null, 130,
137, 255, 2) and signal (SIGKILL, SIGTERM, SIGINT, SIGHUP) had multiple
separate it() tests all calling the same pure function with the same
arguments — one assertion per test. Since the function is pure and
deterministic, these redundant calls add overhead without adding signal.

Merge per-argument test groups into single tests that check all
properties at once. All 3240 expect() calls are preserved; 38 redundant
test wrappers are removed (1395 → 1357 tests).

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 11:55:10 -05:00
A
193f3777a3
test: Remove duplicate and theatrical tests (#2187)
- Consolidate 3 identical-setup "both 404" tests into 1 test checking all assertions at once
- Consolidate 2 identical-setup "both 500" tests into 1 test
- Consolidate 4 near-identical network-error tests into 2 tests (error message + troubleshooting hints)
- Remove duplicate validatePrompt max-length test (10KB+1 bytes) already covered in security.test.ts

Removes 6 tests total (1401 → 1395). No behavior coverage lost.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-04 13:32:01 +00:00
A
035c09c9bb
docs: Sync README with source of truth (#2188)
- Gate 1 (Matrix drift): manifest.json has 7 agents (hermes added) and
  49 implemented combinations; README tagline said "6 agents / 42
  combinations" and the matrix table was missing the Hermes Agent row
- Gate 2 (Commands drift): --headless, --output json, and --custom flags
  exist in help.ts getHelpUsageSection() but were absent from the
  README commands table

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 08:30:17 -05:00
A
083c103ab9
fix(run): suppress duplicate failure output on SSH disconnect (exit 255) (#2186)
When SSH disconnects with exit code 255, the server is still running.
Previously the warn message ("SSH connection lost") was followed by the
full reportScriptFailure block, which was contradictory. Now we return
undefined after the warn so reportScriptFailure is skipped entirely.

Fixes #2185

Agent: issue-fixer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 07:16:49 -05:00
A
03cc7f4132
fix(interactive): honour --dry-run flag in single-agent interactive path (#2184)
When a user ran `spawn claude --dry-run`, the dry-run flag was silently
ignored and a real server was provisioned. `cmdAgentInteractive` was
passing `dryRun` in the `debug` parameter position of `execScript`, so
no preview was shown and `SPAWN_DEBUG=1` was set instead.

Fix:
- Export `showDryRunPreview` from `run.ts`
- Import and call it in `cmdAgentInteractive` after cloud selection
- Return early when `dryRun` is set (matches `cmdRun` behaviour)
- Pass `undefined` for the `debug` argument (interactive path has no
  debug flag)

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 06:14:50 -05:00
Ahmed Abushagur
c9ea6384da
fix(history): merge connection into history.json immediately at provision time (#2177)
Previously, saveVmConnection wrote to a single last-connection.json temp
file that was only merged into history.json lazily when spawn ls was run.
This caused connections to be silently dropped when:
- Two servers spawned before running spawn ls (file overwritten)
- The last history record already had a connection (merge skipped)

Now saveVmConnection writes directly into history.json by finding the
most recent record matching the cloud with no connection yet. The temp
file is still written for backward compatibility but is no longer the
primary storage.

Also fixes saveLaunchCmd to update history.json directly, and
consolidates sprite's local saveVmConnection to use the shared one.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: A <258483684+la14-1@users.noreply.github.com>
2026-03-04 01:36:28 -08:00
A
cb91b5d236
refactor: fix stale comments referencing renamed functions (#2182)
- Update key-request.sh comment that referenced non-existent
  loadTokenFromConfig function in digitalocean.ts
- Update test comments referencing validateAgent/validateCloud
  which were renamed to validateEntity

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 01:35:18 -08:00
A
c77cab0fff
fix(security): add --proto '=https' to update-check and update command curl calls (#2183)
The auto-update path in update-check.ts and the manual `spawn update` command
in commands/update.ts were missing --proto '=https' on their curl calls that
download and execute the install script. Without it, curl may follow redirects
to non-HTTPS URLs on hostile networks (MITM/DNS hijacking).

- update-check.ts: add --proto =https to execFileSync curl args
- commands/update.ts: replace execSync shell pipe with safe two-step
  execFileSync pattern (fetch script via curl --proto =https, then
  execute via bash -c) — matches the pattern already in update-check.ts

Same vulnerability class as PR #2172 (TypeScript files) and PR #2160 (shell
scripts); those PRs missed these two code paths.

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 04:18:56 -05:00
A
9376884009
feat(qa): add record-keeper teammate to QA bot (#2176)
Add a 5th teammate (record-keeper) to the QA quality cycle that keeps
README.md in sync with source-of-truth files. Uses a conservative
three-gate check (matrix drift, commands drift, troubleshooting gaps)
and only makes changes when drift is detected. Includes safeguards:
30-line diff limit, prohibited sections list, and source citations
required in PR body.

Co-authored-by: spawn-bot <spawn-bot@openrouter.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 00:23:03 -08:00
A
c8581b7958
fix(security): add --proto '=https' to TypeScript curl provisioning calls (#2172)
* fix(security): add --proto '=https' to curl calls in TypeScript provisioning

Fixes #2169

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix(lint): break long lines for biome format compliance

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-04 00:21:37 -08:00
A
3f8a9d7432
fix: use caduceus ⚕ icon for hermes agent (#2181)
Replace the Nous Research org avatar with the actual Staff of Hermes
(⚕) symbol from the hermes-agent page favicon. Sourced from the
WordPress emoji SVG and converted to 180x180 PNG.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-04 00:07:48 -08:00
A
1f879e1d1e
chore: refresh agent GitHub stars and icon metadata (#2179)
Notable star count changes:
- openclaw: 212,334 → 256,970 (+44,636)
- opencode: 107,223 → 115,408 (+8,185)
- zeroclaw: 15,177 → 21,867 (+6,690)
- claude: 67,857 → 73,410 (+5,553)
- codex: 61,159 → 62,925 (+1,766)
- hermes: 1,016 → 1,617 (+601)
- kilocode: 15,619 → 16,172 (+553)

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:49:15 -08:00
A
bfe53524c1
docs: add mandatory bun install step to worktree workflow (#2180)
Worktrees don't share node_modules with the main checkout. Without
`bun install`, tests and biome fail with "Cannot find package" errors
that block the pre-merge hook.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:48:38 -08:00
A
8eb5f8476c
chore: rename fixture files from snake_case to kebab-case (#2167)
Renames create_server, delete_server, ssh_keys, and server_types
fixture JSON files to kebab-case for consistency with codebase
conventions. Updates _metadata.json keys and qa-fixtures-prompt
naming convention accordingly.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:35:43 -08:00
L
61bcedc0eb
feat: migrate to openrouter.ai/labs/spawn CDN + release artifact version checks (#2178)
* feat: migrate shell script URLs to openrouter.ai/labs/spawn CDN

Users on older CLI versions can't auto-update because the repo was restructured
(cli/ → packages/cli/), so old version-check URLs 404. This decouples the CLI
from the repo's internal directory structure:

- Shell script URLs (install, agent scripts, github-auth) now use
  openrouter.ai/labs/spawn/* as primary with GitHub raw as fallback
- Version checks now use GitHub release artifact (cli-latest/version)
  as primary — a static URL that never changes regardless of repo layout
- CI workflow updated to publish a `version` file alongside cli.js
- Remove GITHUB_RAW_URL_PATTERN validation (no longer needed since
  install URL is now a hardcoded CDN string, not interpolated)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: fix biome formatting in update-check test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: CLAUDE.md says biome lint but should say biome check

biome lint only checks lint rules, not formatting. biome check does both.
The hooks and CI already run biome check — the docs were out of sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(hooks): PostToolUse hook wasn't running biome on CLI source files

Two bugs in validate-file.ts:

1. Config search only checked 1-2 levels up from the edited file, but
   biome.json is at packages/cli/ — 3 levels above src/__tests__/*.ts.
   Fix: walk up directories until biome.json is found (or hit root).

2. Ran `biome format` (prints formatted output, always exits 0) instead
   of `biome format --check` (exits non-zero if file needs formatting).
   Fix: use `biome check` which does lint + format check in one pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:34:58 -08:00
A
67443aa4b3
chore: add pre-merge hook to gate gh pr merge/ready on lint + tests (#2173)
Adds a PreToolUse hook for Bash that intercepts `gh pr merge` and
`gh pr ready` commands and runs `biome check src/` + `bun test` before
allowing them. Blocks the command if either check fails.

The hook finds the worktree from the command path or falls back to
git rev-parse --show-toplevel.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:29:26 -08:00
A
446923c447
refactor: extract inline hook commands to TypeScript scripts (#2174)
* refactor: extract inline hook commands to TypeScript scripts in .claude/scripts/

Replace long inline `bash -c '...'` one-liners in .claude/settings.json with
standalone TypeScript scripts that are easier to read, debug, and maintain:

- enforce-worktree.ts: PreToolUse hook ensuring edits happen in worktrees
- validate-file.ts: PostToolUse hook for .sh/.ts file validation
- pre-merge-check.ts: PreToolUse hook running biome + tests before merge

Add .claude/scripts as a bun workspace package (@spawn/hooks).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: replace manual typeguards with valibot schemas in hook scripts

- Extract shared schemas (FilePathInput, CommandInput, parseStdin) to schemas.ts
- Replace inline multi-level typeof/in checks with v.safeParse() calls
- Add valibot dependency to @spawn/hooks package
- Add CLAUDE.md rule: always prefer valibot over manual typeguards, share schemas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: split CLAUDE.md into modular .claude/rules/ files

Split the 437-line monolithic CLAUDE.md into a lean 89-line project overview
plus 9 focused rules files in .claude/rules/ (auto-loaded by Claude Code):

- culture.md — embrace bold changes, parallelize, verify exhaustively
- shell-scripts.md — curl|bash compat, macOS bash 3.x, ESM only, bun not python
- type-safety.md — no `as` assertions, ALWAYS use valibot (never manual typeguards)
- testing.md — bun:test only, no vitest, no subprocess spawning
- git-workflow.md — worktree-first mandatory workflow
- autonomous-loops.md — discovery/refactor service architecture
- discovery.md — how to fill matrix gaps, add clouds/agents
- documentation.md — never commit docs, use .docs/
- cli-version.md — bump version on every CLI change

The type-safety rule now explicitly mandates valibot schemas over manual
typeguard chains in all cases beyond single-primitive narrowing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(lint): run biome check across all packages in CI

The lint workflow only checked packages/cli/src/. Now it checks all
TypeScript locations in a single biome check command:

- packages/cli/src/ (with GritQL plugins)
- packages/shared/src/ (new biome.json)
- .claude/scripts/ (new biome.json)
- .claude/skills/setup-spa/

Fixed all pre-existing lint/format errors:
- node: protocol on all Node.js built-in imports in hook scripts
- useBlockStatements in packages/shared/src/type-guards.ts
- expand formatting in .claude/skills/setup-spa/main.ts and spa.test.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 23:05:41 -08:00
A
6e375d8b29
fix: restore hyphens in OAuth code regex + add regression test (#2171)
* fix: restore hyphens/underscores in OAuth code regex + add test (#2116)

PR #2116 broke OAuth by restricting the auth code regex to alphanumeric
only. OAuth providers (GitHub, Google, etc.) use hyphens and underscores
in their auth codes, so the stricter regex rejected valid codes.

Changes:
- Extract OAUTH_CODE_REGEX as an exported constant from oauth.ts
- Restore `_-` in the character class: [a-zA-Z0-9_-]{16,128}
- Add oauth-code-validation.test.ts with 20 tests covering:
  - Real-world provider formats (hyphens, underscores, mixed)
  - Length bounds (16–128)
  - Injection prevention (shell, XSS, path traversal, null bytes)
  - Character class completeness (explicit regression test for #2116)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* ci: retrigger checks

* fix: restore hyphens in OAuth code regex + add regression test

PR #2116 broke OAuth by restricting the auth code regex to alphanumeric
only. OAuth providers (GitHub, Google) use hyphens and underscores in
their auth codes, so the stricter regex rejected valid codes.

- Extract OAUTH_CODE_REGEX to oauth-constants.ts (zero-dep, testable)
- Restore `_-` in character class: [a-zA-Z0-9_-]{16,128}
- Add regression test covering valid formats, length bounds, injection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: spawn-bot <spawn-bot@openrouter.ai>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 22:52:29 -08:00
A
7c516ac887
fix(history): smart trimming evicts deleted records first, archives overflow (#2168)
* fix(history): smart trimming evicts deleted records first, archives overflow

When history exceeds 100 entries, deleted records (useless for `spawn ls`)
are now evicted first. If still over the limit, oldest non-deleted records
are also trimmed. All evicted records are archived to dated backup files
(history-YYYY-MM-DD.json) so nothing is permanently lost.

Previously, blind .slice() could silently discard records with active
connections that `spawn ls` depends on.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: fix biome formatting issues

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-03 22:37:57 -08:00
A
47ba11aa50
test: Remove duplicate resolveAndLog tests from commands-swap-resolve (#2165)
The resolveAndLog via cmdRun describe block in commands-swap-resolve.test.ts
(~113 lines, 5 tests) duplicated display-name resolution coverage already
provided by commands-resolve-run.test.ts. Both files tested case-insensitive
key resolution (CLAUDE->claude, HETZNER->hetzner) and display name resolution
(Codex->codex, Sprite->sprite) on the same code path.

Removed the entire duplicate resolveAndLog section. The detectAndFixSwappedArgs
and prompt-handling-with-swapped-args sections remain, as those test distinct
behavior not covered elsewhere.

-- qa/dedup-scanner

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-03 21:49:37 -08:00
A
523ae3284d
fix(security): replace execSync shell interpolation with execFileSync array args in auto-update (#2162)
* fix(security): replace execSync shell interpolation with execFileSync array args in auto-update

Fixes #2161

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: format update-check files to pass Biome lint

Agent: pr-maintainer
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 00:25:31 -05:00
A
6334abe5a6
refactor: Remove stale comment listing untested functions in run-path test (#2166)
The block comment in run-path-credential-display.test.ts listed five
functions it claimed to test, but the file only tests two:
  - prioritizeCloudsByCredentials
  - isRetryableExitCode

Functions buildCredentialStatusLines, formatAuthVarLine, validateRunSecurity,
and validateEntities were never imported or exercised in this file. Removed
the misleading entries so the comment accurately reflects test coverage.

-- qa/code-quality

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
2026-03-04 00:24:44 -05:00
A
1097f055c3
fix(security): add --proto '=https' to all curl executable downloads (#2160)
42 curl calls downloading JS bundles, CLI binaries, and gh CLI tarballs
were missing --proto '=https', allowing protocol downgrade attacks on
hostile networks. PR #2138 fixed bun installer calls; this closes the
remaining gap for executable downloads.

Fixes applied:
- sh/{sprite,aws,gcp,hetzner,daytona,local}/{claude,codex,openclaw,opencode,kilocode,hermes,zeroclaw}.sh (42 files)
- sh/cli/install.sh (cli.js download)
- sh/shared/github-auth.sh (keyring, API, tarball downloads)

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 23:38:03 -05:00
A
251ddf2967
fix(e2e): pass env_b64 via printf stdin to eliminate interpolation risk (#2159)
Fixes #2152

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:34:31 -08:00
A
85e0c932c7
fix(ssh): use boolean flag to detect TCP probe success in waitForSsh (#2157)
When the TCP probe succeeds on the final attempt, `attempt` equals
`maxAttempts` after the loop increments it. The previous guard
`attempt >= maxAttempts` then incorrectly threw a timeout error even
though the port was open.

Fix by tracking TCP success with a `tcpOpen` boolean flag and checking
that instead of the attempt counter.

Fixes #2155

Agent: issue-fixer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-03 20:47:02 -05:00
A
4d3f2ba54a
refactor: Remove dead code and stale references (#2154)
* refactor: Remove redundant loadTokenFromConfig wrappers in hetzner, daytona, digitalocean

The previous PR (#2151) introduced shared loadApiToken() in shared/ui.ts and
updated hetzner/daytona to delegate to it via thin wrapper functions. This
commit removes the now-unnecessary wrapper functions entirely, inlining the
loadApiToken() calls directly at the callsite.

Also removes the 16-line duplicate loadTokenFromConfig() implementation in
digitalocean.ts (which replicates the same api_key/token field reading and
regex validation logic as loadApiToken) and replaces it with a direct call to
loadApiToken("digitalocean").

-- qa/code-quality

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* bump version to 0.12.12 (main already has 0.12.11)

---------

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-03 20:43:19 -05:00
A
a6b92e1e86
test: Remove theatrical test that timeouts waiting for interactive prompt (#2153)
The 'promptBundle should skip prompt without --custom' test expected
promptBundle() to return immediately when SPAWN_CUSTOM is unset. But
promptBundle() has no SPAWN_CUSTOM guard — it always shows an interactive
selection prompt unless LIGHTSAIL_BUNDLE or SPAWN_NON_INTERACTIVE=1 is set.

Without SPAWN_NON_INTERACTIVE=1, the test blocks on stdin input and hits
the 5-second bun:test timeout. When run in the full test suite it
appeared to pass due to module import caching from previous tests, making
it a flaky, non-deterministic test.

Remove the test entirely since it tests non-existent behavior.

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: L <6723574+louisgv@users.noreply.github.com>
2026-03-03 20:41:47 -05:00
A
a76bcaf7d1
fix(run): await res.text() before stopping spinner in downloadScriptWithFallback (#2158)
Fixes #2156

The spinner was stopped with a success message before the HTTP response
body stream was fully consumed. If the stream failed mid-transfer (network
drop, truncation), users saw "Script downloaded" followed by a confusing
downstream error. Now both the primary and fallback paths await res.text()
before calling s.stop().

Agent: issue-fixer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-03 20:39:52 -05:00
A
796eaa9d02
refactor: Remove dead code and stale references (#2151)
- Extract duplicate loadTokenFromConfig helper (hetzner + daytona) into
  shared loadApiToken() in shared/ui.ts, eliminating 24 lines of
  duplicate validation logic across two cloud modules
- Move misplaced FETCH_TIMEOUT and UPDATE_BACKOFF_MS constants in
  update-check.ts from the Schemas section into the Constants section
  where they belong (stale empty section header fix)

Co-authored-by: spawn-qa-bot <qa@openrouter.ai>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 13:19:01 -08:00
A
6423eb51f5
fix(security): validate env values in cloud_headless_env parser (#2146)
* fix(security): validate env values in cloud_headless_env parser

Reject values containing shell metacharacters ($, backtick, ;, &, |, <, >)
to prevent potential command injection if a cloud driver returns malicious output.

Fixes #2139

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(security): replace env value blacklist with whitelist regex

The blacklist approach missed dangerous characters like (), quotes,
backslash, newlines, {}, and !. Switch to a whitelist that only allows
[A-Za-z0-9@%+=:,./_-] — a strict safe set sufficient for env values.

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 20:49:45 +00:00