fix(indexer): update skillPath/branch on upsert to fix stale paths

The upsert query was missing skillPath and branch in onConflictDoUpdate,
so when a repo was restructured (e.g., skills moved to category
subdirectories), the DB retained the old path forever. Also updated
skill-indexer to not skip re-indexing when only the path changed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
airano
2026-02-13 04:56:40 +03:30
parent 908576a307
commit e8bf89d311
2 changed files with 307 additions and 2 deletions

View File

@@ -58,8 +58,16 @@ export async function indexSkill(
// Check if we need to update (unless force)
if (!force) {
if (existing && existing.contentHash === analysis.meta.contentHash) {
console.log(`Skill ${skillId} unchanged, skipping`);
return null;
// Content unchanged, but check if path/branch changed
// (e.g., repo was restructured, file moved to a different directory)
const actualBranch = source.branch || content.repoMeta.defaultBranch;
if (existing.skillPath !== source.path || existing.branch !== actualBranch) {
console.log(`Skill ${skillId} path changed: ${existing.skillPath}${source.path}`);
// Don't skip - fall through to upsert which now updates skillPath/branch
} else {
console.log(`Skill ${skillId} unchanged, skipping`);
return null;
}
}
}