Merge branch 'main' into feat/sync-nodeloc-v1.2.0
Combines the oversized-prompt instructions-file fix from main with the fork's cleanup and redaction hardening: agent container, workspace permissions, proxy, and prompt temp directory all clean up without aborting each other.
This commit is contained in:
commit
a5108b2c36
2 files changed
+111
-7
No files matched your search
+42
-1
@@ -1,4 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import {
|
||||
buildGooseAgentDockerArgs,
|
||||
@@ -6,7 +9,9 @@ import {
|
||||
buildIsolatedWorkspaceCommandDockerArgs,
|
||||
buildWorkspacePermissionDockerArgs,
|
||||
extractGooseFinalText,
|
||||
redactProcessArgs
|
||||
MAX_PROMPT_ARG_BYTES,
|
||||
redactProcessArgs,
|
||||
resolveGooseInputArgs
|
||||
} from "../src/ai/gooseCli.js";
|
||||
|
||||
test("goose agent mounts the workflow binary read-only and keeps a visible install fallback", () => {
|
||||
@@ -31,6 +36,42 @@ test("goose agent mounts the workflow binary read-only and keeps a visible insta
|
||||
assert.equal(args.at(-1), "introduce this pull request");
|
||||
});
|
||||
|
||||
test("oversized prompts switch from --text to an instructions file", async () => {
|
||||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "goose-input-"));
|
||||
try {
|
||||
const small = await resolveGooseInputArgs("tiny prompt", tempDir);
|
||||
assert.deepEqual(small, ["--text", "tiny prompt"]);
|
||||
|
||||
const oversized = "x".repeat(MAX_PROMPT_ARG_BYTES + 1);
|
||||
const args = await resolveGooseInputArgs(oversized, tempDir);
|
||||
assert.equal(args[0], "--instructions");
|
||||
assert.match(args[1]!, /goose-prompt\.md$/);
|
||||
assert.equal(await fs.readFile(args[1]!, "utf8"), oversized);
|
||||
} finally {
|
||||
await fs.rm(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("docker agent mounts the instructions file instead of passing prompt text", () => {
|
||||
const args = buildGooseAgentDockerArgs({
|
||||
containerName: "ghbot-agent-test",
|
||||
realWorkingDirectory: "/tmp/worktree",
|
||||
containerEnv: {},
|
||||
prompt: "oversized prompt body",
|
||||
hostInstructionsFile: "/tmp/goose-agent-x/goose-prompt.md"
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
args.includes(
|
||||
"type=bind,source=/tmp/goose-agent-x/goose-prompt.md,target=/prompt/goose-prompt.md,readonly"
|
||||
)
|
||||
);
|
||||
const instructionsIndex = args.indexOf("--instructions");
|
||||
assert.ok(instructionsIndex > 0);
|
||||
assert.equal(args[instructionsIndex + 1], "/prompt/goose-prompt.md");
|
||||
assert.equal(args.includes("--text"), false);
|
||||
});
|
||||
|
||||
test("isolated validation receives the repository but no model or GitHub credentials", () => {
|
||||
const args = buildIsolatedWorkspaceCommandDockerArgs({
|
||||
containerName: "ghbot-validation-test",
|
||||
|
||||
Reference in new issue
Block a user