@longzai-intelligence-features/config 0.0.1 → 0.0.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/dist/index.d.ts CHANGED
@@ -9,6 +9,15 @@ declare const SCOPE_KEY_PATTERN: RegExp;
9
9
  * init 缺省注册表目录
10
10
  */
11
11
  declare const DEFAULT_REGISTRY_DIR = "docs/features";
12
+ /**
13
+ * 缺省单 root 注册面,开箱即用正形——ADR 0113 全局规定
14
+ *
15
+ * @remarks
16
+ * defineConfig 无参调用即接入,缺省零参数。无信息增量的单 root 注册面
17
+ * 内置为程序侧参数,显性化到配置文件违反开箱即用,仅真实信息增量的
18
+ * 配置项才显式填写
19
+ */
20
+ declare const DEFAULT_SCOPES: readonly ScopeEntry[];
12
21
  /**
13
22
  * 棘轮基线条目 schema,存量豁免逐条带理由登记——存量不追溯,豁免只许缩短
14
23
  */
@@ -45,12 +54,12 @@ type ScopeEntry = z.output<typeof scopeSchema>;
45
54
  * lzi-features 配置根 schema
46
55
  */
47
56
  declare const lziFeaturesConfigSchema: z.ZodObject<{
48
- scopes: z.ZodArray<z.ZodObject<{
57
+ scopes: z.ZodDefault<z.ZodArray<z.ZodObject<{
49
58
  key: z.ZodString;
50
59
  title: z.ZodString;
51
60
  paths: z.ZodArray<z.ZodString>;
52
61
  registryDir: z.ZodString;
53
- }, z.core.$strict>>;
62
+ }, z.core.$strict>>>;
54
63
  check: z.ZodDefault<z.ZodObject<{
55
64
  baseline: z.ZodDefault<z.ZodArray<z.ZodObject<{
56
65
  file: z.ZodString;
@@ -64,7 +73,7 @@ declare const lziFeaturesConfigSchema: z.ZodObject<{
64
73
  }, z.core.$strict>>;
65
74
  }, z.core.$strict>;
66
75
  /**
67
- * lzi-features 配置,用户书写形态,可省略各默认值
76
+ * lzi-features 配置,用户书写形态,可省略各默认值,无参即接入
68
77
  */
69
78
  type LziFeaturesConfigInput = z.input<typeof lziFeaturesConfigSchema>;
70
79
  /**
@@ -92,12 +101,13 @@ declare function parseLziFeaturesConfig(input: unknown): LziFeaturesConfig;
92
101
  * 定义 lzi-features 配置,identity 工厂
93
102
  *
94
103
  * 类型透传,与 lzi-dev.config.ts 等 workspace 配置惯例同构:不在工厂层做任何
95
- * 合并,默认值由本模块 schema 解析层统一落定
104
+ * 合并,默认值由本模块 schema 解析层统一落定。无参调用即接入,缺省单 root
105
+ * 注册面内置为程序侧参数——ADR 0113 开箱即用全局规定
96
106
  *
97
- * @param config - 配置对象,可省略各默认值
107
+ * @param config - 配置对象,可省略,可省略各默认值
98
108
  * @returns 原样返回传入的配置对象
99
109
  */
100
- declare function defineConfig(config: LziFeaturesConfigInput): LziFeaturesConfigInput;
110
+ declare function defineConfig(config?: LziFeaturesConfigInput): LziFeaturesConfigInput;
101
111
  //#endregion
102
112
  //#region src/baseline/render-baseline.renderer.d.ts
103
113
  /**
@@ -197,7 +207,8 @@ declare function importConfigModule(configPath: string): Promise<unknown>;
197
207
  /**
198
208
  * lzi-features 配置脚手架渲染,init 命令落盘
199
209
  *
200
- * 渲染 lzi-features.config.ts 全文,单 scope 起步形态,幂等不覆盖由命令层守卫
210
+ * 正形为 defineConfig 无参调用——ADR 0113 开箱即用全局规定。旗标未显式给定时
211
+ * 渲染无参形态,显式给定时渲染单 scope 显式形态,幂等不覆盖由命令层守卫
201
212
  */
202
213
  /**
203
214
  * 脚手架渲染入参
@@ -219,10 +230,10 @@ type ConfigScaffoldInput = {
219
230
  /**
220
231
  * 渲染 lzi-features.config.ts 脚手架全文
221
232
  *
222
- * @param input - 脚手架入参
233
+ * @param input - 脚手架入参,缺省渲染无参正形
223
234
  * @returns 可直接落盘的配置文件全文
224
235
  */
225
- declare function renderConfigScaffold(input: ConfigScaffoldInput): string;
236
+ declare function renderConfigScaffold(input?: ConfigScaffoldInput): string;
226
237
  //#endregion
227
238
  //#region src/validation/validate-cross-entries.d.ts
228
239
  /**
@@ -234,4 +245,4 @@ declare function renderConfigScaffold(input: ConfigScaffoldInput): string;
234
245
  */
235
246
  declare function validateLziFeaturesConfig(config: LziFeaturesConfig): LziFeaturesConfig;
236
247
  //#endregion
237
- export { CheckBaselineEntry, CheckExclusionEntry, ConfigScaffoldInput, DEFAULT_REGISTRY_DIR, 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 };
248
+ 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,5 +1,6 @@
1
- import"./rolldown-runtime-BqT_7tdF.js";import{loadUnifiedConfig as e}from"@longzai-intelligence-shared-config/core";import{existsSync as t}from"node:fs";import{resolve as n}from"node:path";import{pathToFileURL as r}from"node:url";import*as i from"zod";const a=[`/**`," * lzi-features 配置,由 `--write-baseline --reason <理由>` 再生",` *`,` * 棘轮基线语义:基线按 file 与 rule 精确命中豁免存量违规,基线外新增违规仍红,`,` * 基线条目无对应现行违规计陈旧,修复存量即须同步删除对应条目,棘轮只许缩短直至清零,`,` * 每条豁免必须携带收编理由`,` *`,` * 注意:再生以解析值重建本文件,节内手工注释不保留,长篇说明请写入 docs 目录`,` */`].join(`
2
- `);function o(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 s(e,t){let n=[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,...a.split(`
3
- `),`export default defineConfig({`,` scopes: [`];for(let t of e.scopes){let e=t.paths.map(e=>`'${e}'`).join(`, `);n.push(` { key: '${t.key}', title: '${t.title}', paths: [${e}], registryDir: '${t.registryDir}' },`)}n.push(` ],`,` check: {`,` baseline: [`);for(let e of t)n.push(` { file: '${e.file}', rule: '${e.rule}', reason: '${e.reason}' },`);n.push(` ],`,` exclusions: [`);for(let t of e.check.exclusions)n.push(` { path: '${t.path}', reason: '${t.reason}' },`);return n.push(` ],`,` },`,`});`,``),n.join(`
4
- `)}const c=/^[a-z][a-z0-9-]*$/,l=`docs/features`,u=i.strictObject({file:i.string().min(1),rule:i.string().min(1),reason:i.string().min(1)}),d=i.strictObject({path:i.string().min(1),reason:i.string().min(1)}),f=i.strictObject({key:i.string().regex(c),title:i.string().min(1),paths:i.array(i.string().min(1)).min(1),registryDir:i.string().min(1)}),p=i.strictObject({baseline:i.array(u).default([]),exclusions:i.array(d).default([])}),m=i.strictObject({scopes:i.array(f).min(1),check:p.default({baseline:[],exclusions:[]})});function h(e){let t=m.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 g(e){return e}function _(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 v(e,t){try{return _(h(e))}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`${n},配置文件:${t}`)}}async function y(r={}){if(r.configPath!==void 0){let e=n(r.cwd??process.cwd(),r.configPath);return t(e)?{ok:!0,config:v(await b(e),e),configFilePath:e,source:`explicit`}:{ok:!1,reason:`未找到配置文件:${e}`}}let i=await e({standaloneFile:`lzi-features.config.ts`,unifiedField:`features`,cwd:r.cwd});return i.success?{ok:!0,config:v(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 b(e){let t=await import(r(e).href);if(t.default===void 0)throw Error(`配置文件缺少 default 导出:${e}`);return t.default}function x(e){return[`import { defineConfig } from '@longzai-intelligence-features/config';`,``,`/**`,` * lzi-features 配置`,` */`,`export default defineConfig({`,` scopes: [`,` { key: '${e.scopeKey}', title: '${e.scopeTitle}', paths: ['.'], registryDir: '${e.registryDir}' },`,` ],`,`});`,``].join(`
5
- `)}export{l as DEFAULT_REGISTRY_DIR,a as RATCHET_CONTRACT_HEADER,c as SCOPE_KEY_PATTERN,u as baselineEntrySchema,g as defineConfig,o as deriveBaselineEntries,d as exclusionEntrySchema,b as importConfigModule,y as loadLziFeaturesConfig,m as lziFeaturesConfigSchema,h as parseLziFeaturesConfig,s as renderBaselineRegeneratedConfig,x as renderConfigScaffold,_ as validateLziFeaturesConfig};
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(`
3
+ `),`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(`
6
+ `)}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.1",
3
+ "version": "0.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"