pi-web-ui 0.102.0 → 0.103.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/server/agent-service-daemon.js +17 -10
- package/dist/server/agent-service.js +125 -49
- package/dist/server/bash-tool.js +19 -1
- package/dist/server/client-state.js +9 -1
- package/dist/server/dispatch-domain-handlers.js +66 -0
- package/dist/server/edit-soft-tool.js +15 -3
- package/dist/server/files-service.js +636 -14
- package/dist/server/index.js +7 -1
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/read-tool.js +11 -4
- package/dist/server/remote-ssh-service.js +1314 -0
- package/dist/server/scm.js +16 -0
- package/dist/server/terminals.js +65 -21
- package/dist/server/tool-guards.js +18 -6
- package/dist/server/virtual-tui.js +258 -0
- package/dist/server/webui-context.js +109 -4
- package/package.json +7 -1
- package/web/dist/assets/TerminalPanel-Dk8E4DaC.js +3 -0
- package/web/dist/assets/index-CYQdZEbx.css +1 -0
- package/web/dist/assets/index-Pl0V0tEL.js +680 -0
- package/web/dist/index.html +4 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/TerminalPanel-CYGOzbPT.js +0 -3
- package/web/dist/assets/index-CP71PHb6.js +0 -680
- package/web/dist/assets/index-ytRwL6j0.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,32 @@
|
|
|
10
10
|
|
|
11
11
|
## [Unreleased]
|
|
12
12
|
|
|
13
|
+
## [0.103.1] — 2026-10-11
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **终端退出事件分发与冒烟测试就绪状态加固** —— 修复 `TerminalManager` 在监听到底层 PTY 进程退出(`pty.onExit`)时因提前置位 `entry.exited` 导致 `exit()` 方法首行守卫误拦截,使得 `terminal_exit` 事件无法分发至客户端的缺陷;加固 `terminal-smoke-test` 中子进程创建与命令回显的异步轮询等待,确保不同平台与慢速 CI 环境下测试结果确定性。
|
|
18
|
+
|
|
19
|
+
## [0.103.0] — 2026-10-11
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **远程工作区支持(Remote SSH Workspace)** —— 支持通过 `ssh://[user@]host[:port]/path` URI 直接连接远程 Linux/Unix 主机作为当前对话的工作区;本地提供安全的工作区会话投影(`remote-workspaces/<slug>`),所有对话记录、草稿与运行数据 100% 在本地安全落盘;文件服务、SCM 版本管理、终端 PTY、只读探测与文件读写工具全面原生适配远程执行。
|
|
24
|
+
- **远程主机配置与环境探针(Remote Host & Probe)** —— 目录浏览器新增远程 SSH 模式;支持保存并管理多个远程连接配置;连接建立后自动探测远端系统架构及 Git / Node / Bash 基础工具安装情况,并提供工具缺失一键自动安装引导;支持直接浏览远程服务器文件树并一键打开作为工作区。
|
|
25
|
+
- **虚拟 TUI 交互浮层(Virtual TUI Modal & Bridge)** —— 终端管理器新增虚拟 TUI 浮层支持;当工具启动交互式命令行或全屏终端应用时,Web 前端自动唤起全屏/半屏 TUI 交互弹窗,无缝桥接键盘输入与屏幕缓冲区渲染。
|
|
26
|
+
- **官网与文档中心导航指引** —— README 首页新增 pi-web-ui 官方网站与详细文档中心快捷访问链接。
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- **会话物理路径与远程目录解析健壮性** —— 修复在部分未初始化或 mock 状态下 `stateStore` 访问异常的问题,并在非远程工作区场景提供零损耗快速回退。
|
|
31
|
+
- **样式与 CSS 变量兼容性修复** —— 统一目录浏览器 SSH 相关面板的 Hover 高亮样式为系统标准 `--bg-elev2`,消除未定义变量告警。
|
|
32
|
+
|
|
33
|
+
<!-- auto-i18n:start -->
|
|
34
|
+
### i18n
|
|
35
|
+
|
|
36
|
+
- 前端新增 key(21):`workspaceModeLocal`、`workspaceModeRemote`、`sshHost`、`sshPort`、`sshUser`、`sshAuthType`、`sshPassword`、`sshKeyPath`、`sshAgent`、`sshSaveProfile`、`sshProfileName`、`sshConnectAndProbe`、`sshConnecting`、`sshSavedProfiles`、`sshInstallTool`、`sshInstalling`、`sshSkipAndBrowse`、`sshOpenRemoteWorkspace`、`sshDisconnect`、`sshDeleteProfileConfirm`、`tuiOverlayTitle`
|
|
37
|
+
<!-- auto-i18n:end -->
|
|
38
|
+
|
|
13
39
|
## [0.102.0] — 2026-10-10
|
|
14
40
|
|
|
15
41
|
### Added
|
|
@@ -1583,6 +1609,9 @@ when?, children?}`,也收 `topbar` / `settings` 这类简写别名);宿主
|
|
|
1583
1609
|
- 0.29.0(2026-08-23):全局搜索弹窗(Ctrl+K)+ 消息列表惰性窗口化。
|
|
1584
1610
|
|
|
1585
1611
|
[Unreleased]: https://github.com/xing-shuyin/pi-web-ui/compare/v0.101.0...main
|
|
1612
|
+
[0.103.1]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.1
|
|
1613
|
+
[0.103.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.103.0
|
|
1614
|
+
[0.102.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.102.0
|
|
1586
1615
|
[0.101.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.101.0
|
|
1587
1616
|
[0.100.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.100.0
|
|
1588
1617
|
[0.99.0]: https://github.com/xing-shuyin/pi-web-ui/releases/tag/v0.99.0
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# 💬 pi-web-ui
|
|
4
4
|
|
|
5
|
-
**English** | [简体中文](https://github.com/xing-shuyin/pi-web-ui/blob/main/README.zh-CN.md)
|
|
5
|
+
**English** | [简体中文](https://github.com/xing-shuyin/pi-web-ui/blob/main/README.zh-CN.md) · 🌐 [**Official Website**](https://xing-shuyin.github.io/pi-web-ui-site/) · 📖 [**Documentation Portal**](https://xing-shuyin.github.io/pi-web-ui-site/docs.html)
|
|
6
6
|
|
|
7
7
|
_Just open your browser — get all your work done._
|
|
8
8
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-web-ui
|
|
2
2
|
|
|
3
|
-
[English](https://github.com/xing-shuyin/pi-web-ui/blob/main/README.md) | **简体中文**
|
|
3
|
+
[English](https://github.com/xing-shuyin/pi-web-ui/blob/main/README.md) | **简体中文** · 🌐 [**官方网站**](https://xing-shuyin.github.io/pi-web-ui-site/) · 📖 [**详细文档中心**](https://xing-shuyin.github.io/pi-web-ui-site/docs.html)
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/pi-web-ui)
|
|
6
6
|
[](https://nodejs.org/)
|
|
@@ -21,6 +21,7 @@ import { toServiceInfo, launchOrigin } from "./launch-origin.js";
|
|
|
21
21
|
import { isPseudoClientId, checkPluginCwd } from "./client-id-utils.js";
|
|
22
22
|
import { pickAdoptableOrphan } from "./orphan-manager.js";
|
|
23
23
|
import { piSessionsRoot } from "./session-search.js";
|
|
24
|
+
import { isRemoteWorkspaceUri, resolveWorkspaceSessionDir } from "./remote-ssh-service.js";
|
|
24
25
|
import { MAX_OPEN_CONVERSATIONS } from "./agent-formatters.js";
|
|
25
26
|
import { collectSubagentDescendantIds } from "./subagents.js";
|
|
26
27
|
import { pickLatestClientSnapshot } from "./plugin-conversation-view.js";
|
|
@@ -1067,16 +1068,21 @@ export class AgentService {
|
|
|
1067
1068
|
let cwd = this.cwd;
|
|
1068
1069
|
const saved = this.stateStore.get(clientId);
|
|
1069
1070
|
if (saved.lastCwd && saved.lastCwd !== this.cwd) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
// autofs 触发点)上会在内核里挂起,冻住整个事件循环(含控制
|
|
1073
|
-
// socket 与其他客户端的心跳);异步版本只挡本连接,超时提示照发。
|
|
1074
|
-
const { stat } = await import("node:fs/promises");
|
|
1075
|
-
if ((await stat(saved.lastCwd)).isDirectory())
|
|
1076
|
-
cwd = saved.lastCwd;
|
|
1071
|
+
if (isRemoteWorkspaceUri(saved.lastCwd)) {
|
|
1072
|
+
cwd = saved.lastCwd;
|
|
1077
1073
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1074
|
+
else {
|
|
1075
|
+
try {
|
|
1076
|
+
// issue #295:异步 stat —— 同步 stat 落在坏挂载(已卸载的外部卷/
|
|
1077
|
+
// autofs 触发点)上会在内核里挂起,冻住整个事件循环(含控制
|
|
1078
|
+
// socket 与其他客户端的心跳);异步版本只挡本连接,超时提示照发。
|
|
1079
|
+
const { stat } = await import("node:fs/promises");
|
|
1080
|
+
if ((await stat(saved.lastCwd)).isDirectory())
|
|
1081
|
+
cwd = saved.lastCwd;
|
|
1082
|
+
}
|
|
1083
|
+
catch {
|
|
1084
|
+
// gone (unmounted drive / deleted / hanging mount) — fall back to the default
|
|
1085
|
+
}
|
|
1080
1086
|
}
|
|
1081
1087
|
}
|
|
1082
1088
|
// Sessions use the SDK default per-project dir — no per-client dir.
|
|
@@ -1087,7 +1093,8 @@ export class AgentService {
|
|
|
1087
1093
|
let createOpts;
|
|
1088
1094
|
if (this.clients.size > 0) {
|
|
1089
1095
|
try {
|
|
1090
|
-
const
|
|
1096
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore.dataDir, cwd);
|
|
1097
|
+
const infos = await SessionManager.list(sessionBaseDir, piSessionsRoot());
|
|
1091
1098
|
const recent = infos[0]?.path ? resolve(infos[0].path) : undefined;
|
|
1092
1099
|
const owner = recent ? this.findSessionOwner(recent, clientId) : null;
|
|
1093
1100
|
if (owner) {
|
|
@@ -24,7 +24,7 @@ import { homedir } from "node:os";
|
|
|
24
24
|
import { basename, delimiter, dirname, join, resolve, sep } from "node:path";
|
|
25
25
|
import { fileURLToPath } from "node:url";
|
|
26
26
|
import { writeAtomicSync } from "./atomic-file.js";
|
|
27
|
-
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createBashToolDefinition, createCodemodeExtension, createEditToolDefinition, createLocalBashOperations, createToolSearchExtension, createWriteToolDefinition, getAgentDir, SessionManager, VERSION, estimateTokens, } from "@earendil-works/pi-coding-agent";
|
|
27
|
+
import { createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createBashToolDefinition, createCodemodeExtension, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createToolSearchExtension, createWriteToolDefinition, getAgentDir, SessionManager, VERSION, estimateTokens, } from "@earendil-works/pi-coding-agent";
|
|
28
28
|
import { Type } from "typebox";
|
|
29
29
|
import { BG_CLEANUP_FALLBACK_MIN, BgServerTracker } from "./bg-servers.js";
|
|
30
30
|
import { checkAll as checkAllUpdates, collectTargets, compareVersions as compareSemver, detectPiSdkSplit, resolveNpmRegistry, sortUpdateItems, } from "./update-check.js";
|
|
@@ -46,6 +46,7 @@ import { MarkerService } from "./marker-service.js";
|
|
|
46
46
|
import { SlashCommandsService, parseSlash } from "./slash-commands.js";
|
|
47
47
|
import { ModelAdminService } from "./model-admin.js";
|
|
48
48
|
import { FilesService, MACHINE_ROOT, desktopDirWire, workspacePath } from "./files-service.js";
|
|
49
|
+
import { buildRemoteWorkspacePersona, createRemoteSdkOperations, formatCwdForPrompt, getGlobalRemoteSshService, isRemoteWorkspaceUri, RemoteSshService, resolveWorkspaceSessionDir, restoreWorkspaceUriFromSessionDir, setGlobalRemoteSshService, } from "./remote-ssh-service.js";
|
|
49
50
|
import { DEFAULT_TOOL_WATCHDOG_TIMEOUT_MS, effectiveToolWatchdogMs, isExtensionDisabled, isExtensionEnabled, normalizeDisabledPluginTools, normalizePathKey, normalizeRetryMaxAttempts, normalizeSkillList, ClientStateStore, } from "./client-state.js";
|
|
50
51
|
import { pick, resolveServerLang } from "./i18n.js";
|
|
51
52
|
import { SubagentTemplatesStore, pickTemplatePrompt } from "./subagent-templates.js";
|
|
@@ -454,10 +455,11 @@ export class ClientSession {
|
|
|
454
455
|
const spawnerSession = spawner?.session ?? this.session;
|
|
455
456
|
const baseCwd = spawner?.cwd ?? this.cwd;
|
|
456
457
|
// 相对 cwd 按派发者所在目录解析:直接透传会相对 server 进程 cwd 落到别处。
|
|
457
|
-
const resolvedCwd = cwd ? resolve(baseCwd, cwd) : baseCwd;
|
|
458
|
+
const resolvedCwd = isRemoteWorkspaceUri(baseCwd) ? baseCwd : cwd ? resolve(baseCwd, cwd) : baseCwd;
|
|
459
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, resolvedCwd);
|
|
458
460
|
const conversationId = persist ? `conv-${randomUUID().slice(0, 8)}` : `sa-${randomUUID().slice(0, 8)}`;
|
|
459
461
|
const terminals = this.makeTerminalManager(conversationId, resolvedCwd);
|
|
460
|
-
const sessionManager = persist ? SessionManager.create(
|
|
462
|
+
const sessionManager = persist ? SessionManager.create(sessionBaseDir) : SessionManager.inMemory(sessionBaseDir);
|
|
461
463
|
if (!persist) {
|
|
462
464
|
// 为内存子代理提供隔离的临时运行目录(供 SoL-Pi 等依赖 getSessionDir 的扩展正常放置缓存),
|
|
463
465
|
// 但保持 persist = false(不写 .jsonl 对话文件、不污染历史记录)
|
|
@@ -469,11 +471,12 @@ export class ClientSession {
|
|
|
469
471
|
catch { }
|
|
470
472
|
}
|
|
471
473
|
const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(terminals, apply, conversationId), {
|
|
472
|
-
cwd:
|
|
474
|
+
cwd: sessionBaseDir,
|
|
473
475
|
agentDir: this.agentDir,
|
|
474
476
|
sessionManager,
|
|
475
477
|
});
|
|
476
478
|
const conv = this.makeConversation(runtime, conversationId, terminals);
|
|
479
|
+
conv.cwd = resolvedCwd;
|
|
477
480
|
conv.isSubagent = !persist;
|
|
478
481
|
// 父对话 = 真正派发它的会话(按会话归属的 host 包装填入)。直接用 active
|
|
479
482
|
// 会错:后台对话运行时用户可能正看着别的项目对话,孩子会被记到无关
|
|
@@ -1004,8 +1007,10 @@ export class ClientSession {
|
|
|
1004
1007
|
this.noteSkillCatalogDigest(src.skills);
|
|
1005
1008
|
const showSkills = presetShowsSkillCatalog(preset);
|
|
1006
1009
|
const effectiveSkills = showSkills ? this.fillSkillContents(src.skills) : [];
|
|
1010
|
+
const realCwd = restoreWorkspaceUriFromSessionDir(src.cwd);
|
|
1011
|
+
const isRemote = isRemoteWorkspaceUri(realCwd);
|
|
1007
1012
|
return {
|
|
1008
|
-
cwd:
|
|
1013
|
+
cwd: formatCwdForPrompt(realCwd),
|
|
1009
1014
|
systemPromptFile: this.lastBaseSystemPrompt || undefined,
|
|
1010
1015
|
builtinSoul: BUILTIN_SOUL,
|
|
1011
1016
|
selectedTools: src.selectedTools,
|
|
@@ -1018,7 +1023,11 @@ export class ClientSession {
|
|
|
1018
1023
|
piDocs: PI_DOC_PATHS.docs,
|
|
1019
1024
|
piExamples: PI_DOC_PATHS.examples,
|
|
1020
1025
|
appendFiles: this.lastSdkAppendFiles,
|
|
1021
|
-
windowsPersona:
|
|
1026
|
+
windowsPersona: isRemote
|
|
1027
|
+
? buildRemoteWorkspacePersona(realCwd)
|
|
1028
|
+
: process.platform === "win32"
|
|
1029
|
+
? WINDOWS_PERSONA
|
|
1030
|
+
: "",
|
|
1022
1031
|
terminalGuidance: isTerminalGuidanceOn(effectiveDisabledAgentTools(this.settingsSvc.current), preset)
|
|
1023
1032
|
? TERMINAL_TOOLS_GUIDANCE
|
|
1024
1033
|
: "",
|
|
@@ -1757,6 +1766,10 @@ export class ClientSession {
|
|
|
1757
1766
|
static async create(clientId, cwd, stateStore, opts) {
|
|
1758
1767
|
const agentDir = process.env.PI_CODING_AGENT_DIR ?? getAgentDir();
|
|
1759
1768
|
const cs = new ClientSession(clientId, cwd, agentDir, stateStore);
|
|
1769
|
+
if (!getGlobalRemoteSshService()) {
|
|
1770
|
+
setGlobalRemoteSshService(new RemoteSshService(stateStore.dataDir));
|
|
1771
|
+
}
|
|
1772
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(stateStore.dataDir, cwd);
|
|
1760
1773
|
const conversationId = cs.nextConversationId();
|
|
1761
1774
|
const terminals = cs.makeTerminalManager(conversationId, cwd);
|
|
1762
1775
|
// Resume the most recent session for this project — the SDK default
|
|
@@ -1765,11 +1778,11 @@ export class ClientSession {
|
|
|
1765
1778
|
// issue #145: opts.blank = 跳过恢复(最近那条在别处跑着),直接空白新对话。
|
|
1766
1779
|
// issue #235:坏转录(重复压缩标记成环)修一次再试,否则整项目首屏
|
|
1767
1780
|
// "Failed to initialize session"。
|
|
1768
|
-
const opened = await cs.openManagerAndRuntime(() => (opts?.blank ? SessionManager.create(
|
|
1769
|
-
cwd,
|
|
1781
|
+
const opened = await cs.openManagerAndRuntime(() => (opts?.blank ? SessionManager.create(sessionBaseDir) : SessionManager.continueRecent(sessionBaseDir)), (m) => createAgentSessionRuntime(cs.makeRuntimeFactory(terminals, undefined, conversationId), {
|
|
1782
|
+
cwd: sessionBaseDir,
|
|
1770
1783
|
agentDir,
|
|
1771
1784
|
sessionManager: m,
|
|
1772
|
-
}), async () => (await SessionManager.list(
|
|
1785
|
+
}), async () => (await SessionManager.list(sessionBaseDir))[0]?.path);
|
|
1773
1786
|
const runtime = opened.runtime;
|
|
1774
1787
|
if (opened.repair) {
|
|
1775
1788
|
for (const n of cs.transcriptRepairNotices(opened.repair))
|
|
@@ -1779,6 +1792,7 @@ export class ClientSession {
|
|
|
1779
1792
|
// ModelRuntime that every later conversation reuses.
|
|
1780
1793
|
cs.sharedModelRuntime = runtime.services.modelRuntime;
|
|
1781
1794
|
const conv = cs.makeConversation(runtime, conversationId, terminals);
|
|
1795
|
+
conv.cwd = cwd;
|
|
1782
1796
|
cs.convs.set(conv.id, conv);
|
|
1783
1797
|
cs.activeId = conv.id;
|
|
1784
1798
|
for (const d of runtime.diagnostics) {
|
|
@@ -1943,7 +1957,13 @@ export class ClientSession {
|
|
|
1943
1957
|
if (this.delegateModeOf(ownerId) && !this.planModeOf(ownerId)) {
|
|
1944
1958
|
out.push(DELEGATION_SYSTEM_PROMPT);
|
|
1945
1959
|
}
|
|
1946
|
-
|
|
1960
|
+
const realCwd = restoreWorkspaceUriFromSessionDir(effectiveCwd);
|
|
1961
|
+
if (isRemoteWorkspaceUri(realCwd)) {
|
|
1962
|
+
// 远程 SSH 工作区:明确告知 AI 当前处于远程主机以及所有工具已透明桥接至远端,
|
|
1963
|
+
// 绝不注入本地 WINDOWS_PERSONA 以免误导模型以为在本地 Windows 环境。
|
|
1964
|
+
out.push(buildRemoteWorkspacePersona(realCwd));
|
|
1965
|
+
}
|
|
1966
|
+
else if (process.platform === "win32") {
|
|
1947
1967
|
// Windows 专属 persona:bash 工具跑 Git Bash 且无默认超时、终端
|
|
1948
1968
|
// 是交互式 TTY——注入约束避免 heredoc/交互/长驻命令挂死整个会话;
|
|
1949
1969
|
// GBK 老中文文件让模型改用终端按正确编码读(iconv/chcp/Get-Content)。
|
|
@@ -2065,8 +2085,10 @@ export class ClientSession {
|
|
|
2065
2085
|
}
|
|
2066
2086
|
const currentPreset = conv?.agentPreset ?? targetPreset ?? this.settingsSvc.current.defaultAgentPreset ?? "standard";
|
|
2067
2087
|
const opts = event.systemPromptOptions;
|
|
2088
|
+
const rawCwdForPrompt = typeof opts?.cwd === "string" ? opts.cwd : (conv?.cwd ?? effectiveCwd ?? this.cwd);
|
|
2089
|
+
const realCwdForPrompt = restoreWorkspaceUriFromSessionDir(rawCwdForPrompt);
|
|
2068
2090
|
const rendered = this.renderMainCompose({
|
|
2069
|
-
cwd:
|
|
2091
|
+
cwd: realCwdForPrompt,
|
|
2070
2092
|
selectedTools: baseNames.length > 0 ? baseNames : (opts?.selectedTools ?? []),
|
|
2071
2093
|
toolSnippets: activeSnippets,
|
|
2072
2094
|
toolSignatures: activeSignatures,
|
|
@@ -2080,8 +2102,17 @@ export class ClientSession {
|
|
|
2080
2102
|
})),
|
|
2081
2103
|
preset: currentPreset,
|
|
2082
2104
|
});
|
|
2083
|
-
|
|
2084
|
-
|
|
2105
|
+
if (rendered) {
|
|
2106
|
+
return { systemPrompt: rewrap(rendered) };
|
|
2107
|
+
}
|
|
2108
|
+
// 未自定义模板但处于远程工作区时,将 SDK 默认提示词里的本地缓存目录替换为远程真实目录
|
|
2109
|
+
if (isRemoteWorkspaceUri(realCwdForPrompt)) {
|
|
2110
|
+
const patchedCore = core.replace(/Current working directory:\s*[^\r\n]+/, `Current working directory: ${formatCwdForPrompt(realCwdForPrompt)}`);
|
|
2111
|
+
if (patchedCore !== core) {
|
|
2112
|
+
return { systemPrompt: rewrap(patchedCore) };
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
return undefined;
|
|
2085
2116
|
});
|
|
2086
2117
|
},
|
|
2087
2118
|
},
|
|
@@ -2334,7 +2365,7 @@ export class ClientSession {
|
|
|
2334
2365
|
isSubagent: false,
|
|
2335
2366
|
runtime,
|
|
2336
2367
|
session: runtime.session,
|
|
2337
|
-
cwd: runtime.cwd,
|
|
2368
|
+
cwd: restoreWorkspaceUriFromSessionDir(runtime.cwd),
|
|
2338
2369
|
createdAt: Date.now(),
|
|
2339
2370
|
agentPreset: this.settingsSvc.current.defaultAgentPreset ?? "standard",
|
|
2340
2371
|
presetLocked: false,
|
|
@@ -4007,6 +4038,15 @@ export class ClientSession {
|
|
|
4007
4038
|
resolveDialog(id, value) {
|
|
4008
4039
|
this.webUi.resolveDialog(id, value);
|
|
4009
4040
|
}
|
|
4041
|
+
handleTuiOverlayInput(id, data) {
|
|
4042
|
+
this.webUi.handleTuiOverlayInput(id, data);
|
|
4043
|
+
}
|
|
4044
|
+
handleTuiOverlayResize(id, cols, rows) {
|
|
4045
|
+
this.webUi.handleTuiOverlayResize(id, cols, rows);
|
|
4046
|
+
}
|
|
4047
|
+
handleTuiOverlayCancel(id) {
|
|
4048
|
+
this.webUi.handleTuiOverlayCancel(id);
|
|
4049
|
+
}
|
|
4010
4050
|
// -----------------------------------------------------------------------
|
|
4011
4051
|
// 用户提问桥(标准 pi 引擎 ask_user_question customTool)
|
|
4012
4052
|
// -----------------------------------------------------------------------
|
|
@@ -6033,7 +6073,8 @@ export class ClientSession {
|
|
|
6033
6073
|
const planGate = (def) => withGoalReviewGate(withDelegationGate(withPlanModeGate(def, () => this.planModeOf(ownerId), () => this.getLang()), () => this.delegateModeOf(ownerId), () => this.getLang()), () => this.goalReviewTurnOf(ownerId), () => this.getLang());
|
|
6034
6074
|
const composeWrite = (base) => planGate(wrapWriteToolWithPermission(cwd, currentPermission, () => this.roots, () => this.getLang(), approve, () => ownerId, () => this.approvalRules.list(), base));
|
|
6035
6075
|
const composeEdit = (base) => planGate(wrapEditToolWithPermission(cwd, currentPermission, () => this.roots, () => this.getLang(), approve, () => ownerId, () => this.approvalRules.list(), base));
|
|
6036
|
-
|
|
6076
|
+
const remoteOps = createRemoteSdkOperations(cwd);
|
|
6077
|
+
const specs = [
|
|
6037
6078
|
{
|
|
6038
6079
|
name: "read",
|
|
6039
6080
|
// 没有扩展 read:完整覆盖(内置基底 + 英文描述 + file_path 别名)。
|
|
@@ -6048,13 +6089,35 @@ export class ClientSession {
|
|
|
6048
6089
|
// guidelines 逐条复述(唯一/合并/不要垫大段未改区域都说两遍)。只改描述,保留 SDK 的
|
|
6049
6090
|
// 参数 schema / guidelines / 执行体;有扩展 edit 时(composeWith)一律不动它的文案。
|
|
6050
6091
|
fallback: () => composeEdit({
|
|
6051
|
-
...createEditToolDefinition(cwd),
|
|
6092
|
+
...createEditToolDefinition(cwd, remoteOps ? { operations: remoteOps.edit } : undefined),
|
|
6052
6093
|
description: EDIT_DESCRIPTION,
|
|
6053
6094
|
promptGuidelines: EDIT_GUIDELINES,
|
|
6054
6095
|
}),
|
|
6055
6096
|
composeWith: (base) => composeEdit(base),
|
|
6056
6097
|
},
|
|
6057
6098
|
];
|
|
6099
|
+
if (remoteOps) {
|
|
6100
|
+
specs.push({
|
|
6101
|
+
name: "ls",
|
|
6102
|
+
fallback: () => createLsToolDefinition(cwd, { operations: remoteOps.ls }),
|
|
6103
|
+
}, {
|
|
6104
|
+
name: "find",
|
|
6105
|
+
fallback: () => createFindToolDefinition(cwd, { operations: remoteOps.find }),
|
|
6106
|
+
}, {
|
|
6107
|
+
name: "grep",
|
|
6108
|
+
fallback: () => {
|
|
6109
|
+
const baseGrep = createGrepToolDefinition(cwd);
|
|
6110
|
+
return {
|
|
6111
|
+
...baseGrep,
|
|
6112
|
+
execute: async (_id, params) => {
|
|
6113
|
+
const text = await remoteOps.grepExecute(params ?? {});
|
|
6114
|
+
return { content: [{ type: "text", text }], details: undefined };
|
|
6115
|
+
},
|
|
6116
|
+
};
|
|
6117
|
+
},
|
|
6118
|
+
});
|
|
6119
|
+
}
|
|
6120
|
+
return specs;
|
|
6058
6121
|
}
|
|
6059
6122
|
/** 统一工具门控(tool_manage 唯一落点):按 disabledAgentTools 把目录内工具
|
|
6060
6123
|
* 逐个加回/剔除活跃集(工具仍留在注册表,重开可直接加回;live 生效无需
|
|
@@ -7669,16 +7732,17 @@ export class ClientSession {
|
|
|
7669
7732
|
// #280 & #335:转录链损坏时修一次再试(见 openManagerAndRuntime)。
|
|
7670
7733
|
// 严禁在 ownFile 不存在时回退到 continueRecent(conv.cwd) 或按 mtime list 历史文件,
|
|
7671
7734
|
// 否则会直接接错并顶替同项目的其它历史会话,污染别人的转录记录。
|
|
7735
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, conv.cwd);
|
|
7672
7736
|
const opened = await this.openManagerAndRuntime(() => {
|
|
7673
7737
|
if (ownFile && existsSync(ownFile)) {
|
|
7674
7738
|
return SessionManager.open(ownFile);
|
|
7675
7739
|
}
|
|
7676
|
-
return conv.isEphemeral ? SessionManager.inMemory(
|
|
7740
|
+
return conv.isEphemeral ? SessionManager.inMemory(sessionBaseDir) : SessionManager.create(sessionBaseDir);
|
|
7677
7741
|
}, (m) =>
|
|
7678
7742
|
// 子代理带模板时按原模板重建(conv.subagentTemplate 是派发时工厂
|
|
7679
7743
|
// 用的同一快照);普通对话 undefined,行为不变。
|
|
7680
7744
|
createAgentSessionRuntime(this.makeRuntimeFactory(conv.terminals, conv.subagentTemplate, conv.id), {
|
|
7681
|
-
cwd:
|
|
7745
|
+
cwd: sessionBaseDir,
|
|
7682
7746
|
agentDir: this.agentDir,
|
|
7683
7747
|
sessionManager: m,
|
|
7684
7748
|
}), async () => (ownFile && existsSync(ownFile) ? ownFile : undefined));
|
|
@@ -7818,9 +7882,10 @@ export class ClientSession {
|
|
|
7818
7882
|
try {
|
|
7819
7883
|
const conversationId = this.nextConversationId();
|
|
7820
7884
|
const terminals = this.makeTerminalManager(conversationId, this.cwd);
|
|
7885
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, this.cwd);
|
|
7821
7886
|
let sessionManager;
|
|
7822
7887
|
if (ephemeral) {
|
|
7823
|
-
sessionManager = SessionManager.inMemory(
|
|
7888
|
+
sessionManager = SessionManager.inMemory(sessionBaseDir);
|
|
7824
7889
|
// 为无痕临时会话提供隔离的临时运行目录(供 SoL-Pi 等依赖 getSessionDir 的扩展正常放置缓存),
|
|
7825
7890
|
// 但保持 persist = false(不写 .jsonl 对话文件、不污染历史记录)
|
|
7826
7891
|
const ephemeralDir = join(this.agentDir, "ephemeral-sessions", conversationId);
|
|
@@ -7831,14 +7896,15 @@ export class ClientSession {
|
|
|
7831
7896
|
catch { }
|
|
7832
7897
|
}
|
|
7833
7898
|
else {
|
|
7834
|
-
sessionManager = SessionManager.create(
|
|
7899
|
+
sessionManager = SessionManager.create(sessionBaseDir);
|
|
7835
7900
|
}
|
|
7836
7901
|
const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(terminals, undefined, conversationId, prevModel ?? undefined, _preset), {
|
|
7837
|
-
cwd:
|
|
7902
|
+
cwd: sessionBaseDir,
|
|
7838
7903
|
agentDir: this.agentDir,
|
|
7839
7904
|
sessionManager,
|
|
7840
7905
|
});
|
|
7841
7906
|
const conv = this.makeConversation(runtime, conversationId, terminals);
|
|
7907
|
+
conv.cwd = this.cwd;
|
|
7842
7908
|
if (ephemeral)
|
|
7843
7909
|
conv.isEphemeral = true;
|
|
7844
7910
|
if (_preset) {
|
|
@@ -8895,11 +8961,12 @@ export class ClientSession {
|
|
|
8895
8961
|
const inFlight = ClientSession.sessionInfosInFlight.get(cwdKey);
|
|
8896
8962
|
if (inFlight)
|
|
8897
8963
|
return inFlight;
|
|
8964
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, this.cwd);
|
|
8898
8965
|
const run = (async () => {
|
|
8899
8966
|
try {
|
|
8900
8967
|
const sessionDir = piSessionsRoot()
|
|
8901
8968
|
? resolve(piSessionsRoot())
|
|
8902
|
-
: SessionManager.create(
|
|
8969
|
+
: SessionManager.create(sessionBaseDir).getSessionDir();
|
|
8903
8970
|
if (!existsSync(sessionDir))
|
|
8904
8971
|
return [];
|
|
8905
8972
|
const dirEntries = await fsPromises.readdir(sessionDir);
|
|
@@ -8936,16 +9003,8 @@ export class ClientSession {
|
|
|
8936
9003
|
return info;
|
|
8937
9004
|
}));
|
|
8938
9005
|
const validInfos = results.filter((info) => info !== null);
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
// 「历史会话」列表,点开即把整个工作区切走。与 SessionManager.list(cwd, ...) 的
|
|
8942
|
-
// fallback 及 discoverRecentProjectsFromDisk 同口径:normalizePathKey(Windows
|
|
8943
|
-
// 大小写/斜杠归一)。空 cwd 的损坏文件须排除——normalizePathKey("") 会 resolve 到
|
|
8944
|
-
// process.cwd(),恰好等于本项目时会把垃圾文件误收进来。
|
|
8945
|
-
const ownInfos = validInfos.filter((info) => info.cwd !== "" && normalizePathKey(info.cwd) === cwdKey);
|
|
8946
|
-
// 200 名额只在 cwd 过滤**之后**分配:扁平布局下若先截断,本项目会话可能被
|
|
8947
|
-
// 其他项目的文件挤出列表。截断仍按上面的 mtime 降序序取(Promise.all 保序),
|
|
8948
|
-
// 与原有选集口径一致;非扁平布局每-cwd 子目录内文件全属本项目,过滤幂等。
|
|
9006
|
+
const baseDirKey = normalizePathKey(sessionBaseDir);
|
|
9007
|
+
const ownInfos = validInfos.filter((info) => info.cwd !== "" && (normalizePathKey(info.cwd) === cwdKey || normalizePathKey(info.cwd) === baseDirKey));
|
|
8949
9008
|
const candidates = ownInfos.slice(0, 200);
|
|
8950
9009
|
candidates.sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
8951
9010
|
ClientSession.sessionInfosCache.set(cwdKey, { infos: candidates, at: Date.now() });
|
|
@@ -8953,7 +9012,7 @@ export class ClientSession {
|
|
|
8953
9012
|
}
|
|
8954
9013
|
catch {
|
|
8955
9014
|
try {
|
|
8956
|
-
const fallback = await SessionManager.list(
|
|
9015
|
+
const fallback = await SessionManager.list(sessionBaseDir, piSessionsRoot());
|
|
8957
9016
|
// 统一口径:列表缓存一律不带转录全文(issue #440),搜索按需另行加载
|
|
8958
9017
|
const stripped = fallback.map((s) => ({ ...s, allMessagesText: "" }));
|
|
8959
9018
|
ClientSession.sessionInfosCache.set(cwdKey, { infos: stripped, at: Date.now() });
|
|
@@ -9380,7 +9439,8 @@ export class ClientSession {
|
|
|
9380
9439
|
const wasEphemeral = !!conv.isEphemeral;
|
|
9381
9440
|
try {
|
|
9382
9441
|
const cwd = conv.cwd || this.cwd;
|
|
9383
|
-
const
|
|
9442
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, cwd);
|
|
9443
|
+
const sampleSm = SessionManager.create(sessionBaseDir);
|
|
9384
9444
|
const sessionDir = sampleSm.getSessionDir();
|
|
9385
9445
|
if (!existsSync(sessionDir)) {
|
|
9386
9446
|
mkdirSync(sessionDir, { recursive: true });
|
|
@@ -9984,11 +10044,13 @@ export class ClientSession {
|
|
|
9984
10044
|
this.repairTranscriptFileBeforeOpen(targetPath);
|
|
9985
10045
|
const sessionManager = SessionManager.open(targetPath);
|
|
9986
10046
|
calibrateSessionLeaf(sessionManager);
|
|
9987
|
-
const
|
|
10047
|
+
const rawSessionCwd = sessionManager.getCwd();
|
|
10048
|
+
const targetCwd = restoreWorkspaceUriFromSessionDir(rawSessionCwd);
|
|
10049
|
+
const runtimeCwd = resolveWorkspaceSessionDir(this.stateStore?.dataDir, targetCwd);
|
|
9988
10050
|
const conversationId = this.nextConversationId();
|
|
9989
10051
|
openedTerminals = this.makeTerminalManager(conversationId, targetCwd);
|
|
9990
10052
|
openedRuntime = await createAgentSessionRuntime(this.makeRuntimeFactory(openedTerminals, undefined, conversationId), {
|
|
9991
|
-
cwd:
|
|
10053
|
+
cwd: runtimeCwd,
|
|
9992
10054
|
agentDir: this.agentDir,
|
|
9993
10055
|
sessionManager,
|
|
9994
10056
|
});
|
|
@@ -10124,12 +10186,13 @@ export class ClientSession {
|
|
|
10124
10186
|
const prevThinking = targetConv.session.thinkingLevel ?? null;
|
|
10125
10187
|
const conversationId = this.nextConversationId();
|
|
10126
10188
|
const terminals = this.makeTerminalManager(conversationId, targetConv.cwd);
|
|
10189
|
+
const sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, targetConv.cwd);
|
|
10127
10190
|
let forkedManager;
|
|
10128
10191
|
if (isPersisted) {
|
|
10129
10192
|
const sessionDir = targetConv.session.sessionManager.getSessionDir();
|
|
10130
10193
|
let forkedSessionPath;
|
|
10131
10194
|
if (!targetLeafId) {
|
|
10132
|
-
const sm = SessionManager.create(
|
|
10195
|
+
const sm = SessionManager.create(sessionBaseDir, sessionDir);
|
|
10133
10196
|
sm.newSession({ parentSession: currentSessionFile });
|
|
10134
10197
|
forkedSessionPath = sm.getSessionFile();
|
|
10135
10198
|
}
|
|
@@ -10144,7 +10207,7 @@ export class ClientSession {
|
|
|
10144
10207
|
calibrateSessionLeaf(forkedManager);
|
|
10145
10208
|
}
|
|
10146
10209
|
else {
|
|
10147
|
-
forkedManager = SessionManager.create(
|
|
10210
|
+
forkedManager = SessionManager.create(sessionBaseDir);
|
|
10148
10211
|
if (targetLeafId) {
|
|
10149
10212
|
const branch = targetConv.session.sessionManager.getBranch(targetLeafId);
|
|
10150
10213
|
for (const e of branch) {
|
|
@@ -10160,7 +10223,7 @@ export class ClientSession {
|
|
|
10160
10223
|
}
|
|
10161
10224
|
}
|
|
10162
10225
|
const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(terminals, undefined, conversationId, prevModel ?? undefined), {
|
|
10163
|
-
cwd:
|
|
10226
|
+
cwd: sessionBaseDir,
|
|
10164
10227
|
agentDir: this.agentDir,
|
|
10165
10228
|
sessionManager: forkedManager,
|
|
10166
10229
|
});
|
|
@@ -10712,12 +10775,24 @@ export class ClientSession {
|
|
|
10712
10775
|
});
|
|
10713
10776
|
return;
|
|
10714
10777
|
}
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10778
|
+
const isRemote = isRemoteWorkspaceUri(trimmed);
|
|
10779
|
+
let abs;
|
|
10780
|
+
let sessionBaseDir;
|
|
10781
|
+
if (isRemote) {
|
|
10782
|
+
abs = trimmed;
|
|
10783
|
+
// 远程工作区在本地数据目录下分配隔离的物理会话存储目录,保证所有对话历史、记录 100% 存在本地
|
|
10784
|
+
sessionBaseDir = resolveWorkspaceSessionDir(this.stateStore?.dataDir, abs);
|
|
10785
|
+
}
|
|
10786
|
+
else {
|
|
10787
|
+
// Windows 裸盘符("C:")与相对路径基准的处理收敛到 resolveCwdTarget
|
|
10788
|
+
// (纯函数,含 win32/posix 差异说明与单测)。
|
|
10789
|
+
const baseForResolve = isRemoteWorkspaceUri(this.cwd) ? homedir() : this.cwd;
|
|
10790
|
+
abs = resolveCwdTarget(trimmed, baseForResolve);
|
|
10791
|
+
const st = await fs.stat(abs);
|
|
10792
|
+
if (!st.isDirectory()) {
|
|
10793
|
+
throw new Error("路径不是目录");
|
|
10794
|
+
}
|
|
10795
|
+
sessionBaseDir = abs;
|
|
10721
10796
|
}
|
|
10722
10797
|
if (abs === this.cwd) {
|
|
10723
10798
|
this.emit({
|
|
@@ -10768,7 +10843,7 @@ export class ClientSession {
|
|
|
10768
10843
|
// 别处无可见行时不扫目录(首访切项目的常见情形零开销)。
|
|
10769
10844
|
if ((this.listExternalRunning?.() ?? []).length > 0) {
|
|
10770
10845
|
try {
|
|
10771
|
-
const infos = await SessionManager.list(
|
|
10846
|
+
const infos = await SessionManager.list(sessionBaseDir, piSessionsRoot());
|
|
10772
10847
|
const recent = infos[0]?.path ? resolve(infos[0].path) : undefined;
|
|
10773
10848
|
const owner = recent ? this.findSessionOwner?.(recent) : null;
|
|
10774
10849
|
if (owner) {
|
|
@@ -10783,17 +10858,18 @@ export class ClientSession {
|
|
|
10783
10858
|
const terminals = this.makeTerminalManager(conversationId, abs);
|
|
10784
10859
|
// #235:manager+runtime 一起建,转录链损坏时修最近文件后重试一次
|
|
10785
10860
|
// (见 openManagerAndRuntime)。blank(别处在跑)是全新空会话,不会坏。
|
|
10786
|
-
const opened = await this.openManagerAndRuntime(() => (resumeSkipped ? SessionManager.create(
|
|
10787
|
-
cwd:
|
|
10861
|
+
const opened = await this.openManagerAndRuntime(() => (resumeSkipped ? SessionManager.create(sessionBaseDir) : SessionManager.continueRecent(sessionBaseDir)), (m) => createAgentSessionRuntime(this.makeRuntimeFactory(terminals, undefined, conversationId), {
|
|
10862
|
+
cwd: sessionBaseDir,
|
|
10788
10863
|
agentDir: this.agentDir,
|
|
10789
10864
|
sessionManager: m,
|
|
10790
|
-
}), async () => (await SessionManager.list(
|
|
10865
|
+
}), async () => (await SessionManager.list(sessionBaseDir))[0]?.path);
|
|
10791
10866
|
const newRuntime = opened.runtime;
|
|
10792
10867
|
if (opened.repair) {
|
|
10793
10868
|
for (const n of this.transcriptRepairNotices(opened.repair))
|
|
10794
10869
|
this.emit(n);
|
|
10795
10870
|
}
|
|
10796
10871
|
const conv = this.makeConversation(newRuntime, conversationId, terminals);
|
|
10872
|
+
conv.cwd = abs;
|
|
10797
10873
|
this.convs.set(conv.id, conv);
|
|
10798
10874
|
this.activeId = conv.id;
|
|
10799
10875
|
if (displaced)
|
package/dist/server/bash-tool.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { createBashToolDefinition, createLocalBashOperations, } from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { applyHeadTail } from "./terminals.js";
|
|
11
11
|
import { BASH_DESCRIPTION, BASH_PARAMETERS, BASH_PROMPT_GUIDELINES, BASH_PROMPT_SNIPPET } from "./tool-prompts.js";
|
|
12
|
+
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, restoreWorkspaceUriFromSessionDir, } from "./remote-ssh-service.js";
|
|
12
13
|
/**
|
|
13
14
|
* Killable bash tool: wraps the SDK bash tool (native process spawn, NO terminal).
|
|
14
15
|
* Used when the「默认 bash 覆盖」setting is OFF. Registers its own AbortController
|
|
@@ -28,9 +29,26 @@ lang = () => "en") {
|
|
|
28
29
|
kills.add(ac);
|
|
29
30
|
try {
|
|
30
31
|
const signals = [opts.signal, ac.signal].filter((s) => s !== undefined);
|
|
32
|
+
const combinedSignal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];
|
|
33
|
+
const effCwd = restoreWorkspaceUriFromSessionDir(c || cwd);
|
|
34
|
+
if (isRemoteWorkspaceUri(effCwd)) {
|
|
35
|
+
const sshSvc = getGlobalRemoteSshService();
|
|
36
|
+
if (!sshSvc) {
|
|
37
|
+
throw new Error("Remote SSH service is not initialized");
|
|
38
|
+
}
|
|
39
|
+
const timeoutMs = opts.timeout !== undefined && Number.isFinite(opts.timeout) && opts.timeout > 0
|
|
40
|
+
? opts.timeout * 1000
|
|
41
|
+
: undefined;
|
|
42
|
+
const res = await sshSvc.execInWorkspace(effCwd, command, {
|
|
43
|
+
signal: combinedSignal,
|
|
44
|
+
timeoutMs,
|
|
45
|
+
onData: opts.onData,
|
|
46
|
+
});
|
|
47
|
+
return { exitCode: res.exitCode };
|
|
48
|
+
}
|
|
31
49
|
return await base.exec(command, c, {
|
|
32
50
|
...opts,
|
|
33
|
-
signal:
|
|
51
|
+
signal: combinedSignal,
|
|
34
52
|
});
|
|
35
53
|
}
|
|
36
54
|
finally {
|
|
@@ -358,8 +358,12 @@ export function normalizeWorkspaceRoots(v) {
|
|
|
358
358
|
}
|
|
359
359
|
return out;
|
|
360
360
|
}
|
|
361
|
-
/** 跨平台(尤其是 Windows)路径归一化键:统一转绝对路径,并在 Windows 下转小写以消除大小写与正反斜杠差异。
|
|
361
|
+
/** 跨平台(尤其是 Windows)路径归一化键:统一转绝对路径,并在 Windows 下转小写以消除大小写与正反斜杠差异。
|
|
362
|
+
* 对于 ssh:// 格式的远程工作区 URI 保持原样不走路径解析。 */
|
|
362
363
|
export function normalizePathKey(p) {
|
|
364
|
+
if (p.startsWith("ssh://")) {
|
|
365
|
+
return p;
|
|
366
|
+
}
|
|
363
367
|
try {
|
|
364
368
|
const resolved = resolve(p);
|
|
365
369
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
@@ -643,8 +647,12 @@ export class ClientStateStore {
|
|
|
643
647
|
});
|
|
644
648
|
}
|
|
645
649
|
/** 单条路径的存活性探测(issue #441):异步 access,绝不阻塞事件循环。
|
|
650
|
+
* 远程工作区 URI (ssh://) 始终判定存活,避免被本地 fs.access 过滤掉。
|
|
646
651
|
* 独立成 protected 方法便于单测用子类覆写做计数探针。 */
|
|
647
652
|
async pathExists(path) {
|
|
653
|
+
if (path.startsWith("ssh://")) {
|
|
654
|
+
return true;
|
|
655
|
+
}
|
|
648
656
|
return fsPromises.access(path).then(() => true, () => false);
|
|
649
657
|
}
|
|
650
658
|
/** Record discovered projects into global settings cache (without clobbering tombstones). */
|