import { beforeEach, describe, expect, it, vi } from "vitest" ;
import type { OpenClawConfig } from "../config/config.js" ;
const note = vi.hoisted(() => vi.fn());
const resolveAgentWorkspaceDir = vi.hoisted(() => vi.fn(() => "/tmp/workspace" ));
const resolveDefaultAgentId = vi.hoisted(() => vi.fn(() => "main" ));
const resolveBootstrapContextForRun = vi.hoisted(() => vi.fn());
const resolveBootstrapMaxChars = vi.hoisted(() => vi.fn(() => 20 _000 ));
const resolveBootstrapTotalMaxChars = vi.hoisted(() => vi.fn(() => 150 _000 ));
vi.mock("../terminal/note.js" , () => ({
note,
}));
vi.mock("../agents/agent-scope.js" , () => ({
resolveAgentWorkspaceDir,
resolveDefaultAgentId,
}));
vi.mock("../agents/bootstrap-files.js" , () => ({
resolveBootstrapContextForRun,
}));
vi.mock("../agents/pi-embedded-helpers.js" , () => ({
resolveBootstrapMaxChars,
resolveBootstrapTotalMaxChars,
}));
import { noteBootstrapFileSize } from "./doctor-bootstrap-size.js" ;
describe("noteBootstrapFileSize" , () => {
beforeEach(() => {
note.mockClear();
resolveBootstrapContextForRun.mockReset();
resolveBootstrapContextForRun.mockResolvedValue({
bootstrapFiles: [],
contextFiles: [],
});
});
it("emits a warning when bootstrap files are truncated" , async () => {
resolveBootstrapContextForRun.mockResolvedValue({
bootstrapFiles: [
{
name: "AGENTS.md" ,
path: "/tmp/workspace/AGENTS.md" ,
content: "a" .repeat(25 _000 ),
missing: false ,
},
],
contextFiles: [{ path: "/tmp/workspace/AGENTS.md" , content: "a" .repeat(20 _000 ) }],
});
await noteBootstrapFileSize({} as OpenClawConfig);
expect(note).toHaveBeenCalledTimes(1 );
const [message, title] = note.mock.calls[0 ] ?? [];
expect(String(title)).toBe("Bootstrap file size" );
expect(String(message)).toContain("will be truncated" );
expect(String(message)).toContain("AGENTS.md" );
expect(String(message)).toContain("max/file" );
});
it("stays silent when files are comfortably within limits" , async () => {
resolveBootstrapContextForRun.mockResolvedValue({
bootstrapFiles: [
{
name: "AGENTS.md" ,
path: "/tmp/workspace/AGENTS.md" ,
content: "a" .repeat(1 _000 ),
missing: false ,
},
],
contextFiles: [{ path: "/tmp/workspace/AGENTS.md" , content: "a" .repeat(1 _000 ) }],
});
await noteBootstrapFileSize({} as OpenClawConfig);
expect(note).not.toHaveBeenCalled();
});
});
Messung V0.5 in Prozent C=95 H=97 G=95
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland