mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-12 23:43:18 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -0,0 +1,97 @@
|
|||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
createPrefixedOutputWriter,
|
||||
isArtifactSetFresh,
|
||||
parseMode,
|
||||
runNodeStepsInParallel,
|
||||
} from "../../scripts/prepare-extension-package-boundary-artifacts.mjs";
|
||||
|
||||
const tempRoots = new Set<string>();
|
||||
|
||||
afterEach(() => {
|
||||
for (const rootDir of tempRoots) {
|
||||
fs.rmSync(rootDir, { force: true, recursive: true });
|
||||
}
|
||||
tempRoots.clear();
|
||||
});
|
||||
|
||||
describe("prepare-extension-package-boundary-artifacts", () => {
|
||||
it("prefixes each completed line and flushes the trailing partial line", () => {
|
||||
let output = "";
|
||||
const writer = createPrefixedOutputWriter("boundary", {
|
||||
write(chunk: string) {
|
||||
output += chunk;
|
||||
},
|
||||
});
|
||||
|
||||
writer.write("first line\nsecond");
|
||||
writer.write(" line\nthird");
|
||||
writer.flush();
|
||||
|
||||
expect(output).toBe("[boundary] first line\n[boundary] second line\n[boundary] third");
|
||||
});
|
||||
|
||||
it("aborts sibling steps after the first failure", async () => {
|
||||
const startedAt = Date.now();
|
||||
const slowStepTimeoutMs = 60_000;
|
||||
const abortBudgetMs = 30_000;
|
||||
|
||||
await expect(
|
||||
runNodeStepsInParallel([
|
||||
{
|
||||
label: "fail-fast",
|
||||
args: ["--eval", "process.exit(2)"],
|
||||
timeoutMs: slowStepTimeoutMs,
|
||||
},
|
||||
{
|
||||
label: "slow-step",
|
||||
args: ["--eval", "setTimeout(() => {}, 60_000)"],
|
||||
timeoutMs: slowStepTimeoutMs,
|
||||
},
|
||||
]),
|
||||
).rejects.toThrow("fail-fast failed with exit code 2");
|
||||
|
||||
expect(Date.now() - startedAt).toBeLessThan(abortBudgetMs);
|
||||
}, 45_000);
|
||||
|
||||
it("treats artifacts as fresh only when outputs are newer than inputs", () => {
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-boundary-prep-"));
|
||||
tempRoots.add(rootDir);
|
||||
const inputPath = path.join(rootDir, "src", "demo.ts");
|
||||
const outputPath = path.join(rootDir, "dist", "demo.tsbuildinfo");
|
||||
fs.mkdirSync(path.dirname(inputPath), { recursive: true });
|
||||
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
||||
fs.writeFileSync(inputPath, "export const demo = 1;\n", "utf8");
|
||||
fs.writeFileSync(outputPath, "ok\n", "utf8");
|
||||
|
||||
fs.utimesSync(inputPath, new Date(1_000), new Date(1_000));
|
||||
fs.utimesSync(outputPath, new Date(2_000), new Date(2_000));
|
||||
|
||||
expect(
|
||||
isArtifactSetFresh({
|
||||
rootDir,
|
||||
inputPaths: ["src"],
|
||||
outputPaths: ["dist/demo.tsbuildinfo"],
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
fs.utimesSync(inputPath, new Date(3_000), new Date(3_000));
|
||||
|
||||
expect(
|
||||
isArtifactSetFresh({
|
||||
rootDir,
|
||||
inputPaths: ["src"],
|
||||
outputPaths: ["dist/demo.tsbuildinfo"],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("parses prep mode and rejects unknown values", () => {
|
||||
expect(parseMode([])).toBe("all");
|
||||
expect(parseMode(["--mode=package-boundary"])).toBe("package-boundary");
|
||||
expect(() => parseMode(["--mode=nope"])).toThrow("Unknown mode: nope");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue