feat(install): 支持 --system 与 --user 模式切换并自动清理残留二进制
- 在 scripts/install.sh 中默认安装至用户目录 ~/.local/bin,并自动清理历史遗留的 /opt/homebrew/bin/seal-use - 在 scripts/dev-override.ts 中优先命中 ~/.local/bin/seal-use,忽略 Homebrew 路径并自动清理残留 - 在 seal-use update 中支持 --system(提权迁移至 /usr/local/bin)与 --user(降权回归至 ~/.local/bin)选项,添加 seal-use migrate 别名 - 迁移与更新时自动清理另一端的非活动实体二进制(恪守 Single Binary Invariant) - 自更新权限预检:当目标位于系统目录且缺少写权限时,友好提示 sudo seal-use update 而非底层报错 - 在 seal-use doctor 中增加执行模式识别与多份二进制(PATH 阴影)检测告警
This commit is contained in:
1 parent
477cc630b4
commit
87bb10f527
12 files changed
+294
-34
No files matched your search
@@ -58,6 +58,9 @@ describe("Doctor Diagnosis Engine", () => {
|
||||
expect(diagnosis.directories.agentSkillDir).toBeDefined();
|
||||
|
||||
expect(diagnosis.checks.length).toBeGreaterThanOrEqual(3);
|
||||
const execCheck = diagnosis.checks.find((c) => c.id === "executable");
|
||||
expect(execCheck).toBeDefined();
|
||||
expect(execCheck?.message).toMatch(/模式/);
|
||||
expect(diagnosis.knowledge.directorySpecsCount).toBe(EMBEDDED_DIRECTORY_SPECS.length);
|
||||
});
|
||||
|
||||
|
||||
@@ -224,13 +224,39 @@ export function diagnoseSystem(): DoctorDiagnosis {
|
||||
const checks: HealthCheckItem[] = [];
|
||||
|
||||
// Check 1: Executable
|
||||
const isSystem = process.execPath === "/usr/local/bin/seal-use" || process.execPath.startsWith("/usr/local/");
|
||||
const isUser = process.execPath.includes(".local/bin");
|
||||
const modeLabel = isSystem ? "系统全局模式 (/usr/local/bin)" : isUser ? "普通用户模式 (~/.local/bin)" : "独立模式";
|
||||
|
||||
checks.push({
|
||||
id: "executable",
|
||||
title: "命令行二进制",
|
||||
status: "ok",
|
||||
message: `当前执行路径: ${process.execPath}`
|
||||
message: `${process.execPath} [${modeLabel}]`
|
||||
});
|
||||
|
||||
// Check 1b: Duplicate / Shadowed Binaries
|
||||
const knownBinaryLocations = [
|
||||
join(home, ".local", "bin", "seal-use"),
|
||||
"/usr/local/bin/seal-use",
|
||||
"/opt/homebrew/bin/seal-use",
|
||||
join(home, "bin", "seal-use")
|
||||
];
|
||||
const detectedBunWhich = Bun.which("seal-use");
|
||||
const existingBinaries = Array.from(new Set(
|
||||
[detectedBunWhich, ...knownBinaryLocations, process.execPath]
|
||||
.filter((p): p is string => Boolean(p && existsSync(p)))
|
||||
));
|
||||
|
||||
if (existingBinaries.length > 1) {
|
||||
checks.push({
|
||||
id: "binary_integrity",
|
||||
title: "多份二进制检测 (PATH 阴影风险)",
|
||||
status: "warn",
|
||||
message: `检测到多份 seal-use 实体: ${existingBinaries.join(", ")} (当前生效: ${detectedBunWhich ?? process.execPath})`
|
||||
});
|
||||
}
|
||||
|
||||
// Check 2: Config Directory
|
||||
if (directories.configDir?.exists && directories.configDir.writable) {
|
||||
checks.push({
|
||||
|
||||
Reference in new issue
Block a user