chore(format): 撤销误入提交的整体重排,并关闭本仓库的格式化器

# 发生了什么

pi-lens 内置「安全格式化」:它会自动安装 biome 并对**编辑过的文件**跑
`biome format --write`。本机原先没有任何 biome 配置,于是 biome 用它自己的
默认值 —— tab 缩进 + 双引号 —— 把文件整体重写。

我在 19a3161 那次提交里用了 `git add -A`,把这批与功能无关的重排一起扫了进去:
约 7000 行改动散落在 20 个文件上,使那次提交无法审查,还掩盖了
server/internal/handler/permission.go 的一处删行(实为文件末尾空行,无代码丢失)。

# 为什么是「关掉」而不是「配置成我们的风格」

试过把缩进/引号/lineWidth 全部对齐本仓库习惯(biome.json + space/2/single/
lineWidth 120):`biome format --write` 仍然改动 17 个文件。原因是本仓库从未按
biome 的规则排版过 —— 注释按语义换行、数组与调用按可读性手工折行,
这些无法由格式化器还原。也就是说只要格式化器开着,每次编辑都会产生与内容无关的
大面积 diff,把真正的改动埋掉。

因此 biome.jsonc 里 formatter 与 linter 都关闭:本仓库的静态检查由
tsc / go vet / tree-sitter / ast-grep 与各自测试套件承担,不引入会改动无关行的
自动修复。

(pi-lens 这一版把 format 服务的 enabled 硬编码为 true,没有配置开关,
所以只能在仓库侧用 biome 配置让它不动文件;已验证 `biome format --write`
对这些文件零改动。)

# 本提交内容

把 19a3161 里除「有意改动」外的 20 个文件还原到重排前的样子。
19a3161 中真正有意的改动是 deploy/install.sh 的扩展注册与
plugins/pi-mail-bridge/extension/index.ts 新文件,两者原样保留。

验证:Go 全量、三桥插件(320/362/409)、前端 196 全绿;
`biome format --write` 对还原后的文件零改动。
This commit is contained in:
2026-09-11 12:03:51 +08:00
parent 19a3161ee4
commit 429149e118
21 changed files with 5603 additions and 6668 deletions

View File

@ -1,9 +1,3 @@
export declare function dshSessionIdForMail(mailSessionID: any): string;
export declare function matchesMailSession(
dshSessionId: any,
mailSessionID: any,
): boolean;
export declare function pickMailSession(
dshSessionIds: any[] | undefined,
mailSessionID: any,
): string | undefined;
export declare function matchesMailSession(dshSessionId: any, mailSessionID: any): boolean;
export declare function pickMailSession(dshSessionIds: any[] | undefined, mailSessionID: any): string | undefined;

View File

@ -24,7 +24,7 @@
/** 首次尝试使用的 DSH 会话 id。 */
export function dshSessionIdForMail(mailSessionID) {
return `mail-${String(mailSessionID ?? "")}`;
return `mail-${String(mailSessionID ?? '')}`;
}
/**
@ -35,12 +35,12 @@ export function dshSessionIdForMail(mailSessionID) {
* @returns {boolean}
*/
export function matchesMailSession(dshSessionId, mailSessionID) {
const id = String(dshSessionId ?? "");
const base = dshSessionIdForMail(mailSessionID);
if (id === base) return true;
// 模型降级重试mail-<id>-r1 / -r2 / …
const suffix = id.startsWith(`${base}-r`) ? id.slice(base.length + 2) : "";
return suffix.length > 0 && /^\d+$/.test(suffix);
const id = String(dshSessionId ?? '');
const base = dshSessionIdForMail(mailSessionID);
if (id === base) return true;
// 模型降级重试mail-<id>-r1 / -r2 / …
const suffix = id.startsWith(`${base}-r`) ? id.slice(base.length + 2) : '';
return suffix.length > 0 && /^\d+$/.test(suffix);
}
/**
@ -54,19 +54,19 @@ export function matchesMailSession(dshSessionId, mailSessionID) {
* @returns {string|undefined}
*/
export function pickMailSession(dshSessionIds, mailSessionID) {
const base = dshSessionIdForMail(mailSessionID);
const list = Array.isArray(dshSessionIds) ? dshSessionIds.map(String) : [];
if (list.includes(base)) return base;
const base = dshSessionIdForMail(mailSessionID);
const list = Array.isArray(dshSessionIds) ? dshSessionIds.map(String) : [];
if (list.includes(base)) return base;
let best;
let bestIndex = Infinity;
for (const id of list) {
if (!matchesMailSession(id, mailSessionID)) continue;
const idx = Number(id.slice(base.length + 2));
if (idx < bestIndex) {
bestIndex = idx;
best = id;
}
}
return best;
let best;
let bestIndex = Infinity;
for (const id of list) {
if (!matchesMailSession(id, mailSessionID)) continue;
const idx = Number(id.slice(base.length + 2));
if (idx < bestIndex) {
bestIndex = idx;
best = id;
}
}
return best;
}

View File

@ -1,17 +1,17 @@
export interface SseClientOptions {
authHeaders: () => Record<string, string>;
baseURL: string;
path: string;
onEvent: (evt: string, data: any) => void;
log?: (msg: string) => void;
authHeaders: () => Record<string, string>;
baseURL: string;
path: string;
onEvent: (evt: string, data: any) => void;
log?: (msg: string) => void;
}
export declare function createSSEClient(options: SseClientOptions): {
stop: () => void;
reset: () => void;
stop: () => void;
reset: () => void;
};
export declare function createFrameParser(): {
push: (chunk: string) => Array<{ event: string; data: string; id: string }>;
reset: () => void;
lastEventId: () => string;
setLastEventId: (id: string) => void;
push: (chunk: string) => Array<{ event: string; data: string; id: string }>;
reset: () => void;
lastEventId: () => string;
setLastEventId: (id: string) => void;
};

View File

@ -2,20 +2,12 @@ export declare function hasOptions(question: any): boolean;
export declare function optionLabels(question: any): string[];
export declare function questionTitle(question: any): string;
export declare function flattenQuestions(questions: any[]): {
question: string;
options: string[];
context: string;
multiSelect: boolean;
question: string;
options: string[];
context: string;
multiSelect: boolean;
};
export declare function answersFromDecision(
questions: any[],
decision: string,
note?: string,
): {
answers: Array<{ id: string; selected: string[]; custom?: string }>;
export declare function answersFromDecision(questions: any[], decision: string, note?: string): {
answers: Array<{ id: string; selected: string[]; custom?: string }>;
};
export declare function isBlankAnswer(
questions: any[],
decision: string,
note?: string,
): boolean;
export declare function isBlankAnswer(questions: any[], decision: string, note?: string): boolean;