Skip to content

add check cli tool#1178

Merged
zzstoatzz merged 1 commit intomainfrom
check-cli
Jul 14, 2025
Merged

add check cli tool#1178
zzstoatzz merged 1 commit intomainfrom
check-cli

Conversation

@zzstoatzz
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 14, 2025 16:41
@zzstoatzz zzstoatzz merged commit c247bcd into main Jul 14, 2025
3 checks passed
Copy link
Copy Markdown
Contributor

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

This PR adds a new helper to verify CLI commands in Slackbot and integrates it into the core assistant directives.

  • Introduces check_cli_command in search.py for running and validating Prefect CLI commands.
  • Imports and enforces use of check_cli_command in core.py directives.

Reviewed Changes

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

File Description
examples/slackbot/src/slackbot/search.py Added new check_cli_command function to run CLI commands with timeout, output capture, and error handling.
examples/slackbot/src/slackbot/core.py Imported check_cli_command and updated mission directives to require its use before suggesting CLI commands.
Comments suppressed due to low confidence (2)

examples/slackbot/src/slackbot/search.py:231

  • New functionality is added without corresponding tests; consider adding unit tests to cover success, timeout, not-found, and error cases.
def check_cli_command(command: str, args: list[str] | None = None) -> str:

examples/slackbot/src/slackbot/core.py:42

  • [nitpick] This directive mixes sentence case and full uppercase; consider revising to match existing style for readability and consistency.
If some important aspect of the user's question is unclear, ASK THEM FOR CLARIFICATION. ADMIT WHEN YOU CANNOT FIND THE ANSWER.

args = []

# Construct the full command
full_command = command.split() + args
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

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

Using str.split() can mis-handle quoted arguments; consider using shlex.split(command) to correctly parse complex command strings.

Suggested change
full_command = command.split() + args
full_command = shlex.split(command) + args

Copilot uses AI. Check for mistakes.
if result.stdout:
output += result.stdout
if result.stderr:
output += f"\n[stderr]: {result.stderr}"
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

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

[nitpick] When stderr is present but stdout is empty, this prepends a newline; you may want to trim or conditionally format to avoid leading whitespace.

Suggested change
output += f"\n[stderr]: {result.stderr}"
output += f"{'\n' if result.stdout else ''}[stderr]: {result.stderr}"

Copilot uses AI. Check for mistakes.
if not output.strip():
output = f"Command ran successfully with exit code {result.returncode} but produced no output"

return output[:2000] # Limit output length to prevent huge responses
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

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

The 2000 character limit is a magic number; consider extracting it into a named constant or configuring it elsewhere for clarity.

Suggested change
return output[:2000] # Limit output length to prevent huge responses
return output[:MAX_OUTPUT_LENGTH] # Limit output length to prevent huge responses

Copilot uses AI. Check for mistakes.
@zzstoatzz zzstoatzz deleted the check-cli branch July 14, 2025 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants