@nudojs/service 1.0.0 → 1.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/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Node, File } from '@babel/types';
2
- import { TypeValue, Abs, PolyFn, AbsModuleExports, AstEnv, Phi, BMemberDiag, BCallRecord, TranspiledCallResult } from '@nudojs/core';
2
+ import { Abs, PolyFn, AbsModuleExports, AstEnv, Phi, BMemberDiag, BCallRecord, TranspiledCallResult, NudoConstraint } from '@nudojs/core';
3
3
  export { AbsInlay, BMemberDiag, collectAbsInlays } from '@nudojs/core';
4
- import { C as CallRecord } from './config-UlReSTfh.js';
5
- export { I as InterfaceConfig, N as NudoConfig, f as findProjectConfig, i as interfaceConfig } from './config-UlReSTfh.js';
4
+ import { C as CallRecord } from './config-NqDRWWpn.js';
5
+ export { I as InterfaceConfig, N as NudoConfig, f as findProjectConfig, i as interfaceConfig, m as matchesEmitAllowlist } from './config-NqDRWWpn.js';
6
6
  import { HarvestedEnv } from '@nudojs/harvester';
7
7
  import { FunctionWithDirectives } from '@nudojs/parser';
8
8
 
@@ -46,18 +46,20 @@ type Diagnostic = {
46
46
  };
