mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 385dcbd8a9
Co-authored-by: Swader <1430603+Swader@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { WorkspaceBootstrapFile } from "./workspace.js";
|
|
import { buildSystemPromptReport } from "./system-prompt-report.js";
|
|
|
|
function makeBootstrapFile(overrides: Partial<WorkspaceBootstrapFile>): WorkspaceBootstrapFile {
|
|
return {
|
|
name: "AGENTS.md",
|
|
path: "/tmp/workspace/AGENTS.md",
|
|
content: "alpha",
|
|
missing: false,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe("buildSystemPromptReport", () => {
|
|
it("counts injected chars when injected file paths are absolute", () => {
|
|
const file = makeBootstrapFile({ path: "/tmp/workspace/policies/AGENTS.md" });
|
|
const report = buildSystemPromptReport({
|
|
source: "run",
|
|
generatedAt: 0,
|
|
bootstrapMaxChars: 20_000,
|
|
systemPrompt: "system",
|
|
bootstrapFiles: [file],
|
|
injectedFiles: [{ path: "/tmp/workspace/policies/AGENTS.md", content: "trimmed" }],
|
|
skillsPrompt: "",
|
|
tools: [],
|
|
});
|
|
|
|
expect(report.injectedWorkspaceFiles[0]?.injectedChars).toBe("trimmed".length);
|
|
});
|
|
|
|
it("keeps legacy basename matching for injected files", () => {
|
|
const file = makeBootstrapFile({ path: "/tmp/workspace/policies/AGENTS.md" });
|
|
const report = buildSystemPromptReport({
|
|
source: "run",
|
|
generatedAt: 0,
|
|
bootstrapMaxChars: 20_000,
|
|
systemPrompt: "system",
|
|
bootstrapFiles: [file],
|
|
injectedFiles: [{ path: "AGENTS.md", content: "trimmed" }],
|
|
skillsPrompt: "",
|
|
tools: [],
|
|
});
|
|
|
|
expect(report.injectedWorkspaceFiles[0]?.injectedChars).toBe("trimmed".length);
|
|
});
|
|
});
|