@ttsc/wasm 0.30.4 → 0.31.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.
Files changed (174) hide show
  1. package/README.md +3 -3
  2. package/build/build-wasm.cjs +5 -4
  3. package/build/go-build-cache.cjs +347 -0
  4. package/build/pack-prepare.cjs +3 -2
  5. package/cmd/ttsc-wasm/main.go +22 -10
  6. package/cmd/ttsc-wasm/main_wasm.go +2 -2
  7. package/dist/.ttsc-wasm-build.json +138 -58
  8. package/dist/go.mod +7 -5
  9. package/dist/ttsc.wasm +2 -2
  10. package/go.mod +7 -5
  11. package/go.sum +10 -10
  12. package/host/api.go +34 -41
  13. package/host/doc.go +7 -6
  14. package/host/expose.go +42 -0
  15. package/host/fountain.go +192 -22
  16. package/host/host.go +10 -25
  17. package/host/host_native.go +3 -5
  18. package/host/invoke.go +133 -0
  19. package/host/plugin.go +37 -72
  20. package/host/result.go +108 -0
  21. package/lib/src/BootTtscWorkerTerminationError.d.ts +20 -0
  22. package/lib/src/BootTtscWorkerTerminationError.js +20 -0
  23. package/lib/src/BootTtscWorkerTerminationError.js.map +1 -1
  24. package/lib/src/MemFSError.d.ts +21 -2
  25. package/lib/src/MemFSError.js +25 -2
  26. package/lib/src/MemFSError.js.map +1 -1
  27. package/lib/src/bootTtsc.d.ts +49 -2
  28. package/lib/src/bootTtsc.js +89 -23
  29. package/lib/src/bootTtsc.js.map +1 -1
  30. package/lib/src/createMemFS.d.ts +45 -0
  31. package/lib/src/createMemFS.js +269 -66
  32. package/lib/src/createMemFS.js.map +1 -1
  33. package/lib/src/parseResult.d.ts +19 -0
  34. package/lib/src/parseResult.js +19 -0
  35. package/lib/src/parseResult.js.map +1 -1
  36. package/lib/src/structures/IBootResult.d.ts +20 -2
  37. package/lib/src/structures/IBootTtscOptions.d.ts +28 -6
  38. package/lib/src/structures/IFileStats.d.ts +51 -0
  39. package/lib/src/structures/IMemFSHost.d.ts +89 -0
  40. package/lib/src/structures/ITtscApi.d.ts +154 -9
  41. package/lib/src/structures/ITtscBuildOpts.d.ts +18 -1
  42. package/lib/src/structures/ITtscCompileResult.d.ts +20 -2
  43. package/lib/src/structures/ITtscDiagnostic.d.ts +25 -1
  44. package/lib/src/structures/ITtscFileQuery.d.ts +19 -1
  45. package/lib/src/structures/ITtscFountainDiagnosticsResult.d.ts +20 -1
  46. package/lib/src/structures/ITtscNodeAtPositionResult.d.ts +18 -1
  47. package/lib/src/structures/ITtscNodeInfo.d.ts +23 -2
  48. package/lib/src/structures/ITtscPluginOpts.d.ts +24 -3
  49. package/lib/src/structures/ITtscPositionQuery.d.ts +21 -4
  50. package/lib/src/structures/ITtscReleaseSnapshotResult.d.ts +22 -2
  51. package/lib/src/structures/ITtscResult.d.ts +31 -5
  52. package/lib/src/structures/ITtscSnapshotHandle.d.ts +19 -1
  53. package/lib/src/structures/ITtscSnapshotResult.d.ts +22 -1
  54. package/lib/src/structures/ITtscSnapshotsResult.d.ts +19 -1
  55. package/lib/src/structures/ITtscSourceFileTextResult.d.ts +19 -1
  56. package/lib/src/structures/ITtscSourceFilesResult.d.ts +23 -2
  57. package/lib/src/structures/ITtscSymbolAtPositionResult.d.ts +18 -1
  58. package/lib/src/structures/ITtscSymbolDeclaration.d.ts +25 -2
  59. package/lib/src/structures/ITtscSymbolInfo.d.ts +19 -1
  60. package/lib/src/structures/ITtscTransformResult.d.ts +21 -3
  61. package/lib/src/structures/ITtscTypeAtPositionResult.d.ts +18 -1
  62. package/lib/src/structures/ITtscTypeInfo.d.ts +19 -1
  63. package/lib/src/structures/ITtscVersion.d.ts +28 -1
  64. package/lib/src/structures/IWasmExecFS.d.ts +310 -0
  65. package/package.json +4 -2
  66. package/shim-vendor/shim/ast/enums_gen.go +4 -2
  67. package/shim-vendor/shim/ast/go.mod +5 -5
  68. package/shim-vendor/shim/ast/go.sum +10 -10
  69. package/shim-vendor/shim/ast/lint.go +1088 -20
  70. package/shim-vendor/shim/ast/parent.go +38 -22
  71. package/shim-vendor/shim/ast/safe_text.go +48 -26
  72. package/shim-vendor/shim/ast/shim.go +1307 -20
  73. package/shim-vendor/shim/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
  74. package/shim-vendor/shim/ast/test/node_text_joins_multi_hop_qualified_name_test.go +24 -9
  75. package/shim-vendor/shim/ast/test/node_text_joins_one_hop_qualified_name_test.go +9 -5
  76. package/shim-vendor/shim/ast/test/node_text_returns_empty_for_nil_test.go +13 -5
  77. package/shim-vendor/shim/ast/test/node_text_returns_identifier_text_test.go +12 -5
  78. package/shim-vendor/shim/ast/test/node_text_skips_empty_qualified_left_test.go +35 -5
  79. package/shim-vendor/shim/astnav/go.mod +5 -5
  80. package/shim-vendor/shim/astnav/go.sum +12 -10
  81. package/shim-vendor/shim/astnav/shim.go +9 -0
  82. package/shim-vendor/shim/bundled/go.mod +7 -1
  83. package/shim-vendor/shim/bundled/go.sum +12 -0
  84. package/shim-vendor/shim/checker/enums_gen.go +4 -2
  85. package/shim-vendor/shim/checker/extra-shim.json +6 -0
  86. package/shim-vendor/shim/checker/go.mod +5 -5
  87. package/shim-vendor/shim/checker/go.sum +10 -10
  88. package/shim-vendor/shim/checker/node_builder_fields_gen.go +19 -0
  89. package/shim-vendor/shim/checker/shim.go +827 -114
  90. package/shim-vendor/shim/compiler/emit_sourcemap.go +68 -29
  91. package/shim-vendor/shim/compiler/emitassemble.go +36 -2
  92. package/shim-vendor/shim/compiler/emithook.go +13 -3
  93. package/shim-vendor/shim/compiler/go.mod +5 -5
  94. package/shim-vendor/shim/compiler/go.sum +10 -10
  95. package/shim-vendor/shim/compiler/incremental.go +56 -20
  96. package/shim-vendor/shim/compiler/resolution.go +92 -9
  97. package/shim-vendor/shim/core/enums_gen.go +2 -2
  98. package/shim-vendor/shim/core/go.mod +6 -1
  99. package/shim-vendor/shim/core/go.sum +10 -0
  100. package/shim-vendor/shim/core/modulekind.go +9 -0
  101. package/shim-vendor/shim/core/shim.go +157 -6
  102. package/shim-vendor/shim/diagnosticwriter/go.mod +10 -1
  103. package/shim-vendor/shim/diagnosticwriter/go.sum +20 -0
  104. package/shim-vendor/shim/diagnosticwriter/lint.go +188 -10
  105. package/shim-vendor/shim/diagnosticwriter/shim.go +14 -0
  106. package/shim-vendor/shim/lsp/go.mod +5 -5
  107. package/shim-vendor/shim/lsp/go.sum +10 -10
  108. package/shim-vendor/shim/lsp/shim.go +78 -2
  109. package/shim-vendor/shim/parser/go.mod +10 -1
  110. package/shim-vendor/shim/parser/go.sum +22 -0
  111. package/shim-vendor/shim/printer/emithost.go +46 -1
  112. package/shim-vendor/shim/printer/go.mod +5 -5
  113. package/shim-vendor/shim/printer/go.sum +10 -10
  114. package/shim-vendor/shim/printer/shim.go +114 -7
  115. package/shim-vendor/shim/printer/sourcemap.go +55 -0
  116. package/shim-vendor/shim/scanner/go.mod +10 -1
  117. package/shim-vendor/shim/scanner/go.sum +20 -0
  118. package/shim-vendor/shim/scanner/regexp.go +19 -4
  119. package/shim-vendor/shim/scanner/shim.go +3 -0
  120. package/shim-vendor/shim/stringutil/extra-shim.json +1 -0
  121. package/shim-vendor/shim/stringutil/go.mod +5 -0
  122. package/shim-vendor/shim/stringutil/go.sum +2 -0
  123. package/shim-vendor/shim/stringutil/shim.go +119 -0
  124. package/shim-vendor/shim/transformers/go.mod +5 -5
  125. package/shim-vendor/shim/transformers/go.sum +12 -10
  126. package/shim-vendor/shim/transformers/shim.go +12 -3
  127. package/shim-vendor/shim/tsoptions/command_line_raw.go +44 -0
  128. package/shim-vendor/shim/tsoptions/go.mod +10 -1
  129. package/shim-vendor/shim/tsoptions/go.sum +22 -0
  130. package/shim-vendor/shim/tsoptions/shim.go +1 -1
  131. package/shim-vendor/shim/tspath/go.mod +1 -1
  132. package/shim-vendor/shim/tspath/go.sum +6 -0
  133. package/shim-vendor/shim/vfs/cachedvfs/go.mod +3 -1
  134. package/shim-vendor/shim/vfs/cachedvfs/go.sum +12 -0
  135. package/shim-vendor/shim/vfs/decode.go +26 -0
  136. package/shim-vendor/shim/vfs/decode_test.go +42 -0
  137. package/shim-vendor/shim/vfs/go.mod +7 -1
  138. package/shim-vendor/shim/vfs/go.sum +12 -0
  139. package/shim-vendor/shim/vfs/osvfs/go.mod +7 -1
  140. package/shim-vendor/shim/vfs/osvfs/go.sum +12 -0
  141. package/src/BootTtscWorkerTerminationError.ts +22 -0
  142. package/src/MemFSError.ts +29 -2
  143. package/src/bootTtsc.ts +104 -28
  144. package/src/createMemFS.ts +291 -64
  145. package/src/parseResult.ts +19 -0
  146. package/src/structures/IBootResult.ts +21 -2
  147. package/src/structures/IBootTtscOptions.ts +32 -6
  148. package/src/structures/IFileStats.ts +65 -0
  149. package/src/structures/IMemFSHost.ts +97 -0
  150. package/src/structures/ITtscApi.ts +154 -9
  151. package/src/structures/ITtscBuildOpts.ts +19 -1
  152. package/src/structures/ITtscCompileResult.ts +21 -2
  153. package/src/structures/ITtscDiagnostic.ts +32 -1
  154. package/src/structures/ITtscFileQuery.ts +19 -1
  155. package/src/structures/ITtscFountainDiagnosticsResult.ts +20 -1
  156. package/src/structures/ITtscNodeAtPositionResult.ts +18 -1
  157. package/src/structures/ITtscNodeInfo.ts +27 -2
  158. package/src/structures/ITtscPluginOpts.ts +28 -3
  159. package/src/structures/ITtscPositionQuery.ts +21 -4
  160. package/src/structures/ITtscReleaseSnapshotResult.ts +22 -2
  161. package/src/structures/ITtscResult.ts +34 -5
  162. package/src/structures/ITtscSnapshotHandle.ts +19 -1
  163. package/src/structures/ITtscSnapshotResult.ts +22 -1
  164. package/src/structures/ITtscSnapshotsResult.ts +19 -1
  165. package/src/structures/ITtscSourceFileTextResult.ts +19 -1
  166. package/src/structures/ITtscSourceFilesResult.ts +23 -2
  167. package/src/structures/ITtscSymbolAtPositionResult.ts +18 -1
  168. package/src/structures/ITtscSymbolDeclaration.ts +27 -2
  169. package/src/structures/ITtscSymbolInfo.ts +23 -1
  170. package/src/structures/ITtscTransformResult.ts +22 -3
  171. package/src/structures/ITtscTypeAtPositionResult.ts +18 -1
  172. package/src/structures/ITtscTypeInfo.ts +20 -1
  173. package/src/structures/ITtscVersion.ts +33 -1
  174. package/src/structures/IWasmExecFS.ts +336 -0