47
47
  type CaseResult = {
48
48
  name: string;
49
- args: TypeValue[];
50
- result: TypeValue;
51
- throws: TypeValue;
49
+ /** 无损参数 Abs */
50
+ argAbs: Abs[];
51
+ /** 无损结果 Abs */
52
+ abs: Abs;
53
+ /** 无损抛出 Abs(未抛为 never) */
54
+ throwsAbs: Abs;
52
55
  throwLoc?: SourceLocation;
53
56
  source?: "directive" | "callsite";
54
57
  /** `@nudo:case "name" (…) => expected` — presence means the case is a test assertion */
55
- expected?: TypeValue;
58
+ expected?: Abs;
56
59
  /** number of additional call sites folded into a symbolic case */
57
60
  aggregatedFrom?: number;
58
61
  /**
59
62
  * 内涵摘要(代数 generalize):无损 Abs + term/pred/conf。
60
- * 仅在 entry@ / call@(Abs 路径)填充;外延 TypeValue 不变。
61
63
  */
62
64
  intension?: {
63
65
  display?: string;
@@ -69,15 +71,14 @@ type CaseResult = {
69
71
  /** 无损 Abs 多行(formatAbsMultiline) */
70
72
  absMultiline?: string;
71
73
  };
72
- /** 无损 Abs(denote/守卫用);仅 Abs 路径 case 填充 */
73
- abs?: Abs;
74
74
  };
75
75
  type FunctionAnalysis = {
76
76
  name: string;
77
77
  loc: SourceLocation;
78
78
  paramNames: string[];
79
79
  cases: CaseResult[];
80
- combined?: TypeValue;
80
+ /** cases 结果 Abs 的 join;dts 返回位源 */
81
+ combinedAbs?: Abs;
81
82
  entryOnly?: boolean;
82
83
  skipped?: boolean;
83
84
  /**
@@ -91,7 +92,8 @@ type FunctionAnalysis = {
91
92
  fromModule?: string;
92
93
  };
93
94
  type BindingInfo = {
94
- type: TypeValue;
95
+ /** 无损 Abs */
96
+ abs: Abs;
95
97
  loc?: SourceLocation;
96
98
  };
97
99
  type CaseHint = {
@@ -109,7 +111,8 @@ type AnalysisResult = {
109
111
  * the original — lookups must use the File that produced this result, not a
110
112
  * freshly parsed one. getTypeAtPosition rebuilds its own map and is unaffected.
111
113
  */
112
- nodeTypeMap: Map<Node, TypeValue>;
114
+ /** 无损节点 Abs */
115
+ nodeAbsMap: Map<Node, Abs>;
113
116
  caseHints: CaseHint[];
114
117
  /** functions imported from other modules, synthesized from cross-file call sites observed while analyzing this file */
115
118
  externalFunctions?: FunctionAnalysis[];
@@ -163,6 +166,7 @@ declare function analyzeFileAsync(filePath: string, source: string, activeCases?
163
166
  * 真实的实参类型与结果类型——后续 analyzeFile 将其注入合成 case,
164
167
  * 使被使用方从 entry-only(参数全 unknown)升级为真实调用形态。
165
168
  *
169
+ * Abs 路径(TypeValue evaluateProgram 已删):evalProgramAbs + AbsCallRecord。
166
170
  * 只做求值与记录,不产出诊断;求值异常不抛出(使用现场文件可能
167
171
  * 依赖未 mock 的全局,收集不到就收集不到,不能拖垮主分析)。
168
172
  */
@@ -192,10 +196,17 @@ declare function getCasesForFile(filePath: string, source: string): {
192
196
  loc: SourceLocation;
193
197
  }[];
194
198
  /** Async entry to getTypeAtPosition with path-env preloading (see analyzeFileAsync). */
195
- declare function getTypeAtPositionAsync(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Promise<TypeValue | null>;
196
- declare function getTypeAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): TypeValue | null;
199
+ declare function getTypeAtPositionAsync(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Promise<Abs | null>;
200
+ /** Async entry to getAbsAtPosition(与 getTypeAtPositionAsync 同预加载口径) */
201
+ declare function getAbsAtPositionAsync(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Promise<Abs | null>;
202
+ /**
203
+ * 光标处无损 Abs。B-path 节点表优先;用例函数体走 Abs 重放。
204
+ */
205
+ declare function getAbsAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Abs | null;
206
+ /** 光标处类型(Abs)。B-path 节点表优先;用例函数体走 Abs 重放。 */
207
+ declare function getTypeAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Abs | null;
197
208
  type HoverInfo = {
198
- /** 外延 TypeValue 展示(bridge 有损,仅兜底) */
209
+ /** 外延展示(formatShape / formatAbs) */
199
210
  typeText: string;
200
211
  /** 内涵签名(代数 generalize) */
201
212
  intension?: string;
@@ -205,12 +216,12 @@ type HoverInfo = {
205
216
  absMultiline?: string;
206
217
  };
207
218
  /**
208
- * LSP hover:优先无损 Abs(类型即计算本体),TypeValue 仅作外延对照。
219
+ * LSP hover:优先无损 Abs(类型即计算本体)。
209
220
  * 节点表也是 Abs(collectAbsNodeTypes),不经 bridge。
210
221
  *
211
222
  * 函数名/调用 callee 位置(design-hof-relations §7):
212
223
  * intension 一律走 generalize/formatPoly(HOF fnRels 在这里);
213
- * typeText 仍落 B-path / TypeValue(调用点显示结果类型,不是函数签名)。
224
+ * typeText 仍落 B-path Abs(调用点显示结果类型,不是函数签名)。
214
225
  * 禁止用 B-path 的 arity-only fn Abs 冒充权威关系源。
215
226
  */
216
227
  declare function getHoverAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): HoverInfo | null;
@@ -220,8 +231,9 @@ declare function getCompletionsAtPosition(filePath: string, source: string, line
220
231
  * `nudo infer --json` 稳定契约 v1(CI / Agent)。
221
232
  *
222
233
  * 字段只增不改语义:
223
- * - ext_*:TypeValue 投影字符串(有损,兼容)
234
+ * - args / result / throws / combined:formatShape 外延投影(有损,兼容)
224
235
  * - intension.abs*:无损 Abs 展示(主线)
236
+ * - argsAbs / resultAbs:CaseResult 上的无损 Abs(formatAbs);有则补齐
225
237
  */
226
238
 
227
239
  type InferJsonCase = {
@@ -232,6 +244,10 @@ type InferJsonCase = {
232
244
  throws: string | null;
233
245
  source: string | null;
234
246
  aggregatedFrom?: number;
247
+ /** 无损参数 Abs 展示(与 args 对齐;缺失位省略) */
248
+ argsAbs?: string[];
249
+ /** 无损结果 Abs 展示 */
250
+ resultAbs?: string;
235
251
  /** 无损内涵(Abs);无则省略 */
236
252
  intension?: {
237
253
  display?: string;
@@ -249,6 +265,8 @@ type InferJsonFunction = {
249
265
  noDeclaration?: boolean;
250
266
  cases: InferJsonCase[];
251
267
  combined?: string;
268
+ /** 无损 combined Abs 展示 */
269
+ combinedAbs?: string;
252
270
  };
253
271
  type InferJson = {
254
272
  version: 1;
@@ -356,7 +374,7 @@ declare function harvestPackage(pkg: string, fromDir?: string, maxFiles?: number
356
374
  };
357
375
  /** harvest 结果 → 人类可读导出表 */
358
376
  declare function formatHarvestSummary(h: PackageHarvest): string;
359
- /** 取某个导出的 TypeValue 字符串 */
377
+ /** 取某个导出的展示串(formatShape) */
360
378
  declare function lookupHarvested(h: PackageHarvest, moduleName: string, exportName: string): string | undefined;
361
379
 
362
380
  /**
@@ -373,7 +391,7 @@ declare function clearHarvestCache(): void;
373
391
  * 自动 harvest 源码中全部裸包(有 @types 或包内 dts 时)。
374
392
  * 返回可注入 setEnvModules 的 modules 表;无包可 harvest 时为空对象。
375
393
  */
376
- declare function autoHarvestModules(source: string, fromDir: string): Record<string, Record<string, TypeValue>>;
394
+ declare function autoHarvestModules(source: string, fromDir: string): Record<string, Record<string, Abs>>;
377
395
 
378
396
  /**
379
397
  * Host:import 图(相对 + 裸包 harvest)→ Abs 导出表 → 注入入口。
@@ -439,12 +457,12 @@ declare function evalProgramAbsWithModules(source: string, entryFile: string, op
439
457
  declare function collectAbsBindingsFromGraph(source: string, filePath: string, opts?: AbsGraphOptions): Map<string, Abs>;
440
458
 
441
459
  /**
442
- * Harvest TypeValue 导出 → AbsModuleExports(供 Abs 模块图注入)。
443
- * fnSig → absFunction + apply 直接返回声明返回类型(conf=mock)。
460
+ * Harvest Abs 导出 → AbsModuleExports(供 Abs 模块图注入)。
461
+ * harvest 产物已是 Abs;fn 槽 apply 直接返回声明返回类型(conf=mock)。
444
462
  */
445
463
 
446
- /** 单个 TypeValue 导出 → Abs(可调用) */
447
- declare function harvestedValueToAbs(tv: TypeValue): Abs;
464
+ /** 单个 Abs 导出 → 可调用 mock(fn 槽 apply 返回声明返回类型) */
465
+ declare function harvestedValueToAbs(a: Abs): Abs;
448
466
  /**
449
467
  * 把 harvest 的 modules/globals 合成 AbsModuleExports。
450
468
  * 键同时登记:原始模块路径、包名、basename(path / @types/path)。
@@ -454,7 +472,7 @@ declare function packageHarvestToAbsModules(pkg: string, h: PackageHarvest): Rec
454
472
  /** 裸说明符 → Abs 导出表(走 harvest 缓存) */
455
473
  declare function bareSpecToAbsModules(spec: string, fromFile: string): AbsModuleExports | undefined;
456
474
 
457
- /** @nudo:env → Abs 全局表(保留 fnSig impl) */
475
+ /** @nudo:env → Abs 全局表(env 模块 Abs 原生) */
458
476
  declare function collectEnvGlobals(envNames: string[]): Record<string, Abs>;
459
477
  /** @nudo:env modules(path / node:path / fs…)→ AbsModuleExports */
460
478
  declare function collectEnvModules(envNames: string[]): Record<string, AbsModuleExports>;
@@ -547,14 +565,6 @@ declare function clearAnalysisSessionCaches(): void;
547
565
  /** 比 clearAnalysisSessionCaches 更彻底:再丢 AST LRU(测试 / 进程复用场景) */
548
566
  declare function resetAllAnalysisCaches(): void;
549
567
 
550
- /**
551
- * env TypeValue → Abs:
552
- * - fnSig 带 impl(Promise.resolve / URL / path.join…)→ apply 路径,保留精确字面量
553
- * - fnSig 仅有声明(readFileSync…)→ relationFn,调用产出声明返回类型而非 unknown
554
- */
555
-
556
- declare function envValueToAbs(tv: TypeValue): Abs;
557
-
558
568
  /**
559
569
  * B 路径静态诊断(AST,不执行):
560
570
  * - unreachable:同块 return/throw 之后的语句
@@ -638,12 +648,13 @@ declare function encodeSemanticTokens(tokens: SemanticToken[]): number[];
638
648
  * - 函数声明/函数表达式的名字 → function;所有函数的参数 → parameter;
639
649
  * - 对象字面量的键:值为函数 → method,否则 property。
640
650
  *
641
- * 推断复用 evaluateProgram 的绑定分析(与补全/诊断同一求值链),不另建
642
- * 符号体系;解析失败返回 [],求值中断则按已绑定的部分结果继续上色。
651
+ * 推断优先 Abs 模块图绑定(TypeValue 退出主路径);失败时复用
652
+ * evaluateProgram。解析失败返回 []。
643
653
  */
644
654
  declare function buildSemanticTokens(filePath: string, source: string): number[];
645
655
 
646
- declare function typeValueToTSType(tv: TypeValue): string;
656
+ /** Abs → TS 类型串。有损:pred / 非 lit term 落到 shape 基类型。 */
657
+ declare function absToTSType(a: Abs): string;
647
658
  /**
648
659
  * 为单个函数生成 .d.ts 声明行(JSDoc + 单一 widen 主签名)。
649
660
  * service 的 generateDts 与 CLI `--dts`(infer/watch)共用本函数,
@@ -652,19 +663,21 @@ declare function typeValueToTSType(tv: TypeValue): string;
652
663
  declare function generateFunctionDtsLines(fn: FunctionAnalysis): string[];
653
664
  declare function generateDts(result: AnalysisResult): string;
654
665
 
655
- declare function typeValueToZodSchema(tv: TypeValue): string;
666
+ /** Abs → zod schema 源码。有损:pred / 非 lit term 落到 shape 基类型。 */
667
+ declare function absToZodSchema(a: Abs): string;
656
668
 
657
- declare function generateGuardFunction(name: string, tv: TypeValue): string;
658
- /** Abs 指称守卫(设计 §2.7):比 TypeValue 投影多保留 pred */
669
+ /** Abs 指称守卫(设计 §2.7):保留 pred */
659
670
  declare function generateGuardFunctionFromAbs(name: string, abs: Abs): string;
671
+ /** 兼容别名:Abs 路径唯一 */
672
+ declare function generateGuardFunction(name: string, abs: Abs): string;
660
673
 
661
- /** 单个 TypeValue → parseTypeValueExpr 可解析回去的表达式文本;不可表达返回 null */
662
- declare function serializeCaseArg(tv: TypeValue): string | null;
674
+ /** 单个 Abs → parseCaseArgExpr 可解析回去的表达式文本;不可表达返回 null */
675
+ declare function serializeCaseArg(a: Abs): string | null;
663
676
  /**
664
677
  * 组装单行 ` * @nudo:case "name" (a, b)` 指令文本(无尾换行)。
665
678
  * 任一实参不可序列化、或名字含双引号/换行(名字正则 `"([^"]+)"` 承载不了)→ 整体 null。
666
679
  */
667
- declare function buildCaseDirective(name: string, args: TypeValue[]): string | null;
680
+ declare function buildCaseDirective(name: string, argsAbs: Abs[]): string | null;
668
681
  /**
669
682
  * 从源码剥离所有本模块生成的 @nudo:case 指令(名字以 call@ 开头,整行删除)。
670
683
  * 若所属 JSDoc 块因此只剩空 ` *` 行(无其他 @nudo:* 指令、无文字内容),
@@ -729,8 +742,8 @@ declare function mockDirectivesToAbsSeeds(functions: Array<{
729
742
  * `nudo interface` 的打印数据源(design-refine-derivation §11 第 0 步):
730
743
  * 逐顶层函数展示有效契约分层——effectiveInterface 命中(手写契约 / 侧车
731
744
  * 生成段)时 params/returns 用 formatConstraint 组合式显示;未命中走
732
- * implicit:直接展示 analyzer 的现成推断结果(case 实参与 Combined 的
733
- * TypeValue 串,不强求约束式)。
745
+ * implicit:优先 CaseResult.argAbs / FunctionAnalysis.combinedAbs(无损
746
+ * Abs 源),展示用 formatShape(外延口径,不强求约束式、不带 conf)。
734
747
  *
735
748
  * autoBind 沿 package.json#nudo.interface(findProjectConfig → interfaceConfig)
736
749
  * 下传,可用 opts 覆盖(测试 / CLI 显式开关);读盘用 defaultLoadModule
@@ -785,6 +798,8 @@ declare function interfaceSurface(filePath: string, opts?: InterfaceSurfaceOpts)
785
798
  */
786
799
 
787
800
  type EmitInterfaceSkipReason = "name-clash" | "not-projectable" | "not-an-export" | "no-change"
801
+ /** package.json#nudo.interface.emit 白名单拒绝 */
802
+ | "emit-denied"
788
803
  /** 手工合并的多声明符 @generated 段:按段原子保留,不拆不重写 */
789
804
  | "multi-declarator";
790
805
  type EmitInterfaceOpts = {
@@ -834,4 +849,125 @@ declare function emitInterface(filePath: string, opts: EmitInterfaceOpts): Promi
834
849
  */
835
850
  declare function formatEmitSummary(sourcePath: string, sidecarRel: string, result: EmitInterfaceResult): string[];
836
851
 
837
- export { type AbsGraphOptions, type AbsMockSeeds, type AbsModuleCacheEntry, type AbsModuleGraphResult, type AbsModuleLoadIssue, type AnalysisResult, type BPathBuiltinUnknown, type BPathDiagnostics, type BPathRunResult, type BPathUnreachable, type BindingInfo, CallRecord, type CaseHint, type CaseInfo, type CaseResult, type CompletionItem, type Diagnostic, type DiagnosticSeverity, type DiagnosticTag, type EmitInterfaceOpts, type EmitInterfaceResult, type EmitInterfaceSkipReason, type EmitResult, type EmitSkipReason, type FunctionAnalysis, type HoverInfo, type InferJson, type InferJsonCase, type InferJsonFunction, type InterfaceSurfaceEntry, type InterfaceSurfaceOpts, type LoadModule, type ModuleExports, type ModuleGraphCache, type NodeEnvResult, type PackageHarvest, type ReferenceInfo, SEMANTIC_TOKEN_MODIFIERS, SEMANTIC_TOKEN_TYPES, type SemanticToken, type SourceLocation, type SymbolInfo, type SymbolTable, analyzeExportsFromSource, analyzeFile, analyzeFileAsync, autoHarvestModules, barePackageName, bareSpecToAbsModules, buildCaseDirective, buildModuleGraph, buildSemanticTokens, clearAbsModuleCache, clearAnalysisFileCache, clearAnalysisSessionCaches, clearBPathCache, clearFnAnalysisCache, clearHarvestCache, collectAbsBindingsFromGraph, collectBPathDiagnostics, collectBPathReplacements, collectBarePackages, collectCallRecords, collectDependencySpecs, collectDtsFromEntry, collectEnvGlobals, collectEnvModules, collectStaticImports, computeDirtySet, defaultAbsLoadModule, defaultLoadModule, emitInterface, encodeSemanticTokens, envValueToAbs, evalAbsModuleGraph, evalProgramAbsWithModules, evictAbsModuleCacheFiles, evictAnalysisCachesForFiles, evictAnalysisFileCacheForFiles, evictBPathCacheForFiles, evictFnAnalysisCacheForFiles, formatEmitSummary, formatHarvestSummary, formatInterfaceSurfaceLine, generateDts, generateFunctionDtsLines, generateGuardFunction, generateGuardFunctionFromAbs, getAnalysisFileCacheSize, getCasesForFile, getCompletionsAtPosition, getHoverAtPosition, getTypeAtPosition, getTypeAtPositionAsync, harvestNodeTypes, harvestPackage, harvestPackageCached, harvestToAbsModules, harvestedValueToAbs, insertGeneratedCaseDirectives, interfaceSurface, isBPathCapable, isNudoTargetPath, lookupHarvested, mockDirectivesToAbsSeeds, packageHarvestToAbsModules, resetAllAnalysisCaches, resolvePackageRoot, serializeCaseArg, serializeInferJson, stripGeneratedCaseDirectives, summarizeNodeEnv, topoSortDirty, tryBPathCall, tryBPathCallFull, tryRunBPath, typeValueToTSType, typeValueToZodSchema, unifiedDiff };
852
+ /**
853
+ * Root 驱动的契约下行(design-refine-derivation §4.2 / §11 Phase 2)。
854
+ *
855
+ * 对含手写契约根的文件(lib.nudo.js 绑定 add4):
856
+ * 1. 从侧车 AST 抽出参数约束的源表达式(`positive` ← `./std.nudo.js`);
857
+ * 2. constraintToEntryAbs + tagDerivationRoot;
858
+ * 3. analyzeFn 求值 body(模块图注入下游),收集调用记录 + 推导打点;
859
+ * 4. 闭包内下游导出投影为组合式 DSL,禁止事后从 Abs 反编译链。
860
+ *
861
+ * check 分轨:每条 root 链独立;join 只用于工件聚合(多调用者)。
862
+ */
863
+
864
+ type ConstraintSourceExpr = {
865
+ expr: string;
866
+ importFrom?: string;
867
+ importName?: string;
868
+ };
869
+ type DerivedParam = {
870
+ name: string;
871
+ constraint: NudoConstraint;
872
+ dsl: string;
873
+ prelude: string[];
874
+ imports: Array<{
875
+ name: string;
876
+ from: string;
877
+ }>;
878
+ /** 单链组合式投影时的推导图 root 节点 id(返回位相对锚定用) */
879
+ rootNodeId?: number;
880
+ /** 该参数位自 root 起消耗的 shift 步数(与 prelude 行数无关,读图) */
881
+ shiftCount?: number;
882
+ };
883
+ type DerivedExport = {
884
+ file: string;
885
+ fn: string;
886
+ paramNames: string[];
887
+ params: DerivedParam[];
888
+ returns?: {
889
+ constraint: NudoConstraint;
890
+ dsl: string;
891
+ prelude: string[];
892
+ imports: Array<{
893
+ name: string;
894
+ from: string;
895
+ }>;
896
+ };
897
+ /** `lib.js:add4` */
898
+ derivedFrom: string;
899
+ compositional: boolean;
900
+ underivable?: boolean;
901
+ };
902
+ type RootDeriveOpts = {
903
+ loadModule?: LoadModule;
904
+ autoBind?: boolean;
905
+ fnNames?: string[];
906
+ /**
907
+ * true:只刷新目标侧车里**已存在**的 @generated 段(CLI 无 --fn/--all 时
908
+ * 的默认行为——不发明新下游契约)。false/省略:闭包内全部可推导导出。
909
+ */
910
+ refreshExistingOnly?: boolean;
911
+ };
912
+ type RootDeriveResult = {
913
+ roots: string[];
914
+ derived: DerivedExport[];
915
+ hasRoot: boolean;
916
+ };
917
+ /** 从侧车源码抽出 `export const f = fn({ x: positive }, ret)` 的约束源表达式 */
918
+ declare function extractFnConstraintSources(sidecarSrc: string, fnName: string): {
919
+ params: Record<string, ConstraintSourceExpr>;
920
+ returns?: ConstraintSourceExpr;
921
+ };
922
+ /**
923
+ * 入口:对 filePath 做 root 驱动下行推导。
924
+ */
925
+ declare function deriveFromRoot(filePath: string, opts?: RootDeriveOpts): RootDeriveResult;
926
+ /**
927
+ * 组装生成段(组合式 + import + prelude)。
928
+ * importFrom 相对 root 侧车解析,再相对 target 侧车写出。
929
+ *
930
+ * `takenNames`:侧车顶层已占用标识符(手写 / 既有生成段 / 本批先前段)。
931
+ * 同文件多导出时对 import local 与 prelude local 做避让改写,
932
+ * 保证拼出的侧车在模块作用域内无重复声明。
933
+ */
934
+ declare function formatDerivedSection(row: DerivedExport, opts: {
935
+ rootSidecarDir: string;
936
+ targetSidecarDir: string;
937
+ takenNames?: Iterable<string>;
938
+ }): {
939
+ text: string;
940
+ usedNames: string[];
941
+ } | undefined;
942
+ type EmitDerivedResult = {
943
+ /** 被写/将写的下游侧车(绝对路径) */
944
+ sidecars: Array<{
945
+ file: string;
946
+ sidecarPath: string;
947
+ fn: string;
948
+ written: boolean;
949
+ changed: boolean;
950
+ skipped?: "name-clash" | "not-projectable" | "underivable" | "no-change";
951
+ diff?: string;
952
+ issues: Array<{
953
+ code: string;
954
+ severity: "error" | "warning" | "info";
955
+ message: string;
956
+ }>;
957
+ }>;
958
+ hasRoot: boolean;
959
+ roots: string[];
960
+ /** 根在别处 / 无契约根且无已存在生成段 → info */
961
+ entryOnly?: boolean;
962
+ };
963
+ declare function emitDerivedFromRoot(rootFile: string, opts: {
964
+ fnNames?: string[];
965
+ mode: "add" | "update";
966
+ dryRun?: boolean;
967
+ loadModule?: LoadModule;
968
+ autoBind?: boolean;
969
+ /** 只刷新目标侧车里已存在的 @generated 段(不发明新下游契约) */
970
+ refreshExistingOnly?: boolean;
971
+ }): EmitDerivedResult;
972
+
973
+ export { type AbsGraphOptions, type AbsMockSeeds, type AbsModuleCacheEntry, type AbsModuleGraphResult, type AbsModuleLoadIssue, type AnalysisResult, type BPathBuiltinUnknown, type BPathDiagnostics, type BPathRunResult, type BPathUnreachable, type BindingInfo, CallRecord, type CaseHint, type CaseInfo, type CaseResult, type CompletionItem, type ConstraintSourceExpr, type DerivedExport, type DerivedParam, type Diagnostic, type DiagnosticSeverity, type DiagnosticTag, type EmitDerivedResult, type EmitInterfaceOpts, type EmitInterfaceResult, type EmitInterfaceSkipReason, type EmitResult, type EmitSkipReason, type FunctionAnalysis, type HoverInfo, type InferJson, type InferJsonCase, type InferJsonFunction, type InterfaceSurfaceEntry, type InterfaceSurfaceOpts, type LoadModule, type ModuleExports, type ModuleGraphCache, type NodeEnvResult, type PackageHarvest, type ReferenceInfo, type RootDeriveOpts, type RootDeriveResult, SEMANTIC_TOKEN_MODIFIERS, SEMANTIC_TOKEN_TYPES, type SemanticToken, type SourceLocation, type SymbolInfo, type SymbolTable, absToTSType, absToZodSchema, analyzeExportsFromSource, analyzeFile, analyzeFileAsync, autoHarvestModules, barePackageName, bareSpecToAbsModules, buildCaseDirective, buildModuleGraph, buildSemanticTokens, clearAbsModuleCache, clearAnalysisFileCache, clearAnalysisSessionCaches, clearBPathCache, clearFnAnalysisCache, clearHarvestCache, collectAbsBindingsFromGraph, collectBPathDiagnostics, collectBPathReplacements, collectBarePackages, collectCallRecords, collectDependencySpecs, collectDtsFromEntry, collectEnvGlobals, collectEnvModules, collectStaticImports, computeDirtySet, defaultAbsLoadModule, defaultLoadModule, deriveFromRoot, emitDerivedFromRoot, emitInterface, encodeSemanticTokens, evalAbsModuleGraph, evalProgramAbsWithModules, evictAbsModuleCacheFiles, evictAnalysisCachesForFiles, evictAnalysisFileCacheForFiles, evictBPathCacheForFiles, evictFnAnalysisCacheForFiles, extractFnConstraintSources, formatDerivedSection, formatEmitSummary, formatHarvestSummary, formatInterfaceSurfaceLine, generateDts, generateFunctionDtsLines, generateGuardFunction, generateGuardFunctionFromAbs, getAbsAtPosition, getAbsAtPositionAsync, getAnalysisFileCacheSize, getCasesForFile, getCompletionsAtPosition, getHoverAtPosition, getTypeAtPosition, getTypeAtPositionAsync, harvestNodeTypes, harvestPackage, harvestPackageCached, harvestToAbsModules, harvestedValueToAbs, insertGeneratedCaseDirectives, interfaceSurface, isBPathCapable, isNudoTargetPath, lookupHarvested, mockDirectivesToAbsSeeds, packageHarvestToAbsModules, resetAllAnalysisCaches, resolvePackageRoot, serializeCaseArg, serializeInferJson, stripGeneratedCaseDirectives, summarizeNodeEnv, topoSortDirty, tryBPathCall, tryBPathCallFull, tryRunBPath, unifiedDiff };