cc-safe-setup 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/index.mjs +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,11 @@ cc-safe-setup gives you 4 essential hooks. For the complete autonomous operation
|
|
|
80
80
|
|
|
81
81
|
Or start with the free hooks: [claude-code-hooks](https://github.com/yurukusa/claude-code-hooks)
|
|
82
82
|
|
|
83
|
+
## Related
|
|
84
|
+
|
|
85
|
+
- [Japanese guide (Qiita)](https://qiita.com/yurukusa/items/a9714b33f5d974e8f1e8) — この記事の日本語解説
|
|
86
|
+
- [The incident that inspired this tool](https://github.com/anthropics/claude-code/issues/36339) — NTFS junction rm -rf
|
|
87
|
+
|
|
83
88
|
## License
|
|
84
89
|
|
|
85
90
|
MIT
|
package/index.mjs
CHANGED
|
@@ -50,8 +50,53 @@ function ask(question) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const DRY_RUN = process.argv.includes('--dry-run') || process.argv.includes('-n');
|
|
53
|
+
const UNINSTALL = process.argv.includes('--uninstall') || process.argv.includes('--remove');
|
|
54
|
+
|
|
55
|
+
async function uninstall() {
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(c.bold + ' cc-safe-setup --uninstall' + c.reset);
|
|
58
|
+
console.log();
|
|
59
|
+
|
|
60
|
+
let removed = 0;
|
|
61
|
+
for (const id of Object.keys(HOOKS)) {
|
|
62
|
+
const hookPath = join(HOOKS_DIR, id + '.sh');
|
|
63
|
+
if (existsSync(hookPath)) {
|
|
64
|
+
const { unlinkSync } = await import('fs');
|
|
65
|
+
unlinkSync(hookPath);
|
|
66
|
+
console.log(' ' + c.red + 'x' + c.reset + ' Removed ' + c.dim + hookPath + c.reset);
|
|
67
|
+
removed++;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (existsSync(SETTINGS_PATH)) {
|
|
72
|
+
try {
|
|
73
|
+
const settings = JSON.parse(readFileSync(SETTINGS_PATH, 'utf-8'));
|
|
74
|
+
if (settings.hooks) {
|
|
75
|
+
for (const trigger of Object.keys(settings.hooks)) {
|
|
76
|
+
settings.hooks[trigger] = settings.hooks[trigger].filter(e =>
|
|
77
|
+
!e.hooks || !e.hooks.some(h => {
|
|
78
|
+
const cmd = h.command || '';
|
|
79
|
+
return Object.keys(HOOKS).some(id => cmd.includes(id + '.sh'));
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
if (settings.hooks[trigger].length === 0) delete settings.hooks[trigger];
|
|
83
|
+
}
|
|
84
|
+
if (Object.keys(settings.hooks).length === 0) delete settings.hooks;
|
|
85
|
+
writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
86
|
+
console.log(' ' + c.red + 'x' + c.reset + ' Cleaned settings.json');
|
|
87
|
+
}
|
|
88
|
+
} catch(e) {}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
console.log();
|
|
92
|
+
console.log(c.bold + ' Done.' + c.reset + ' ' + removed + ' hooks removed.');
|
|
93
|
+
console.log(' ' + c.dim + 'Restart Claude Code to deactivate.' + c.reset);
|
|
94
|
+
console.log();
|
|
95
|
+
}
|
|
53
96
|
|
|
54
97
|
async function main() {
|
|
98
|
+
if (UNINSTALL) return uninstall();
|
|
99
|
+
|
|
55
100
|
console.log();
|
|
56
101
|
console.log(c.bold + ' cc-safe-setup' + c.reset);
|
|
57
102
|
console.log(c.dim + ' Make Claude Code safe for autonomous operation' + c.reset);
|
package/package.json
CHANGED