feat: add prompt history plugin Host prerequisites (#3588)

Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
This commit is contained in:
Clément Fiere
2026-09-15 20:05:40 +02:00
committed by GitHub
parent 186e354116
commit 2b1d0cf7d1
184 changed files with 21016 additions and 661 deletions
+26
View File
@@ -0,0 +1,26 @@
import { createHash } from "node:crypto";
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
import path from "node:path";
import process from "node:process";
const argumentIndex = process.argv.indexOf("--outDir");
if (argumentIndex === -1 || !process.argv[argumentIndex + 1]) {
throw new Error("build:e2e-plugin requires --outDir");
}
const source = path.resolve("e2e/fixtures/plugins/prompt-history-plugin/bundle.js");
const outputDirectory = path.resolve(process.argv[argumentIndex + 1]);
const output = path.join(outputDirectory, "bundle.js");
const content = await readFile(source);
const sourceHash = createHash("sha256").update(content).digest("hex");
await rm(outputDirectory, { recursive: true, force: true });
await mkdir(outputDirectory, { recursive: true });
await writeFile(output, content);
const generated = await readFile(output);
const generatedHash = createHash("sha256").update(generated).digest("hex");
if (generatedHash !== sourceHash) {
throw new Error("build:e2e-plugin generated stale output");
}
console.log(`[build:e2e-plugin] ${sourceHash} -> ${output}`);
@@ -0,0 +1,46 @@
import { createHash } from "node:crypto";
import { readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import process from "node:process";
const [sourcePath, generatedPath, manifestPath, archivePath, identityPath] = process.argv.slice(2);
if (!identityPath)
throw new Error(
"write-e2e-plugin-identity requires source, output, manifest, archive, and identity paths",
);
async function sha256(file) {
return createHash("sha256")
.update(await readFile(file))
.digest("hex");
}
const manifest = await readFile(manifestPath, "utf8");
for (const required of [
'id: "kandev-plugin-e2e"',
'version: "1.0.0"',
'min_kandev_version: "0.91.1"',
'api_read: ["messages"]',
]) {
if (!manifest.includes(required)) throw new Error(`fixture manifest missing ${required}`);
}
const output = await readFile(generatedPath, "utf8");
if (!output.includes('id: "prompt-history-plugin"')) {
throw new Error("fixture output missing prompt-history-plugin panel");
}
const identity = {
schemaVersion: 2,
pluginId: "kandev-plugin-e2e",
pluginVersion: "1.0.0",
bundlePath: "ui/bundle.js",
sourceHash: await sha256(sourcePath),
generatedOutputHash: await sha256(generatedPath),
manifestHash: await sha256(manifestPath),
archiveSha256: await sha256(archivePath),
manifestCapability: "messages",
minKandevVersion: "0.91.1",
panelKey: "prompt-history-plugin",
};
await writeFile(identityPath, `${JSON.stringify(identity, null, 2)}\n`);
console.log(`[e2e-plugin-identity] ${path.resolve(identityPath)}`);