start-vibing 3.0.7 → 3.0.8

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 (36) hide show
  1. package/README.md +64 -51
  2. package/package.json +1 -1
  3. package/template/.claude/CLAUDE.md +702 -229
  4. package/template/.claude/agents/claude-md-compactor.md +2 -14
  5. package/template/.claude/agents/documenter.md +0 -7
  6. package/template/.claude/agents/domain-updater.md +2 -7
  7. package/template/.claude/config/README.md +10 -8
  8. package/template/.claude/config/domain-mapping.json +1 -1
  9. package/template/.claude/settings.json +0 -129
  10. package/template/.claude/skills/codebase-knowledge/domains/claude-system.md +51 -416
  11. package/template/.claude/skills/codebase-knowledge/domains/mcp-integration.md +37 -204
  12. package/template/CLAUDE.md +65 -701
  13. package/template/.claude/agents/_archive/13-debugging/build-error-fixer.md +0 -207
  14. package/template/.claude/agents/_archive/13-debugging/debugger.md +0 -149
  15. package/template/.claude/agents/_archive/13-debugging/error-stack-analyzer.md +0 -141
  16. package/template/.claude/agents/_archive/13-debugging/network-debugger.md +0 -208
  17. package/template/.claude/agents/_archive/13-debugging/runtime-error-fixer.md +0 -181
  18. package/template/.claude/agents/_archive/13-debugging/type-error-resolver.md +0 -185
  19. package/template/.claude/agents/_archive/14-validation/final-validator.md +0 -93
  20. package/template/.claude/commands/feature.md +0 -48
  21. package/template/.claude/commands/fix.md +0 -80
  22. package/template/.claude/commands/research.md +0 -107
  23. package/template/.claude/commands/validate.md +0 -72
  24. package/template/.claude/config/mcp-config.json +0 -344
  25. package/template/.claude/hooks/SETUP.md +0 -126
  26. package/template/.claude/hooks/run-hook.cmd +0 -46
  27. package/template/.claude/hooks/run-hook.sh +0 -43
  28. package/template/.claude/hooks/run-hook.ts +0 -230
  29. package/template/.claude/hooks/security-check.js +0 -202
  30. package/template/.claude/hooks/stop-validator.ts +0 -1667
  31. package/template/.claude/hooks/user-prompt-submit.ts +0 -104
  32. package/template/.claude/scripts/mcp-quick-install.ts +0 -151
  33. package/template/.claude/scripts/setup-mcps.ts +0 -651
  34. package/template/.claude/skills/hook-development/SKILL.md +0 -343
  35. package/template/.claude/skills/mongoose-patterns/SKILL.md +0 -499
  36. package/template/.claude/skills/playwright-automation/SKILL.md +0 -438
