@longzai-intelligence-ledger/config 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 ADDED
@@ -0,0 +1,5 @@
1
+ # @longzai-intelligence-ledger/config
2
+
3
+ Longzai Intelligence Ledger 配置包:`lzi-ledger.config.ts` 的类型定义、`defineConfig` 工厂、常量、配置文件模板与统一加载器,台账形态阈值与豁免声明的唯一出口。
4
+
5
+ 主导出契约:`defineConfig`、`LziLedgerConfig`、`LedgerThresholds`、`LedgerExemptions`、`renderLziLedgerConfigTemplate`、`loadLziLedgerConfig`、`findLziLedgerConfigFile`、`STANDALONE_CONFIG_FILE`、`DEFAULT_STATUS_VOCABULARY`、`ENV_KEYS`。
@@ -0,0 +1,215 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * 台账形态量化阈值组
4
+ *
5
+ * 对应族 README 最简索引量化口径,全部为闭区间上限
6
+ * 行宽按字符计数,中文与半角字符均计一字符
7
+ */
8
+ type LedgerThresholds = {
9
+ /**
10
+ * 索引文件单行最大字符数
11
+ *
12
+ * @default 400
13
+ */
14
+ maxLineLength: number;
15
+ /**
16
+ * 工作流档最大行数
17
+ *
18
+ * @default 100
19
+ */
20
+ maxWorkstreamLines: number;
21
+ /**
22
+ * 工作流档最大字节数
23
+ *
24
+ * @default 16000
25
+ */
26
+ maxWorkstreamBytes: number;
27
+ };
28
+ /**
29
+ * 台账形态豁免组
30
+ *
31
+ * 豁免以相对台账族根的 glob 声明,支持 `*` 单段与 `**` 跨段通配
32
+ */
33
+ type LedgerExemptions = {
34
+ /**
35
+ * 体量豁免清单
36
+ *
37
+ * 命中者不受工作流档行数与字节数上限约束,行宽与链接规则仍然生效
38
+ * 典型形态为并档承袭档,原账总账全文迁入且内容逐字保留
39
+ *
40
+ * @default [ ]
41
+ */
42
+ sizeExemptGlobs: string[];
43
+ /**
44
+ * 临时路径豁免清单
45
+ *
46
+ * 命中者不执行临时目录路径禁令,典型形态为引述 gitignore 模式枚举的正档案
47
+ *
48
+ * @default [ ]
49
+ */
50
+ tmpPathAllowGlobs: string[];
51
+ /**
52
+ * 哈希禁令豁免清单
53
+ *
54
+ * 命中者不受索引面提交哈希禁令约束,典型形态为并档承袭档
55
+ *
56
+ * @default [ ]
57
+ */
58
+ hashExemptGlobs: string[];
59
+ };
60
+ /**
61
+ * LziLedger 配置
62
+ *
63
+ * 定义 `lzi-ledger.config.ts` 配置文件的结构,由 `lzi-ledger check` 消费
64
+ */
65
+ type LziLedgerConfig = {
66
+ /**
67
+ * 台账族根目录,相对消费仓仓库根
68
+ *
69
+ * @default 'docs/ledgers'
70
+ */
71
+ ledgersRoot: string;
72
+ /**
73
+ * 量化阈值覆写
74
+ *
75
+ * 未声明的阈值项沿用默认值
76
+ */
77
+ thresholds: Partial<LedgerThresholds>;
78
+ /**
79
+ * 豁免清单
80
+ */
81
+ exemptions: LedgerExemptions;
82
+ /**
83
+ * 附加状态词表
84
+ *
85
+ * 在默认词表之外追加合法状态值,适配各账自定义工作流级状态
86
+ *
87
+ * @default [ ]
88
+ */
89
+ extraStatusVocabulary: string[];
90
+ };
91
+ //#endregion
92
+ //#region src/define.config.d.ts
93
+ /**
94
+ * 定义 LziLedger 配置
95
+ *
96
+ * 填充缺省字段后原样返回,提供完整类型推导
97
+ * 纯数据整理,运行时无副作用
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * import { defineConfig } from '@longzai-intelligence-ledger/config';
102
+ *
103
+ * export default defineConfig({
104
+ * exemptions: {
105
+ * sizeExemptGlobs: ['compliance-clearance/workstreams/00*.md'],
106
+ * },
107
+ * });
108
+ * ```;
109
+ *
110
+ * @param config - LziLedger 配置对象,可省略全部字段
111
+ * @returns 填充缺省值后的完整配置对象
112
+ */
113
+ declare const defineConfig: (config?: Partial<LziLedgerConfig>) => LziLedgerConfig;
114
+ //#endregion
115
+ //#region src/constants.d.ts
116
+ /**
117
+ * standalone 配置文件名
118
+ *
119
+ * 消费仓仓库根的 `lzi-ledger.config.ts`,是台账形态阈值与豁免声明的单一真源
120
+ */
121
+ declare const STANDALONE_CONFIG_FILE = "lzi-ledger.config.ts";
122
+ /**
123
+ * 统一配置字段名
124
+ *
125
+ * 消费仓选择统一配置形态时,`lzi.config.ts` 中承载 LziLedger 配置的字段名
126
+ */
127
+ declare const UNIFIED_CONFIG_FIELD = "ledger";
128
+ /**
129
+ * 默认台账族根目录,相对消费仓仓库根
130
+ */
131
+ declare const DEFAULT_LEDGERS_ROOT = "docs/ledgers";
132
+ /**
133
+ * 默认状态词表
134
+ *
135
+ * 聚合表与工作流档状态位的合法取值,`已并入 NNN` 形态由引擎按模式识别
136
+ */
137
+ declare const DEFAULT_STATUS_VOCABULARY: readonly ['待建档', '待启动', '进行中', '已收口', '不适用'];
138
+ /**
139
+ * lzi-ledger 自身消费的环境变量名单一真源
140
+ *
141
+ * 新增环境变量先入本名单再使用,禁止裸字符串散落
142
+ * 当前版本不消费任何自有环境变量,保留空记录固化规范位
143
+ */
144
+ declare const ENV_KEYS: {};
145
+ //#endregion
146
+ //#region src/config-template.utils.d.ts
147
+ /**
148
+ * 配置文件模板渲染
149
+ *
150
+ * 为 `lzi-ledger init` 生成 `lzi-ledger.config.ts` 存根
151
+ * 存根只携带注释指引与空骨架,阈值一律沿用默认值
152
+ */
153
+ /**
154
+ * 配置模板参数
155
+ */
156
+ type LziLedgerConfigTemplateParams = {
157
+ /**
158
+ * 是否带豁免示例注释
159
+ *
160
+ * @default false
161
+ */
162
+ withExemptionExamples?: boolean;
163
+ };
164
+ /**
165
+ * 渲染 lzi-ledger 配置文件模板
166
+ *
167
+ * @param params - 模板参数,控制是否附带豁免示例注释
168
+ * @returns 配置文件全文
169
+ */
170
+ declare const renderLziLedgerConfigTemplate: (params?: LziLedgerConfigTemplateParams) => string;
171
+ //#endregion
172
+ //#region src/load.config.d.ts
173
+ /**
174
+ * 配置来源
175
+ */
176
+ type LziLedgerConfigSource = 'standalone' | 'unified';
177
+ /**
178
+ * 配置加载结果
179
+ */
180
+ type LziLedgerConfigResult = {
181
+ /**
182
+ * 加载后的 LziLedger 配置对象
183
+ */
184
+ config: Partial<LziLedgerConfig>;
185
+ /**
186
+ * 命中的配置文件绝对路径
187
+ */
188
+ configFilePath: string;
189
+ /**
190
+ * 配置来源,standalone 专属文件或 unified 统一配置字段
191
+ */
192
+ source: LziLedgerConfigSource;
193
+ };
194
+ /**
195
+ * 查找配置文件路径
196
+ *
197
+ * 从起点目录向上查找 `lzi-ledger.config.ts`
198
+ *
199
+ * @param cwd - 查找起点目录,缺省为当前工作目录
200
+ * @returns 配置文件的绝对路径,未找到时返回 null
201
+ */
202
+ declare const findLziLedgerConfigFile: (cwd?: string) => string | null;
203
+ /**
204
+ * 加载 LziLedger 配置
205
+ *
206
+ * shared-config 标准组合,standalone 优先,unified 兜底,整配置生效不做字段级合并
207
+ * 调用方负责对返回的局部配置做缺省填充
208
+ *
209
+ * @param cwd - 查找起点目录,缺省为当前工作目录
210
+ * @returns 配置加载结果,两种形态均未命中时返回 null
211
+ * @throws {@link Error} 当配置文件存在但动态加载或解析失败时,由 loadUnifiedConfig 透传
212
+ */
213
+ declare const loadLziLedgerConfig: (cwd?: string) => Promise<LziLedgerConfigResult | null>;
214
+ //#endregion
215
+ export { DEFAULT_LEDGERS_ROOT, DEFAULT_STATUS_VOCABULARY, ENV_KEYS, type LedgerExemptions, type LedgerThresholds, type LziLedgerConfig, type LziLedgerConfigResult, type LziLedgerConfigSource, type LziLedgerConfigTemplateParams, STANDALONE_CONFIG_FILE, UNIFIED_CONFIG_FIELD, defineConfig, findLziLedgerConfigFile, loadLziLedgerConfig, renderLziLedgerConfigTemplate };
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import{loadUnifiedConfig as e,resolveStandaloneConfigPath as t}from"@longzai-intelligence-shared-config/core";const n=(e={})=>({ledgersRoot:e.ledgersRoot??`docs/ledgers`,thresholds:e.thresholds??{},exemptions:{sizeExemptGlobs:e.exemptions?.sizeExemptGlobs??[],tmpPathAllowGlobs:e.exemptions?.tmpPathAllowGlobs??[],hashExemptGlobs:e.exemptions?.hashExemptGlobs??[]},extraStatusVocabulary:e.extraStatusVocabulary??[]}),r=`lzi-ledger.config.ts`,i=`ledger`,a=`docs/ledgers`,o=[`待建档`,`待启动`,`进行中`,`已收口`,`不适用`],s={},c=(e={})=>`import { defineConfig } from '@longzai-intelligence-ledger/config';
2
+
3
+ /**
4
+ * lzi-ledger 台账形态门禁配置
5
+ *
6
+ * 量化口径正源为台账族 README,本文件只做阈值覆写与豁免声明
7
+ * 阈值默认值为单行 400 字符,工作流档 100 行且 16000 字节
8
+ */
9
+ export default defineConfig({
10
+ ${e.withExemptionExamples===!0?` exemptions: {
11
+ // 体量豁免,并档承袭档原账全文迁入者适用,行宽与链接规则仍生效
12
+ sizeExemptGlobs: [],
13
+ // 临时路径豁免,引述 gitignore 模式枚举的正档案适用
14
+ tmpPathAllowGlobs: [],
15
+ },
16
+ `:``}});
17
+ `,l=e=>t(r,e),u=async t=>{let n=await e({standaloneFile:r,unifiedField:i,cwd:t});return n.success?{config:n.config,configFilePath:n.configFilePath,source:n.source}:null};export{a as DEFAULT_LEDGERS_ROOT,o as DEFAULT_STATUS_VOCABULARY,s as ENV_KEYS,r as STANDALONE_CONFIG_FILE,i as UNIFIED_CONFIG_FIELD,n as defineConfig,l as findLziLedgerConfigFile,u as loadLziLedgerConfig,c as renderLziLedgerConfigTemplate};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@longzai-intelligence-ledger/config",
3
+ "version": "0.0.1",
4
+ "description": "Longzai Intelligence Ledger 配置",
5
+ "keywords": [
6
+ "config",
7
+ "ledger",
8
+ "longzai-intelligence",
9
+ "schema"
10
+ ],
11
+ "license": "UNLICENSED",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "type": "module",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "lzi-builder",
26
+ "build:prod": "NODE_ENV=production bun run build",
27
+ "prepublishOnly": "bun run build:prod",
28
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
29
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
30
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
31
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
32
+ "lint": "oxlint && oxfmt --check",
33
+ "lint:fix": "oxlint --fix && oxfmt",
34
+ "test": "bun test",
35
+ "test:watch": "bun test --watch",
36
+ "test:coverage": "bun test --coverage",
37
+ "clean": "lzi-dev-cli clean"
38
+ },
39
+ "dependencies": {
40
+ "@longzai-intelligence-shared-config/core": "^0.0.7"
41
+ }
42
+ }