Skip to content

refactor: shared CloudflareCommand base and clearer errors - #6

Merged
jordanpartridge merged 1 commit into
mainfrom
cursor/shared-command-base-6412
Sep 15, 2026
Merged

jordanpartridge merged 1 commit into
mainfrom
cursor/shared-command-base-6412

Conversation

@jordanpartridge

@jordanpartridge jordanpartridge commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rebased onto latest main. Instead of a separate abstract CloudflareCommand (main already uses InteractsWithCloudflare + OutputsJson), this PR:

  • Adds shared resolveZoneId, truncate, and formatApiError helpers to InteractsWithCloudflare
  • Removes duplicated helpers from DNS commands
  • Modernizes dns:delete / dns:update onto the shared traits (no exit(1))
  • Uses formatApiError on zone/tunnel failure paths
  • Aligns tunnel:get JSON with the agent envelope

Test plan

  • vendor/bin/pest locally
  • CI green
  • Spot-check dns:delete / dns:update / tunnel:get --json
Open in Web Open in Cursor 

@jordanpartridge
jordanpartridge force-pushed the cursor/shared-command-base-6412 branch from ea8bbef to 07ee936 Compare September 10, 2026 05:53

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

  • Removes all bare exit(1) calls in favor of returning FAILURE.
  • New base class centralizes token handling, zone resolution, and error formatting.
  • Test covers the missing-token case.

Three files still carry the now-unused InteractsWithCloudflare import after the inheritance change (TunnelCreate/Delete/List). Minor cleanup only.

@jordanpartridge

Copy link
Copy Markdown
Contributor Author

Only TunnelCreateCommand still uses InteractsWithCloudflare, and that is on purpose: create-time token / credentials display lives on the trait. Delete and list already extend CloudflareCommand with no leftover import.

Move resolveZoneId/truncate/formatApiError onto InteractsWithCloudflare,
modernize dns:delete and dns:update onto the shared traits (no exit(1)),
and use formatApiError across zone/tunnel failure paths.

Co-authored-by: Jordan Partridge <jordan@partridge.rocks>
@cursor
cursor Bot force-pushed the cursor/shared-command-base-6412 branch from 07ee936 to d581768 Compare September 13, 2026 00:46

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

  • Base trait + resolveZoneId/formatApiError centralizes the duplicated logic that was scattered across every command.
  • All error paths now surface the Cloudflare errors.0.message when present; raw body only as fallback.
  • getConnector now returns nullable and the commands check it, removing the bare exit(1) calls.
  • Test expectations updated to match the new jsonSuccess/jsonFail payload shape.
  • No correctness or safety regressions observed.

@jordanpartridge
jordanpartridge marked this pull request as ready for review September 13, 2026 00:47

@lexi-chief-of-staff lexi-chief-of-staff Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it.

  • Centralizes resolveZoneId, truncate, formatApiError in InteractsWithCloudflare; all prior duplicates removed.
  • DNS delete/update now use traits + jsonFail instead of exit(1) and error().
  • formatApiError applied to every failure path; JSON envelope aligned on tunnel:get.
  • Tests updated for new payload shape.

No blocking issues. Minor duplication note between resolveZoneId and resolveZoneIdForHostname, but not a correctness problem.

@jordanpartridge
jordanpartridge merged commit 47dcbde into main Sep 15, 2026
1 check passed
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.

2 participants