Skip to content

feat(worker): Add 'processTaskImport' job for AI-powered issue generation #86

Closed

Description

@integry

Epic: Implement the new "Import Tasks" feature.
Part: 1 of 2 (Backend Infrastructure)

Goal

Create the backend infrastructure to accept a raw text blob from the UI, queue a new job type (processTaskImport), and have a worker execute an "analysis/planning" task using Claude.

Context

This new job type will provide Claude with the user's text and read-only access to the repository via a worktree. Unlike other jobs, Claude's goal is not to implement code, but to analyze the request and output a series of gh commands to create the planned GitHub issues.

Implementation Steps

  1. src/queue/taskQueue.js

    • Update the createWorker processor function to handle the new job name 'processTaskImport'.
    // ...
    } else if (job.name === 'processPullRequestComment') {
        return processPullRequestCommentJob(job);
    } else if (job.name === 'processTaskImport') {
        return processTaskImportJob(job); // Add this
    } else {
    // ...
  2. packages/dashboard/server.js

    • Add a new ensureAuthenticated POST route: app.post('/api/import-tasks', ensureAuthenticated, async (req, res) => { ... });.
    • This endpoint should expect { taskDescription: string, repository: string } in the request body.
    • Inside the route, add a new job to the taskQueue:
      • Job Name: 'processTaskImport'
      • Job Data: { taskDescription, repository, correlationId: generateCorrelationId(), user: req.user.username }
      • Job ID: Generate a unique ID, e.g., import-tasks-${repository.replace('/', '-')}-${Date.now()}.
    • Respond to the client with { jobId: newJob.id }.
  3. src/worker.js

    • Import generateTaskImportPrompt from src/claude/claudeService.js.
    • Create and export a new async function: async function processTaskImportJob(job) { ... }.
    • This function's structure should be very similar to processGitHubIssueJob (logging, state, auth, etc.).
    • Key Logic:
      • Get job data: const { taskDescription, repository, correlationId } = job.data;.
      • Split repository into repoOwner and repoName.
      • Call ensureRepoCloned and createWorktreeForIssue to set up a repo context. Use a placeholder like issueId: 'import' and modelName: 'planner' for unique naming.
      • Call the new generateTaskImportPrompt(taskDescription, repoOwner, repoName, worktreeInfo.worktreePath) (to be created in step 4).
      • Call executeClaudeCode with this new prompt.
      • Log the result from executeClaudeCode. This job is "fire and forget" - its only goal is to run the planning prompt. Claude will execute the gh commands from within its container.
      • Ensure cleanupWorktree is called in a finally block.
  4. src/claude/claudeService.js

    • Create and export a new function: generateTaskImportPrompt(taskDescription, repoOwner, repoName, worktreePath).
    • This function should return the following prompt string, injecting the appropriate variables:
    You are an expert software analyst. Your task is to convert code change requests into detailed GitHub issue specifications for the **${repoOwner}/${repoName}** repo, so a junior developer can implement them. If the issue specification with comments is already defined, publish it directly to Github without modifications, otherwise carefully analyze the request first and then publish the issues.
    
    You are working in a git worktree at '${worktreePath}' which contains the full source code for analysis and planning.
    
    You MUST publish issues and their respective comments using gh commands:
    
    1.  **Create an Issue:** The issue body must contain:
        * A detailed task description and context.
        * Clear, step-by-step implementation instructions.
    2.  **Add a Comment:** After creating the issue and capturing its ID/number, add a separate comment to that issue containing the suggested implementation code (use diffs where possible).
    3.  **Multi-Issue Tasks:** If the work is significant, break it into multiple issues. When doing so, the issue description must reference the previous issue ID and describe the epic's overall goal and current stage. Prefer a single issue when possible.
    
    **YOUR FOCUS: ANALYSIS AND 'gh' COMMANDS ONLY**
    -   You have read-only access to the codebase for planning.
    -   DO NOT implement any code changes.
    -   DO NOT use git commands (add, commit, push).
    -   Your *only* output should be the bash script using 'gh' commands to create the issues.
    
    Here is the user's request:
    ---
    ${taskDescription}
    ---
    

Activity

  1. integry commented on Sep 23, 2025

    @integry
    OwnerAuthor

    Implementation Guidance

    The new processTaskImportJob function in src/worker.js will be the core of this feature. It should follow the 3-phase pattern (Setup, AI, Cleanup) just like processGitHubIssueJob.

    • Setup Phase: Clone/update the target repo and create a worktree.
    • AI Phase: Call generateTaskImportPrompt and then executeClaudeCode.
    • Cleanup Phase: Call cleanupWorktree.

    The executeClaudeCode function already provides the gh binary and GH_TOKEN to the container, so Claude's gh commands will execute and create the issues. We just need to log the stdout from executeClaudeCode to confirm.

    Files to modify:

    • src/queue/taskQueue.js (Add processTaskImport to worker logic)
    • packages/dashboard/server.js (Add POST /api/import-tasks endpoint)
    • src/worker.js (Add processTaskImportJob function)
    • src/claude/claudeService.js (Add generateTaskImportPrompt function)
  2. integry commented on Sep 23, 2025

    @integry
    OwnerAuthor

    Besides a raw text blob, it will also accept a repo ID (username/repo)

  3. propr-dev commented on Sep 23, 2025

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude-opus-4-20250514 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Model: claude-opus-4-20250514
    • Branch: ai-fix/86-feat-worker-add-processta-20250923-1141-claude-opus-4-20250514-i2a
    • Base Branch: main
    • Worktree: issue-86-20250923-1141-claude-opus-4-20250514-i2a
  4. propr-dev commented on Sep 23, 2025

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude-opus-4-20250514 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Model: claude-opus-4-20250514
    • Branch: ai-fix/86-feat-worker-add-processta-20250923-1141-claude-opus-4-20250514-00l
    • Base Branch: main
    • Worktree: issue-86-20250923-1141-claude-opus-4-20250514-00l
  5. added a commit that references this issue on Sep 23, 2025
  6. added a commit that references this issue on Sep 23, 2025
  7. added a commit that references this issue on Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions