diff --git a/packages/coding-agent/src/core/package-manager.ts b/packages/coding-agent/src/core/package-manager.ts index 1ee3db55..41021532 100644 --- a/packages/coding-agent/src/core/package-manager.ts +++ b/packages/coding-agent/src/core/package-manager.ts @@ -5,6 +5,7 @@ import { homedir, tmpdir } from "node:os"; import { basename, dirname, join, relative, resolve } from "node:path"; import { minimatch } from "minimatch"; import { CONFIG_DIR_NAME } from "../config.js"; +import { looksLikeGitUrl } from "../utils/git.js"; import type { PackageSource, SettingsManager } from "./settings-manager.js"; export interface PathMetadata { @@ -522,7 +523,7 @@ export class DefaultPackageManager implements PackageManager { }; } - if (source.startsWith("git:") || this.looksLikeGitUrl(source)) { + if (source.startsWith("git:") || looksLikeGitUrl(source)) { const repoSpec = source.startsWith("git:") ? source.slice("git:".length).trim() : source; const [repo, ref] = repoSpec.split("@"); const normalized = repo.replace(/^https?:\/\//, "").replace(/\.git$/, ""); @@ -542,12 +543,6 @@ export class DefaultPackageManager implements PackageManager { return { type: "local", path: source }; } - private looksLikeGitUrl(source: string): boolean { - const gitHosts = ["github.com", "gitlab.com", "bitbucket.org", "codeberg.org"]; - const normalized = source.replace(/^https?:\/\//, ""); - return gitHosts.some((host) => normalized.startsWith(`${host}/`)); - } - /** * Get a unique identity for a package, ignoring version/ref. * Used to detect when the same package is in both global and project settings. diff --git a/packages/coding-agent/src/core/settings-manager.ts b/packages/coding-agent/src/core/settings-manager.ts index acdf8e8d..dfc75826 100644 --- a/packages/coding-agent/src/core/settings-manager.ts +++ b/packages/coding-agent/src/core/settings-manager.ts @@ -195,39 +195,9 @@ export class SettingsManager { } } - // Migrate npm:/git: sources from extensions array to packages array - if (Array.isArray(settings.extensions)) { - const localExtensions: string[] = []; - const packageSources: string[] = []; - - for (const ext of settings.extensions) { - if (typeof ext !== "string") continue; - if (ext.startsWith("npm:") || ext.startsWith("git:") || SettingsManager.looksLikeGitUrl(ext)) { - packageSources.push(ext); - } else { - localExtensions.push(ext); - } - } - - if (packageSources.length > 0) { - const existingPackages = Array.isArray(settings.packages) ? settings.packages : []; - settings.packages = [...existingPackages, ...packageSources]; - settings.extensions = localExtensions.length > 0 ? localExtensions : undefined; - if (settings.extensions === undefined) { - delete settings.extensions; - } - } - } - return settings as Settings; } - private static looksLikeGitUrl(source: string): boolean { - const gitHosts = ["github.com", "gitlab.com", "bitbucket.org", "codeberg.org"]; - const normalized = source.replace(/^https?:\/\//, ""); - return gitHosts.some((host) => normalized.startsWith(`${host}/`)); - } - private loadProjectSettings(): Settings { // In-memory mode: return stored in-memory project settings if (!this.persist) { diff --git a/packages/coding-agent/src/utils/git.ts b/packages/coding-agent/src/utils/git.ts new file mode 100644 index 00000000..30363c32 --- /dev/null +++ b/packages/coding-agent/src/utils/git.ts @@ -0,0 +1,6 @@ +const GIT_HOSTS = ["github.com", "gitlab.com", "bitbucket.org", "codeberg.org"]; + +export function looksLikeGitUrl(source: string): boolean { + const normalized = source.replace(/^https?:\/\//, ""); + return GIT_HOSTS.some((host) => normalized.startsWith(`${host}/`)); +}