Files
fuck-u-code/bin/fuck-u-code.js
Codex 80002aebea fix: harden security and clean up code quality issues
- git clone now uses execFile (no shell) and rejects URLs with shell metacharacters; removed dead parseRepoName.

- config show masks apiKey; config file chmod 0600 after writing keys.

- CLI launcher reports signal kills as failures and supports FUCK_U_CODE_MAX_MEMORY (default 4096MB).

- File discovery: well-known non-code dirs are defaults, not hard overrides; user-included dirs are analyzed.

- Nested .gitignore loading uses forward slashes so it works on Windows.

- Deduplicated analysis output rendering; fixed fetch timeout cleanup; aligned concurrency default to 8; enabled zh_TW locale end to end.

- Fixed pre-existing lint errors and Windows-flaky MCP tests; added git-utils, secrets, file-discovery tests; release workflow now runs tests.
2026-08-06 12:22:48 -07:00

63 lines
1.5 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const hasMemoryFlag = process.execArgv.some(arg => arg.startsWith('--max-old-space-size'));
if (!hasMemoryFlag) {
const DEFAULT_MEMORY_MB = 4096;
const configuredMemory = Number(process.env.FUCK_U_CODE_MAX_MEMORY);
const memoryMb = Number.isFinite(configuredMemory) && configuredMemory >= 512
? Math.floor(configuredMemory)
: DEFAULT_MEMORY_MB;
const args = [
`--max-old-space-size=${memoryMb}`,
join(__dirname, '..', 'dist', 'index.js'),
...process.argv.slice(2)
];
const child = spawn(process.execPath, args, {
stdio: ['inherit', 'inherit', 'pipe'],
env: process.env
});
let inFatalError = false;
child.stderr.on('data', (data) => {
const text = data.toString();
if (text.includes('Fatal process out of memory') || text.includes('Native stack trace')) {
inFatalError = true;
return;
}
if (inFatalError) {
return;
}
process.stderr.write(data);
});
child.on('exit', (code) => {
if (code === 133 && inFatalError) {
process.exit(0);
} else if (code === null) {
// Killed by a signal (or crashed) must not be reported as success.
process.exit(1);
} else {
process.exit(code);
}
});
child.on('error', () => {
process.exit(1);
});
} else {
import('../dist/index.js');
}