@textcortex/zenocode 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import {
|
|
7
|
+
buildOpenCodeConfig,
|
|
8
|
+
chooseDefaults,
|
|
9
|
+
writePrivateJsonFile,
|
|
10
|
+
} from "./run-codecortex.mjs";
|
|
11
|
+
|
|
12
|
+
test("chooseDefaults prefers kimi k2.5 thinking for Zenocode", () => {
|
|
13
|
+
const defaults = chooseDefaults({
|
|
14
|
+
"glm-5": {},
|
|
15
|
+
"kimi-k2-5-thinking": {},
|
|
16
|
+
"gpt-5-2": {},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
assert.deepEqual(defaults, {
|
|
20
|
+
model: "kimi-k2-5-thinking",
|
|
21
|
+
smallModel: "kimi-k2-5-thinking",
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("buildOpenCodeConfig includes an openai stub for fallback runtime auth plugins", () => {
|
|
26
|
+
const config = buildOpenCodeConfig({
|
|
27
|
+
baseUrl: "http://127.0.0.1:8080",
|
|
28
|
+
providerID: "textcortex",
|
|
29
|
+
model: "kimi-k2-5-thinking",
|
|
30
|
+
smallModel: "kimi-k2-5-thinking",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
assert.deepEqual(config.enabled_providers, ["textcortex"]);
|
|
34
|
+
assert.equal(config.model, "textcortex/kimi-k2-5-thinking");
|
|
35
|
+
assert.ok(config.provider.openai);
|
|
36
|
+
assert.deepEqual(config.provider.openai.models, {});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("writePrivateJsonFile stores credentials with private permissions", async (t) => {
|
|
40
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "zenocode-runtime-"));
|
|
41
|
+
const credentialsPath = path.join(tempDir, "runtime", "credentials.json");
|
|
42
|
+
|
|
43
|
+
t.after(async () => {
|
|
44
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
await writePrivateJsonFile(credentialsPath, { access_token: "secret-token" });
|
|
48
|
+
|
|
49
|
+
const saved = JSON.parse(await fs.readFile(credentialsPath, "utf-8"));
|
|
50
|
+
assert.equal(saved.access_token, "secret-token");
|
|
51
|
+
|
|
52
|
+
if (process.platform !== "win32") {
|
|
53
|
+
const dirMode = (await fs.stat(path.dirname(credentialsPath))).mode & 0o777;
|
|
54
|
+
const fileMode = (await fs.stat(credentialsPath)).mode & 0o777;
|
|
55
|
+
|
|
56
|
+
assert.equal(dirMode, 0o700);
|
|
57
|
+
assert.equal(fileMode, 0o600);
|
|
58
|
+
}
|
|
59
|
+
});
|