Skip to content

feat(cli): add shell completion metadata#646

Draft
dqn wants to merge 8 commits intomainfrom
feat/cli-shell-completion
Draft

feat(cli): add shell completion metadata#646
dqn wants to merge 8 commits intomainfrom
feat/cli-shell-completion

Conversation

@dqn
Copy link
Contributor

@dqn dqn commented Mar 1, 2026

Upgrade politty to v0.4.3 and add completion properties to CLI arg definitions for context-aware shell completion.

Main Changes

  • Upgrade politty from v0.4.0 to v0.4.3
  • Add completion properties to CLI args:
Type Arg Matcher/Extensions
file --env-file matcher: [".env.*", ".env"]
file --env-file-if-exists matcher: [".env.*", ".env"]
file --config extensions: ["ts"]
directory --dir
directory --output
none --workspace-id
none --profile
  • Extract shared configArg to eliminate duplication across config-accepting commands
  • Add 12 completion tests covering subcommand/option regression and directive verification

How to verify

Source the completion script in your shell:

# zsh
eval "$(pnpm -C packages/sdk exec tailor-sdk completion zsh)"

# bash
eval "$(pnpm -C packages/sdk exec tailor-sdk completion bash)"

Then try:

tailor-sdk <TAB>                                    # subcommands
tailor-sdk apply --<TAB>                            # option names
tailor-sdk apply --config <TAB>                     # .ts files only
tailor-sdk apply --env-file <TAB>                   # .env files only
tailor-sdk staticwebsite deploy --dir <TAB>         # directories only
tailor-sdk workspace user invite --role <TAB>       # admin/editor/viewer

Notes

  • Existing z.enum() args (e.g., --role) auto-complete via politty's built-in enum detection without explicit completion property

dqn added 2 commits March 1, 2026 11:56
Add completion properties to CLI arg definitions for context-aware
shell completion: file completion for config/env-file args, directory
completion for dir/output args, and suppressed file fallback for
workspace-id/profile args. Existing z.enum() args (e.g., role) already
auto-complete via politty's built-in enum detection.

Add comprehensive completion tests covering subcommand/option name
completion (regression guard) and new completion property verification
(file, directory, none, enum directives).
@changeset-bot
Copy link

changeset-bot bot commented Mar 1, 2026

🦋 Changeset detected

Latest commit: f602e81

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

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
Copy link

pkg-pr-new bot commented Mar 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@tailor-platform/create-sdk@646

commit: 36c85ec

@github-actions

This comment has been minimized.

@toiroakr
Copy link
Contributor

toiroakr commented Mar 1, 2026

It can be handled as a separate task, but I'd like to restrict --env-file specifically to .env files.
Perhaps it would be better to allow a syntax like matcher: [.env.*] instead of using extensions. (Maybe directory as well?)

@dqn
Copy link
Contributor Author

dqn commented Mar 1, 2026

It can be handled as a separate task, but I'd like to restrict --env-file specifically to .env files.
Perhaps it would be better to allow a syntax like matcher: [.env.*] instead of using extensions. (Maybe directory as well?)

I think adding something like matcher: [".env.*"] filtering to politty would be the right approach. I'm planning to update politty for performance improvements, so let's release matcher support together with that update.

dqn added 4 commits March 2, 2026 14:14
…0.4.2

Restrict --env-file and --env-file-if-exists completion to .env files
using politty's new matcher glob pattern support. Also fix type error
in options.test.ts by using SubCommandValue from politty.
Fix truncated pipe output when sourcing completion scripts via eval.
…tion

# Conflicts:
#	packages/sdk/src/cli/commands/generate/service.ts
#	packages/sdk/src/cli/commands/tailordb/migrate/generate.ts
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Code Metrics Report (packages/sdk)

main (669693d) #646 (36c85ec) +/-
Coverage 50.2% 50.3% +0.0%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (669693d) | #646 (36c85ec) |  +/-  |
  |--------------------|----------------|----------------|-------|
+ | Coverage           |          50.2% |          50.3% | +0.0% |
  |   Files            |            258 |            258 |     0 |
  |   Lines            |           8672 |           8673 |    +1 |
+ |   Covered          |           4362 |           4363 |    +1 |
+ | Code to Test Ratio |          1:0.4 |          1:0.4 |  +0.0 |
  |   Code             |          50113 |          50233 |  +120 |
+ |   Test             |          20169 |          20282 |  +113 |

Code coverage of files in pull request scope (12.7% → 13.0%)

Files Coverage +/- Status
packages/sdk/src/cli/commands/staticwebsite/deploy.ts 3.9% 0.0% modified
packages/sdk/src/cli/commands/tailordb/erd/export.ts 2.8% 0.0% modified
packages/sdk/src/cli/commands/tailordb/migrate/generate.ts 0.8% 0.0% modified
packages/sdk/src/cli/shared/args.ts 64.2% +0.6% modified

SDK Configure Bundle Size

main (669693d) #646 (36c85ec) +/-
configure-index-size 9.34KB 9.34KB 0KB
dependency-chunks-size 32.64KB 32.64KB 0KB
total-bundle-size 41.98KB 41.98KB 0KB

Runtime Performance

main (669693d) #646 (36c85ec) +/-
Generate Median 2,522ms 2,617ms 95ms
Generate Max 2,645ms 2,665ms 20ms
Apply Build Median 2,640ms 2,685ms 45ms
Apply Build Max 2,702ms 2,711ms 9ms

Type Performance (instantiations)

main (669693d) #646 (36c85ec) +/-
tailordb-basic 157,161 157,161 0
tailordb-optional 5,240 5,240 0
tailordb-relation 5,147 5,147 0
tailordb-validate 4,004 4,004 0
tailordb-hooks 7,157 7,157 0
tailordb-object 12,944 12,944 0
tailordb-enum 3,872 3,872 0
resolver-basic 13,799 13,799 0
resolver-nested 30,546 30,546 0
resolver-array 22,590 22,590 0
executor-schedule 12,583 12,583 0
executor-webhook 9,138 9,138 0
executor-record 13,770 13,770 0
executor-resolver 16,476 16,476 0
executor-operation-function 9,116 9,116 0
executor-operation-gql 9,119 9,119 0
executor-operation-webhook 9,132 9,132 0
executor-operation-workflow 10,413 10,413 0

Reported by octocov

@dqn
Copy link
Contributor Author

dqn commented Mar 3, 2026

This PR is ready to merge once the minimumReleaseAge constraint on the politty 0.4.4 package is lifted (currently 3 days after release).

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