@deepseek-ai/dsh-typert-loader 0.1.5-rc.2 → 0.1.6-alpha.2

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/typert/loader/README.md
5
- README.md: ba8fe7d6b13924b6f9a39d1e792153f346aec530
6
- README.zh.md: a4c16ac5f5b54e8524422f6574092e909988be95
5
+ README.md: c45fbdebe7c2a05491515c3679ca2a3338285ca1
6
+ README.zh.md: 9cb6ae6da5da30292d74e05932cd147090aa4dc8
package/README.md CHANGED
@@ -9,7 +9,7 @@ English | [中文](README.zh.md)
9
9
 
10
10
  ## Summary
11
11
 
12
- With `dsh-typert-loader` mounted, every package that mounts in a Loader composition automatically contributes its generated Typert reflection and schemas to the runtime registry — and withdraws them when the package or the plugin unmounts. Packages without the generated export are skipped, so adding the plugin to any composition is safe. An explicit `packages` list covers plugins nested behind another Loader entry, whose fibers carry no resolvable package specifier. It is a Node-only plugin and needs the config-tree resolution anchor to resolve packages.
12
+ With `dsh-typert-loader` mounted, every package that mounts in a Loader composition automatically contributes its generated Typert reflection and schema factories to the runtime registry — and withdraws them when the package or the plugin unmounts. Packages without the generated export are skipped, so adding the plugin to any composition is safe. An explicit `packages` list covers plugins nested behind another Loader entry, whose fibers carry no resolvable package specifier. It is a Node-only plugin and needs the config-tree resolution anchor to resolve packages.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -44,7 +44,7 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
44
44
 
45
45
  ### What gets registered
46
46
 
47
- Each qualifying Loader entry contributes its generated host-face reflection and schemas to the runtime registry. Registration follows the entry lifecycle: it is withdrawn when the entry or the plugin unmounts, and a registration whose import settles after both are gone is discarded.
47
+ Each qualifying Loader entry contributes its generated host-face reflection and schema factories to the runtime registry. Registration follows the entry lifecycle: it is withdrawn when the entry or the plugin unmounts, and an import that settles after either owner is gone is discarded.
48
48
 
49
49
  ### Observable behavior and failures
50
50
 
@@ -66,7 +66,7 @@ The plugin is an incremental scanner mirroring the client-modules node half: eve
66
66
 
67
67
  ### Manifest validation
68
68
 
69
- `validateTypertManifest()` is the module/file boundary: the manifest crosses from a build artifact into the typed registry, so every field is checked. The manifest must name the package that exports it, carry face `host`, hold zod v4 schema instances, and keep well-formed service, event, object, member, type, and documentation records; invocation descriptors must use strict codecs. Every failure names the package and the defect.
69
+ `validateTypertManifest()` is the module/file boundary: the manifest crosses from a build artifact into the typed registry, so every field is checked. The manifest must name the package that exports it, carry face `host`, hold schema factories, and keep well-formed service, event, object, member, type, and documentation records; invocation descriptors must use strict codecs with factories. Every failure names the package and the defect.
70
70
 
71
71
  ### Caching and ownership
72
72
 
package/README.zh.md CHANGED
@@ -9,7 +9,7 @@ kind: "package-reference"
9
9
 
10
10
  ## 概述
11
11
 
12
- 挂载 `dsh-typert-loader` 后,Loader 组合中每个挂载的包都会自动把其生成的 Typert 反射与 schema 贡献给运行时注册表——并在包或本插件卸载时自动撤销。没有该导出的包会被跳过,因此在任何 Loader 组合中挂载它都是安全的。显式 `packages` 用于覆盖嵌套在另一 Loader 配置项之下的插件,这些插件的 fiber 不携带可解析的包说明符。它是仅支持 Node 的插件,需要配置树解析锚点才能解析包。
12
+ 挂载 `dsh-typert-loader` 后,Loader 组合中每个挂载的包都会自动把其生成的 Typert 反射与 schema factory 贡献给运行时注册表——并在包或本插件卸载时自动撤销。没有该导出的包会被跳过,因此在任何 Loader 组合中挂载它都是安全的。显式 `packages` 用于覆盖嵌套在另一 Loader 配置项之下的插件,这些插件的 fiber 不携带可解析的包说明符。它是仅支持 Node 的插件,需要配置树解析锚点才能解析包。
13
13
 
