dsh-vscode-mode 0.5.1 → 0.5.3
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.md +32 -5
- package/lib/client.js +556 -31
- package/lib/client.js.map +1 -1
- package/lib/index.js +185 -40
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/client/compat.ts +1 -1
- package/src/client/editorLimit.ts +31 -0
- package/src/client/index.ts +4 -0
- package/src/client/markdownPreview.ts +24 -0
- package/src/client/md/componentType.ts +28 -0
- package/src/client/md/mdPanel.ts +98 -0
- package/src/client/searchSeed.ts +64 -0
- package/src/client/sidebar/panels/SearchPanel.ts +70 -15
- package/src/client/styles/editor.css +10 -1
- package/src/client/tabActions.ts +54 -0
- package/src/client/ui/EditorView.ts +167 -13
- package/src/client/ui/McpSettings.ts +29 -0
- package/src/client/ui/commandCatalog.ts +5 -0
- package/src/client/ui/horizontalWheel.ts +85 -0
- package/src/client-primitives.d.ts +34 -0
- package/src/compat.ts +2 -2
- package/src/fileOpenSettings.ts +89 -10
- package/src/lsp/extmgr.ts +56 -3
- package/src/lsp/zip.ts +25 -9
- package/src/revert.ts +20 -8
- package/src/shared/editorLimit.ts +46 -0
- package/src/shared/keybindings.ts +3 -0
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { chmod, copyFile, cp, mkdir, readFile, readdir, rename, rm, stat, truncate, writeFile } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, extname, join, normalize, resolve, sep } from "node:path";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, watch, writeFileSync } from "node:fs";
|
|
4
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, watch, writeFileSync } from "node:fs";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import { homedir, tmpdir } from "node:os";
|
|
7
7
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -125,6 +125,7 @@ const KEYBINDING_DEFAULTS = {
|
|
|
125
125
|
"edrv.quickOpen": "Ctrl+P",
|
|
126
126
|
"edrv.toggleSidebar": "Ctrl+B",
|
|
127
127
|
"edrv.searchInFiles": "Ctrl+Shift+F",
|
|
128
|
+
"edrv.toggleMarkdownPreview": "Ctrl+Shift+V",
|
|
128
129
|
"edrv.navigateBack": "Alt+ArrowLeft|Ctrl+Alt+-",
|
|
129
130
|
"edrv.navigateForward": "Alt+ArrowRight|Ctrl+Shift+-",
|
|
130
131
|
"edrv.nextTab": "Ctrl+Alt+ArrowRight|Ctrl+PageDown",
|
|
@@ -330,17 +331,83 @@ async function hostImport(specifier) {
|
|
|
330
331
|
return import(specifier);
|
|
331
332
|
}
|
|
332
333
|
/**
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
334
|
+
* schema 库候选名(新名在前)。
|
|
335
|
+
* DSH 官方自 0.1.5 起把 vendored 包改名为 @deepseek-ai/schemastery 并全树改用新名,
|
|
336
|
+
* 安装树里**没有**裸 schemastery;裸名保留给 rc 线(其 dsh-settings 仍 peers 旧名),
|
|
337
|
+
* 也让开发形态(插件 node_modules 有 devDependency 副本)继续可用。
|
|
338
|
+
*/
|
|
339
|
+
const SCHEMA_SPECIFIERS = ["@deepseek-ai/schemastery", "schemastery"];
|
|
340
|
+
/** 设置持久化包名(installSettingsSection 仅 rc 线提供,alpha 线缺失属正常)。 */
|
|
341
|
+
const SETTINGS_SPECIFIER = "@deepseek-ai/dsh-settings";
|
|
342
|
+
/**
|
|
343
|
+
* 逐个尝试候选名,返回首个加载成功的模块及其包名(全失败返回 null,不抛错)。
|
|
344
|
+
* @author ddj 2026年09月18号
|
|
345
|
+
* @param specifiers 候选包名(按优先级)
|
|
346
|
+
* @param importFn 加载函数(测试注入)
|
|
347
|
+
* @returns 命中的模块与包名;全失败返回 null
|
|
348
|
+
*/
|
|
349
|
+
async function firstImport(specifiers, importFn = hostImport) {
|
|
350
|
+
for (const specifier of specifiers) try {
|
|
351
|
+
return {
|
|
352
|
+
specifier,
|
|
353
|
+
module: await importFn(specifier)
|
|
354
|
+
};
|
|
355
|
+
} catch {}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 抹平 schema 库的 ESM/CJS 互操作形态取默认导出。
|
|
360
|
+
* 三种实测形态:真 ESM(`default` 即 z)、CJS 经 import()(`default` 与
|
|
361
|
+
* `module.exports` 同为 z)、双层包装(`default.default` 才是 z)。
|
|
362
|
+
* @author ddj 2026年09月18号
|
|
363
|
+
* @param module 加载到的模块命名空间(可空)
|
|
364
|
+
* @returns 具备 object/string 等构造器的 z;取不到返回 null
|
|
365
|
+
*/
|
|
366
|
+
function pickSchema(module) {
|
|
367
|
+
const layers = [
|
|
368
|
+
module,
|
|
369
|
+
module?.default,
|
|
370
|
+
module?.["module.exports"]
|
|
371
|
+
];
|
|
372
|
+
for (const layer of layers) {
|
|
373
|
+
const z = layer?.default ?? layer;
|
|
374
|
+
if (z && typeof z.object === "function" && typeof z.string === "function") return z;
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
/** 实际命中的 schema 库名(供兼容性报告展示;未命中为空串)。 */
|
|
379
|
+
let schemaLib = "";
|
|
380
|
+
/**
|
|
381
|
+
* 读取实际命中的 schema 库名(报告文案用)。
|
|
382
|
+
* @author ddj 2026年09月18号
|
|
383
|
+
* @returns 包名;未解析到为空串
|
|
384
|
+
*/
|
|
385
|
+
function schemaLibName() {
|
|
386
|
+
return schemaLib;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* 动态加载设置依赖(模块级缓存;schema 库缺失返回 null 而非抛错)。
|
|
390
|
+
* ⚠️ 两个依赖**独立解析**:@deepseek-ai/dsh-settings 仅 rc 线跑 legacy 策略时需要,
|
|
391
|
+
* alpha 线走 settings 服务 installSection 用不到它;原先 Promise.all 让该包缺失
|
|
392
|
+
* 拖垮整体 → 用户端(npm 安装)settings section 永不装配。
|
|
393
|
+
* 同理,schema 库按候选链解析(安装树只有新名 @deepseek-ai/schemastery)。
|
|
394
|
+
* @author ddj 2026年08月24号 / 2026年09月15号 / 2026年09月18号
|
|
395
|
+
* @param importFn 加载函数(测试注入;缺省宿主锚点动态导入)
|
|
337
396
|
* @returns 设置依赖或 null
|
|
338
397
|
*/
|
|
339
|
-
function loadSettingsDeps() {
|
|
340
|
-
if (!depsPromise) depsPromise = Promise.all([
|
|
341
|
-
|
|
342
|
-
z
|
|
343
|
-
|
|
398
|
+
function loadSettingsDeps(importFn = hostImport) {
|
|
399
|
+
if (!depsPromise) depsPromise = Promise.all([firstImport([SETTINGS_SPECIFIER], importFn), firstImport(SCHEMA_SPECIFIERS, importFn)]).then(([settingsHit, schemaHit]) => {
|
|
400
|
+
const z = pickSchema(schemaHit?.module);
|
|
401
|
+
if (!z) {
|
|
402
|
+
schemaLib = "";
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
schemaLib = schemaHit?.specifier ?? "";
|
|
406
|
+
return {
|
|
407
|
+
installSettingsSection: (settingsHit?.module)?.installSettingsSection,
|
|
408
|
+
z
|
|
409
|
+
};
|
|
410
|
+
}).catch(() => null);
|
|
344
411
|
return depsPromise;
|
|
345
412
|
}
|
|
346
413
|
const INSTALL_UNMOUNTED = "设置 section 尚未装配";
|
|
@@ -480,6 +547,7 @@ async function installOpenSettingsSection(ctx, ns, entry, hooks, loader = loadSe
|
|
|
480
547
|
fileOpenTool: deps.z.string().default(FILE_OPEN_DEFAULT),
|
|
481
548
|
keybindings: deps.z.object(keybindingsShape(deps.z)).default({ ...KEYBINDING_DEFAULTS }),
|
|
482
549
|
sidebarMinWidth: deps.z.number().default(300),
|
|
550
|
+
maxOpenEditors: deps.z.number().default(10),
|
|
483
551
|
integrationBaseUrl: deps.z.string().default(INTEGRATION_BASE_DEFAULT),
|
|
484
552
|
aiInline: deps.z.boolean().default(AI_CONFIG_DEFAULT.enabled),
|
|
485
553
|
aiProvider: deps.z.string().default(AI_CONFIG_DEFAULT.provider),
|
|
@@ -1698,7 +1766,7 @@ function detectExternal(ctx, depsAvailable) {
|
|
|
1698
1766
|
{
|
|
1699
1767
|
name: "设置持久化(@deepseek-ai/dsh-settings)",
|
|
1700
1768
|
active: depsAvailable,
|
|
1701
|
-
note: depsAvailable ? "设置 section
|
|
1769
|
+
note: depsAvailable ? "设置 section 已安装(schema: " + (schemaLibName() || "未知") + ")" : "未安装:fileOpenTool 持久化降级为配置值"
|
|
1702
1770
|
},
|
|
1703
1771
|
{
|
|
1704
1772
|
name: "settings 服务",
|
|
@@ -4256,8 +4324,33 @@ function newContentSearcher(ctx) {
|
|
|
4256
4324
|
//#endregion
|
|
4257
4325
|
//#region src/revert.ts
|
|
4258
4326
|
/**
|
|
4327
|
+
* 删除单文件的 argv(纯函数,platform 可注入便于单测)。
|
|
4328
|
+
* Windows 走 PowerShell Remove-Item;其余平台走 /bin/rm。
|
|
4329
|
+
* 原先无条件先发 powershell:macOS/Linux 上必然 spawn 失败后才回落,
|
|
4330
|
+
* 每删一个文件多一次无谓 spawn 与失败噪声。
|
|
4331
|
+
* @author ddj 2026年09月18号
|
|
4332
|
+
* @param absPath 绝对路径
|
|
4333
|
+
* @param platform 目标平台(缺省当前进程平台)
|
|
4334
|
+
* @returns 删除命令 argv
|
|
4335
|
+
*/
|
|
4336
|
+
function removeFileArgv(absPath, platform = process.platform) {
|
|
4337
|
+
if (platform === "win32") return [
|
|
4338
|
+
"powershell",
|
|
4339
|
+
"-NoProfile",
|
|
4340
|
+
"-NonInteractive",
|
|
4341
|
+
"-Command",
|
|
4342
|
+
"Remove-Item -LiteralPath \"" + absPath + "\" -Force"
|
|
4343
|
+
];
|
|
4344
|
+
return [
|
|
4345
|
+
"/bin/rm",
|
|
4346
|
+
"-f",
|
|
4347
|
+
"--",
|
|
4348
|
+
absPath
|
|
4349
|
+
];
|
|
4350
|
+
}
|
|
4351
|
+
/**
|
|
4259
4352
|
* 删除新建文件(拒绝创建时):subprocess 删除,路径先经 fs.contains 校验工作区边界。
|
|
4260
|
-
* @author ddj 2026年08月20号
|
|
4353
|
+
* @author ddj 2026年08月20号 / 2026年09月18号
|
|
4261
4354
|
* @returns 成功或失败原因
|
|
4262
4355
|
*/
|
|
4263
4356
|
async function deleteCreated(ctx, session, record) {
|
|
@@ -4293,29 +4386,13 @@ async function deleteCreated(ctx, session, record) {
|
|
|
4293
4386
|
}
|
|
4294
4387
|
};
|
|
4295
4388
|
try {
|
|
4296
|
-
await attempt(
|
|
4297
|
-
"powershell",
|
|
4298
|
-
"-NoProfile",
|
|
4299
|
-
"-NonInteractive",
|
|
4300
|
-
"-Command",
|
|
4301
|
-
"Remove-Item -LiteralPath \"" + p + "\" -Force"
|
|
4302
|
-
]);
|
|
4389
|
+
await attempt(removeFileArgv(p));
|
|
4303
4390
|
return { ok: true };
|
|
4304
4391
|
} catch (error) {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
"--",
|
|
4310
|
-
p
|
|
4311
|
-
]);
|
|
4312
|
-
return { ok: true };
|
|
4313
|
-
} catch (error2) {
|
|
4314
|
-
return {
|
|
4315
|
-
ok: false,
|
|
4316
|
-
error: "删除失败(文件仍存在):" + String(error) + " / " + String(error2)
|
|
4317
|
-
};
|
|
4318
|
-
}
|
|
4392
|
+
return {
|
|
4393
|
+
ok: false,
|
|
4394
|
+
error: "删除失败(文件仍存在):" + String(error)
|
|
4395
|
+
};
|
|
4319
4396
|
}
|
|
4320
4397
|
}
|
|
4321
4398
|
/** 整调用回滚:write/编辑用 before 整文件恢复;新建文件转 deleteCreated。 */
|
|
@@ -9864,9 +9941,9 @@ const CDIR_SIG = 33639248;
|
|
|
9864
9941
|
const LHDR_SIG = 67324752;
|
|
9865
9942
|
/**
|
|
9866
9943
|
* 解析 ZIP 缓冲区 → 条目列表(不解压内容,仅元数据)。
|
|
9867
|
-
* @author ddj 2026年08月27号
|
|
9944
|
+
* @author ddj 2026年08月27号 / 2026年09月18号
|
|
9868
9945
|
* @param buf zip 字节
|
|
9869
|
-
* @returns
|
|
9946
|
+
* @returns 条目元数据(含 Unix mode,见 modeOf)
|
|
9870
9947
|
*/
|
|
9871
9948
|
function zipEntries(buf) {
|
|
9872
9949
|
const eocd = findEocd(buf);
|
|
@@ -9884,22 +9961,36 @@ function zipEntries(buf) {
|
|
|
9884
9961
|
const commentLen = buf.readUInt16LE(offset + 32);
|
|
9885
9962
|
const localOffset = buf.readUInt32LE(offset + 42);
|
|
9886
9963
|
const name = buf.subarray(offset + 46, offset + 46 + nameLen).toString("utf8");
|
|
9964
|
+
const mode = modeOf(buf.readUInt32LE(offset + 38));
|
|
9887
9965
|
out.push({
|
|
9888
9966
|
name,
|
|
9889
9967
|
method,
|
|
9890
9968
|
compressed,
|
|
9891
9969
|
uncompressed,
|
|
9892
|
-
localOffset
|
|
9970
|
+
localOffset,
|
|
9971
|
+
...mode === void 0 ? {} : { mode }
|
|
9893
9972
|
});
|
|
9894
9973
|
offset += 46 + nameLen + extraLen + commentLen;
|
|
9895
9974
|
}
|
|
9896
9975
|
return out;
|
|
9897
9976
|
}
|
|
9898
9977
|
/**
|
|
9978
|
+
* 中央目录 external attributes → Unix 权限位。
|
|
9979
|
+
* ZIP 把 Unix mode 放在 `st_mode << 16`(含 S_IFREG 等类型位),低 16 位仅 DOS 属性;
|
|
9980
|
+
* 故必须右移 16 再取低 9 位权限。非 Unix 归档(Windows 打包)该字段为 0 或纯 DOS 位。
|
|
9981
|
+
* @author ddj 2026年09月18号
|
|
9982
|
+
* @param attributes 中央目录 offset+38 的 4 字节
|
|
9983
|
+
* @returns 0o000~0o777 权限位;无有效 mode 返回 undefined
|
|
9984
|
+
*/
|
|
9985
|
+
function modeOf(attributes) {
|
|
9986
|
+
const mode = attributes >>> 16 & 511;
|
|
9987
|
+
return mode === 0 ? void 0 : mode;
|
|
9988
|
+
}
|
|
9989
|
+
/**
|
|
9899
9990
|
* 解压 ZIP → 条目列表(目录条目含尾部 /)。
|
|
9900
|
-
* @author ddj 2026年08月27号
|
|
9991
|
+
* @author ddj 2026年08月27号 / 2026年09月18号
|
|
9901
9992
|
* @param buf zip 字节
|
|
9902
|
-
* @returns
|
|
9993
|
+
* @returns 条目(含内容与可选 mode)
|
|
9903
9994
|
*/
|
|
9904
9995
|
function unzip(buf) {
|
|
9905
9996
|
const metas = zipEntries(buf);
|
|
@@ -9919,7 +10010,8 @@ function unzip(buf) {
|
|
|
9919
10010
|
out.push({
|
|
9920
10011
|
path: meta.name,
|
|
9921
10012
|
data,
|
|
9922
|
-
isDirectory: isDir
|
|
10013
|
+
isDirectory: isDir,
|
|
10014
|
+
...meta.mode === void 0 ? {} : { mode: meta.mode }
|
|
9923
10015
|
});
|
|
9924
10016
|
}
|
|
9925
10017
|
return out;
|
|
@@ -9960,8 +10052,60 @@ function vsixManifest(vsix) {
|
|
|
9960
10052
|
throw new Error("VSIX 缺少 extension/package.json");
|
|
9961
10053
|
}
|
|
9962
10054
|
/**
|
|
10055
|
+
* 判定解包路径是否为可执行入口(无 mode 时的启发式兜底)。
|
|
10056
|
+
* 只认确定语义:`bin/` 段下的文件、语言服务器/运行时常见可执行名、`.sh` 脚本。
|
|
10057
|
+
* @author ddj 2026年09月18号
|
|
10058
|
+
* @param rel 相对路径(/ 分隔)
|
|
10059
|
+
* @returns 是否应补执行位
|
|
10060
|
+
*/
|
|
10061
|
+
function looksExec(rel) {
|
|
10062
|
+
const path = String(rel ?? "").replace(/\\/g, "/");
|
|
10063
|
+
if (!path) return false;
|
|
10064
|
+
if (path.split("/").includes("bin")) return true;
|
|
10065
|
+
if (/\.(sh|bash|zsh)$/i.test(path)) return true;
|
|
10066
|
+
const base = (path.split("/").pop() ?? "").replace(/\.exe$/i, "");
|
|
10067
|
+
return [
|
|
10068
|
+
"lua-language-server",
|
|
10069
|
+
"emmylua_ls",
|
|
10070
|
+
"OmniSharp",
|
|
10071
|
+
"dotnet",
|
|
10072
|
+
"node"
|
|
10073
|
+
].includes(base);
|
|
10074
|
+
}
|
|
10075
|
+
/**
|
|
10076
|
+
* 计算解包后要施加的权限位(纯函数,可单测)。
|
|
10077
|
+
* 优先信任归档自带的 Unix mode 中的执行位(VS Code 自身解 VSIX 即此口径);
|
|
10078
|
+
* 归档无 mode(Windows 打包的 VSIX)时按路径启发式补 0o755;
|
|
10079
|
+
* 其余保持 undefined(交给 umask 默认,不越权改动)。
|
|
10080
|
+
* @author ddj 2026年09月18号
|
|
10081
|
+
* @param entry 解压条目
|
|
10082
|
+
* @returns 目标权限位;无需处理返回 undefined
|
|
10083
|
+
*/
|
|
10084
|
+
function execModeOf(entry) {
|
|
10085
|
+
if (entry.isDirectory) return void 0;
|
|
10086
|
+
const mode = entry.mode;
|
|
10087
|
+
if (mode !== void 0 && (mode & 73) !== 0) return mode;
|
|
10088
|
+
return looksExec(entry.path) ? 493 : void 0;
|
|
10089
|
+
}
|
|
10090
|
+
/**
|
|
10091
|
+
* 落盘后补可执行位(POSIX 专属;Windows 无此概念,直接跳过)。
|
|
10092
|
+
* 必须 best-effort:只读文件系统/无权限时不能拖垮整个扩展安装。
|
|
10093
|
+
* @author ddj 2026年09月18号
|
|
10094
|
+
* @param target 落盘绝对路径
|
|
10095
|
+
* @param entry 解压条目
|
|
10096
|
+
* @param platform 目标平台(测试注入)
|
|
10097
|
+
*/
|
|
10098
|
+
function applyExecBit(target, entry, platform = process.platform) {
|
|
10099
|
+
if (platform === "win32") return;
|
|
10100
|
+
const mode = execModeOf(entry);
|
|
10101
|
+
if (mode === void 0) return;
|
|
10102
|
+
try {
|
|
10103
|
+
chmodSync(target, mode);
|
|
10104
|
+
} catch (error) {}
|
|
10105
|
+
}
|
|
10106
|
+
/**
|
|
9963
10107
|
* 解包 VSIX 到目录(仅取 extension/ 子树,剥前缀;返回清单)。
|
|
9964
|
-
* @author ddj 2026年08月27号
|
|
10108
|
+
* @author ddj 2026年08月27号 / 2026年09月18号
|
|
9965
10109
|
* @param vsix vsix 字节
|
|
9966
10110
|
* @param dest 目标目录(已存在则先清空)
|
|
9967
10111
|
* @returns 清单对象
|
|
@@ -9985,6 +10129,7 @@ function unpackVsix(vsix, dest) {
|
|
|
9985
10129
|
}
|
|
9986
10130
|
mkdirSync(dirname(target), { recursive: true });
|
|
9987
10131
|
writeFileSync(target, entry.data);
|
|
10132
|
+
applyExecBit(target, entry);
|
|
9988
10133
|
if (rel === "package.json") manifest = JSON.parse(entry.data.toString("utf8"));
|
|
9989
10134
|
}
|
|
9990
10135
|
if (!manifest) throw new Error("VSIX 解包后缺少 package.json");
|