@@ -1,23 +1,49 @@
1
1
  import type { IMemFSHost } from "./IMemFSHost";
2
2
 
3
- /** Options for `bootTtsc`. All fields except `wasmUrl` have sensible defaults. */
3
+ /**
4
+ * Options for `bootTtsc`. All fields except `wasmUrl` have defaults.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * URLs, AbortSignal and an injectable MemFS use browser integration primitives;
8
+ * the explicit API name mirrors the Go host's global bridge identity.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * Binary and bridge identity are explicit, while optional cancellation and
11
+ * host injection cover actual boot ownership without a generic loader layer.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * Runtime identity and host come from the caller or documented protocol defaults,
14
+ * without selecting a different boot path for a named consumer.
15
+ * @evidence contracts/common.md#meaningful-documentation
16
+ * Native JSDoc explains defaults, cancellation sharing and host identity. Separate
17
+ * ownership paragraphs follow the documentation skill's context guidance.
18
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources IBootTtscOptions is a data interface and acquires no handle, task or retained state.
19
+ * @evidenceExclude contracts/performance.md#efficient-algorithms IBootTtscOptions is a data interface and chooses no algorithm or processing strategy.
20
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work IBootTtscOptions is a data interface and coordinates no shared or repeated computation.
21
+ */
4
22
  export interface IBootTtscOptions {
5
23
  /** URL of the .wasm to fetch. */
6
24
  wasmUrl: string;
25
+
7
26
  /** Cancel this boot attempt, including a shared in-flight attempt. */
8
27
  signal?: AbortSignal;
9
- /** URL of wasm_exec.js. Defaults to the same directory as wasmUrl. */
28
+
29
+ /**
30
+ * URL of wasm_exec.js; defaults to a sibling URL without the binary's
31
+ * query/fragment.
32
+ */
10
33
  wasmExecUrl?: string;
34
+
11
35
  /**
12
36
  * GlobalThis property name the wasm binds. Must match the value the wasm was
13
37
  * built with (the `apiName` passed to `host.Expose`). Defaults to `"ttsc"`.
14
38
  */
15
39
  apiName?: string;
40
+
16
41
  /**
17
- * Optional pre-existing MemFS host. When omitted, a fresh one is created and
18
- * stored on the returned BootResult. Pass an existing host when you want to
19
- * boot multiple wasms over the same filesystem (e.g. base ttsc + a typia
20
- * wasm) so they share project sources.
42
+ * Optional pre-existing MemFS host. A new boot creates one when omitted;
43
+ * joining an existing boot reuses its host. A different explicit host or
44
+ * runtime-script URL is rejected. Pass an existing host when you want to
45
+ * retry before a runtime starts or reuse an existing boot's filesystem. This
46
+ * does not make one Worker safe to host multiple Go runtimes simultaneously.
21
47
  */
22
48
  host?: IMemFSHost;
23
49
  }