14
14
  ## 目录
15
15
 
@@ -40,15 +40,15 @@ kind: "package-reference"
40
40
  |---|---|---|
41
41
  | `packages` | `[]` | 为嵌套在另一 Loader 配置项下的插件额外注册的包产物;每个包都必须能从配置树解析,并导出 `./typert` |
42
42
 
43
- 生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-typert-loader)是每个受支持字段的穷尽式真源。
43
+ 生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-typert-loader)是所有受支持字段的完整真源。
44
44
 
45
45
  ### 注册什么
46
46
 
47
- 每个符合条件的 Loader 配置项都会把其生成的宿主侧反射与 schema 贡献给运行时注册表。注册跟随配置项生命周期:配置项或本插件卸载时撤销;在两者都已消失后才结束的注册会被丢弃。
47
+ 每个符合条件的 Loader 配置项都会把其生成的宿主侧反射与 schema factory 贡献给运行时注册表。注册跟随配置项生命周期:配置项或本插件卸载时撤销;在配置项或本插件任一方卸载后才结束的导入操作会被丢弃。
48
48
 
49
49
  ### 可观察行为与失败
50
50
 
51
- 没有该导出的包会被静默跳过。解析结论与已导入的 manifest 会在整个进程生命周期内缓存,因此新增 `./typert` 导出后必须重启。已挂载配置项对应的产物格式错误时,激活会大声失败;之后才发生的失败按包记录日志,不会阻止无关包完成注册。无法从配置树解析、或缺少该导出的显式 `packages` 条目会大声失败并指名该包。
51
+ 没有该导出的包会被静默跳过。解析结论与已导入的 manifest(元数据清单)会在整个进程生命周期内缓存,因此新增 `./typert` 导出后必须重启。已挂载配置项对应的产物格式错误时,激活会明确报错;之后才发生的失败按包记录日志,不会阻止无关包完成注册。无法从配置树解析、或缺少该导出的显式 `packages` 条目会明确报错并指名该包。
52
52
 
53
53
  -----
54
54
 
@@ -62,11 +62,11 @@ kind: "package-reference"
62
62
 
63
63
  ### 设计理念
64
64
 
65
- 本插件是一个增量扫描器,与 client-modules 的 Node 半实现对称:每次 Cordis `internal/plugin` 事件都会把该 fiber 的配置项名称标记为脏,微任务 flush 会针对实时 Loader 配置项逐一调和每个脏名称;激活阶段用所有当前配置项填充同一脏集合。
65
+ 本插件是一个增量扫描器,与 client-modules 的 Node 侧实现对称:每次 Cordis `internal/plugin` 事件都会把该 fiber 的配置项名称标记为脏,微任务 flush 会针对实时 Loader 配置项逐一调和每个脏名称;激活阶段用所有当前配置项填充同一脏集合。
66
66
 
67
67
  ### Manifest 校验
68
68
 
69
- `validateTypertManifest()` 是模块/文件边界:manifest 从构建产物进入类型化注册表,因此每个字段都会被检查。manifest 必须指名导出它的包、携带 `host` face、持有 zod v4 schema 实例,并保持服务、事件、对象、成员、类型与文档记录格式正确;调用描述符必须使用严格编解码器。每次失败都会指名包与缺陷。
69
+ `validateTypertManifest()` 是模块/文件边界:manifest 从构建产物进入类型化注册表,因此每个字段都会被检查。manifest 必须指名导出它的包、携带 `host` face、持有 schema factory,并保持服务、事件、对象、成员、类型与文档记录格式正确;调用描述符必须使用带 factory 的严格编解码器。每次失败都会指名包与缺陷。
70
70
 
71
71
  ### 缓存与归属
72
72
 
@@ -76,8 +76,8 @@ kind: "package-reference"
76
76
 
77
77
  | 文件 | 职责 |
78
78
  |---|---|
