@nudojs/lsp 0.8.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.
- package/README.md +5 -3
- package/dist/index.d.ts +101 -0
- package/dist/index.js +250754 -0
- package/dist/public-api.d.ts +45 -0
- package/dist/public-api.js +82 -0
- package/dist/server.d.ts +14 -6
- package/dist/server.js +76406 -90125
- package/package.json +23 -9
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@ Language Server Protocol implementation for the [Nudo](https://github.com/nudojs
|
|
|
4
4
|
|
|
5
5
|
## What is Nudo?
|
|
6
6
|
|
|
7
|
-
Nudo is a type inference engine for JavaScript.
|
|
7
|
+
Nudo is a type inference engine for JavaScript. The type system is Abs (`shape × term × pred × conf`); production analysis is Abs-native. Inference executes observed call sites via abstract interpretation — no TypeScript, no build step. Contracts come from `*.nudo.js` sidecars + `@nudo:contract` / `@nudo:contract`.
|
|
8
|
+
|
|
9
|
+
Primary CLI verbs for agents/CI: `nudo check` (signatures + gate), `nudo test` (case report), `nudo contract` (interfaces), `nudo export` (dts/guard/schema/standard), `nudo health` (drift). Observation is check/test/IDE hover.
|
|
8
10
|
|
|
9
11
|
## This package
|
|
10
12
|
|
|
@@ -12,8 +14,8 @@ Nudo is a type inference engine for JavaScript. Instead of a separate type syste
|
|
|
12
14
|
|
|
13
15
|
- Hover type information
|
|
14
16
|
- Completions based on inferred types
|
|
15
|
-
- Diagnostics from abstract interpretation
|
|
16
|
-
-
|
|
17
|
+
- Diagnostics from abstract interpretation (L1 contracts + L2 entry throws)
|
|
18
|
+
- Debug scenario navigation for `@nudo:case` witnesses (contract CodeLens first; case is the debug sub-layer)
|
|
17
19
|
- Go-to-Definition
|
|
18
20
|
- Find References
|
|
19
21
|
- Rename Symbol
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { InterfaceSource, Abs, InterfaceTierOpts } from '@nudojs/core';
|
|
2
|
+
import { SourceLocation, CompletionItem } from '@nudojs/service';
|
|
3
|
+
|
|
4
|
+
type CaseInfo = {
|
|
5
|
+
functionName: string;
|
|
6
|
+
caseName: string;
|
|
7
|
+
caseIndex: number;
|
|
8
|
+
};
|
|
9
|
+
declare function getCasesForFile(filePath: string, source: string): {
|
|
10
|
+
functionName: string;
|
|
11
|
+
cases: {
|
|
12
|
+
name: string;
|
|
13
|
+
index: number;
|
|
14
|
+
}[];
|
|
15
|
+
loc: SourceLocation;
|
|
16
|
+
}[];
|
|
17
|
+
/** Async entry to getTypeAtPosition with path-env preloading (see analyzeFileAsync). */
|
|
18
|
+
declare function getTypeAtPositionAsync(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Promise<Abs | null>;
|
|
19
|
+
/** Async entry to getAbsAtPosition(与 getTypeAtPositionAsync 同预加载口径) */
|
|
20
|
+
declare function getAbsAtPositionAsync(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Promise<Abs | null>;
|
|
21
|
+
/**
|
|
22
|
+
* 光标处无损 Abs。B-path 节点表优先;用例函数体走 Abs 重放。
|
|
23
|
+
*/
|
|
24
|
+
declare function getAbsAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Abs | null;
|
|
25
|
+
/** 光标处类型(Abs)。B-path 节点表优先;用例函数体走 Abs 重放。 */
|
|
26
|
+
declare function getTypeAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>): Abs | null;
|
|
27
|
+
type HoverInfo = {
|
|
28
|
+
/** 外延展示(formatShape / formatAbs) */
|
|
29
|
+
typeText: string;
|
|
30
|
+
/** 内涵签名(代数 generalize) */
|
|
31
|
+
intension?: string;
|
|
32
|
+
/** 无损 Abs 单行展示(shape / term / pred / conf) */
|
|
33
|
+
abs?: string;
|
|
34
|
+
/** 无损 Abs 多行展示 */
|
|
35
|
+
absMultiline?: string;
|
|
36
|
+
/** CodeLens `● interface` 同源档位(A7);仅本地 named export */
|
|
37
|
+
interfaceSource?: InterfaceSource;
|
|
38
|
+
/** 有效契约展示(handwritten/generated);implicit 为 undefined */
|
|
39
|
+
interfaceDisplay?: string;
|
|
40
|
+
};
|
|
41
|
+
/** A7:hover/inlay 与 CodeLens interface 档同源(design-refine-derivation §8) */
|
|
42
|
+
type HoverInterfaceOpts = InterfaceTierOpts;
|
|
43
|
+
/**
|
|
44
|
+
* LSP hover:优先无损 Abs(类型即计算本体)。
|
|
45
|
+
* 节点表也是 Abs(collectAbsNodeTypes),不经 bridge。
|
|
46
|
+
*
|
|
47
|
+
* 函数名/调用 callee 位置(design-hof-relations §7):
|
|
48
|
+
* intension 一律走 generalize/formatPoly(HOF fnRels 在这里);
|
|
49
|
+
* typeText 仍落 B-path Abs(调用点显示结果类型,不是函数签名)。
|
|
50
|
+
* 禁止用 B-path 的 arity-only fn Abs 冒充权威关系源。
|
|
51
|
+
*
|
|
52
|
+
* A7 default 档:函数名 hover 附带 interfaceTierOf 来源 + 契约展示,
|
|
53
|
+
* 与 CodeLens `● interface / <source>` 同源;选 case 时 body 仍走
|
|
54
|
+
* activeCases 重放,interface 档标注不变。
|
|
55
|
+
*/
|
|
56
|
+
declare function getHoverAtPosition(filePath: string, source: string, line: number, column: number, activeCases?: Map<string, number>, opts?: HoverInterfaceOpts): HoverInfo | null;
|
|
57
|
+
declare function getCompletionsAtPosition(filePath: string, source: string, line: number, column: number): CompletionItem[];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Semantic tokens 图例(tokenTypes 下标即 LSP 编码里的 tokenType 值)。
|
|
61
|
+
* 与 LSP server capabilities 里声明的 legend 必须逐字对齐——server.ts 直接
|
|
62
|
+
* 导入本常量注册,保证「提取端索引」与「客户端图例」单一来源。
|
|
63
|
+
* 顺序沿用 lsp 包原 legend(function/variable/parameter/property 在前),
|
|
64
|
+
* 末尾追加 method(对象字面量方法键)与 interface 档 modifier(A7),
|
|
65
|
+
* 只追加不重排,客户端索引稳定。
|
|
66
|
+
*/
|
|
67
|
+
declare const SEMANTIC_TOKEN_TYPES: readonly ["function", "variable", "parameter", "property", "type", "keyword", "string", "number", "comment", "decorator", "method"];
|
|
68
|
+
declare const SEMANTIC_TOKEN_MODIFIERS: readonly ["declaration", "readonly", "deprecated", "unreachable", "contract", "generated", "derived"];
|
|
69
|
+
type SemanticToken = {
|
|
70
|
+
line: number;
|
|
71
|
+
char: number;
|
|
72
|
+
length: number;
|
|
73
|
+
typeIndex: number;
|
|
74
|
+
modifierBitmask: number;
|
|
75
|
+
};
|
|
76
|
+
/** LSP 标准相对五元组编码:deltaLine/deltaStartChar/length/tokenType/tokenModifiers。 */
|
|
77
|
+
declare function encodeSemanticTokens(tokens: SemanticToken[]): number[];
|
|
78
|
+
/** A7:interface 档 → semantic token modifier(与 CodeLens 同源) */
|
|
79
|
+
declare function interfaceTierModifierBit(src: InterfaceSource): number;
|
|
80
|
+
type BuildSemanticTokensOpts = InterfaceTierOpts & {
|
|
81
|
+
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 从源码提取 semantic tokens 并按 LSP 相对编码返回扁平 number[]。
|
|
85
|
+
*
|
|
86
|
+
* 上色范围(声明位优先,未解析的 token 一律不上色):
|
|
87
|
+
* - 顶层 const/let/var 声明的绑定名:推断为函数绑定 → function,否则 variable
|
|
88
|
+
* (函数体内部的声明不做 env 反查——外层同名绑定会串味,统一 variable);
|
|
89
|
+
* - 函数声明/函数表达式的名字 → function;所有函数的参数 → parameter;
|
|
90
|
+
* - 对象字面量的键:值为函数 → method,否则 property。
|
|
91
|
+
*
|
|
92
|
+
* A7:本地 named export 的函数绑定额外带 interface 档 modifier
|
|
93
|
+
* (contract / generated / derived),与 CodeLens `● interface` 同源。
|
|
94
|
+
* 非导出绑定只带 declaration,不假装进档。
|
|
95
|
+
*
|
|
96
|
+
* 推断优先 Abs 模块图绑定(TypeValue 退出主路径);失败时复用
|
|
97
|
+
* evaluateProgram。解析失败返回 []。
|
|
98
|
+
*/
|
|
99
|
+
declare function buildSemanticTokens(filePath: string, source: string, opts?: BuildSemanticTokensOpts): number[];
|
|
100
|
+
|
|
101
|
+
export { type BuildSemanticTokensOpts, type CaseInfo, type HoverInfo, SEMANTIC_TOKEN_MODIFIERS, SEMANTIC_TOKEN_TYPES, type SemanticToken, buildSemanticTokens, encodeSemanticTokens, getAbsAtPosition, getAbsAtPositionAsync, getCasesForFile, getCompletionsAtPosition, getHoverAtPosition, getTypeAtPosition, getTypeAtPositionAsync, interfaceTierModifierBit };
|