← back to liminal-hq__smdu

Function bodies 6 total

All specs Real LLM only Function bodies
isEffectivelyHidden function · typescript · L112-L122 (11 LOC)
src/review/derive.ts
export function isEffectivelyHidden(node: FileNode): boolean {
	if (node.isHidden) return true;

	let current = node.parent;
	while (current) {
		if (current.isHidden) return true;
		current = current.parent;
	}

	return false;
}
inferReviewType function · typescript · L128-L135 (8 LOC)
src/review/derive.ts
export function inferReviewType(node: FileNode): string {
	if (node.isDirectory) return 'directory';
	const category = getFileTypeCategory(node.name, false);
	if (category) return category;
	const extension = getExtension(node.name);
	if (!extension) return 'file';
	return extension.slice(1);
}
getAgeBucket function · typescript · L137-L154 (18 LOC)
src/review/derive.ts
export function getAgeBucket(date: Date | undefined, now: Date): ReviewAgeBucket | undefined {
	if (!date || Number.isNaN(date.getTime())) return undefined;

	const oneDayAgo = addDays(now, -1);
	const sevenDaysAgo = addDays(now, -7);
	const oneMonthAgo = addMonths(now, -1);
	const threeMonthsAgo = addMonths(now, -3);
	const sixMonthsAgo = addMonths(now, -6);
	const oneYearAgo = addYears(now, -1);

	if (date >= oneDayAgo) return 'today';
	if (date >= sevenDaysAgo) return 'week';
	if (date >= oneMonthAgo) return 'month';
	if (date >= threeMonthsAgo) return 'older-1m';
	if (date >= sixMonthsAgo) return 'older-3m';
	if (date >= oneYearAgo) return 'older-6m';
	return 'older-1y';
}
createReviewEntry function · typescript · L156-L204 (49 LOC)
src/review/derive.ts
export function createReviewEntry(
	node: FileNode,
	root: FileNode,
	sourceRoot: string,
	options?: Partial<CreateReviewEntryOptions>,
): ReviewEntry {
	const now = options?.now ?? new Date();
	const depthFromRoot = options?.depthFromRoot ?? 0;
	const hiddenByAncestry = options?.hiddenByAncestry ?? false;
	const directoryCountMap =
		options?.directoryCountMap ??
		new Map<FileNode, { fileCount: number; directoryCount: number }>();

	const counts =
		directoryCountMap.get(node) ??
		(node.isDirectory
			? countDirectoryDescendants(node)
			: {
					fileCount: 1,
					directoryCount: 0,
				});

	const effectiveHidden = node.isHidden || hiddenByAncestry;
	const modifiedAt = node.mtime;
	const createdAt = node.birthtime;

	return {
		id: node.path,
		node,
		path: node.path,
		parentPath: node.parent?.path ?? path.dirname(node.path),
		basename: node.name,
		kind: node.isDirectory ? 'directory' : 'file',
		size: node.size,
		percentOfRoot: root.size > 0 ? (node.size / root.size) * 100 :
deriveReviewEntries function · typescript · L206-L258 (53 LOC)
src/review/derive.ts
export function deriveReviewEntries(
	root: FileNode,
	options: DeriveReviewOptions = {},
): ReviewEntry[] {
	const now = options.now ?? new Date();
	const sourceRoot = options.sourceRoot ?? root.path;
	const includeRoot = options.includeRoot ?? false;
	const entries: ReviewEntry[] = [];
	const directoryCountMap = buildDirectoryCountMap(root);

	type StackItem = {
		node: FileNode;
		depthFromRoot: number;
		hiddenByAncestry: boolean;
	};

	const stack: StackItem[] = [];

	if (includeRoot) {
		stack.push({ node: root, depthFromRoot: 0, hiddenByAncestry: false });
	} else {
		const children = root.children ?? [];
		for (let i = children.length - 1; i >= 0; i -= 1) {
			stack.push({ node: children[i], depthFromRoot: 1, hiddenByAncestry: false });
		}
	}

	while (stack.length > 0) {
		const current = stack.pop();
		if (!current) continue;

		entries.push(
			createReviewEntry(current.node, root, sourceRoot, {
				now,
				depthFromRoot: current.depthFromRoot,
				hiddenByAncestry: current
scanDirectory function · typescript · L217-L226 (10 LOC)
src/scanner.ts
export async function scanDirectory(
	dirPath: string,
	parent?: FileNode,
	onProgress?: ScanProgressCallback,
	progress?: ScanProgress,
	signal?: AbortSignal,
	onPartial?: ScanPartialCallback,
): Promise<FileNode> {
	return scanDirectoryInternal(dirPath, parent, onProgress, progress, signal, onPartial);
}