@nola-lang/typescript-plugin 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Evgen Mykhailenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ Part of [Nola](https://github.com/nola-lang/nola), a TypeScript superset (`.tsi`) where `infer` functions and `ask` extractors turn prompts into typed values.
2
+
3
+ **Internal package** — you probably want [`nola-lang`](https://www.npmjs.com/package/nola-lang) (the dev tool) or [`@nola-lang/runtime`](https://www.npmjs.com/package/@nola-lang/runtime) (the app dependency).
4
+
5
+ This package is the tsserver plugin that serves `.tsi` files and their companions to TypeScript editors. The Nola VS Code extension loads it automatically.
6
+
7
+ Versioned in lockstep with the whole toolchain; internal APIs may change in any release.
@@ -0,0 +1,17 @@
1
+ import type ts from "typescript";
2
+ export interface CompanionRegistration {
3
+ sourceFile: string;
4
+ sourceRoot?: string;
5
+ }
6
+ /** Registry lookup for the ServerHost decoration; exact match first, then case-insensitive. */
7
+ export declare function companionRegistration(fileName: string): CompanionRegistration | undefined;
8
+ /**
9
+ * Companions in the editor: host-level synthetic scripts (never VirtualCode —
10
+ * nobody edits them, no mappings map back). Derived from the CURRENT host
11
+ * snapshot of the source file and versioned by that file's script version, so
12
+ * unsaved edits propagate and TypeScript owns invalidation (spec §6b).
13
+ */
14
+ export declare function decorateHostWithCompanions(typescript: typeof ts, host: ts.LanguageServiceHost, options?: {
15
+ sourceRoot?: string;
16
+ }): void;
17
+ //# sourceMappingURL=companion-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"companion-host.d.ts","sourceRoot":"","sources":["../src/companion-host.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAWjC,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAeD,+FAA+F;AAC/F,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAGzF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,OAAO,EAAE,EACrB,IAAI,EAAE,EAAE,CAAC,mBAAmB,EAC5B,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACpC,IAAI,CA+FN"}
@@ -0,0 +1,121 @@
1
+ import { dirname, resolve as resolvePath } from "node:path";
2
+ import { companionSourceCandidates, compileCompanion, isCompanionSpecifier } from "@nola-lang/compiler";
3
+ function norm(p) {
4
+ return p.replace(/\\/g, "/");
5
+ }
6
+ // Process-wide registry of every companion any host decoration has resolved,
7
+ // keyed by normalized companion fileName (plus a lowercase index for Windows
8
+ // case-insensitive probes). The ServerHost decoration reads it so tsserver's
9
+ // ScriptInfo/watch layer can treat companions as real files — see
10
+ // decorateServerHostForCompanions.
11
+ const sharedCompanions = new Map();
12
+ const sharedCompanionsLower = new Map();
13
+ function registerCompanion(companionFileName, registration) {
14
+ sharedCompanions.set(companionFileName, registration);
15
+ sharedCompanionsLower.set(companionFileName.toLowerCase(), registration);
16
+ }
17
+ /** Registry lookup for the ServerHost decoration; exact match first, then case-insensitive. */
18
+ export function companionRegistration(fileName) {
19
+ const key = norm(fileName);
20
+ return sharedCompanions.get(key) ?? sharedCompanionsLower.get(key.toLowerCase());
21
+ }
22
+ /**
23
+ * Companions in the editor: host-level synthetic scripts (never VirtualCode —
24
+ * nobody edits them, no mappings map back). Derived from the CURRENT host
25
+ * snapshot of the source file and versioned by that file's script version, so
26
+ * unsaved edits propagate and TypeScript owns invalidation (spec §6b).
27
+ */
28
+ export function decorateHostWithCompanions(typescript, host, options = {}) {
29
+ /** synthetic companion fileName -> its on-disk/source fileName */
30
+ const companionSources = new Map();
31
+ const cache = new Map();
32
+ const sourceFor = (companionFileName) => companionSources.get(norm(companionFileName));
33
+ const computeSnapshot = (companionFileName) => {
34
+ const source = sourceFor(companionFileName);
35
+ if (!source)
36
+ return undefined;
37
+ const version = host.getScriptVersion(source);
38
+ const cached = cache.get(companionFileName);
39
+ if (cached && cached.sourceVersion === version)
40
+ return cached.snapshot;
41
+ const sourceSnap = host.getScriptSnapshot(source);
42
+ if (!sourceSnap)
43
+ return undefined;
44
+ const text = sourceSnap.getText(0, sourceSnap.getLength());
45
+ const companion = compileCompanion(text, source, { sourceRoot: options.sourceRoot });
46
+ const snapshot = typescript.ScriptSnapshot.fromString(companion.code);
47
+ cache.set(companionFileName, { sourceVersion: version, snapshot });
48
+ return snapshot;
49
+ };
50
+ const tryResolveCompanion = (specifier, containingFile) => {
51
+ if (!isCompanionSpecifier(specifier) || !specifier.startsWith("."))
52
+ return undefined;
53
+ const importerDir = dirname(containingFile);
54
+ for (const candidate of companionSourceCandidates(specifier)) {
55
+ const p = resolvePath(importerDir, candidate);
56
+ if (host.fileExists?.(p) ?? typescript.sys.fileExists(p)) {
57
+ const companionFileName = norm(`${resolvePath(importerDir, specifier).slice(0, -".js".length)}.ts`);
58
+ companionSources.set(companionFileName, norm(p));
59
+ registerCompanion(companionFileName, { sourceFile: norm(p), sourceRoot: options.sourceRoot });
60
+ return companionFileName;
61
+ }
62
+ }
63
+ return undefined;
64
+ };
65
+ const priorResolve = host.resolveModuleNameLiterals?.bind(host);
66
+ host.resolveModuleNameLiterals = (literals, containingFile, redirected, opts, file, reused) => {
67
+ // ONE base call with the full literal array: tsserver's resolution cache
68
+ // keeps per-call bookkeeping (reusedNames correspond to the literals it
69
+ // did NOT receive) — per-literal delegation corrupts it and crashes the
70
+ // server in stopWatchFailedLookupLocationOfResolution. Companion entries
71
+ // then replace their slots in the result.
72
+ const base = priorResolve
73
+ ? priorResolve(literals, containingFile, redirected, opts, file, reused)
74
+ : literals.map((literal) => ({
75
+ resolvedModule: typescript.resolveModuleName(literal.text, containingFile, opts, {
76
+ fileExists: (f) => host.fileExists?.(f) ?? typescript.sys.fileExists(f),
77
+ readFile: (f) => host.readFile?.(f) ?? typescript.sys.readFile(f),
78
+ }).resolvedModule,
79
+ }));
80
+ return literals.map((literal, i) => {
81
+ const companion = tryResolveCompanion(literal.text, containingFile);
82
+ if (companion) {
83
+ return {
84
+ resolvedModule: {
85
+ resolvedFileName: companion,
86
+ extension: typescript.Extension.Ts,
87
+ isExternalLibraryImport: false,
88
+ },
89
+ };
90
+ }
91
+ return base[i];
92
+ });
93
+ };
94
+ const priorFileExists = host.fileExists?.bind(host);
95
+ host.fileExists = (f) => (sourceFor(f) ? computeSnapshot(norm(f)) !== undefined : (priorFileExists?.(f) ?? false));
96
+ const priorGetSnapshot = host.getScriptSnapshot.bind(host);
97
+ host.getScriptSnapshot = (f) => {
98
+ if (!sourceFor(f))
99
+ return priorGetSnapshot(f);
100
+ // Under tsserver the prior chain is Project.getScriptSnapshot, whose side
101
+ // effect mints and attaches the companion's ScriptInfo (it exists to
102
+ // tsserver's file layer via decorateServerHostForCompanions). Without a
103
+ // ScriptInfo, tsserver asserts on the companion in several places
104
+ // (document-registry cache, project telemetry). The returned snapshot is
105
+ // still ours — derived from the LIVE source snapshot, so unsaved edits
106
+ // propagate; the ScriptInfo's disk-derived text is never user-visible.
107
+ priorGetSnapshot(f);
108
+ return computeSnapshot(norm(f));
109
+ };
110
+ const priorGetVersion = host.getScriptVersion.bind(host);
111
+ host.getScriptVersion = (f) => {
112
+ const source = sourceFor(f);
113
+ return source ? `companion-of:${priorGetVersion(source)}` : priorGetVersion(f);
114
+ };
115
+ const priorReadFile = host.readFile?.bind(host);
116
+ host.readFile = (f) => {
117
+ const snapshot = sourceFor(f) ? computeSnapshot(norm(f)) : undefined;
118
+ return snapshot ? snapshot.getText(0, snapshot.getLength()) : priorReadFile?.(f);
119
+ };
120
+ }
121
+ //# sourceMappingURL=companion-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"companion-host.js","sourceRoot":"","sources":["../src/companion-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAQxG,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC;AAOD,6EAA6E;AAC7E,6EAA6E;AAC7E,6EAA6E;AAC7E,kEAAkE;AAClE,mCAAmC;AACnC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAiC,CAAC;AAClE,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAiC,CAAC;AAEvE,SAAS,iBAAiB,CAAC,iBAAyB,EAAE,YAAmC;IACvF,gBAAgB,CAAC,GAAG,CAAC,iBAAiB,EAAE,YAAY,CAA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C5B,OAAO,MAAM,CAAC,CAAC,CAAC,gBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,EAAE;QACpB,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrE,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * tsserver's DocumentRegistry uses the ProjectService as an external source
3
+ * file cache and ASSERTS that every cached path has a ScriptInfo
4
+ * (`Debug.checkDefined` in ProjectService.setDocument). Synthetic companion
5
+ * modules are host-level scripts with no on-disk file: tsserver's
6
+ * watch/ScriptInfo lifecycle drops their info shortly after creation, and
7
+ * from then on EVERY program rebuild (any edit) dies in that assert —
8
+ * diagnostics freeze until the file is closed and reopened. The cache is
9
+ * genuinely optional (getDocument is already null-safe), so skip the write
10
+ * when no ScriptInfo exists instead of crashing.
11
+ *
12
+ * setDocument/getScriptInfoForPath are @internal API — the guard no-ops
13
+ * gracefully if a future TypeScript renames them. One ProjectService serves
14
+ * every project, so the patch applies once per instance.
15
+ */
16
+ export declare function guardProjectServiceDocumentCache(projectService: unknown): void;
17
+ //# sourceMappingURL=document-cache-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-cache-guard.d.ts","sourceRoot":"","sources":["../src/document-cache-guard.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gCAAgC,CAAC,cAAc,EAAE,OAAO,GAAG,IAAI,CAS9E"}
@@ -0,0 +1,29 @@
1
+ const PATCHED = Symbol.for("nola.documentCacheGuard");
2
+ /**
3
+ * tsserver's DocumentRegistry uses the ProjectService as an external source
4
+ * file cache and ASSERTS that every cached path has a ScriptInfo
5
+ * (`Debug.checkDefined` in ProjectService.setDocument). Synthetic companion
6
+ * modules are host-level scripts with no on-disk file: tsserver's
7
+ * watch/ScriptInfo lifecycle drops their info shortly after creation, and
8
+ * from then on EVERY program rebuild (any edit) dies in that assert —
9
+ * diagnostics freeze until the file is closed and reopened. The cache is
10
+ * genuinely optional (getDocument is already null-safe), so skip the write
11
+ * when no ScriptInfo exists instead of crashing.
12
+ *
13
+ * setDocument/getScriptInfoForPath are @internal API — the guard no-ops
14
+ * gracefully if a future TypeScript renames them. One ProjectService serves
15
+ * every project, so the patch applies once per instance.
16
+ */
17
+ export function guardProjectServiceDocumentCache(projectService) {
18
+ const ps = projectService;
19
+ if (ps[PATCHED] || typeof ps.setDocument !== "function" || typeof ps.getScriptInfoForPath !== "function")
20
+ return;
21
+ ps[PATCHED] = true;
22
+ const prior = ps.setDocument.bind(ps);
23
+ ps.setDocument = (key, path, sourceFile) => {
24
+ if (!ps.getScriptInfoForPath?.(path))
25
+ return;
26
+ prior(key, path, sourceFile);
27
+ };
28
+ }
29
+ //# sourceMappingURL=document-cache-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-cache-guard.js","sourceRoot":"","sources":["../src/document-cache-guard.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAQtD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gCAAgC,CAAC,cAAuB;IACtE,MAAM,EAAE,GAAG,cAAyC,CAAC;IACrD,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,WAAW,KAAK,UAAU,IAAI,OAAO,EAAE,CAAC,oBAAoB,KAAK,UAAU;QAAE,OAAO;IACjH,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACnB,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtC,EAAE,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE;QACzC,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC;YAAE,OAAO;QAC7C,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { decorateHostWithCompanions } from "./companion-host.js";
2
+ export { createNolaTsPlugin } from "./plugin.js";
3
+ export { decorateHostHideShadowedDeclarations } from "./shadowed-declarations.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { decorateHostWithCompanions } from "./companion-host.js";
2
+ export { createNolaTsPlugin } from "./plugin.js";
3
+ export { decorateHostHideShadowedDeclarations } from "./shadowed-declarations.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC"}