import assert from "node:assert/strict"; import { readFile, stat } from "node:fs/promises"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import test from "node:test"; const root = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const readJson = async (name) => JSON.parse(await readFile(resolve(root, name), "utf8")); test("demo owns an exact SDK pin and reproducible lock", async () => { const pkg = await readJson("package.json"); assert.equal(pkg.dependencies["@cline/sdk"], "0.2.0"); assert.equal(pkg.engines.node, "24.15.0"); const lock = await readJson("package-lock.json"); assert.equal(lock.packages[""].dependencies["@cline/sdk"], "0.2.0"); assert.equal(lock.packages["node_modules/@cline/sdk"].version, "0.2.0"); assert.equal(lock.packages["node_modules/@cline/core"].version, "0.2.0"); }); test("installable manifest declares public v1 adapter and a matching preset", async () => { const manifest = await readJson("idea-plugin.json"); assert.equal(manifest.ideaPluginManifestVersion, 1); assert.equal(manifest.id, "idea.cline-demo"); assert.equal(manifest.contributes.agentAdapters.length, 1); const adapter = manifest.contributes.agentAdapters[0]; assert.equal(adapter.protocol, "idea-agent-session"); assert.equal(adapter.protocolVersion, 1); assert.equal(adapter.command, "bin/idea-cline-adapter.mjs"); assert.equal(adapter.id, "cline-sdk"); assert.equal(adapter.configSchema.additionalProperties, false); assert.deepEqual(adapter.configSchema.required, ["model", "endpoint"]); assert.equal(adapter.configSchema.properties.apiKey.format, "secret"); assert.deepEqual(Object.keys(adapter.configSchema.properties).sort(), ["apiKey", "endpoint", "model"]); assert.ok(manifest.contributes.aiProfiles.some((preset) => preset.adapterId === adapter.id)); assert.ok(manifest.contributes.aiProfiles.every((preset) => !("apiKey" in preset.configDefaults))); assert.ok((await stat(resolve(root, manifest.main))).isFile()); }); test("public process entry and runtime modules are real package files", async () => { const entry = await stat(resolve(root, "bin/idea-cline-adapter.mjs")); assert.ok(entry.isFile()); assert.ok(entry.mode & 0o111, "host must be able to execute the adapter entry"); for (const name of ["src/adapter.mjs", "src/cline-runtime.mjs"]) { assert.ok((await stat(resolve(root, name))).isFile()); } });