Skip to content

feat: complete worktree services and deployments in the shell - #804

Open
0xcadams wants to merge 2 commits into
0xcadams/cli-cobrafrom
0xcadams/cli-completion
Open

0xcadams wants to merge 2 commits into
0xcadams/cli-cobrafrom
0xcadams/cli-completion

Conversation

@0xcadams

Copy link
Copy Markdown
Member

What

Homebrew installs the bash, zsh and fish completions for tnl and tnld. Typing tnl connect or tnl wait --service and pressing Tab offers service names from the current worktree.

Why

The generated browser metadata has no deployment names and can omit connector-only services. Completing a name should not evaluate project code or open credentials.

Changes

  • Record a small declaration index during generation and app preparation. Read local names on Tab, with endpoint metadata as a fallback.
  • Use the Cobra tree for commands, flags and enum values. Exercise all three generated scripts and the argument separator in the built-binary suite.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T15:00:24.729551Z 5b057f2 New commits
🔒 Security Review ✅ Completed 2026-11-20T15:03:01.585139Z 5b057f2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2337cab15f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/tnl/completion.go
Comment on lines +57 to +62
for name, complete := range map[string]cobra.CompletionFunc{"service": services, "deployment": deployments} {
if cmd.Flags().Lookup(name) != nil {
if _, ok := cmd.GetFlagCompletionFunc(name); ok {
continue
}
if err := cmd.RegisterFlagCompletionFunc(name, complete); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict name completion to flags that accept service names

In a worktree with completion metadata, this registers local service-name suggestions for tnl publisher enroll --service and tnl publisher grant add --service, even though their help specifies “Exact saved service ID.” Both handlers pass that value to publisherCLIGrantScope, which rejects non-ID values with opaqueid.Valid(serviceID, opaqueid.ServicePrefix), so accepting these suggestions makes the command fail. Register project-name completion only for commands whose selectors accept those names; leave ID-only flags unregistered or give them an appropriate completer. This also preserves the service-name/service-ID distinction required by AGENTS.md.

AGENTS.md reference: AGENTS.md:L120-L121

Useful? React with 👍 / 👎.

Comment thread cmd/tnl/generate.go
Comment on lines +32 to +33
} else if err := meta.WriteCompletion(ctx, project); err != nil {
return err

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the offline-generation test for the new local index

Every successful non-check generation now creates .tnl/local/completion.json and its lock file, but TestGenerateTypesWithoutGitOriginOrRuntimeValues still runs generate and then asserts that .tnl/local does not exist (cmd/tnl/generate_test.go:45–54). Both configuration variants therefore fail with “generation wrote runtime values,” breaking the routine task go:test suite invoked by .github/workflows/checks.yml. Update that assertion to permit the completion index while retaining checks that generation does not write runtime endpoint metadata or open client state.

Useful? React with 👍 / 👎.

@0xcadams
0xcadams added this pull request to stack #809 November 20, 2026 14:56
@0xcadams
0xcadams force-pushed the 0xcadams/cli-completion branch from 1ea839e to 5b057f2 Compare November 20, 2026 14:59

This branch has not been deployed

No deployments
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