dsh-extra-paths 0.1.1 → 0.2.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.md +6 -2
- package/README.zh.md +6 -2
- package/lib/client.js +311 -92
- package/lib/policy.js +15 -2
- package/lib/policy.js.map +1 -1
- package/lib/types/policy.d.ts +18 -1
- package/lib/types/wrap-fs.d.ts +13 -0
- package/lib/wrap-fs.js +74 -5
- package/lib/wrap-fs.js.map +1 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ settings page plus a preview of the effective roots for the current workspace.
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
Requires DSH `0.1.5` / `0.2.0` / `0.2.1` (outside that range the install gate refuses the package).
|
|
11
|
+
Requires DSH `0.1.5` / `0.2.0` / `0.2.1` / `0.2.2` (outside that range the install gate refuses the package).
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
dsh plugin --profile <name> add dsh-extra-paths # <name> = your profile
|
|
@@ -21,7 +21,11 @@ pnpm install && pnpm build
|
|
|
21
21
|
dsh plugin --profile <name> add /path/to/dsh-extra-paths # path = absolute path to this repo
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Then open
|
|
24
|
+
Then open **Extra writable paths** in the settings sidebar. In **Settings → Plugins** the same page lives on this
|
|
25
|
+
plugin's own row: open the `dsh-extra-paths` bundle, then hit that row's **Configure** button.
|
|
26
|
+
|
|
27
|
+
The page follows DSH's own language selection (**Settings → General → Language**): it ships Simplified Chinese and
|
|
28
|
+
English copy, and every other UI language falls back to English.
|
|
25
29
|
|
|
26
30
|
## Configuration
|
|
27
31
|
|
package/README.zh.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## 安装
|
|
9
9
|
|
|
10
|
-
需要 DSH `0.1.5` / `0.2.0` / `0.2.1`(不在范围内会被安装闸门拒绝)。
|
|
10
|
+
需要 DSH `0.1.5` / `0.2.0` / `0.2.1` / `0.2.2`(不在范围内会被安装闸门拒绝)。
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
13
|
dsh plugin --profile <name> add dsh-extra-paths # <name>=你的 profile 名
|
|
@@ -20,7 +20,11 @@ pnpm install && pnpm build
|
|
|
20
20
|
dsh plugin --profile <name> add /path/to/dsh-extra-paths # 路径=本仓库的绝对路径
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
装好后打开设置左栏的「额外可写路径」。在 **设置 → 插件** 里,同一页在这个插件自己那一行上:
|
|
24
|
+
打开 `dsh-extra-paths` 组合包,点该行的「配置」。
|
|
25
|
+
|
|
26
|
+
页面文案跟随 DSH 自己的语言选择(**设置 → 常规 → 语言**):内置简体中文与英文两套文案,
|
|
27
|
+
其它界面语言回落到英文。
|
|
24
28
|
|
|
25
29
|
## 配置
|
|
26
30
|
|
package/lib/client.js
CHANGED
|
@@ -29,6 +29,136 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
let react = require("react");
|
|
30
30
|
react = __toESM(react, 1);
|
|
31
31
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
//#region src/client/locales.ts
|
|
33
|
+
/** English copy — the fallback locale for every non-Chinese UI language. */
|
|
34
|
+
const en = {
|
|
35
|
+
navLabel: "Extra writable paths",
|
|
36
|
+
summaryLoading: "Extra writable paths: loading…",
|
|
37
|
+
summaryUnavailable: "Extra writable paths: not offered by this host",
|
|
38
|
+
summaryEmpty: "Extra writable paths: not configured yet",
|
|
39
|
+
summaryCount: "Extra writable paths: {count} saved · writing needs no approval",
|
|
40
|
+
introBefore: "These paths stay writable outside the session workspace, ",
|
|
41
|
+
introNoApproval: "without approval",
|
|
42
|
+
introAfter: "; both the write tools and the terminal honor the surfaces below.",
|
|
43
|
+
introRuleBefore: "Relative spellings resolve against the base workspace; enforcement uses ",
|
|
44
|
+
introRuleEmphasis: "each session's own workspace",
|
|
45
|
+
introRuleAfter: ", so one configuration points at different directories in different sessions.",
|
|
46
|
+
baseWorkspace: "Base workspace",
|
|
47
|
+
notSelected: "(none selected)",
|
|
48
|
+
basePlaceholder: "Absolute path, or start with ~/ (for example ~/projects)",
|
|
49
|
+
manualBase: "Type a path",
|
|
50
|
+
pickBase: "Pick from list",
|
|
51
|
+
baseHint: "Preview and inline resolution only",
|
|
52
|
+
save: "Save",
|
|
53
|
+
saving: "Saving…",
|
|
54
|
+
addPath: "Add path",
|
|
55
|
+
addParent: "Add the workspace parent (..)",
|
|
56
|
+
discard: "Discard changes",
|
|
57
|
+
dirty: "Unsaved changes",
|
|
58
|
+
synced: "In sync with the configuration",
|
|
59
|
+
emptyPaths: "No paths configured yet: start with \"Add path\" or \"Add the workspace parent (..)\" above.",
|
|
60
|
+
rowTitle: "Path {index}",
|
|
61
|
+
delete: "Remove",
|
|
62
|
+
pathPlaceholder: "~/projects/notes/home, ../some-repo, .. (parent), ~/projects/**/.worktrees/.. (pattern)",
|
|
63
|
+
patternResolved: "Pattern: the host expands it along the directory structure",
|
|
64
|
+
patternMatches: "{count} directories match (see the preview below)",
|
|
65
|
+
patternNoMatches: "(no matches yet, or capped by the expansion limit)",
|
|
66
|
+
resolvePendingEmpty: "The resolved path appears here once you type a path",
|
|
67
|
+
resolveNeedsBase: "A relative path needs a base workspace: choose or type one above",
|
|
68
|
+
resolveBaseInvalid: "The base workspace must be an absolute path or start with ~/ (for example ~/projects)",
|
|
69
|
+
resolveNeedsHome: "~ needs the host home directory (available after the first preview)",
|
|
70
|
+
resolvedAs: "Resolves to",
|
|
71
|
+
hostResolved: "(host resolves: {path})",
|
|
72
|
+
mode: "Applies under",
|
|
73
|
+
surfaces: "Surfaces",
|
|
74
|
+
surfaceFs: "Write tools",
|
|
75
|
+
surfaceShell: "Terminal",
|
|
76
|
+
scopeWrite: "Follows the session mode (denied under read-only)",
|
|
77
|
+
scopeAlways: "Always writable (allowed under read-only too)",
|
|
78
|
+
statusOk: "active",
|
|
79
|
+
statusMissing: "missing",
|
|
80
|
+
statusRejected: "rejected",
|
|
81
|
+
previewTitle: "Resolution preview",
|
|
82
|
+
previewDirty: " (including unsaved changes)",
|
|
83
|
+
previewEffective: "{count} effective roots",
|
|
84
|
+
previewNoBase: "Choose or type a base workspace above and the host's effective roots appear here.",
|
|
85
|
+
previewBadBase: "The base workspace must be absolute or start with ~/ (for example ~/projects); a relative path cannot be the base.",
|
|
86
|
+
previewExpandingHome: "Expanding ~: the host home directory arrives with the first preview.",
|
|
87
|
+
previewUnavailable: "Preview unavailable (the host did not offer the route, the connection is not ready, or it rejected the base workspace).",
|
|
88
|
+
previewEmpty: "Nothing to resolve yet.",
|
|
89
|
+
unresolved: "(unresolved)",
|
|
90
|
+
saveRefused: "The host refused the save: this configuration may be overridden by a home patch or a command-line overlay (the settings page only writes the profile cordis.patch.yml). Remove the same-id override from ~/.dsh/cordis.patch.yml, or edit the profile patch and restart."
|
|
91
|
+
};
|
|
92
|
+
/** Simplified Chinese copy. */
|
|
93
|
+
const zh = {
|
|
94
|
+
navLabel: "额外可写路径",
|
|
95
|
+
summaryLoading: "额外可写路径:读取中…",
|
|
96
|
+
summaryUnavailable: "额外可写路径:宿主未提供该设置",
|
|
97
|
+
summaryEmpty: "额外可写路径:尚未配置",
|
|
98
|
+
summaryCount: "额外可写路径:{count} 条 · 保存即生效,写入无需审批",
|
|
99
|
+
introBefore: "这些路径在会话工作区之外也可以写,",
|
|
100
|
+
introNoApproval: "不需要审批",
|
|
101
|
+
introAfter: ";写工具与终端都按下面的「作用面」生效。",
|
|
102
|
+
introRuleBefore: "相对路径按「基准工作区」解析——执法时用的是",
|
|
103
|
+
introRuleEmphasis: "各会话自己的工作区",
|
|
104
|
+
introRuleAfter: ",所以同一份配置在不同会话会指向不同目录。",
|
|
105
|
+
baseWorkspace: "基准工作区",
|
|
106
|
+
notSelected: "(未选择)",
|
|
107
|
+
basePlaceholder: "绝对路径,或以 ~/ 开头(例如 ~/projects)",
|
|
108
|
+
manualBase: "手填",
|
|
109
|
+
pickBase: "从列表选",
|
|
110
|
+
baseHint: "仅用于预览与行内解析",
|
|
111
|
+
save: "保存",
|
|
112
|
+
saving: "保存中…",
|
|
113
|
+
addPath: "添加路径",
|
|
114
|
+
addParent: "添加工作区上一层(..)",
|
|
115
|
+
discard: "放弃修改",
|
|
116
|
+
dirty: "有未保存的修改",
|
|
117
|
+
synced: "已与配置同步",
|
|
118
|
+
emptyPaths: "还没有配置路径:用上面的「添加路径」或「添加工作区上一层(..)」开始。",
|
|
119
|
+
rowTitle: "路径 {index}",
|
|
120
|
+
delete: "删除",
|
|
121
|
+
pathPlaceholder: "~/projects/notes/home、../某仓库、..(上一层)、~/projects/**/.worktrees/..(模式)",
|
|
122
|
+
patternResolved: "模式:由宿主按目录结构展开",
|
|
123
|
+
patternMatches: "当前命中 {count} 个目录(见下方预览)",
|
|
124
|
+
patternNoMatches: "(暂无命中,或被展开上限拦截)",
|
|
125
|
+
resolvePendingEmpty: "填入路径后这里会显示解析结果",
|
|
126
|
+
resolveNeedsBase: "相对路径需要基准工作区:请在上面选择或填写",
|
|
127
|
+
resolveBaseInvalid: "基准工作区需要绝对路径,或以 ~/ 开头(例如 ~/projects)",
|
|
128
|
+
resolveNeedsHome: "~ 需要宿主的家目录(第一次预览返回后即可解析)",
|
|
129
|
+
resolvedAs: "解析为",
|
|
130
|
+
hostResolved: "(宿主解析:{path})",
|
|
131
|
+
mode: "生效模式",
|
|
132
|
+
surfaces: "作用面",
|
|
133
|
+
surfaceFs: "写工具",
|
|
134
|
+
surfaceShell: "终端",
|
|
135
|
+
scopeWrite: "随会话模式(read-only 下拒绝)",
|
|
136
|
+
scopeAlways: "始终可写(read-only 下也允许)",
|
|
137
|
+
statusOk: "生效",
|
|
138
|
+
statusMissing: "目录不存在",
|
|
139
|
+
statusRejected: "已拒绝",
|
|
140
|
+
previewTitle: "解析预览",
|
|
141
|
+
previewDirty: "(含未保存修改)",
|
|
142
|
+
previewEffective: "生效根 {count} 条",
|
|
143
|
+
previewNoBase: "先在上面选择或填写「基准工作区」,这里就会显示宿主解析出的生效根。",
|
|
144
|
+
previewBadBase: "基准工作区需要绝对路径,或以 ~/ 开头(例如 ~/projects);相对路径不能当基准用。",
|
|
145
|
+
previewExpandingHome: "正在展开 ~:宿主的家目录会在第一次预览返回后给出。",
|
|
146
|
+
previewUnavailable: "预览不可用(宿主没提供该路由、连接还没就绪,或基准工作区被宿主拒绝)。",
|
|
147
|
+
previewEmpty: "还没有可解析的路径。",
|
|
148
|
+
unresolved: "(未解析)",
|
|
149
|
+
saveRefused: "保存被宿主拒绝:该配置可能被 home patch 或命令行覆盖(设置页只写 profile 的 cordis.patch.yml)。请删掉 ~/.dsh/cordis.patch.yml 里同 id 的覆盖,或直接改 profile patch 后重启。"
|
|
150
|
+
};
|
|
151
|
+
/** Fill `{name}` placeholders; unknown names stay verbatim, like the host seat. */
|
|
152
|
+
function format(template, params) {
|
|
153
|
+
if (params === void 0) return template;
|
|
154
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The built-in translate function: Chinese copy, `{name}` placeholders.
|
|
158
|
+
* Used when the host supplies no locale seat (0.1.5 slots, unit tests).
|
|
159
|
+
*/
|
|
160
|
+
const fallbackTranslate = (key, params) => format(zh[key], params);
|
|
161
|
+
//#endregion
|
|
32
162
|
//#region src/client/paths.ts
|
|
33
163
|
/**
|
|
34
164
|
* Lexical path resolution for the settings page's live column. It mirrors the
|
|
@@ -329,10 +459,15 @@ window.__ModuleLoader__.load({
|
|
|
329
459
|
//#endregion
|
|
330
460
|
//#region src/client/page.tsx
|
|
331
461
|
/**
|
|
332
|
-
* The Extra paths settings page: one card per configured path,
|
|
462
|
+
* The Extra paths settings page: one card per configured path, localized copy,
|
|
333
463
|
* a LIVE lexical resolution per row against a base workspace, quick add
|
|
334
464
|
* buttons, and the host's authoritative preview of the DRAFT (unsaved rows).
|
|
335
465
|
*
|
|
466
|
+
* Copy follows the host's own language selection: every string comes from the
|
|
467
|
+
* dictionaries registered by `../client/index` through the framework-injected
|
|
468
|
+
* `t` seat, and the Chinese dictionary is the built-in fallback for a host that
|
|
469
|
+
* supplies no seat at all (0.1.5 slots, unit tests).
|
|
470
|
+
*
|
|
336
471
|
* The base workspace comes from the shell's standard `useWorkspaces` hook when
|
|
337
472
|
* the slot supplies it — a snapshot read once during activation would be
|
|
338
473
|
* `undefined` whenever the registry had not loaded yet, which is exactly how the
|
|
@@ -340,26 +475,37 @@ window.__ModuleLoader__.load({
|
|
|
340
475
|
* compositions that pass no standard props.
|
|
341
476
|
* @module dsh-extra-paths/client/page
|
|
342
477
|
*/
|
|
478
|
+
/**
|
|
479
|
+
* Marker carried by a refusal raised in the late-bound scope. The page maps it
|
|
480
|
+
* to localized copy instead of showing the scope's internal message.
|
|
481
|
+
*/
|
|
482
|
+
const SAVE_REFUSED_CODE = "extra-paths/save-refused";
|
|
483
|
+
/**
|
|
484
|
+
* Message carried by that marker error (Chinese). The page shows the localized
|
|
485
|
+
* `saveRefused` copy; this text only reaches logs/tests.
|
|
486
|
+
*/
|
|
487
|
+
const SAVE_REFUSED_MESSAGE = zh.saveRefused;
|
|
488
|
+
/** Build the refusal error the page recognizes. */
|
|
489
|
+
function saveRefusedError() {
|
|
490
|
+
const error = new Error(SAVE_REFUSED_MESSAGE);
|
|
491
|
+
error.code = SAVE_REFUSED_CODE;
|
|
492
|
+
return error;
|
|
493
|
+
}
|
|
494
|
+
/** Whether a rejected save is the host refusing the write. */
|
|
495
|
+
function isSaveRefused(cause) {
|
|
496
|
+
return cause?.code === SAVE_REFUSED_CODE;
|
|
497
|
+
}
|
|
343
498
|
const NOOP_HOOK = () => void 0;
|
|
344
499
|
const IDENTITY = (snapshot) => snapshot;
|
|
345
500
|
function itemsOf(value) {
|
|
346
501
|
const items = value?.items;
|
|
347
502
|
return Array.isArray(items) ? items : [];
|
|
348
503
|
}
|
|
349
|
-
const STATUS_LABEL = {
|
|
350
|
-
ok: "生效",
|
|
351
|
-
missing: "目录不存在",
|
|
352
|
-
rejected: "已拒绝"
|
|
353
|
-
};
|
|
354
504
|
const STATUS_STYLE = {
|
|
355
505
|
ok: styles.statusOk,
|
|
356
506
|
missing: styles.statusMissing,
|
|
357
507
|
rejected: styles.statusRejected
|
|
358
508
|
};
|
|
359
|
-
const SCOPE_LABEL = {
|
|
360
|
-
write: "随会话模式(read-only 下拒绝)",
|
|
361
|
-
"always-write": "始终可写(read-only 下也允许)"
|
|
362
|
-
};
|
|
363
509
|
function rowsOf(section) {
|
|
364
510
|
const rows = [];
|
|
365
511
|
for (const item of section?.paths ?? []) if (typeof item === "string") rows.push({
|
|
@@ -389,11 +535,32 @@ window.__ModuleLoader__.load({
|
|
|
389
535
|
return snapshot;
|
|
390
536
|
}
|
|
391
537
|
/**
|
|
538
|
+
* The one-liner the plugin manager shows in its list (`view: 'summary'`).
|
|
539
|
+
*
|
|
540
|
+
* The manager renders every configuration entry twice: a compact summary in the
|
|
541
|
+
* list, and the full view on the entry's own page. Rendering the editor for both
|
|
542
|
+
* is what used to fill the Plugins page with the whole form, so the summary is a
|
|
543
|
+
* separate component that can never grow one.
|
|
544
|
+
* @param props - the bound settings scope and the host's translate seat.
|
|
545
|
+
*/
|
|
546
|
+
function ExtraPathsSummary({ scope, t }) {
|
|
547
|
+
const translate = t ?? fallbackTranslate;
|
|
548
|
+
const { status, value } = useSnapshot(scope);
|
|
549
|
+
const rows = rowsOf(value).filter((row) => row.path.trim() !== "");
|
|
550
|
+
const text = status === "loading" ? translate("summaryLoading") : status === "unavailable" ? translate("summaryUnavailable") : rows.length === 0 ? translate("summaryEmpty") : translate("summaryCount", { count: rows.length });
|
|
551
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
552
|
+
style: styles.dim,
|
|
553
|
+
children: text
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
392
557
|
* Render the page.
|
|
393
|
-
* @param props - the bound settings scope, the
|
|
394
|
-
* lazy fallback used when the composition
|
|
558
|
+
* @param props - the bound settings scope, the host's translate seat, the
|
|
559
|
+
* standard workspace hook, and the lazy fallback used when the composition
|
|
560
|
+
* supplies no standard props.
|
|
395
561
|
*/
|
|
396
|
-
function ExtraPathsPage({ scope, getWorkspaces, useWorkspaces }) {
|
|
562
|
+
function ExtraPathsPage({ scope, t, getWorkspaces, useWorkspaces }) {
|
|
563
|
+
const tr = t ?? fallbackTranslate;
|
|
397
564
|
const snapshot = useSnapshot(scope);
|
|
398
565
|
const fromHook = itemsOf((useWorkspaces ?? NOOP_HOOK)(IDENTITY));
|
|
399
566
|
const candidates = (fromHook.length > 0 ? fromHook : itemsOf(getWorkspaces?.()?.list?.getSnapshot?.())).map((item) => item.path).filter((path) => typeof path === "string" && path !== "");
|
|
@@ -467,10 +634,11 @@ window.__ModuleLoader__.load({
|
|
|
467
634
|
const save = () => {
|
|
468
635
|
setBusy(true);
|
|
469
636
|
setError(void 0);
|
|
470
|
-
scope.set("paths", payloadOf(rows)).then(() => {
|
|
471
|
-
|
|
637
|
+
scope.set("paths", payloadOf(rows)).then((accepted) => {
|
|
638
|
+
if (accepted === false) setError(tr("saveRefused"));
|
|
639
|
+
else setDirty(false);
|
|
472
640
|
}).catch((cause) => {
|
|
473
|
-
setError(String(cause));
|
|
641
|
+
setError(isSaveRefused(cause) ? tr("saveRefused") : cause instanceof Error ? cause.message : String(cause));
|
|
474
642
|
}).finally(() => {
|
|
475
643
|
setBusy(false);
|
|
476
644
|
});
|
|
@@ -486,11 +654,12 @@ window.__ModuleLoader__.load({
|
|
|
486
654
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
487
655
|
style: styles.intro,
|
|
488
656
|
children: [
|
|
489
|
-
"
|
|
490
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "
|
|
491
|
-
"
|
|
492
|
-
|
|
493
|
-
"
|
|
657
|
+
tr("introBefore"),
|
|
658
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: tr("introNoApproval") }),
|
|
659
|
+
tr("introAfter"),
|
|
660
|
+
tr("introRuleBefore"),
|
|
661
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: tr("introRuleEmphasis") }),
|
|
662
|
+
tr("introRuleAfter")
|
|
494
663
|
]
|
|
495
664
|
}),
|
|
496
665
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -498,7 +667,7 @@ window.__ModuleLoader__.load({
|
|
|
498
667
|
children: [
|
|
499
668
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
500
669
|
style: styles.cardTitle,
|
|
501
|
-
children: "
|
|
670
|
+
children: tr("baseWorkspace")
|
|
502
671
|
}),
|
|
503
672
|
picker ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
504
673
|
className: "xp-select",
|
|
@@ -510,7 +679,7 @@ window.__ModuleLoader__.load({
|
|
|
510
679
|
},
|
|
511
680
|
children: [known ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
512
681
|
value: typedBase,
|
|
513
|
-
children: typedBase === "" ? "
|
|
682
|
+
children: typedBase === "" ? tr("notSelected") : typedBase
|
|
514
683
|
}), candidates.map((path) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
515
684
|
value: path,
|
|
516
685
|
children: path
|
|
@@ -519,7 +688,7 @@ window.__ModuleLoader__.load({
|
|
|
519
688
|
className: "xp-input",
|
|
520
689
|
style: styles.baseField,
|
|
521
690
|
value: cwd,
|
|
522
|
-
placeholder: "
|
|
691
|
+
placeholder: tr("basePlaceholder"),
|
|
523
692
|
onChange: (event) => {
|
|
524
693
|
setCwdPinned(true);
|
|
525
694
|
setCwd(event.target.value);
|
|
@@ -531,11 +700,11 @@ window.__ModuleLoader__.load({
|
|
|
531
700
|
onClick: () => {
|
|
532
701
|
setManualBase(!manualBase);
|
|
533
702
|
},
|
|
534
|
-
children: picker ? "
|
|
703
|
+
children: picker ? tr("manualBase") : tr("pickBase")
|
|
535
704
|
}) : null,
|
|
536
705
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
537
706
|
style: styles.dim,
|
|
538
|
-
children: "
|
|
707
|
+
children: tr("baseHint")
|
|
539
708
|
})
|
|
540
709
|
]
|
|
541
710
|
}),
|
|
@@ -547,7 +716,7 @@ window.__ModuleLoader__.load({
|
|
|
547
716
|
className: "xp-button xp-button-on",
|
|
548
717
|
disabled: busy || !dirty,
|
|
549
718
|
onClick: save,
|
|
550
|
-
children: busy ? "
|
|
719
|
+
children: busy ? tr("saving") : tr("save")
|
|
551
720
|
}),
|
|
552
721
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
553
722
|
type: "button",
|
|
@@ -555,7 +724,7 @@ window.__ModuleLoader__.load({
|
|
|
555
724
|
onClick: () => {
|
|
556
725
|
append("");
|
|
557
726
|
},
|
|
558
|
-
children: "
|
|
727
|
+
children: tr("addPath")
|
|
559
728
|
}),
|
|
560
729
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
561
730
|
type: "button",
|
|
@@ -563,24 +732,24 @@ window.__ModuleLoader__.load({
|
|
|
563
732
|
onClick: () => {
|
|
564
733
|
append("..");
|
|
565
734
|
},
|
|
566
|
-
children: "
|
|
735
|
+
children: tr("addParent")
|
|
567
736
|
}),
|
|
568
737
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
569
738
|
type: "button",
|
|
570
739
|
className: "xp-button",
|
|
571
740
|
disabled: !dirty,
|
|
572
741
|
onClick: reset,
|
|
573
|
-
children: "
|
|
742
|
+
children: tr("discard")
|
|
574
743
|
}),
|
|
575
744
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
576
745
|
style: styles.dim,
|
|
577
|
-
children: dirty ? "
|
|
746
|
+
children: dirty ? tr("dirty") : tr("synced")
|
|
578
747
|
})
|
|
579
748
|
]
|
|
580
749
|
}),
|
|
581
750
|
rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
582
751
|
style: styles.dim,
|
|
583
|
-
children: "
|
|
752
|
+
children: tr("emptyPaths")
|
|
584
753
|
}) : null,
|
|
585
754
|
rows.map((row, index) => {
|
|
586
755
|
const patternRow = row.path.includes("*");
|
|
@@ -592,16 +761,16 @@ window.__ModuleLoader__.load({
|
|
|
592
761
|
children: [
|
|
593
762
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
594
763
|
style: styles.cardHead,
|
|
595
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
764
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
596
765
|
style: styles.cardTitle,
|
|
597
|
-
children:
|
|
766
|
+
children: tr("rowTitle", { index: index + 1 })
|
|
598
767
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
599
768
|
style: styles.cardHeadRight,
|
|
600
769
|
children: [hostEntry !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
601
770
|
style: STATUS_STYLE[hostEntry.status],
|
|
602
771
|
children: [
|
|
603
772
|
"[",
|
|
604
|
-
|
|
773
|
+
tr(hostEntry.status === "ok" ? "statusOk" : hostEntry.status === "missing" ? "statusMissing" : "statusRejected"),
|
|
605
774
|
hostMatches.length > 1 ? ` ×${hostMatches.length}` : "",
|
|
606
775
|
"]"
|
|
607
776
|
]
|
|
@@ -612,7 +781,7 @@ window.__ModuleLoader__.load({
|
|
|
612
781
|
setDirty(true);
|
|
613
782
|
setRows((current) => current.filter((_, i) => i !== index));
|
|
614
783
|
},
|
|
615
|
-
children: "
|
|
784
|
+
children: tr("delete")
|
|
616
785
|
})]
|
|
617
786
|
})]
|
|
618
787
|
}),
|
|
@@ -620,7 +789,7 @@ window.__ModuleLoader__.load({
|
|
|
620
789
|
className: "xp-input",
|
|
621
790
|
style: styles.pathInput,
|
|
622
791
|
value: row.path,
|
|
623
|
-
placeholder: "
|
|
792
|
+
placeholder: tr("pathPlaceholder"),
|
|
624
793
|
onChange: (event) => {
|
|
625
794
|
update(index, { path: event.target.value });
|
|
626
795
|
}
|
|
@@ -630,29 +799,25 @@ window.__ModuleLoader__.load({
|
|
|
630
799
|
children: patternRow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
631
800
|
style: styles.dim,
|
|
632
801
|
children: [
|
|
633
|
-
"
|
|
802
|
+
tr("patternResolved"),
|
|
634
803
|
" ",
|
|
635
|
-
hostMatches.length > 0 ?
|
|
804
|
+
hostMatches.length > 0 ? tr("patternMatches", { count: hostMatches.length }) : tr("patternNoMatches")
|
|
636
805
|
]
|
|
637
806
|
}) : resolved === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
638
807
|
style: styles.dim,
|
|
639
|
-
children: row.path.trim() === "" ? "
|
|
808
|
+
children: row.path.trim() === "" ? tr("resolvePendingEmpty") : typedBase === "" ? tr("resolveNeedsBase") : !usableBase ? tr("resolveBaseInvalid") : tr("resolveNeedsHome")
|
|
640
809
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
641
810
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
642
811
|
style: styles.dim,
|
|
643
|
-
children: "
|
|
812
|
+
children: tr("resolvedAs")
|
|
644
813
|
}),
|
|
645
814
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
646
815
|
style: styles.code,
|
|
647
816
|
children: resolved
|
|
648
817
|
}),
|
|
649
|
-
hostEntry !== void 0 && hostEntry.resolved !== resolved ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
818
|
+
hostEntry !== void 0 && hostEntry.resolved !== resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
650
819
|
style: styles.dim,
|
|
651
|
-
children:
|
|
652
|
-
"(宿主解析:",
|
|
653
|
-
hostEntry.resolved,
|
|
654
|
-
")"
|
|
655
|
-
]
|
|
820
|
+
children: tr("hostResolved", { path: hostEntry.resolved })
|
|
656
821
|
}) : null
|
|
657
822
|
] })
|
|
658
823
|
}),
|
|
@@ -660,7 +825,7 @@ window.__ModuleLoader__.load({
|
|
|
660
825
|
style: styles.controlsRow,
|
|
661
826
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
662
827
|
style: styles.field,
|
|
663
|
-
children: ["
|
|
828
|
+
children: [tr("mode"), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
664
829
|
className: "xp-select",
|
|
665
830
|
value: row.scope,
|
|
666
831
|
onChange: (event) => {
|
|
@@ -668,10 +833,10 @@ window.__ModuleLoader__.load({
|
|
|
668
833
|
},
|
|
669
834
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
670
835
|
value: "write",
|
|
671
|
-
children:
|
|
836
|
+
children: tr("scopeWrite")
|
|
672
837
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
673
838
|
value: "always-write",
|
|
674
|
-
children:
|
|
839
|
+
children: tr("scopeAlways")
|
|
675
840
|
})]
|
|
676
841
|
})]
|
|
677
842
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -679,7 +844,7 @@ window.__ModuleLoader__.load({
|
|
|
679
844
|
children: [
|
|
680
845
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
681
846
|
style: styles.dim,
|
|
682
|
-
children: "
|
|
847
|
+
children: tr("surfaces")
|
|
683
848
|
}),
|
|
684
849
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
685
850
|
type: "button",
|
|
@@ -687,7 +852,7 @@ window.__ModuleLoader__.load({
|
|
|
687
852
|
onClick: () => {
|
|
688
853
|
toggleSurface(index, "fs");
|
|
689
854
|
},
|
|
690
|
-
children: "
|
|
855
|
+
children: tr("surfaceFs")
|
|
691
856
|
}),
|
|
692
857
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
693
858
|
type: "button",
|
|
@@ -695,7 +860,7 @@ window.__ModuleLoader__.load({
|
|
|
695
860
|
onClick: () => {
|
|
696
861
|
toggleSurface(index, "shell");
|
|
697
862
|
},
|
|
698
|
-
children: "
|
|
863
|
+
children: tr("surfaceShell")
|
|
699
864
|
})
|
|
700
865
|
]
|
|
701
866
|
})]
|
|
@@ -712,32 +877,28 @@ window.__ModuleLoader__.load({
|
|
|
712
877
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
713
878
|
style: styles.panelHead,
|
|
714
879
|
children: [
|
|
715
|
-
"
|
|
716
|
-
dirty ? "
|
|
717
|
-
preview !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
880
|
+
tr("previewTitle"),
|
|
881
|
+
dirty ? tr("previewDirty") : "",
|
|
882
|
+
preview !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
718
883
|
style: styles.dim,
|
|
719
|
-
children:
|
|
720
|
-
"生效根 ",
|
|
721
|
-
preview.effective.length,
|
|
722
|
-
" 条"
|
|
723
|
-
]
|
|
884
|
+
children: tr("previewEffective", { count: preview.effective.length })
|
|
724
885
|
}) : null
|
|
725
886
|
]
|
|
726
887
|
}), typedBase === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
727
888
|
style: styles.dim,
|
|
728
|
-
children: "
|
|
889
|
+
children: tr("previewNoBase")
|
|
729
890
|
}) : !usableBase ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
730
891
|
style: styles.dim,
|
|
731
|
-
children: "
|
|
892
|
+
children: tr("previewBadBase")
|
|
732
893
|
}) : base === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
733
894
|
style: styles.dim,
|
|
734
|
-
children: "
|
|
895
|
+
children: tr("previewExpandingHome")
|
|
735
896
|
}) : preview === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
736
897
|
style: styles.dim,
|
|
737
|
-
children: "
|
|
898
|
+
children: tr("previewUnavailable")
|
|
738
899
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [preview.entries.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
739
900
|
style: styles.dim,
|
|
740
|
-
children: "
|
|
901
|
+
children: tr("previewEmpty")
|
|
741
902
|
}) : preview.entries.map((entry, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
742
903
|
style: styles.entry,
|
|
743
904
|
children: [
|
|
@@ -745,7 +906,7 @@ window.__ModuleLoader__.load({
|
|
|
745
906
|
style: STATUS_STYLE[entry.status],
|
|
746
907
|
children: [
|
|
747
908
|
"[",
|
|
748
|
-
|
|
909
|
+
tr(entry.status === "ok" ? "statusOk" : entry.status === "missing" ? "statusMissing" : "statusRejected"),
|
|
749
910
|
"]"
|
|
750
911
|
]
|
|
751
912
|
}),
|
|
@@ -759,7 +920,7 @@ window.__ModuleLoader__.load({
|
|
|
759
920
|
}),
|
|
760
921
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
761
922
|
style: styles.code,
|
|
762
|
-
children: entry.resolved === "" ? "
|
|
923
|
+
children: entry.resolved === "" ? tr("unresolved") : entry.resolved
|
|
763
924
|
})
|
|
764
925
|
]
|
|
765
926
|
}, `${index}-${entry.raw}`)), preview.warnings.map((warning) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -774,11 +935,28 @@ window.__ModuleLoader__.load({
|
|
|
774
935
|
//#region src/client/index.tsx
|
|
775
936
|
/**
|
|
776
937
|
* Client half: contributes the Extra paths configuration page to the settings
|
|
777
|
-
* dialog
|
|
778
|
-
* the plugin's own card (0.1.5: `settings.plugin.item`, keyed by the settings
|
|
779
|
-
* namespace; 0.2.x: `plugins.item`, a list slot).
|
|
938
|
+
* dialog and to the plugin manager.
|
|
780
939
|
*
|
|
781
|
-
*
|
|
940
|
+
* THREE ENTRY POINTS, ONE PAGE — and the plugin manager asks for two different
|
|
941
|
+
* views of it. `view: 'summary'` is the one-liner it lays out in its list;
|
|
942
|
+
* anything else is the editor (`view: 'page'` on the entry's own page). Ignoring
|
|
943
|
+
* that split is what used to render the whole form inline in the plugin list,
|
|
944
|
+
* under the built-in plugins group, and pushed everything else off screen.
|
|
945
|
+
*
|
|
946
|
+
* - `settings.section` — a nav row in the settings dialog's left column. Declared
|
|
947
|
+
* by both host generations, so this is the entry point that always exists.
|
|
948
|
+
* - 0.2.x `plugins.row.config` — a KEYED slot spelled `<bundle name>#<entry id>`.
|
|
949
|
+
* Our own row inside the `dsh-extra-paths` bundle gains a 配置 control that
|
|
950
|
+
* opens this page in the plugin manager. Present in every 0.2.x release
|
|
951
|
+
* (checked against 0.2.0-rc.2 and 0.2.1-rc.5).
|
|
952
|
+
* - 0.1.5 `settings.plugin.item` — the keyed card of the older settings dialog,
|
|
953
|
+
* keyed by the settings namespace.
|
|
954
|
+
*
|
|
955
|
+
* The 0.2.x `plugins.item` slot is deliberately NOT registered: the shipped
|
|
956
|
+
* contract reserves it for the host's own plugins ("用于官方插件", rendered in the
|
|
957
|
+
* 内置插件配置 group). A third-party bundle belongs on its own row instead.
|
|
958
|
+
*
|
|
959
|
+
* TWO HOST GENERATIONS, ONE SCOPE. The settings scope this page edits moved in
|
|
782
960
|
* 0.2.0: `ctx.settingsScope` (0.1.5) is gone and replaced by `ctx.configForms`
|
|
783
961
|
* — which however exposes the SAME three methods the page was written against
|
|
784
962
|
* (`getSnapshot`/`subscribe`/`set`). So the page keeps its narrow `PageScope`
|
|
@@ -788,10 +966,19 @@ window.__ModuleLoader__.load({
|
|
|
788
966
|
* waiting forever.
|
|
789
967
|
*
|
|
790
968
|
* Slot keys, register shapes and the module table were taken from the RUNNING
|
|
791
|
-
* version's own official occupants (`dsh-client-ui-settings-
|
|
792
|
-
* `dsh-client-ui-settings-
|
|
793
|
-
*
|
|
794
|
-
*
|
|
969
|
+
* version's own official occupants (`dsh-client-ui-settings-agent-loop`,
|
|
970
|
+
* `dsh-client-ui-settings-shell`) and their published contracts. A slot key that
|
|
971
|
+
* nothing declares is inert under `ctx.slots.inject` (the callback never runs),
|
|
972
|
+
* which is what lets one build register into both generations.
|
|
973
|
+
*
|
|
974
|
+
* LOCALIZED COPY FOLLOWS THE HOST'S OWN LANGUAGE SELECTION. The client half
|
|
975
|
+
* registers its `zh`/`en` dictionaries under this plugin's namespace through
|
|
976
|
+
* `ctx.locale.register`, and every slot registration declares `locale: NAMESPACE`
|
|
977
|
+
* so the renderer hands each page render the framework `t` seat. Switching
|
|
978
|
+
* Settings → General → Language therefore switches this page too, without a
|
|
979
|
+
* reload; languages without a dictionary fall back to English (the host's
|
|
980
|
+
* documented baseline), and a host without a locale seat (0.1.5 slots, tests)
|
|
981
|
+
* falls back to the built-in Chinese copy.
|
|
795
982
|
*
|
|
796
983
|
* Every @deepseek-ai/* import here is TYPE-ONLY (erased): the runtime services
|
|
797
984
|
* arrive through cordis, and react resolves from the page's module table
|
|
@@ -801,14 +988,23 @@ window.__ModuleLoader__.load({
|
|
|
801
988
|
/**
|
|
802
989
|
* Client services this half needs.
|
|
803
990
|
*
|
|
804
|
-
*
|
|
991
|
+
* `locale` ships in every supported host generation and backs the framework `t`
|
|
992
|
+
* seat; the settings scope itself is fetched late-bound below, because the
|
|
805
993
|
* 0.1.5 (`settingsScope`) and 0.2.x (`configForms`) providers differ and an
|
|
806
994
|
* `inject` entry for a service that never appears would block activation.
|
|
807
995
|
*/
|
|
808
|
-
const inject = ["slots"];
|
|
996
|
+
const inject = ["slots", "locale"];
|
|
809
997
|
/** The settings namespace this page edits — the one the host half registers. */
|
|
810
998
|
const NAMESPACE = "extra-paths";
|
|
811
999
|
/**
|
|
1000
|
+
* The plugin manager's key for our row: `<bundle name>#<entry id>`.
|
|
1001
|
+
*
|
|
1002
|
+
* The bundle name is the package name and the row id is the entry this repo's
|
|
1003
|
+
* `cordis.patch.yml` inserts; `tests/client-slots.test.ts` pins it against both
|
|
1004
|
+
* files so a rename cannot silently detach the config control.
|
|
1005
|
+
*/
|
|
1006
|
+
const ROW_KEY = "dsh-extra-paths#extra-paths";
|
|
1007
|
+
/**
|
|
812
1008
|
* A `PageScope` that forwards to whichever real scope arrives.
|
|
813
1009
|
*
|
|
814
1010
|
* Subscribers are held here rather than on the real scope so a page that mounted
|
|
@@ -834,7 +1030,13 @@ window.__ModuleLoader__.load({
|
|
|
834
1030
|
listeners.delete(listener);
|
|
835
1031
|
};
|
|
836
1032
|
},
|
|
837
|
-
set: (field, value) =>
|
|
1033
|
+
set: (field, value) => {
|
|
1034
|
+
if (real === void 0) return Promise.resolve();
|
|
1035
|
+
return real.set(field, value).then((accepted) => {
|
|
1036
|
+
if (accepted === false) throw saveRefusedError();
|
|
1037
|
+
return accepted;
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
838
1040
|
},
|
|
839
1041
|
attach: (next) => {
|
|
840
1042
|
if (next === void 0) return;
|
|
@@ -851,6 +1053,13 @@ window.__ModuleLoader__.load({
|
|
|
851
1053
|
*/
|
|
852
1054
|
function apply(ctx) {
|
|
853
1055
|
const { scope, attach } = lateBoundScope();
|
|
1056
|
+
const registerLocales = () => ctx.locale.register(NAMESPACE, {
|
|
1057
|
+
zh,
|
|
1058
|
+
en
|
|
1059
|
+
});
|
|
1060
|
+
if (typeof ctx.effect === "function") ctx.effect(registerLocales, "extra-paths: locales");
|
|
1061
|
+
else registerLocales();
|
|
1062
|
+
const t = ctx.locale.bind(NAMESPACE);
|
|
854
1063
|
ctx.inject(["settingsScope"], (child) => {
|
|
855
1064
|
const { settingsScope } = child;
|
|
856
1065
|
attach(settingsScope.bind({ namespace: NAMESPACE }));
|
|
@@ -860,7 +1069,7 @@ window.__ModuleLoader__.load({
|
|
|
860
1069
|
attach({
|
|
861
1070
|
getSnapshot: () => configForms.get(NAMESPACE).getSnapshot(),
|
|
862
1071
|
subscribe: (listener) => configForms.get(NAMESPACE).subscribe(listener),
|
|
863
|
-
set: (field, value) => configForms.get(NAMESPACE).set(field, value)
|
|
1072
|
+
set: (field, value) => configForms.get(NAMESPACE).set(field, value)
|
|
864
1073
|
});
|
|
865
1074
|
});
|
|
866
1075
|
const getWorkspaces = () => ctx.get("workspaces", false);
|
|
@@ -868,35 +1077,45 @@ window.__ModuleLoader__.load({
|
|
|
868
1077
|
scope,
|
|
869
1078
|
getWorkspaces
|
|
870
1079
|
});
|
|
871
|
-
|
|
1080
|
+
/** The editor, forwarding the shell's workspace hook when the slot carries one. */
|
|
1081
|
+
const renderPage = (slotProps) => react.createElement(ExtraPathsPage, {
|
|
1082
|
+
scope,
|
|
1083
|
+
t: typeof slotProps?.t === "function" ? slotProps.t : void 0,
|
|
1084
|
+
getWorkspaces,
|
|
1085
|
+
useWorkspaces: typeof slotProps?.useWorkspaces === "function" ? slotProps.useWorkspaces : void 0
|
|
1086
|
+
});
|
|
1087
|
+
/** The slot component: one line for `summary`, the editor for every other view. */
|
|
1088
|
+
const card = (slotProps) => slotProps?.view === "summary" ? react.createElement(ExtraPathsSummary, {
|
|
1089
|
+
scope,
|
|
1090
|
+
t: typeof slotProps.t === "function" ? slotProps.t : void 0
|
|
1091
|
+
}) : renderPage(slotProps);
|
|
872
1092
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
873
1093
|
name: "settings.section",
|
|
874
1094
|
id: NAMESPACE,
|
|
875
1095
|
order: 40,
|
|
876
|
-
label: () => "
|
|
1096
|
+
label: () => t("navLabel"),
|
|
877
1097
|
locale: NAMESPACE,
|
|
878
1098
|
inject: props
|
|
879
|
-
},
|
|
1099
|
+
}, card));
|
|
880
1100
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
881
1101
|
name: "settings.plugin.item",
|
|
882
1102
|
key: NAMESPACE,
|
|
883
1103
|
locale: NAMESPACE,
|
|
884
1104
|
inject: props
|
|
885
|
-
},
|
|
886
|
-
const
|
|
887
|
-
name: "plugins.
|
|
888
|
-
|
|
889
|
-
order: 40,
|
|
890
|
-
label: () => "额外可写路径",
|
|
1105
|
+
}, card));
|
|
1106
|
+
const registerRow = () => ctx.slots.inject("plugins.row.config", () => ctx.slots.register({
|
|
1107
|
+
name: "plugins.row.config",
|
|
1108
|
+
key: ROW_KEY,
|
|
891
1109
|
locale: NAMESPACE,
|
|
892
1110
|
inject: props
|
|
893
|
-
},
|
|
1111
|
+
}, card));
|
|
894
1112
|
const forms = ctx.get("configForms", false);
|
|
895
|
-
if (typeof forms?.whileServed === "function" && typeof ctx.effect === "function") ctx.effect(() => forms.whileServed?.(["extra-paths"],
|
|
896
|
-
else
|
|
1113
|
+
if (typeof forms?.whileServed === "function" && typeof ctx.effect === "function") ctx.effect(() => forms.whileServed?.(["extra-paths"], registerRow) ?? registerRow(), "extra-paths: row page while served");
|
|
1114
|
+
else registerRow();
|
|
897
1115
|
}
|
|
898
1116
|
//#endregion
|
|
899
1117
|
exports.NAMESPACE = NAMESPACE;
|
|
1118
|
+
exports.ROW_KEY = ROW_KEY;
|
|
900
1119
|
exports.apply = apply;
|
|
901
1120
|
exports.inject = inject;
|
|
902
1121
|
exports.lateBoundScope = lateBoundScope;
|
package/lib/policy.js
CHANGED
|
@@ -7,11 +7,24 @@
|
|
|
7
7
|
* under a configured root. The mode rises to `workspace-write` because that is
|
|
8
8
|
* this grant's meaning: a single call is allowed to write this root, while the
|
|
9
9
|
* base class keeps owning resolution, atomic publication and the version guard.
|
|
10
|
+
*
|
|
11
|
+
* The caller's own `additionalWritableRoots` are dropped on purpose: under a
|
|
12
|
+
* `read-only` session an `always-write` grant must not smuggle the deployment's
|
|
13
|
+
* extra roots into the elevated call.
|
|
10
14
|
* @param policy - the caller's resolved policy.
|
|
11
15
|
* @param workspaceRoot - the canonical configured root that matched the target.
|
|
16
|
+
* @param additionalWritableRoots - further configured roots to grant in the
|
|
17
|
+
* same call (DSH 0.2.2+ only; used by `moveFile` when both ends lie under
|
|
18
|
+
* different configured roots).
|
|
12
19
|
* @returns the policy to hand the base implementation.
|
|
13
20
|
*/
|
|
14
|
-
export function syntheticPolicy(policy, workspaceRoot) {
|
|
15
|
-
|
|
21
|
+
export function syntheticPolicy(policy, workspaceRoot, additionalWritableRoots) {
|
|
22
|
+
const { additionalWritableRoots: _callerRoots, ...rest } = policy;
|
|
23
|
+
return {
|
|
24
|
+
...rest,
|
|
25
|
+
mode: 'workspace-write',
|
|
26
|
+
workspaceRoot,
|
|
27
|
+
...(additionalWritableRoots === undefined ? {} : { additionalWritableRoots }),
|
|
28
|
+
};
|
|
16
29
|
}
|
|
17
30
|
//# sourceMappingURL=policy.js.map
|
package/lib/policy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAkB,EAClB,aAAqB,EACrB,uBAA2C;IAE3C,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAA;IACjE,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,iBAAiB;QACvB,aAAa;QACb,GAAG,CAAC,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,CAAC;KAC9E,CAAA;AACH,CAAC"}
|
package/lib/types/policy.d.ts
CHANGED
|
@@ -7,6 +7,16 @@ import type { SandboxModeLike } from './grant.js';
|
|
|
7
7
|
export interface PolicyLike {
|
|
8
8
|
readonly mode: SandboxModeLike;
|
|
9
9
|
readonly workspaceRoot: string;
|
|
10
|
+
/**
|
|
11
|
+
* Explicit extra writable directories a policy may carry (DSH 0.2.2+).
|
|
12
|
+
*
|
|
13
|
+
* The 0.2.2 enforcement layers derive their allow-list from the workspace
|
|
14
|
+
* root PLUS this list, so a single synthetic policy can grant more than one
|
|
15
|
+
* configured root — which is what a move between two configured roots needs.
|
|
16
|
+
* Older hosts have no such field and ignore it; the wrapper only sets it for
|
|
17
|
+
* the 0.2.2-only `moveFile` surface.
|
|
18
|
+
*/
|
|
19
|
+
readonly additionalWritableRoots?: readonly string[];
|
|
10
20
|
readonly sessionId?: unknown;
|
|
11
21
|
}
|
|
12
22
|
/**
|
|
@@ -14,8 +24,15 @@ export interface PolicyLike {
|
|
|
14
24
|
* under a configured root. The mode rises to `workspace-write` because that is
|
|
15
25
|
* this grant's meaning: a single call is allowed to write this root, while the
|
|
16
26
|
* base class keeps owning resolution, atomic publication and the version guard.
|
|
27
|
+
*
|
|
28
|
+
* The caller's own `additionalWritableRoots` are dropped on purpose: under a
|
|
29
|
+
* `read-only` session an `always-write` grant must not smuggle the deployment's
|
|
30
|
+
* extra roots into the elevated call.
|
|
17
31
|
* @param policy - the caller's resolved policy.
|
|
18
32
|
* @param workspaceRoot - the canonical configured root that matched the target.
|
|
33
|
+
* @param additionalWritableRoots - further configured roots to grant in the
|
|
34
|
+
* same call (DSH 0.2.2+ only; used by `moveFile` when both ends lie under
|
|
35
|
+
* different configured roots).
|
|
19
36
|
* @returns the policy to hand the base implementation.
|
|
20
37
|
*/
|
|
21
|
-
export declare function syntheticPolicy(policy: PolicyLike, workspaceRoot: string): PolicyLike;
|
|
38
|
+
export declare function syntheticPolicy(policy: PolicyLike, workspaceRoot: string, additionalWritableRoots?: readonly string[]): PolicyLike;
|
package/lib/types/wrap-fs.d.ts
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* The filesystem half of the plugin: a transparent Proxy over `ctx.fs` that
|
|
3
3
|
* re-stamps ONE call's policy when its target lies under a configured root.
|
|
4
4
|
*
|
|
5
|
+
* The host generation decides how many mutations this surface has. 0.2.0/0.2.1
|
|
6
|
+
* fence `writeText`/`editText`; 0.2.2 additionally fences `patchText`,
|
|
7
|
+
* `deleteFile` and `moveFile` (the `apply_patch` tool and the delete/move
|
|
8
|
+
* operations). The wrapper therefore overrides every mutation the INNER service
|
|
9
|
+
* actually exposes, and never invents one: on a 0.2.1 service the three newer
|
|
10
|
+
* methods stay absent, exactly as the base class declared them.
|
|
11
|
+
*
|
|
5
12
|
* Transparency rules (verified against cordis 4.0.2 by
|
|
6
13
|
* spike/cordis-get-wrap-baseline.mjs): forward every property with the inner
|
|
7
14
|
* value as the receiver, bind methods to the inner instance — except
|
|
@@ -24,6 +31,12 @@ export interface FsInnerLike {
|
|
|
24
31
|
}): Promise<FsTargetLike>;
|
|
25
32
|
writeText(target: FsTargetLike, content: string, expected?: unknown, signal?: AbortSignal, policy?: PolicyLike): Promise<unknown>;
|
|
26
33
|
editText(target: FsTargetLike, edit: unknown, expected?: unknown, signal?: AbortSignal, policy?: PolicyLike): Promise<unknown>;
|
|
34
|
+
/** DSH 0.2.2+: apply parsed hunks (the `apply_patch` tool's surface). */
|
|
35
|
+
patchText?(target: FsTargetLike, hunks: unknown, expected?: unknown, signal?: AbortSignal, policy?: PolicyLike): Promise<unknown>;
|
|
36
|
+
/** DSH 0.2.2+: remove one regular file. */
|
|
37
|
+
deleteFile?(target: FsTargetLike, expected?: unknown, signal?: AbortSignal, policy?: PolicyLike): Promise<unknown>;
|
|
38
|
+
/** DSH 0.2.2+: publish a destination and remove the source. */
|
|
39
|
+
moveFile?(source: FsTargetLike, destination: FsTargetLike, options?: unknown, signal?: AbortSignal, policy?: PolicyLike): Promise<unknown>;
|
|
27
40
|
readonly sandboxMode?: string;
|
|
28
41
|
}
|
|
29
42
|
/** What the wrapper needs from the plugin. */
|
package/lib/wrap-fs.js
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* The filesystem half of the plugin: a transparent Proxy over `ctx.fs` that
|
|
3
3
|
* re-stamps ONE call's policy when its target lies under a configured root.
|
|
4
4
|
*
|
|
5
|
+
* The host generation decides how many mutations this surface has. 0.2.0/0.2.1
|
|
6
|
+
* fence `writeText`/`editText`; 0.2.2 additionally fences `patchText`,
|
|
7
|
+
* `deleteFile` and `moveFile` (the `apply_patch` tool and the delete/move
|
|
8
|
+
* operations). The wrapper therefore overrides every mutation the INNER service
|
|
9
|
+
* actually exposes, and never invents one: on a 0.2.1 service the three newer
|
|
10
|
+
* methods stay absent, exactly as the base class declared them.
|
|
11
|
+
*
|
|
5
12
|
* Transparency rules (verified against cordis 4.0.2 by
|
|
6
13
|
* spike/cordis-get-wrap-baseline.mjs): forward every property with the inner
|
|
7
14
|
* value as the receiver, bind methods to the inner instance — except
|
|
@@ -9,6 +16,8 @@
|
|
|
9
16
|
* (`Service[Symbol.hasInstance]` walks `instance.constructor`).
|
|
10
17
|
* @module dsh-extra-paths/wrap-fs
|
|
11
18
|
*/
|
|
19
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
20
|
+
import { resolve as resolvePath } from 'node:path';
|
|
12
21
|
import { grantFor } from './grant.js';
|
|
13
22
|
import { isUnder } from './paths.js';
|
|
14
23
|
import { syntheticPolicy } from './policy.js';
|
|
@@ -27,6 +36,22 @@ export function isConfiningFs(value) {
|
|
|
27
36
|
&& typeof fs.resolve === 'function'
|
|
28
37
|
&& typeof fs.sandboxMode === 'string';
|
|
29
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether a configured root can be expressed as an `additionalWritableRoots`
|
|
41
|
+
* entry for the 0.2.2 fence: an existing PHYSICAL directory. The base fence
|
|
42
|
+
* rejects missing, non-directory and symlinked entries by throwing, so a grant
|
|
43
|
+
* list is only assembled from roots that pass the same test.
|
|
44
|
+
* @param path - the canonical root to test.
|
|
45
|
+
* @returns true when the base fence would accept it.
|
|
46
|
+
*/
|
|
47
|
+
function isPhysicalDirectory(path) {
|
|
48
|
+
try {
|
|
49
|
+
return statSync(path).isDirectory() && realpathSync.native(path) === resolvePath(path);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
30
55
|
/**
|
|
31
56
|
* Wrap one filesystem service.
|
|
32
57
|
* @param inner - the service instance read from the context.
|
|
@@ -35,10 +60,12 @@ export function isConfiningFs(value) {
|
|
|
35
60
|
*/
|
|
36
61
|
export function wrapFs(inner, deps) {
|
|
37
62
|
const bound = new Map();
|
|
63
|
+
/** Roots this call grants, or an empty list when the target set is not covered. */
|
|
64
|
+
const grantedFor = (policy) => grantFor(policy.mode, resolveRoots(deps.readConfig(), policy.workspaceRoot).roots, 'fs');
|
|
38
65
|
const translate = async (target, policy, delegate) => {
|
|
39
66
|
if (policy === undefined || policy.mode === 'danger-full-access')
|
|
40
67
|
return delegate(policy);
|
|
41
|
-
const granted =
|
|
68
|
+
const granted = grantedFor(policy);
|
|
42
69
|
if (granted.length === 0)
|
|
43
70
|
return delegate(policy);
|
|
44
71
|
// Re-canonicalise NOW, exactly like the base fence does, so the identity we
|
|
@@ -49,17 +76,59 @@ export function wrapFs(inner, deps) {
|
|
|
49
76
|
return delegate(policy);
|
|
50
77
|
return delegate(syntheticPolicy(policy, match.root));
|
|
51
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* A move is one call with TWO fenced targets. Both ends must land in the
|
|
81
|
+
* configured set; one policy then carries the union. When the ends share one
|
|
82
|
+
* configured root the workspace-root re-stamp is enough on every host; two
|
|
83
|
+
* different roots are expressed through `additionalWritableRoots` (0.2.2+,
|
|
84
|
+
* the only host generation that has `moveFile` at all).
|
|
85
|
+
*/
|
|
86
|
+
const translateMove = async (source, destination, policy, delegate) => {
|
|
87
|
+
if (policy === undefined || policy.mode === 'danger-full-access')
|
|
88
|
+
return delegate(policy);
|
|
89
|
+
const granted = grantedFor(policy);
|
|
90
|
+
if (granted.length === 0)
|
|
91
|
+
return delegate(policy);
|
|
92
|
+
const [freshSource, freshDestination] = await Promise.all([
|
|
93
|
+
inner.resolve(source.displayPath),
|
|
94
|
+
inner.resolve(destination.displayPath),
|
|
95
|
+
]);
|
|
96
|
+
const sourceRoot = granted.find(root => isUnder(String(freshSource.targetKey), root.root));
|
|
97
|
+
const destinationRoot = granted.find(root => isUnder(String(freshDestination.targetKey), root.root));
|
|
98
|
+
if (sourceRoot === undefined || destinationRoot === undefined)
|
|
99
|
+
return delegate(policy);
|
|
100
|
+
if (sourceRoot === destinationRoot)
|
|
101
|
+
return delegate(syntheticPolicy(policy, sourceRoot.root));
|
|
102
|
+
const roots = [sourceRoot.root, destinationRoot.root];
|
|
103
|
+
if (!roots.every(isPhysicalDirectory))
|
|
104
|
+
return delegate(policy);
|
|
105
|
+
return delegate(syntheticPolicy(policy, sourceRoot.root, [destinationRoot.root]));
|
|
106
|
+
};
|
|
52
107
|
// Built ONCE per wrapper: reading a method twice must hand back the same
|
|
53
108
|
// function (and a fresh closure per read is pure allocation). Nothing here
|
|
54
109
|
// captures read-time state — the policy is resolved inside each call.
|
|
55
110
|
const writeText = (t, content, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.writeText(t, content, expected, signal, effective));
|
|
56
111
|
const editText = (t, edit, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.editText(t, edit, expected, signal, effective));
|
|
112
|
+
const patchText = (t, hunks, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.patchText(t, hunks, expected, signal, effective));
|
|
113
|
+
const deleteFile = (t, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.deleteFile(t, expected, signal, effective));
|
|
114
|
+
const moveFile = (source, destination, options, signal, policy) => translateMove(source, destination, policy ?? deps.fallbackPolicy(), effective => inner.moveFile(source, destination, options, signal, effective));
|
|
115
|
+
const overrides = new Map([
|
|
116
|
+
['writeText', writeText],
|
|
117
|
+
['editText', editText],
|
|
118
|
+
]);
|
|
119
|
+
// Only override what the running host declares: a 0.2.1 service must keep
|
|
120
|
+
// answering `undefined` for the 0.2.2-only mutations.
|
|
121
|
+
if (typeof inner.patchText === 'function')
|
|
122
|
+
overrides.set('patchText', patchText);
|
|
123
|
+
if (typeof inner.deleteFile === 'function')
|
|
124
|
+
overrides.set('deleteFile', deleteFile);
|
|
125
|
+
if (typeof inner.moveFile === 'function')
|
|
126
|
+
overrides.set('moveFile', moveFile);
|
|
57
127
|
return new Proxy(inner, {
|
|
58
128
|
get(target, prop) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return editText;
|
|
129
|
+
const override = overrides.get(prop);
|
|
130
|
+
if (override !== undefined)
|
|
131
|
+
return override;
|
|
63
132
|
const value = Reflect.get(target, prop, target);
|
|
64
133
|
if (typeof value !== 'function' || prop === 'constructor')
|
|
65
134
|
return value;
|
package/lib/wrap-fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-fs.js","sourceRoot":"","sources":["../src/wrap-fs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wrap-fs.js","sourceRoot":"","sources":["../src/wrap-fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAA;AA8B9D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,EAAE,GAAG,KAAgC,CAAA;IAC3C,OAAO,OAAO,EAAE,EAAE,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UAAU;QAAE,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAE7E,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE;QACtB,GAAG,CAAC,MAAM,EAAE,IAAI;YACd,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACpC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAA;YAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;YAC/C,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,IAAI,KAAK,aAAa;gBAAE,OAAO,KAAK,CAAA;YACvE,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAC9B,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAA;YACvC,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC7B,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YACnB,OAAO,EAAE,CAAA;QACX,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-extra-paths",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "配置一组额外可写根:fs 工具与受限 shell 首次尝试即可写、无需审批,带 Web 设置页与按目录结构锚定的路径模式。 · DSH plugin: configured extra writable roots for the fs tools and the sandboxed shell, with a Web settings page and structure-anchored path patterns.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"client": {
|
|
28
28
|
"platform": "web",
|
|
29
29
|
"inject": [
|
|
30
|
+
"@deepseek-ai/dsh-client-locale",
|
|
30
31
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
31
32
|
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
32
33
|
]
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"paths": "node scripts/dsh-paths.mjs",
|
|
38
|
+
"check:sanitized": "node scripts/check-sanitized.mjs",
|
|
37
39
|
"prepare": "node scripts/dsh-paths.mjs --tolerant",
|
|
38
40
|
"build": "pnpm run build:host && pnpm run build:client",
|
|
39
41
|
"build:host": "node scripts/dsh-paths.mjs && tsc -p tsconfig.json",
|
|
@@ -79,19 +81,19 @@
|
|
|
79
81
|
},
|
|
80
82
|
"engines": {
|
|
81
83
|
"node": ">=20",
|
|
82
|
-
"dsh": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0"
|
|
84
|
+
"dsh": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
86
|
-
"@deepseek-ai/dsh-fs": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
87
|
-
"@deepseek-ai/dsh-sandbox": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
88
|
-
"@deepseek-ai/dsh-sandbox-policy": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
89
|
-
"@deepseek-ai/dsh-settings": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
90
|
-
"@deepseek-ai/dsh-fs-sandbox": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
91
|
-
"@deepseek-ai/dsh-system-prompt": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
92
|
-
"@deepseek-ai/dsh-host-webserver": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
93
|
-
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0",
|
|
94
|
-
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0"
|
|
88
|
+
"@deepseek-ai/dsh-fs": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
89
|
+
"@deepseek-ai/dsh-sandbox": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
90
|
+
"@deepseek-ai/dsh-sandbox-policy": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
91
|
+
"@deepseek-ai/dsh-settings": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
92
|
+
"@deepseek-ai/dsh-fs-sandbox": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
93
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
94
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
95
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-0 <0.1.6-0 || >=0.2.0-0 <0.2.2-0 || >=0.2.2-0 <0.2.3-0"
|
|
95
97
|
},
|
|
96
98
|
"peerDependenciesMeta": {
|
|
97
99
|
"@deepseek-ai/dsh-fs-sandbox": {
|