refactor: reorganize task management imports and update task handling tools
- Updated import paths for task management providers in task-comment, task-create, and task-update tools. - Removed deprecated task-complete and task-pickup tools, replacing them with work-finish and work-start tools for improved task handling. - Enhanced work-finish and work-start tools to streamline task completion and pickup processes, including context-aware detection and auto-scheduling features. - Updated package.json to include build scripts and main entry point. - Modified tsconfig.json to enable output directory, declaration files, and source maps for better TypeScript support.
This commit is contained in:
36
lib/providers/index.ts
Normal file
36
lib/providers/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Provider factory — auto-detects GitHub vs GitLab from git remote.
|
||||
*/
|
||||
import { execFileSync } from "node:child_process";
|
||||
import type { IssueProvider } from "./provider.js";
|
||||
import { GitLabProvider } from "./gitlab.js";
|
||||
import { GitHubProvider } from "./github.js";
|
||||
import { resolveRepoPath } from "../projects.js";
|
||||
|
||||
export type ProviderOptions = {
|
||||
provider?: "gitlab" | "github";
|
||||
repo?: string;
|
||||
repoPath?: string;
|
||||
};
|
||||
|
||||
export type ProviderWithType = {
|
||||
provider: IssueProvider;
|
||||
type: "github" | "gitlab";
|
||||
};
|
||||
|
||||
function detectProvider(repoPath: string): "gitlab" | "github" {
|
||||
try {
|
||||
const url = execFileSync("git", ["remote", "get-url", "origin"], { cwd: repoPath, timeout: 5_000 }).toString().trim();
|
||||
return url.includes("github.com") ? "github" : "gitlab";
|
||||
} catch {
|
||||
return "gitlab";
|
||||
}
|
||||
}
|
||||
|
||||
export function createProvider(opts: ProviderOptions): ProviderWithType {
|
||||
const repoPath = opts.repoPath ?? (opts.repo ? resolveRepoPath(opts.repo) : null);
|
||||
if (!repoPath) throw new Error("Either repoPath or repo must be provided");
|
||||
const type = opts.provider ?? detectProvider(repoPath);
|
||||
const provider = type === "github" ? new GitHubProvider({ repoPath }) : new GitLabProvider({ repoPath });
|
||||
return { provider, type };
|
||||
}
|
||||
Reference in New Issue
Block a user