79
- | [`src/index.ts`](src/index.ts) | 插件入口:`Config`、扫描器、manifest 校验、注册接线 |
80
- | — | 不发布运行时不变式伴生入口;Loader entry 生命周期直接持有每个准确的 registry disposer,integration test 会观察注册与移除。 |
79
+ | [`src/index.ts`](src/index.ts) | 插件入口:`Config`、扫描器、manifest 校验、注册装配逻辑 |
80
+ | — | 不发布运行时不变式伴生入口;Loader 配置项的生命周期直接持有每个对应的注册表资源释放函数,集成测试会观察注册与移除。 |
81
81
 
82
82
  </details>
83
83
 
@@ -86,7 +86,7 @@ kind: "package-reference"
86
86
  <a id="further-exploration"></a>
87
87
  ## 进一步探索
88
88
 
89
- 当包级约定不够用时阅读以下页面;它们从 loader 逐步进入它注册什么以及什么产生这些内容。
89
+ 当包级约定不够用时阅读以下页面;这些页面从 loader 开始,依次介绍它注册的内容及其生成方。
90
90
 
91
91
  - [Typert 注册表](../registry/README.zh.md)——本插件所供给的服务。
92
92
  - [Typert 生成器](../generator/README.zh.md)——产生 loader 所导入产物的包。
@@ -102,7 +102,7 @@ kind: "package-reference"
102
102
 
103
103
  #### KV Cache 影响
104
104
 
105
- 无直接影响;注册变化只有在消费方读取注册表时才会触及请求。
105
+ 无直接影响;注册变更只有通过读取注册表的消费方才会影响请求。
106
106
 
107
107
  ## 已知限制与延期工作
108
108
 
package/lib/index.js CHANGED
@@ -84,7 +84,7 @@ function validateTypertManifest(pkgName, exported) {
84
84
  if (typeof value !== "object" || value === null) throw new Error(`typert-loader: ${pkgName} TYPERT.schemas contains a non-object schema`);
85
85
  const schema = value;
86
86
  requireString(pkgName, schema, "name", "schema");
87
- if (typeof schema.schema !== "object" || schema.schema === null || !("_zod" in schema.schema)) throw new Error(`typert-loader: ${pkgName} TYPERT schema "${schema.name}" is not a zod v4 schema instance`);
87
+ if (typeof schema.create !== "function") throw new Error(`typert-loader: ${pkgName} TYPERT schema "${schema.name}" has no create() factory`);
88
88
  }
89
89
  const model = requireObject(pkgName, manifest.model, "TYPERT.model");
90
90
  const services = requireArray(pkgName, model.services, "TYPERT.model.services");
@@ -207,7 +207,7 @@ function requireStrictCodec(pkgName, value, subject) {
207
207
  const codec = requireObject(pkgName, value, subject);
208
208
  if (codec.mode !== "strict") throw new Error(`typert-loader: ${pkgName} ${subject} must use a strict codec`);
209
209
  requireString(pkgName, codec, "typeSymbol", subject);
210
- if (typeof codec.schema !== "object" || codec.schema === null || !("_zod" in codec.schema) || typeof codec.schema.parse !== "function") throw new Error(`typert-loader: ${pkgName} ${subject} is not backed by a zod v4 schema`);
210
+ if (typeof codec.create !== "function") throw new Error(`typert-loader: ${pkgName} ${subject} has no create() factory`);
211
211
  }
212
212
  /**
213
213
  * Scan current Loader entries during activation, then follow entry mounts and
@@ -217,7 +217,8 @@ function requireStrictCodec(pkgName, value, subject) {
217
217
  */
