Skip to content

Make install/init non-interactive paths more accessible to agents#20

Open
cevian wants to merge 2 commits into
mainfrom
cevian/ai-friendly-install
Open

Make install/init non-interactive paths more accessible to agents#20
cevian wants to merge 2 commits into
mainfrom
cevian/ai-friendly-install

Conversation

@cevian
Copy link
Copy Markdown
Contributor

@cevian cevian commented May 27, 2026

Summary

  • When ghost init is invoked without a TTY, list the exact commands needed to finish setup non-interactively (ghost init path, ghost login, ghost mcp install all, ghost completion <shell>) instead of just saying "run it from a TTY".
  • When the curl-pipe installer (scripts/install.sh) can't reach /dev/tty, it already runs ghost init path; now it also prints the remaining commands an agent should run instead of just suggesting ghost init.
  • Motivation: AI agents driving installs can't open a TTY, so the previous messages left them without actionable next steps.

🤖 Generated with Claude Code

When ghost init or the install script can't reach an interactive terminal,
list the exact commands an agent needs to run (ghost login, ghost mcp install
all, ghost completion <shell>) instead of just telling the user to "run it
from a TTY".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cevian cevian requested a review from murrayju May 27, 2026 16:44
Comment thread internal/cmd/init.go Outdated
Comment on lines +109 to +112
1. ghost init path # add ghost to your PATH
2. ghost login # authenticate (or use --api-key)
3. ghost mcp install all # install MCP server in all detected clients (or pass a specific client name)
4. ghost completion <shell> # print completion script; append it to your shell rc file`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It'd be nice not to duplicate so much of the content from these 2 messages (and the tests).

Better yet, it'd be cool if in this case we only printed the commands which weren't already configured.

Comment thread internal/cmd/init.go Outdated
1. ghost init path # add ghost to your PATH
2. ghost login # authenticate (or use --api-key)
3. ghost mcp install all # install MCP server in all detected clients (or pass a specific client name)
4. ghost completion <shell> # print completion script; append it to your shell rc file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Running ghost completion zsh isn't really helpful - it just prints a script to the screen. You really need to modify the shell.rc to call this command correctly, which isn't adequately explained here.

I think we should add a ghost init completion command, which does this for you (we already have the code).

Address PR review feedback:
- Add `ghost init completion` subcommand that actually appends the completion
  snippet to the shell rc file, so the printed command is self-contained
  (previously `ghost completion <shell>` only printed a script).
- De-duplicate the two non-interactive error sites behind a single helper
  that detects current state and lists only the standalone commands for
  steps that aren't already configured. The --skip-if-configured hint is
  omitted when the flag was already passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cevian
Copy link
Copy Markdown
Contributor Author

cevian commented May 29, 2026

Addressed both pieces of review feedback in f19d180:

  • ghost completion <shell> was unhelpful → added a new ghost init completion subcommand that wraps the existing runInitCompletions body (which appends the sourcing line to the shell rc). The non-interactive instructions now point at that command instead.
  • Duplicated message + tests → both error sites now share nonInteractiveError(states, includeSkipHint). State is detected upfront and the message only lists commands for steps that aren't already configured. The --skip-if-configured hint is omitted when the flag was already passed.

Added two new tests (TestInit_NonInteractiveAllUnconfigured, TestInit_NonInteractiveOnlyLoginUnconfigured) to cover both the full-list and filtered cases, plus TestInitCompletionSubcommandNonInteractive for the new subcommand.

Comment thread internal/cmd/init.go

func buildInitCompletionCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "completion",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe make this completions with completion as an alias. I'm not really sure which is more correct, but we use the plural in the descriptions 😅

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