cc-hook-registry 1.2.0 → 2.1.0

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.
Files changed (2) hide show
  1. package/index.mjs +70 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -60,6 +60,27 @@ const REGISTRY = [
60
60
  { id: 'read-before-edit', name: 'Read Before Edit Warning', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn when editing files not recently read', tags: ['read', 'edit', 'mismatch', 'old_string'], install: 'npx cc-safe-setup --install-example read-before-edit' },
61
61
  { id: 'commit-quality-gate', name: 'Commit Message Quality', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn on vague commit messages and long subjects', tags: ['commit', 'message', 'quality', 'conventional'], install: 'npx cc-safe-setup --install-example commit-quality-gate' },
62
62
 
63
+ // cc-safe-setup — additional examples
64
+ { id: 'allowlist', name: 'Allowlist (Inverse Permission)', category: 'safety', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Block everything not explicitly approved', tags: ['allowlist', 'whitelist', 'inverse'], install: 'npx cc-safe-setup --install-example allowlist' },
65
+ { id: 'auto-approve-build', name: 'Auto-Approve Build/Test', category: 'approve', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Auto-approve npm/cargo/go build, test, lint commands', tags: ['build', 'test', 'lint', 'npm', 'cargo'], install: 'npx cc-safe-setup --install-example auto-approve-build' },
66
+ { id: 'auto-approve-docker', name: 'Auto-Approve Docker', category: 'approve', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Auto-approve docker build, compose, ps, logs', tags: ['docker', 'compose', 'container'], install: 'npx cc-safe-setup --install-example auto-approve-docker' },
67
+ { id: 'auto-approve-git-read', name: 'Auto-Approve Git Read', category: 'approve', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Auto-approve git status/log/diff even with -C flags', tags: ['git', 'read', 'status', 'log'], install: 'npx cc-safe-setup --install-example auto-approve-git-read' },
68
+ { id: 'auto-approve-python', name: 'Auto-Approve Python', category: 'approve', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Auto-approve pytest, mypy, ruff, black, isort', tags: ['python', 'pytest', 'lint', 'format'], install: 'npx cc-safe-setup --install-example auto-approve-python' },
69
+ { id: 'auto-approve-ssh', name: 'Auto-Approve SSH', category: 'approve', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Auto-approve safe SSH commands (uptime, whoami)', tags: ['ssh', 'remote', 'server'], install: 'npx cc-safe-setup --install-example auto-approve-ssh' },
70
+ { id: 'auto-checkpoint', name: 'Auto-Checkpoint', category: 'recovery', source: 'cc-safe-setup', trigger: 'PostToolUse', desc: 'Auto-commit after edits for rollback protection', tags: ['checkpoint', 'commit', 'rollback', 'recovery'], install: 'npx cc-safe-setup --install-example auto-checkpoint' },
71
+ { id: 'auto-snapshot', name: 'Auto-Snapshot', category: 'recovery', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Save file copies before edits', tags: ['snapshot', 'backup', 'rollback'], install: 'npx cc-safe-setup --install-example auto-snapshot' },
72
+ { id: 'session-checkpoint', name: 'Session Checkpoint', category: 'recovery', source: 'cc-safe-setup', trigger: 'PreCompact', desc: 'Save session state before context compaction', tags: ['session', 'compact', 'state'], install: 'npx cc-safe-setup --install-example session-checkpoint' },
73
+ { id: 'branch-name-check', name: 'Branch Name Check', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn on non-conventional branch names', tags: ['branch', 'naming', 'convention'], install: 'npx cc-safe-setup --install-example branch-name-check' },
74
+ { id: 'commit-message-check', name: 'Commit Message Check', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn on non-conventional commit messages', tags: ['commit', 'message', 'conventional'], install: 'npx cc-safe-setup --install-example commit-message-check' },
75
+ { id: 'edit-guard', name: 'Edit Guard', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Block Edit/Write to protected files', tags: ['edit', 'write', 'protected'], install: 'npx cc-safe-setup --install-example edit-guard' },
76
+ { id: 'enforce-tests', name: 'Enforce Tests', category: 'quality', source: 'cc-safe-setup', trigger: 'PostToolUse', desc: 'Warn when source files change without test files', tags: ['tests', 'enforce', 'quality'], install: 'npx cc-safe-setup --install-example enforce-tests' },
77
+ { id: 'large-file-guard', name: 'Large File Guard', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn when Write creates files over 500KB', tags: ['large', 'file', 'size'], install: 'npx cc-safe-setup --install-example large-file-guard' },
78
+ { id: 'todo-check', name: 'TODO Check', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn when committing files with TODO/FIXME markers', tags: ['todo', 'fixme', 'hack'], install: 'npx cc-safe-setup --install-example todo-check' },
79
+ { id: 'verify-before-commit', name: 'Verify Before Commit', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Block commit unless tests passed recently', tags: ['verify', 'test', 'commit'], install: 'npx cc-safe-setup --install-example verify-before-commit' },
80
+ { id: 'symlink-guard', name: 'Symlink Traversal Guard', category: 'safety', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Detect symlink/junction traversal in rm targets', tags: ['symlink', 'junction', 'ntfs', 'traversal'], install: 'npx cc-safe-setup --install-example symlink-guard', issue: '#36339' },
81
+ { id: 'binary-file-guard', name: 'Binary File Guard', category: 'quality', source: 'cc-safe-setup', trigger: 'PreToolUse', desc: 'Warn when Write targets binary file types', tags: ['binary', 'image', 'archive'], install: 'npx cc-safe-setup --install-example binary-file-guard' },
82
+ { id: 'stale-branch-guard', name: 'Stale Branch Guard', category: 'quality', source: 'cc-safe-setup', trigger: 'PostToolUse', desc: 'Warn when branch is far behind default', tags: ['branch', 'stale', 'behind', 'rebase'], install: 'npx cc-safe-setup --install-example stale-branch-guard' },
83
+
63
84
  // External projects
64
85
  { id: 'safety-net', name: 'Safety Net (Full Suite)', category: 'safety', source: 'kenryu42/claude-code-safety-net', trigger: 'PreToolUse', desc: 'TypeScript safety hooks with configurable severity levels', tags: ['typescript', 'safety', 'configurable'], install: 'npx @anthropic-ai/claude-code-safety-net', stars: 1185 },
65
86
  { id: 'hooks-mastery', name: 'Hooks Mastery (Python)', category: 'framework', source: 'disler/claude-code-hooks-mastery', trigger: 'All', desc: 'Python hooks covering all hook events + LLM integration', tags: ['python', 'mastery', 'all-events', 'llm'], install: 'git clone + copy', stars: 3386 },
@@ -171,10 +192,55 @@ else if (command === 'install') {
171
192
  console.log();
172
193
 
173
194
  if (hook.install.startsWith('npx cc-safe-setup')) {
174
- try {
175
- execSync(hook.install, { stdio: 'inherit' });
176
- } catch (e) {
177
- console.log(c.yellow + ' Run the command manually: ' + hook.install + c.reset);
195
+ // Try direct download first (no cc-safe-setup dependency)
196
+ const exampleName = hook.install.match(/--install-example\s+(\S+)/)?.[1];
197
+ if (exampleName) {
198
+ const rawUrl = `https://raw.githubusercontent.com/yurukusa/cc-safe-setup/main/examples/${exampleName}.sh`;
199
+ const hookPath = join(HOME, '.claude', 'hooks', exampleName + '.sh');
200
+ try {
201
+ mkdirSync(join(HOME, '.claude', 'hooks'), { recursive: true });
202
+ const script = execSync(`curl -sL "${rawUrl}"`, { encoding: 'utf-8' });
203
+ if (script.startsWith('#!/bin/bash')) {
204
+ writeFileSync(hookPath, script);
205
+ chmodSync(hookPath, 0o755);
206
+
207
+ // Auto-register in settings.json
208
+ const trigger = script.includes('PreToolUse') ? 'PreToolUse' :
209
+ script.includes('PostToolUse') ? 'PostToolUse' :
210
+ script.includes('Stop') ? 'Stop' : 'PreToolUse';
211
+ const matcher = script.includes('Matcher: "Bash"') || script.includes('MATCHER: "Bash"') ? 'Bash' :
212
+ script.includes('Matcher: "Edit|Write"') ? 'Edit|Write' : '';
213
+
214
+ let settings = {};
215
+ if (existsSync(SETTINGS_PATH)) {
216
+ try { settings = JSON.parse(readFileSync(SETTINGS_PATH, 'utf-8')); } catch {}
217
+ }
218
+ if (!settings.hooks) settings.hooks = {};
219
+ if (!settings.hooks[trigger]) settings.hooks[trigger] = [];
220
+
221
+ const existing = settings.hooks[trigger].flatMap(e => (e.hooks || []).map(h => h.command));
222
+ if (!existing.some(cmd => cmd.includes(exampleName))) {
223
+ settings.hooks[trigger].push({
224
+ matcher,
225
+ hooks: [{ type: 'command', command: hookPath }],
226
+ });
227
+ mkdirSync(dirname(SETTINGS_PATH), { recursive: true });
228
+ writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2));
229
+ }
230
+
231
+ console.log(c.green + ' ✓ Installed: ' + hookPath + c.reset);
232
+ console.log(c.green + ' ✓ Registered in settings.json (' + trigger + ')' + c.reset);
233
+ console.log(c.dim + ' Restart Claude Code to activate.' + c.reset);
234
+ } else {
235
+ throw new Error('Invalid script');
236
+ }
237
+ } catch {
238
+ // Fallback to cc-safe-setup
239
+ console.log(c.dim + ' Direct download failed, using cc-safe-setup...' + c.reset);
240
+ try { execSync(hook.install, { stdio: 'inherit' }); } catch {}
241
+ }
242
+ } else {
243
+ try { execSync(hook.install, { stdio: 'inherit' }); } catch {}
178
244
  }
179
245
  } else {
180
246
  console.log(c.dim + ' This hook requires manual installation. Follow the instructions above.' + c.reset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-hook-registry",
3
- "version": "1.2.0",
3
+ "version": "2.1.0",
4
4
  "description": "Search, browse, and install Claude Code hooks from the community. GitHub-based registry, no server needed.",
5
5
  "main": "index.mjs",
6
6
  "bin": {