Skip to content

feat(run-commit): accept repo:tag refs via --ref flag#186

Merged
AlephNotation merged 2 commits into
mainfrom
feat/run-commit-ref-flag
May 12, 2026
Merged

feat(run-commit): accept repo:tag refs via --ref flag#186
AlephNotation merged 2 commits into
mainfrom
feat/run-commit-ref-flag

Conversation

@nsluss
Copy link
Copy Markdown
Contributor

@nsluss nsluss commented Apr 20, 2026

Summary

vers run-commit <arg> previously always sent {commit_id: ...} to the API, which meant any non-UUID argument (e.g. a repo:tag reference like my-app:latest) hit a generic 422 from the server.

This change adds a --ref flag that switches the request payload to {ref: ...}, letting the API resolve repo tags in the caller's own org.

Also adds a friendly error when the argument looks like a repo:tag (contains :) and --ref was omitted, pointing users at the right flag instead of a cryptic 422.

Verification

The positive case was verified end-to-end against pi-agent:latest in prod.

Followups (not in this PR)

  • No unit tests yet. Happy to add table-driven tests for looksLikeRepoRef + handler-level tests mirroring internal/handlers/tags_test.go (mock httptest.NewServer, assert the request body contains "ref" vs "commit_id"). Say the word.

noah and others added 2 commits May 11, 2026 18:41
Before this change, 'vers run-commit <arg>' always sent the argument as
{"commit_id": ...} in the API request. Passing a repo:tag reference
like 'my-app:latest' failed with 422 Unprocessable Entity because the
server tried to parse it as a UUID.

--ref switches the underlying payload to {"ref": ...}, which the API
resolves against tags in the caller's own org. The positive case was
verified end-to-end against pi-agent:latest.

Also added a friendly error when the argument looks like a repo:tag
(contains ':') and --ref was omitted, pointing the user at the right
flag instead of hitting a generic 422 from the API.
Two new files, matching the existing repo test style (tags_test.go
pattern for handler tests via httptest.NewServer, routing_test.go
table-driven pattern for cmd-level pure-function tests):

  internal/handlers/run_commit_test.go:
    - TestHandleRunCommit_CommitIDPath — verifies default (IsRef=false)
      sends commit_id, no ref key in body
    - TestHandleRunCommit_RefPath      — verifies IsRef=true sends ref,
      no commit_id key
    - TestHandleRunCommit_ServerError  — verifies non-2xx surfaces as
      a caller-visible error (no silent swallowing)

  cmd/run_commit_test.go:
    - TestLooksLikeRepoRef (table-driven, 16 cases) — positive: canonical
      repo:tag shapes with various legal chars. Negative: empty/no-colon,
      malformed colon placement, chars outside the legal name set (space,
      slash, @, #, non-ASCII).
    - TestLooksLikeRepoRef_MultipleColons — documents the current (intended)
      behavior for a:b:c as NOT matching, since the second colon isn't a
      legal name char.
@AlephNotation AlephNotation force-pushed the feat/run-commit-ref-flag branch from c9ce32b to dc8dcc4 Compare May 12, 2026 01:42
@AlephNotation AlephNotation marked this pull request as ready for review May 12, 2026 01:42
@AlephNotation
Copy link
Copy Markdown
Contributor

Rebased onto current main (was based on f7af8e8 from April, missing PRs #190, #191, #196, #197). Conflict was small \u2014 just cmd/run_commit.go import block and request-building section needed to take both the F1 --json plumbing + F14 job ledger hooks AND the new --ref flag + friendly-nudge branch.

Verified locally:

  • make build, gofmt, go test ./... all clean
  • New unit tests (cmd/run_commit_test.go, internal/handlers/run_commit_test.go) pass
  • vers run-commit my-app:latest without --ref triggers the friendly nudge
  • vers run-commit some-uuid --ref --json sends {ref: ...} to the API and surfaces the API's clean error if the ref is malformed
  • vers agent-context | jq '.commands."run-commit".flags."--ref"' picks up the new flag automatically (no annotation needed)
  • The friendly nudge error message matches SKILL principle 3 (errors that teach) \u2014 includes the corrected invocation

Marked ready for review. Nothing left blocking from a tech standpoint.

@AlephNotation AlephNotation merged commit 1ffdd37 into main May 12, 2026
6 checks passed
@AlephNotation AlephNotation deleted the feat/run-commit-ref-flag branch May 12, 2026 02:29
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