SuperCharge Claude Code v1.0.0 - Complete Customization Package
Features: - 30+ Custom Skills (cognitive, development, UI/UX, autonomous agents) - RalphLoop autonomous agent integration - Multi-AI consultation (Qwen) - Agent management system with sync capabilities - Custom hooks for session management - MCP servers integration - Plugin marketplace setup - Comprehensive installation script Components: - Skills: always-use-superpowers, ralph, brainstorming, ui-ux-pro-max, etc. - Agents: 100+ agents across engineering, marketing, product, etc. - Hooks: session-start-superpowers, qwen-consult, ralph-auto-trigger - Commands: /brainstorm, /write-plan, /execute-plan - MCP Servers: zai-mcp-server, web-search-prime, web-reader, zread - Binaries: ralphloop wrapper Installation: ./supercharge.sh
This commit is contained in:
81
plugins/claude-code-safety-net/src/bin/claude-code.ts
Normal file
81
plugins/claude-code-safety-net/src/bin/claude-code.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { analyzeCommand, loadConfig } from '../core/analyze.ts';
|
||||
import { redactSecrets, writeAuditLog } from '../core/audit.ts';
|
||||
import { envTruthy } from '../core/env.ts';
|
||||
import { formatBlockedMessage } from '../core/format.ts';
|
||||
import type { HookInput, HookOutput } from '../types.ts';
|
||||
|
||||
function outputDeny(reason: string, command?: string, segment?: string): void {
|
||||
const message = formatBlockedMessage({
|
||||
reason,
|
||||
command,
|
||||
segment,
|
||||
redact: redactSecrets,
|
||||
});
|
||||
|
||||
const output: HookOutput = {
|
||||
hookSpecificOutput: {
|
||||
hookEventName: 'PreToolUse',
|
||||
permissionDecision: 'deny',
|
||||
permissionDecisionReason: message,
|
||||
},
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(output));
|
||||
}
|
||||
|
||||
export async function runClaudeCodeHook(): Promise<void> {
|
||||
const chunks: Buffer[] = [];
|
||||
|
||||
for await (const chunk of process.stdin) {
|
||||
chunks.push(chunk as Buffer);
|
||||
}
|
||||
|
||||
const inputText = Buffer.concat(chunks).toString('utf-8').trim();
|
||||
|
||||
if (!inputText) {
|
||||
return;
|
||||
}
|
||||
|
||||
let input: HookInput;
|
||||
try {
|
||||
input = JSON.parse(inputText) as HookInput;
|
||||
} catch {
|
||||
if (envTruthy('SAFETY_NET_STRICT')) {
|
||||
outputDeny('Failed to parse hook input JSON (strict mode)');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.tool_name !== 'Bash') {
|
||||
return;
|
||||
}
|
||||
|
||||
const command = input.tool_input?.command;
|
||||
if (!command) {
|
||||
return;
|
||||
}
|
||||
|
||||
const cwd = input.cwd ?? process.cwd();
|
||||
const strict = envTruthy('SAFETY_NET_STRICT');
|
||||
const paranoidAll = envTruthy('SAFETY_NET_PARANOID');
|
||||
const paranoidRm = paranoidAll || envTruthy('SAFETY_NET_PARANOID_RM');
|
||||
const paranoidInterpreters = paranoidAll || envTruthy('SAFETY_NET_PARANOID_INTERPRETERS');
|
||||
|
||||
const config = loadConfig(cwd);
|
||||
|
||||
const result = analyzeCommand(command, {
|
||||
cwd,
|
||||
config,
|
||||
strict,
|
||||
paranoidRm,
|
||||
paranoidInterpreters,
|
||||
});
|
||||
|
||||
if (result) {
|
||||
const sessionId = input.session_id;
|
||||
if (sessionId) {
|
||||
writeAuditLog(sessionId, command, result.segment, result.reason, cwd);
|
||||
}
|
||||
outputDeny(result.reason, command, result.segment);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user