mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 21:00:41 +00:00
refactor(coding-agent): centralize git url detection
This commit is contained in:
parent
4719929f6a
commit
254c00b788
3 changed files with 8 additions and 37 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue