Skip to content

Enhancement: work item discovery tool — scan GitHub and Azure DevOps for issues and upsert as work-item entities #214

Description

@JoshuaRowePhantom

Summary

There is currently no tool that discovers work items (GitHub issues, Azure DevOps work items) and upserts them as work-item entities in the workspace store. This tool is the data-supply side of the pull-requests/work-items views.


Design

GitHub Work Item Discovery

Tool type: "github-work-item-discovery"
File: Tools/GitHub/GitHubWorkItemDiscoveryTool.cs

Behaviour:

  1. For each github-repository entity in the store, call GET /repos/{owner}/{repo}/issues?state=all&per_page=100 (pagination via Link header)
  2. For each issue returned:
    • Skip if pull_request key is present (those are PRs, not issues)
    • Map fields: number, title, statestatus (open/closed), labels[].namelabels[], linked commit SHAs from timeline events → related-commits[], html_urlurls.default
    • Upsert a github-work-item entity using WorkspaceToolEntityUtilities.UpsertEntityByPrimaryNameAsync
    • Naming: ["github", <owner>, <repo>, "work-items", <number>]
    • If a related github-pull-request entity exists in the store (via the timeline cross-referenced events), also create a related relationship between the work item and that PR entity
  3. Write a tool-execution-result entity summarising: repositories scanned, issues found, entities created/updated.

Auth: Uses GitHubTokenResolver (shared with GitHubPullRequestDiscoveryTool).


Azure DevOps Work Item Discovery

Tool type: "azure-devops-work-item-discovery"
File: Tools/AzureDevOps/AzureDevOpsWorkItemDiscoveryTool.cs

Behaviour:

  1. For each azure-devops-project entity in the store, run a WIQL query: SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project ORDER BY [System.ChangedDate] DESC
  2. Batch-fetch work item details via POST /_apis/wit/workitemsbatch
  3. Map fields:
    • System.Titletitle
    • System.Statestatus (Active/In Progress → in-progress; New/To Do → open; Done/Resolved/Closed → closed)
    • System.Tagslabels[] (split on ;)
    • relations[].url where rel = ArtifactLink/Git.Commitrelated-commits[] (extract SHA from artifact URI)
    • _links.html.hrefurls.default
  4. Upsert as azure-devops-work-item entities.
  5. Update the existing AzureDevOpsWorkItemDiscoveryTool rather than creating a separate one (same tool, extended field mapping).

Tool Relationship Schema

Both tools need a tool-relationship entity that configures:

  • Which repositories/projects to scan
  • Poll frequency (suggested default: every 15 minutes)
  • Max items per repository (default: 200)

Tests

GitHubWorkItemDiscoveryTool_MapsIssueFieldsToWorkItemEntity

  • Mock GitHub API returning one issue with labels, state=open
  • Assert entity has correct status, labels, urls.default, naming convention

GitHubWorkItemDiscoveryTool_SkipsIssuesThatArePullRequests

  • Mock API returning issue with pull_request key present
  • Assert no github-work-item entity upserted

GitHubWorkItemDiscoveryTool_WritesRelatedRelationship_WhenLinkedPrEntityExists

  • Mock cross-referenced timeline event pointing to a PR entity already in store
  • Assert related relationship entity created between issue and PR

AzureDevOpsWorkItemDiscoveryTool_MapsTagsToLabels

  • ADO work item with System.Tags = "bug;performance"
  • Assert labels = ["bug", "performance"]

AzureDevOpsWorkItemDiscoveryTool_MapsGitCommitLinksToRelatedCommits

  • ADO work item with artifact link vstfs:///Git/Commit/<project-id>/<repo-id>/<sha>
  • Assert related-commits = ["<sha>"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestverifiedIssue has been verified

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions