-
Notifications
You must be signed in to change notification settings - Fork 2
Add issue key support to daf investigate command #363
Description
Overview
Enhance the daf investigate command to accept an issue key argument, similar to how daf open <issue_key> works. This allows users to create investigation-only sessions directly from existing issue tracker tickets.
Current Behavior
Currently, daf investigate requires an explicit --goal parameter:
daf investigate --goal "Research Redis caching options"
daf investigate --goal "Investigate timeout issue" --parent PROJ-59038Users working on investigation-focused tickets must:
- Read the ticket manually
- Copy the summary/description
- Create the investigation session with
--goal
Proposed Enhancement
Add support for passing an issue key directly:
# JIRA
daf investigate PROJ-12345
# GitHub/GitLab
daf investigate owner/repo#123
daf investigate #123The command should:
- Auto-detect the issue tracker backend (JIRA/GitHub/GitLab)
- Fetch the ticket/issue details
- Use the ticket summary as the investigation goal
- Store the issue key for tracking
- Create an investigation-only session
Implementation Approach
Based on codebase analysis:
1. Command Signature Update
In devflow/cli/main.py, modify the investigate command to accept an optional positional argument:
@cli.command(name="investigate")
@click.argument("issue_key", required=False)
@click.option("--goal", help="Goal/description (overrides issue summary if issue_key provided)")
# ... existing options ...
def investigate(ctx, issue_key, goal, ...):2. Issue Key Detection
Follow the pattern from open_command.py:326-351:
- Detect if argument matches issue key pattern
- Determine backend (JIRA vs GitHub/GitLab)
- Fetch issue/ticket details
- Extract summary and description
3. Backend-Specific Fetching
JIRA:
from devflow.jira.utils import is_issue_key_pattern, validate_jira_ticket
from devflow.jira import JiraClient
if is_issue_key_pattern(issue_key):
jira_client = JiraClient()
ticket = jira_client.get_ticket(issue_key)
goal = ticket.get("summary")
parent = None # Could use epic link if availableGitHub/GitLab:
from devflow.github.utils import parse_github_issue_key
from devflow.github import GitHubClient
owner, repo, number = parse_github_issue_key(issue_key)
github_client = GitHubClient()
issue = github_client.get_issue(owner, repo, number)
goal = issue.get("title")4. Session Creation
Pass extracted data to existing create_investigation_session():
create_investigation_session(
goal=goal,
parent=issue_key, # Track under the original ticket
name=name or f"investigate-{issue_key}",
# ... other params
)5. Initial Prompt Enhancement
Update _build_investigation_prompt() to include issue details when created from ticket:
- Link to original issue
- Include issue description/requirements
- Reference acceptance criteria (if available)
Acceptance Criteria
-
daf investigate <JIRA-KEY>creates investigation session from JIRA ticket -
daf investigate owner/repo#123creates investigation session from GitHub issue -
daf investigate #123creates investigation session from GitHub issue (current repo) - Issue summary is used as the investigation goal
- Issue key is stored in session for tracking
- Session name defaults to
investigate-<issue-key>if not provided -
--goalflag still works and overrides issue summary if both provided - Error handling for invalid/not-found issues
- Initial prompt includes link to original issue
- Works with both JIRA and GitHub/GitLab backends
- Unit tests added for issue key detection and parsing
- Integration tests added for JIRA and GitHub/GitLab workflows
- Documentation updated (AGENTS.md, skills, command help)
-
daf investigate --helpreflects new usage
Technical Details
Files to Modify
-
devflow/cli/main.py (~line 1917-1956)
- Add
issue_keyargument toinvestigatecommand - Add logic to detect and fetch issue
- Add
-
devflow/cli/commands/investigate_command.py
- Update
create_investigation_session()to handle issue_key - Add issue fetching logic
- Update
_build_investigation_prompt()to include issue details
- Update
-
Tests
tests/test_investigate_command.py- Add tests for issue key supportintegration-tests/test_investigation.sh- Add integration tests
-
Documentation
AGENTS.md- Update command examplesdevflow/cli_skills/daf-workflow/SKILL.md- Update workflow guidance- Command help text
Edge Cases to Handle
- Issue key matches existing session name (prefer session name)
- Issue not found / access denied
- Both
issue_keyand--goalprovided (goal overrides) - Invalid issue key format
- Network/API failures when fetching issue
- Investigation session already exists for this issue
Similar Patterns in Codebase
This enhancement mirrors existing patterns:
daf open <issue_key>(devflow/cli/commands/open_command.py:326-351)daf jira open <issue_key>(devflow/cli/commands/jira_open_command.py)daf git new <type>(devflow/cli/commands/git_new_command.py)
Benefits
- Faster workflow: Users can jump directly from issue to investigation
- Consistency: Matches
daf open <issue_key>pattern - Auto-tracking: Issue key automatically linked to investigation session
- Better context: Initial prompt includes full issue details
- Reduced errors: No manual copy-paste of ticket summaries
Example Workflows
Before (Current)
# User opens JIRA ticket in browser
# Copies summary: "Investigate Redis caching for subscription API"
daf investigate --goal "Investigate Redis caching for subscription API" --parent PROJ-12345After (Enhanced)
# Direct from issue key
daf investigate PROJ-12345Related
- Existing:
daf open <issue_key>for development sessions - Existing:
daf jira new <type>for ticket creation sessions - This enhancement:
daf investigate <issue_key>for investigation sessions