dev #11
@@ -318,6 +318,7 @@ pytest tests/test_ai_review.py::TestSecurityScanner -v
|
|||||||
5. Add tests in `tests/test_ai_review.py`
|
5. Add tests in `tests/test_ai_review.py`
|
||||||
|
|
||||||
Example commands:
|
Example commands:
|
||||||
|
- `@codebot help` - Show all available commands with examples
|
||||||
- `@codebot triage` - Full issue triage with labeling
|
- `@codebot triage` - Full issue triage with labeling
|
||||||
- `@codebot explain` - Explain the issue
|
- `@codebot explain` - Explain the issue
|
||||||
- `@codebot suggest` - Suggest solutions
|
- `@codebot suggest` - Suggest solutions
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ In any issue comment:
|
|||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
|---------|-------------|
|
|---------|-------------|
|
||||||
|
| `@codebot help` | **Help:** Show all available commands with examples |
|
||||||
| `@codebot setup-labels` | **Setup:** Automatically create/map repository labels for auto-labeling |
|
| `@codebot setup-labels` | **Setup:** Automatically create/map repository labels for auto-labeling |
|
||||||
| `@codebot triage` | Full issue triage with auto-labeling and analysis |
|
| `@codebot triage` | Full issue triage with auto-labeling and analysis |
|
||||||
| `@codebot summarize` | Summarize the issue in 2-3 sentences |
|
| `@codebot summarize` | Summarize the issue in 2-3 sentences |
|
||||||
@@ -180,6 +181,8 @@ In any issue comment:
|
|||||||
| `@codebot suggest` | Suggest solutions or next steps |
|
| `@codebot suggest` | Suggest solutions or next steps |
|
||||||
| `@codebot` (any question) | Chat with AI using codebase/web search tools |
|
| `@codebot` (any question) | Chat with AI using codebase/web search tools |
|
||||||
|
|
||||||
|
**New to OpenRabbit?** Just type `@codebot help` in any issue to see all available commands!
|
||||||
|
|
||||||
### Label Setup Command
|
### Label Setup Command
|
||||||
|
|
||||||
The `@codebot setup-labels` command intelligently detects your existing label schema and sets up auto-labeling:
|
The `@codebot setup-labels` command intelligently detects your existing label schema and sets up auto-labeling:
|
||||||
|
|||||||
@@ -263,6 +263,84 @@ class TestMetrics:
|
|||||||
assert summary["requests"]["success"] == 1
|
assert summary["requests"]["success"] == 1
|
||||||
|
|
||||||
|
|
||||||
|
class TestHelpCommand:
|
||||||
|
"""Test help command functionality."""
|
||||||
|
|
||||||
|
def test_help_command_returns_text(self):
|
||||||
|
"""Test that help command returns formatted help text."""
|
||||||
|
from agents.issue_agent import IssueAgent
|
||||||
|
|
||||||
|
agent = IssueAgent(
|
||||||
|
gitea_client=None,
|
||||||
|
llm_client=None,
|
||||||
|
config={
|
||||||
|
"interaction": {
|
||||||
|
"mention_prefix": "@codebot",
|
||||||
|
"commands": ["help", "triage", "explain"],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
help_text = agent._command_help()
|
||||||
|
|
||||||
|
assert help_text is not None
|
||||||
|
assert len(help_text) > 100
|
||||||
|
assert "@codebot" in help_text
|
||||||
|
assert "help" in help_text.lower()
|
||||||
|
assert "triage" in help_text.lower()
|
||||||
|
|
||||||
|
def test_help_includes_all_sections(self):
|
||||||
|
"""Test that help text includes all major sections."""
|
||||||
|
from agents.issue_agent import IssueAgent
|
||||||
|
|
||||||
|
agent = IssueAgent(
|
||||||
|
gitea_client=None,
|
||||||
|
llm_client=None,
|
||||||
|
config={"interaction": {"mention_prefix": "@codebot"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
help_text = agent._command_help()
|
||||||
|
|
||||||
|
# Check for main sections
|
||||||
|
assert "Issue Triage" in help_text
|
||||||
|
assert "Interactive Chat" in help_text
|
||||||
|
assert "Setup & Utility" in help_text
|
||||||
|
assert "Pull Request" in help_text
|
||||||
|
assert "Quick Examples" in help_text
|
||||||
|
|
||||||
|
def test_help_uses_custom_bot_name(self):
|
||||||
|
"""Test that help command uses custom bot name from config."""
|
||||||
|
from agents.issue_agent import IssueAgent
|
||||||
|
|
||||||
|
agent = IssueAgent(
|
||||||
|
gitea_client=None,
|
||||||
|
llm_client=None,
|
||||||
|
config={"interaction": {"mention_prefix": "@mybot"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
help_text = agent._command_help()
|
||||||
|
|
||||||
|
assert "@mybot" in help_text
|
||||||
|
assert "@codebot" not in help_text
|
||||||
|
|
||||||
|
def test_help_includes_examples(self):
|
||||||
|
"""Test that help text includes usage examples."""
|
||||||
|
from agents.issue_agent import IssueAgent
|
||||||
|
|
||||||
|
agent = IssueAgent(
|
||||||
|
gitea_client=None,
|
||||||
|
llm_client=None,
|
||||||
|
config={"interaction": {"mention_prefix": "@codebot"}},
|
||||||
|
)
|
||||||
|
|
||||||
|
help_text = agent._command_help()
|
||||||
|
|
||||||
|
# Check for example commands
|
||||||
|
assert "triage" in help_text
|
||||||
|
assert "explain" in help_text
|
||||||
|
assert "setup-labels" in help_text
|
||||||
|
|
||||||
|
|
||||||
class TestLabelSetup:
|
class TestLabelSetup:
|
||||||
"""Test label setup and schema detection."""
|
"""Test label setup and schema detection."""
|
||||||
|
|
||||||
|
|||||||
@@ -380,7 +380,9 @@ class IssueAgent(BaseAgent):
|
|||||||
title = issue.get("title", "")
|
title = issue.get("title", "")
|
||||||
body = issue.get("body", "")
|
body = issue.get("body", "")
|
||||||
|
|
||||||
if command == "summarize":
|
if command == "help":
|
||||||
|
return self._command_help()
|
||||||
|
elif command == "summarize":
|
||||||
return self._command_summarize(title, body)
|
return self._command_summarize(title, body)
|
||||||
elif command == "explain":
|
elif command == "explain":
|
||||||
return self._command_explain(title, body)
|
return self._command_explain(title, body)
|
||||||
@@ -445,6 +447,68 @@ Be practical and concise."""
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"{self.AI_DISCLAIMER}\n\nSorry, I was unable to generate suggestions. Error: {e}"
|
return f"{self.AI_DISCLAIMER}\n\nSorry, I was unable to generate suggestions. Error: {e}"
|
||||||
|
|
||||||
|
def _command_help(self) -> str:
|
||||||
|
"""Generate help message with all available commands."""
|
||||||
|
mention_prefix = self.config.get("interaction", {}).get(
|
||||||
|
"mention_prefix", "@codebot"
|
||||||
|
)
|
||||||
|
|
||||||
|
help_text = f"""{self.AI_DISCLAIMER}
|
||||||
|
|
||||||
|
## Available {mention_prefix} Commands
|
||||||
|
|
||||||
|
### Issue Triage & Analysis
|
||||||
|
- `{mention_prefix} triage` - Full issue triage with auto-labeling and priority assignment
|
||||||
|
- `{mention_prefix} summarize` - Generate 2-3 sentence summary of the issue
|
||||||
|
- `{mention_prefix} explain` - Detailed explanation of what the issue is about
|
||||||
|
- `{mention_prefix} suggest` - Solution suggestions or next steps
|
||||||
|
- `{mention_prefix} security` - Security-focused analysis of the issue
|
||||||
|
|
||||||
|
### Interactive Chat
|
||||||
|
- `{mention_prefix} [question]` - Ask questions about the codebase (uses search & file reading tools)
|
||||||
|
- Example: `{mention_prefix} how does authentication work?`
|
||||||
|
- Example: `{mention_prefix} find all API endpoints`
|
||||||
|
|
||||||
|
### Setup & Utility
|
||||||
|
- `{mention_prefix} help` - Show this help message
|
||||||
|
- `{mention_prefix} setup-labels` - Auto-create/map repository labels for auto-labeling
|
||||||
|
|
||||||
|
### Pull Request Analysis
|
||||||
|
PR reviews run automatically when you open or update a pull request. The bot provides:
|
||||||
|
- Inline code review comments
|
||||||
|
- Security vulnerability scanning
|
||||||
|
- Approval or change-request recommendations
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Quick Examples
|
||||||
|
|
||||||
|
**Triage an issue:**
|
||||||
|
```
|
||||||
|
{mention_prefix} triage
|
||||||
|
```
|
||||||
|
|
||||||
|
**Get help understanding:**
|
||||||
|
```
|
||||||
|
{mention_prefix} explain
|
||||||
|
```
|
||||||
|
|
||||||
|
**Ask about the codebase:**
|
||||||
|
```
|
||||||
|
{mention_prefix} how does the authentication system work?
|
||||||
|
```
|
||||||
|
|
||||||
|
**Setup repository labels:**
|
||||||
|
```
|
||||||
|
{mention_prefix} setup-labels
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*For full documentation, see the [README](https://github.com/YourOrg/OpenRabbit/blob/main/README.md)*
|
||||||
|
"""
|
||||||
|
return help_text
|
||||||
|
|
||||||
def _command_triage(self, context: AgentContext, issue: dict) -> str:
|
def _command_triage(self, context: AgentContext, issue: dict) -> str:
|
||||||
"""Perform full triage analysis on the issue."""
|
"""Perform full triage analysis on the issue."""
|
||||||
title = issue.get("title", "")
|
title = issue.get("title", "")
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ interaction:
|
|||||||
respond_to_mentions: true
|
respond_to_mentions: true
|
||||||
mention_prefix: "@codebot" # Change this to customize your bot's name!
|
mention_prefix: "@codebot" # Change this to customize your bot's name!
|
||||||
commands:
|
commands:
|
||||||
|
- help
|
||||||
- explain
|
- explain
|
||||||
- suggest
|
- suggest
|
||||||
- security
|
- security
|
||||||
|
|||||||
Reference in New Issue
Block a user