@@ -3,21 +3,86 @@
3
3
  *
4
4
  * Mirrors the subset of `fs.Stats` that `wasm_exec.js` reads. Fields not
5
5
  * relevant to Go's `os.FileInfo` (e.g. ownership) are zeroed.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation
8
+ * Node-shaped fields and kind predicates match the Go js/wasm bridge's stats
9
+ * consumer; this is a virtual projection rather than a native inode model.
10
+ * @evidence contracts/common.md#clear-and-simple-design
11
+ * One stats snapshot groups sampled kind, byte size and projected metadata;
12
+ * predicates expose the two supported kinds without another node hierarchy.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
14
+ * Synthetic device/ownership values express MemFS capabilities, without
15
+ * presenting browser-host metadata as actual operating-system file identity.
16
+ * @evidence contracts/common.md#meaningful-documentation
17
+ * Native JSDoc explains bridge scope, time and size units and synthetic fields,
18
+ * following the documentation skill's concrete context guidance.
19
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources IFileStats only groups the virtual-filesystem members and acquires no handle, task or retained state.
20
+ * @evidenceExclude contracts/performance.md#efficient-algorithms IFileStats only groups the virtual-filesystem members and chooses no algorithm.
21
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work IFileStats only groups the virtual-filesystem members and coordinates no computation.
6
22
  */
7
23
  export interface IFileStats {
24
+ /**
25
+ * Whether the sampled node is a virtual directory.
26
+ *
27
+ * @evidence contracts/common.md#principled-implementation makeStats captures node.kind once, so the predicate reports that sampled directory classification.
28
+ * @evidence contracts/common.md#clear-and-simple-design The kind query is separate from metadata fields and shares the captured classification with isFile.
29
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts It reports the sampled node kind, not a filename heuristic.
30
+ * @evidence contracts/common.md#meaningful-documentation JSDoc names snapshot provenance under the documentation skill's context rule.
31
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources isDirectory is a signature only; the lifetime of what it touches belongs to createMemFS.
32
+ * @evidenceExclude contracts/performance.md#efficient-algorithms isDirectory is a signature only; its algorithm and cost belong to createMemFS.
33
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work isDirectory is a signature only; sharing of repeated work belongs to createMemFS.
34
+ */
8
35
  isDirectory(): boolean;
36
+
37
+ /**
38
+ * Whether the sampled node is a virtual regular file.
39
+ *
40
+ * @evidence contracts/common.md#principled-implementation MemFS has only file and directory nodes, making the inverse sampled-directory flag its regular-file classification.
41
+ * @evidence contracts/common.md#clear-and-simple-design The predicate exposes the other supported node kind through the same snapshot rather than recalculating a path.
42
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The virtual node kind determines the result, without extension special cases.
43
+ * @evidence contracts/common.md#meaningful-documentation JSDoc distinguishes regular-file classification under the documentation skill's clarity rule.
44
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources isFile is a signature only; the lifetime of what it touches belongs to createMemFS.
45
+ * @evidenceExclude contracts/performance.md#efficient-algorithms isFile is a signature only; its algorithm and cost belong to createMemFS.
46
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work isFile is a signature only; sharing of repeated work belongs to createMemFS.
47
+ */
9
48
  isFile(): boolean;
49
+
50
+ /** File byte length; zero for a directory. */
10
51
  size: number;
52
+
53
+ /** Virtual file-kind and permission bits, in Node stat format. */
11
54
  mode: number;
55
+
56
+ /** Modification time in milliseconds since the Unix epoch. */
12
57
  mtimeMs: number;
58
+
59
+ /** Access-time projection; MemFS uses its modification timestamp. */
13
60
  atimeMs: number;
61
+
62
+ /** Change-time projection; MemFS uses its modification timestamp. */
14
63
  ctimeMs: number;
64
+
65
+ /** Synthetic device identity; MemFS uses zero. */
15
66
  dev: number;
67
+
68
+ /** Synthetic inode identity; MemFS uses zero. */
16
69
  ino: number;
70
+
71
+ /** Synthetic link count; MemFS uses one. */
17
72
  nlink: number;
73
+
74
+ /** Synthetic owner id; MemFS uses zero. */
18
75
  uid: number;
76
+
77
+ /** Synthetic group id; MemFS uses zero. */
19
78
  gid: number;
79
+
80
+ /** Synthetic special-device identity; MemFS uses zero. */
20
81
  rdev: number;
82
+
83
+ /** Virtual preferred I/O block size in bytes. */
21
84
  blksize: number;
85
+
86
+ /** Allocated-size projection measured in 512-byte blocks. */
22
87
  blocks: number;
23
88
  }
