dsh-extra-paths 0.1.0 → 0.1.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/LICENSE +21 -0
- package/README.md +70 -51
- package/README.zh.md +88 -0
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 0x7a76
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,80 +1,99 @@
|
|
|
1
1
|
# dsh-extra-paths
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
插件以服务包装实现,不改 DSH 核心代码,并提供 Web 设置页与「当前工作区解析出的生效根」预览。
|
|
3
|
+
English | [中文](README.zh.md)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Let DSH **write to a set of configured external paths on the first try, with no approval**: this covers the `write`/`edit`
|
|
6
|
+
tools and `bash` subprocesses alike. The plugin works by wrapping services (it does not change DSH core) and ships a Web
|
|
7
|
+
settings page plus a preview of the effective roots for the current workspace.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Requires DSH `0.1.5` / `0.2.0` / `0.2.1` (outside that range the install gate refuses the package).
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
dsh plugin --profile <name> add dsh-extra-paths # <name> = your profile
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
From a checkout instead of the registry:
|
|
9
18
|
|
|
10
19
|
```bash
|
|
11
20
|
pnpm install && pnpm build
|
|
12
|
-
dsh plugin --profile <name> add /path/to/dsh-extra-paths #
|
|
21
|
+
dsh plugin --profile <name> add /path/to/dsh-extra-paths # path = absolute path to this repo
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
Then open the **Extra paths** card under **Settings → Plugins**, or **Extra writable paths** in the settings sidebar.
|
|
16
25
|
|
|
17
|
-
##
|
|
26
|
+
## Configuration
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
Write it into the `extra-paths` section of the settings document `~/.dsh/settings.yaml`, or just use the settings page
|
|
29
|
+
(**saving takes effect immediately, no restart needed**). `<work root>` below is a placeholder for the directory that
|
|
30
|
+
holds your projects (an absolute path, or one starting with `~/`) — replace it with a path of your own:
|
|
21
31
|
|
|
22
32
|
```yaml
|
|
23
33
|
extra-paths:
|
|
24
34
|
paths:
|
|
25
|
-
-
|
|
26
|
-
- path: ../../notes/home #
|
|
35
|
+
- <work root>/notes/home # default scope/surfaces
|
|
36
|
+
- path: ../../notes/home # relative paths resolve against the session workspace
|
|
27
37
|
scope: always-write
|
|
28
|
-
- path:
|
|
38
|
+
- path: <work root>/some-repo
|
|
29
39
|
scope: write
|
|
30
|
-
surfaces: [fs] #
|
|
40
|
+
surfaces: [fs] # only the write/edit tools may write here
|
|
31
41
|
```
|
|
32
42
|
|
|
33
|
-
| scope |
|
|
43
|
+
| scope | session `read-only` | session `workspace-write` |
|
|
34
44
|
|---|---|---|
|
|
35
|
-
| `write
|
|
36
|
-
| `always-write` |
|
|
45
|
+
| `write` (default) | denied | writable |
|
|
46
|
+
| `always-write` | writable | writable |
|
|
37
47
|
|
|
38
|
-
`surfaces
|
|
48
|
+
`surfaces`: `fs` = the `write`/`edit`/str-replace tools; `shell` = `bash` subprocesses. Reads and execution are not
|
|
49
|
+
sandboxed to begin with.
|
|
39
50
|
|
|
40
|
-
###
|
|
51
|
+
### How relative paths resolve
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
Relative paths resolve against **each session's own workspace** (the settings page has a "base workspace" field so you
|
|
54
|
+
can preview this):
|
|
43
55
|
|
|
44
|
-
|
|
|
56
|
+
| Spelling | Resolves to | Notes |
|
|
45
57
|
|---|---|---|
|
|
46
|
-
| `..` |
|
|
47
|
-
|
|
|
48
|
-
| `../../notes/home` |
|
|
49
|
-
| `~/notes/home` |
|
|
58
|
+
| `..` | `<work root>` | the **parent** of the workspace; that directory and all of its siblings become writable |
|
|
59
|
+
| `../some-repo` | `<work root>/some-repo` | grants exactly one sibling repository (more precise than `..`, recommended) |
|
|
60
|
+
| `../../notes/home` | `<work root>/notes/home` | go up a few levels and into another tree |
|
|
61
|
+
| `~/notes/home` | under your home | independent of the workspace; `~user` is not expanded (same as the host) |
|
|
50
62
|
|
|
51
|
-
###
|
|
63
|
+
### Patterns: anchor a grant to directory structure (no hard-coded paths)
|
|
52
64
|
|
|
53
|
-
`path`
|
|
65
|
+
A `path` can use wildcards to describe **a group of directories**, turning "a certain directory exists somewhere in this
|
|
66
|
+
path" into a condition:
|
|
54
67
|
|
|
55
|
-
|
|
|
68
|
+
| Spelling | Matches (the granted root) |
|
|
56
69
|
|---|---|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
| `<work root>/**/.worktrees/..` | every **repository root that contains `.worktrees`** (the parent of `.worktrees`) |
|
|
71
|
+
| `<work root>/**/.worktrees/*` | each individual worktree (`.git` and the main checkout are never touched) |
|
|
72
|
+
| `<work root>/<some-repo>/.worktrees/*` | every worktree of one repository (**zero traversal cost**, recommended) |
|
|
73
|
+
| `<work root>/*/notes` | the `notes` directory under every repository/project |
|
|
74
|
+
|
|
75
|
+
Syntax: `*` = exactly one level, `**` = at most 3 levels (**only directories that actually exist** match, so
|
|
76
|
+
"`.worktrees` must exist" comes for free); a trailing `..` moves up **after** matching (so `…/.worktrees/..` is "the
|
|
77
|
+
parent of `.worktrees`", rather than something lexical collapsing eats away).
|
|
78
|
+
|
|
79
|
+
Safety bounds (hard constraints, not advice):
|
|
80
|
+
|
|
81
|
+
- the wildcard needs a **literal anchor** before it, at least two segments long, absolute or starting with `~/` —
|
|
82
|
+
`/**`, `~/**`, `/srv/**` are refused outright
|
|
83
|
+
- traversal **never enters** `node_modules` or `.git`, and `**` never enters hidden directories (`.worktrees` is a
|
|
84
|
+
literal, so it still matches at its own level)
|
|
85
|
+
- bounded: `**` covers at most 3 levels, and more than 4096 directories or more than 256 matches makes **the whole
|
|
86
|
+
pattern inert** (fail closed — never a partial, unpredictable grant); the reason is reported as a warning
|
|
87
|
+
- expansions are cached for 30 seconds, so a **newly created worktree is picked up within 30 seconds**
|
|
88
|
+
|
|
89
|
+
The settings page shows the **resolved absolute path** live for every row (symlinks follow the host's canonical
|
|
90
|
+
preview) and, for a pattern row, the match count as `[active ×N]` plus each concrete root below it; zero matches and
|
|
91
|
+
blocked patterns are both spelled out — so there is no need to "save first and then check whether it resolved".
|
|
92
|
+
|
|
93
|
+
## Known limits
|
|
94
|
+
|
|
95
|
+
- Per-path "no restrictions at all" is not achievable: the bash sandbox works at whole-invocation granularity.
|
|
96
|
+
- Relative paths resolve against the session workspace, so the same entry points at different directories in different
|
|
97
|
+
workspaces — the settings page preview shows the actual resolution.
|
|
98
|
+
- The shell side is not widened on Windows; `always-write` weakens what the `read-only` stop button can do for that path.
|
|
99
|
+
- Files written outside the workspace do not appear in the `deliverables` workspace-changes card.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# dsh-extra-paths
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
让 DSH 对一组配置的外部路径**首次尝试即可写、无需审批**:既覆盖 `write`/`edit` 工具,也覆盖 `bash` 子进程。
|
|
6
|
+
插件以服务包装实现,不改 DSH 核心代码,并提供 Web 设置页与「当前工作区解析出的生效根」预览。
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
需要 DSH `0.1.5` / `0.2.0` / `0.2.1`(不在范围内会被安装闸门拒绝)。
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
dsh plugin --profile <name> add dsh-extra-paths # <name>=你的 profile 名
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
想从源码安装(开发时):
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm install && pnpm build
|
|
20
|
+
dsh plugin --profile <name> add /path/to/dsh-extra-paths # 路径=本仓库的绝对路径
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
装好后打开 **设置 → 插件** 里的「Extra paths」卡片,或设置左栏的「额外可写路径」。
|
|
24
|
+
|
|
25
|
+
## 配置
|
|
26
|
+
|
|
27
|
+
写进设置文档 `~/.dsh/settings.yaml` 的 `extra-paths` 段,或直接用设置页(**保存即生效,无需重启**)。
|
|
28
|
+
下面的 `<工作根>` 是占位符,指你放项目的那个上层目录(绝对路径,或 `~/` 开头的路径):
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
extra-paths:
|
|
32
|
+
paths:
|
|
33
|
+
- <工作根>/notes/home # 用默认 scope/surfaces
|
|
34
|
+
- path: ../../notes/home # 相对路径按「会话工作区」解析
|
|
35
|
+
scope: always-write
|
|
36
|
+
- path: <工作根>/some-repo
|
|
37
|
+
scope: write
|
|
38
|
+
surfaces: [fs] # 只允许 write/edit 工具写
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
| scope | 会话 read-only | 会话 workspace-write |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `write`(默认) | 拒绝 | 可写 |
|
|
44
|
+
| `always-write` | 可写 | 可写 |
|
|
45
|
+
|
|
46
|
+
`surfaces`:`fs` = `write`/`edit`/str-replace 工具;`shell` = `bash` 子进程。读与执行本来就不受沙箱限制。
|
|
47
|
+
|
|
48
|
+
### 相对路径怎么写
|
|
49
|
+
|
|
50
|
+
相对路径按**各会话自己的工作区**解析(设置页里可以改「基准工作区」来预览):
|
|
51
|
+
|
|
52
|
+
| 写法 | 解析成 | 说明 |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `..` | `<工作根>` | 工作区的**上一层**,该目录及其所有兄弟目录都可写 |
|
|
55
|
+
| `../某仓库` | `<工作根>/某仓库` | 只放行那一个兄弟仓库(比 `..` 精确,推荐) |
|
|
56
|
+
| `../../notes/home` | `<工作根>/notes/home` | 往上几层再进别的树 |
|
|
57
|
+
| `~/notes/home` | 家目录下 | 与工作区无关;`~user` 不展开(与宿主一致) |
|
|
58
|
+
|
|
59
|
+
### 模式:按目录结构锚定(不用写死路径)
|
|
60
|
+
|
|
61
|
+
`path` 里可以用通配符描述**一组目录**,于是"路径里存在某个目录"可以变成一个条件:
|
|
62
|
+
|
|
63
|
+
| 写法 | 命中(授予的根) |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `<工作根>/**/.worktrees/..` | 每个**含 `.worktrees` 的仓库根**(`.worktrees` 的上级) |
|
|
66
|
+
| `<工作根>/**/.worktrees/*` | 每个具体 worktree(不碰 `.git` 与主检出) |
|
|
67
|
+
| `<工作根>/<某仓库>/.worktrees/*` | 某一个仓库下所有 worktree(**零遍历开销**,最推荐) |
|
|
68
|
+
| `<工作根>/*/notes` | 每个仓库/项目下的 `notes` 目录 |
|
|
69
|
+
|
|
70
|
+
语法:`*` = 恰好一层、`**` = 最多 3 层(**只匹配真实存在的目录**,所以"必须存在 `.worktrees`"是自然结果);
|
|
71
|
+
结尾的 `..` 在**命中之后**再上移(因此 `…/.worktrees/..` 就是"`.worktrees` 的上级",不会被词法折叠吃掉)。
|
|
72
|
+
|
|
73
|
+
安全边界(都是硬约束,不是建议):
|
|
74
|
+
|
|
75
|
+
- 通配符前必须有**字面量锚点**,且锚点至少两层、必须是绝对路径或 `~/` 开头 —— `/**`、`~/**`、`/srv/**` 一律拒绝
|
|
76
|
+
- 遍历**不进入** `node_modules`、`.git`,`**` 也不进入隐藏目录(`.worktrees` 本身是字面量,仍在当层匹配)
|
|
77
|
+
- 有界:`**` 最多 3 层、目录数 > 4096 或命中 > 256 时**整个模式不生效**(fail closed,绝不给"部分命中"这种不可预期的授权);触顶原因会写进告警
|
|
78
|
+
- 展开结果缓存 30 秒,因此**新建的 worktree 最迟 30 秒**被纳入
|
|
79
|
+
|
|
80
|
+
设置页每行会**实时显示解析到的绝对路径**(符号链接以宿主的「解析预览」为准),模式行显示命中条数 `[生效 ×N]`
|
|
81
|
+
并列出每个具体根;0 命中或被拦截都会明确说明,所以不必"先保存再看解析对不对"。
|
|
82
|
+
|
|
83
|
+
## 已知边界
|
|
84
|
+
|
|
85
|
+
- 逐路径的"完全不受限"做不到:bash 沙箱是整次调用粒度。
|
|
86
|
+
- 相对路径按会话工作区解析,因此同一份配置在不同工作区指向不同目录——设置页的预览会显示实际解析结果。
|
|
87
|
+
- Windows 的 shell 侧不放行;`always-write` 会削弱 `read-only` 急停按钮对该路径的作用。
|
|
88
|
+
- 写在工作区外的文件不会出现在 `deliverables` 的工作区变更卡片里。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-extra-paths",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"build:client": "tsdown",
|
|
41
41
|
"watch:client": "tsdown --watch",
|
|
42
42
|
"typecheck": "node scripts/dsh-paths.mjs && tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
|
|
43
|
-
"test": "vitest run"
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"prepublishOnly": "pnpm run build && pnpm test"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@deepseek-ai/schemastery": "^3.18.4"
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"settings",
|
|
68
69
|
"bash"
|
|
69
70
|
],
|
|
70
|
-
"license": "
|
|
71
|
+
"license": "MIT",
|
|
71
72
|
"repository": {
|
|
72
73
|
"type": "git",
|
|
73
74
|
"url": "git+https://github.com/0x7a76/dsh-extra-paths.git"
|