From 77c2b0bd8fddc7fc7d808317b46290990bb97792 Mon Sep 17 00:00:00 2001 From: can1357 Date: Tue, 2 Jun 2026 08:27:04 +0200 Subject: [PATCH] chore: minor fixes --- .../test/xiaomi-tp-login-integration.test.ts | 18 +++++----- .../test/system-prompt-dedup.test.ts | 36 ++++++++----------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/packages/ai/test/xiaomi-tp-login-integration.test.ts b/packages/ai/test/xiaomi-tp-login-integration.test.ts index d1e4ecec7..1711bfd47 100644 --- a/packages/ai/test/xiaomi-tp-login-integration.test.ts +++ b/packages/ai/test/xiaomi-tp-login-integration.test.ts @@ -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, diff --git a/packages/coding-agent/test/system-prompt-dedup.test.ts b/packages/coding-agent/test/system-prompt-dedup.test.ts index f19497abd..92fdd84d2 100644 --- a/packages/coding-agent/test/system-prompt-dedup.test.ts +++ b/packages/coding-agent/test/system-prompt-dedup.test.ts @@ -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 () => {