feat(coding-agent): add SSH URL support for git packages

Use hosted-git-info library for robust parsing of SSH URLs (git@host:path
and ssh://) in addition to HTTPS. SSH and HTTPS URLs for the same repo
are now properly deduplicated.
This commit is contained in:
Markus Ekholm 2026-02-05 15:13:05 +01:00
parent 0404a93e33
commit fba9a8aece
No known key found for this signature in database
GPG key ID: D0889DEBE04FA19B
9 changed files with 576 additions and 48 deletions

View file

@ -33,6 +33,7 @@ import { allTools } from "./core/tools/index.js";
import { runMigrations, showDeprecationWarnings } from "./migrations.js";
import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
import { parseGitUrl } from "./utils/git.js";
/**
* Read all content from piped stdin.
@ -122,15 +123,13 @@ function normalizeExtensionSource(source: string): { type: "npm" | "git" | "loca
const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@.+)?$/);
return { type: "npm", key: match?.[1] ?? spec };
}
if (source.startsWith("git:")) {
const repo = source.slice("git:".length).trim().split("@")[0] ?? "";
return { type: "git", key: repo.replace(/^https?:\/\//, "").replace(/\.git$/, "") };
}
// Raw git URLs
if (source.startsWith("https://") || source.startsWith("http://")) {
const repo = source.split("@")[0] ?? "";
return { type: "git", key: repo.replace(/^https?:\/\//, "").replace(/\.git$/, "") };
// Try parsing as git URL
const parsed = parseGitUrl(source);
if (parsed) {
return { type: "git", key: `${parsed.host}/${parsed.path}` };
}
return { type: "local", key: source };
}