-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: jira toolkit #59
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5200c26
add a jira toolkit
michaelneale cb0b8d2
ruff checks
michaelneale 8e59419
more fixes
michaelneale 244caa3
mention the new toolkit
michaelneale 2cc548e
Update src/goose/toolkit/prompts/jira.jinja
michaelneale 9dba714
feedback on PR
michaelneale 8e3d492
updating'
michaelneale 959bab8
format
michaelneale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is a python CLI app that uses UV. Read CONTRIBUTING.md for information on how to build and test it as needed. | ||
Some key concepts are that it is run as a command line interface, dependes on the "ai-exchange" package, and has the concept of toolkits which are ways that its behavior can be extended. Look in src/goose and tests. | ||
Once the user has UV installed it should be able to be used effectively along with uvx to run tasks as needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from exchange import Message # type: ignore | ||
from goose.toolkit.base import tool # type: ignore | ||
import re | ||
|
||
from goose.toolkit.base import Toolkit | ||
|
||
|
||
class Jira(Toolkit): | ||
"""Provides an additional prompt on how to interact with Jira""" | ||
|
||
def system(self) -> str: | ||
"""Retrieve detailed configuration and procedural guidelines for Jira operations""" | ||
return Message.load("prompts/jira.jinja").text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to pass os= here for the prompt jinja to work |
||
|
||
@tool | ||
def is_jira_issue(self, issue_key: str) -> str: | ||
""" | ||
Checks if a given string is a valid JIRA issue key. | ||
Use this if it looks like the user is asking about a JIRA issue. | ||
|
||
Args: | ||
issue_key (str): The potential Jira issue key to be validated. | ||
|
||
""" | ||
pattern = r"[A-Z]+-\d+" | ||
return bool(re.match(pattern, issue_key)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
You can interact with jira issues via the `jira` command line generally. | ||
If it fails to auth, prompt the user to run `jira init` in a separate terminal and then try again. | ||
|
||
Typically when someone requests you to look at a ticket, they mean to view | ||
not just the top level comments and history, but also the comments nested within that ticket and status. | ||
|
||
Some usages are for looking up a JIRA backlog, or looking up a JIRA issue. | ||
Use the tool is_jira_issue if not sure that a string that looks like a jira issue is. | ||
|
||
Use `jira --help` if not sure of command line options. | ||
|
||
If the jira command line is not installed, you can install it as follows: | ||
|
||
{% if os == 'Darwin' %} | ||
On macOS, install with: | ||
```sh | ||
brew tap ankitpokhrel/jira-cli | ||
brew install jira-cli | ||
``` | ||
{% else %} | ||
On other operating systems, refer to the instructions here: https://github.com/ankitpokhrel/jira-cli | ||
{% endif %} | ||
michaelneale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
from goose.toolkit.jira import Jira | ||
|
||
|
||
class TestJiraToolkit(unittest.TestCase): | ||
michaelneale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@patch("goose.toolkit.jira.Message.load") | ||
def test_jira_system_prompt(self, mock_load): | ||
michaelneale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mock_load.return_value.text = "This is a prompt for jira" | ||
jira_toolkit = Jira(None) | ||
prompt = jira_toolkit.system() | ||
# Ensure Jinja template syntax isn't present in the loaded prompt | ||
self.assertNotIn("{%", prompt) | ||
self.assertNotIn("%}", prompt) | ||
self.assertEqual(prompt, "This is a prompt for jira") | ||
|
||
def test_is_jira_issue(self): | ||
jira_toolkit = Jira(None) | ||
valid_jira_issue = "PROJ-123" | ||
invalid_jira_issue = "INVALID_ISSUE" | ||
# Ensure the regex correctly identifies valid JIRA issues | ||
self.assertTrue(jira_toolkit.is_jira_issue(valid_jira_issue)) | ||
self.assertFalse(jira_toolkit.is_jira_issue(invalid_jira_issue)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seemed to make a HUGE practical difference to goose.