Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/aw/orchestrate-agentic-campaign.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ and synchronizing campaign state into a GitHub Project board.

3) Parse discovered items from the manifest:
- Each item has: url, content_type (issue/pull_request/discussion), number, repo, created_at, updated_at, state
- Items discovered via tracker-id also have: worker_workflow (the workflow name that created the item)
- Closed items have: closed_at (for issues) or merged_at (for PRs)
- Items are pre-sorted by updated_at for deterministic processing

Expand Down
2 changes: 1 addition & 1 deletion .github/aw/update-agentic-campaign-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Use **content number** (integer), never the URL as an identifier.
These rules apply to any time you write fields:

- `campaign_id`: always `{{.CampaignID}}`
- `worker_workflow`: workflow ID if known, else `"unknown"`
- `worker_workflow`: use `worker_workflow` from discovery manifest if present, else `"unknown"`
- `repository`: extract `owner/repo` from the issue/PR URL
- `priority`: default `Medium` unless explicitly known
- `size`: default `Medium` unless explicitly known
Expand Down
13 changes: 10 additions & 3 deletions actions/setup/js/campaign_discovery.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ function saveCursor(cursorPath, cursor) {
* Normalize a discovered item to standard format
* @param {any} item - Raw GitHub item (issue, PR, or discussion)
* @param {string} contentType - Type: "issue", "pull_request", or "discussion"
* @param {string | undefined} workerWorkflow - Worker workflow identifier (optional)
* @returns {any} Normalized item
*/
function normalizeItem(item, contentType) {
function normalizeItem(item, contentType, workerWorkflow) {
const normalized = {
url: item.html_url || item.url,
content_type: contentType,
Expand All @@ -93,6 +94,11 @@ function normalizeItem(item, contentType) {
title: item.title,
};

// Add worker workflow if available
if (workerWorkflow) {
normalized.worker_workflow = workerWorkflow;
}

// Add closed/merged dates
if (item.closed_at) {
normalized.closed_at = item.closed_at;
Expand Down Expand Up @@ -187,7 +193,7 @@ async function searchByTrackerId(octokit, trackerId, repos, orgs, maxItems, maxP

// Determine if it's a PR or issue
const contentType = item.pull_request ? "pull_request" : "issue";
const normalized = normalizeItem(item, contentType);
const normalized = normalizeItem(item, contentType, trackerId);
items.push(normalized);
}

Expand Down Expand Up @@ -277,7 +283,8 @@ async function searchByLabel(octokit, label, repos, orgs, maxItems, maxPages, cu

// Determine if it's a PR or issue
const contentType = item.pull_request ? "pull_request" : "issue";
const normalized = normalizeItem(item, contentType);
// Label-based discovery doesn't provide workflow information
const normalized = normalizeItem(item, contentType, undefined);
items.push(normalized);
}

Expand Down
56 changes: 55 additions & 1 deletion actions/setup/js/campaign_discovery.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("campaign_discovery", () => {
});

describe("normalizeItem", () => {
it("should normalize an issue", () => {
it("should normalize an issue without worker_workflow", () => {
const issue = {
html_url: "https://github.com/owner/repo/issues/1",
number: 1,
Expand All @@ -50,6 +50,32 @@ describe("campaign_discovery", () => {
});
});

it("should normalize an issue with worker_workflow", () => {
const issue = {
html_url: "https://github.com/owner/repo/issues/1",
number: 1,
repository: { full_name: "owner/repo" },
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-02T00:00:00Z",
state: "open",
title: "Test Issue",
};

const normalized = normalizeItem(issue, "issue", "security-scanner");

expect(normalized).toEqual({
url: "https://github.com/owner/repo/issues/1",
content_type: "issue",
number: 1,
repo: "owner/repo",
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-02T00:00:00Z",
state: "open",
title: "Test Issue",
worker_workflow: "security-scanner",
});
});

it("should normalize a pull request with merged_at", () => {
const pr = {
html_url: "https://github.com/owner/repo/pull/2",
Expand Down Expand Up @@ -77,6 +103,34 @@ describe("campaign_discovery", () => {
});
});

it("should normalize a pull request with worker_workflow", () => {
const pr = {
html_url: "https://github.com/owner/repo/pull/2",
number: 2,
repository: { full_name: "owner/repo" },
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-02T00:00:00Z",
state: "closed",
title: "Test PR",
merged_at: "2025-01-03T00:00:00Z",
};

const normalized = normalizeItem(pr, "pull_request", "fix-pr-worker");

expect(normalized).toEqual({
url: "https://github.com/owner/repo/pull/2",
content_type: "pull_request",
number: 2,
repo: "owner/repo",
created_at: "2025-01-01T00:00:00Z",
updated_at: "2025-01-02T00:00:00Z",
state: "closed",
title: "Test PR",
merged_at: "2025-01-03T00:00:00Z",
worker_workflow: "fix-pr-worker",
});
});

it("should normalize a closed issue with closed_at", () => {
const issue = {
html_url: "https://github.com/owner/repo/issues/3",
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/templates/orchestrate-agentic-campaign.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ and synchronizing campaign state into a GitHub Project board.

3) Parse discovered items from the manifest:
- Each item has: url, content_type (issue/pull_request/discussion), number, repo, created_at, updated_at, state
- Items discovered via tracker-id also have: worker_workflow (the workflow name that created the item)
- Closed items have: closed_at (for issues) or merged_at (for PRs)
- Items are pre-sorted by updated_at for deterministic processing

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/templates/update-agentic-campaign-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Use **content number** (integer), never the URL as an identifier.
These rules apply to any time you write fields:

- `campaign_id`: always `{{.CampaignID}}`
- `worker_workflow`: workflow ID if known, else `"unknown"`
- `worker_workflow`: use `worker_workflow` from discovery manifest if present, else `"unknown"`
- `repository`: extract `owner/repo` from the issue/PR URL
- `priority`: default `Medium` unless explicitly known
- `size`: default `Medium` unless explicitly known
Expand Down