INNER CODE UNIT · TypeScript

isSafePromptsDir

ZaxbyHub/opencode-swarm · src/cli/index.ts:254

export function isSafePromptsDir(p: string, configuredDir?: string): boolean {
	const canonical = safeRealpathSync(p, p);
	if (canonical === null) {
		return false;
	}
	const resolved = path.resolve(canonical);
	const home = path.resolve(os.homedir());
	if (resolved === '/' || resolved === home || resolved.length <= home.length) {
		return false;
	}
	if (segmentDepthBelowRoot(resolved) < 3) {
		return false;
	}
	if (path.basename(resolved) !== 'opencode-swarm') {
		return false;
	}
	if (!hasSafeConfigArtifactParent(resolved, configuredDir)) {
		return false;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…