- Add GitLabProvider class for handling issue operations, label management, and MR checks. - Implement methods for ensuring labels, creating issues, listing issues by label, and transitioning labels. - Introduce a provider factory to auto-detect GitLab or GitHub based on the repository URL. - Create project registration tool to validate repositories, create state labels, and log project entries. - Enhance queue status and session health tools to support new session management features. - Update task completion and task creation tools to support auto-chaining and improved session handling. - Refactor task pickup tool to streamline model selection and session management.
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
/**
|
|
* Provider factory — creates the appropriate IssueProvider for a repository.
|
|
*
|
|
* Auto-detects provider from git remote URL:
|
|
* - github.com → GitHubProvider (gh CLI)
|
|
* - Everything else → GitLabProvider (glab CLI)
|
|
*
|
|
* Can be overridden with explicit `provider` option.
|
|
*/
|
|
import { execFileSync } from "node:child_process";
|
|
import type { IssueProvider } from "../issue-provider.js";
|
|
import { GitLabProvider } from "./gitlab.js";
|
|
import { GitHubProvider } from "./github.js";
|
|
|
|
export type ProviderOptions = {
|
|
provider?: "gitlab" | "github";
|
|
glabPath?: string;
|
|
ghPath?: string;
|
|
repoPath: string;
|
|
};
|
|
|
|
function detectProvider(repoPath: string): "gitlab" | "github" {
|
|
try {
|
|
const url = execFileSync("git", ["remote", "get-url", "origin"], {
|
|
cwd: repoPath,
|
|
timeout: 5_000,
|
|
}).toString().trim();
|
|
|
|
if (url.includes("github.com")) return "github";
|
|
return "gitlab";
|
|
} catch {
|
|
return "gitlab";
|
|
}
|
|
}
|
|
|
|
export type ProviderWithType = {
|
|
provider: IssueProvider;
|
|
type: "github" | "gitlab";
|
|
};
|
|
|
|
export function createProvider(opts: ProviderOptions): ProviderWithType {
|
|
const type = opts.provider ?? detectProvider(opts.repoPath);
|
|
|
|
if (type === "github") {
|
|
return {
|
|
provider: new GitHubProvider({ ghPath: opts.ghPath, repoPath: opts.repoPath }),
|
|
type: "github",
|
|
};
|
|
}
|
|
return {
|
|
provider: new GitLabProvider({ glabPath: opts.glabPath, repoPath: opts.repoPath }),
|
|
type: "gitlab",
|
|
};
|
|
}
|