Skip to content

Auto-create missing GitHub labels when creating issues #12

Description

@helixclaw

Summary

When iloom creates issues (e.g., epic issues via il plan), it passes labels to gh issue create --label. If the label doesn't exist on the repository, the gh CLI fails with an error. iloom should automatically check for and create missing labels before attempting to create the issue.

Problem

Currently, createIssue() in src/utils/github.ts passes labels directly to the gh CLI without verifying they exist. This causes failures when:

  • A user runs il plan on a fresh repo that doesn't have the epic label
  • Any issue creation specifies a label that hasn't been manually created on the repo

This is a self-demonstrating bug — creating this very epic with an epic label fails if the label doesn't exist.

Proposed Solution

Add an ensureLabelsExist() utility function in src/utils/github.ts that:

  1. Checks if each label exists on the repo using gh api to query the labels endpoint
  2. Creates any missing labels using gh api POST to the labels endpoint
  3. Is called by createIssue() before the gh issue create command

This should be a general-purpose solution that works for any label, not just epic.

Key Files

  • src/utils/github.tscreateIssue() function (line ~247)
  • src/mcp/GitHubIssueManagementProvider.ts — calls createIssue()
  • src/utils/github.test.ts — tests for github utilities

Acceptance Criteria

  • Missing labels are auto-created before issue creation
  • Existing labels are not duplicated or modified
  • Error from label creation is handled gracefully (e.g., permission denied — should warn and continue without label rather than failing)
  • Works with the optional repo parameter for cross-repo operations
  • Tests cover: label exists, label missing and created, label creation fails gracefully

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions