Skip to content

Add setup script and CLI wrapper for ms-copilot#2

Merged
JakeDot merged 1 commit intomainfrom
claude/add-setup-ms-copilot-script
Apr 7, 2026
Merged

Add setup script and CLI wrapper for ms-copilot#2
JakeDot merged 1 commit intomainfrom
claude/add-setup-ms-copilot-script

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Apr 7, 2026

Creates a setup script that aliases the main CLI wrapper as ms-copilot in the current environment and persists it across shell sessions.

Changes

  • ms-copilot-cli.sh: Main CLI entry point with commands for help, version, validate, and test-workflow
  • setup-ms-copilot.sh: Setup script that:
    • Creates ms-copilot alias in current shell session immediately
    • Detects shell type (bash/zsh/fish)
    • Optionally persists alias to appropriate RC file (.bashrc, .zshrc, or .config/fish/config.fish)
    • Prevents duplicate entries with section markers
  • README.md: Added CLI tool documentation and setup instructions

Usage

./setup-ms-copilot.sh  # Interactive setup with persistence option
ms-copilot help        # Available after setup
ms-copilot validate    # Validates GitHub Actions workflows

The alias is available immediately in the current session and optionally persisted for future sessions based on user confirmation.

- Add ms-copilot-cli.sh as main CLI wrapper with commands: help, version, validate, test-workflow
- Add setup-ms-copilot.sh that creates ms-copilot alias in current shell
- Setup script detects shell type (bash/zsh/fish) and offers to persist alias in RC files
- Update README with CLI tool documentation and setup instructions
- Fix arithmetic expansion issue in validate_workflows function

Agent-Logs-Url: https://github.com/JakeDot/ms-copilot/sessions/fd410e93-b64e-499c-b2e6-7c247f9f9d8a

Co-authored-by: JakeDot <12250212+JakeDot@users.noreply.github.com>
@Claude Claude AI assigned Claude and JakeDot Apr 7, 2026
@JakeDot JakeDot marked this pull request as ready for review April 7, 2026 16:22
Copilot AI review requested due to automatic review settings April 7, 2026 16:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a local developer-facing CLI wrapper (ms-copilot) and an interactive setup script intended to make the command available via a shell alias, alongside README documentation describing local CLI usage.

Changes:

  • Introduces ms-copilot-cli.sh with basic commands (help, version, validate, test-workflow, setup).
  • Adds setup-ms-copilot.sh to create/persist an ms-copilot alias in common shells.
  • Documents CLI setup and usage in README.md.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
setup-ms-copilot.sh Adds an interactive installer that attempts to create/persist an ms-copilot alias.
ms-copilot-cli.sh Adds a bash-based CLI wrapper with validation/testing helper commands.
README.md Documents CLI setup steps and available commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread setup-ms-copilot.sh
Comment on lines +24 to +46
if [ -n "$BASH_VERSION" ]; then
echo "bash"
elif [ -n "$ZSH_VERSION" ]; then
echo "zsh"
elif [ -n "$FISH_VERSION" ]; then
echo "fish"
else
# Try to detect from SHELL environment variable
case "$SHELL" in
*/bash)
echo "bash"
;;
*/zsh)
echo "zsh"
;;
*/fish)
echo "fish"
;;
*)
echo "unknown"
;;
esac
fi
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

detect_shell will always return bash when this script is executed normally because the shebang runs it under Bash, so $BASH_VERSION is always set. This can cause persisting the alias into the wrong RC file for users whose login shell is zsh/fish. Prefer detecting the user’s interactive/login shell via $SHELL (or similar) first, and only fall back to runtime variables when the script is actually sourced by that shell.

Suggested change
if [ -n "$BASH_VERSION" ]; then
echo "bash"
elif [ -n "$ZSH_VERSION" ]; then
echo "zsh"
elif [ -n "$FISH_VERSION" ]; then
echo "fish"
else
# Try to detect from SHELL environment variable
case "$SHELL" in
*/bash)
echo "bash"
;;
*/zsh)
echo "zsh"
;;
*/fish)
echo "fish"
;;
*)
echo "unknown"
;;
esac
fi
# Prefer the user's login/interactive shell so aliases are persisted
# to the correct RC file when this script is executed under Bash.
case "$SHELL" in
*/bash)
echo "bash"
;;
*/zsh)
echo "zsh"
;;
*/fish)
echo "fish"
;;
*)
# Fall back to runtime shell variables when SHELL is unavailable
# or when the script is sourced by a supported shell.
if [ -n "$BASH_VERSION" ]; then
echo "bash"
elif [ -n "$ZSH_VERSION" ]; then
echo "zsh"
elif [ -n "$FISH_VERSION" ]; then
echo "fish"
else
echo "unknown"
fi
;;
esac

Copilot uses AI. Check for mistakes.
Comment thread setup-ms-copilot.sh
Comment on lines +72 to +82
# Create alias command for the shell
get_alias_command() {
local shell_type="$1"
case "$shell_type" in
fish)
echo "alias ms-copilot='${CLI_SCRIPT}'"
;;
*)
echo "alias ms-copilot='${CLI_SCRIPT}'"
;;
esac
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The fish alias syntax here is Bash-style (alias name='value' with =). In fish, alias takes the form alias name 'command' (no =), so persisting this line into config.fish won’t work. Generate a fish-compatible alias/function definition when shell_type is fish.

Copilot uses AI. Check for mistakes.
Comment thread setup-ms-copilot.sh
Comment on lines +125 to +138
# Set up the alias in the current shell
setup_current_shell() {
local shell_type
shell_type=$(detect_shell)
local alias_cmd
alias_cmd=$(get_alias_command "$shell_type")

echo -e "${BLUE}Setting up ms-copilot alias in current shell...${NC}"

# Set the alias for the current session
alias ms-copilot="${CLI_SCRIPT}"

echo -e "${GREEN}✓${NC} Alias 'ms-copilot' created in current shell session"
echo -e " You can now run: ${BOLD}ms-copilot help${NC}"
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

This script cannot create an alias in the current user shell session when run as ./setup-ms-copilot.sh because it runs in a child process; alias ms-copilot=... only affects the script’s process and is lost when it exits. To make “available immediately” true, either require users to source the script, or output the alias command for eval, or install a real executable/symlink (e.g., into ~/.local/bin) instead of relying on aliases.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment on lines +42 to +55
2. Run the setup script:
```bash
./setup-ms-copilot.sh
```

3. The setup script will:
- Create an `ms-copilot` alias in your current shell session
- Optionally add the alias to your shell configuration file (`.bashrc`, `.zshrc`, or `.config/fish/config.fish`)
- Make the alias persistent across shell sessions

4. Verify the installation:
```bash
ms-copilot help
```
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

The CLI setup instructions imply ./setup-ms-copilot.sh will create an ms-copilot alias usable immediately (step 3/4). Since aliases set inside a script don’t propagate to the parent shell, these steps will fail unless the user sources their RC file or starts a new shell. Please adjust the docs to match the actual behavior (or update the setup script to support source/eval-based installation).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@codex[agent] is export ing an alias possible?

@JakeDot JakeDot merged commit b4eadbb into main Apr 7, 2026
7 of 8 checks passed
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.

3 participants