Add /gori-output command for session-scoped output directory
This commit is contained in:
@@ -166,8 +166,11 @@ async function runVideoJob(requestId: string): Promise<VideoJobResult> {
|
|||||||
// File helpers
|
// File helpers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Session-scoped output directory override (set via /gori-output)
|
||||||
|
let sessionOutputDir: string | undefined;
|
||||||
|
|
||||||
function outputDir(cwd: string): string {
|
function outputDir(cwd: string): string {
|
||||||
const dir = process.env.GORITECHES_OUTPUT_DIR ?? path.join(cwd, "goritech-media");
|
const dir = sessionOutputDir ?? process.env.GORITECHES_OUTPUT_DIR ?? path.join(cwd, "goritech-media");
|
||||||
fs.mkdirSync(dir, { recursive: true });
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
@@ -503,6 +506,34 @@ export default function goritechMedia(pi: ExtensionAPI) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// /gori-output [dir]: set or show output directory for this session
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
pi.registerCommand("gori-output", {
|
||||||
|
description: "Set or show output directory (usage: /gori-output [dir], empty to reset, no args to show)",
|
||||||
|
handler: async (args, ctx) => {
|
||||||
|
const dir = args.trim();
|
||||||
|
if (!dir) {
|
||||||
|
const current = sessionOutputDir ?? process.env.GORITECHES_OUTPUT_DIR ?? path.join(ctx.cwd ?? process.cwd(), "goritech-media");
|
||||||
|
ctx.ui.notify(`Output dir: ${current}${sessionOutputDir ? " (session override)" : ""}\nUsage: /gori-output <dir> to set, /gori-output reset to clear`, "info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dir === "reset") {
|
||||||
|
sessionOutputDir = undefined;
|
||||||
|
ctx.ui.notify("Output dir reset to default (<cwd>/goritech-media or GORITECHES_OUTPUT_DIR env)", "info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const abs = path.resolve(ctx.cwd ?? process.cwd(), dir);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(abs, { recursive: true });
|
||||||
|
sessionOutputDir = abs;
|
||||||
|
ctx.ui.notify(`Output dir set to: ${abs} (this session only)`, "info");
|
||||||
|
} catch (err: any) {
|
||||||
|
ctx.ui.notify(`Failed to set output dir: ${err?.message ?? err}`, "error");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// /gori-media command: quick smoke test + usage
|
// /gori-media command: quick smoke test + usage
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@@ -526,9 +557,10 @@ export default function goritechMedia(pi: ExtensionAPI) {
|
|||||||
`API key: ${keySource}`,
|
`API key: ${keySource}`,
|
||||||
`Image model: ${IMAGE_MODEL}`,
|
`Image model: ${IMAGE_MODEL}`,
|
||||||
`Video model: ${VIDEO_MODEL}`,
|
`Video model: ${VIDEO_MODEL}`,
|
||||||
`Output dir: ${process.env.GORITECHES_OUTPUT_DIR ?? "<cwd>/goritech-media"}`,
|
`Output dir: ${sessionOutputDir ?? process.env.GORITECHES_OUTPUT_DIR ?? "<cwd>/goritech-media"}${sessionOutputDir ? " (session)" : ""}`,
|
||||||
``,
|
``,
|
||||||
`Tools: generate_image, edit_image, generate_video (model-callable)`,
|
`Tools: generate_image, edit_image, generate_video (model-callable)`,
|
||||||
|
`Commands: /gori-output [dir], /gori-fetch <id>, /gori-media`,
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
"info",
|
"info",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user