mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 16:40:47 +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
106
openclaw/test/helpers/plugins/package-manifest-contract.ts
Normal file
106
openclaw/test/helpers/plugins/package-manifest-contract.ts
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isAtLeast, parseSemver } from "../../../src/infra/runtime-guard.js";
|
||||
import { parseMinHostVersionRequirement } from "../../../src/plugins/min-host-version.js";
|
||||
import { bundledPluginFile } from "../bundled-plugin-paths.js";
|
||||
|
||||
type PackageManifest = {
|
||||
dependencies?: Record<string, string>;
|
||||
optionalDependencies?: Record<string, string>;
|
||||
openclaw?: {
|
||||
install?: {
|
||||
minHostVersion?: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type PackageManifestContractParams = {
|
||||
pluginId: string;
|
||||
pluginLocalRuntimeDeps?: string[];
|
||||
mirroredRootRuntimeDeps?: string[];
|
||||
minHostVersionBaseline?: string;
|
||||
};
|
||||
|
||||
// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- Test helper lets assertions ascribe package manifest shape.
|
||||
function readJson<T>(relativePath: string): T {
|
||||
const absolutePath = path.resolve(process.cwd(), relativePath);
|
||||
return JSON.parse(fs.readFileSync(absolutePath, "utf8")) as T;
|
||||
}
|
||||
|
||||
export function describePackageManifestContract(params: PackageManifestContractParams) {
|
||||
const packagePath = bundledPluginFile(params.pluginId, "package.json");
|
||||
|
||||
describe(`${params.pluginId} package manifest contract`, () => {
|
||||
if (params.pluginLocalRuntimeDeps?.length) {
|
||||
for (const dependencyName of params.pluginLocalRuntimeDeps) {
|
||||
it(`keeps ${dependencyName} plugin-local`, () => {
|
||||
const rootManifest = readJson("package.json") as PackageManifest;
|
||||
const pluginManifest = readJson(packagePath) as PackageManifest;
|
||||
const pluginSpec =
|
||||
pluginManifest.dependencies?.[dependencyName] ??
|
||||
pluginManifest.optionalDependencies?.[dependencyName];
|
||||
const rootSpec =
|
||||
rootManifest.dependencies?.[dependencyName] ??
|
||||
rootManifest.optionalDependencies?.[dependencyName];
|
||||
|
||||
expect(pluginSpec).toBeTruthy();
|
||||
expect(rootSpec).toBeUndefined();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (params.mirroredRootRuntimeDeps?.length) {
|
||||
for (const dependencyName of params.mirroredRootRuntimeDeps) {
|
||||
it(`mirrors ${dependencyName} at the root package`, () => {
|
||||
const rootManifest = readJson<PackageManifest>("package.json");
|
||||
const pluginManifest = readJson<PackageManifest>(packagePath);
|
||||
const pluginSpec =
|
||||
pluginManifest.dependencies?.[dependencyName] ??
|
||||
pluginManifest.optionalDependencies?.[dependencyName];
|
||||
const rootSpec =
|
||||
rootManifest.dependencies?.[dependencyName] ??
|
||||
rootManifest.optionalDependencies?.[dependencyName];
|
||||
|
||||
expect(pluginSpec).toBeTruthy();
|
||||
expect(rootSpec).toBe(pluginSpec);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const minHostVersionBaseline = params.minHostVersionBaseline;
|
||||
if (minHostVersionBaseline) {
|
||||
it("declares a parseable minHostVersion floor at or above the baseline", () => {
|
||||
const baseline = parseSemver(minHostVersionBaseline);
|
||||
expect(baseline).not.toBeNull();
|
||||
if (!baseline) {
|
||||
return;
|
||||
}
|
||||
|
||||
const manifest = readJson<PackageManifest>(packagePath);
|
||||
const requirement = parseMinHostVersionRequirement(
|
||||
manifest.openclaw?.install?.minHostVersion ?? null,
|
||||
);
|
||||
|
||||
expect(
|
||||
requirement,
|
||||
`${packagePath} should declare openclaw.install.minHostVersion`,
|
||||
).not.toBeNull();
|
||||
if (!requirement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const minimum = parseSemver(requirement.minimumLabel);
|
||||
expect(minimum, `${packagePath} should use a parseable semver floor`).not.toBeNull();
|
||||
if (!minimum) {
|
||||
return;
|
||||
}
|
||||
|
||||
expect(
|
||||
isAtLeast(minimum, baseline),
|
||||
`${packagePath} should require at least OpenClaw ${minHostVersionBaseline}`,
|
||||
).toBe(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue