fix: address PR review — shebang, double-escaping, data loss, uninstall scope
- Add shebang banner to NPX CLI esbuild config so npx claude-mem works - Remove manual backslash pre-escaping in WindsurfHooksInstaller (JSON.stringify handles it) - Scope cache deletion to claude-mem only, not entire vendor namespace - Use getWorkerPort() in OpenCodeInstaller instead of hard-coded 37777 - Throw on corrupt JSON in readJsonSafe/readGeminiSettings/Windsurf to prevent data loss - Fix Cursor install stub to warn instead of silently succeeding - Fix Gemini uninstall to remove individual hooks within groups, not whole groups - Update tests for new corrupt-file-throws behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -192,35 +192,34 @@ describe('MCP Integrations', () => {
|
||||
});
|
||||
|
||||
describe('corrupt file recovery', () => {
|
||||
it('replaces corrupt JSON with fresh config', () => {
|
||||
it('throws on corrupt JSON to prevent data loss', () => {
|
||||
const configPath = join(tempDir, 'mcp.json');
|
||||
writeFileSync(configPath, 'not valid json {{{{');
|
||||
|
||||
// readJsonSafe returns default {} for corrupt file
|
||||
writeMcpJsonConfig(configPath, '/path/to/mcp.cjs');
|
||||
expect(() => writeMcpJsonConfig(configPath, '/path/to/mcp.cjs')).toThrow(
|
||||
/Corrupt JSON file, refusing to overwrite/
|
||||
);
|
||||
|
||||
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
||||
expect(config.mcpServers['claude-mem']).toBeDefined();
|
||||
// Original file should be untouched
|
||||
expect(readFileSync(configPath, 'utf-8')).toBe('not valid json {{{{');
|
||||
});
|
||||
|
||||
it('handles empty file gracefully', () => {
|
||||
it('throws on empty file to prevent data loss', () => {
|
||||
const configPath = join(tempDir, 'mcp.json');
|
||||
writeFileSync(configPath, '');
|
||||
|
||||
writeMcpJsonConfig(configPath, '/path/to/mcp.cjs');
|
||||
|
||||
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
||||
expect(config.mcpServers['claude-mem']).toBeDefined();
|
||||
expect(() => writeMcpJsonConfig(configPath, '/path/to/mcp.cjs')).toThrow(
|
||||
/Corrupt JSON file, refusing to overwrite/
|
||||
);
|
||||
});
|
||||
|
||||
it('handles file with only whitespace', () => {
|
||||
it('throws on file with only whitespace', () => {
|
||||
const configPath = join(tempDir, 'mcp.json');
|
||||
writeFileSync(configPath, ' \n\n ');
|
||||
|
||||
writeMcpJsonConfig(configPath, '/path/to/mcp.cjs');
|
||||
|
||||
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
||||
expect(config.mcpServers['claude-mem']).toBeDefined();
|
||||
expect(() => writeMcpJsonConfig(configPath, '/path/to/mcp.cjs')).toThrow(
|
||||
/Corrupt JSON file, refusing to overwrite/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user