@@ -4,15 +4,112 @@ import type { IWasmExecFS } from "./IWasmExecFS";
4
4
  * Handle returned by `createMemFS`. Provides the `fs` shim to install on
5
5
  * `globalThis` plus convenience methods for seeding the virtual filesystem
6
6
  * before booting the wasm.
7
+ *
8
+ * @evidence contracts/common.md#principled-implementation
9
+ * A bridge plus seeding/readback methods keeps virtual filesystem ownership
10
+ * explicit, with byte and text access separate and missing reads nullable.
11
+ * @evidence contracts/common.md#clear-and-simple-design
12
+ * Low-level bridge access, convenience seeding/readback and output captures
13
+ * have distinct members, all sharing one host instead of separate stores.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
15
+ * The same owned filesystem serves compiler input and caller readback;
16
+ * output captures are distinct from ordinary files and from native host I/O.
17
+ * @evidence contracts/common.md#meaningful-documentation
18
+ * Native JSDoc explains copying, directory creation, missing reads and stream
19
+ * reset scope, following the documentation skill's ownership/context guidance.
20
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources IMemFSHost only groups the virtual-filesystem members and acquires no handle, task or retained state.
21
+ * @evidenceExclude contracts/performance.md#efficient-algorithms IMemFSHost only groups the virtual-filesystem members and chooses no algorithm.
22
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work IMemFSHost only groups the virtual-filesystem members and coordinates no computation.
7
23
  */
8
24
  export interface IMemFSHost {
25
+ /** Bridge installed before evaluating wasm_exec.js. */
9
26
  fs: IWasmExecFS;
27
+
28
+ /**
29
+ * Store copied bytes or UTF-8 text, creating missing parent directories.
30
+ *
31
+ * @evidence contracts/common.md#principled-implementation A dedicated seeding API owns recursive directory creation rather than changing low-level open.
32
+ * @evidence contracts/common.md#clear-and-simple-design One convenience operation owns caller-data copying and parent creation; low-level open keeps its separate contract.
33
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Caller data is copied into the real backing tree, not an alternate fixture store.
34
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states encoding, copying and parent creation under the documentation skill's context guidance.
35
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources writeFile is a signature only; the lifetime of what it touches belongs to createMemFS.
36
+ * @evidenceExclude contracts/performance.md#efficient-algorithms writeFile is a signature only; its algorithm and cost belong to createMemFS.
37
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work writeFile is a signature only; sharing of repeated work belongs to createMemFS.
38
+ */
10
39
  writeFile(path: string, data: string | Uint8Array): void;
40
+
41
+ /**
42
+ * Read an owned copy of file bytes; return null for an absent path or
43
+ * directory.
44
+ *
45
+ * @evidence contracts/common.md#principled-implementation Nullable copied bytes distinguish an absent file from an empty file.
46
+ * @evidence contracts/common.md#clear-and-simple-design Byte readback has one nullable result and leaves text conversion to the separate text operation.
47
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Readback uses the compiler's backing tree rather than reconstructing expected output.
48
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains ownership and null meaning under the documentation skill's absence guidance.
49
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources readFile is a signature only; the lifetime of what it touches belongs to createMemFS.
50
+ * @evidenceExclude contracts/performance.md#efficient-algorithms readFile is a signature only; its algorithm and cost belong to createMemFS.
51
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work readFile is a signature only; sharing of repeated work belongs to createMemFS.
52
+ */
11
53
  readFile(path: string): Uint8Array | null;
54
+
55
+ /**
56
+ * Decode file bytes as UTF-8; return null for an absent path or directory.
57
+ *
58
+ * Decoding follows `TextDecoder`: a leading byte-order mark is dropped and a
59
+ * malformed sequence becomes U+FFFD. `readFile` returns the exact bytes.
60
+ *
61
+ * @evidence contracts/common.md#principled-implementation Text decoding adapts the same byte store using TextDecoder's UTF-8 behavior.
62
+ * @evidence contracts/common.md#clear-and-simple-design A text view shares the stored file identity and hides decoding/cache details from callers.
63
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The text view does not introduce a separately mutable source cache.
64
+ * @evidence contracts/common.md#meaningful-documentation JSDoc names encoding and null meaning under the documentation skill's units/context guidance.
65
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources readFileText is a signature only; the lifetime of what it touches belongs to createMemFS.
66
+ * @evidenceExclude contracts/performance.md#efficient-algorithms readFileText is a signature only; its algorithm and cost belong to createMemFS.
67
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work readFileText is a signature only; sharing of repeated work belongs to createMemFS.
68
+ */
12
69
  readFileText(path: string): string | null;
70
+
71
+ /**
72
+ * Whether a normalized path names a stored file or directory.
73
+ *
74
+ * @evidence contracts/common.md#principled-implementation A presence query delegates to the same virtual path identity as read and write.
75
+ * @evidence contracts/common.md#clear-and-simple-design A separate presence predicate includes directories without expanding the file-read result shape.
76
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Actual tree membership determines presence, without an extension-based guess.
77
+ * @evidence contracts/common.md#meaningful-documentation JSDoc distinguishes presence from file readability under the documentation skill's clarity guidance.
78
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources exists is a signature only; the lifetime of what it touches belongs to createMemFS.
79
+ * @evidenceExclude contracts/performance.md#efficient-algorithms exists is a signature only; its algorithm and cost belong to createMemFS.
80
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work exists is a signature only; sharing of repeated work belongs to createMemFS.
81
+ */
13
82
  exists(path: string): boolean;
83
+
84
+ /**
85
+ * Create a directory chain; reject file ancestors before creating any prefix.
86
+ *
87
+ * @evidence contracts/common.md#principled-implementation Recursive seeding is explicit and validates the whole chain before mutation.
88
+ * @evidence contracts/common.md#clear-and-simple-design Parent creation is one named convenience operation instead of being hidden in every bridge path.
89
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts A file is not reclassified as a directory to force a requested path to exist.
90
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains rejection effects under the documentation skill's failure guidance.
91
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources mkdirp is a signature only; the lifetime of what it touches belongs to createMemFS.
92
+ * @evidenceExclude contracts/performance.md#efficient-algorithms mkdirp is a signature only; its algorithm and cost belong to createMemFS.
93
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work mkdirp is a signature only; sharing of repeated work belongs to createMemFS.
94
+ */
14
95
  mkdirp(path: string): void;
96
+
97
+ /** Captured UTF-8 output written to the reserved stdout descriptor. */
15
98
  stdout: { buffer: string };
99
+
100
+ /** Captured UTF-8 output written to the reserved stderr descriptor. */
16
101
  stderr: { buffer: string };
102
+
103
+ /**
104
+ * Clear stdout/stderr captures without changing files or open descriptors.
105
+ *
106
+ * @evidence contracts/common.md#principled-implementation Resetting only owned stream buffers makes capture lifetime explicit.
107
+ * @evidence contracts/common.md#clear-and-simple-design Stream reset has one explicit boundary and does not combine filesystem cleanup with capture management.
108
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Reset does not erase compiler input or hide failed operations as a filesystem reset.
109
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states the reset boundary under the documentation skill's ownership guidance.
110
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources resetStdio is a signature only; the lifetime of what it touches belongs to createMemFS.
111
+ * @evidenceExclude contracts/performance.md#efficient-algorithms resetStdio is a signature only; its algorithm and cost belong to createMemFS.
112
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work resetStdio is a signature only; sharing of repeated work belongs to createMemFS.
113
+ */
17
114
  resetStdio(): void;
18
115
  }