@@ -1,230 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Universal Hook Runner
4
- *
5
- * Runs hooks with multiple runtime fallbacks:
6
- * 1. bun (primary - fastest TypeScript execution)
7
- * 2. npx tsx (TypeScript fallback)
8
- * 3. python3 (Python fallback)
9
- * 4. python (Python fallback)
10
- *
11
- * IMPORTANT: TypeScript files are the source of truth.
12
- * Python files are only for environments without Node.js/Bun.
13
- *
14
- * Usage: npx tsx run-hook.ts <hook-name>
15
- * The hook-name should be without extension (e.g., "stop-validator")
16
- */
17
-
18
- import { spawnSync } from 'child_process';
19
- import { existsSync, unlinkSync } from 'fs';
20
- import { join, dirname } from 'path';
21
- import { fileURLToPath } from 'url';
22
-
23
- // Get hooks directory - handle both ESM and CJS contexts
24
- const getHooksDir = (): string => {
25
- try {
26
- if (typeof import.meta.url !== 'undefined') {
27
- return dirname(fileURLToPath(import.meta.url));
28
- }
29
- } catch {
30
- // Fallback for environments where import.meta is not available
31
- }
32
- return process.cwd();
33
- };
34
-
35
- const HOOKS_DIR = getHooksDir();
36
-
37
- /**
38
- * Remove deprecated settings.local.json if it exists.
39
- * This file was previously tracked but should not be used anymore.
40
- * All hooks should use the universal runner via settings.json.
41
- */
42
- function cleanupDeprecatedFiles(): void {
43
- const claudeDir = join(HOOKS_DIR, '..');
44
- const settingsLocalPath = join(claudeDir, 'settings.local.json');
45
-
46
- if (existsSync(settingsLocalPath)) {
47
- try {
48
- unlinkSync(settingsLocalPath);
49
- console.error('[run-hook] Removed deprecated settings.local.json');
50
- } catch {
51
- // Ignore errors - file may be locked or read-only
52
- }
53
- }
54
- }
55
-
56
- function checkRuntime(cmd: string): boolean {
57
- try {
58
- const result = spawnSync(cmd, ['--version'], {
59
- stdio: 'pipe',
60
- shell: true,
61
- timeout: 5000,
62
- windowsHide: true,
63
- });
64
- return result.status === 0;
65
- } catch {
66
- return false;
67
- }
68
- }
69
-
70
- interface RuntimeResult {
71
- exitCode: number;
72
- output: string;
73
- error?: string;
74
- }
75
-
76
- function runWithRuntime(
77
- cmd: string,
78
- args: string[],
79
- input: string
80
- ): RuntimeResult {
81
- try {
82
- const result = spawnSync(cmd, args, {
83
- input,
84
- shell: true,
85
- stdio: ['pipe', 'pipe', 'pipe'],
86
- timeout: 30000,
87
- windowsHide: true,
88
- encoding: 'utf8',
89
- });
90
-
91
- return {
92
- exitCode: result.status ?? 1,
93
- output: result.stdout?.toString() || '',
94
- error: result.stderr?.toString() || undefined,
95
- };
96
- } catch (err) {
97
- return {
98
- exitCode: 1,
99
- output: '',
100
- error: err instanceof Error ? err.message : 'Unknown error',
101
- };
102
- }
103
- }
104
-
105
- async function runHook(hookName: string, stdinData: string): Promise<void> {
106
- const tsPath = join(HOOKS_DIR, `${hookName}.ts`);
107
-
108
- // Runtime detection order - TypeScript ONLY (source of truth)
109
- // Python files are deprecated and should be removed
110
- const runtimes: Array<{ name: string; cmd: string }> = [
111
- { name: 'bun', cmd: 'bun' },
112
- { name: 'npx-tsx', cmd: 'npx tsx' },
113
- ];
114
-
115
- for (const runtime of runtimes) {
116
- if (!existsSync(tsPath)) {
117
- continue;
118
- }
119
-
120
- if (!checkRuntime(runtime.cmd.split(' ')[0])) {
121
- continue;
122
- }
123
-
124
- const result = runWithRuntime(runtime.cmd, [tsPath], stdinData);
125
-
126
- // Handle exit codes according to Claude Code hook specification:
127
- // - Exit code 0: Success (stdout in transcript)
128
- // - Exit code 2: Blocking error (stderr feeds back to Claude)
129
- // - Other: Non-blocking error
130
-
131
- if (result.exitCode === 0) {
132
- // Success - output stdout
133
- process.stdout.write(result.output);
134
- process.exit(0);
135
- } else if (result.exitCode === 2) {
136
- // Blocking error - for Stop hooks, JSON is in stdout
137
- // Pass through both stdout (JSON response) and stderr (debug logs)
138
- process.stdout.write(result.output);
139
- if (result.error) {
140
- process.stderr.write(result.error);
141
- }
142
- process.exit(2);
143
- } else {
144
- // Non-blocking error or runtime not found
145
- if (result.error?.includes('not found')) {
146
- // Runtime not available, try next
147
- continue;
148
- }
149
- // Hook failed but not blocking
150
- process.stdout.write(result.output);
151
- if (result.error) {
152
- process.stderr.write(result.error);
153
- }
154
- process.exit(result.exitCode);
155
- }
156
- }
157
-
158
- // No runtime available - return safe default
159
- console.error(`[run-hook] No runtime available to run hook: ${hookName}`);
160
- console.error('[run-hook] Please install bun or Node.js (for npx tsx)');
161
- const safeDefault = JSON.stringify({
162
- decision: 'approve',
163
- continue: true,
164
- reason: 'Hook runtime not available, allowing by default',
165
- });
166
- process.stdout.write(safeDefault);
167
- process.exit(0);
168
- }
169
-
170
- async function readStdinWithTimeout(timeoutMs: number): Promise<string> {
171
- return new Promise((resolve) => {
172
- const timeout = setTimeout(() => {
173
- process.stdin.destroy();
174
- resolve('{}');
175
- }, timeoutMs);
176
-
177
- let data = '';
178
- process.stdin.setEncoding('utf8');
179
- process.stdin.on('data', (chunk: string) => {
180
- data += chunk;
181
- });
182
- process.stdin.on('end', () => {
183
- clearTimeout(timeout);
184
- resolve(data || '{}');
185
- });
186
- process.stdin.on('error', () => {
187
- clearTimeout(timeout);
188
- resolve('{}');
189
- });
190
-
191
- // Handle case where stdin is empty/closed immediately
192
- if (process.stdin.readableEnded) {
193
- clearTimeout(timeout);
194
- resolve('{}');
195
- }
196
- });
197
- }
198
-
199
- // Main
200
- async function main(): Promise<void> {
201
- // Log hook invocation for debugging (writes to stderr so it doesn't affect JSON output)
202
- const hookName = process.argv[2];
203
- const timestamp = new Date().toISOString();
204
- console.error(`[run-hook] ${timestamp} - Hook invoked: ${hookName || 'none'}`);
205
-
206
- // Clean up deprecated files on every hook run
207
- cleanupDeprecatedFiles();
208
-
209
- if (!hookName) {
210
- console.error('[run-hook] Usage: bun run-hook.ts <hook-name>');
211
- process.exit(1);
212
- }
213
-
214
- // Read stdin with timeout to avoid hanging
215
- const stdinData = await readStdinWithTimeout(2000);
216
- console.error(`[run-hook] ${hookName} - stdin received, length: ${stdinData.length}`);
217
- await runHook(hookName, stdinData);
218
- }
219
-
220
- main().catch((err) => {
221
- console.error('[run-hook] Fatal error:', err);
222
- // Return safe default on error
223
- const safeDefault = JSON.stringify({
224
- decision: 'approve',
225
- continue: true,
226
- reason: 'Hook runner error, allowing by default',
227
- });
228
- process.stdout.write(safeDefault);
229
- process.exit(0);
230
- });
@@ -1,202 +0,0 @@
1
- /**
2
- * Hook de Seguranca Pre-Tool
3
- *
4
- * Este hook e executado ANTES de qualquer ferramenta ser chamada.
5
- * Sua funcao e bloquear acoes potencialmente perigosas.
6
- *
7
- * Baseado em: OpenSSF Security Guide for AI Code Assistants
8
- * https://best.openssf.org/Security-Focused-Guide-for-AI-Code-Assistant-Instructions
9
- */
10
-
11
- // Padroes perigosos que devem ser bloqueados
12
- const DANGEROUS_PATTERNS = {
13
- // Comandos destrutivos
14
- commands: [
15
- /rm\s+-rf\s+[\/~]/i, // rm -rf com path perigoso
16
- /rm\s+-rf\s+\*/i, // rm -rf *
17
- /sudo\s+rm/i, // sudo rm
18
- /mkfs/i, // formatar disco
19
- /dd\s+if=/i, // dd (pode destruir dados)
20
- />\s*\/dev\//i, // escrever em devices
21
- /chmod\s+777/i, // permissoes muito abertas
22
- /curl.*\|\s*(ba)?sh/i, // curl pipe to shell
23
- /wget.*\|\s*(ba)?sh/i, // wget pipe to shell
24
- ],
25
-
26
- // Padroes de codigo inseguro
27
- code: [
28
- /eval\s*\(/i, // eval()
29
- /new\s+Function\s*\(/i, // new Function()
30
- /innerHTML\s*=/i, // innerHTML assignment (XSS)
31
- /document\.write\s*\(/i, // document.write (XSS)
32
- /dangerouslySetInnerHTML/i, // React dangerous prop
33
- /\$\{.*\}\s*\)/i, // Template injection em queries
34
- ],
35
-
36
- // Exposicao de dados sensiveis
37
- sensitive: [
38
- /password\s*[:=]/i, // Senha hardcoded
39
- /api[_-]?key\s*[:=]/i, // API key hardcoded
40
- /secret\s*[:=]/i, // Secret hardcoded
41
- /private[_-]?key/i, // Private key
42
- /BEGIN\s+(RSA|DSA|EC)\s+PRIVATE/i, // Chave privada PEM
43
- ],
44
-
45
- // Patterns especificos do projeto
46
- project: [
47
- /userId.*req\.body/i, // userId do request body
48
- /userId.*input\./i, // userId do input tRPC
49
- /findById\(.*input/i, // Query sem validacao de owner
50
- /z\.any\(\)/i, // Zod any (sem validacao)
51
- ],
52
- };
53
-
54
- // Arquivos que nao devem ser modificados
55
- const PROTECTED_FILES = ['.env', '.env.local', '.env.production', '.env.development', 'bun.lockb'];
56
-
57
- // Diretorios que nao devem ser acessados
58
- const PROTECTED_DIRS = ['/etc', '/var', '/usr', '/root', '/home', 'node_modules', '.git/objects'];
59
-
60
- /**
61
- * Verifica se um comando/codigo contem padroes perigosos
62
- * @param {string} content - Conteudo a verificar
63
- * @param {string} category - Categoria de padroes
64
- * @returns {Object} - { blocked: boolean, reason: string }
65
- */
66
- function checkDangerousPatterns(content, category) {
67
- const patterns = DANGEROUS_PATTERNS[category] || [];
68
-
69
- for (const pattern of patterns) {
70
- if (pattern.test(content)) {
71
- return {
72
- blocked: true,
73
- reason: `Padrao perigoso detectado: ${pattern.toString()}`,
74
- category,
75
- };
76
- }
77
- }
78
-
79
- return { blocked: false };
80
- }
81
-
82
- /**
83
- * Verifica se um arquivo e protegido
84
- * @param {string} filePath - Caminho do arquivo
85
- * @returns {boolean}
86
- */
87
- function isProtectedFile(filePath) {
88
- return PROTECTED_FILES.some(
89
- (protected) => filePath.endsWith(protected) || filePath.includes(protected)
90
- );
91
- }
92
-
93
- /**
94
- * Verifica se um diretorio e protegido
95
- * @param {string} dirPath - Caminho do diretorio
96
- * @returns {boolean}
97
- */
98
- function isProtectedDir(dirPath) {
99
- return PROTECTED_DIRS.some(
100
- (protected) => dirPath.startsWith(protected) || dirPath.includes(protected)
101
- );
102
- }
103
-
104
- /**
105
- * Hook principal - executado antes de cada tool call
106
- * @param {Object} toolCall - Dados da chamada de ferramenta
107
- * @returns {Object} - { allowed: boolean, reason?: string }
108
- */
109
- function preToolHook(toolCall) {
110
- const { name, args } = toolCall;
111
-
112
- // Verificar comandos bash
113
- if (name === 'bash' && args.command) {
114
- const result = checkDangerousPatterns(args.command, 'commands');
115
- if (result.blocked) {
116
- return {
117
- allowed: false,
118
- reason: `Comando bloqueado: ${result.reason}`,
119
- };
120
- }
121
- }
122
-
123
- // Verificar escrita de arquivos
124
- if (['file_write', 'file_edit'].includes(name)) {
125
- // Verificar arquivo protegido
126
- if (args.path && isProtectedFile(args.path)) {
127
- return {
128
- allowed: false,
129
- reason: `Arquivo protegido: ${args.path}`,
130
- };
131
- }
132
-
133
- // Verificar conteudo perigoso
134
- if (args.content) {
135
- const codeResult = checkDangerousPatterns(args.content, 'code');
136
- if (codeResult.blocked) {
137
- return {
138
- allowed: false,
139
- reason: `Codigo inseguro: ${codeResult.reason}`,
140
- };
141
- }
142
-
143
- const sensitiveResult = checkDangerousPatterns(args.content, 'sensitive');
144
- if (sensitiveResult.blocked) {
145
- return {
146
- allowed: false,
147
- reason: `Dados sensiveis detectados: ${sensitiveResult.reason}`,
148
- };
149
- }
150
-
151
- const projectResult = checkDangerousPatterns(args.content, 'project');
152
- if (projectResult.blocked) {
153
- return {
154
- allowed: false,
155
- reason: `Violacao de regra do projeto: ${projectResult.reason}`,
156
- };
157
- }
158
- }
159
- }
160
-
161
- // Verificar leitura de diretorios protegidos
162
- if (name === 'file_read' && args.path) {
163
- if (isProtectedDir(args.path)) {
164
- return {
165
- allowed: false,
166
- reason: `Diretorio protegido: ${args.path}`,
167
- };
168
- }
169
- }
170
-
171
- // Permitir por padrao
172
- return { allowed: true };
173
- }
174
-
175
- /**
176
- * Log de seguranca para auditoria
177
- * @param {string} action - Acao tomada
178
- * @param {Object} details - Detalhes
179
- */
180
- function logSecurityEvent(action, details) {
181
- const timestamp = new Date().toISOString();
182
- const logEntry = {
183
- timestamp,
184
- action,
185
- ...details,
186
- };
187
-
188
- // Em producao, enviar para sistema de logging
189
- console.log('[SECURITY]', JSON.stringify(logEntry));
190
- }
191
-
192
- // Exportar para uso pelo SDK
193
- module.exports = {
194
- preToolHook,
195
- checkDangerousPatterns,
196
- isProtectedFile,
197
- isProtectedDir,
198
- logSecurityEvent,
199
- DANGEROUS_PATTERNS,
200
- PROTECTED_FILES,
201
- PROTECTED_DIRS,
202
- };