dsh-doc-preview 0.1.2 → 0.1.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 +8 -1
- package/lib/index.js +8 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -40,6 +40,11 @@ http://<host>/docs/<工作区id>/<相对路径>.md -> 渲染该工作区内的
|
|
|
40
40
|
传可选参数 `rel` 时,`docs` 列出该相对目录下 `.md/.markdown/.html` 的链接;不传则只给工作区根链接。
|
|
41
41
|
- **优雅降级**:缺 `cwd` / 当前 cwd 未登记 / 无 registry 时不抛错,返回 `{ workspaceUrl: null, note: '…' }`。
|
|
42
42
|
- **相对路径**:返回 `/docs/...` 相对路径(前缀由宿主 Web 提供);仅 Web 形态适用。
|
|
43
|
+
- **输出 schema 约束**:`doc_preview_links` 通过 `ctx.tools.register` 以**原始 ToolDefinition** 注册,其
|
|
44
|
+
`output.schema` 必须使用 dsh 的强制 JSON-Schema 子集(`object/array/string/number/integer/boolean/null`),
|
|
45
|
+
**不能**写作者 DSL 的 `type: 'json'`(那只在 `defineTool()` 里合法,会先编译成 annotation-only 节点;
|
|
46
|
+
原样传给 `register` 会触发 `assertSupportedJsonSchema` 报错、导致宿主启动失败)。这里用的是 annotation-only
|
|
47
|
+
schema(不写 `type` = 任意 JSON),语义与 `json` 节点编译后完全一致。
|
|
43
48
|
|
|
44
49
|
## 安装
|
|
45
50
|
|
|
@@ -66,6 +71,7 @@ lib/index.js # 构建产物(Loader 实际加载)
|
|
|
66
71
|
cordis.patch.yml # 插入 doc-preview 行,inject webServer + tools + workspaceRegistry
|
|
67
72
|
tests/drive-route.mjs # 路由自测(mock workspaceRegistry)
|
|
68
73
|
tests/tools-test.mjs # doc_preview_links 工具自测(mock registry + exec.agent)
|
|
74
|
+
tests/schema-test.mjs # 输出 schema 防回归自测(拒绝非法 type:'json')
|
|
69
75
|
tests/render-test.mjs # md 渲染自测
|
|
70
76
|
tests/logic-test.mjs # 渲染边界 + 穿越防护自测
|
|
71
77
|
README.md / ENABLE.md
|
|
@@ -74,9 +80,10 @@ README.md / ENABLE.md
|
|
|
74
80
|
## 自测
|
|
75
81
|
|
|
76
82
|
```sh
|
|
77
|
-
npm test # build +
|
|
83
|
+
npm test # build + 全部五套自测
|
|
78
84
|
node tests/drive-route.mjs # 工作区映射/隔离/404
|
|
79
85
|
node tests/tools-test.mjs # doc_preview_links 工具
|
|
86
|
+
node tests/schema-test.mjs # 输出 schema 防回归
|
|
80
87
|
tsx --tsconfig tsconfig.json tests/render-test.mjs
|
|
81
88
|
tsx --tsconfig tsconfig.json tests/logic-test.mjs
|
|
82
89
|
```
|
package/lib/index.js
CHANGED
|
@@ -316,8 +316,15 @@ function createDocPreviewLinks(wsRegistry) {
|
|
|
316
316
|
optional: true,
|
|
317
317
|
},
|
|
318
318
|
},
|
|
319
|
+
// NOTE: the output schema must use the enforced JSON-Schema subset
|
|
320
|
+
// (object/array/string/number/integer/boolean/null) — NOT the author DSL
|
|
321
|
+
// `type: 'json'`. `doc_preview_links` is registered as a raw ToolDefinition
|
|
322
|
+
// through ctx.tools.register, which skips defineTool()'s DSL→subset compile;
|
|
323
|
+
// a verbatim `type: 'json'` would fail assertSupportedJsonSchema and crash
|
|
324
|
+
// host startup. An annotation-only schema (no `type`) = unconstrained JSON,
|
|
325
|
+
// the exact post-compile meaning of the DSL `json` node.
|
|
319
326
|
output: {
|
|
320
|
-
schema: {
|
|
327
|
+
schema: { description: 'doc_preview_links result: workspace, workspaceUrl, and optional docs list' },
|
|
321
328
|
render: renderJson,
|
|
322
329
|
},
|
|
323
330
|
async execute(args, exec) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-doc-preview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "A dsh bundle plugin: preview local Markdown/HTML documents per workspace in the Web GUI via a /docs route on ctx.webServer + ctx.workspaceRegistry.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"logic:test": "tsx --tsconfig ./tsconfig.json tests/logic-test.mjs",
|
|
65
65
|
"route:test": "node tests/drive-route.mjs",
|
|
66
66
|
"tools:test": "node tests/tools-test.mjs",
|
|
67
|
-
"test": "node
|
|
67
|
+
"schema:test": "node tests/schema-test.mjs",
|
|
68
|
+
"test": "node scripts/build.mjs && node tests/drive-route.mjs && node tests/tools-test.mjs && node tests/schema-test.mjs && tsx --tsconfig ./tsconfig.json tests/render-test.mjs && tsx --tsconfig ./tsconfig.json tests/logic-test.mjs"
|
|
68
69
|
}
|
|
69
70
|
}
|