@longzai-intelligence-toolchain/config 0.0.0-stage → 0.0.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 CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
1
+ # @longzai-intelligence-toolchain/config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 开发工具类项目的配置类型定义包模板,集中声明项目级与 workspace 级配置的类型结构并提供默认配置,供 CLI、Dashboard 及其他包共享配置契约。
4
+
5
+ 定位为 dev-tool 项目模板 monorepo 的可选 packages 包(依据 template.json 的 includeConfig 条件决定是否生成),归属于 `packages/*` workspace。作为配置层的单一事实来源,向上为 apps/cli、apps/dashboard 等应用提供配置类型与默认值,自身不依赖项目内其他包,保持配置定义的独立与稳定。
6
+
7
+ 职能上,该包通过 src/index.ts 对外导出 ProjectConfig、WorkspaceConfig 两个配置类型以及 DEFAULT_CONFIG 默认配置常量:ProjectConfig 描述项目整体配置结构,WorkspaceConfig 描述 workspace 子包配置结构,DEFAULT_CONFIG 提供开箱即用的默认值。构建产物经 tsgo --build 与 resolve-aliases 处理后产出 ./dist/index.js 与类型声明,exports 字段限定对外导出路径,files 字段声明仅发布 dist 目录。
8
+
9
+ 实现情况为脚手架模板初始状态,package.json 的 description、exports、files、scripts(build、build:prod、typecheck、lint、test、clean 等)均已就绪,license 声明为 UNLICENSED。src/index.ts 已定义导出契约,但其引用的 ./types 与 ./defaults 模块文件尚未在模板中提供,需在使用模板后由开发者按导出契约补齐具体实现。
@@ -0,0 +1,91 @@
1
+ import "./rolldown-runtime-BqT_7tdF.js";
2
+ import * as z from "zod";
3
+ //#region src/config.types.d.ts
4
+ /**
5
+ * 单个委托域的就地覆盖项
6
+ *
7
+ * @remarks
8
+ * 就地配置 `lzi-toolchain.config.ts` 的 `domains` 表按域名声明覆盖,未声明的域走域表默认值
9
+ */
10
+ type DomainOverride = {
11
+ /**
12
+ * 覆盖该域委托的引擎 bin 名
13
+ */
14
+ bin?: string;
15
+ /**
16
+ * 是否启用该域
17
+ *
18
+ * @default true
19
+ */
20
+ enabled?: boolean;
21
+ };
22
+ /**
23
+ * `lzi-toolchain.config.ts` 的配置形态
24
+ *
25
+ * @remarks
26
+ * 全字段可选,空对象合法。伞形层只委托不实现,配置面仅承载委托行为的就地微调
27
+ */
28
+ type ToolchainConfig = {
29
+ /**
30
+ * 委托域的就地覆盖表,键为域名
31
+ */
32
+ domains?: Record<string, DomainOverride>;
33
+ };
34
+ /**
35
+ * 域覆盖项的 zod schema
36
+ */
37
+ declare const domainOverrideSchema: z.ZodObject<{
38
+ bin: z.ZodOptional<z.ZodString>;
39
+ enabled: z.ZodOptional<z.ZodBoolean>;
40
+ }, z.core.$strip>;
41
+ /**
42
+ * 配置形态的 zod schema
43
+ */
44
+ declare const toolchainConfigSchema: z.ZodObject<{
45
+ domains: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
46
+ bin: z.ZodOptional<z.ZodString>;
47
+ enabled: z.ZodOptional<z.ZodBoolean>;
48
+ }, z.core.$strip>>>;
49
+ }, z.core.$strip>;
50
+ /**
51
+ * 配置加载结果
52
+ */
53
+ type LoadedToolchainConfig = {
54
+ /**
55
+ * 经 zod 校验后的配置对象
56
+ */
57
+ config: ToolchainConfig;
58
+ /**
59
+ * 命中的配置文件绝对路径
60
+ */
61
+ filePath: string;
62
+ };
63
+ //#endregion
64
+ //#region src/define-config.factory.d.ts
65
+ /**
66
+ * 就地配置声明工厂
67
+ *
68
+ * @remarks
69
+ * ADR 0147 决策 2 要求配置文件以 `defineConfig` 工厂收口导出,禁裸对象字面量。
70
+ * 参数可选且默认空对象,无参调用 `defineConfig()` 即合法导出,对齐家族声明仓形态。
71
+ * 传入值经 zod 运行时校验,校验失败即抛错,禁止静默降级。
72
+ * @param config - 配置对象,字段全部可选
73
+ * @returns 经校验的原配置对象
74
+ * @throws {@link Error} 配置校验失败时抛出,消息含字段路径与原因
75
+ */
76
+ declare const defineConfig: (config?: ToolchainConfig) => ToolchainConfig;
77
+ //#endregion
78
+ //#region src/loader.utils.d.ts
79
+ /**
80
+ * 从 cwd 向上发现并加载就地配置
81
+ *
82
+ * @remarks
83
+ * 家族同款发现链:自 `process.cwd()` 逐级向上查找 `lzi-toolchain.config.ts`,
84
+ * 命中即动态导入 default 导出并经 zod 校验。未命中返回 null,调用方以空配置继续。
85
+ * 导入失败与校验失败均抛错,禁止静默吞掉错误配置。
86
+ * @returns 加载结果,未发现配置文件时为 null
87
+ * @throws {@link Error} 配置文件动态导入失败或校验失败时抛出
88
+ */
89
+ declare const loadToolchainConfig: () => Promise<LoadedToolchainConfig | null>;
90
+ //#endregion
91
+ export { type DomainOverride, type LoadedToolchainConfig, type ToolchainConfig, defineConfig, domainOverrideSchema, loadToolchainConfig, toolchainConfigSchema };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-BqT_7tdF.js";import*as e from"zod";import{existsSync as t}from"node:fs";import{join as n}from"node:path";const r=e.object({bin:e.string().min(1).optional(),enabled:e.boolean().optional()}),i=e.object({domains:e.record(e.string().min(1),r).optional()}),a=(e={})=>{let t=i.safeParse(e);if(!t.success){let e=t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `);throw Error(`lzi-toolchain.config.ts 校验失败: ${e}`)}return e},o=async()=>{let e=process.cwd();for(;;){let r=n(e,`lzi-toolchain.config.ts`);if(t(r)){let e=(await import(r)).default,t=i.safeParse(e);if(!t.success){let e=t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `);throw Error(`${r} 校验失败: ${e}`)}return{config:t.data,filePath:r}}let a=n(e,`..`);if(a===e)return null;e=a}};export{a as defineConfig,r as domainOverrideSchema,o as loadToolchainConfig,i as toolchainConfigSchema};
@@ -0,0 +1 @@
1
+ import"node:module";export{};
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-toolchain/config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Longzai Intelligence 工具链伞形配置契约(lzi-toolchain.config.ts 类型正本、defineConfig 工厂与加载器)",
5
+ "keywords": [
6
+ "config",
7
+ "longzai-intelligence"
8
+ ],
9
+ "license": "UNLICENSED",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "type": "module",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "lzi-builder",
24
+ "build:prod": "NODE_ENV=production lzi-builder",
25
+ "prepublishOnly": "bun run build:prod",
26
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
27
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
28
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
29
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
30
+ "lint": "oxlint && oxfmt --check",
31
+ "lint:fix": "oxlint --fix && oxfmt",
32
+ "test": "bun test",
33
+ "test:watch": "bun test --watch",
34
+ "test:coverage": "bun test --coverage",
35
+ "clean": "lzi-dev-cli clean"
36
+ },
37
+ "dependencies": {
38
+ "zod": "^4.6.5"
39
+ }
40
+ }