218
218
  async function apply(ctx, config) {
219
219
  if (ctx.baseUrl === void 0) throw new Error("typert-loader: ctx.baseUrl is unset — the loader needs the config-tree anchor to resolve plugin packages");
220
- const require = createRequire(ctx.baseUrl);
220
+ const baseUrl = ctx.baseUrl;
221
+ const require = createRequire(baseUrl);
221
222
  const configured = new Set(config.packages);
222
223
  const registered = /* @__PURE__ */ new Map();
223
224
  const pending = /* @__PURE__ */ new Map();
@@ -235,17 +236,33 @@ async function apply(ctx, config) {
235
236
  const resolveArtifact = (pkgName) => {
236
237
  const cached = artifactPath.get(pkgName);
237
238
  if (cached !== void 0) return cached;
239
+ const firstSlash = pkgName.indexOf("/");
240
+ if (firstSlash >= 0 && (pkgName[0] !== "@" || pkgName.indexOf("/", firstSlash + 1) >= 0)) {
241
+ if (configured.has(pkgName)) throw new Error(`typert-loader: configured package "${pkgName}" cannot be resolved from the config tree — add it to the composition package dependencies or remove it from packages`);
242
+ artifactPath.set(pkgName, null);
243
+ return null;
244
+ }
238
245
  let pkgPath;
246
+ let pkg;
239
247
  try {
240
- pkgPath = require.resolve(`${pkgName}/package.json`);
248
+ const packages = ctx.get("pluginPackages");
249
+ const resolvedPackage = packages?.packageOf(pkgName, baseUrl);
250
+ if (packages !== void 0 && resolvedPackage === void 0) throw new Error("package is absent from the active resolver");
251
+ pkgPath = resolvedPackage === void 0 ? require.resolve(`${pkgName}/package.json`) : resolvedPackage.manifestPath;
252
+ pkg = resolvedPackage?.manifest;
241
253
  } catch (cause) {
242
254
  if (configured.has(pkgName)) throw new Error(`typert-loader: configured package "${pkgName}" cannot be resolved from the config tree — add it to the composition package dependencies or remove it from packages`, { cause });
243
255
  artifactPath.set(pkgName, null);
244
256
  return null;
245
257
  }
246
- const rel = typertExportOf(pkgName, JSON.parse(readFileSync(pkgPath, "utf8")).exports);
258
+ pkg ??= JSON.parse(readFileSync(pkgPath, "utf8"));
259
+ const manifestName = typeof pkg.name === "string" ? pkg.name : pkgName;
260
+ const rel = typertExportOf(manifestName, pkg.exports);
247
261
  if (rel === void 0 && configured.has(pkgName)) throw new Error(`typert-loader: configured package "${pkgName}" does not export "${TYPERT_HOST_EXPORT}"`);
248
- const resolved = rel === void 0 ? null : join(dirname(pkgPath), rel);
262
+ const resolved = rel === void 0 ? null : {
263
+ packageName: manifestName,
264
+ path: join(dirname(pkgPath), rel)
265
+ };
249
266
  artifactPath.set(pkgName, resolved);
250
267
  return resolved;
251
268
  };
@@ -275,9 +292,9 @@ async function apply(ctx, config) {
275
292
  return;
276
293
  }
277
294
  if (registered.has(entryName) || pending.has(entryName)) return void 0;
278
- const path = resolveArtifact(entryName);
279
- if (path === null) return void 0;
280
- const task = loadManifest(entryName, path).then((manifest) => {
295
+ const artifact = resolveArtifact(entryName);
296
+ if (artifact === null) return void 0;
297
+ const task = loadManifest(artifact.packageName, artifact.path).then((manifest) => {
281
298
  if (!active || !qualifies(entryName) || registered.has(entryName)) return;
282
299
  registered.set(entryName, ctx.typert.register(manifest));
283
300
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-typert-loader",
3
3
  "description": "Loader integration for generated Typert package contributions",
4
- "version": "0.1.5-rc.2",
4
+ "version": "0.1.6-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -28,16 +28,17 @@
28
28
  "license": "MIT",
29
29
  "peerDependencies": {
30
30
  "@deepseek-ai/cordis-plugin-loader": "^1.0.3",
31
- "@deepseek-ai/cordis": "^4.0.2",
32
- "@deepseek-ai/dsh-typert-registry": "^0.1.5-rc.2"
31
+ "@deepseek-ai/dsh-typert-registry": "^0.1.6-alpha.2",
32
+ "@deepseek-ai/cordis": "^4.0.2"
33
33
  },
34
34
  "dependencies": {
35
35
  "@deepseek-ai/schemastery": "^3.18.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "zod": "^4.4.3",
39
+ "@deepseek-ai/dsh-app-boot": "^0.1.6-alpha.2",
39
40
  "@deepseek-ai/cordis-plugin-loader": "^1.0.3",
40
- "@deepseek-ai/dsh-typert-registry": "^0.1.5-rc.2",
41
+ "@deepseek-ai/dsh-typert-registry": "^0.1.6-alpha.2",
41
42
  "@deepseek-ai/cordis": "^4.0.2"
42
43
  }
43
44
  }