Skip to content

Add vector api passthrough command#30

Merged
itspriddle merged 12 commits into
mainfrom
worktree-api-cmd
Jun 3, 2026
Merged

Add vector api passthrough command#30
itspriddle merged 12 commits into
mainfrom
worktree-api-cmd

Conversation

@itspriddle
Copy link
Copy Markdown
Member

@itspriddle itspriddle commented May 30, 2026

Summary

Adds a vector api <endpoint> passthrough command modeled on gh api, so users
can 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

  • Generic client methodClient.Do(ctx, method, path, headers, body) on
    internal/api, sharing the existing auth / base-URL / error-code pipeline.
    Caller headers override the defaults (Authorization, Accept, User-Agent).
  • Base commandvector api <endpoint> with smart path resolution: a
    leading / is sent verbatim, otherwise /api/v1/vector/ is prepended
    (sites/api/v1/vector/sites). Raw response output, pretty-printed when
    JSON; the persistent --jq filter applies to the full envelope.
  • Method + body-X/--method (auto-POST when fields/--input are 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[]=value opts into arrays. --input <file|-> sends a raw body and is
    mutually exclusive with the field flags.
  • Custom headers — repeatable -H/--header key:value, overriding defaults.
  • Response inspection-i/--include prints the status line + response
    headers; --verbose echoes the resolved request to stderr (stdout stays
    pipeable).
  • Auto-pagination--paginate follows meta pages and merges each data
    array 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, and e2e/api.bats.

Testing

make check passes in full (fmt-check + vet + lint + test + test-e2e +
check-surface + check-skill-drift + tidy-check) — 297 e2e tests green, including
the new api cases.

Notes for reviewers

  • History contains per-story fix-up commits (gate fixes and missed flag docs).
    Squashing each story's commit pair before merge is reasonable if a clean
    one-commit-per-story history is preferred.
  • The man-page e2e test (e2e/manpage.bats) only enforces command-level
    documentation, 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.

itspriddle added 12 commits May 30, 2026 12:34
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.
@itspriddle itspriddle merged commit ee4ec82 into main Jun 3, 2026
4 checks passed
@itspriddle itspriddle deleted the worktree-api-cmd branch June 3, 2026 13:37
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