mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
fix(skills): improve robustness of enable/disable operations
- Add rollback in moveDirectory when rmSync fails after cpSync - Add transaction rollback in disable/enableSkill when config save fails - Surface config corruption by throwing on JSON parse errors - Add robust JSON error parsing with fallback in frontend - Add loading state and double-click prevention for toggle button
This commit is contained in:
@@ -64,19 +64,28 @@ function getDisabledSkillsConfigPath(location: SkillLocation, projectPath: strin
|
||||
|
||||
/**
|
||||
* Load disabled skills configuration
|
||||
* Throws on JSON parse errors to surface config corruption
|
||||
*/
|
||||
function loadDisabledSkillsConfig(location: SkillLocation, projectPath: string): DisabledSkillsConfig {
|
||||
const configPath = getDisabledSkillsConfigPath(location, projectPath);
|
||||
try {
|
||||
if (existsSync(configPath)) {
|
||||
const content = readFileSync(configPath, 'utf8');
|
||||
const config = JSON.parse(content);
|
||||
return { skills: config.skills || {} };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[Skills] Failed to load disabled skills config: ${error}`);
|
||||
|
||||
if (!existsSync(configPath)) {
|
||||
return { skills: {} };
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readFileSync(configPath, 'utf8');
|
||||
const config = JSON.parse(content);
|
||||
return { skills: config.skills || {} };
|
||||
} catch (error) {
|
||||
// Throw on JSON parse errors to surface config corruption
|
||||
if (error instanceof SyntaxError) {
|
||||
throw new Error(`Config file corrupted: ${configPath}`);
|
||||
}
|
||||
// Log and return empty for other errors (permission, etc.)
|
||||
console.error(`[Skills] Failed to load disabled skills config: ${error}`);
|
||||
return { skills: {} };
|
||||
}
|
||||
return { skills: {} };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user