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:
- For each
github-repository entity in the store, call GET /repos/{owner}/{repo}/issues?state=all&per_page=100 (pagination via Link header)
- For each issue returned:
- Skip if
pull_request key is present (those are PRs, not issues)
- Map fields:
number, title, state → status (open/closed), labels[].name → labels[], linked commit SHAs from timeline events → related-commits[], html_url → urls.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
- 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:
- 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
- Batch-fetch work item details via
POST /_apis/wit/workitemsbatch
- Map fields:
System.Title → title
System.State → status (Active/In Progress → in-progress; New/To Do → open; Done/Resolved/Closed → closed)
System.Tags → labels[] (split on ;)
relations[].url where rel = ArtifactLink/Git.Commit → related-commits[] (extract SHA from artifact URI)
_links.html.href → urls.default
- Upsert as
azure-devops-work-item entities.
- 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>"]
Summary
There is currently no tool that discovers work items (GitHub issues, Azure DevOps work items) and upserts them as
work-itementities 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.csBehaviour:
github-repositoryentity in the store, callGET /repos/{owner}/{repo}/issues?state=all&per_page=100(pagination viaLinkheader)pull_requestkey is present (those are PRs, not issues)number,title,state→status(open/closed),labels[].name→labels[], linked commit SHAs from timeline events →related-commits[],html_url→urls.defaultgithub-work-itementity usingWorkspaceToolEntityUtilities.UpsertEntityByPrimaryNameAsync["github", <owner>, <repo>, "work-items", <number>]github-pull-requestentity exists in the store (via the timelinecross-referencedevents), also create arelatedrelationship between the work item and that PR entitytool-execution-resultentity summarising: repositories scanned, issues found, entities created/updated.Auth: Uses
GitHubTokenResolver(shared withGitHubPullRequestDiscoveryTool).Azure DevOps Work Item Discovery
Tool type:
"azure-devops-work-item-discovery"File:
Tools/AzureDevOps/AzureDevOpsWorkItemDiscoveryTool.csBehaviour:
azure-devops-projectentity in the store, run a WIQL query:SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @project ORDER BY [System.ChangedDate] DESCPOST /_apis/wit/workitemsbatchSystem.Title→titleSystem.State→status(Active/In Progress →in-progress; New/To Do →open; Done/Resolved/Closed →closed)System.Tags→labels[](split on;)relations[].urlwhererel = ArtifactLink/Git.Commit→related-commits[](extract SHA from artifact URI)_links.html.href→urls.defaultazure-devops-work-itementities.AzureDevOpsWorkItemDiscoveryToolrather than creating a separate one (same tool, extended field mapping).Tool Relationship Schema
Both tools need a
tool-relationshipentity that configures:Tests
GitHubWorkItemDiscoveryTool_MapsIssueFieldsToWorkItemEntitystatus,labels,urls.default, naming conventionGitHubWorkItemDiscoveryTool_SkipsIssuesThatArePullRequestspull_requestkey presentgithub-work-itementity upsertedGitHubWorkItemDiscoveryTool_WritesRelatedRelationship_WhenLinkedPrEntityExistsrelatedrelationship entity created between issue and PRAzureDevOpsWorkItemDiscoveryTool_MapsTagsToLabelsSystem.Tags = "bug;performance"labels = ["bug", "performance"]AzureDevOpsWorkItemDiscoveryTool_MapsGitCommitLinksToRelatedCommitsvstfs:///Git/Commit/<project-id>/<repo-id>/<sha>related-commits = ["<sha>"]