Skip to content

Commit ef45f3b

Browse files
author
luozihao
committed
chore: update stale pnpm/SEA references in comments; format touched files
1 parent 0d49f9c commit ef45f3b

8 files changed

Lines changed: 129 additions & 122 deletions

File tree

apps/kimi-code/scripts/dev.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (externalUrl !== undefined && externalUrl.length > 0) {
2626
env[MARKETPLACE_ENV] = externalUrl;
2727
console.error(`Using external plugin marketplace: ${externalUrl}`);
2828
} else {
29-
// Default: every `pnpm run dev:cli` runs its own isolated marketplace server on a
29+
// Default: every `bun run dev:cli` runs its own isolated marketplace server on a
3030
// random port, so multiple concurrent dev instances never collide. Overwrite any
3131
// inherited MARKETPLACE_ENV so a stale URL from a dead instance can't break this run.
3232
const inherited = process.env[MARKETPLACE_ENV]?.trim();

apps/kimi-code/test/cli/update/native-manifest.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ describe('fetchNativeReleaseManifest', () => {
5555
bun: {},
5656
futureField: { nested: true },
5757
});
58-
const manifest = await fetchNativeReleaseManifest(VERSION, mockFetch({ ok: true, status: 200, body }));
58+
const manifest = await fetchNativeReleaseManifest(
59+
VERSION,
60+
mockFetch({ ok: true, status: 200, body }),
61+
);
5962
expect(manifest.version).toBe(VERSION);
6063
});
6164

