feat: enhance workflow and testing infrastructure

- Introduced ExecutionMode type for project execution modes (parallel, sequential).
- Updated SetupOpts to use ExecutionMode instead of string literals.
- Enhanced workflow states to include a new "In Review" state with appropriate transitions.
- Implemented TestHarness for end-to-end testing, including command interception and workspace setup.
- Created TestProvider for in-memory issue tracking during tests.
- Refactored project registration and setup tools to utilize ExecutionMode.
- Updated various tools to ensure compatibility with new workflow and execution modes.
- Added new dependencies: cockatiel for resilience and zod for schema validation.
This commit is contained in:
Lauren ten Hoor
2026-02-16 13:27:14 +08:00
parent a359ffed34
commit 371e760d94
37 changed files with 2444 additions and 263 deletions

View File

@@ -6,8 +6,11 @@ import {
type Issue,
type StateLabel,
type IssueComment,
type PrStatus,
PrState,
} from "./provider.js";
import { runCommand } from "../run-command.js";
import { withResilience } from "./resilience.js";
import {
DEFAULT_WORKFLOW,
getStateLabels,
@@ -41,8 +44,10 @@ export class GitHubProvider implements IssueProvider {
}
private async gh(args: string[]): Promise<string> {
const result = await runCommand(["gh", ...args], { timeoutMs: 30_000, cwd: this.repoPath });
return result.stdout.trim();
return withResilience(async () => {
const result = await runCommand(["gh", ...args], { timeoutMs: 30_000, cwd: this.repoPath });
return result.stdout.trim();
});
}
async ensureLabel(name: string, color: string): Promise<void> {
@@ -125,6 +130,28 @@ export class GitHubProvider implements IssueProvider {
} catch { return null; }
}
async getPrStatus(issueId: number): Promise<PrStatus> {
const pat = `#${issueId}`;
// Check open PRs first
try {
const raw = await this.gh(["pr", "list", "--state", "open", "--json", "title,body,url,reviewDecision", "--limit", "20"]);
const prs = JSON.parse(raw) as Array<{ title: string; body: string; url: string; reviewDecision: string }>;
const pr = prs.find((p) => p.title.includes(pat) || (p.body ?? "").includes(pat));
if (pr) {
const state = pr.reviewDecision === "APPROVED" ? PrState.APPROVED : PrState.OPEN;
return { state, url: pr.url };
}
} catch { /* continue to merged check */ }
// Check merged PRs
try {
const raw = await this.gh(["pr", "list", "--state", "merged", "--json", "title,body,url", "--limit", "20"]);
const prs = JSON.parse(raw) as Array<{ title: string; body: string; url: string }>;
const pr = prs.find((p) => p.title.includes(pat) || (p.body ?? "").includes(pat));
if (pr) return { state: PrState.MERGED, url: pr.url };
} catch { /* ignore */ }
return { state: PrState.CLOSED, url: null };
}
async addComment(issueId: number, body: string): Promise<void> {
await this.gh(["issue", "comment", String(issueId), "--body", body]);
}