feat: add project context model

This commit is contained in:
zenchantlive 2026-02-11 19:44:47 -08:00
parent 0e3815ac3c
commit 0b127b5404
4 changed files with 54 additions and 1 deletions

View file

@ -0,0 +1,25 @@
import path from 'node:path';
import { canonicalizeWindowsPath, toDisplayPath, windowsPathKey } from './pathing';
import type { ProjectContext, ProjectSource } from './types';
interface BuildProjectContextOptions {
source?: ProjectSource;
addedAt?: string | null;
}
export function buildProjectContext(root: string, options: BuildProjectContextOptions = {}): ProjectContext {
if (!root) {
throw new Error('Project root is required to build project context.');
}
const normalizedRoot = canonicalizeWindowsPath(root);
return {
key: windowsPathKey(normalizedRoot),
root: normalizedRoot,
displayPath: toDisplayPath(normalizedRoot),
name: path.basename(normalizedRoot),
source: options.source ?? 'local',
addedAt: options.addedAt ?? null,
};
}

View file

@ -59,3 +59,16 @@ export interface ParseableBeadIssue extends Partial<BeadIssue> {
id: string;
title: string;
}
export type ProjectSource = 'local' | 'registry' | 'scanner';
export interface ProjectContext {
key: string;
root: string;
displayPath: string;
name: string;
source: ProjectSource;
addedAt: string | null;
}
export type BeadIssueWithProject = BeadIssue & { project: ProjectContext };