@@ -106,9 +109,13 @@ describe('fetchNativeReleaseManifest', () => {
106109
// Headers arrive, then the body stalls; only the timeout can end this.
107110
text: async () =>
108111
new Promise<string>((_, reject) => {
109-
init?.signal?.addEventListener('abort', () => {
110-
reject(new Error('aborted'));
111-
}, { once: true });
112+
init?.signal?.addEventListener(
113+
'abort',
114+
() => {
115+
reject(new Error('aborted'));
116+
},
117+
{ once: true },
118+
);
112119
}),
113120
})) as unknown as typeof fetch;
114121
const promise = fetchNativeReleaseManifest(VERSION, f);
@@ -148,7 +155,9 @@ describe('selectBunPlatformEntry', () => {
148155

149156
describe('url helpers', () => {
150157
it('builds the manifest and binary URLs from the binaries base', () => {
151-
expect(nativeManifestUrl(VERSION)).toBe(`${kimiCodeCdnBinariesBase()}/${VERSION}/manifest.json`);
158+
expect(nativeManifestUrl(VERSION)).toBe(
159+
`${kimiCodeCdnBinariesBase()}/${VERSION}/manifest.json`,
160+
);
152161
expect(nativeBinaryUrl(VERSION, 'kimi-code-bun-win32-x64.zip')).toBe(
153162
`${kimiCodeCdnBinariesBase()}/${VERSION}/kimi-code-bun-win32-x64.zip`,
154163
);

apps/kimi-code/test/scripts/native/release-artifacts.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ describe('native release artifacts', () => {
181181
const releaseDir = await mkdtemp(join(tmpdir(), 'kimi-manifest-partialbun-'));
182182
const [...missing] = SUPPORTED_TARGETS;
183183
const uncovered = missing.pop();
184-
if (uncovered === undefined || missing.length === 0) throw new Error('expected multiple supported targets');
184+
if (uncovered === undefined || missing.length === 0)
185+
throw new Error('expected multiple supported targets');
185186

186187
try {
187188
for (const target of missing) {
@@ -202,5 +203,4 @@ describe('native release artifacts', () => {
202203
rmSync(releaseDir, { recursive: true, force: true });
203204
}
204205
});
205-
206206
});

apps/kimi-code/tsdown.worker.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Dedicated tsdown config that bundles the off-main-thread workers into
22
// self-contained ESM files so they can ride the SEA blob as assets
3-
// (02-sea-blob.mjs) and be spawned from disk at runtime:
3+
// and be spawned from disk at runtime:
44
// - text-build-worker.mjs: the minidb text-build worker
55
// (packages/minidb/src/worker/text-build-worker.ts);
66
// - search-worker.mjs: the kap-server global-search worker

packages/kap-server/test/search/searchRoute.test.ts

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { ISessionIndex, type SessionSummary } from '@moonshot-ai/agent-core-v2';
66
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
77

88
import { type RunningServer, startServer } from '../../src/start';
9-
import { TEST_HOST_IDENTITY } from '../helpers/hostIdentity';
109
import { authedFetch } from '../helpers/auth';
10+
import { TEST_HOST_IDENTITY } from '../helpers/hostIdentity';
1111

1212
interface Envelope<T> {
1313
code: number;
@@ -252,58 +252,67 @@ describe('server-v2 session routes with the global search DB unavailable', () =>
252252
return (await res.json()) as Envelope<T>;
253253
}
254254

255-
it('session list / create / get / cold resume pass with the search index down', { timeout: 30_000 }, async () => {
256-
await boot();
257-
const created = await postJson<{ id: string }>('/api/v1/sessions', {
258-
metadata: { cwd: home },
259-
});
260-
expect(created.code).toBe(0);
261-
const id = created.data.id;
262-
const list = await getJson<{ items: { id: string }[] }>('/api/v1/sessions');
263-
expect(list.code).toBe(0);
264-
await expect
265-
.poll(
266-
async () =>
267-
(await getJson<{ items: { id: string }[] }>('/api/v1/sessions')).data.items.map(
268-
(item) => item.id,
269-
),
270-
{ interval: 1_000 },
271-
)
272-
.toContain(id);
273-
await server!.close();
274-
server = undefined;
255+
it(
256+
'session list / create / get / cold resume pass with the search index down',
257+
{ timeout: 30_000 },
258+
async () => {
259+
await boot();
260+
const created = await postJson<{ id: string }>('/api/v1/sessions', {
261+
metadata: { cwd: home },
262+
});
263+
expect(created.code).toBe(0);
264+
const id = created.data.id;
265+
const list = await getJson<{ items: { id: string }[] }>('/api/v1/sessions');
266+
expect(list.code).toBe(0);
267+
await expect
268+
.poll(
269+
async () =>
270+
(await getJson<{ items: { id: string }[] }>('/api/v1/sessions')).data.items.map(
271+
(item) => item.id,
272+
),
273+
{ interval: 1_000 },
274+
)
275+
.toContain(id);
276+
await server!.close();
277+
server = undefined;
275278

276-
await boot();
277-
const coldList = await getJson<{ items: { id: string }[] }>('/api/v1/sessions');
278-
expect(coldList.code).toBe(0);
279-
expect(coldList.data.items.map((item) => item.id)).toContain(id);
280-
const got = await getJson<{ id: string }>(`/api/v1/sessions/${id}`);
281-
expect(got.code).toBe(0);
282-
const messages = await getJson<{ items: unknown[] }>(`/api/v1/sessions/${id}/messages`);
283-
expect(messages.code).toBe(0);
279+
await boot();
280+
const coldList = await getJson<{ items: { id: string }[] }>('/api/v1/sessions');
281+
expect(coldList.code).toBe(0);
282+
expect(coldList.data.items.map((item) => item.id)).toContain(id);
283+
const got = await getJson<{ id: string }>(`/api/v1/sessions/${id}`);
284+
expect(got.code).toBe(0);
285+
const messages = await getJson<{ items: unknown[] }>(`/api/v1/sessions/${id}/messages`);
286+
expect(messages.code).toBe(0);
284287

285-
const probe = await stat(join(home as string, 'search-index'));
286-
expect(probe.isFile()).toBe(true);
287-
});
288+
const probe = await stat(join(home as string, 'search-index'));
289+
expect(probe.isFile()).toBe(true);
290+
},
291+
);
288292

289-
it('only the full-text search request reports the index outage', { timeout: 30_000 }, async () => {
290-
await boot();
291-
const created = await postJson<{ id: string }>('/api/v1/sessions', {
292-
metadata: { cwd: home },
293-
});
294-
expect(created.code).toBe(0);
293+
it(
294+
'only the full-text search request reports the index outage',
295+
{ timeout: 30_000 },
296+
async () => {
297+
await boot();
298+
const created = await postJson<{ id: string }>('/api/v1/sessions', {
299+
metadata: { cwd: home },
300+
});
301+
expect(created.code).toBe(0);
295302

296-
await expect
297-
.poll(
298-
async () => (await postJson<SearchPageWire>('/api/v1/search', { query: 'anything' })).code,
299-
{ timeout: 10_000, interval: 100 },
300-
)
301-
.toBe(50001);
302-
const search = await postJson<SearchPageWire>('/api/v1/search', { query: 'anything' });
303-
expect(search.code).toBe(50001);
304-
expect(search.msg).toContain('search index failed to open');
303+
await expect
304+
.poll(
305+
async () =>
306+
(await postJson<SearchPageWire>('/api/v1/search', { query: 'anything' })).code,
307+
{ timeout: 10_000, interval: 100 },
308+
)
309+
.toBe(50001);
310+
const search = await postJson<SearchPageWire>('/api/v1/search', { query: 'anything' });
311+
expect(search.code).toBe(50001);
312+
expect(search.msg).toContain('search index failed to open');
305313

306-
const list = await getJson<{ items: unknown[] }>('/api/v1/sessions');
307-
expect(list.code).toBe(0);
308-
});
314+
const list = await getJson<{ items: unknown[] }>('/api/v1/sessions');
315+
expect(list.code).toBe(0);
316+
},
317+
);
309318
});

packages/kap-server/test/sessions.test.ts

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { tmpdir } from 'node:os';
44
import { join } from 'node:path';
55
import { inflateRawSync } from 'node:zlib';
66

7-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
8-
97
import {
108
Error2,
119
ErrorCodes,
@@ -29,13 +27,14 @@ import {
2927
type ServiceIdentifier,
3028
type ScopeSeed,
3129
} from '@moonshot-ai/agent-core-v2';
30+
import { encodeWorkDirKey } from '@moonshot-ai/agent-core-v2/_base/utils/workdir-slug';
3231
import { TurnStarted } from '@moonshot-ai/agent-core-v2/agent/loop/turnEvents';
3332
import { sessionWarningsResponseSchema } from '@moonshot-ai/agent-core-v2/app/sessionLegacy/sessionProtocol';
34-
import { encodeWorkDirKey } from '@moonshot-ai/agent-core-v2/_base/utils/workdir-slug';
33+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3534

3635
import { type RunningServer, startServer } from '../src/start';
37-
import { TEST_HOST_IDENTITY } from './helpers/hostIdentity';
3836
import { authHeaders } from './helpers/auth';
37+
import { TEST_HOST_IDENTITY } from './helpers/hostIdentity';
3938

4039
interface Envelope<T> {
4140
code: number;
@@ -70,11 +69,7 @@ interface PageWire {
7069
has_more: boolean;
7170
}
7271

73-
function agentRpc(
74-
service: ServiceIdentifier<unknown>,
75-
method: string,
76-
sessionId: string,
77-
): string {
72+
function agentRpc(service: ServiceIdentifier<unknown>, method: string, sessionId: string): string {
7873
return `/api/v1/debug/session/${sessionId}/agent/main/${String(service)}/${method}`;
7974
}
8075

@@ -468,11 +463,9 @@ describe('server-v2 /api/v1/sessions', () => {
468463
expect(page3.body.data.items.map((s) => s.id)).toEqual([ids[0]]);
469464
expect(page3.body.data.has_more).toBe(false);
470465

471-
const seen = [
472-
...page1.body.data.items,
473-
...page2.body.data.items,
474-
...page3.body.data.items,
475-
].map((s) => s.id);
466+
const seen = [...page1.body.data.items, ...page2.body.data.items, ...page3.body.data.items].map(
467+
(s) => s.id,
468+
);
476469
expect(new Set(seen).size).toBe(7);
477470
expect(new Set(seen)).toEqual(new Set(ids));
478471

@@ -629,22 +622,18 @@ describe('server-v2 /api/v1/sessions', () => {
629622
});
630623
const id = created.body.data.id;
631624
for (const text of ['first REST prompt', 'second REST prompt', 'third REST prompt']) {
632-
const submitted = await postJson<{ prompt_id: string }>(
633-
`/api/v1/sessions/${id}/prompts`,
634-
{ content: [{ type: 'text', text }] },
635-
);
625+
const submitted = await postJson<{ prompt_id: string }>(`/api/v1/sessions/${id}/prompts`, {
626+
content: [{ type: 'text', text }],
627+
});
636628
expect(submitted.body.code).toBe(0);
637629
}
638630

639-
const generated = await postJson<{ title: string }>(
640-
`/api/v1/sessions/${id}/title/generate`,
641-
);
631+
const generated = await postJson<{ title: string }>(`/api/v1/sessions/${id}/title/generate`);
642632
expect(generated.body).toMatchObject({ code: 0, data: { title: 'generated from REST' } });
643633
expect(toolsRequest).toEqual({
644634
method: 'chat_title',
645635
params: {
646-
chat_content:
647-
'user: first REST prompt\nuser: second REST prompt\nuser: third REST prompt',
636+
chat_content: 'user: first REST prompt\nuser: second REST prompt\nuser: third REST prompt',
648637
},
649638
});
650639

@@ -679,9 +668,7 @@ describe('server-v2 /api/v1/sessions', () => {
679668
});
680669

681670
it('returns session-not-found when generating a title for a missing session', async () => {
682-
const generated = await postJson<null>(
683-
'/api/v1/sessions/sess_missing_title/title/generate',
684-
);
671+
const generated = await postJson<null>('/api/v1/sessions/sess_missing_title/title/generate');
685672

686673
expect(generated.body.code).toBe(40401);
687674
});
@@ -816,9 +803,7 @@ describe('server-v2 /api/v1/sessions', () => {
816803
agent_config: { goal_control: 'resume' },
817804
});
818805

819-
const refreshed = await getJson<{ status: string } | null>(
820-
`/api/v1/sessions/${rig.id}/goal`,
821-
);
806+
const refreshed = await getJson<{ status: string } | null>(`/api/v1/sessions/${rig.id}/goal`);
822807

823808
expect(refreshed.body.data?.status).toBe('active');
824809
} finally {
@@ -851,9 +836,9 @@ describe('server-v2 /api/v1/sessions', () => {
851836
.delete(encodeWorkDirKey(cwd));
852837
await rm(cwd, { recursive: true, force: true });
853838

854-
await expect(
855-
resumeSessionById((server as RunningServer).core.accessor, id),
856-
).rejects.toThrow(/does not exist/);
839+
await expect(resumeSessionById((server as RunningServer).core.accessor, id)).rejects.toThrow(
840+
/does not exist/,
841+
);
857842

858843
const archived = await postJson<{ archived: boolean }>(`/api/v1/sessions/${id}:archive`);
859844
expect(archived.body.code).toBe(0);
@@ -911,7 +896,10 @@ describe('server-v2 /api/v1/sessions', () => {
911896
const created = await postJson<SessionWire>('/api/v1/sessions', {
912897
metadata: { cwd: home as string },
913898
});
914-
const session = getLiveSessionById((server as RunningServer).core.accessor, created.body.data.id);
899+
const session = getLiveSessionById(
900+
(server as RunningServer).core.accessor,
901+
created.body.data.id,
902+
);
915903
if (session === undefined) throw new Error('expected live session');
916904
const agent = await session.accessor
917905
.get(IAgentLifecycleService)
@@ -921,10 +909,9 @@ describe('server-v2 /api/v1/sessions', () => {
921909
.mockRejectedValue(new Error2(ErrorCodes.SESSION_BUSY, 'session is busy'));
922910

923911
try {
924-
const response = await postJson<null>(
925-
`/api/v1/sessions/${created.body.data.id}:undo`,
926-
{ count: 1 },
927-
);
912+
const response = await postJson<null>(`/api/v1/sessions/${created.body.data.id}:undo`, {
913+
count: 1,
914+
});
928915

929916
expect(response.body.code).toBe(40901);
930917
} finally {
@@ -1135,14 +1122,10 @@ describe('server-v2 /api/v1/sessions', () => {
11351122
it('paginates archived_only without returning empty filtered pages', async () => {
11361123
const cwd = home as string;
11371124
const archivedOlder = await postJson<SessionWire>('/api/v1/sessions', { metadata: { cwd } });
1138-
await postJson<{ archived: boolean }>(
1139-
`/api/v1/sessions/${archivedOlder.body.data.id}:archive`,
1140-
);
1125+
await postJson<{ archived: boolean }>(`/api/v1/sessions/${archivedOlder.body.data.id}:archive`);
11411126

11421127
const archivedNewer = await postJson<SessionWire>('/api/v1/sessions', { metadata: { cwd } });
1143-
await postJson<{ archived: boolean }>(
1144-
`/api/v1/sessions/${archivedNewer.body.data.id}:archive`,
1145-
);
1128+
await postJson<{ archived: boolean }>(`/api/v1/sessions/${archivedNewer.body.data.id}:archive`);
11461129

11471130
await postJson<SessionWire>('/api/v1/sessions', { metadata: { cwd } });
11481131
await postJson<SessionWire>('/api/v1/sessions', { metadata: { cwd } });
@@ -1480,11 +1463,24 @@ describe('server-v2 /api/v1/sessions', () => {
14801463

14811464
it('derives the session title from the first prompt submitted via /api/v1', async () => {
14821465
const cwd = home as string;
1483-
await writeFile(join(cwd, 'config.toml'), [
1484-
'default_model = "stub"', '', '[providers.stub]', 'type = "openai"',
1485-
'base_url = "http://127.0.0.1:9999"', 'api_key = "stub"', '',
1486-
'[models.stub]', 'provider = "stub"', 'model = "stub"', 'max_context_size = 1000', '',
1487-
].join('\n'), 'utf-8');
1466+
await writeFile(
1467+
join(cwd, 'config.toml'),
1468+
[
1469+
'default_model = "stub"',
1470+
'',
1471+
'[providers.stub]',
1472+
'type = "openai"',
1473+
'base_url = "http://127.0.0.1:9999"',
1474+
'api_key = "stub"',
1475+
'',
1476+
'[models.stub]',
1477+
'provider = "stub"',
1478+
'model = "stub"',
1479+
'max_context_size = 1000',
1480+
'',
1481+
].join('\n'),
1482+
'utf-8',
1483+
);
14881484
const created = await postJson<SessionWire>('/api/v1/sessions', { metadata: { cwd } });
14891485
const id = created.body.data.id;
14901486
expect(created.body.data.title).toBe('');

0 commit comments

Comments
 (0)