fix: standalone path in lock, sync lock on update, honor --force

- install: use actual installed path (handles .md files) for lock
  entry and results instead of reconstructing from skillName
- update: call addSkillToLock after both local and remote updates
  so lock.json stays in sync with metadata
- update: --force bypasses GitHub activity and checksum skip-checks
- update: timestamp comparison falls back to installedAt when
  updatedAt is not set
This commit is contained in:
Rohit Ghumare
2026-04-11 13:46:28 +01:00
parent 05b566c0df
commit e7dbaeb2b3
2 changed files with 32 additions and 8 deletions
+8 -4
View File
@@ -597,20 +597,24 @@ export class InstallCommand extends Command {
}
if (installedAgents.length > 0) {
const primaryInstallPath = join(getInstallDir(this.global, installedAgents[0] as AgentType), skillName);
const firstAgentInstallDir = getInstallDir(this.global, installedAgents[0] as AgentType);
const isStandalone = existsSync(join(firstAgentInstallDir, skillName.endsWith(".md") ? skillName : `${skillName}.md`));
const actualPath = isStandalone
? join(firstAgentInstallDir, skillName.endsWith(".md") ? skillName : `${skillName}.md`)
: join(firstAgentInstallDir, skillName);
addSkillToLock(skillName, {
source: this.source,
sourceType: providerAdapter!.type,
installedAt: new Date().toISOString(),
checksum: computeSkillChecksum(primaryInstallPath),
checksum: computeSkillChecksum(actualPath),
agents: installedAgents,
path: primaryInstallPath,
path: actualPath,
});
installResults.push({
skillName,
method: installMethod,
agents: installedAgents,
path: primaryInstallPath,
path: actualPath,
});
}
}
+24 -4
View File
@@ -1,7 +1,7 @@
import { existsSync, rmSync, cpSync } from 'node:fs';
import { join } from 'node:path';
import { Command, Option } from 'clipanion';
import { findAllSkills, findSkill, detectProvider, isLocalPath, computeSkillChecksum } from '@skillkit/core';
import { findAllSkills, findSkill, detectProvider, isLocalPath, computeSkillChecksum, addSkillToLock } from '@skillkit/core';
import { getSearchDirs, loadSkillMetadata, saveSkillMetadata, fetchGitHubActivity } from '../helpers.js';
import { colors, spinner, warn, step } from '../onboarding/index.js';
@@ -86,8 +86,18 @@ export class UpdateCommand extends Command {
rmSync(skill.path, { recursive: true, force: true });
cpSync(localPath, skill.path, { recursive: true, dereference: true });
metadata.checksum = computeSkillChecksum(skill.path);
metadata.updatedAt = new Date().toISOString();
saveSkillMetadata(skill.path, metadata);
addSkillToLock(skill.name, {
source: metadata.source,
sourceType: metadata.sourceType,
installedAt: metadata.installedAt,
updatedAt: metadata.updatedAt,
checksum: metadata.checksum,
agents: [],
path: skill.path,
});
s.stop(`Updated ${skill.name}`);
updated++;
@@ -101,9 +111,10 @@ export class UpdateCommand extends Command {
}
const parsed = provider.parseSource?.(metadata.source);
if (parsed && 'owner' in parsed && 'repo' in parsed && (provider.type === 'github' || provider.type === 'skills-sh')) {
if (!this.force && 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) {
const localDate = metadata.updatedAt ?? metadata.installedAt;
if (activity?.pushedAt && localDate && activity.pushedAt <= localDate) {
s.stop(`${skill.name}: no changes detected`);
skipped++;
continue;
@@ -131,7 +142,7 @@ export class UpdateCommand extends Command {
}
const newChecksum = computeSkillChecksum(sourcePath);
if (newChecksum && metadata.checksum && newChecksum === metadata.checksum) {
if (!this.force && newChecksum && metadata.checksum && newChecksum === metadata.checksum) {
s.stop(`${skill.name}: already up to date`);
rmSync(result.path, { recursive: true, force: true });
skipped++;
@@ -146,6 +157,15 @@ export class UpdateCommand extends Command {
metadata.checksum = computeSkillChecksum(skill.path);
metadata.updatedAt = new Date().toISOString();
saveSkillMetadata(skill.path, metadata);
addSkillToLock(skill.name, {
source: metadata.source,
sourceType: metadata.sourceType,
installedAt: metadata.installedAt,
updatedAt: metadata.updatedAt,
checksum: metadata.checksum,
agents: [],
path: skill.path,
});
s.stop(`Updated ${skill.name}`);
updated++;