@@ -11,28 +11,79 @@ import type { ITtscVersion } from "./ITtscVersion";
11
11
  *
12
12
  * Obtain an instance via `bootTtsc`, which waits for the wasm to signal
13
13
  * readiness and returns the typed handle together with its `IMemFSHost`.
14
+ *
15
+ * @evidence contracts/common.md#principled-implementation
16
+ * Signatures mirror host.Expose's direct metadata/list methods and asynchronous
17
+ * project/snapshot methods, sharing request DTOs and the native result envelope.
18
+ * @evidence contracts/common.md#clear-and-simple-design
19
+ * Named verbs distinguish project work from retained-program queries; requests
20
+ * share small DTOs and async results share one envelope. Direct metadata/list
21
+ * values stay synchronous because their native handlers do not load a project.
22
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
23
+ * Queries address retained programs through opaque handles rather than
24
+ * substituting JavaScript source heuristics for compiler semantics.
25
+ * @evidence contracts/common.md#meaningful-documentation
26
+ * JSDoc separates acquisition, decoding, coordinates and snapshot ownership,
27
+ * following the documentation skill's paragraph and context guidance.
28
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscApi only groups the wasm API verbs and acquires no handle, task or retained state.
29
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscApi only groups the wasm API verbs and chooses no algorithm.
30
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscApi only groups the wasm API verbs and coordinates no computation.
14
31
  */
