pi-web-ui 0.109.0 → 0.111.0
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 +31 -0
- package/README.md +21 -1
- package/README.zh-CN.md +21 -1
- package/README.zh-TW.md +201 -677
- package/bin/frp-manager.mjs +85 -7
- package/dist/server/agent-formatters.js +10 -6
- package/dist/server/agent-service-daemon.js +29 -11
- package/dist/server/agent-service.js +160 -54
- package/dist/server/attachments.js +140 -37
- package/dist/server/canvas/canvas-agent-tool.js +587 -0
- package/dist/server/canvas/canvas-cards.js +144 -0
- package/dist/server/canvas/canvas-dispatch.js +155 -0
- package/dist/server/canvas/canvas-orchestrator.js +1027 -0
- package/dist/server/canvas/canvas-store.js +260 -0
- package/dist/server/client-id-utils.js +2 -2
- package/dist/server/client-state.js +24 -0
- package/dist/server/context-budget.js +6 -3
- package/dist/server/dispatch-domain-handlers.js +2 -0
- package/dist/server/dispatch-plugin-handlers.js +1 -0
- package/dist/server/dsh/dsh-agent-service.js +115 -9
- package/dist/server/dsh/dsh-client.js +10 -1
- package/dist/server/dsh/runtime/goal-rpc.mjs +128 -3
- package/dist/server/dsh/runtime/launcher.mjs +59 -5
- package/dist/server/dsh/runtime/runtime-root.mjs +353 -40
- package/dist/server/durable/durable-agent-service.js +3 -0
- package/dist/server/durable/durable-driver.js +1 -1
- package/dist/server/durable/durable-tools.js +4 -1
- package/dist/server/file-transfer-routes.js +8 -2
- package/dist/server/files-service.js +33 -6
- package/dist/server/goal-service.js +12 -3
- package/dist/server/index.js +175 -13
- package/dist/server/locales.js +33 -0
- package/dist/server/marker-service.js +10 -14
- package/dist/server/markers/builtins/action.js +5 -6
- package/dist/server/markers/builtins/notify.js +2 -2
- package/dist/server/markers/builtins/rename.js +2 -2
- package/dist/server/markers/marker.js +45 -4
- package/dist/server/markers/registry.js +36 -1
- package/dist/server/message-window.js +193 -0
- package/dist/server/model-admin.js +0 -4
- package/dist/server/office-parse.js +394 -7
- package/dist/server/plugin-api-catalog.js +6 -0
- package/dist/server/plugin-catalog-sync.js +10 -2
- package/dist/server/plugin-catalog.js +63 -10
- package/dist/server/plugins.js +144 -26
- package/dist/server/preset-fields.js +35 -1
- package/dist/server/preset-share.js +5 -3
- package/dist/server/process-utils.js +58 -24
- package/dist/server/prompt-assembler.js +7 -1
- package/dist/server/prompt-composer.js +66 -36
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/remote-ssh-service.js +16 -4
- package/dist/server/settings-service.js +24 -3
- package/dist/server/slash-commands.js +16 -4
- package/dist/server/text-sniff.js +10 -7
- package/dist/server/themes.js +36 -1
- package/dist/server/tool-manager.js +30 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/claude-code.js +19 -2
- package/dist/server/universal/drivers/dsh-driver.js +1 -1
- package/dist/server/universal/universal-attachments.js +5 -0
- package/dist/server/universal/universal-service.js +5 -0
- package/dist/server/universal/universal-session.js +38 -15
- package/dist/server/update-check.js +90 -5
- package/dist/server/workspace-snapshot.js +33 -2
- package/dist/server/worktree-service.js +1 -1
- package/docs/dsh-engine.md +497 -0
- package/package.json +11 -5
- package/plugin-sdk/index.d.ts +37 -0
- package/plugin-sdk/index.mjs +19 -0
- package/plugins/catalog.json +44 -2
- package/themes/aetheris.css +263 -118
- package/themes/bases/flow-base.css +1363 -0
- package/themes/bases/obsidian-base.css +895 -0
- package/themes/bases/zhujian-base.css +687 -0
- package/themes/bases/zhupi-base.css +659 -0
- package/themes/flow-light.css +2 -925
- package/themes/flow.css +1 -936
- package/themes/md-preview.css +113 -0
- package/themes/wallpaper-flow.css +251 -1029
- package/themes/wallpaper-obsidian.css +1 -673
- package/themes/zhujian-dark.css +1 -605
- package/themes/zhujian.css +1 -654
- package/themes/zhupi-dark.css +1 -576
- package/themes/zhupi.css +1 -626
- package/web/dist/assets/{TerminalPanel-BD3a9o-a.js → TerminalPanel-BiUNySMA.js} +2 -2
- package/web/dist/assets/index-B0ajS__T.js +697 -0
- package/web/dist/assets/index-BHik5WGG.css +1 -0
- package/web/dist/assets/{markdown-DXwnfD9T.js → markdown-BJZlfvdP.js} +24 -24
- package/web/dist/assets/markdown-DSNUiDzp.css +1 -0
- package/web/dist/index.html +4 -4
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/es-DIDZppIF.js +0 -2
- package/web/dist/assets/index-AccytlpP.css +0 -1
- package/web/dist/assets/index-B3dar1BK.js +0 -690
- package/web/dist/assets/markdown-CCeVCbci.css +0 -1
|
@@ -12,7 +12,7 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
|
12
12
|
import { homedir } from "node:os";
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import { FilesService } from "../files-service.js";
|
|
15
|
-
import { TerminalManager, makePersistentTerminalTools
|
|
15
|
+
import { TerminalManager, makePersistentTerminalTools } from "../terminals.js";
|
|
16
16
|
import { TERMINAL_TOOL_NAMES } from "../tool-manager.js";
|
|
17
17
|
import { BgServerTracker } from "../bg-servers.js";
|
|
18
18
|
import { ModelAdminService } from "../model-admin.js";
|
|
@@ -65,6 +65,9 @@ export class UniversalSession {
|
|
|
65
65
|
activeConvId;
|
|
66
66
|
conversations = new Map();
|
|
67
67
|
isStreaming = false;
|
|
68
|
+
/** 在途回合归属的会话 id(#700/#701):prompt 开始时锚定,finalizeTurn 收尾时消费并清空。
|
|
69
|
+
* 会话切换/回滚不再让流式回写与回合收尾锚错会话,避免跨对话内容污染落盘。 */
|
|
70
|
+
turnConvId = null;
|
|
68
71
|
streamingMessage = null;
|
|
69
72
|
streamingThinking = "";
|
|
70
73
|
streamingText = "";
|
|
@@ -444,8 +447,9 @@ export class UniversalSession {
|
|
|
444
447
|
conversationId: conv.id,
|
|
445
448
|
rev: this.rev,
|
|
446
449
|
messages: conv.messages,
|
|
447
|
-
|
|
448
|
-
|
|
450
|
+
// 回合归属会话才携带流式态:切走后的前台会话快照不再混入后台回合内容(#701)
|
|
451
|
+
streamingMessage: !this.turnConvId || this.turnConvId === conv.id ? this.streamingMessage : null,
|
|
452
|
+
isStreaming: !this.turnConvId || this.turnConvId === conv.id ? this.isStreaming : false,
|
|
449
453
|
isEphemeral: Boolean(conv.isEphemeral),
|
|
450
454
|
draft: this.sessionDrafts.get(conv.id) ?? null,
|
|
451
455
|
model: {
|
|
@@ -548,6 +552,7 @@ export class UniversalSession {
|
|
|
548
552
|
}
|
|
549
553
|
this.isStreaming = true;
|
|
550
554
|
const conv = this.activeConv;
|
|
555
|
+
this.turnConvId = conv.id;
|
|
551
556
|
const now = Date.now();
|
|
552
557
|
// 2. 扫描用户文本中的 @ 提及(文件路径与技能指令)
|
|
553
558
|
const availableSkills = await this.collectUniversalSkills();
|
|
@@ -705,7 +710,7 @@ export class UniversalSession {
|
|
|
705
710
|
return;
|
|
706
711
|
this.send({
|
|
707
712
|
type: "message_delta",
|
|
708
|
-
conversationId: this.activeConvId,
|
|
713
|
+
conversationId: this.turnConvId ?? this.activeConvId,
|
|
709
714
|
seq: ++this.deltaSeq,
|
|
710
715
|
messageId: this.streamingMessage.id,
|
|
711
716
|
usage: null,
|
|
@@ -717,16 +722,19 @@ export class UniversalSession {
|
|
|
717
722
|
clearTimeout(this.snapshotTimer);
|
|
718
723
|
this.snapshotTimer = null;
|
|
719
724
|
}
|
|
725
|
+
// 回合收尾锚定回合归属会话:中途切走/回滚不再把本轮内容写进别的会话(#700/#701)
|
|
726
|
+
const turnId = this.turnConvId;
|
|
727
|
+
this.turnConvId = null;
|
|
728
|
+
const conv = (turnId && this.conversations.get(turnId)) || this.activeConv;
|
|
720
729
|
if (this.streamingMessage) {
|
|
721
|
-
|
|
730
|
+
conv.messages.push(this.streamingMessage);
|
|
722
731
|
this.streamingMessage = null;
|
|
723
732
|
}
|
|
724
733
|
if (this.pendingToolResults.length > 0) {
|
|
725
|
-
|
|
734
|
+
conv.messages.push(...this.pendingToolResults);
|
|
726
735
|
this.pendingToolResults = [];
|
|
727
736
|
}
|
|
728
737
|
// 累计会话统计与上下文占用(底座统一驱动底栏上下文环、Token 计数、缓存命中率与累计成本)
|
|
729
|
-
const conv = this.activeConv;
|
|
730
738
|
if (!conv.stats) {
|
|
731
739
|
conv.stats = {
|
|
732
740
|
tokens: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
@@ -756,20 +764,20 @@ export class UniversalSession {
|
|
|
756
764
|
// 回写 Claude 分配的 session ID(保证多轮上下文连续)
|
|
757
765
|
if (typeof this.driver.getActiveSessionId === "function") {
|
|
758
766
|
const activeSid = this.driver.getActiveSessionId();
|
|
759
|
-
if (activeSid &&
|
|
760
|
-
|
|
767
|
+
if (activeSid && conv.driverSessionId !== activeSid) {
|
|
768
|
+
conv.driverSessionId = activeSid;
|
|
761
769
|
}
|
|
762
770
|
}
|
|
763
771
|
this.isStreaming = false;
|
|
764
772
|
this.streamingThinking = "";
|
|
765
773
|
this.streamingText = "";
|
|
766
|
-
|
|
767
|
-
if (!
|
|
768
|
-
this.store.saveConversation(this.cwd,
|
|
774
|
+
conv.updatedAt = Date.now();
|
|
775
|
+
if (!conv.isEphemeral) {
|
|
776
|
+
this.store.saveConversation(this.cwd, conv);
|
|
769
777
|
}
|
|
770
778
|
// 解析本轮生成的内联标记(如 [[conv:rename:...]] / [[action:suggest:...]])
|
|
771
779
|
if (this.streamingText && this.streamingText.includes("[[")) {
|
|
772
|
-
void this.markerSvc.handleAssistantText(
|
|
780
|
+
void this.markerSvc.handleAssistantText(conv.id, this.streamingText);
|
|
773
781
|
}
|
|
774
782
|
this.flushSnapshot();
|
|
775
783
|
void this.refreshSessions();
|
|
@@ -982,6 +990,11 @@ export class UniversalSession {
|
|
|
982
990
|
if (!targetConv) {
|
|
983
991
|
targetConv = this.activeConv;
|
|
984
992
|
}
|
|
993
|
+
// 回滚与在途回合互斥:先落定在途回合再截断,否则 finalize 与 slice 交错导致截断/错位(#700)
|
|
994
|
+
if (targetConv.id === this.activeConvId && (this.isStreaming || this.streamingMessage)) {
|
|
995
|
+
await this.abort();
|
|
996
|
+
targetConv = this.activeConv;
|
|
997
|
+
}
|
|
985
998
|
const idx = targetConv.messages.findIndex((m) => m.id === messageId);
|
|
986
999
|
if (idx < 0) {
|
|
987
1000
|
this.emitNotice("error", "找不到指定的回滚目标消息", "Rollback target message not found");
|
|
@@ -1075,8 +1088,15 @@ export class UniversalSession {
|
|
|
1075
1088
|
this.flushSnapshot();
|
|
1076
1089
|
return;
|
|
1077
1090
|
}
|
|
1078
|
-
//
|
|
1079
|
-
|
|
1091
|
+
// 截断到编辑点之前的所有历史消息(跳过属于本轮提问的前置附件卡片,避免 prompt 重新注入后附件重复),
|
|
1092
|
+
// fork 一个新的 UniversalConversation
|
|
1093
|
+
let cutIdx = idx;
|
|
1094
|
+
while (cutIdx > 0 &&
|
|
1095
|
+
conv.messages[cutIdx - 1]?.role === "custom" &&
|
|
1096
|
+
conv.messages[cutIdx - 1]?.customType === "file") {
|
|
1097
|
+
cutIdx--;
|
|
1098
|
+
}
|
|
1099
|
+
const headMessages = structuredClone(conv.messages.slice(0, cutIdx));
|
|
1080
1100
|
const forkedConv = this.createEmptyConversation(conv.title, Boolean(conv.isEphemeral));
|
|
1081
1101
|
forkedConv.messages = headMessages;
|
|
1082
1102
|
if (headMessages.length > 0) {
|
|
@@ -1807,6 +1827,9 @@ export class UniversalSession {
|
|
|
1807
1827
|
retainFinishedConversations: false,
|
|
1808
1828
|
openRecentSessionOnProjectSwitch: true,
|
|
1809
1829
|
skillsFullText: [],
|
|
1830
|
+
skillsCatalogMaxDesc: 250,
|
|
1831
|
+
skillsCatalogShowLocation: false,
|
|
1832
|
+
skillsCatalogBudget: 20000,
|
|
1810
1833
|
visionBridgeEnabled: false,
|
|
1811
1834
|
visionBridgeModel: null,
|
|
1812
1835
|
visionBridgePromptMode: "append",
|
|
@@ -316,15 +316,100 @@ async function runGit(args, cwd) {
|
|
|
316
316
|
});
|
|
317
317
|
return stdout.trim();
|
|
318
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Patterns to query via `git ls-remote` for a requested ref name.
|
|
321
|
+
* Full `refs/` paths are queried directly (with peeled tag fallback);
|
|
322
|
+
* shorthand names look up branches, tags, and peeled tags.
|
|
323
|
+
*/
|
|
324
|
+
export function buildLsRemotePatternsForRef(ref) {
|
|
325
|
+
if (ref.startsWith("refs/")) {
|
|
326
|
+
return [ref, `${ref}^{}`];
|
|
327
|
+
}
|
|
328
|
+
return [`refs/heads/${ref}`, `refs/tags/${ref}`, `refs/tags/${ref}^{}`, ref, `${ref}^{}`];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Pick the remote commit SHA corresponding to a requested ref from `git ls-remote` output.
|
|
332
|
+
*
|
|
333
|
+
* Precedence:
|
|
334
|
+
* 1. Full/explicit ref match (`refs/...^{}`, direct `refs/...`, or `HEAD`)
|
|
335
|
+
* 2. Branch ref: `refs/heads/<ref>`
|
|
336
|
+
* 3. Tag ref: peeled annotated tag (`refs/tags/<ref>^{}`) wins over lightweight tag (`refs/tags/<ref>`)
|
|
337
|
+
*/
|
|
338
|
+
export function pickRemoteShaForRef(output, ref) {
|
|
339
|
+
const map = new Map();
|
|
340
|
+
for (const line of output.split(/\r?\n/)) {
|
|
341
|
+
const match = line.trim().match(/^([0-9a-f]{40})\s+(\S+)$/i);
|
|
342
|
+
if (match) {
|
|
343
|
+
map.set(match[2], match[1]);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Full / explicit ref match
|
|
347
|
+
if (map.has(`${ref}^{}`))
|
|
348
|
+
return map.get(`${ref}^{}`);
|
|
349
|
+
if (map.has(ref))
|
|
350
|
+
return map.get(ref);
|
|
351
|
+
// Branch: refs/heads/<ref>
|
|
352
|
+
const branchRef = `refs/heads/${ref}`;
|
|
353
|
+
if (map.has(branchRef))
|
|
354
|
+
return map.get(branchRef);
|
|
355
|
+
// Tag: peeled tag wins over unpeeled tag
|
|
356
|
+
const peeledTagRef = `refs/tags/${ref}^{}`;
|
|
357
|
+
if (map.has(peeledTagRef))
|
|
358
|
+
return map.get(peeledTagRef);
|
|
359
|
+
const tagRef = `refs/tags/${ref}`;
|
|
360
|
+
if (map.has(tagRef))
|
|
361
|
+
return map.get(tagRef);
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
319
364
|
/**
|
|
320
365
|
* Compare a clone's HEAD against its remote (lightweight: `ls-remote` fetches
|
|
321
|
-
* refs only, no objects).
|
|
322
|
-
*
|
|
366
|
+
* refs only, no objects). When a configured ref (`@...`) is given, the remote
|
|
367
|
+
* benchmark is resolved from that ref (branch, tag, or commit sha) instead of
|
|
368
|
+
* blindly comparing against the checked-out branch's upstream (issue #665).
|
|
369
|
+
* When ref is absent, upstream branch wins when configured, else origin HEAD.
|
|
323
370
|
*/
|
|
324
|
-
export async function defaultCheckGitExtension(installDir) {
|
|
371
|
+
export async function defaultCheckGitExtension(installDir, ref) {
|
|
325
372
|
const localSha = await runGit(["rev-parse", "HEAD"], installDir);
|
|
326
373
|
if (!/^[0-9a-f]{40}$/i.test(localSha))
|
|
327
374
|
throw new Error(`Bad local HEAD: ${localSha.slice(0, 20)}`);
|
|
375
|
+
const targetRef = ref?.trim() || null;
|
|
376
|
+
if (targetRef) {
|
|
377
|
+
let remoteSha = null;
|
|
378
|
+
let lsRemoteError = null;
|
|
379
|
+
try {
|
|
380
|
+
const patterns = buildLsRemotePatternsForRef(targetRef);
|
|
381
|
+
const out = await runGit(["ls-remote", "origin", ...patterns], installDir);
|
|
382
|
+
remoteSha = pickRemoteShaForRef(out, targetRef);
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
385
|
+
lsRemoteError = err;
|
|
386
|
+
}
|
|
387
|
+
if (!remoteSha && /^[0-9a-f]{7,40}$/i.test(targetRef)) {
|
|
388
|
+
// Commit SHA reference: if local HEAD already matches the requested SHA (prefix or exact),
|
|
389
|
+
// the clone is fully up to date.
|
|
390
|
+
if (localSha.toLowerCase().startsWith(targetRef.toLowerCase())) {
|
|
391
|
+
remoteSha = localSha;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
try {
|
|
395
|
+
const parsed = await runGit(["rev-parse", `${targetRef}^{commit}`], installDir);
|
|
396
|
+
if (/^[0-9a-f]{40}$/i.test(parsed))
|
|
397
|
+
remoteSha = parsed;
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
/* commit not present in local repo yet */
|
|
401
|
+
}
|
|
402
|
+
if (!remoteSha)
|
|
403
|
+
remoteSha = targetRef;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (!remoteSha) {
|
|
407
|
+
if (lsRemoteError)
|
|
408
|
+
throw lsRemoteError;
|
|
409
|
+
throw new Error(`Failed to resolve remote ref: ${targetRef}`);
|
|
410
|
+
}
|
|
411
|
+
return { localSha, remoteSha };
|
|
412
|
+
}
|
|
328
413
|
let remoteSha = null;
|
|
329
414
|
try {
|
|
330
415
|
const upstream = await runGit(["rev-parse", "--abbrev-ref", "@{upstream}"], installDir);
|
|
@@ -758,8 +843,8 @@ gitCheck = defaultCheckGitExtension) {
|
|
|
758
843
|
try {
|
|
759
844
|
if (!t.installDir)
|
|
760
845
|
throw new Error("missing install dir");
|
|
761
|
-
const { localSha, remoteSha } = await gitCheck(t.installDir);
|
|
762
|
-
const upToDate = localSha.trim() === remoteSha.trim();
|
|
846
|
+
const { localSha, remoteSha } = await gitCheck(t.installDir, t.ref);
|
|
847
|
+
const upToDate = localSha.trim().toLowerCase() === remoteSha.trim().toLowerCase();
|
|
763
848
|
results[i] = {
|
|
764
849
|
name: t.name,
|
|
765
850
|
kind: t.kind,
|
|
@@ -21,6 +21,9 @@ import { gitDirOf } from "./scm.js";
|
|
|
21
21
|
const exec = promisify(execFile);
|
|
22
22
|
/** 单次 git 快照/还原命令超时时间(毫秒)。 */
|
|
23
23
|
const GIT_SNAPSHOT_TIMEOUT_MS = 15_000;
|
|
24
|
+
/** 物理还原互斥链(#697):同一 cwd 的 git read-tree/clean 序列串行执行,
|
|
25
|
+
* 杜绝并发回滚交错破坏 index/工作区;key 为 resolve 后的 cwd。 */
|
|
26
|
+
const pendingRestores = new Map();
|
|
24
27
|
/** 执行单条 git 命令,返回 stdout。 */
|
|
25
28
|
async function runGit(cwd, args, envExtra) {
|
|
26
29
|
const { stdout } = await exec("git", ["-c", "core.quotepath=false", ...args], {
|
|
@@ -221,8 +224,10 @@ export async function createWorkspaceSnapshot(cwd) {
|
|
|
221
224
|
}
|
|
222
225
|
if (!tree)
|
|
223
226
|
return null;
|
|
224
|
-
// 异步更新持久化影子 index
|
|
225
|
-
|
|
227
|
+
// 异步更新持久化影子 index 缓存供下轮秒级复用。必须 await 后再进 finally:
|
|
228
|
+
// 否则 finally 里 rm(tempIndex) 会在拷贝中途删掉源文件,Windows 上拷贝要么
|
|
229
|
+
// EBUSY 失败、要么把半截内容写进 cachePath(下轮读坏缓存再回落,缓存失效)。
|
|
230
|
+
await copyFile(tempIndex, cachePath).catch(() => { });
|
|
226
231
|
// 优化 3:检查 tree 是否与该 cwd 上次快照完全一致
|
|
227
232
|
const normCwd = resolve(cwd);
|
|
228
233
|
const last = lastSnapshotByCwd.get(normCwd);
|
|
@@ -283,6 +288,32 @@ export async function createWorkspaceSnapshot(cwd) {
|
|
|
283
288
|
* 同仓库的兄弟目录在以上任何一步都不受影响。
|
|
284
289
|
*/
|
|
285
290
|
export async function restoreWorkspaceSnapshot(cwd, snapshotRef) {
|
|
291
|
+
const key = resolve(cwd);
|
|
292
|
+
const prev = pendingRestores.get(key);
|
|
293
|
+
let release;
|
|
294
|
+
const gate = new Promise((r) => {
|
|
295
|
+
release = r;
|
|
296
|
+
});
|
|
297
|
+
const mine = (prev ?? Promise.resolve()).then(() => gate);
|
|
298
|
+
pendingRestores.set(key, mine);
|
|
299
|
+
if (prev) {
|
|
300
|
+
try {
|
|
301
|
+
await prev;
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
// 前一还原失败不阻塞后继
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
return await restoreWorkspaceSnapshotInner(cwd, snapshotRef);
|
|
309
|
+
}
|
|
310
|
+
finally {
|
|
311
|
+
if (pendingRestores.get(key) === mine)
|
|
312
|
+
pendingRestores.delete(key);
|
|
313
|
+
release();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async function restoreWorkspaceSnapshotInner(cwd, snapshotRef) {
|
|
286
317
|
const gitDir = await gitDirOf(cwd);
|
|
287
318
|
if (!gitDir) {
|
|
288
319
|
return { success: false, error: "Workspace is not a Git repository" };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 4. 组装 `WorktreeInfo` 上下文供 UI 横幅与 AI 工具消费。
|
|
11
11
|
*/
|
|
12
12
|
import { execFile } from "node:child_process";
|
|
13
|
-
import { resolve,
|
|
13
|
+
import { resolve, normalize } from "node:path";
|
|
14
14
|
import { promisify } from "node:util";
|
|
15
15
|
import { existsSync } from "node:fs";
|
|
16
16
|
import { pick } from "./i18n.js";
|