feat(sdk): add --field option to api command with proto-aware completion#1195
Draft
dqn wants to merge 7 commits into
Draft
feat(sdk): add --field option to api command with proto-aware completion#1195dqn wants to merge 7 commits into
dqn wants to merge 7 commits into
Conversation
`completion.custom.resolve` (in-process JS resolver that sees other arg values) is needed by the upcoming `tailor-sdk api --field` proto-aware completion. PR toiroakr/politty#353 adds it; replace with the released version once published.
`tailor-sdk api <endpoint> -f key=value` (`--field`) lets users set request body fields without writing JSON. Dotted keys build nested objects (`-f application.name=foo`); `--field` overrides matching keys in `--body`; values are strings only. Field names tab-complete from the endpoint's proto schema, with step-by-step completion of nested message fields (bash / zsh / fish). Implemented via politty's new `completion.custom.resolve` resolver, which receives the entered endpoint as `parsedArgs.endpoint` and the previously-supplied `-f` values for de-duplication.
🦋 Changeset detectedLatest commit: fc00ae5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
⚡ pkg.pr.new@tailor-platform/sdk@tailor-platform/create-sdk
|
This comment has been minimized.
This comment has been minimized.
Adds value-side completion to `tailor-sdk api -f key=value`: enum-typed fields offer their value names and bool-typed fields offer `true`/`false`, inferred from the endpoint's proto schema. Scalar, message, list, and map fields stay free-form.
…uild pnpm caches `pkg.pr.new` URLs in three layers (store index DB, lockfile, hoisted node_modules) and `pnpm install --force` / `update` / `--fix-lockfile` alone can't pull in a refreshed PR tarball. Adding a `?v=YYYYMMDD` query parameter to the override URL forces a new cache key. Bump this value whenever PR #353 is repushed.
The previous cache-buster (?v=20260521) ended up serving a stale build that pre-dated the dedup commit on politty's PR. Bump to ?v=20260522 to force pnpm to refetch and pick up the `_used_field_keys` tracker that de-dupes repeated `-f key=value` slots.
Switch the `--field` completion from politty's dynamic JS resolver to the new `expand` variant. Candidates (key=, key=ENUM_VALUE, key=true/false, key. drill-down) are enumerated once at script-generation time and inlined into the shell completion script keyed by the `endpoint` positional. TAB no longer spawns a Node process — the shell dispatches via a static lookup table, and politty's `_used_field_keys` tracker dedupes repeated key= slots within a single `api` invocation.
Code Metrics Report (packages/sdk)
Details | | main (d3d984f) | #1195 (32ef49f) | +/- |
|--------------------|----------------|-----------------|-------|
+ | Coverage | 61.9% | 62.0% | +0.1% |
| Files | 363 | 363 | 0 |
| Lines | 12651 | 12701 | +50 |
+ | Covered | 7833 | 7881 | +48 |
+ | Code to Test Ratio | 1:0.4 | 1:0.4 | +0.0 |
| Code | 82915 | 83195 | +280 |
+ | Test | 34645 | 34810 | +165 |Code coverage of files in pull request scope (94.7% → 95.1%)
SDK Configure Bundle Size
Runtime Performance
Type Performance (instantiations)
Reported by octocov |
…be fix The refreshed build drops the `--` separator before `-S ''` so `_describe` treats the suffix as a compadd option rather than an additional name group, restoring the no-trailing-space behavior on `key=` candidates.
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
Add
tailor-sdk api <endpoint> -f key=valueso users can set request-bodyfields without writing JSON, with proto-driven tab completion of field
names (including dotted nested paths) across bash / zsh / fish.
Main changes
--field/-f(repeatable) onapi. Dotted keys build nestedobjects (
-f application.name=foo);--fieldoverrides matching keysin
--body. Values are strings only — use--bodyfor non-stringscalars.
-f application.<TAB>lists children of
application,=is appended on leaves and.onmessages. Enum-typed and bool-typed leaves additionally surface their
value set inline (e.g.
role=TEAM_ROLE_ADMIN,disabled=true).Previously-supplied keys are de-duped per-invocation via politty's
_used_field_keystracker.into the shell completion script via politty's
expandvariant —TAB looks them up from the inlined table keyed on the
endpointpositional, with no Node process spawn per keystroke.
polittytohttps://pkg.pr.new/politty@353for theexpand_used_field_keyssupport. Existing completion tests adapted tothe new async
generateCandidates(ctx, { shell })signature.Performance
Per-TAB latency for
tailor-sdk api GetFunctionExecution -f <TAB>(bash completion sourced in a loop,
gdatewall clock):resolve(politty's JS resolver; spawns__completein Node per TAB)expand(table inlined into the generated script, this PR)resolve-case cost is dominated by Node startup + SDK module load.Notes
feat(completion): add in-process JS resolver for dynamic value completion toiroakr/politty#353 ships. That PR has grown from ~1,500 lines
(
resolveonly) to 6,000+ lines asexpandand its stabilizationfixes landed.
resolveand switching the CLI to a Bun-shippedbinary instead of moving to
expand.bun runagainst the samedist already cuts the
resolve-case to ~420 ms/TAB (vs node's~952 ms), and
bun build --compilewould shave more — but compileis currently blocked: the CLI eagerly loads native deps
(
oxc-parser,rolldown/oxc-resolver,@napi-rs/keyring) thatfail to load inside Bun's bundled VFS, and fixing that needs
lazy-loading or shimming all of them. Even an optimistic
~200 ms compiled-bun cold start is still ~400× the ~0.45 ms
expandlookup, so revertingexpandto keepresolvedoesn'tcarry.
--body(e.g.'"str"') combined with--fieldisrejected — there's no sensible merge target.