feat(backend): ThtRunner session mutation + documents methods

This commit is contained in:
2026-06-29 12:29:14 +02:00
parent 03053b0716
commit 4a63db51e8
2 changed files with 61 additions and 0 deletions
+20
View File
@@ -18,6 +18,14 @@ export interface SessionRow {
author: string | null;
}
export interface SessionDocument {
phase: string;
key: string;
title: string;
format: string;
content: string;
}
export class ThtRunner {
constructor(private cfg: ThtConfig) {}
@@ -61,6 +69,11 @@ export class ThtRunner {
return JSON.parse(stdout) as T;
}
private async ok(args: string[]): Promise<void> {
const { code, stderr } = await this.run(args);
if (code !== 0) throw new Error(`tht ${args.join(" ")} exit ${code}: ${stderr.trim()}`);
}
async sessionNew(o: {
question: string;
provider?: string;
@@ -109,4 +122,11 @@ export class ThtRunner {
if (code !== 0) throw new Error(`tht sql export exit ${code}: ${stderr.trim()}`);
return { path: stdout.trim() };
}
setName(id: string, name: string) { return this.ok(["session", "set-name", id, "--name", name]); }
setGroup(id: string, group: string) { return this.ok(["session", "set-group", id, "--group", group]); }
archive(id: string) { return this.ok(["session", "archive", id]); }
unarchive(id: string) { return this.ok(["session", "unarchive", id]); }
deleteSession(id: string) { return this.ok(["session", "delete", id]); }
documents(id: string) { return this.json<SessionDocument[]>(["session", "documents", id, "--json"]); }
}