@longzai-intelligence-features/config 0.0.3 → 0.0.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/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import "./rolldown-runtime-BqT_7tdF.js";
2
1
  import * as z from "zod";
3
- //#region src/schema/lzi-features-config.schema.d.ts
4
2
  /**
5
3
  * scope key 合法形态,kebab-case
6
4
  */
@@ -100,7 +98,7 @@ declare function parseLziFeaturesConfig(input: unknown): LziFeaturesConfig;
100
98
  /**
101
99
  * 定义 lzi-features 配置,identity 工厂
102
100
  *
103
- * 类型透传,与 lzi-dev.config.ts 等 workspace 配置惯例同构:不在工厂层做任何
101
+ * 类型透传,与 lzi-dev-tools.config.ts 等 workspace 配置惯例同构:不在工厂层做任何
104
102
  * 合并,默认值由本模块 schema 解析层统一落定。无参调用即接入,缺省单 root
105
103
  * 注册面内置为程序侧参数——ADR 0113 开箱即用全局规定
106
104
  *
@@ -108,8 +106,6 @@ declare function parseLziFeaturesConfig(input: unknown): LziFeaturesConfig;
108
106
  * @returns 原样返回传入的配置对象
109
107
  */
110
108
  declare function defineConfig(config?: LziFeaturesConfigInput): LziFeaturesConfigInput;
111
- //#endregion
112
- //#region src/baseline/render-baseline.renderer.d.ts
113
109
  /**
114
110
  * 棘轮契约注释头,再生文件头
115
111
  */
@@ -129,8 +125,6 @@ declare function deriveBaselineEntries(entries: readonly CheckBaselineEntry[]):
129
125
  * @returns 完整配置文件文本,棘轮契约头加 defineConfig 体
130
126
  */
131
127
  declare function renderBaselineRegeneratedConfig(config: LziFeaturesConfig, baseline: readonly CheckBaselineEntry[]): string;
132
- //#endregion
133
- //#region src/loader/load-features-config.utils.d.ts
134
128
  /**
135
129
  * 配置来源类型
136
130
  */
@@ -202,8 +196,6 @@ declare function loadLziFeaturesConfig(options?: LoadLziFeaturesConfigOptions):
202
196
  * @throws {@link Error} 导入失败或无 default 导出
203
197
  */
204
198
  declare function importConfigModule(configPath: string): Promise<unknown>;
205
- //#endregion
206
- //#region src/scaffold/render-scaffold.renderer.d.ts
207
199
  /**
208
200
  * lzi-features 配置脚手架渲染,init 命令落盘
209
201
  *
@@ -234,8 +226,6 @@ type ConfigScaffoldInput = {
234
226
  * @returns 可直接落盘的配置文件全文
235
227
  */
236
228
  declare function renderConfigScaffold(input?: ConfigScaffoldInput): string;
237
- //#endregion
238
- //#region src/validation/validate-cross-entries.d.ts
239
229
  /**
240
230
  * 校验并透传配置,语义非法即抛,消息聚合全部违规项
241
231
  *
@@ -244,5 +234,4 @@ declare function renderConfigScaffold(input?: ConfigScaffoldInput): string;
244
234
  * @throws {@link Error} 跨条目语义违规
245
235
  */
246
236
  declare function validateLziFeaturesConfig(config: LziFeaturesConfig): LziFeaturesConfig;
247
- //#endregion
248
237
  export { CheckBaselineEntry, CheckExclusionEntry, ConfigScaffoldInput, DEFAULT_REGISTRY_DIR, DEFAULT_SCOPES, LoadLziFeaturesConfigFailure, LoadLziFeaturesConfigOptions, LoadLziFeaturesConfigResult, LoadLziFeaturesConfigSuccess, LziFeaturesConfig, LziFeaturesConfigInput, LziFeaturesConfigSource, RATCHET_CONTRACT_HEADER, SCOPE_KEY_PATTERN, ScopeEntry, ScopeEntryInput, baselineEntrySchema, defineConfig, deriveBaselineEntries, exclusionEntrySchema, importConfigModule, loadLziFeaturesConfig, lziFeaturesConfigSchema, parseLziFeaturesConfig, renderBaselineRegeneratedConfig, renderConfigScaffold, validateLziFeaturesConfig };