15
32
  export interface ITtscApi {
16
- /** Build metadata reported by the wasm. Useful for diagnostics. */
33
+ /**
34
+ * Build metadata reported synchronously by the wasm.
35
+ *
36
+ * @evidence contracts/common.md#principled-implementation The direct return mirrors jsVersion's synchronous projection.
37
+ * @evidence contracts/common.md#clear-and-simple-design One direct metadata value requires no project request or asynchronous transport envelope.
38
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Binary metadata supplies identity rather than a guessed browser or release constant.
39
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states direct-return behavior under the documentation skill's context rule.
40
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources version is a signature only; the lifetime of what it touches belongs to the Go host.
41
+ * @evidenceExclude contracts/performance.md#efficient-algorithms version is a signature only; its algorithm and cost belong to the Go host.
42
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work version is a signature only; sharing of repeated work belongs to the Go host.
43
+ */
17
44
  version(): ITtscVersion;
18
45
 
19
46
  /**
20
47
  * Compile a project: typecheck + emit. `result` is JSON;
21
48
  * `parseResult<ITtscCompileResult>` deserializes it.
49
+ *
50
+ * @evidence contracts/common.md#principled-implementation The Promise envelope follows native Build and the shared project request.
51
+ * @evidence contracts/common.md#clear-and-simple-design The named emit verb reuses project options and the result envelope without mixing no-emit switches into its request.
52
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The loaded program supplies output, without a consumer-specific emitter path.
53
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states purpose and decoding under the documentation skill's context rule.
54
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources build is a signature only; the lifetime of what it touches belongs to the Go host.
55
+ * @evidenceExclude contracts/performance.md#efficient-algorithms build is a signature only; its algorithm and cost belong to the Go host.
56
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work build is a signature only; sharing of repeated work belongs to the Go host.
22
57
  */
23
58
  build(opts: ITtscBuildOpts): Promise<ITtscResult>;
24
59
 
25
60
  /**
26
61
  * Typecheck without emit. `result` is JSON; `parseResult<ITtscCompileResult>`
27
62
  * deserializes it.
63
+ *
64
+ * @evidence contracts/common.md#principled-implementation Native Check owns no-emit loading and the shared compile payload.
65
+ * @evidence contracts/common.md#clear-and-simple-design A separate no-emit verb makes intent explicit while sharing project and diagnostic representations.
66
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts No-emit is a loader option rather than pretending an emitted build was a check.
67
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains no-emit and decoding under the documentation skill's clarity rule.
68
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources check is a signature only; the lifetime of what it touches belongs to the Go host.
69
+ * @evidenceExclude contracts/performance.md#efficient-algorithms check is a signature only; its algorithm and cost belong to the Go host.
70
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work check is a signature only; sharing of repeated work belongs to the Go host.
28
71
  */
29
72
  check(opts: ITtscBuildOpts): Promise<ITtscResult>;
30
73
 
31
74
  /**
32
- * Return every source file the program saw, keyed by project-relative path.
33
- * Used by playgrounds that want to render the TypeScript view after a source
34
- * rewriter (e.g. paths) has run. `result` is JSON; use
75
+ * Return source text keyed by project-relative path inside cwd and absolute
76
+ * path outside it. Used by playgrounds that want to render the TypeScript
77
+ * view after a source rewriter (e.g. paths) has run. `result` is JSON; use
35
78
  * `parseResult<ITtscTransformResult>` to deserialize.
79
+ *
80
+ * @evidence contracts/common.md#principled-implementation Native Transform projects post-plugin text through the shared project request.
81
+ * @evidence contracts/common.md#clear-and-simple-design The source projection is its own verb and DTO, keeping emitted output distinct from transformed TypeScript.
82
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Source comes from the transformed program rather than inference from emitted JavaScript.
83
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains source stage, paths and decoding under the documentation skill's context rule.
84
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources transform is a signature only; the lifetime of what it touches belongs to the Go host.
85
+ * @evidenceExclude contracts/performance.md#efficient-algorithms transform is a signature only; its algorithm and cost belong to the Go host.
86
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work transform is a signature only; sharing of repeated work belongs to the Go host.
36
87
  */
37
88
  transform(opts: ITtscBuildOpts): Promise<ITtscResult>;
38
89
 
@@ -40,10 +91,28 @@ export interface ITtscApi {
40
91
  * Dispatch a registered plugin's subcommand. Returns the captured stdout /
41
92
  * stderr (the same streams the native sidecar binary would write to) together
42
93
  * with the exit code.
94
+ *
95
+ * @evidence contracts/common.md#principled-implementation Named dispatch adapts scalar options to a registered Go Plugin's command arguments.
96
+ * @evidence contracts/common.md#clear-and-simple-design One dispatcher forwards plugin-owned arguments without adding a host endpoint for each plugin command.
97
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Invocation-owned streams replace global-output mutation; command semantics stay with the plugin.
98
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains dispatch and output ownership under the documentation skill's ownership rule.
99
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources plugin is a signature only; the lifetime of what it touches belongs to the Go host.
100
+ * @evidenceExclude contracts/performance.md#efficient-algorithms plugin is a signature only; its algorithm and cost belong to the Go host.
101
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work plugin is a signature only; sharing of repeated work belongs to the Go host.
43
102
  */
44
103
  plugin(opts: ITtscPluginOpts): Promise<ITtscResult>;
45
104
 
46
- /** Names of the plugins this wasm was built with. */
105
+ /**
106
+ * Names of registered plugins, returned synchronously.
107
+ *
108
+ * @evidence contracts/common.md#principled-implementation The direct array mirrors the native registry's name projection.
109
+ * @evidence contracts/common.md#clear-and-simple-design A direct name list exposes registration discovery without leaking Plugin instances or invoking commands.
110
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Entries describe linked registrations rather than a fixed list of npm packages.
111
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states registry provenance and direct return under the documentation skill's context rule.
112
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources plugins is a signature only; the lifetime of what it touches belongs to the Go host.
113
+ * @evidenceExclude contracts/performance.md#efficient-algorithms plugins is a signature only; its algorithm and cost belong to the Go host.
114
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work plugins is a signature only; sharing of repeated work belongs to the Go host.
115
+ */
47
116
  plugins(): string[];
48
117
 
49
118
  /**
@@ -53,31 +122,83 @@ export interface ITtscApi {
53
122
  * Callers MUST call `releaseSnapshot` for every handle they receive to free
54
123
  * the program's checker pool lease and let Go GC reclaim the AST. Use
55
124
  * `parseResult<ITtscSnapshotResult>` to read the handle.
125
+ *
126
+ * @evidence contracts/common.md#principled-implementation An opaque handle references a retained native program for repeated queries.
127
+ * @evidence contracts/common.md#clear-and-simple-design Acquisition is distinct from querying and release, so the caller can identify its explicit retained-program lifetime.
128
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Queries share the actual program rather than rebuilding approximations for each request.
129
+ * @evidence contracts/common.md#meaningful-documentation Separate JSDoc paragraphs explain acquisition, decoding and release under the documentation skill.
130
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources snapshot is a signature only; the lifetime of what it touches belongs to the Go host.
131
+ * @evidenceExclude contracts/performance.md#efficient-algorithms snapshot is a signature only; its algorithm and cost belong to the Go host.
132
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work snapshot is a signature only; sharing of repeated work belongs to the Go host.
56
133
  */
57
134
  snapshot(opts: ITtscBuildOpts): Promise<ITtscResult>;
58
135
 
59
136
  /**
60
137
  * Drop a snapshot held by the wasm. Safe to call with an already-released
61
- * handle — the response's `released` flag will be `false`.
138
+ * handle. The response's `released` flag will be `false`.
139
+ *
140
+ * @evidence contracts/common.md#principled-implementation Explicit release follows the registry's idempotent delete-and-close operation.
141
+ * @evidence contracts/common.md#clear-and-simple-design One handle-based release operation owns cleanup instead of coupling it to an unrelated query result.
142
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts The owning registry controls release rather than a guessed JavaScript GC event.
143
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains already-released behavior under the documentation skill's absence guidance.
144
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources releaseSnapshot is a signature only; the lifetime of what it touches belongs to the Go host.
145
+ * @evidenceExclude contracts/performance.md#efficient-algorithms releaseSnapshot is a signature only; its algorithm and cost belong to the Go host.
146
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work releaseSnapshot is a signature only; sharing of repeated work belongs to the Go host.
62
147
  */
63
148
  releaseSnapshot(opts: ITtscSnapshotHandle): Promise<ITtscResult>;
64
149
 
65
- /** List the currently retained snapshot handles. Debug aid. */
150
+ /**
151
+ * List currently retained snapshot handles in unspecified order.
152
+ *
153
+ * @evidence contracts/common.md#principled-implementation The Promise envelope projects the live native registry without exposing programs.
154
+ * @evidence contracts/common.md#clear-and-simple-design The listing exposes only current handles and uses the same async envelope as other registry operations.
155
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Registry ownership supplies the list rather than a caller-side history.
156
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states lifetime and order under the documentation skill's context rule.
157
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources snapshots is a signature only; the lifetime of what it touches belongs to the Go host.
158
+ * @evidenceExclude contracts/performance.md#efficient-algorithms snapshots is a signature only; its algorithm and cost belong to the Go host.
159
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work snapshots is a signature only; sharing of repeated work belongs to the Go host.
160
+ */
66
161
  snapshots(): Promise<ITtscResult>;
67
162
 
68
- /** List source file paths held by the snapshot's program. */
163
+ /**
164
+ * List non-declaration source paths held by the snapshot's program.
165
+ *
166
+ * @evidence contracts/common.md#principled-implementation A shared handle selects the retained program whose SourceFiles supplies the projection.
167
+ * @evidence contracts/common.md#clear-and-simple-design File identities are queried separately from their text and semantic details to keep this projection focused.
168
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Compiler membership determines files rather than a filesystem glob approximation.
169
+ * @evidence contracts/common.md#meaningful-documentation JSDoc names snapshot provenance and declaration exclusion under the documentation skill's context rule.
170
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getSourceFiles is a signature only; the lifetime of what it touches belongs to the Go host.
171
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getSourceFiles is a signature only; its algorithm and cost belong to the Go host.
172
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getSourceFiles is a signature only; sharing of repeated work belongs to the Go host.
173
+ */
69
174
  getSourceFiles(opts: ITtscSnapshotHandle): Promise<ITtscResult>;
70
175
 
71
176
  /**
72
177
  * Read the current text the snapshot's program is holding for a file. After
73
178
  * transform-stage plugins ran inside this snapshot, the text reflects their
74
179
  * rewrites.
180
+ *
181
+ * @evidence contracts/common.md#principled-implementation A handle/file query reads the native program's current source text.
182
+ * @evidence contracts/common.md#clear-and-simple-design The shared file query selects one source; its text-only payload avoids duplicating snapshot or AST state.
183
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Readback does not substitute an editor buffer that may differ from the retained program.
184
+ * @evidence contracts/common.md#meaningful-documentation JSDoc names retained and transformed text under the documentation skill's provenance guidance.
185
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getSourceFileText is a signature only; the lifetime of what it touches belongs to the Go host.
186
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getSourceFileText is a signature only; its algorithm and cost belong to the Go host.
187
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getSourceFileText is a signature only; sharing of repeated work belongs to the Go host.
75
188
  */
76
189
  getSourceFileText(opts: ITtscFileQuery): Promise<ITtscResult>;
77
190
 
78
191
  /**
79
192
  * Diagnostics from the snapshot's program. Pass `file` to filter to a single
80
- * project-relative path.
193
+ * project-relative or absolute path.
194
+ *
195
+ * @evidence contracts/common.md#principled-implementation Program diagnostics supply the result, narrowed by an optional file selector.
196
+ * @evidence contracts/common.md#clear-and-simple-design One optional file filter refines the same diagnostic operation without another per-file endpoint.
197
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Messages come from compiler diagnostics rather than a parallel source-pattern checker.
198
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains filter identity under the documentation skill's context rule.
199
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getDiagnostics is a signature only; the lifetime of what it touches belongs to the Go host.
200
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getDiagnostics is a signature only; its algorithm and cost belong to the Go host.
201
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getDiagnostics is a signature only; sharing of repeated work belongs to the Go host.
81
202
  */
82
203
  getDiagnostics(
83
204
  opts: ITtscSnapshotHandle & { file?: string },
@@ -86,6 +207,14 @@ export interface ITtscApi {
86
207
  /**
87
208
  * Return the syntax token touching `position` (byte offset), including
88
209
  * punctuation. Returns `{node: null}` for whitespace and comments.
210
+ *
211
+ * @evidence contracts/common.md#principled-implementation Native astnav owns token lookup in the retained program using byte coordinates.
212
+ * @evidence contracts/common.md#clear-and-simple-design The shared position request drives a syntax-only result, leaving checker-specific queries separate.
213
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Compiler AST semantics replace guessed JavaScript lexical scans.
214
+ * @evidence contracts/common.md#meaningful-documentation JSDoc states units and null meaning under the documentation skill's coordinate/absence guidance.
215
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getNodeAtPosition is a signature only; the lifetime of what it touches belongs to the Go host.
216
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getNodeAtPosition is a signature only; its algorithm and cost belong to the Go host.
217
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getNodeAtPosition is a signature only; sharing of repeated work belongs to the Go host.
89
218
  */
90
219
  getNodeAtPosition(opts: ITtscPositionQuery): Promise<ITtscResult>;
91
220
 
@@ -93,12 +222,28 @@ export interface ITtscApi {
93
222
  * Resolve the token at `position` and return the enclosing TypeScript-Go
94
223
  * semantic node's printed type string + flags. Returns `{type: null}` when
95
224
  * the position has no token or no type-bearing token.
225
+ *
226
+ * @evidence contracts/common.md#principled-implementation The retained checker owns semantic lookup and printing after token navigation.
227
+ * @evidence contracts/common.md#clear-and-simple-design Type presentation has its own nullable payload while using the same position selector as syntax and symbol queries.
228
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Types come from compiler semantics rather than source spelling or a fabricated any result.
229
+ * @evidence contracts/common.md#meaningful-documentation JSDoc distinguishes token and semantic lookup under the documentation skill's context rule.
230
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getTypeAtPosition is a signature only; the lifetime of what it touches belongs to the Go host.
231
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getTypeAtPosition is a signature only; its algorithm and cost belong to the Go host.
232
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getTypeAtPosition is a signature only; sharing of repeated work belongs to the Go host.
96
233
  */
97
234
  getTypeAtPosition(opts: ITtscPositionQuery): Promise<ITtscResult>;
98
235
 
99
236
  /**
100
237
  * Resolve the symbol the token at `position` refers to, including up to 16
101
238
  * declaration sites. Returns `{symbol: null}` when no symbol is bound.
239
+ *
240
+ * @evidence contracts/common.md#principled-implementation The retained checker resolves symbols and projects bounded declaration metadata.
241
+ * @evidence contracts/common.md#clear-and-simple-design One symbol payload combines identity with a small declaration projection without adding follow-up declaration handles.
242
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts Declaration sites come from the symbol rather than searching text for equal names.
243
+ * @evidence contracts/common.md#meaningful-documentation JSDoc explains the cap and null result under the documentation skill's context rule.
244
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources getSymbolAtPosition is a signature only; the lifetime of what it touches belongs to the Go host.
245
+ * @evidenceExclude contracts/performance.md#efficient-algorithms getSymbolAtPosition is a signature only; its algorithm and cost belong to the Go host.
246
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work getSymbolAtPosition is a signature only; sharing of repeated work belongs to the Go host.
102
247
  */
103
248
  getSymbolAtPosition(opts: ITtscPositionQuery): Promise<ITtscResult>;
104
249
  }
@@ -1,7 +1,25 @@
1
- /** Options shared by `build`, `check`, and `transform`. */
1
+ /**
2
+ * Options shared by `build`, `check`, and `transform`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * Required cwd and optional tsconfig mirror the native project endpoints;
6
+ * omission delegates the default to the host that loads the project.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * The shared request contains project root and config selection only; the
9
+ * chosen API verb owns whether that project is emitted, checked or projected.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Project identity comes from the caller, rather than a consumer-specific root.
12
+ * @evidence contracts/common.md#meaningful-documentation
13
+ * Member JSDoc distinguishes virtual absolute cwd from relative config paths
14
+ * and names the default, following the documentation skill's clear prose.
15
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscBuildOpts is a data interface and acquires no handle, task or retained state.
16
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscBuildOpts is a data interface and chooses no algorithm or processing strategy.
17
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscBuildOpts is a data interface and coordinates no shared or repeated computation.
18
+ */
2
19
  export interface ITtscBuildOpts {
3
20
  /** Absolute virtual path the project lives at inside the MemFS. */
4
21
  cwd: string;
22
+
5
23
  /** Tsconfig path, relative to `cwd`. Defaults to `tsconfig.json`. */
6
24
  tsconfig?: string;
7
25
  }
@@ -3,10 +3,29 @@ import type { ITtscDiagnostic } from "./ITtscDiagnostic";
3
3
  /**
4
4
  * Structured payload inside `ITtscResult.result` for `build` and `check`.
5
5
  *
6
- * `output` maps emit-destination paths (relative to `cwd`) to file contents. It
7
- * is empty when `check` is called without emit.
6
+ * `output` maps emit-destination paths to file contents. Paths inside `cwd` are
7
+ * relative; outside destinations remain absolute. `check` returns an empty
8
+ * map.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation
11
+ * A path-keyed string record matches the native JSON output map; optional
12
+ * diagnostics reflect its omitempty encoding rather than requiring a sentinel.
13
+ * @evidence contracts/common.md#clear-and-simple-design
14
+ * Diagnostics and emitted files have separate fields, reusing one diagnostic
15
+ * type while keeping the transport envelope outside this compile payload.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
17
+ * Compiler-produced paths and contents remain data, without fixture-shaped keys.
18
+ * @evidence contracts/common.md#meaningful-documentation
19
+ * JSDoc identifies the enclosing envelope, path base and no-emit meaning;
20
+ * separate paragraphs follow the documentation skill's purpose and context rule.
21
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscCompileResult is a data interface and acquires no handle, task or retained state.
22
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscCompileResult is a data interface and chooses no algorithm or processing strategy.
23
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscCompileResult is a data interface and coordinates no shared or repeated computation.
8
24
  */
9
25
  export interface ITtscCompileResult {
26
+ /** Present when the native result includes diagnostic messages. */
10
27
  diagnostics?: ITtscDiagnostic[];
28
+
29
+ /** Emitted file contents keyed by their destination paths. */
11
30
  output: Record<string, string>;
12
31
  }
@@ -1,14 +1,45 @@
1
1
  /**
2
2
  * A single TypeScript compiler diagnostic emitted during `build`, `check`, or
3
- * `transform`. `line` and `character` are 0-based.
3
+ * `transform`. `line` and `character` are 1-based, matching the native driver.
4
+ *
5
+ * @evidence contracts/common.md#principled-implementation
6
+ * Nullable file identity and optional locations mirror CompileDiagnostic's
7
+ * native JSON projection; the severity union matches its two public categories.
8
+ * @evidence contracts/common.md#clear-and-simple-design
9
+ * Identity, byte span, display location and message remain distinct fields;
10
+ * optional coordinates express absent context without an extra location model.
11
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
12
+ * Diagnostic codes and locations come from the compiler rather than a guessed
13
+ * editor coordinate or a fixture-specific message classification.
14
+ * @evidence contracts/common.md#meaningful-documentation
15
+ * Native JSDoc explains byte ranges, 1-based display locations and missing
16
+ * source context, following the documentation skill's units and absence rules.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscDiagnostic is a data interface and acquires no handle, task or retained state.
18
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscDiagnostic is a data interface and chooses no algorithm or processing strategy.
19
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscDiagnostic is a data interface and coordinates no shared or repeated computation.
4
20
  */
5
21
  export interface ITtscDiagnostic {
22
+ /** Absolute slash-separated source path; null for project-wide diagnostics. */
6
23
  file: string | null;
24
+
25
+ /** Error affects the exit code; warning does not. */
7
26
  category: "error" | "warning";
27
+
28
+ /** Native compiler or plugin diagnostic identifier. */
8
29
  code: number;
30
+
31
+ /** Inclusive UTF-8 byte offset when source location is available. */
9
32
  start?: number;
33
+
34
+ /** Span length in UTF-8 bytes when source location is available. */
10
35
  length?: number;
36
+
37
+ /** 1-based source line; omitted when no display location is available. */
11
38
  line?: number;
39
+
40
+ /** 1-based UTF-8 byte column; omitted when no display location is available. */
12
41
  character?: number;
42
+
43
+ /** Complete diagnostic message for presentation to the caller. */
13
44
  messageText: string;
14
45
  }