



























@@ -291,6 +291,64 @@ describe("loadPluginRegistrySnapshotWithMetadata", () => {
291291expect(result.diagnostics).toStrictEqual([]);
292292});
293293294+it.runIf(process.platform !== "win32")(
295+"treats persisted package metadata symlinks outside the plugin root as stale",
296+() => {
297+const tempRoot = makeTempDir();
298+const rootDir = path.join(tempRoot, "workspace");
299+const stateDir = path.join(tempRoot, "state");
300+const outsideDir = path.join(tempRoot, "outside");
301+const packageJsonPath = path.join(rootDir, "package.json");
302+const outsidePackageJsonPath = path.join(outsideDir, "package.json");
303+const env = { ...createHermeticEnv(tempRoot), OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" };
304+const config = {
305+plugins: {
306+load: { paths: [rootDir] },
307+},
308+};
309+writePackagePlugin(rootDir);
310+fs.mkdirSync(outsideDir, { recursive: true });
311+fs.rmSync(packageJsonPath);
312+fs.writeFileSync(
313+outsidePackageJsonPath,
314+JSON.stringify({ name: "demo", version: "1.0.0" }),
315+"utf8",
316+);
317+fs.symlinkSync(outsidePackageJsonPath, packageJsonPath);
318+const index = loadInstalledPluginIndex({ config, env });
319+const [plugin] = index.plugins;
320+if (!plugin) {
321+throw new Error("expected test plugin");
322+}
323+writePersistedInstalledPluginIndexSync(
324+{
325+ ...index,
326+plugins: [
327+{
328+ ...plugin,
329+packageJson: {
330+path: "package.json",
331+hash: fileHash(packageJsonPath),
332+fileSignature: fileSignature(packageJsonPath),
333+},
334+},
335+ ...index.plugins.slice(1),
336+],
337+},
338+{ stateDir },
339+);
340+341+const result = loadPluginRegistrySnapshotWithMetadata({
342+ config,
343+ env,
344+ stateDir,
345+});
346+347+expect(result.source).toBe("derived");
348+expectDiagnosticsContainCode(result.diagnostics, "persisted-registry-stale-source");
349+},
350+);
351+294352it("detects same-size same-mtime manifest replacements", () => {
295353const tempRoot = makeTempDir();
296354const rootDir = path.join(tempRoot, "workspace");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。