chore(frontend): introduce prettier + eslint and prune unused code
Backend CI / Backend (push) Has been cancelled
Frontend CI / Frontend (push) Failing after 1m39s

- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports)
- Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier
- Add root scripts: format, format:check, lint, lint:fix
- Reformat 257 files across admin-web, ops-web, desktop-client, packages
- Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters
- Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex
- Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-01 20:39:09 +08:00
parent 21c7892ee4
commit 162abdc97c
258 changed files with 42261 additions and 37556 deletions
+111 -103
View File
@@ -1,26 +1,28 @@
import { describe, expect, it } from "vitest";
import { describe, expect, it } from 'vitest'
import { __kimiTestUtils } from "./kimi";
import { __kimiTestUtils } from './kimi'
const {
buildSourceItem,
classifyKimiSources,
mergeKimiSourceLinksIntoContentSnapshot,
normalizeUrl,
} = __kimiTestUtils;
} = __kimiTestUtils
function buildSnapshot(overrides: Partial<Parameters<typeof classifyKimiSources>[0]>): Parameters<typeof classifyKimiSources>[0] {
function buildSnapshot(
overrides: Partial<Parameters<typeof classifyKimiSources>[0]>,
): Parameters<typeof classifyKimiSources>[0] {
return {
url: "https://www.kimi.com/chat/test",
title: "Kimi",
currentModelLabel: "K2.6 思考",
url: 'https://www.kimi.com/chat/test',
title: 'Kimi',
currentModelLabel: 'K2.6 思考',
loginRequired: false,
loginReason: null,
busy: false,
busySignals: [],
sendDisabled: null,
answerText: "答案",
answerBlocks: ["答案"],
answerText: '答案',
answerBlocks: ['答案'],
reasoningText: null,
reasoningBlocks: [],
questionMatched: true,
@@ -30,109 +32,115 @@ function buildSnapshot(overrides: Partial<Parameters<typeof classifyKimiSources>
panelCitationLinks: [],
inlineCitationCandidateLinks: [],
searchResultLinks: [],
signature: "sig",
signature: 'sig',
...overrides,
};
}
}
describe("kimi adapter helpers", () => {
it("unwraps Kimi redirect URLs before storing source items", () => {
expect(normalizeUrl("https://www.kimi.com/redirect?url=https%3A%2F%2Fexample.com%2Fsource%23ref")).toBe(
"https://example.com/source",
);
describe('kimi adapter helpers', () => {
it('unwraps Kimi redirect URLs before storing source items', () => {
expect(
normalizeUrl('https://www.kimi.com/redirect?url=https%3A%2F%2Fexample.com%2Fsource%23ref'),
).toBe('https://example.com/source')
expect(buildSourceItem({
url: "https://www.kimi.com/redirect?target=https%3A%2F%2Fsource.example.com%2Fnews%3Fid%3D1",
title: "搜索结果标题",
text: null,
siteName: "来源站点",
})).toMatchObject({
url: "https://source.example.com/news?id=1",
normalized_url: "https://source.example.com/news?id=1",
title: "搜索结果标题",
site_name: "来源站点",
host: "source.example.com",
});
});
it("uses search web results as citation sources and footer references as content citation candidates", () => {
const classified = classifyKimiSources(buildSnapshot({
searchResultLinks: [
{
url: "https://search.example.com/a",
title: "搜索网页 A",
text: "搜索网页 A",
siteName: "搜索站点",
},
],
panelCitationLinks: [
{
url: "https://content.example.com/cited",
title: "页尾引用文章",
text: "页尾引用文章",
siteName: "内容站点",
},
],
inlineCitationCandidateLinks: [
{
url: "https://content.example.com/site",
title: null,
text: "内容站点",
siteName: "内容站点",
},
],
}));
expect(classified.citations).toHaveLength(1);
expect(classified.citations[0]?.url).toBe("https://search.example.com/a");
expect(classified.searchResults[0]?.url).toBe("https://search.example.com/a");
expect(classified.panelCitations[0]?.url).toBe("https://content.example.com/cited");
expect(classified.inlineCitationCandidates.map((item) => item.url)).toEqual([
"https://content.example.com/cited",
"https://content.example.com/site",
]);
});
it("falls back to footer references as citation sources when no search web results are visible", () => {
const classified = classifyKimiSources(buildSnapshot({
panelCitationLinks: [
{
url: "https://content.example.com/cited",
title: "页尾引用文章",
text: "页尾引用文章",
siteName: "内容站点",
},
],
}));
expect(classified.searchResults).toHaveLength(0);
expect(classified.citations).toHaveLength(1);
expect(classified.citations[0]?.url).toBe("https://content.example.com/cited");
});
it("keeps the answer text from the content snapshot when merging side-panel sources", () => {
const merged = mergeKimiSourceLinksIntoContentSnapshot(
buildSnapshot({
answerText: "真实回答正文",
answerBlocks: ["真实回答正文"],
expect(
buildSourceItem({
url: 'https://www.kimi.com/redirect?target=https%3A%2F%2Fsource.example.com%2Fnews%3Fid%3D1',
title: '搜索结果标题',
text: null,
siteName: '来源站点',
}),
).toMatchObject({
url: 'https://source.example.com/news?id=1',
normalized_url: 'https://source.example.com/news?id=1',
title: '搜索结果标题',
site_name: '来源站点',
host: 'source.example.com',
})
})
it('uses search web results as citation sources and footer references as content citation candidates', () => {
const classified = classifyKimiSources(
buildSnapshot({
answerText: "搜索网页 48\nhttps://example.com/a 很长的侧栏文本",
answerBlocks: ["搜索网页 48\nhttps://example.com/a 很长的侧栏文本"],
searchResultLinks: [
{
url: "https://example.com/a",
title: "搜索结果 A",
text: "搜索结果 A",
siteName: "Example",
url: 'https://search.example.com/a',
title: '搜索网页 A',
text: '搜索网页 A',
siteName: '搜索站点',
},
],
panelCitationLinks: [
{
url: 'https://content.example.com/cited',
title: '页尾引用文章',
text: '页尾引用文章',
siteName: '内容站点',
},
],
inlineCitationCandidateLinks: [
{
url: 'https://content.example.com/site',
title: null,
text: '内容站点',
siteName: '内容站点',
},
],
}),
);
)
expect(merged.answerText).toBe("真实回答正文");
expect(merged.answerBlocks).toEqual(["真实回答正文"]);
expect(merged.searchResultLinks).toHaveLength(1);
expect(merged.searchResultLinks[0]?.url).toBe("https://example.com/a");
});
});
expect(classified.citations).toHaveLength(1)
expect(classified.citations[0]?.url).toBe('https://search.example.com/a')
expect(classified.searchResults[0]?.url).toBe('https://search.example.com/a')
expect(classified.panelCitations[0]?.url).toBe('https://content.example.com/cited')
expect(classified.inlineCitationCandidates.map((item) => item.url)).toEqual([
'https://content.example.com/cited',
'https://content.example.com/site',
])
})
it('falls back to footer references as citation sources when no search web results are visible', () => {
const classified = classifyKimiSources(
buildSnapshot({
panelCitationLinks: [
{
url: 'https://content.example.com/cited',
title: '页尾引用文章',
text: '页尾引用文章',
siteName: '内容站点',
},
],
}),
)
expect(classified.searchResults).toHaveLength(0)
expect(classified.citations).toHaveLength(1)
expect(classified.citations[0]?.url).toBe('https://content.example.com/cited')
})
it('keeps the answer text from the content snapshot when merging side-panel sources', () => {
const merged = mergeKimiSourceLinksIntoContentSnapshot(
buildSnapshot({
answerText: '真实回答正文',
answerBlocks: ['真实回答正文'],
}),
buildSnapshot({
answerText: '搜索网页 48\nhttps://example.com/a 很长的侧栏文本',
answerBlocks: ['搜索网页 48\nhttps://example.com/a 很长的侧栏文本'],
searchResultLinks: [
{
url: 'https://example.com/a',
title: '搜索结果 A',
text: '搜索结果 A',
siteName: 'Example',
},
],
}),
)
expect(merged.answerText).toBe('真实回答正文')
expect(merged.answerBlocks).toEqual(['真实回答正文'])
expect(merged.searchResultLinks).toHaveLength(1)
expect(merged.searchResultLinks[0]?.url).toBe('https://example.com/a')
})
})