Add vector api passthrough command#30
Merged
Merged
Conversation
The passthrough command needs to send arbitrary methods, headers, and bodies through the same auth/base-URL pipeline as the typed helpers. Default Authorization, Accept, and User-Agent headers now only apply when the caller hasn't already set them, so custom headers can override the defaults.
The Do body-passthrough test compared a JSON string with assert.Equal, which testifylint's encoded-compare rule rejects. Switch to assert.JSONEq so the lint gate passes.
Add a generic "vector api <endpoint>" command that performs an authenticated GET against a resolved Vector Pro URL and prints the raw response. An endpoint beginning with "/" is sent verbatim; any other value has "/api/v1/vector/" prepended. JSON responses are pretty-printed and honor --jq on the full envelope; other bodies are written verbatim.
Add -X/--method, -f/--raw-field, -F/--field, and --input to the api command so it can create, update, and delete resources, mirroring gh api ergonomics. The method defaults to POST when fields or --input are supplied without an explicit -X. Typed -F values coerce booleans, null, and numeric literals, and load @file/@- contents. Reusing a plain field key is a loud error; the key[]=value suffix opts into array accumulation. For body-bearing methods fields become a JSON body, otherwise they are appended to the query string. --input sends a raw body from a file or stdin and is mutually exclusive with the field flags.
The new POST e2e cases must send your_customer_id and dev_php_version so Prism's OpenAPI request-body validation passes. Switch the missing-input test to require.NotErrorAs to satisfy testifylint, and document the new api flags in SKILL.md so the agent reference stays in sync.
Add a repeatable -H/--header flag to vector api. Headers are parsed from key:value specs and layered over the defaults so an explicit header wins over the client's Authorization/Accept and the JSON Content-Type set for field/input bodies. A spec without a colon is a client-side validation error (exit code 3).
Add -i/--include to print the response status line and headers before the body, and --verbose to echo the resolved request (method, URL, and body) to stderr before sending so stdout stays pipeable and jq-able.
Add the -i/--include and --verbose flags to the man page and SKILL.md and cover them with e2e cases. These were omitted from the prior commit.
Document -i/--include and --verbose in the man page and SKILL.md. The manpage and skill-drift checks only enforce command names, not flags, so these were missed when the flags first landed.
--paginate follows meta.current_page/meta.last_page, incrementing the
page query parameter and merging each page's data array into a single
JSON array so --jq applies to the combined result. Fetching stops after
a 100-page cap with a warning to stderr; a response without the
{data, meta} shape falls back to a single unchanged request. --paginate
is mutually exclusive with -i/--include.
The auto-pagination commit added the flag to .surface but not the man page or skill reference. manpage.bats only checks command names and skill-drift only checks .surface, so the gate stayed green without them; add the docs to match the auxiliary-update convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
vector api <endpoint>passthrough command modeled ongh api, so userscan call any Vector Pro API endpoint directly — bridging the gap when the API
ships an endpoint before a dedicated CLI subcommand exists.
What's included
Client.Do(ctx, method, path, headers, body)oninternal/api, sharing the existing auth / base-URL / error-code pipeline.Caller headers override the defaults (
Authorization,Accept,User-Agent).vector api <endpoint>with smart path resolution: aleading
/is sent verbatim, otherwise/api/v1/vector/is prepended(
sites→/api/v1/vector/sites). Raw response output, pretty-printed whenJSON; the persistent
--jqfilter applies to the full envelope.-X/--method(auto-POST when fields/--inputare given),-f/--raw-field(string),-F/--field(typed: bool/null/number coercion,@file/@-loading). Reused scalar keys are a loud exit-3 error (gh-style);key[]=valueopts into arrays.--input <file|->sends a raw body and ismutually exclusive with the field flags.
-H/--header key:value, overriding defaults.-i/--includeprints the status line + responseheaders;
--verboseechoes the resolved request to stderr (stdout stayspipeable).
--paginatefollowsmetapages and merges eachdataarray into one JSON array (100-page cap with a stderr warning; mutually
exclusive with
-i).Auxiliary surfaces kept in sync throughout:
.surface,skills/vector/SKILL.md,man/man1/vector.1, ande2e/api.bats.Testing
make checkpasses in full (fmt-check + vet + lint + test + test-e2e +check-surface + check-skill-drift + tidy-check) — 297 e2e tests green, including
the new
apicases.Notes for reviewers
Squashing each story's commit pair before merge is reasonable if a clean
one-commit-per-story history is preferred.
e2e/manpage.bats) only enforces command-leveldocumentation, not per-flag — which is why several flag-doc fix-up commits were
needed. A follow-up to assert flag-level coverage would close that gap.