mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 20:03:05 +00:00
Skip over exact duplicate skills
This commit is contained in:
parent
61cd977926
commit
0c4d60f8c8
1 changed files with 17 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
||||
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from "fs";
|
||||
import { minimatch } from "minimatch";
|
||||
import { homedir } from "os";
|
||||
import { basename, dirname, join, resolve } from "path";
|
||||
|
|
@ -357,6 +357,7 @@ export function loadSkills(options: LoadSkillsOptions = {}): LoadSkillsResult {
|
|||
const resolvedAgentDir = agentDir ?? getAgentDir();
|
||||
|
||||
const skillMap = new Map<string, Skill>();
|
||||
const realPathSet = new Set<string>();
|
||||
const allWarnings: SkillWarning[] = [];
|
||||
const collisionWarnings: SkillWarning[] = [];
|
||||
|
||||
|
|
@ -383,6 +384,20 @@ export function loadSkills(options: LoadSkillsOptions = {}): LoadSkillsResult {
|
|||
if (!matchesIncludePatterns(skill.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Resolve symlinks to detect duplicate files
|
||||
let realPath: string;
|
||||
try {
|
||||
realPath = realpathSync(skill.filePath);
|
||||
} catch {
|
||||
realPath = skill.filePath;
|
||||
}
|
||||
|
||||
// Skip silently if we've already loaded this exact file (via symlink)
|
||||
if (realPathSet.has(realPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const existing = skillMap.get(skill.name);
|
||||
if (existing) {
|
||||
collisionWarnings.push({
|
||||
|
|
@ -391,6 +406,7 @@ export function loadSkills(options: LoadSkillsOptions = {}): LoadSkillsResult {
|
|||
});
|
||||
} else {
|
||||
skillMap.set(skill.name, skill);
|
||||
realPathSet.add(realPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue