full initial implementation

This commit is contained in:
Shivering Ocelot committed 2026-09-03 23:43:33 -05:00
1 parent 65fc75e509
commit d9d9b7f463
15 files changed
+799 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import fs from 'node:fs';
import path from 'node:path';
export const spec = {
name: 'delete_file',
description: 'Delete a file (or directory) in the space.',
parameters: {
type: 'object',
properties: {
path: { type: 'string', description: 'Path relative to the space directory.' },
},
required: ['path'],
},
};
function resolveIn(base, relPath) {
const resolved = path.resolve(base, relPath);
if (resolved !== base && !resolved.startsWith(base + path.sep)) {
throw new Error('Path escapes the space directory');
}
return resolved;
}
export default async function (args, ctx) {
const file = resolveIn(ctx.dir, args.path);
if (!fs.existsSync(file)) throw new Error(`No such file: ${args.path}`);
fs.rmSync(file, { recursive: true });
return { deleted: args.path };
}