@longzai-intelligence-features/config 0.0.4 → 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,5 +1,4 @@
1
1
  import * as z from "zod";
2
- //#region src/schema/lzi-features-config.schema.d.ts
3
2
  /**
4
3
  * scope key 合法形态,kebab-case
5
4
  */
@@ -107,8 +106,6 @@ declare function parseLziFeaturesConfig(input: unknown): LziFeaturesConfig;
107
106
  * @returns 原样返回传入的配置对象
108
107
  */
109
108
  declare function defineConfig(config?: LziFeaturesConfigInput): LziFeaturesConfigInput;
110
- //#endregion
111
- //#region src/baseline/render-baseline.renderer.d.ts
112
109
  /**
113
110
  * 棘轮契约注释头,再生文件头
114
111
  */
@@ -128,8 +125,6 @@ declare function deriveBaselineEntries(entries: readonly CheckBaselineEntry[]):
128
125
  * @returns 完整配置文件文本,棘轮契约头加 defineConfig 体
129
126
  */
130
127
  declare function renderBaselineRegeneratedConfig(config: LziFeaturesConfig, baseline: readonly CheckBaselineEntry[]): string;
131
- //#endregion
132
- //#region src/loader/load-features-config.utils.d.ts
133
128
  /**
134
129
  * 配置来源类型
135
130
  */
@@ -201,8 +196,6 @@ declare function loadLziFeaturesConfig(options?: LoadLziFeaturesConfigOptions):
201
196
  * @throws {@link Error} 导入失败或无 default 导出
202
197
  */
203
198
  declare function importConfigModule(configPath: string): Promise<unknown>;
204
- //#endregion
205
- //#region src/scaffold/render-scaffold.renderer.d.ts
206
199
  /**
207
200
  * lzi-features 配置脚手架渲染,init 命令落盘
208
201
  *
@@ -233,8 +226,6 @@ type ConfigScaffoldInput = {
233
226
  * @returns 可直接落盘的配置文件全文
234
227
  */
235
228
  declare function renderConfigScaffold(input?: ConfigScaffoldInput): string;
236
- //#endregion
237
- //#region src/validation/validate-cross-entries.d.ts
238
229
  /**
239
230
  * 校验并透传配置,语义非法即抛,消息聚合全部违规项
240
231
  *
@@ -243,5 +234,4 @@ declare function renderConfigScaffold(input?: ConfigScaffoldInput): string;
243
234
  * @throws {@link Error} 跨条目语义违规
244
235
  */
245
236
  declare function validateLziFeaturesConfig(config: LziFeaturesConfig): LziFeaturesConfig;
246
- //#endregion
247
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.4",
3
+ "version": "0.0.5",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"