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:
@@ -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],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user