mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 06:33:15 +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
92
openclaw/test/scripts/check-dynamic-import-warts.test.ts
Normal file
92
openclaw/test/scripts/check-dynamic-import-warts.test.ts
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { findDynamicImportAdvisories } from "../../scripts/check-dynamic-import-warts.mjs";
|
||||
|
||||
describe("check-dynamic-import-warts", () => {
|
||||
it("flags runtime static plus dynamic imports of the same module", () => {
|
||||
const source = `
|
||||
import { run } from "./runtime.js";
|
||||
export async function start() {
|
||||
return await import("./runtime.js");
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([
|
||||
{
|
||||
line: 4,
|
||||
reason: 'runtime static + dynamic import of "./runtime.js" (static line 2)',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("ignores type-only static imports", () => {
|
||||
const source = `
|
||||
import { type Runtime } from "./runtime.js";
|
||||
export async function start(): Promise<Runtime> {
|
||||
return (await import("./runtime.js")).createRuntime();
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([]);
|
||||
});
|
||||
|
||||
it("flags repeated direct dynamic imports", () => {
|
||||
const source = `
|
||||
export async function one() {
|
||||
return await import("./runtime.js");
|
||||
}
|
||||
export async function two() {
|
||||
return await import("./runtime.js");
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([
|
||||
{
|
||||
line: 3,
|
||||
reason: 'repeated direct dynamic import of "./runtime.js" (2 callsites: 3, 6)',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("ignores cached loader patterns", () => {
|
||||
const source = `
|
||||
let runtimePromise: Promise<typeof import("./runtime.js")> | undefined;
|
||||
function loadRuntime() {
|
||||
runtimePromise ??= import("./runtime.js");
|
||||
return runtimePromise;
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([]);
|
||||
});
|
||||
|
||||
it("flags direct dynamic imports inside execute paths", () => {
|
||||
const source = `
|
||||
export function createTool() {
|
||||
return {
|
||||
execute: async () => {
|
||||
return await import("./runtime.js");
|
||||
},
|
||||
};
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([
|
||||
{
|
||||
line: 5,
|
||||
reason:
|
||||
'direct dynamic import of "./runtime.js" inside execute path; move it behind a cached loader',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("allows execute paths that call cached loaders", () => {
|
||||
const source = `
|
||||
let runtimePromise: Promise<typeof import("./runtime.js")> | undefined;
|
||||
function loadRuntime() {
|
||||
runtimePromise ??= import("./runtime.js");
|
||||
return runtimePromise;
|
||||
}
|
||||
export function createTool() {
|
||||
return {
|
||||
execute: async () => await loadRuntime(),
|
||||
};
|
||||
}
|
||||
`;
|
||||
expect(findDynamicImportAdvisories(source)).toEqual([]);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue