dsh-mini-utility-dock 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.en.md +10 -0
- package/CHANGELOG.md +14 -4
- package/LICENSE +1 -1
- package/README.en.md +17 -25
- package/README.md +17 -25
- package/package.json +1 -1
package/CHANGELOG.en.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.5 - 2026-09-17
|
|
4
|
+
|
|
5
|
+
- Documentation maintenance: README and CHANGELOG cleanup. Fragments and command behavior are unchanged, so consumer pins need no update.
|
|
6
|
+
|
|
7
|
+
## 0.1.4 - 2026-09-16
|
|
8
|
+
|
|
9
|
+
- Add a cross-repo consistency section to the READMEs, separating two different properties: **local** -- a consumer's `npm test` runs `loopback:check` / `guard:check` to compare both fragments byte-for-byte against the version of this package it pins, covering both "edited a block by hand" and "forgot to re-`sync`"; and **cross-repo** -- this package's published versions are immutable and consumers pin an exact version, so "all three pin the same version" already implies "all three hold byte-identical blocks".
|
|
10
|
+
- That section also records that a consumer's `scripts/guard-parity.mjs` is a **manual diagnostic, not a CI gate**, because the property it asserts cannot hold while a peer checkout resolves to a different branch, which would make it report false failures.
|
|
11
|
+
- The LICENSE copyright holder is now `xswt442-cmd`.
|
|
12
|
+
|
|
3
13
|
## 0.1.3 - 2026-09-14
|
|
4
14
|
|
|
5
15
|
- Add two host-side fragments. `dist/loopback.js` (`dsh-loopback-helpers`) exports `LOOPBACK_HOSTNAMES`, `normalizeHostValue`, `hostHostname`, `isLoopbackName` and `isLoopbackAddress`. `dist/guard.js` (`dsh-host-guard`) exports `portOf`, `GUARD_REASONS`, `DEFAULT_GUARD_POLICY` and an internal `bindGuard()` factory; a consumer passes its own error codes and wording as `policy`, so the enforcement does not fork per plugin.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.5 - 2026-09-17
|
|
4
|
+
|
|
5
|
+
- 文档维护:README 与 CHANGELOG 的整理,片段与命令行为不变,故无需改动消费仓的 pin。
|
|
6
|
+
|
|
7
|
+
## 0.1.4 - 2026-09-16
|
|
8
|
+
|
|
9
|
+
- README 新增「跨仓一致性」一节:本地由消费仓 `npm test` 的 `loopback:check` / `guard:check` 逐字节比对,跨仓由消费仓 pin 精确版本保证。
|
|
10
|
+
- 该节记录 `scripts/guard-parity.mjs` 是人工诊断工具而非 CI 门禁。
|
|
11
|
+
- LICENSE 版权署名统一为 `xswt442-cmd`。
|
|
12
|
+
|
|
3
13
|
## 0.1.3 - 2026-09-14
|
|
4
14
|
|
|
5
|
-
- 新增两个 host 侧片段:`dist/loopback.js`(`dsh-loopback-helpers
|
|
6
|
-
- `sync` / `check`
|
|
7
|
-
- 修正 README
|
|
8
|
-
- 新增测试:多块同步与幂等 `check
|
|
15
|
+
- 新增两个 host 侧片段:`dist/loopback.js`(`dsh-loopback-helpers`)导出回环判定谓词;`dist/guard.js`(`dsh-host-guard`)导出 `portOf`、`GUARD_REASONS`、`DEFAULT_GUARD_POLICY` 与内部的 `bindGuard()` 工厂,调用方以 `policy` 传入自己的错误码与文案。
|
|
16
|
+
- `sync` / `check` 处理目标文件中所有已标记的片段,按 `FRAGMENTS` 顺序自下而上应用。
|
|
17
|
+
- 修正 README 与包描述:说明两个 host 侧片段的职责、固定顺序与 `bindGuard` 不导出的原因。
|
|
18
|
+
- 新增测试:多块同步与幂等 `check`、块顺序、片段不引入 `import`/`require`、判据不被重复声明。
|
|
9
19
|
|
|
10
20
|
## 0.1.2 - 2026-09-06
|
|
11
21
|
|
package/LICENSE
CHANGED
package/README.en.md
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
1
|
# dsh-mini-utility-dock
|
|
2
2
|
|
|
3
|
-
Source fragments and an embedding CLI shared by the DSH plugins.
|
|
3
|
+
Source fragments and an embedding CLI shared by the DSH plugins.
|
|
4
4
|
|
|
5
5
|
## Fragments
|
|
6
6
|
|
|
7
|
-
Three fragments, each delimited by markers.
|
|
8
|
-
|
|
9
7
|
| Fragment | Marker | Target file | Exports |
|
|
10
8
|
| --- | --- | --- | --- |
|
|
11
9
|
| dock bootstrap | `dsh-mini-utility-dock` | `lib/client.js` | — |
|
|
12
10
|
| loopback predicates | `dsh-loopback-helpers` | `lib/shared.js` | `LOOPBACK_HOSTNAMES`, `normalizeHostValue`, `hostHostname`, `isLoopbackName`, `isLoopbackAddress` |
|
|
13
11
|
| host request guard | `dsh-host-guard` | `lib/shared.js` | `portOf`, `GUARD_REASONS`, `DEFAULT_GUARD_POLICY` |
|
|
14
12
|
|
|
15
|
-
`dsh-loopback-helpers` decides address locality; the Host-header path and the TCP-peer path share one decision. `dsh-host-guard` decides admission, and provides a `bindGuard()` factory internally.
|
|
16
|
-
|
|
17
13
|
## Usage
|
|
18
14
|
|
|
19
15
|
Write the markers into the target file, then run the CLI.
|
|
20
16
|
|
|
21
17
|
```sh
|
|
22
|
-
npx dsh-mini-utility-dock sync path/to/
|
|
23
|
-
npx dsh-mini-utility-dock check path/to/
|
|
18
|
+
npx dsh-mini-utility-dock sync path/to/shared.js
|
|
19
|
+
npx dsh-mini-utility-dock check path/to/shared.js
|
|
24
20
|
```
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
The CLI maintains every marked fragment in the file, applied bottom-up in `FRAGMENTS` order. `sync` preserves marker indentation; `check` exits non-zero on drift.
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
Equivalent entry point from this repository (target passed by the caller):
|
|
29
25
|
|
|
30
26
|
```sh
|
|
31
|
-
npm run dock:embed -- check path/to/client.js
|
|
32
|
-
npm run dock:embed -- sync path/to/client.js
|
|
27
|
+
npm run dock:embed -- check path/to/client.js
|
|
28
|
+
npm run dock:embed -- sync path/to/client.js
|
|
33
29
|
```
|
|
34
30
|
|
|
35
|
-
Consumers invoke the same CLI as `loopback:sync` / `guard:sync`, with the target fixed to their own `lib/shared.js
|
|
36
|
-
|
|
37
|
-
## The two host-side fragments
|
|
38
|
-
|
|
39
|
-
The two fragments in `lib/shared.js` have a fixed order, `dsh-loopback-helpers` first.
|
|
40
|
-
|
|
41
|
-
The order is a functional requirement, not a style choice. Both fragments occupy one file, and `dsh-host-guard` uses the module-scope names the preceding fragment exports. It therefore neither redeclares those predicates nor imports a sibling module: redeclaring collides with the declaration in the same file, and importing would break the standalone-publication constraint. The `guard-parity` check fails when the order is reversed.
|
|
42
|
-
|
|
43
|
-
`bindGuard` is not exported from the fragment. A consumer declares its own guard export in the same file (typically reusing an existing name such as `createGuard`), and exporting the same identifier would collide. Each plugin calls `bindGuard()` and passes its own error codes and wording through `policy`: the enforcement is shared, the error vocabulary stays with each plugin.
|
|
31
|
+
Consumers invoke the same CLI as `loopback:sync` / `guard:sync`, with the target fixed to their own `lib/shared.js`.
|
|
44
32
|
|
|
45
|
-
##
|
|
33
|
+
## Constraints
|
|
46
34
|
|
|
47
|
-
`dist/` is the single source
|
|
35
|
+
- `dist/` is the single source. Run `npm test` after a change, and re-`sync` consumers.
|
|
36
|
+
- The two fragments in `lib/shared.js` have a fixed order, `dsh-loopback-helpers` first: `dsh-host-guard` uses the module-scope names the preceding fragment exports, and neither redeclares nor imports them.
|
|
37
|
+
- A fragment must not contain `import` or `require`; a consumer must publish standalone.
|
|
38
|
+
- `bindGuard` is not exported — a consumer declares its own guard export in the same file. Each plugin passes its own error codes and wording through `policy`; the enforcement is shared.
|
|
39
|
+
- A missing, blank, or non-string `label` falls back to `id`.
|
|
48
40
|
|
|
49
|
-
|
|
41
|
+
## Cross-repo consistency
|
|
50
42
|
|
|
51
|
-
|
|
43
|
+
A consumer's `npm test` runs `loopback:check` / `guard:check`, comparing its two fragments byte for byte against the dock version it pins. A published version is immutable and consumers pin an exact version, so pin agreement implies fragment agreement.
|
|
52
44
|
|
|
53
|
-
|
|
45
|
+
`scripts/guard-parity.mjs` (in each consumer) checks that cross-repo property directly, including pin agreement. It is a manual diagnostic and **does not run in CI**: the property cannot hold while peers sit on a different branch. Run it when all three checkouts share a branch.
|
package/README.md
CHANGED
|
@@ -1,53 +1,45 @@
|
|
|
1
1
|
# dsh-mini-utility-dock
|
|
2
2
|
|
|
3
|
-
DSH 插件共享的源码片段与嵌入 CLI
|
|
3
|
+
DSH 插件共享的源码片段与嵌入 CLI。
|
|
4
4
|
|
|
5
5
|
## 片段
|
|
6
6
|
|
|
7
|
-
三个片段,均由标记界定。
|
|
8
|
-
|
|
9
7
|
| 片段 | 标记 | 目标文件 | 导出 |
|
|
10
8
|
| --- | --- | --- | --- |
|
|
11
9
|
| dock 引导 | `dsh-mini-utility-dock` | `lib/client.js` | — |
|
|
12
10
|
| loopback 判定 | `dsh-loopback-helpers` | `lib/shared.js` | `LOOPBACK_HOSTNAMES`、`normalizeHostValue`、`hostHostname`、`isLoopbackName`、`isLoopbackAddress` |
|
|
13
11
|
| host 请求守卫 | `dsh-host-guard` | `lib/shared.js` | `portOf`、`GUARD_REASONS`、`DEFAULT_GUARD_POLICY` |
|
|
14
12
|
|
|
15
|
-
`dsh-loopback-helpers` 定义地址的归属:Host 头与 TCP 对端两条路径共用同一判定。`dsh-host-guard` 定义准入策略,并在内部提供 `bindGuard()` 工厂。
|
|
16
|
-
|
|
17
13
|
## 使用
|
|
18
14
|
|
|
19
15
|
在目标文件中写入标记,然后运行 CLI。
|
|
20
16
|
|
|
21
17
|
```sh
|
|
22
|
-
npx dsh-mini-utility-dock sync path/to/
|
|
23
|
-
npx dsh-mini-utility-dock check path/to/
|
|
18
|
+
npx dsh-mini-utility-dock sync path/to/shared.js
|
|
19
|
+
npx dsh-mini-utility-dock check path/to/shared.js
|
|
24
20
|
```
|
|
25
21
|
|
|
26
|
-
`sync`
|
|
22
|
+
CLI 处理文件中所有已标记的片段,按 `FRAGMENTS` 顺序自下而上应用;`sync` 保留标记缩进,`check` 在漂移时非零退出。
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
本仓库等价入口(目标由调用方传入):
|
|
29
25
|
|
|
30
26
|
```sh
|
|
31
|
-
npm run dock:embed -- check path/to/client.js
|
|
32
|
-
npm run dock:embed -- sync path/to/client.js
|
|
27
|
+
npm run dock:embed -- check path/to/client.js
|
|
28
|
+
npm run dock:embed -- sync path/to/client.js
|
|
33
29
|
```
|
|
34
30
|
|
|
35
|
-
消费插件以 `loopback:sync` / `guard:sync` 调用同一 CLI
|
|
36
|
-
|
|
37
|
-
## host 侧两个片段的约定
|
|
38
|
-
|
|
39
|
-
`lib/shared.js` 中的两个片段顺序固定,`dsh-loopback-helpers` 在前。
|
|
40
|
-
|
|
41
|
-
顺序是功能要求,不是风格约定。两者位于同一文件,`dsh-host-guard` 直接使用前一片段导出的模块级名字,因此它既不重新声明这些判据,也不 import 兄弟模块:重新声明与 import 都会与同文件内的声明冲突,且 import 会破坏插件独立发布的约束。`guard-parity` 检查在该顺序被颠倒时失败。
|
|
42
|
-
|
|
43
|
-
`bindGuard` 不从片段导出。消费插件在同一文件中声明自己的 guard 导出(通常沿用 `createGuard` 等既有名字),导出同名标识符会冲突。每个插件调用 `bindGuard()`,通过 `policy` 传入自身的错误码与文案;判定逻辑共用,错误词汇由各插件持有。
|
|
31
|
+
消费插件以 `loopback:sync` / `guard:sync` 调用同一 CLI,目标固定为自身 `lib/shared.js`。
|
|
44
32
|
|
|
45
|
-
##
|
|
33
|
+
## 约束
|
|
46
34
|
|
|
47
|
-
|
|
35
|
+
- `dist/` 是唯一来源。改片段后运行 `npm test`,并让消费插件重新 `sync`。
|
|
36
|
+
- `lib/shared.js` 中两个片段顺序固定,`dsh-loopback-helpers` 在前:`dsh-host-guard` 直接使用前一片段导出的模块级名字,既不重新声明也不 import。
|
|
37
|
+
- 片段不得包含 `import` 或 `require`;消费插件必须能独立发布。
|
|
38
|
+
- `bindGuard` 不从片段导出——消费插件在同一文件中声明自己的 guard 导出。各插件通过 `policy` 传入自身错误码与文案,判定逻辑共用。
|
|
39
|
+
- `label` 缺省、空白或非字符串时回退为 `id`。
|
|
48
40
|
|
|
49
|
-
|
|
41
|
+
## 跨仓一致性
|
|
50
42
|
|
|
51
|
-
|
|
43
|
+
消费仓的 `npm test` 用 `loopback:check` / `guard:check` 把本仓两个片段与所 pin 的 dock 版本逐字节比对。dock 版本不可变且消费仓 pin 精确版本,故「pin 一致」即「片段一致」。
|
|
52
44
|
|
|
53
|
-
`
|
|
45
|
+
`scripts/guard-parity.mjs`(位于各消费仓)直接检这条跨仓性质,含 pin 一致性断言。它是人工诊断工具,**不在 CI 中运行**:peer 处于不同分支时该性质本就不成立。请在三个检出同分支时运行。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mini-utility-dock",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Canonical fragments and a build-time embedding CLI shared by DSH plugins: the Mini Utility Dock bootstrap for client halves, and the loopback predicates plus the host request guard for host halves.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|