@nudojs/service 1.0.0 → 1.1.0

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.
@@ -0,0 +1,114 @@
1
+ type NudoConfig = {
2
+ env?: string[];
3
+ mocks?: Record<string, string>;
4
+ contract?: {
5
+ /** 侧车 ambient 绑定总开关(check/LSP 执法与 contract 打印共用) */
6
+ autoBind?: boolean;
7
+ /**
8
+ * emit 白名单(Phase 3,§7.3):glob 数组,相对 projectDir。
9
+ * 省略/空 = 不按路径过滤(仍受 --fn/--all 与「默认只刷已有生成段」约束)。
10
+ */
11
+ emit?: string[] | string;
12
+ };
13
+ /** 分析范围与噪声档(design-cli-semantics.md §7) */
14
+ analysis?: {
15
+ include?: string[] | string;
16
+ exclude?: string[] | string;
17
+ /** directives | exports(默认)| all */
18
+ mode?: string;
19
+ /** off | errors | default | verbose */
20
+ diagnostics?: string;
21
+ /** polyvariant:保留的精确调用点 case 上限(默认 3);超出进 symbolic #widened */
22
+ callSiteBudget?: number;
23
+ /** C0.5:求值命中闭对象缺字段 → nudo:missing-slot;默认 off */
24
+ evalMissingSlot?: "off" | "warning";
25
+ /**
26
+ * B $fork 总次数上限(默认 5000)。env `NUDO_MAX_FORKS` 优先。
27
+ * n≥1 有限整数;非法值回默认。启动时 set 进 core(setBForkBudgetLimit)。
28
+ */
29
+ maxForks?: number;
30
+ };
31
+ /** 磁盘缓存(B3):true → `.nudo/cache`;字符串 → 自定义根;false/省略 → 关 */
32
+ cache?: boolean | string;
33
+ /**
34
+ * 进程内会话 LRU 上限(内存/速度权衡)。多项目开 IDE 时调低封顶;
35
+ * 单大仓 warm 命中可调高。0 = 关闭该层。env `NUDO_CACHE_MAX_*` 优先。
36
+ */
37
+ sessionCache?: {
38
+ maxFiles?: number;
39
+ maxFns?: number;
40
+ maxBRuns?: number;
41
+ };
42
+ /** check 门禁(design-cli-semantics §3) */
43
+ check?: {
44
+ /** L2 入口 may-throw:error | warning | off(默认 error) */
45
+ entryThrows?: "error" | "warning" | "off";
46
+ /** L2 --ignore-throws 类型名列表 */
47
+ ignoreThrows?: string[];
48
+ };
49
+ };
50
+ type InterfaceConfig = {
51
+ autoBind: boolean;
52
+ /** emit 路径白名单(已归一化;空数组 = 不限制) */
53
+ emit: string[];
54
+ };
55
+ type AnalysisMode = "directives" | "exports" | "all";
56
+ type DiagnosticsLevel = "off" | "errors" | "default" | "verbose";
57
+ type AnalysisConfig = {
58
+ include: string[];
59
+ exclude: string[];
60
+ mode: AnalysisMode;
61
+ diagnostics: DiagnosticsLevel;
62
+ /** polyvariant 精确调用点上限(B4) */
63
+ callSiteBudget: number;
64
+ /** C0.5 evaluation-driven missing-slot;默认 off */
65
+ evalMissingSlot: "off" | "warning";
66
+ /** B $fork 总次数上限(已归一化;非法值回 core 默认) */
67
+ maxForks: number;
68
+ };
69
+ type CheckConfig = {
70
+ /** L2 入口 may-throw 执法档;默认 error */
71
+ entryThrows: "error" | "warning" | "off";
72
+ /** L2 ignoreThrows 类型名;默认空 */
73
+ ignoreThrows: string[];
74
+ };
75
+ /** package.json#nudo.check → 执法选项 */
76
+ declare function checkConfig(config: NudoConfig | null | undefined): CheckConfig;
77
+ /** A1 产品默认:exports — 普通带导出的 .js 进 IDE;directives/all 需显式 */
78
+ declare const DEFAULT_ANALYSIS_MODE: AnalysisMode;
79
+ /**
80
+ * 归一化 `nudo.analysis`。默认 mode=exports(A1:无指令但有 export/侧车的文件
81
+ * 进 IDE 分析;`all` / `directives` 需显式配置)。
82
+ * diagnostics:directives→errors,exports/all→default。
83
+ * include 空 = 不按路径过滤(isNudoTargetPath 已管扩展名)。
84
+ */
85
+ declare function analysisConfig(config: NudoConfig | null | undefined): AnalysisConfig;
86
+ /**
87
+ * 把 fork 预算写进 core(core 保持无 IO)。
88
+ * 优先级:env `NUDO_MAX_FORKS` > `package.json#nudo.analysis.maxForks` > 默认 5000。
89
+ * 约定:n≥1 有限整数;非法值回默认。返回实际生效值。
90
+ * 由 findProjectConfig / 宿主启动时调用(与 setSessionCacheFromProject 同时机)。
91
+ */
92
+ declare function applyBForkBudgetFromConfig(config: NudoConfig | null | undefined, env?: NodeJS.ProcessEnv): number;
93
+ /** 当前生效 fork 上限(调试/测试;与 core getBForkBudgetLimit 同源) */
94
+ declare function currentBForkBudgetLimit(): number;
95
+ /** 磁盘缓存根(B3):config.cache / NUDO_CACHE_DIR / 默认关 */
96
+ declare function diskCacheRoot(config: NudoConfig | null | undefined, projectDir: string | undefined): string | undefined;
97
+ /**
98
+ * 归一化 `nudo.contract` 配置段。
99
+ * - autoBind 默认 true
100
+ * - emit:string | string[] → string[](空 = 不限制路径)
101
+ */
102
+ declare function interfaceConfig(config: NudoConfig | null | undefined): InterfaceConfig;
103
+ /**
104
+ * 极简 glob(`**` / `*` / `?`):相对 projectDir 匹配**源文件**绝对路径
105
+ * (不是侧车路径;侧车随源文件同目录写出)。无白名单 → true。
106
+ * 路径分隔符归一为 `/`。
107
+ */
108
+ declare function matchesEmitAllowlist(absPath: string, projectDir: string | undefined, patterns: string[]): boolean;
109
+ declare function findProjectConfig(startDir: string): {
110
+ config: NudoConfig;
111
+ projectDir: string;
112
+ } | null;
113
+
114
+ export { type AnalysisConfig as A, type CheckConfig as C, type DiagnosticsLevel as D, type InterfaceConfig as I, type NudoConfig as N, type AnalysisMode as a, analysisConfig as b, checkConfig as c, diskCacheRoot as d, DEFAULT_ANALYSIS_MODE as e, findProjectConfig as f, applyBForkBudgetFromConfig as g, currentBForkBudgetLimit as h, interfaceConfig as i, matchesEmitAllowlist as m };