Skip to content

feat(cli)!: move server commands under patchula remote and keep local commands local - #380

Merged
sweepies merged 3 commits into
mainfrom
feat/remote-namespace
Nov 23, 2026
Merged

sweepies merged 3 commits into
mainfrom
feat/remote-namespace

Conversation

@sweepies

@sweepies sweepies commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Separates local execution from server execution by moving every server-backed command into a dedicated patchula remote namespace.

Summary of changes

  • New patchula remote namespace: lookup, run [--dry-run], tui [--once], login, and logout, each accepting --server <URL> (overriding PATCHULA_SERVER).
    • When neither --server nor PATCHULA_SERVER is set and a single repository is targeted (inferred from the checkout's GitHub remote or named directly), patchula remote validates the owner/repo slug, resolves the advertising bot's GitHub App via /apps/{slug} before contacting advertised hosts (capped at 5 distinct servers per scan), verifies the App binding, and remembers (server, app) in remotes.json once sign-in or the run succeeds (with a stderr notice).
    • Using remotes.json avoids breaking upgrades from legacy repositories.json files.
    • patchula remote logout forgets both the server's token and any remembered repositories using it (and can infer the server from the current checkout's remembered entry). Unreachable remembered servers hint at patchula remote logout --server ....
    • Local-only flags (--cache, --config, --config-dir, --settings, --concurrency, --all-repos, --default-config, --allow-lockfile-pending, --recheck) do not exist under patchula remote, removing the local_flags() conflict table.
  • Local commands stay local: apply, lookup, tui, and run always run on this machine and never read remotes.json or prompt to switch to a server. Removed --remote, --here, and top-level patchula auth.
  • patchula run always targets GitHub: both run and run --dry-run read GitHub (inferring this checkout's GitHub remote when no repository is named) with no pushed() clean-tree/default-branch check. Added --dir <DIR> (requiring --dry-run) for planning from a local directory (used by mise run corpus:check).
  • Scoped --recheck: moved --recheck <WHEN> off global root flags onto run and serve.
  • Docs & snapshots: regenerated crates/cli/tests/help.txt and docs/src/content/docs/reference/cli.md, documented remote discovery and sign-in in docs/src/content/docs/internals/threat-model.md, and updated guides, reference pages, README.md, docs/agent-setup.md, skills/patchula/SKILL.md, and PatchulaSettings.pkl.

Verification

  • cargo test --locked -p patchula-cli (96 unit tests + 17 integration tests)
  • cargo test --locked -p patchula-server (55 tests)
  • cargo clippy --locked -p patchula-cli -p patchula-server --all-targets -- -D warnings
  • mise run docs:build (38 pages, all internal links valid)

… commands local

Separate server execution from local commands by replacing --remote, --here,
patchula auth, and the interactive per-checkout server prompt with a dedicated
`patchula remote` namespace (`lookup`, `run`, `tui`, `login`, `logout`).

- Top-level `apply`, `lookup`, `tui`, and `run` always run on this machine and
  never read `repositories.json` or talk to a server.
- `patchula run` always targets GitHub (inferring this checkout's repository
  when omitted), even with `--dry-run`, removing the `pushed()` clean-tree and
  default-branch gate. `run --dry-run --dir <DIR>` plans from a local directory
  when needed (such as `corpus:check`).
- `patchula remote` takes `--server <URL>` (also `PATCHULA_SERVER`), discovers
  and caches the server advertised by a single repository when neither is set,
  and never exposes local-only flags.
- Move `--recheck` off global root flags onto `run` and `serve`.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 2c40243 Commit Preview URL

Branch Preview URL
Nov 23 2026, 07:06 AM

…ghten hints

Addresses every finding from the adversarial review of PR #380:

- Store remembered remote servers in `remotes.json` so legacy `repositories.json`
  files (with `remote: bool`) never break `patchula remote logout` or discovery.
- Validate `owner/repo` slugs before API calls, resolve GitHub `/apps/{slug}`
  before contacting advertised hosts, and cap distinct servers probed per scan (5).
- Persist newly discovered pins only after login or the remote run succeeds, with
  a one-line notice on stderr naming the server, App client ID, and logout command.
- Attach a `patchula remote logout --server ...` hint when a remembered server is
  unreachable.
- Stop suggesting `--default-config` when `run --dry-run --dir` lacks a config;
  point to `--config FILE` instead.
- Move `--server <URL>` onto each `remote` subcommand so `Usage:` and CLI docs
  list it with accurate precedence/discovery help text.
- Document remote discovery and sign-in in `docs/src/content/docs/internals/threat-model.md`.
- Add unit tests for legacy `repositories.json`, checkout `login`/`logout` + failed
  login, `remote_target` precedence/validation, probe ordering/cap, unreachable
  remembered-server hints, and `run --dry-run --dir` planning.
@sweepies
sweepies merged commit 9e11474 into main Nov 23, 2026
13 checks passed
@sweepies
sweepies deleted the feat/remote-namespace branch November 23, 2026 07:19
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 23, 2026
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