fix: address Devin and CodeRabbit review findings

- Use finally for temp cleanup so user cancels don't leak cloned dirs
- Move addSkillToLock outside inner agent loop, merge agents array
- Use source:name as lock key to avoid cross-source collisions
- Gate GitHub activity check on provider.type (skip for GitLab/Bitbucket)
- Normalize source URL to owner/repo before official check
- Include skill name in trust badge output
- Atomic lock.json writes via tmp file + renameSync
- Remove stale --federated suggestion from find no-results message
This commit is contained in:
Rohit Ghumare
2026-04-11 13:36:07 +01:00
parent 56c565bc65
commit 05b566c0df
4 changed files with 41 additions and 21 deletions
+1 -1
View File
@@ -259,7 +259,7 @@ export class FindCommand extends Command {
);
console.log(
colors.muted(
" skillkit find -f <query> # Also search GitHub SKILL.md files",
" skillkit find <query> # Search marketplace + GitHub",
),
);
console.log(colors.muted(" skillkit ui # Browse in TUI"));
+17 -14
View File
@@ -177,16 +177,16 @@ export class InstallCommand extends Command {
skillsToInstall, targetAgents, installMethod, providerAdapter, cloneResult, s,
);
this.cleanupTemp(cloneResult);
this.updateAgentsMd(installResults.length);
await this.showResults(installResults, targetAgents, providerAdapter, isInteractive);
return 0;
} catch (err) {
if (cloneResult) this.cleanupTemp(cloneResult);
s.stop(colors.error("Installation failed"));
console.log(colors.muted(err instanceof Error ? err.message : String(err)));
return 1;
} finally {
if (cloneResult) this.cleanupTemp(cloneResult);
}
}
@@ -448,7 +448,10 @@ export class InstallCommand extends Command {
"supabase/agent-skills",
"stripe/ai",
];
const isOfficial = officialSources.some((prefix) => this.source.startsWith(prefix));
const sourceProvider = detectProvider(this.source);
const parsedSource = sourceProvider?.parseSource(this.source);
const normalizedSource = parsedSource ? `${parsedSource.owner}/${parsedSource.repo}` : this.source;
const isOfficial = officialSources.includes(normalizedSource);
const scorer = new TrustScorer();
for (const skill of skillsToInstall) {
@@ -462,7 +465,7 @@ export class InstallCommand extends Command {
score: result.score,
source: this.source,
});
console.log(` Trust: ${badge}`);
console.log(` ${colors.primary(skill.name)}: ${badge}`);
}
}
console.log("");
@@ -585,15 +588,6 @@ export class InstallCommand extends Command {
metadata.checksum = computeSkillChecksum(targetPath);
saveSkillMetadata(targetPath, metadata);
addSkillToLock(skillName, {
source: this.source,
sourceType: providerAdapter!.type,
installedAt: new Date().toISOString(),
checksum: metadata.checksum,
agents: [agentType],
path: targetPath,
});
installedAgents.push(agentType);
s.stop(`Installed ${skillName} to ${adapter.name}${useSymlink ? " (symlink)" : ""}`);
} catch (err) {
@@ -603,11 +597,20 @@ export class InstallCommand extends Command {
}
if (installedAgents.length > 0) {
const primaryInstallPath = join(getInstallDir(this.global, installedAgents[0] as AgentType), skillName);
addSkillToLock(skillName, {
source: this.source,
sourceType: providerAdapter!.type,
installedAt: new Date().toISOString(),
checksum: computeSkillChecksum(primaryInstallPath),
agents: installedAgents,
path: primaryInstallPath,
});
installResults.push({
skillName,
method: installMethod,
agents: installedAgents,
path: join(getInstallDir(this.global, installedAgents[0] as AgentType), skillName),
path: primaryInstallPath,
});
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ export class UpdateCommand extends Command {
}
const parsed = provider.parseSource?.(metadata.source);
if (parsed && 'owner' in parsed && 'repo' in parsed) {
if (parsed && 'owner' in parsed && 'repo' in parsed && (provider.type === 'github' || provider.type === 'skills-sh')) {
const activity = await fetchGitHubActivity(parsed.owner, parsed.repo);
if (activity?.pushedAt && metadata.updatedAt && activity.pushedAt <= metadata.updatedAt) {
s.stop(`${skill.name}: no changes detected`);
+22 -5
View File
@@ -1,4 +1,4 @@
import { existsSync, readFileSync, writeFileSync, mkdirSync, statSync } from 'node:fs';
import { existsSync, readFileSync, writeFileSync, mkdirSync, statSync, renameSync } from 'node:fs';
import { join, dirname, basename } from 'node:path';
import { homedir } from 'node:os';
import { createHash } from 'node:crypto';
@@ -171,18 +171,35 @@ export function loadLockFile(): LockFile {
export function saveLockFile(lock: LockFile): void {
const dir = dirname(LOCK_FILE);
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
writeFileSync(LOCK_FILE, JSON.stringify(lock, null, 2), 'utf-8');
const tmpFile = `${LOCK_FILE}.${process.pid}.tmp`;
writeFileSync(tmpFile, JSON.stringify(lock, null, 2), 'utf-8');
renameSync(tmpFile, LOCK_FILE);
}
export function addSkillToLock(name: string, entry: LockEntry): void {
const lock = loadLockFile();
lock.skills[name] = entry;
const key = `${entry.source}:${name}`;
const existing = lock.skills[key];
if (existing) {
const mergedAgents = [...new Set([...existing.agents, ...entry.agents])];
lock.skills[key] = { ...entry, agents: mergedAgents };
} else {
lock.skills[key] = entry;
}
saveLockFile(lock);
}
export function removeSkillFromLock(name: string): void {
export function removeSkillFromLock(name: string, source?: string): void {
const lock = loadLockFile();
delete lock.skills[name];
if (source) {
delete lock.skills[`${source}:${name}`];
} else {
for (const key of Object.keys(lock.skills)) {
if (key === name || key.endsWith(`:${name}`)) {
delete lock.skills[key];
}
}
}
saveLockFile(lock);
}