Skip to content

Add issue key support to daf investigate command #363

@itdove

Description

@itdove

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-59038

Users working on investigation-focused tickets must:

  1. Read the ticket manually
  2. Copy the summary/description
  3. 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 #123

The command should:

  1. Auto-detect the issue tracker backend (JIRA/GitHub/GitLab)
  2. Fetch the ticket/issue details
  3. Use the ticket summary as the investigation goal
  4. Store the issue key for tracking
  5. 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 available

GitHub/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#123 creates investigation session from GitHub issue
  • daf investigate #123 creates 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
  • --goal flag 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 --help reflects new usage

Technical Details

Files to Modify

  1. devflow/cli/main.py (~line 1917-1956)

    • Add issue_key argument to investigate command
    • Add logic to detect and fetch issue
  2. 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
  3. Tests

    • tests/test_investigate_command.py - Add tests for issue key support
    • integration-tests/test_investigation.sh - Add integration tests
  4. Documentation

    • AGENTS.md - Update command examples
    • devflow/cli_skills/daf-workflow/SKILL.md - Update workflow guidance
    • Command help text

Edge Cases to Handle

  1. Issue key matches existing session name (prefer session name)
  2. Issue not found / access denied
  3. Both issue_key and --goal provided (goal overrides)
  4. Invalid issue key format
  5. Network/API failures when fetching issue
  6. 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

  1. Faster workflow: Users can jump directly from issue to investigation
  2. Consistency: Matches daf open <issue_key> pattern
  3. Auto-tracking: Issue key automatically linked to investigation session
  4. Better context: Initial prompt includes full issue details
  5. 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-12345

After (Enhanced)

# Direct from issue key
daf investigate PROJ-12345

Related

  • 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions