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
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { Plugin } from '@opencode-ai/plugin';
|
|
import { analyzeCommand, loadConfig } from './core/analyze.ts';
|
|
import { envTruthy } from './core/env.ts';
|
|
import { formatBlockedMessage } from './core/format.ts';
|
|
import { loadBuiltinCommands } from './features/builtin-commands/index.ts';
|
|
|
|
export const SafetyNetPlugin: Plugin = async ({ directory }) => {
|
|
const safetyNetConfig = loadConfig(directory);
|
|
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');
|
|
|
|
return {
|
|
config: async (opencodeConfig: Record<string, unknown>) => {
|
|
const builtinCommands = loadBuiltinCommands();
|
|
const existingCommands = (opencodeConfig.command as Record<string, unknown>) ?? {};
|
|
|
|
opencodeConfig.command = {
|
|
...builtinCommands,
|
|
...existingCommands,
|
|
};
|
|
},
|
|
|
|
'tool.execute.before': async (input, output) => {
|
|
if (input.tool === 'bash') {
|
|
const command = output.args.command;
|
|
const result = analyzeCommand(command, {
|
|
cwd: directory,
|
|
config: safetyNetConfig,
|
|
strict,
|
|
paranoidRm,
|
|
paranoidInterpreters,
|
|
});
|
|
if (result) {
|
|
const message = formatBlockedMessage({
|
|
reason: result.reason,
|
|
command,
|
|
segment: result.segment,
|
|
});
|
|
|
|
throw new Error(message);
|
|
}
|
|
}
|
|
},
|
|
};
|
|
};
|