chore: minor fixes

This commit is contained in:
can1357
2026-06-02 08:27:04 +02:00
parent b503f7d86b
commit 77c2b0bd8f
2 changed files with 24 additions and 30 deletions
@@ -71,7 +71,7 @@ describe("loginXiaomi with tp- key", () => {
it("falls back SGP → AMS → CN during validation", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
const url = String(input);
seen.push(url);
if (url.includes(TOKEN_PLAN_HOSTS.sgp) || url.includes(TOKEN_PLAN_HOSTS.ams)) {
@@ -94,7 +94,7 @@ describe("loginXiaomi with tp- key", () => {
});
it("throws when all three token-plan hosts return 401", async () => {
using _hook = hookFetch((_input) => {
using _hook = hookFetch(_input => {
return new Response("Invalid API Key", { status: 401 });
});
@@ -110,7 +110,7 @@ describe("loginXiaomi with tp- key", () => {
it("falls back through timeouts: SGP timeout → AMS timeout → CN success", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
const url = String(input);
seen.push(url);
if (url.includes(TOKEN_PLAN_HOSTS.sgp) || url.includes(TOKEN_PLAN_HOSTS.ams)) {
@@ -135,7 +135,7 @@ describe("loginXiaomi with tp- key", () => {
it("does NOT hit the standard api.xiaomimimo.com for tp- keys", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
seen.push(String(input));
return new Response("{}", { status: 200, headers: { "Content-Type": "application/json" } });
});
@@ -158,7 +158,7 @@ describe("xiaomiModelManagerOptions with tp- key", () => {
it("discovers models from SGP first", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
seen.push(String(input));
return new Response(JSON.stringify({ data: [{ id: "mimo-v2.5" }] }), {
status: 200,
@@ -178,7 +178,7 @@ describe("xiaomiModelManagerOptions with tp- key", () => {
it("falls back SGP → AMS → CN during discovery", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
const url = String(input);
seen.push(url);
@@ -217,7 +217,7 @@ describe("xiaomiModelManagerOptions with tp- key", () => {
it("does NOT use standard host for tp- key model discovery", async () => {
const seen: string[] = [];
using _hook = hookFetch((input) => {
using _hook = hookFetch(input => {
seen.push(String(input));
return new Response(JSON.stringify({ data: [] }), {
status: 200,
@@ -241,7 +241,7 @@ describe("Xiaomi tp- full round-trip", () => {
// Phase 1: Login
const loginUrls: string[] = [];
using _hook1 = hookFetch((input) => {
using _hook1 = hookFetch(input => {
loginUrls.push(String(input));
return new Response("{}", { status: 200, headers: { "Content-Type": "application/json" } });
});
@@ -262,7 +262,7 @@ describe("Xiaomi tp- full round-trip", () => {
// Phase 2: Model discovery with the returned key
const discoveryUrls: string[] = [];
using _hook2 = hookFetch((input) => {
using _hook2 = hookFetch(input => {
discoveryUrls.push(String(input));
return new Response(JSON.stringify({ data: [{ id: "mimo-v2.5" }] }), {
status: 200,
@@ -2,9 +2,6 @@ import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
import { createAgentSession } from "@oh-my-pi/pi-coding-agent/sdk";
import { SessionManager } from "@oh-my-pi/pi-coding-agent/session/session-manager";
import {
buildSystemPrompt,
loadProjectContextFiles,
@@ -37,28 +34,25 @@ describe("SYSTEM.md prompt assembly", () => {
fs.mkdirSync(systemDir, { recursive: true });
fs.writeFileSync(path.join(systemDir, "SYSTEM.md"), systemPrompt);
const { session } = await createAgentSession({
const { systemPrompt: renderedPrompt } = await buildSystemPrompt({
cwd: projectDir,
agentDir: projectDir,
sessionManager: SessionManager.inMemory(),
settings: Settings.isolated(),
systemPrompt: [systemPrompt],
disableExtensionDiscovery: true,
skills: [],
customPrompt: systemPrompt,
contextFiles: [],
promptTemplates: [],
slashCommands: [],
enableMCP: false,
enableLsp: false,
skills: [],
rules: [],
toolNames: [],
workspaceTree: {
rootPath: projectDir,
rendered: "",
truncated: false,
totalLines: 0,
agentsMdFiles: [],
},
});
try {
const formatted = session.formatSessionAsText();
const matches = formatted.match(new RegExp(escapeRegExp(systemPrompt), "g")) ?? [];
expect(matches).toHaveLength(1);
} finally {
await session.dispose();
}
const promptText = renderedPrompt.join("\n\n");
const matches = promptText.match(new RegExp(escapeRegExp(systemPrompt), "g")) ?? [];
expect(matches).toHaveLength(1);
});
it("prefers project SYSTEM.md over user SYSTEM.md", async () => {