Phase 1: add trackSkill — dedupe tracked skills by name.

Upsert merges sources without reordering the skills list per SPEC §6.1
dedupe and insertion-order rules.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-17 10:04:55 +07:00
parent edcf5352c4
commit a671a6dc35
+31
View File
@@ -86,3 +86,34 @@ export function createRuntimeFlags(): RuntimeFlags {
autoCompactIntegration: "auto",
};
}
export interface TrackSkillInput {
name: string;
filePath: string;
baseDir: string;
source: SkillSource;
seenAt?: number;
}
/** Upsert by name, merge sources, preserve insertion order (SPEC §6.1). */
export function trackSkill(state: ExtensionState, input: TrackSkillInput): void {
const seenAt = input.seenAt ?? Date.now();
const existing = state.skills.find((skill) => skill.name === input.name);
if (existing) {
existing.filePath = input.filePath;
existing.baseDir = input.baseDir;
existing.lastSeenAt = seenAt;
if (!existing.sources.includes(input.source)) {
existing.sources.push(input.source);
}
return;
}
state.skills.push({
name: input.name,
filePath: input.filePath,
baseDir: input.baseDir,
firstSeenAt: seenAt,
lastSeenAt: seenAt,
sources: [input.source],
});
}