mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 09:04:29 +00:00
Rename Foundry handoffs to tasks (#239)
* Restore foundry onboarding stack * Consolidate foundry rename * Create foundry tasks without prompts * Rename Foundry handoffs to tasks
This commit is contained in:
parent
d30cc0bcc8
commit
d75e8c31d1
281 changed files with 9242 additions and 4356 deletions
41
foundry/packages/cli/src/task-editor.ts
Normal file
41
foundry/packages/cli/src/task-editor.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
const DEFAULT_EDITOR_TEMPLATE = ["# Enter task task details below.", "# Lines starting with # are ignored.", ""].join("\n");
|
||||
|
||||
export function sanitizeEditorTask(input: string): string {
|
||||
return input
|
||||
.split(/\r?\n/)
|
||||
.filter((line) => !line.trim().startsWith("#"))
|
||||
.join("\n")
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function openEditorForTask(): string {
|
||||
const editor = process.env.VISUAL?.trim() || process.env.EDITOR?.trim() || "vi";
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "hf-task-"));
|
||||
const taskPath = join(tempDir, "task.md");
|
||||
|
||||
try {
|
||||
writeFileSync(taskPath, DEFAULT_EDITOR_TEMPLATE, "utf8");
|
||||
const result = spawnSync(editor, [taskPath], { stdio: "inherit" });
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
if ((result.status ?? 1) !== 0) {
|
||||
throw new Error(`Editor exited with status ${result.status ?? "unknown"}`);
|
||||
}
|
||||
|
||||
const raw = readFileSync(taskPath, "utf8");
|
||||
const task = sanitizeEditorTask(raw);
|
||||
if (!task) {
|
||||
throw new Error("Missing task task text");
|
||||
}
|
||||
return task;
|
||||
} finally {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue