refactor: notify/footer 持久配置收编到 config/,chrome bridge 地址固定

仓库规则要求 config/ 为唯一配置来源、不以环境变量作持久默认值:
- pi-notify 改读 config/pi-notify.json(逐字段校验回退,复用原 parsers 钳制)
- pi-minimal-footer 改读 config/pi-minimal-footer.json
- pi-chrome 移除 PI_CHROME_BRIDGE_HOST/PORT,固定 127.0.0.1:17318
  (浏览器端 service_worker.js 硬编码同一地址,单侧可配只会断连)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
云服务部-叶林立
2026-10-21 19:16:47 -07:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 0c45b1a438
commit e996f59469
19 changed files with 366 additions and 121 deletions
+51
View File
@@ -0,0 +1,51 @@
import assert from "node:assert/strict";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, it } from "node:test";
import { readFooterSettings } from "../settings.ts";
let tempDir: string | undefined;
afterEach(() => {
if (tempDir) {
rmSync(tempDir, { recursive: true, force: true });
tempDir = undefined;
}
});
function configPath(contents: string): string {
tempDir = mkdtempSync(join(tmpdir(), "pi-minimal-footer-settings-"));
const path = join(tempDir, "pi-minimal-footer.json");
writeFileSync(path, contents);
return path;
}
const expectedDefaults = { showCwd: true, showBranch: true };
describe("readFooterSettings", () => {
it("returns all defaults when the config file is missing", () => {
assert.deepEqual(readFooterSettings("/does/not/exist/pi-minimal-footer.json"), expectedDefaults);
});
it("returns all defaults for malformed or non-object JSON", () => {
for (const contents of ["not json", "[1,2]", "42"]) {
assert.deepEqual(readFooterSettings(configPath(contents)), expectedDefaults, contents);
}
});
it("adopts explicit boolean values", () => {
assert.deepEqual(
readFooterSettings(configPath(JSON.stringify({ showCwd: false, showBranch: false }))),
{ showCwd: false, showBranch: false },
);
});
it("falls back per-field for non-boolean values", () => {
assert.deepEqual(
readFooterSettings(configPath(JSON.stringify({ showCwd: "no", showBranch: 0 }))),
expectedDefaults,
);
});
});