@him666233/dsh-inline-diff 1.4.0 → 1.4.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/README.en.md +13 -5
- package/README.md +13 -5
- package/client.js +640 -142
- package/index.js +451 -32
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1585,6 +1585,209 @@ __export(index_exports, {
|
|
|
1585
1585
|
module.exports = __toCommonJS(index_exports);
|
|
1586
1586
|
var import_react7 = require("react");
|
|
1587
1587
|
|
|
1588
|
+
// src/client/api.js
|
|
1589
|
+
var API_PREFIX = "/dsh-inline-diff/api";
|
|
1590
|
+
function resolveApiPath(action, baseUri = typeof document !== "undefined" ? document.baseURI : void 0) {
|
|
1591
|
+
const suffix = String(action ?? "").replace(/^\/+/, "");
|
|
1592
|
+
const rootPath = `${API_PREFIX}/${suffix}`;
|
|
1593
|
+
if (typeof baseUri !== "string" || baseUri === "") return rootPath;
|
|
1594
|
+
try {
|
|
1595
|
+
const base = new URL(baseUri);
|
|
1596
|
+
const dir = base.pathname.endsWith("/") ? base.pathname : base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1);
|
|
1597
|
+
return `${dir}${API_PREFIX.replace(/^\/+/, "")}/${suffix}`.replace(/\/{2,}/g, "/");
|
|
1598
|
+
} catch {
|
|
1599
|
+
return rootPath;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
var TIMEOUT_MS = 1e4;
|
|
1603
|
+
async function call(action, payload2) {
|
|
1604
|
+
const controller = new AbortController();
|
|
1605
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
1606
|
+
try {
|
|
1607
|
+
const response = await fetch(resolveApiPath(action), {
|
|
1608
|
+
method: "POST",
|
|
1609
|
+
headers: { "content-type": "application/json" },
|
|
1610
|
+
body: JSON.stringify(payload2 ?? {}),
|
|
1611
|
+
signal: controller.signal
|
|
1612
|
+
});
|
|
1613
|
+
if (!response.ok) return null;
|
|
1614
|
+
const data = await response.json();
|
|
1615
|
+
return data !== null && typeof data === "object" ? data : null;
|
|
1616
|
+
} catch {
|
|
1617
|
+
return null;
|
|
1618
|
+
} finally {
|
|
1619
|
+
clearTimeout(timer);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
async function fetchSnapshot(sessionId, callId) {
|
|
1623
|
+
if (typeof sessionId !== "string" || sessionId === "" || callId === void 0 || callId === null) return null;
|
|
1624
|
+
const data = await call("snapshot", { sessionId, callId: String(callId) });
|
|
1625
|
+
if (data === null || data.ok !== true) return null;
|
|
1626
|
+
const snapshot = data.snapshot;
|
|
1627
|
+
if (snapshot === null || typeof snapshot !== "object") return null;
|
|
1628
|
+
if (typeof snapshot.after !== "string") return null;
|
|
1629
|
+
return {
|
|
1630
|
+
path: typeof snapshot.path === "string" ? snapshot.path : "",
|
|
1631
|
+
before: typeof snapshot.before === "string" ? snapshot.before : null,
|
|
1632
|
+
after: snapshot.after,
|
|
1633
|
+
operation: typeof snapshot.operation === "string" ? snapshot.operation : snapshot.before === null ? "create" : "update"
|
|
1634
|
+
};
|
|
1635
|
+
}
|
|
1636
|
+
async function fetchFileText(cwd, path) {
|
|
1637
|
+
if (typeof cwd !== "string" || cwd === "" || typeof path !== "string" || path === "") return null;
|
|
1638
|
+
const data = await call("read", { cwd, path });
|
|
1639
|
+
if (data === null || data.ok !== true) return null;
|
|
1640
|
+
if (data.kind === "text" && typeof data.text === "string") return { kind: "text", text: data.text, size: data.size };
|
|
1641
|
+
if (data.kind === "binary") return { kind: "binary", size: data.size };
|
|
1642
|
+
if (data.kind === "oversized") return { kind: "oversized", size: data.size };
|
|
1643
|
+
return null;
|
|
1644
|
+
}
|
|
1645
|
+
async function fetchToolNames() {
|
|
1646
|
+
const controller = new AbortController();
|
|
1647
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
1648
|
+
try {
|
|
1649
|
+
const response = await fetch(resolveApiPath("tools"), {
|
|
1650
|
+
credentials: "include",
|
|
1651
|
+
signal: controller.signal,
|
|
1652
|
+
headers: { accept: "application/json" }
|
|
1653
|
+
});
|
|
1654
|
+
if (!response.ok) return null;
|
|
1655
|
+
const data = await response.json();
|
|
1656
|
+
if (data === null || typeof data !== "object" || data.ok !== true || !Array.isArray(data.tools)) return null;
|
|
1657
|
+
const names = [];
|
|
1658
|
+
for (const name of data.tools) {
|
|
1659
|
+
if (typeof name === "string" && name !== "" && name.length <= 200) names.push(name);
|
|
1660
|
+
}
|
|
1661
|
+
return names;
|
|
1662
|
+
} catch {
|
|
1663
|
+
return null;
|
|
1664
|
+
} finally {
|
|
1665
|
+
clearTimeout(timer);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
async function fetchReadRoots() {
|
|
1669
|
+
const controller = new AbortController();
|
|
1670
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
1671
|
+
try {
|
|
1672
|
+
const response = await fetch(resolveApiPath("read-roots"), {
|
|
1673
|
+
credentials: "include",
|
|
1674
|
+
signal: controller.signal,
|
|
1675
|
+
headers: { accept: "application/json" }
|
|
1676
|
+
});
|
|
1677
|
+
if (!response.ok) return null;
|
|
1678
|
+
const data = await response.json();
|
|
1679
|
+
if (data === null || typeof data !== "object" || data.ok !== true || !Array.isArray(data.roots)) return null;
|
|
1680
|
+
return {
|
|
1681
|
+
roots: data.roots.filter((root) => typeof root === "string" && root !== ""),
|
|
1682
|
+
max: Number.isInteger(data.max) && data.max > 0 ? data.max : 12
|
|
1683
|
+
};
|
|
1684
|
+
} catch {
|
|
1685
|
+
return null;
|
|
1686
|
+
} finally {
|
|
1687
|
+
clearTimeout(timer);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
async function saveReadRoots(roots) {
|
|
1691
|
+
const controller = new AbortController();
|
|
1692
|
+
const timer = setTimeout(() => controller.abort(), 15e3);
|
|
1693
|
+
try {
|
|
1694
|
+
const response = await fetch(resolveApiPath("read-roots"), {
|
|
1695
|
+
method: "POST",
|
|
1696
|
+
credentials: "include",
|
|
1697
|
+
signal: controller.signal,
|
|
1698
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
1699
|
+
body: JSON.stringify({ roots: Array.isArray(roots) ? roots : [] })
|
|
1700
|
+
});
|
|
1701
|
+
const data = await response.json().catch(() => null);
|
|
1702
|
+
if (data === null || typeof data !== "object") return null;
|
|
1703
|
+
if (data.ok === true && Array.isArray(data.roots)) {
|
|
1704
|
+
return { ok: true, roots: data.roots.filter((root) => typeof root === "string" && root !== "") };
|
|
1705
|
+
}
|
|
1706
|
+
return { ok: false, code: typeof data.code === "string" ? data.code : "invalid-roots" };
|
|
1707
|
+
} catch {
|
|
1708
|
+
return null;
|
|
1709
|
+
} finally {
|
|
1710
|
+
clearTimeout(timer);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
var FILE_CACHE_LIMIT = 24;
|
|
1714
|
+
var FILE_CACHE_TTL = 15e3;
|
|
1715
|
+
var fileCache = /* @__PURE__ */ new Map();
|
|
1716
|
+
function trimCache(map, limit) {
|
|
1717
|
+
while (map.size > limit) {
|
|
1718
|
+
const oldest = map.keys().next().value;
|
|
1719
|
+
if (oldest === void 0) break;
|
|
1720
|
+
map.delete(oldest);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
async function cachedFileText(cwd, path) {
|
|
1724
|
+
const key = `${cwd ?? ""}\0${path ?? ""}`;
|
|
1725
|
+
const now = Date.now();
|
|
1726
|
+
const hit = fileCache.get(key);
|
|
1727
|
+
if (hit !== void 0 && now - hit.at < FILE_CACHE_TTL) {
|
|
1728
|
+
fileCache.delete(key);
|
|
1729
|
+
fileCache.set(key, hit);
|
|
1730
|
+
return hit.value;
|
|
1731
|
+
}
|
|
1732
|
+
const value = await fetchFileText(cwd, path);
|
|
1733
|
+
fileCache.set(key, { value, at: now });
|
|
1734
|
+
trimCache(fileCache, FILE_CACHE_LIMIT);
|
|
1735
|
+
return value;
|
|
1736
|
+
}
|
|
1737
|
+
var SNAPSHOT_CACHE_LIMIT = 160;
|
|
1738
|
+
var snapshotCache = /* @__PURE__ */ new Map();
|
|
1739
|
+
async function cachedSnapshot(sessionId, callId) {
|
|
1740
|
+
const key = `${sessionId ?? ""}\0${callId ?? ""}`;
|
|
1741
|
+
if (snapshotCache.has(key)) return snapshotCache.get(key) ?? null;
|
|
1742
|
+
let snapshot = await fetchSnapshot(sessionId, callId);
|
|
1743
|
+
if (snapshot === null) {
|
|
1744
|
+
await new Promise((resolve) => setTimeout(resolve, 180));
|
|
1745
|
+
snapshot = await fetchSnapshot(sessionId, callId);
|
|
1746
|
+
}
|
|
1747
|
+
snapshotCache.set(key, snapshot);
|
|
1748
|
+
trimCache(snapshotCache, SNAPSHOT_CACHE_LIMIT);
|
|
1749
|
+
return snapshot;
|
|
1750
|
+
}
|
|
1751
|
+
async function fetchUpdateInfo(refresh) {
|
|
1752
|
+
const controller = new AbortController();
|
|
1753
|
+
const timer = setTimeout(() => controller.abort(), 25e3);
|
|
1754
|
+
try {
|
|
1755
|
+
const suffix = refresh === true ? "?refresh=1" : "";
|
|
1756
|
+
const response = await fetch(`${resolveApiPath("update/versions")}${suffix}`, {
|
|
1757
|
+
credentials: "include",
|
|
1758
|
+
signal: controller.signal,
|
|
1759
|
+
headers: { accept: "application/json" }
|
|
1760
|
+
});
|
|
1761
|
+
if (!response.ok) return null;
|
|
1762
|
+
const data = await response.json();
|
|
1763
|
+
return data !== null && typeof data === "object" && data.ok === true ? data : null;
|
|
1764
|
+
} catch {
|
|
1765
|
+
return null;
|
|
1766
|
+
} finally {
|
|
1767
|
+
clearTimeout(timer);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
async function performUpdate(version) {
|
|
1771
|
+
const controller = new AbortController();
|
|
1772
|
+
const timer = setTimeout(() => controller.abort(), 26e4);
|
|
1773
|
+
try {
|
|
1774
|
+
const response = await fetch(resolveApiPath("update/install"), {
|
|
1775
|
+
method: "POST",
|
|
1776
|
+
credentials: "include",
|
|
1777
|
+
signal: controller.signal,
|
|
1778
|
+
headers: { "content-type": "application/json", accept: "application/json" },
|
|
1779
|
+
body: JSON.stringify({ version })
|
|
1780
|
+
});
|
|
1781
|
+
if (!response.ok) return null;
|
|
1782
|
+
const data = await response.json();
|
|
1783
|
+
return data !== null && typeof data === "object" ? data : null;
|
|
1784
|
+
} catch {
|
|
1785
|
+
return null;
|
|
1786
|
+
} finally {
|
|
1787
|
+
clearTimeout(timer);
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1588
1791
|
// src/client/enhanced-shell.jsx
|
|
1589
1792
|
var import_react4 = require("react");
|
|
1590
1793
|
|
|
@@ -2479,6 +2682,16 @@ function exceedsAlignBudget(beforeText, afterText) {
|
|
|
2479
2682
|
const newMetric = measureTextBudget(afterText);
|
|
2480
2683
|
return oldMetric.lines > ALIGN_MAX_SIDE_LINES || newMetric.lines > ALIGN_MAX_SIDE_LINES || oldMetric.lines * newMetric.lines > ALIGN_MAX_CELLS || exceedsMaterializationBudget([oldMetric, newMetric]);
|
|
2481
2684
|
}
|
|
2685
|
+
function sameContentAfterEolNormalization(left, right) {
|
|
2686
|
+
if (left === right) return true;
|
|
2687
|
+
const leftLines = contentLines(left);
|
|
2688
|
+
const rightLines = contentLines(right);
|
|
2689
|
+
if (leftLines.length !== rightLines.length) return false;
|
|
2690
|
+
for (let index = 0; index < leftLines.length; index += 1) {
|
|
2691
|
+
if (leftLines[index] !== rightLines[index]) return false;
|
|
2692
|
+
}
|
|
2693
|
+
return true;
|
|
2694
|
+
}
|
|
2482
2695
|
function buildCardModel({ block, toolName, cwd, home, snapshot, fileText, loading }) {
|
|
2483
2696
|
const call2 = deriveCall(block);
|
|
2484
2697
|
const resolvedToolName = resolveToolName(call2, toolName);
|
|
@@ -2518,6 +2731,9 @@ function buildCardModel({ block, toolName, cwd, home, snapshot, fileText, loadin
|
|
|
2518
2731
|
if (before !== null && before === after) {
|
|
2519
2732
|
return { ...base, status: "nochange", operation, source: "snapshot", diff: diffText(before, after) };
|
|
2520
2733
|
}
|
|
2734
|
+
if (before !== null && !overMaterialization && sameContentAfterEolNormalization(before, after)) {
|
|
2735
|
+
return { ...base, status: "nochange", operation, source: "snapshot", diff: diffText(before, after) };
|
|
2736
|
+
}
|
|
2521
2737
|
if (overMaterialization || before !== null && exceedsAlignBudget(before, after)) {
|
|
2522
2738
|
const oldCount = oldMetric.lines;
|
|
2523
2739
|
const newCount = newMetric.lines;
|
|
@@ -3020,6 +3236,17 @@ var zh = {
|
|
|
3020
3236
|
"settings.subagentNote": "子代理会话与主会话共用这套设置;差异快照按各自 Session 独立记录,互不影响。",
|
|
3021
3237
|
"settings.dsmCurrent": "当前 DSH 对话记录模式:{mode}",
|
|
3022
3238
|
"settings.reset": "恢复默认",
|
|
3239
|
+
"settings.readRoots": "额外可读目录(工作区外)",
|
|
3240
|
+
"settings.readRootsDesc": "历史回放或 str_replace_editor 需要读取“当前文件”补齐行号;工作区外文件默认只显示修改块。这里添加的目录允许本插件的只读展示 API 读取其中的文本文件(≤2MB)。",
|
|
3241
|
+
"settings.readRootsNote": "目录保存在 Host(~/.dsh/dsh-inline-diff/read-roots.json),不会上传文件;只影响历史回放的当前文件读取。添加后同源脚本也能通过本插件读取该目录内的文本,请只添加可信目录。",
|
|
3242
|
+
"settings.readRootsPlaceholder": "例如 D:\\projects\\shared 或 /Users/me/projects",
|
|
3243
|
+
"settings.readRootsAdd": "添加目录",
|
|
3244
|
+
"settings.readRootsRemove": "移除",
|
|
3245
|
+
"settings.readRootsEmpty": "尚未添加任何目录",
|
|
3246
|
+
"settings.readRootsBusy": "保存中…",
|
|
3247
|
+
"settings.readRootsSaved": "已保存",
|
|
3248
|
+
"settings.readRootsError": "保存失败({code})",
|
|
3249
|
+
"settings.readRootsLimit": "最多 {max} 个目录",
|
|
3023
3250
|
"update.title": "版本与更新",
|
|
3024
3251
|
"update.current": "当前版本 v{version}",
|
|
3025
3252
|
"update.latest": "最新",
|
|
@@ -3273,6 +3500,17 @@ var en = {
|
|
|
3273
3500
|
"settings.subagentNote": "Subagent sessions use the same settings; diff snapshots are recorded per Session and never interfere.",
|
|
3274
3501
|
"settings.dsmCurrent": "Current DSH transcript mode: {mode}",
|
|
3275
3502
|
"settings.reset": "Reset to defaults",
|
|
3503
|
+
"settings.readRoots": "Extra readable folders (outside workspace)",
|
|
3504
|
+
"settings.readRootsDesc": "History replay or str_replace_editor reads the current file to fill in line numbers; files outside the workspace otherwise stop at changed hunks. Folders added here allow this plugin’s read-only display API to read text files (≤2 MB) inside them.",
|
|
3505
|
+
"settings.readRootsNote": "The list is stored by the Host (~/.dsh/dsh-inline-diff/read-roots.json) and no files are uploaded; it only affects current-file reads for history replay. Same-origin scripts can also use this plugin to read those folders, so only add trusted directories.",
|
|
3506
|
+
"settings.readRootsPlaceholder": "e.g. D:\\projects\\shared or /Users/me/projects",
|
|
3507
|
+
"settings.readRootsAdd": "Add folder",
|
|
3508
|
+
"settings.readRootsRemove": "Remove",
|
|
3509
|
+
"settings.readRootsEmpty": "No folders added yet",
|
|
3510
|
+
"settings.readRootsBusy": "Saving…",
|
|
3511
|
+
"settings.readRootsSaved": "Saved",
|
|
3512
|
+
"settings.readRootsError": "Save failed ({code})",
|
|
3513
|
+
"settings.readRootsLimit": "At most {max} folders",
|
|
3276
3514
|
"update.title": "Version & updates",
|
|
3277
3515
|
"update.current": "Current version v{version}",
|
|
3278
3516
|
"update.latest": "Latest",
|
|
@@ -3765,7 +4003,24 @@ function summaryOf(args, call2) {
|
|
|
3765
4003
|
if (args === null || typeof args !== "object") return "";
|
|
3766
4004
|
const specific = call2 === void 0 ? "" : searchSummary(call2);
|
|
3767
4005
|
if (specific !== "") return specific;
|
|
3768
|
-
const keys = [
|
|
4006
|
+
const keys = [
|
|
4007
|
+
"description",
|
|
4008
|
+
"command",
|
|
4009
|
+
"file_path",
|
|
4010
|
+
"path",
|
|
4011
|
+
"localPath",
|
|
4012
|
+
"remotePath",
|
|
4013
|
+
"url",
|
|
4014
|
+
"query",
|
|
4015
|
+
"queries",
|
|
4016
|
+
"prompt",
|
|
4017
|
+
"objective",
|
|
4018
|
+
"skill",
|
|
4019
|
+
"title",
|
|
4020
|
+
"name",
|
|
4021
|
+
"tool",
|
|
4022
|
+
"alias"
|
|
4023
|
+
];
|
|
3769
4024
|
for (const key of keys) {
|
|
3770
4025
|
const value = args[key];
|
|
3771
4026
|
if (Array.isArray(value)) {
|
|
@@ -4123,129 +4378,6 @@ function EnhancedShellCard(props) {
|
|
|
4123
4378
|
var import_react5 = require("react");
|
|
4124
4379
|
var import_react_dom = require("react-dom");
|
|
4125
4380
|
|
|
4126
|
-
// src/client/api.js
|
|
4127
|
-
var API_PREFIX = "/dsh-inline-diff/api";
|
|
4128
|
-
var TIMEOUT_MS = 1e4;
|
|
4129
|
-
async function call(action, payload2) {
|
|
4130
|
-
const controller = new AbortController();
|
|
4131
|
-
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
4132
|
-
try {
|
|
4133
|
-
const response = await fetch(`${API_PREFIX}/${action}`, {
|
|
4134
|
-
method: "POST",
|
|
4135
|
-
headers: { "content-type": "application/json" },
|
|
4136
|
-
body: JSON.stringify(payload2 ?? {}),
|
|
4137
|
-
signal: controller.signal
|
|
4138
|
-
});
|
|
4139
|
-
if (!response.ok) return null;
|
|
4140
|
-
const data = await response.json();
|
|
4141
|
-
return data !== null && typeof data === "object" ? data : null;
|
|
4142
|
-
} catch {
|
|
4143
|
-
return null;
|
|
4144
|
-
} finally {
|
|
4145
|
-
clearTimeout(timer);
|
|
4146
|
-
}
|
|
4147
|
-
}
|
|
4148
|
-
async function fetchSnapshot(sessionId, callId) {
|
|
4149
|
-
if (typeof sessionId !== "string" || sessionId === "" || callId === void 0 || callId === null) return null;
|
|
4150
|
-
const data = await call("snapshot", { sessionId, callId: String(callId) });
|
|
4151
|
-
if (data === null || data.ok !== true) return null;
|
|
4152
|
-
const snapshot = data.snapshot;
|
|
4153
|
-
if (snapshot === null || typeof snapshot !== "object") return null;
|
|
4154
|
-
if (typeof snapshot.after !== "string") return null;
|
|
4155
|
-
return {
|
|
4156
|
-
path: typeof snapshot.path === "string" ? snapshot.path : "",
|
|
4157
|
-
before: typeof snapshot.before === "string" ? snapshot.before : null,
|
|
4158
|
-
after: snapshot.after,
|
|
4159
|
-
operation: typeof snapshot.operation === "string" ? snapshot.operation : snapshot.before === null ? "create" : "update"
|
|
4160
|
-
};
|
|
4161
|
-
}
|
|
4162
|
-
async function fetchFileText(cwd, path) {
|
|
4163
|
-
if (typeof cwd !== "string" || cwd === "" || typeof path !== "string" || path === "") return null;
|
|
4164
|
-
const data = await call("read", { cwd, path });
|
|
4165
|
-
if (data === null || data.ok !== true) return null;
|
|
4166
|
-
if (data.kind === "text" && typeof data.text === "string") return { kind: "text", text: data.text, size: data.size };
|
|
4167
|
-
if (data.kind === "binary") return { kind: "binary", size: data.size };
|
|
4168
|
-
if (data.kind === "oversized") return { kind: "oversized", size: data.size };
|
|
4169
|
-
return null;
|
|
4170
|
-
}
|
|
4171
|
-
var FILE_CACHE_LIMIT = 24;
|
|
4172
|
-
var FILE_CACHE_TTL = 15e3;
|
|
4173
|
-
var fileCache = /* @__PURE__ */ new Map();
|
|
4174
|
-
function trimCache(map, limit) {
|
|
4175
|
-
while (map.size > limit) {
|
|
4176
|
-
const oldest = map.keys().next().value;
|
|
4177
|
-
if (oldest === void 0) break;
|
|
4178
|
-
map.delete(oldest);
|
|
4179
|
-
}
|
|
4180
|
-
}
|
|
4181
|
-
async function cachedFileText(cwd, path) {
|
|
4182
|
-
const key = `${cwd ?? ""}\0${path ?? ""}`;
|
|
4183
|
-
const now = Date.now();
|
|
4184
|
-
const hit = fileCache.get(key);
|
|
4185
|
-
if (hit !== void 0 && now - hit.at < FILE_CACHE_TTL) {
|
|
4186
|
-
fileCache.delete(key);
|
|
4187
|
-
fileCache.set(key, hit);
|
|
4188
|
-
return hit.value;
|
|
4189
|
-
}
|
|
4190
|
-
const value = await fetchFileText(cwd, path);
|
|
4191
|
-
fileCache.set(key, { value, at: now });
|
|
4192
|
-
trimCache(fileCache, FILE_CACHE_LIMIT);
|
|
4193
|
-
return value;
|
|
4194
|
-
}
|
|
4195
|
-
var SNAPSHOT_CACHE_LIMIT = 160;
|
|
4196
|
-
var snapshotCache = /* @__PURE__ */ new Map();
|
|
4197
|
-
async function cachedSnapshot(sessionId, callId) {
|
|
4198
|
-
const key = `${sessionId ?? ""}\0${callId ?? ""}`;
|
|
4199
|
-
if (snapshotCache.has(key)) return snapshotCache.get(key) ?? null;
|
|
4200
|
-
let snapshot = await fetchSnapshot(sessionId, callId);
|
|
4201
|
-
if (snapshot === null) {
|
|
4202
|
-
await new Promise((resolve) => setTimeout(resolve, 180));
|
|
4203
|
-
snapshot = await fetchSnapshot(sessionId, callId);
|
|
4204
|
-
}
|
|
4205
|
-
snapshotCache.set(key, snapshot);
|
|
4206
|
-
trimCache(snapshotCache, SNAPSHOT_CACHE_LIMIT);
|
|
4207
|
-
return snapshot;
|
|
4208
|
-
}
|
|
4209
|
-
async function fetchUpdateInfo(refresh) {
|
|
4210
|
-
const controller = new AbortController();
|
|
4211
|
-
const timer = setTimeout(() => controller.abort(), 25e3);
|
|
4212
|
-
try {
|
|
4213
|
-
const suffix = refresh === true ? "?refresh=1" : "";
|
|
4214
|
-
const response = await fetch(`${API_PREFIX}/update/versions${suffix}`, {
|
|
4215
|
-
credentials: "include",
|
|
4216
|
-
signal: controller.signal,
|
|
4217
|
-
headers: { accept: "application/json" }
|
|
4218
|
-
});
|
|
4219
|
-
if (!response.ok) return null;
|
|
4220
|
-
const data = await response.json();
|
|
4221
|
-
return data !== null && typeof data === "object" && data.ok === true ? data : null;
|
|
4222
|
-
} catch {
|
|
4223
|
-
return null;
|
|
4224
|
-
} finally {
|
|
4225
|
-
clearTimeout(timer);
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
async function performUpdate(version) {
|
|
4229
|
-
const controller = new AbortController();
|
|
4230
|
-
const timer = setTimeout(() => controller.abort(), 26e4);
|
|
4231
|
-
try {
|
|
4232
|
-
const response = await fetch(`${API_PREFIX}/update/install`, {
|
|
4233
|
-
method: "POST",
|
|
4234
|
-
credentials: "include",
|
|
4235
|
-
signal: controller.signal,
|
|
4236
|
-
headers: { "content-type": "application/json", accept: "application/json" },
|
|
4237
|
-
body: JSON.stringify({ version })
|
|
4238
|
-
});
|
|
4239
|
-
if (!response.ok) return null;
|
|
4240
|
-
const data = await response.json();
|
|
4241
|
-
return data !== null && typeof data === "object" ? data : null;
|
|
4242
|
-
} catch {
|
|
4243
|
-
return null;
|
|
4244
|
-
} finally {
|
|
4245
|
-
clearTimeout(timer);
|
|
4246
|
-
}
|
|
4247
|
-
}
|
|
4248
|
-
|
|
4249
4381
|
// node_modules/highlight.js/es/core.js
|
|
4250
4382
|
var import_core = __toESM(require_core(), 1);
|
|
4251
4383
|
var core_default = import_core.default;
|
|
@@ -23417,7 +23549,11 @@ body[data-dsh-inline-diff-appearance='light'] [data-shell-tone='light'] {
|
|
|
23417
23549
|
}
|
|
23418
23550
|
/* ---- 增强风格平铺命令执行行(bash / pwsh / win_bash) ---- */
|
|
23419
23551
|
.enhanced-tool {
|
|
23420
|
-
|
|
23552
|
+
/* 代码字体只取“字体族”token:--dsw-font-markdown-code-block-small 是 font 简写
|
|
23553
|
+
(字号/行高/字族),直接当 font-family 用会得到非法值并回退宿主正文字体。
|
|
23554
|
+
DSH 主题在 body 上提供 --ds-font-family-code,:root 上提供
|
|
23555
|
+
--dsh-font-family-code-default 作为内置字体栈兜底。 */
|
|
23556
|
+
--enhanced-mono: var(--ds-font-family-code, var(--dsh-font-family-code-default, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace));
|
|
23421
23557
|
display: flex;
|
|
23422
23558
|
flex-direction: column;
|
|
23423
23559
|
/* 头部与 IO 面板之间不留 gap:IN 状态条必须直接顶到标题条,中间不能有空白带。
|
|
@@ -23816,7 +23952,7 @@ body[data-dsh-inline-diff-appearance='light'] [data-shell-tone='light'] {
|
|
|
23816
23952
|
.did-settings-scroll { padding: 12px 10px 14px 16px; }
|
|
23817
23953
|
}
|
|
23818
23954
|
.did-card {
|
|
23819
|
-
--did-mono: var(--
|
|
23955
|
+
--did-mono: var(--ds-font-family-code, var(--dsh-font-family-code-default, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace));
|
|
23820
23956
|
--did-inset-x: 9px;
|
|
23821
23957
|
display: flex;
|
|
23822
23958
|
flex-direction: column;
|
|
@@ -24095,7 +24231,7 @@ body[data-dsh-inline-diff-appearance='light'] [data-shell-tone='light'] {
|
|
|
24095
24231
|
padding: 0 5px;
|
|
24096
24232
|
border: 0.5px solid currentColor;
|
|
24097
24233
|
border-radius: 999px;
|
|
24098
|
-
font-family: var(--
|
|
24234
|
+
font-family: var(--dsw-font-family, system-ui, sans-serif);
|
|
24099
24235
|
font-size: 10px;
|
|
24100
24236
|
line-height: 14px;
|
|
24101
24237
|
white-space: nowrap;
|
|
@@ -24312,7 +24448,7 @@ body[data-dsh-inline-diff-appearance='light'] [data-shell-tone='light'] {
|
|
|
24312
24448
|
border: 0.5px solid var(--did-border-2);
|
|
24313
24449
|
border-radius: 999px;
|
|
24314
24450
|
color: var(--did-fg-tertiary);
|
|
24315
|
-
font-family: var(--enhanced-mono, var(--
|
|
24451
|
+
font-family: var(--enhanced-mono, var(--ds-font-family-code, ui-monospace, monospace));
|
|
24316
24452
|
font-size: 10.5px;
|
|
24317
24453
|
line-height: 16px;
|
|
24318
24454
|
white-space: nowrap;
|
|
@@ -24328,7 +24464,7 @@ body[data-dsh-inline-diff-appearance='light'] [data-shell-tone='light'] {
|
|
|
24328
24464
|
grid-template-columns: 2.7em minmax(0, 1fr) auto;
|
|
24329
24465
|
min-width: 0;
|
|
24330
24466
|
padding: 0 var(--did-inset-x) 0 14px;
|
|
24331
|
-
font-family: var(--did-mono,
|
|
24467
|
+
font-family: var(--did-mono, var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace));
|
|
24332
24468
|
font-size: calc(var(--dsh-content-font-size-secondary, 13px) - 1px);
|
|
24333
24469
|
line-height: 18px;
|
|
24334
24470
|
border-left: 0.5px solid transparent;
|
|
@@ -25201,6 +25337,95 @@ body[data-dsh-inline-diff-appearance='dark'] [data-shell-tone='light'] .did-zoom
|
|
|
25201
25337
|
}
|
|
25202
25338
|
}
|
|
25203
25339
|
|
|
25340
|
+
/* 常驻呼吸动画(状态点 / IN-OUT 色条)也遵循「减少动效」:只保留静态颜色,
|
|
25341
|
+
不脉冲。入场/输出动画已由上面的 no-preference 媒体查询整体关闭。 */
|
|
25342
|
+
@media (prefers-reduced-motion: reduce) {
|
|
25343
|
+
.enhanced-tool[data-state='running'] .enhanced-dot,
|
|
25344
|
+
.enhanced-tool[data-state='preparing'] .enhanced-dot,
|
|
25345
|
+
.enhanced-section[data-state='running'],
|
|
25346
|
+
.enhanced-section[data-state='preparing'],
|
|
25347
|
+
.did-state[data-state='running'] .did-dot,
|
|
25348
|
+
.did-state[data-state='preparing'] .did-dot {
|
|
25349
|
+
animation: none;
|
|
25350
|
+
}
|
|
25351
|
+
}
|
|
25352
|
+
|
|
25353
|
+
/* ---- 设置页:额外可读目录 ----------------------------------------------- */
|
|
25354
|
+
.did-readroots {
|
|
25355
|
+
margin-top: 14px;
|
|
25356
|
+
padding-top: 14px;
|
|
25357
|
+
border-top: 0.5px solid var(--did-border-1);
|
|
25358
|
+
}
|
|
25359
|
+
.did-readroots-row {
|
|
25360
|
+
display: flex;
|
|
25361
|
+
align-items: center;
|
|
25362
|
+
gap: 8px;
|
|
25363
|
+
margin-top: 8px;
|
|
25364
|
+
}
|
|
25365
|
+
.did-readroots-input {
|
|
25366
|
+
flex: 1 1 auto;
|
|
25367
|
+
min-width: 0;
|
|
25368
|
+
padding: 5px 8px;
|
|
25369
|
+
border: 0.5px solid var(--did-border-2);
|
|
25370
|
+
border-radius: 8px;
|
|
25371
|
+
background: var(--did-surface-2);
|
|
25372
|
+
color: var(--did-fg-primary);
|
|
25373
|
+
font-family: var(--ds-font-family-code, ui-monospace, monospace);
|
|
25374
|
+
font-size: 11.5px;
|
|
25375
|
+
}
|
|
25376
|
+
.did-readroots-input::placeholder { color: var(--did-fg-tertiary); }
|
|
25377
|
+
.did-readroots-input:focus-visible {
|
|
25378
|
+
outline: 1px solid var(--dsw-alias-brand-primary);
|
|
25379
|
+
outline-offset: 1px;
|
|
25380
|
+
}
|
|
25381
|
+
.did-readroots-button {
|
|
25382
|
+
flex: none;
|
|
25383
|
+
padding: 5px 10px;
|
|
25384
|
+
border: 0.5px solid var(--did-border-2);
|
|
25385
|
+
border-radius: 8px;
|
|
25386
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 12%, transparent);
|
|
25387
|
+
color: var(--did-fg-primary);
|
|
25388
|
+
font-size: 11.5px;
|
|
25389
|
+
cursor: pointer;
|
|
25390
|
+
}
|
|
25391
|
+
.did-readroots-button:hover:not(:disabled) {
|
|
25392
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 20%, transparent);
|
|
25393
|
+
}
|
|
25394
|
+
.did-readroots-button:disabled { opacity: 0.5; cursor: default; }
|
|
25395
|
+
.did-readroots-list {
|
|
25396
|
+
display: flex;
|
|
25397
|
+
flex-direction: column;
|
|
25398
|
+
gap: 5px;
|
|
25399
|
+
margin-top: 8px;
|
|
25400
|
+
}
|
|
25401
|
+
.did-readroots-item {
|
|
25402
|
+
display: flex;
|
|
25403
|
+
align-items: center;
|
|
25404
|
+
gap: 8px;
|
|
25405
|
+
padding: 5px 8px;
|
|
25406
|
+
border: 0.5px solid var(--did-border-1);
|
|
25407
|
+
border-radius: 6px;
|
|
25408
|
+
background: var(--did-io-bg);
|
|
25409
|
+
}
|
|
25410
|
+
.did-readroots-path {
|
|
25411
|
+
flex: 1 1 auto;
|
|
25412
|
+
min-width: 0;
|
|
25413
|
+
overflow-wrap: anywhere;
|
|
25414
|
+
color: var(--did-fg-secondary);
|
|
25415
|
+
font-family: var(--ds-font-family-code, ui-monospace, monospace);
|
|
25416
|
+
font-size: 11px;
|
|
25417
|
+
}
|
|
25418
|
+
.did-readroots-empty {
|
|
25419
|
+
padding: 2px 1px;
|
|
25420
|
+
color: var(--did-fg-tertiary);
|
|
25421
|
+
font-size: 11px;
|
|
25422
|
+
}
|
|
25423
|
+
.did-readroots-ok {
|
|
25424
|
+
margin-top: 6px;
|
|
25425
|
+
font-size: 11.5px;
|
|
25426
|
+
color: var(--dsw-alias-state-success-primary);
|
|
25427
|
+
}
|
|
25428
|
+
|
|
25204
25429
|
/* ---- 设置页:版本与更新面板 --------------------------------------------- */
|
|
25205
25430
|
.did-update {
|
|
25206
25431
|
margin-top: 14px;
|
|
@@ -25511,6 +25736,148 @@ ${EMPHASIS_RULES}
|
|
|
25511
25736
|
${BADGE_RULES}
|
|
25512
25737
|
`;
|
|
25513
25738
|
|
|
25739
|
+
// src/client/tool-catalog.js
|
|
25740
|
+
var TOOL_CATALOG_REFRESH_MS = 3e4;
|
|
25741
|
+
var TOOL_NAME_LIMIT = 200;
|
|
25742
|
+
var TOOL_CATALOG_LIMIT = 500;
|
|
25743
|
+
function selectDynamicToolKeys(names, options = {}) {
|
|
25744
|
+
const known = toSet(options.known);
|
|
25745
|
+
const claimed = toSet(options.claimed);
|
|
25746
|
+
const already = toSet(options.already);
|
|
25747
|
+
const limit = Number.isFinite(options.limit) && options.limit > 0 ? Math.floor(options.limit) : TOOL_CATALOG_LIMIT;
|
|
25748
|
+
const selected = [];
|
|
25749
|
+
if (!Array.isArray(names)) return selected;
|
|
25750
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25751
|
+
for (const name of names) {
|
|
25752
|
+
if (typeof name !== "string" || name === "" || name.length > TOOL_NAME_LIMIT) continue;
|
|
25753
|
+
if (seen.has(name)) continue;
|
|
25754
|
+
seen.add(name);
|
|
25755
|
+
if (known.has(name) || claimed.has(name) || already.has(name)) continue;
|
|
25756
|
+
selected.push(name);
|
|
25757
|
+
if (selected.length >= limit) break;
|
|
25758
|
+
}
|
|
25759
|
+
return selected;
|
|
25760
|
+
}
|
|
25761
|
+
function toSet(value) {
|
|
25762
|
+
if (value instanceof Set) return value;
|
|
25763
|
+
if (value === null || value === void 0) return /* @__PURE__ */ new Set();
|
|
25764
|
+
try {
|
|
25765
|
+
return new Set(value);
|
|
25766
|
+
} catch {
|
|
25767
|
+
return /* @__PURE__ */ new Set();
|
|
25768
|
+
}
|
|
25769
|
+
}
|
|
25770
|
+
|
|
25771
|
+
// src/client/dynamic-tool-views.js
|
|
25772
|
+
function createDynamicToolViews(options) {
|
|
25773
|
+
const { slots, known, isEnabled, fetchNames, register } = options;
|
|
25774
|
+
const refreshMs = Number.isFinite(options.refreshMs) && options.refreshMs > 0 ? options.refreshMs : TOOL_CATALOG_REFRESH_MS;
|
|
25775
|
+
const setTimeoutFn = typeof options.setTimeoutFn === "function" ? options.setTimeoutFn : setTimeout;
|
|
25776
|
+
const clearTimeoutFn = typeof options.clearTimeoutFn === "function" ? options.clearTimeoutFn : clearTimeout;
|
|
25777
|
+
const knownSet = known instanceof Set ? known : new Set(known ?? []);
|
|
25778
|
+
const canInspectOccupancy = typeof slots?.entries === "function";
|
|
25779
|
+
const views = /* @__PURE__ */ new Map();
|
|
25780
|
+
let disposed = false;
|
|
25781
|
+
let refreshing = false;
|
|
25782
|
+
let timer = null;
|
|
25783
|
+
let enabled = false;
|
|
25784
|
+
const entryCount = (key) => {
|
|
25785
|
+
try {
|
|
25786
|
+
const entries = typeof slots?.entries === "function" ? slots.entries("tool.call.toolview") : [];
|
|
25787
|
+
if (!Array.isArray(entries)) return 0;
|
|
25788
|
+
let count = 0;
|
|
25789
|
+
for (const entry of entries) if (entry?.options?.key === key) count += 1;
|
|
25790
|
+
return count;
|
|
25791
|
+
} catch {
|
|
25792
|
+
return 0;
|
|
25793
|
+
}
|
|
25794
|
+
};
|
|
25795
|
+
const release = (key) => {
|
|
25796
|
+
const dispose2 = views.get(key);
|
|
25797
|
+
if (dispose2 === void 0) return;
|
|
25798
|
+
views.delete(key);
|
|
25799
|
+
try {
|
|
25800
|
+
dispose2();
|
|
25801
|
+
} catch (error) {
|
|
25802
|
+
console.warn(`[dsh-inline-diff] failed to release dynamic tool view "${key}"`, error);
|
|
25803
|
+
}
|
|
25804
|
+
};
|
|
25805
|
+
const clear = () => {
|
|
25806
|
+
for (const key of [...views.keys()]) release(key);
|
|
25807
|
+
};
|
|
25808
|
+
const clearTimer = () => {
|
|
25809
|
+
if (timer === null) return;
|
|
25810
|
+
clearTimeoutFn(timer);
|
|
25811
|
+
timer = null;
|
|
25812
|
+
};
|
|
25813
|
+
const schedule = () => {
|
|
25814
|
+
if (disposed || !enabled) {
|
|
25815
|
+
clearTimer();
|
|
25816
|
+
return;
|
|
25817
|
+
}
|
|
25818
|
+
clearTimer();
|
|
25819
|
+
timer = setTimeoutFn(() => {
|
|
25820
|
+
timer = null;
|
|
25821
|
+
void refresh();
|
|
25822
|
+
}, refreshMs);
|
|
25823
|
+
};
|
|
25824
|
+
async function refresh() {
|
|
25825
|
+
if (disposed || refreshing || !enabled) return;
|
|
25826
|
+
if (!canInspectOccupancy) return;
|
|
25827
|
+
refreshing = true;
|
|
25828
|
+
try {
|
|
25829
|
+
const names = await fetchNames();
|
|
25830
|
+
if (disposed || !enabled) return;
|
|
25831
|
+
if (!Array.isArray(names)) return;
|
|
25832
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
25833
|
+
for (const name of names) {
|
|
25834
|
+
if (knownSet.has(name) || views.has(name)) continue;
|
|
25835
|
+
if (entryCount(name) > 0) claimed.add(name);
|
|
25836
|
+
}
|
|
25837
|
+
const selected = selectDynamicToolKeys(names, { known: knownSet, claimed, already: views.keys() });
|
|
25838
|
+
for (const key of selected) {
|
|
25839
|
+
if (disposed || !enabled) return;
|
|
25840
|
+
if (entryCount(key) > 0) continue;
|
|
25841
|
+
const dispose2 = register(key);
|
|
25842
|
+
if (typeof dispose2 === "function") views.set(key, dispose2);
|
|
25843
|
+
}
|
|
25844
|
+
} catch (error) {
|
|
25845
|
+
console.warn("[dsh-inline-diff] cannot refresh third-party tool views", error);
|
|
25846
|
+
} finally {
|
|
25847
|
+
refreshing = false;
|
|
25848
|
+
schedule();
|
|
25849
|
+
}
|
|
25850
|
+
}
|
|
25851
|
+
function stepAside() {
|
|
25852
|
+
if (disposed) return;
|
|
25853
|
+
for (const key of [...views.keys()]) {
|
|
25854
|
+
if (entryCount(key) > 1) release(key);
|
|
25855
|
+
}
|
|
25856
|
+
}
|
|
25857
|
+
function setEnabled(next) {
|
|
25858
|
+
if (disposed) return void 0;
|
|
25859
|
+
enabled = next === true;
|
|
25860
|
+
if (!enabled) {
|
|
25861
|
+
clearTimer();
|
|
25862
|
+
clear();
|
|
25863
|
+
return void 0;
|
|
25864
|
+
}
|
|
25865
|
+
const pending = refresh();
|
|
25866
|
+
schedule();
|
|
25867
|
+
return pending;
|
|
25868
|
+
}
|
|
25869
|
+
function dispose() {
|
|
25870
|
+
if (disposed) return;
|
|
25871
|
+
disposed = true;
|
|
25872
|
+
clearTimer();
|
|
25873
|
+
clear();
|
|
25874
|
+
}
|
|
25875
|
+
function keys() {
|
|
25876
|
+
return [...views.keys()];
|
|
25877
|
+
}
|
|
25878
|
+
return { refresh, stepAside, setEnabled, dispose, keys };
|
|
25879
|
+
}
|
|
25880
|
+
|
|
25514
25881
|
// src/client/read-range.js
|
|
25515
25882
|
function compressLineRanges(numbers) {
|
|
25516
25883
|
const ranges = [];
|
|
@@ -25702,7 +26069,7 @@ function startReadRangeChips(t) {
|
|
|
25702
26069
|
}
|
|
25703
26070
|
|
|
25704
26071
|
// src/client/project.js
|
|
25705
|
-
var VERSION = "1.4.
|
|
26072
|
+
var VERSION = "1.4.1";
|
|
25706
26073
|
var AUTHOR = "Him666233";
|
|
25707
26074
|
var AUTHOR_URL = "https://github.com/Him666233";
|
|
25708
26075
|
var REPO_URL = "https://github.com/Him666233/dsh-inline-diff";
|
|
@@ -26244,6 +26611,7 @@ function SettingsPanel({ t, onClose }) {
|
|
|
26244
26611
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-settings-note", children: t("settings.subagentNote") }),
|
|
26245
26612
|
dsmMode !== void 0 && settings.transcript === "enhanced" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-settings-note", children: t("settings.dsmCurrent", { mode: dsmMode }) }) : null,
|
|
26246
26613
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FxSettings, { t, settings, onChange: patchSurfaceEffect }),
|
|
26614
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReadRootsSection, { t }),
|
|
26247
26615
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UpdateSection, { t }),
|
|
26248
26616
|
error !== "" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-settings-error", children: error }) : null
|
|
26249
26617
|
] }),
|
|
@@ -26281,6 +26649,107 @@ function SettingsLauncher({ wide, t }) {
|
|
|
26281
26649
|
}
|
|
26282
26650
|
);
|
|
26283
26651
|
}
|
|
26652
|
+
function ReadRootsSection({ t }) {
|
|
26653
|
+
const [roots, setRoots] = (0, import_react6.useState)([]);
|
|
26654
|
+
const [max, setMax] = (0, import_react6.useState)(12);
|
|
26655
|
+
const [loaded, setLoaded] = (0, import_react6.useState)(false);
|
|
26656
|
+
const [draft, setDraft] = (0, import_react6.useState)("");
|
|
26657
|
+
const [busy, setBusy] = (0, import_react6.useState)(false);
|
|
26658
|
+
const [feedback, setFeedback] = (0, import_react6.useState)(null);
|
|
26659
|
+
(0, import_react6.useEffect)(() => {
|
|
26660
|
+
let alive = true;
|
|
26661
|
+
fetchReadRoots().then((result) => {
|
|
26662
|
+
if (!alive) return;
|
|
26663
|
+
if (result !== null) {
|
|
26664
|
+
setRoots(result.roots);
|
|
26665
|
+
setMax(result.max);
|
|
26666
|
+
}
|
|
26667
|
+
setLoaded(true);
|
|
26668
|
+
});
|
|
26669
|
+
return () => {
|
|
26670
|
+
alive = false;
|
|
26671
|
+
};
|
|
26672
|
+
}, []);
|
|
26673
|
+
const save = async (next) => {
|
|
26674
|
+
if (busy) return;
|
|
26675
|
+
setBusy(true);
|
|
26676
|
+
setFeedback(null);
|
|
26677
|
+
const result = await saveReadRoots(next);
|
|
26678
|
+
setBusy(false);
|
|
26679
|
+
if (result === null) {
|
|
26680
|
+
setFeedback({ kind: "error", code: "network" });
|
|
26681
|
+
return;
|
|
26682
|
+
}
|
|
26683
|
+
if (result.ok !== true) {
|
|
26684
|
+
setFeedback({ kind: "error", code: result.code });
|
|
26685
|
+
return;
|
|
26686
|
+
}
|
|
26687
|
+
setRoots(result.roots);
|
|
26688
|
+
setFeedback({ kind: "ok" });
|
|
26689
|
+
};
|
|
26690
|
+
const add = () => {
|
|
26691
|
+
const value = draft.trim();
|
|
26692
|
+
if (value === "" || busy) return;
|
|
26693
|
+
setDraft("");
|
|
26694
|
+
void save([...roots, value]);
|
|
26695
|
+
};
|
|
26696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "did-readroots", children: [
|
|
26697
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-setting-label", children: t("settings.readRoots") }),
|
|
26698
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-setting-desc", children: t("settings.readRootsDesc") }),
|
|
26699
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "did-readroots-row", children: [
|
|
26700
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26701
|
+
"input",
|
|
26702
|
+
{
|
|
26703
|
+
className: "did-readroots-input",
|
|
26704
|
+
type: "text",
|
|
26705
|
+
value: draft,
|
|
26706
|
+
placeholder: t("settings.readRootsPlaceholder"),
|
|
26707
|
+
"aria-label": t("settings.readRootsPlaceholder"),
|
|
26708
|
+
disabled: busy || !loaded,
|
|
26709
|
+
spellCheck: false,
|
|
26710
|
+
onChange: (event) => setDraft(event.target.value),
|
|
26711
|
+
onKeyDown: (event) => {
|
|
26712
|
+
if (event.key !== "Enter") return;
|
|
26713
|
+
event.preventDefault();
|
|
26714
|
+
add();
|
|
26715
|
+
}
|
|
26716
|
+
}
|
|
26717
|
+
),
|
|
26718
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26719
|
+
"button",
|
|
26720
|
+
{
|
|
26721
|
+
type: "button",
|
|
26722
|
+
className: "did-readroots-button",
|
|
26723
|
+
disabled: busy || !loaded || draft.trim() === "",
|
|
26724
|
+
onClick: add,
|
|
26725
|
+
children: busy ? t("settings.readRootsBusy") : t("settings.readRootsAdd")
|
|
26726
|
+
}
|
|
26727
|
+
)
|
|
26728
|
+
] }),
|
|
26729
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-readroots-list", children: roots.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-readroots-empty", children: t("settings.readRootsEmpty") }) : roots.map((root) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "did-readroots-item", children: [
|
|
26730
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "did-readroots-path", title: root, children: root }),
|
|
26731
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26732
|
+
"button",
|
|
26733
|
+
{
|
|
26734
|
+
type: "button",
|
|
26735
|
+
className: "did-readroots-button",
|
|
26736
|
+
disabled: busy,
|
|
26737
|
+
onClick: () => {
|
|
26738
|
+
void save(roots.filter((item) => item !== root));
|
|
26739
|
+
},
|
|
26740
|
+
children: t("settings.readRootsRemove")
|
|
26741
|
+
}
|
|
26742
|
+
)
|
|
26743
|
+
] }, root)) }),
|
|
26744
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "did-settings-note", children: [
|
|
26745
|
+
t("settings.readRootsLimit", { max }),
|
|
26746
|
+
" · ",
|
|
26747
|
+
t("settings.readRootsNote")
|
|
26748
|
+
] }),
|
|
26749
|
+
feedback?.kind === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-readroots-ok", children: t("settings.readRootsSaved") }) : null,
|
|
26750
|
+
feedback?.kind === "error" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "did-settings-error", children: t("settings.readRootsError", { code: feedback.code ?? "unknown" }) }) : null
|
|
26751
|
+
] });
|
|
26752
|
+
}
|
|
26284
26753
|
function UpdateSection({ t }) {
|
|
26285
26754
|
const [info, setInfo] = (0, import_react6.useState)(null);
|
|
26286
26755
|
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
@@ -26462,6 +26931,13 @@ var PluginSettingsLauncher = withPluginI18n(SettingsLauncher);
|
|
|
26462
26931
|
var inject = ["slots", "locale", "configForms"];
|
|
26463
26932
|
var INLINE_DIFF_KEYS = MUTATION_TOOLS;
|
|
26464
26933
|
var ENHANCED_SHELL_KEYS = SHELL_KEYS;
|
|
26934
|
+
var KNOWN_TOOL_KEYS = /* @__PURE__ */ new Set([
|
|
26935
|
+
...INLINE_DIFF_KEYS,
|
|
26936
|
+
...ENHANCED_SHELL_KEYS,
|
|
26937
|
+
...ENHANCED_DETAILS_KEYS,
|
|
26938
|
+
...ENHANCED_GENERIC_KEYS,
|
|
26939
|
+
...ENHANCED_SEARCH_WEB_KEYS
|
|
26940
|
+
]);
|
|
26465
26941
|
var VIEW_PRIORITY = -100;
|
|
26466
26942
|
function apply(ctx) {
|
|
26467
26943
|
ctx.effect(() => ctx.locale.register(NS, dicts), "dsh-inline-diff: dictionaries");
|
|
@@ -26495,47 +26971,69 @@ function apply(ctx) {
|
|
|
26495
26971
|
};
|
|
26496
26972
|
}, "dsh-inline-diff: appearance");
|
|
26497
26973
|
ctx.slots.inject("tool.call.toolview", () => {
|
|
26498
|
-
|
|
26974
|
+
const knownViews = /* @__PURE__ */ new Map();
|
|
26499
26975
|
let signature = "";
|
|
26500
|
-
const
|
|
26501
|
-
for (const dispose of
|
|
26502
|
-
|
|
26976
|
+
const clearKnown = () => {
|
|
26977
|
+
for (const dispose of knownViews.values()) dispose();
|
|
26978
|
+
knownViews.clear();
|
|
26503
26979
|
};
|
|
26504
|
-
const
|
|
26980
|
+
const register = (key, Component) => {
|
|
26505
26981
|
try {
|
|
26506
|
-
|
|
26982
|
+
return ctx.slots.register({
|
|
26507
26983
|
name: "tool.call.toolview",
|
|
26508
26984
|
key,
|
|
26509
26985
|
priority: VIEW_PRIORITY,
|
|
26510
26986
|
locale: NS
|
|
26511
|
-
}, Component)
|
|
26987
|
+
}, Component);
|
|
26512
26988
|
} catch (error) {
|
|
26513
26989
|
console.warn(`[dsh-inline-diff] cannot take over tool view "${key}"; the stock DSH row stays active`, error);
|
|
26990
|
+
return null;
|
|
26514
26991
|
}
|
|
26515
26992
|
};
|
|
26993
|
+
const registerKnown = (key, Component) => {
|
|
26994
|
+
const dispose = register(key, Component);
|
|
26995
|
+
if (dispose !== null) knownViews.set(key, dispose);
|
|
26996
|
+
};
|
|
26997
|
+
const dynamic = createDynamicToolViews({
|
|
26998
|
+
slots: ctx.slots,
|
|
26999
|
+
known: KNOWN_TOOL_KEYS,
|
|
27000
|
+
isEnabled: () => getSettings().toolCalls === "enhanced",
|
|
27001
|
+
fetchNames: fetchToolNames,
|
|
27002
|
+
register: (key) => register(key, PluginEnhancedExpandedTool)
|
|
27003
|
+
});
|
|
26516
27004
|
const sync = () => {
|
|
26517
27005
|
const settings = getSettings();
|
|
26518
27006
|
const next = `${settings.fileCards}|${settings.shellRows}|${settings.toolCalls}`;
|
|
26519
27007
|
if (next === signature) return;
|
|
26520
27008
|
signature = next;
|
|
26521
|
-
|
|
27009
|
+
clearKnown();
|
|
26522
27010
|
if (settings.fileCards === "enhanced") {
|
|
26523
|
-
for (const key of INLINE_DIFF_KEYS)
|
|
27011
|
+
for (const key of INLINE_DIFF_KEYS) registerKnown(key, PluginInlineDiffCard);
|
|
26524
27012
|
}
|
|
26525
27013
|
if (settings.shellRows === "enhanced") {
|
|
26526
|
-
for (const key of ENHANCED_SHELL_KEYS)
|
|
27014
|
+
for (const key of ENHANCED_SHELL_KEYS) registerKnown(key, PluginEnhancedShellCard);
|
|
26527
27015
|
}
|
|
26528
27016
|
if (settings.toolCalls === "enhanced") {
|
|
26529
27017
|
for (const key of [...ENHANCED_DETAILS_KEYS, ...ENHANCED_GENERIC_KEYS, ...ENHANCED_SEARCH_WEB_KEYS]) {
|
|
26530
|
-
|
|
27018
|
+
registerKnown(key, PluginEnhancedExpandedTool);
|
|
26531
27019
|
}
|
|
26532
27020
|
}
|
|
27021
|
+
dynamic.setEnabled(settings.toolCalls === "enhanced");
|
|
26533
27022
|
};
|
|
26534
27023
|
const unsubscribe = subscribeSettings(sync);
|
|
27024
|
+
const unsubscribeSlot = typeof ctx.slots.subscribe === "function" ? ctx.slots.subscribe("tool.call.toolview", () => dynamic.stepAside()) : () => {
|
|
27025
|
+
};
|
|
27026
|
+
const onFocus = typeof window !== "undefined" && typeof window.addEventListener === "function" ? () => {
|
|
27027
|
+
void dynamic.refresh();
|
|
27028
|
+
} : null;
|
|
27029
|
+
if (onFocus !== null) window.addEventListener("focus", onFocus);
|
|
26535
27030
|
sync();
|
|
26536
27031
|
return () => {
|
|
26537
27032
|
unsubscribe();
|
|
26538
|
-
|
|
27033
|
+
if (typeof unsubscribeSlot === "function") unsubscribeSlot();
|
|
27034
|
+
if (onFocus !== null) window.removeEventListener("focus", onFocus);
|
|
27035
|
+
dynamic.dispose();
|
|
27036
|
+
clearKnown();
|
|
26539
27037
|
};
|
|
26540
27038
|
});
|
|
26541
27039
|
ctx.slots.inject("shell.overlay", function* () {
|