package/dist/index.js CHANGED
@@ -1,6 +1,18 @@
1
- import"./rolldown-runtime-BqT_7tdF.js";import*as e from"zod";import{loadUnifiedConfig as t}from"@longzai-intelligence-shared-config/core";import{existsSync as n}from"node:fs";import{resolve as r}from"node:path";import{pathToFileURL as i}from"node:url";const a=/^[a-z][a-z0-9-]*$/,o=`docs/features`,s=[{key:`root`,title:`全局`,paths:[`.`],registryDir:o}],c=e.strictObject({file:e.string().min(1),rule:e.string().min(1),reason:e.string().min(1)}),l=e.strictObject({path:e.string().min(1),reason:e.string().min(1)}),u=e.strictObject({key:e.string().regex(a),title:e.string().min(1),paths:e.array(e.string().min(1)).min(1),registryDir:e.string().min(1)}),d=e.strictObject({baseline:e.array(c).default([]),exclusions:e.array(l).default([])}),f=e.strictObject({scopes:e.array(u).min(1).default([...s]),check:d.default({baseline:[],exclusions:[]})});function p(e){let t=f.safeParse(e);if(!t.success){let e=t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`,`);throw Error(`lzi-features 配置形态非法:${e}`)}return t.data}function m(e={}){return e}const h=[`/**`," * lzi-features 配置,由 `--write-baseline --reason <理由>` 再生",` *`,` * 棘轮基线语义:基线按 file 与 rule 精确命中豁免存量违规,基线外新增违规仍红,`,` * 基线条目无对应现行违规计陈旧,修复存量即须同步删除对应条目,棘轮只许缩短直至清零,`,` * 每条豁免必须携带收编理由`,` *`,` * 注意:再生以解析值重建本文件,节内手工注释不保留,长篇说明请写入 docs 目录`,` */`].join(`
2
- `);function g(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=`${n.file}::${n.rule}`;t.has(e)||t.set(e,{...n})}return[...t.values()].sort((e,t)=>e.file===t.file?e.rule.localeCompare(t.rule):e.file.localeCompare(t.file))}function _(e,t){let n=JSON.stringify(e.scopes)===JSON.stringify(s),r=[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,...h.split(`
1
+ import"./rolldown-runtime-BqT_7tdF.js";import*as e from"zod";import{loadUnifiedConfig as t}from"@longzai-intelligence-shared-config/core";import{existsSync as n}from"node:fs";import{resolve as r}from"node:path";import{pathToFileURL as i}from"node:url";const a=/^[a-z][a-z0-9-]*$/,o=`docs/features`,s=[{key:`root`,title:`全局`,paths:[`.`],registryDir:o}],c=e.strictObject({file:e.string().min(1),rule:e.string().min(1),reason:e.string().min(1)}),l=e.strictObject({path:e.string().min(1),reason:e.string().min(1)}),u=e.strictObject({key:e.string().regex(a),title:e.string().min(1),paths:e.array(e.string().min(1)).min(1),registryDir:e.string().min(1)}),d=e.strictObject({baseline:e.array(c).default([]),exclusions:e.array(l).default([])}),f=e.strictObject({scopes:e.array(u).min(1).default([...s]),check:d.default({baseline:[],exclusions:[]})});function p(e){let t=f.safeParse(e);if(!t.success){let e=t.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`,`);throw Error(`lzi-features 配置形态非法:${e}`)}return t.data}function m(e={}){return e}const h=`/**
2
+ * lzi-features 配置,由 \`--write-baseline --reason <理由>\` 再生
3
+ *
4
+ * 棘轮基线语义:基线按 file 与 rule 精确命中豁免存量违规,基线外新增违规仍红,
5
+ * 基线条目无对应现行违规计陈旧,修复存量即须同步删除对应条目,棘轮只许缩短直至清零,
6
+ * 每条豁免必须携带收编理由
7
+ *
8
+ * 注意:再生以解析值重建本文件,节内手工注释不保留,长篇说明请写入 docs 目录
9
+ */`;function g(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=`${n.file}::${n.rule}`;t.has(e)||t.set(e,{...n})}return[...t.values()].sort((e,t)=>e.file===t.file?e.rule.localeCompare(t.rule):e.file.localeCompare(t.file))}function _(e,t){let n=JSON.stringify(e.scopes)===JSON.stringify(s),r=[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,...h.split(`
3
10
  `),`export default defineConfig({`];if(!n){r.push(` scopes: [`);for(let t of e.scopes){let e=t.paths.map(e=>`'${e}'`).join(`, `);r.push(` { key: '${t.key}', title: '${t.title}', paths: [${e}], registryDir: '${t.registryDir}' },`)}r.push(` ],`)}r.push(` check: {`,` baseline: [`);for(let e of t)r.push(` { file: '${e.file}', rule: '${e.rule}', reason: '${e.reason}' },`);r.push(` ],`,` exclusions: [`);for(let t of e.check.exclusions)r.push(` { path: '${t.path}', reason: '${t.reason}' },`);return r.push(` ],`,` },`,`});`,``),r.join(`
4
- `)}function v(e){let t=[],n=/* @__PURE__ */ new Map;for(let t of e.scopes)n.set(t.key,(n.get(t.key)??0)+1);for(let[e,r]of n)r>1&&t.push(`scopes: key「${e}」重复登记 ${r} 次,scope key 必须唯一`);let r=/* @__PURE__ */ new Map;for(let t of e.scopes){let e=r.get(t.registryDir)??[];e.push(t.key),r.set(t.registryDir,e)}for(let[e,n]of r)n.length>1&&t.push(`scopes: 注册表目录「${e}」被 ${n.join(`、`)} 共用,一目录一 scope,否则识别与 lint 歧义`);for(let n of e.check.baseline)e.scopes.some(e=>n.file===e.registryDir||n.file.startsWith(`${e.registryDir}/`))||t.push(`check.baseline: 豁免条目「${n.file}」规则 ${n.rule} 不在任何 scope 注册表目录内`);let i=/* @__PURE__ */ new Map;for(let t of e.check.exclusions)i.set(t.path,(i.get(t.path)??0)+1);for(let[e,n]of i)n>1&&t.push(`check.exclusions: 排除路径「${e}」重复登记 ${n} 次`);for(let n of e.check.exclusions)e.scopes.some(e=>n.path===e.registryDir||n.path.startsWith(`${e.registryDir}/`))||t.push(`check.exclusions: 排除条目「${n.path}」不在任何 scope 注册表目录内`);if(t.length>0)throw Error(`lzi-features 配置跨条目语义非法:${t.join(`,`)}`);return e}function y(e,t){try{return v(p(e))}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`${n},配置文件:${t}`)}}async function b(e={}){if(e.configPath!==void 0){let t=r(e.cwd??process.cwd(),e.configPath);return n(t)?{ok:!0,config:y(await x(t),t),configFilePath:t,source:`explicit`}:{ok:!1,reason:`未找到配置文件:${t}`}}let i=await t({standaloneFile:`lzi-features.config.ts`,unifiedField:`features`,cwd:e.cwd});return i.success?{ok:!0,config:y(i.config,i.configFilePath),configFilePath:i.configFilePath,source:i.source}:{ok:!1,reason:`未找到 lzi-features.config.ts,且 lzi.config.ts 无 features 字段,可先执行 lzi-features init`}}async function x(e){let t=await import(i(e).href);if(t.default===void 0)throw Error(`配置文件缺少 default 导出:${e}`);return t.default}function S(e){return e===void 0?[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,`/**`,` * lzi-features 配置`,` */`,`export default defineConfig();`,``].join(`
5
- `):[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,`/**`,` * lzi-features 配置`,` */`,`export default defineConfig({`,` scopes: [`,` { key: '${e.scopeKey}', title: '${e.scopeTitle}', paths: ['.'], registryDir: '${e.registryDir}' },`,` ],`,`});`,``].join(`
11
+ `)}function v(e){let t=[],n=/* @__PURE__ */ new Map;for(let t of e.scopes)n.set(t.key,(n.get(t.key)??0)+1);for(let[e,r]of n)r>1&&t.push(`scopes: key「${e}」重复登记 ${r} 次,scope key 必须唯一`);let r=/* @__PURE__ */ new Map;for(let t of e.scopes){let e=r.get(t.registryDir)??[];e.push(t.key),r.set(t.registryDir,e)}for(let[e,n]of r)n.length>1&&t.push(`scopes: 注册表目录「${e}」被 ${n.join(`、`)} 共用,一目录一 scope,否则识别与 lint 歧义`);for(let n of e.check.baseline)e.scopes.some(e=>n.file===e.registryDir||n.file.startsWith(`${e.registryDir}/`))||t.push(`check.baseline: 豁免条目「${n.file}」规则 ${n.rule} 不在任何 scope 注册表目录内`);let i=/* @__PURE__ */ new Map;for(let t of e.check.exclusions)i.set(t.path,(i.get(t.path)??0)+1);for(let[e,n]of i)n>1&&t.push(`check.exclusions: 排除路径「${e}」重复登记 ${n} 次`);for(let n of e.check.exclusions)e.scopes.some(e=>n.path===e.registryDir||n.path.startsWith(`${e.registryDir}/`))||t.push(`check.exclusions: 排除条目「${n.path}」不在任何 scope 注册表目录内`);if(t.length>0)throw Error(`lzi-features 配置跨条目语义非法:${t.join(`,`)}`);return e}function y(e,t){try{return v(p(e))}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`${n},配置文件:${t}`)}}async function b(e={}){if(e.configPath!==void 0){let t=r(e.cwd??process.cwd(),e.configPath);return n(t)?{ok:!0,config:y(await x(t),t),configFilePath:t,source:`explicit`}:{ok:!1,reason:`未找到配置文件:${t}`}}let i=await t({standaloneFile:`lzi-features.config.ts`,unifiedField:`features`,cwd:e.cwd});return i.success?{ok:!0,config:y(i.config,i.configFilePath),configFilePath:i.configFilePath,source:i.source}:{ok:!1,reason:`未找到 lzi-features.config.ts,且 lzi.config.ts 无 features 字段,可先执行 lzi-features init`}}async function x(e){let t=await import(i(e).href);if(t.default===void 0)throw Error(`配置文件缺少 default 导出:${e}`);return t.default}function S(e){return e===void 0?`import { defineConfig } from '@longzai-intelligence-features/config';
12
+
13
+ /**
14
+ * lzi-features 配置
15
+ */
16
+ export default defineConfig();
17
+ `:[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,`/**`,` * lzi-features 配置`,` */`,`export default defineConfig({`,` scopes: [`,` { key: '${e.scopeKey}', title: '${e.scopeTitle}', paths: ['.'], registryDir: '${e.registryDir}' },`,` ],`,`});`,``].join(`
6
18
  `)}export{o as DEFAULT_REGISTRY_DIR,s as DEFAULT_SCOPES,h as RATCHET_CONTRACT_HEADER,a as SCOPE_KEY_PATTERN,c as baselineEntrySchema,m as defineConfig,g as deriveBaselineEntries,l as exclusionEntrySchema,x as importConfigModule,b as loadLziFeaturesConfig,f as lziFeaturesConfigSchema,p as parseLziFeaturesConfig,_ as renderBaselineRegeneratedConfig,S as renderConfigScaffold,v as validateLziFeaturesConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-features/config",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"
@@ -18,12 +18,9 @@
18
18
  "build": "lzi-builder",
19
19
  "build:prod": "NODE_ENV=production bun run build",
20
20
  "prepublishOnly": "bun run build:prod",
21
- "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
22
- "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
23
- "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
24
- "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
25
- "lint": "oxlint && oxfmt --check",
26
- "lint:fix": "oxlint --fix && oxfmt",
21
+ "typecheck": "lzi-typecheck",
22
+ "lint": "lzi-lint lint",
23
+ "lint:fix": "lzi-lint fix",
27
24
  "test": "bun test",
28
25
  "test:watch": "bun test --watch",
29
26
  "test:coverage": "bun test --coverage"
@@ -31,8 +28,5 @@
31
28
  "dependencies": {
32
29
  "@longzai-intelligence-shared-config/core": "^0.0.5",
33
30
  "zod": "^4.4.3"
34
- },
35
- "devDependencies": {
36
- "@types/bun": "latest"
37
31
  }
38
32
  }