Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Plan: Update init command with interactive mode

  • Add interactive mode when init is invoked without arguments

    • Prompt user to select engine (Copilot, Claude, or Codex)
    • If Copilot selected: generate Copilot YAML config and mcp.json
    • For each engine: inspect environment for secrets
    • Recommend and attempt to create secrets using gh command
    • Ask confirmation before configuring secrets
    • Gracefully handle permission errors when setting secrets
  • Implementation approach:

    • Modified init_command.go to detect when no engine/flags provided
    • Added InitRepositoryInteractive function using huh library for prompts
    • Reused existing MCP setup functions when Copilot selected
    • Check environment variables for engine-specific secrets
    • Used existing tokens_bootstrap.go logic for secret recommendations
    • Attempted to create secrets with gh secret set command
    • Added confirmation prompt using huh.Confirm before setting secrets
    • Enhanced error handling to detect and report permission issues
    • NEW: Use EngineName constants from constants.go for type safety
    • NEW: Renamed mcp variable to copilotMcp for clarity
  • Testing:

    • Add unit tests for interactive mode detection
    • Add tests for precondition checks (CI/test mode blocking)
    • All existing init tests pass
    • Verified non-interactive mode still works with flags
    • Verified help text displays correctly
  • Documentation:

    • Updated command help text with interactive mode section
    • Added examples showing interactive usage
  • Code Quality:

    • All linting passing
    • Code formatted successfully
    • Build succeeds
    • Using typed constants for better code maintainability

Summary

Successfully implemented interactive mode for the init command with all requested improvements:

  1. Interactive engine selection with confirmation prompts
  2. Graceful permission error handling
  3. Type-safe engine constants usage
  4. Clear variable naming (copilotMcp)
Original prompt

Update the init command behavior as follows:

When the command is invoked without arguments, it should enter an interactive mode and prompt the user to select which agent engine to use: Copilot, Claude, or Codex.

If Copilot is selected:

  • Generate the Copilot YAML configuration file.
  • Create the mcp.json file.

For each engine, inspect the environment for the corresponding secrets. If the required secrets are present:

  • Recommend that the user configure them as repository Actions secrets.
  • Attempt to create those secrets using the gh command.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update init command to support interactive mode and engine selection Add interactive engine selection and secret configuration to init command Jan 21, 2026
Copilot AI requested a review from pelikhan January 21, 2026 18:27
@pelikhan
Copy link
Contributor

@copilot ask confirmation before configuring secrets, gracefully handle the case where gh does not have enough permissions to set the secret.

…sion error handling

- Add interactive confirmation prompt before setting repository secrets
- Gracefully handle permission errors (403, Forbidden) with clear messaging
- Display specific error messages for permission issues vs other failures
- Skip setting secrets if user declines confirmation

Co-authored-by: pelikhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot ask confirmation before configuring secrets, gracefully handle the case where gh does not have enough permissions to set the secret.

Added in commit f254409:

  1. Confirmation prompt: Users are now asked to confirm before configuring secrets using an interactive huh.Confirm prompt
  2. Permission error handling: The code now detects 403/Forbidden/permission errors and displays:
    • Specific message: "Insufficient permissions to set {SECRET_NAME}"
    • Helpful guidance: "You may need to grant additional permissions to your GitHub token"
    • Clear distinction between permission errors and other failures

The secret configuration continues with remaining secrets even if one fails due to permissions.

pkg/cli/init.go Outdated
label string
description string
}{
{"copilot", "GitHub Copilot", "GitHub Copilot CLI with agent support"},
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot use types and constants defined in constants.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in commit fd1ffd0 to use constants.CopilotEngine, constants.ClaudeEngine, and constants.CodexEngine instead of string literals.

pkg/cli/init.go Outdated
}

// Configure engine-specific settings
mcp := false
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot rename to copilotMcp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to copilotMcp in commit fd1ffd0.

- Use constants.CopilotEngine, constants.ClaudeEngine, constants.CodexEngine instead of string literals
- Rename variable mcp to copilotMcp for clarity

Co-authored-by: pelikhan <[email protected]>
Copilot AI requested a review from pelikhan January 21, 2026 19:56
@pelikhan pelikhan marked this pull request as ready for review January 21, 2026 20:16
@pelikhan pelikhan merged commit a4f098b into main Jan 21, 2026
47 of 48 checks passed
@pelikhan pelikhan deleted the copilot/update-init-command-behavior branch January 21, 2026 20:53
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