Skip to content

feat(cli): add sow sandbox command + env-patch module - #4

Merged
faculopezscala merged 4 commits into
mainfrom
worktree-agent-ab597022
Apr 6, 2026
Merged

feat(cli): add sow sandbox command + env-patch module#4
faculopezscala merged 4 commits into
mainfrom
worktree-agent-ab597022

Conversation

@faculopezscala

Copy link
Copy Markdown
Contributor

Summary

Lane D of the eng review plan: a flagship zero-config CLI command and a generic env file patcher.

  • sow sandbox [url] — auto-detects the source Postgres, samples + sanitizes it, spins up a local Docker branch, and patches .env.local so npm run dev just works. Thin composition over detectConnection, createConnector, createBranch, and patchEnvFile.
  • packages/cli/src/env-patch.ts — generic env file patcher used by sow sandbox, sow branch create --env-file, and the new sow env revert. Merges keys, preserves comments and unrelated vars, writes a .sow.bak backup, supports interactive prompt + revert, and refuses to clobber existing backups.
  • sow env revert [path] — one-command undo that restores from .sow.bak.
  • sow branch create --env-file now uses patchEnvFile instead of clobbering. --append is a deprecated no-op (env-file always merges now).

Test plan

  • 13 tests for env-patch (create, merge, overwrite, no-op, prompt accept/decline, backup-collision, quoting, comments, revert happy/error)
  • 8 tests for sandbox (single candidate, no candidate, multi+json error, multi+quiet, existing branch reuse, --no-env-file, --yes, connector reuse)
  • Full vitest run: 116 tests passing (95 pre-existing + 21 new)
  • bunx tsup clean for @sowdb/cli
  • bunx eslint clean on touched files

Bisectable commits

  1. feat(cli): extract env-patch module with backup + revert
  2. refactor(cli): use env-patch in branch create --env-file
  3. feat(cli): add sow sandbox command (flagship zero-config flow)
  4. feat(cli): add sow env revert command

🤖 Generated with Claude Code

faculopezscala and others added 4 commits April 6, 2026 01:27
Adds packages/cli/src/env-patch.ts: a generic, dependency-free env file
patcher that merges keys, preserves comments and unrelated vars, writes
a .sow.bak before mutating, and supports interactive prompt + revert.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the clobber-or-append logic with patchEnvFile, which always
merges and writes a backup. The --append flag becomes a no-op with a
deprecation notice on stderr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sow sandbox is a thin composition over detectConnection, createConnector,
createBranch, and patchEnvFile. It auto-detects the source Postgres,
samples it, spins up a local Docker branch, prints DATABASE_URL, and
prompts to patch .env.local. Adds --yes / --no-env-file flags.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restores an env file from its .sow.bak backup written by patchEnvFile,
giving users a one-command undo for sow sandbox / sow branch create
--env-file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant