Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+36 -14
View File
@@ -6,18 +6,40 @@ import { vi } from 'vitest';
export async function mockAgentFiles() {
const backend = await import('../../src/lib/server/backends/native.js');
const { serverDir } = await import('../../src/lib/server/config.js');
return vi.spyOn(backend, 'nativeRequest').mockImplementation(async (instance, kind, payload = {}) => {
const path = join(serverDir(instance.server), String(payload.path ?? '.'));
let result: unknown;
if (kind === 'files.read') {
const content = await fs.readFile(path).catch((error: NodeJS.ErrnoException) => { if (error.code === 'ENOENT') return null; throw error; });
result = { contentBase64: content?.toString('base64') ?? null };
} else if (kind === 'files.stat') {
const stat = await fs.stat(path).catch((error: NodeJS.ErrnoException) => { if (error.code === 'ENOENT') return null; throw error; });
result = stat ? { exists: true, size: stat.size, mtime: stat.mtime.toISOString(), isDirectory: stat.isDirectory(), isFile: stat.isFile() } : null;
} else if (kind === 'files.list') {
result = { entries: (await fs.readdir(path, { withFileTypes: true })).map(entry => ({ name: entry.name, isDirectory: entry.isDirectory(), isFile: entry.isFile() })) };
} else throw new Error(`Unexpected agent command: ${kind}`);
return result as never;
});
return vi
.spyOn(backend, 'nativeRequest')
.mockImplementation(async (instance, kind, payload = {}) => {
const path = join(serverDir(instance.server), String(payload.path ?? '.'));
let result: unknown;
if (kind === 'files.read') {
const content = await fs.readFile(path).catch((error: NodeJS.ErrnoException) => {
if (error.code === 'ENOENT') return null;
throw error;
});
result = { contentBase64: content?.toString('base64') ?? null };
} else if (kind === 'files.stat') {
const stat = await fs.stat(path).catch((error: NodeJS.ErrnoException) => {
if (error.code === 'ENOENT') return null;
throw error;
});
result = stat
? {
exists: true,
size: stat.size,
mtime: stat.mtime.toISOString(),
isDirectory: stat.isDirectory(),
isFile: stat.isFile()
}
: null;
} else if (kind === 'files.list') {
result = {
entries: (await fs.readdir(path, { withFileTypes: true })).map((entry) => ({
name: entry.name,
isDirectory: entry.isDirectory(),
isFile: entry.isFile()
}))
};
} else throw new Error(`Unexpected agent command: ${kind}`);
return result as never;
});
}