fix(coding-teacher): restore context and read project files
This commit is contained in:
@@ -207,6 +207,24 @@ export class CodingProjectFileService {
|
||||
private readonly git: ConversationGitAdapter = new ProcessConversationGitAdapter(),
|
||||
) {}
|
||||
|
||||
async directory(projectPath: string, requestedPath = '.'): Promise<Array<{
|
||||
path: string; name: string; type: 'file' | 'directory';
|
||||
}>> {
|
||||
const relativePath = requestedPath === '.' ? '' : normalizeRelativePath(requestedPath);
|
||||
const target = relativePath
|
||||
? await containedExistingTarget(projectPath, relativePath)
|
||||
: await realpath(projectPath);
|
||||
const entries = await readdir(target, { withFileTypes: true });
|
||||
return entries
|
||||
.filter(entry => (entry.isFile() || entry.isDirectory()) && !SKIPPED_DIRECTORIES.has(entry.name))
|
||||
.sort((left, right) => Number(right.isDirectory()) - Number(left.isDirectory()) || left.name.localeCompare(right.name))
|
||||
.map(entry => ({
|
||||
path: relativePath ? relativePath + '/' + entry.name : entry.name,
|
||||
name: entry.name,
|
||||
type: entry.isDirectory() ? 'directory' as const : 'file' as const,
|
||||
}));
|
||||
}
|
||||
|
||||
async status(projectPath: string): Promise<CodingProjectFileEntry[]> {
|
||||
const result = await this.gitResult(projectPath, [
|
||||
'status',
|
||||
|
||||
Reference in New Issue
Block a user