@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,6 +1,24 @@
1
1
  import type { ITtscSnapshotHandle } from "./ITtscSnapshotHandle";
2
2
 
3
- /** Request shape for `getSourceFileText`. */
3
+ /**
4
+ * Request shape for `getSourceFileText`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * Extending the shared handle keeps snapshot identity consistent while adding
8
+ * the file selector accepted by resolveSnapshotFile in the native host.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * Extending the common handle adds only the file selector, so all file queries
11
+ * share one snapshot identity definition and path interpretation boundary.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * The request names its snapshot and file explicitly; no project lookup is
14
+ * replaced by a fixed consumer path.
15
+ * @evidence contracts/common.md#meaningful-documentation
16
+ * JSDoc names the endpoint and accepted path bases, while the inherited member
17
+ * documents the opaque handle, following the documentation skill's context rule.
18
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscFileQuery is a data interface and acquires no handle, task or retained state.
19
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscFileQuery is a data interface and chooses no algorithm or processing strategy.
20
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscFileQuery is a data interface and coordinates no shared or repeated computation.
21
+ */
4
22
  export interface ITtscFileQuery extends ITtscSnapshotHandle {
5
23
  /** Project-relative or absolute path inside the snapshot's program. */
6
24
  path: string;
@@ -1,6 +1,25 @@
1
1
  import type { ITtscDiagnostic } from "./ITtscDiagnostic";
2
2
 
3
- /** Payload inside `ITtscResult.result` for `getDiagnostics`. */
3
+ /**
4
+ * Payload inside `ITtscResult.result` for `getDiagnostics`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * The required array matches the native endpoint's initialized result slice,
8
+ * unlike compile payloads where an absent diagnostics property is supported.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * A single initialized list represents the selection; messages reuse the
11
+ * compile diagnostic DTO and the transport status remains in its envelope.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * Reusing the compiler diagnostic shape avoids a separate simplified schema
14
+ * that discards information to satisfy a particular UI.
15
+ * @evidence contracts/common.md#meaningful-documentation
16
+ * Native JSDoc identifies the envelope and explains empty-result meaning,
17
+ * using the documentation skill's concrete context guidance.
18
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscFountainDiagnosticsResult is a data interface and acquires no handle, task or retained state.
19
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscFountainDiagnosticsResult is a data interface and chooses no algorithm or processing strategy.
20
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscFountainDiagnosticsResult is a data interface and coordinates no shared or repeated computation.
21
+ */
4
22
  export interface ITtscFountainDiagnosticsResult {
23
+ /** Messages selected by the query; an empty array means none were returned. */
5
24
  diagnostics: ITtscDiagnostic[];
6
25
  }
@@ -1,6 +1,23 @@
1
1
  import type { ITtscNodeInfo } from "./ITtscNodeInfo";
2
2
 
3
- /** Payload inside `ITtscResult.result` for `getNodeAtPosition`. */
3
+ /**
4
+ * Payload inside `ITtscResult.result` for `getNodeAtPosition`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * A nullable node mirrors the native pointer's JSON encoding and distinguishes
8
+ * a successful query with no token from an error envelope.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * One nullable node field expresses a token query result; node details and
11
+ * transport errors stay in their existing separate representations.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * No fabricated node stands in for an absent token; absence remains explicit.
14
+ * @evidence contracts/common.md#meaningful-documentation
15
+ * JSDoc names the endpoint and null meaning, following the documentation
16
+ * skill's requirement to explain optional or absent state.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscNodeAtPositionResult is a data interface and acquires no handle, task or retained state.
18
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscNodeAtPositionResult is a data interface and chooses no algorithm or processing strategy.
19
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscNodeAtPositionResult is a data interface and coordinates no shared or repeated computation.
20
+ */
4
21
  export interface ITtscNodeAtPositionResult {
5
22
  /** `null` when no syntax token touches the position. */
6
23
  node: ITtscNodeInfo | null;
@@ -1,13 +1,38 @@
1
- /** Syntax-token shape returned by `getNodeAtPosition`. */
1
+ /**
2
+ * Syntax-token shape returned by `getNodeAtPosition`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * Numeric kind and byte ranges preserve TypeScript-Go's AST representation;
6
+ * a printable name and optional text make the JSON usable without that AST.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * Kind, range and spelling are a flat token projection, without exposing
9
+ * parent links or mutable compiler nodes to the JavaScript consumer.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Positions remain native byte offsets, without a guessed UTF-16 conversion
12
+ * or an invented source span for a particular token.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * Members explain range units, endpoint inclusion and optional text. Native
15
+ * JSDoc follows the documentation skill's concrete usage-context guidance.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscNodeInfo is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscNodeInfo is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscNodeInfo is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscNodeInfo {
3
21
  /** Numeric `ast.Kind` from TypeScript-Go. */
4
22
  kind: number;
23
+
5
24
  /** Human-readable name of `kind`. */
6
25
  kindName: string;
7
- /** Byte offset where the node begins (inclusive). */
26
+
27
+ /**
28
+ * Byte offset of the token's first byte (inclusive), after leading whitespace
29
+ * and comments.
30
+ */
8
31
  pos: number;
32
+
9
33
  /** Byte offset where the node ends (exclusive). */
10
34
  end: number;
35
+
11
36
  /** Source text covered by the node, when available. */
12
37
  text?: string;
13
38
  }
@@ -1,13 +1,38 @@
1
- /** Options for dispatching a named plugin subcommand via `api.plugin`. */
1
+ /**
2
+ * Options for dispatching a named plugin subcommand via `api.plugin`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * Required dispatch fields plus scalar options mirror buildPluginArgv's native
6
+ * translation, allowing each registered plugin to own its argument schema.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * Named dispatch fields are separated from forwarded scalars; the index
9
+ * signature permits plugin-owned arguments without hardwiring plugin schemas.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Plugin defaults remain with the plugin; this transport does not hardcode
12
+ * consumer-specific arguments or pretend to validate an unknown command.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * Member JSDoc distinguishes dispatch identity from forwarded arguments and
15
+ * boolean omission, following the documentation skill's usage-context guidance.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscPluginOpts is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscPluginOpts is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscPluginOpts is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscPluginOpts {
3
21
  /** Plugin id registered with `host.Expose` (e.g. `@ttsc/banner`). */
4
22
  name: string;
23
+
5
24
  /** Subcommand the plugin's Run will receive (e.g. `build`). */
6
25
  command: string;
26
+
7
27
  /** Forwarded as `--cwd=<value>`. */
8
28
  cwd?: string;
9
- /** Forwarded as `--tsconfig=<value>`. Defaults to `tsconfig.json`. */
29
+
30
+ /** Forwarded as `--tsconfig=<value>`; an absent value is left to the plugin. */
10
31
  tsconfig?: string;
11
- /** Any extra key/value pairs map to `--key=value` argv entries. */
32
+
33
+ /**
34
+ * Scalars become `--key=value`; true becomes `--key`, false/undefined are
35
+ * omitted.
36
+ */
12
37
  [key: string]: string | boolean | number | undefined;
13
38
  }
@@ -3,13 +3,30 @@ import type { ITtscFileQuery } from "./ITtscFileQuery";
3
3
  /**
4
4
  * Request shape for `getNodeAtPosition`, `getTypeAtPosition`,
5
5
  * `getSymbolAtPosition`.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation
8
+ * Extending the shared file query adds the native byte-offset selector without
9
+ * duplicating snapshot/file identity. The native boundary validates finite
10
+ * integer bounds before converting JavaScript numbers to Go byte offsets.
11
+ * @evidence contracts/common.md#clear-and-simple-design
12
+ * The file query owns snapshot and path selection; this extension adds only
13
+ * the byte coordinate shared by syntax, type and symbol endpoint handlers.
14
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
15
+ * The native coordinate system is explicit rather than repaired by guessing
16
+ * that a JavaScript character index equals an offset into UTF-8 source.
17
+ * @evidence contracts/common.md#meaningful-documentation
18
+ * Member JSDoc gives the accepted interval and explains the caller's UTF-16
19
+ * conversion responsibility, following the documentation skill's units rule.
20
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscPositionQuery is a data interface and acquires no handle, task or retained state.
21
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscPositionQuery is a data interface and chooses no algorithm or processing strategy.
22
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscPositionQuery is a data interface and coordinates no shared or repeated computation.
6
23
  */
7
24
  export interface ITtscPositionQuery extends ITtscFileQuery {
8
25
  /**
9
- * Byte offset into the file's source text. It must satisfy `0 <= position <
10
- * sourceText's UTF-8 byte length`; the offset immediately after the final
11
- * byte is out of range. JS callers with a UTF-16 line/character pair must
12
- * resolve it to a byte offset first.
26
+ * Integer byte offset into the file's source text. It must satisfy `0 <=
27
+ * position < sourceText's UTF-8 byte length`; the offset immediately after
28
+ * the final byte is out of range. JS callers with a UTF-16 line/character
29
+ * pair must resolve it to a byte offset first.
13
30
  */
14
31
  position: number;
15
32
  }
@@ -1,5 +1,25 @@
1
- /** Payload inside `ITtscResult.result` for `releaseSnapshot`. */
1
+ /**
2
+ * Payload inside `ITtscResult.result` for `releaseSnapshot`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * The boolean mirrors the native release outcome without making an unknown
6
+ * handle into a transport failure; idempotent callers can inspect the result.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * One outcome field conveys registry removal; handle lookup and resource
9
+ * cleanup belong to the native owner, outside this response value.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * The actual release outcome is represented instead of always reporting success.
12
+ * @evidence contracts/common.md#meaningful-documentation
13
+ * JSDoc separates the enclosing payload from absent-handle meaning, following
14
+ * the documentation skill's guidance for failure and optional state.
15
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscReleaseSnapshotResult is a data interface and acquires no handle, task or retained state.
16
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscReleaseSnapshotResult is a data interface and chooses no algorithm or processing strategy.
17
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscReleaseSnapshotResult is a data interface and coordinates no shared or repeated computation.
18
+ */
2
19
  export interface ITtscReleaseSnapshotResult {
3
- /** `false` when the handle was not present (already released). */
20
+ /**
21
+ * `false` when the handle was absent, whether never created or already
22
+ * released.
23
+ */
4
24
  released: boolean;
5
25
  }
@@ -1,14 +1,43 @@
1
- /** Envelope returned by every `ITtscApi` method. */
1
+ /**
2
+ * Envelope returned by asynchronous `ITtscApi` operations.
3
+ *
4
+ * `version` and `plugins` return their synchronous values directly.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * The uniform exit-code/stream/payload shape mirrors the native JavaScript
8
+ * bridge, with structured JSON separate from plugin output streams.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * One envelope separates status, two output channels and structured payload
11
+ * text, leaving endpoint-specific DTOs outside the transport representation.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * A nonzero code remains visible; empty payload text is not replaced with a
14
+ * fabricated success object or interpreted as evidence that the call succeeded.
15
+ * @evidence contracts/common.md#meaningful-documentation
16
+ * Separate JSDoc paragraphs distinguish asynchronous envelopes from direct
17
+ * values; members explain channels, following the documentation skill's guidance.
18
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscResult is a data interface and acquires no handle, task or retained state.
19
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscResult is a data interface and chooses no algorithm or processing strategy.
20
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscResult is a data interface and coordinates no shared or repeated computation.
21
+ */
2
22
  export interface ITtscResult {
3
23
  /** Exit code. 0 = success, 2 = compiler/config/usage error, 3 = runtime error. */
4
24
  code: number;
5
- /** Anything the wasm wrote to its stdout stream. */
25
+
26
+ /**
27
+ * Invocation-owned plugin stdout; project/query endpoints use an empty
28
+ * string.
29
+ */
6
30
  stdout: string;
7
- /** Anything the wasm wrote to its stderr stream. */
31
+
32
+ /**
33
+ * Plugin stderr or a project/query failure message; distinct from host.stderr
34
+ * capture.
35
+ */
8
36
  stderr: string;
37
+
9
38
  /**
10
- * For the base endpoints, the JSON-encoded compile/transform result. For the
11
- * plugin endpoint, this is empty — the plugin's own output sits in
39
+ * For project and snapshot endpoints, the JSON-encoded structured result. For
40
+ * the plugin endpoint, this is empty. The plugin's own output sits in
12
41
  * stdout/stderr. Use `parseResult<T>` to deserialize.
13
42
  */
14
43
  result: string;
@@ -1,4 +1,22 @@
1
- /** Common request shape for fountain verbs that act on an existing snapshot. */
1
+ /**
2
+ * Common request shape for fountain verbs that act on an existing snapshot.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * The opaque string matches the native snapshot registry's public identity
6
+ * and is shared by query types through interface extension.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * The shared request contains only registry identity; derived requests add
9
+ * selectors without exposing the retained Program or duplicating its lifecycle.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Callers pass the returned identity; they need not reconstruct an internal
12
+ * sequence or depend on the current handle spelling.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * JSDoc identifies the shared request role and opaque producer, following the
15
+ * documentation skill's requirement for nonobvious usage context.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSnapshotHandle is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSnapshotHandle is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSnapshotHandle is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscSnapshotHandle {
3
21
  /** Opaque handle returned by `snapshot`. */
4
22
  handle: string;
@@ -1,4 +1,25 @@
1
- /** Payload inside `ITtscResult.result` for `snapshot`. */
1
+ /**
2
+ * Payload inside `ITtscResult.result` for `snapshot`.
3
+ *
4
+ * The caller owns the returned snapshot and must release it when queries
5
+ * finish.
6
+ *
7
+ * @evidence contracts/common.md#principled-implementation
8
+ * Returning an opaque handle keeps retained Go program objects behind the
9
+ * native registry while allowing several queries to share one snapshot.
10
+ * @evidence contracts/common.md#clear-and-simple-design
11
+ * A single opaque handle transfers query access to the caller; registry state
12
+ * and Program cleanup remain with the host instead of entering the payload.
13
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
14
+ * The handle refers to a real registered program, without encoding a consumer
15
+ * path or fabricated query result into the public identity.
16
+ * @evidence contracts/common.md#meaningful-documentation
17
+ * Separate JSDoc paragraphs explain the envelope and release ownership, and
18
+ * the member names its consumers, following the documentation skill's guidance.
19
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSnapshotResult is a data interface and acquires no handle, task or retained state.
20
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSnapshotResult is a data interface and chooses no algorithm or processing strategy.
21
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSnapshotResult is a data interface and coordinates no shared or repeated computation.
22
+ */
2
23
  export interface ITtscSnapshotResult {
3
24
  /** Opaque handle; pass back to fountain verbs and to `releaseSnapshot`. */
4
25
  handle: string;
@@ -1,4 +1,22 @@
1
- /** Payload inside `ITtscResult.result` for `snapshots`. */
1
+ /**
2
+ * Payload inside `ITtscResult.result` for `snapshots`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * A string array mirrors the registry listing without exposing program objects
6
+ * or implying an ordering that the native map does not provide.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * A flat list exposes live registry identities without a second snapshot
9
+ * descriptor layer or ownership information already supplied by its API.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Entries are current registry identities rather than an expected debug list.
12
+ * @evidence contracts/common.md#meaningful-documentation
13
+ * JSDoc identifies the envelope, empty state and unspecified order using the
14
+ * documentation skill's concrete context guidance.
15
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSnapshotsResult is a data interface and acquires no handle, task or retained state.
16
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSnapshotsResult is a data interface and chooses no algorithm or processing strategy.
17
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSnapshotsResult is a data interface and coordinates no shared or repeated computation.
18
+ */
2
19
  export interface ITtscSnapshotsResult {
20
+ /** Live handles in unspecified order; empty when none are registered. */
3
21
  handles: string[];
4
22
  }
@@ -1,4 +1,22 @@
1
- /** Payload inside `ITtscResult.result` for `getSourceFileText`. */
1
+ /**
2
+ * Payload inside `ITtscResult.result` for `getSourceFileText`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * A required text field mirrors the native successful response; missing files
6
+ * use the error envelope rather than overloading an empty source string.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * The selected file's text is the only payload field; request identity and
9
+ * error status remain in the existing request and transport envelope.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * Text comes from the retained program, without substituting the caller's
12
+ * editor buffer or a separately loaded approximation of the snapshot.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * Native JSDoc names the endpoint and retained-program provenance, following
15
+ * the documentation skill's rule to explain the facts needed by a consumer.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSourceFileTextResult is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSourceFileTextResult is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSourceFileTextResult is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscSourceFileTextResult {
3
21
  /** Current source text held by the snapshot's program. */
4
22
  text: string;
@@ -1,5 +1,26 @@
1
- /** Payload inside `ITtscResult.result` for `getSourceFiles`. */
1
+ /**
2
+ * Payload inside `ITtscResult.result` for `getSourceFiles`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * A string array carries the native program's source-file keys without making
6
+ * the JavaScript consumer depend on Go AST objects.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * The payload exposes only source identities; source text and semantic queries
9
+ * remain separate operations instead of inflating every file-list response.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * The program supplies file identity; the response does not invent a fixed
12
+ * entry file or hide files according to a consumer name.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * JSDoc identifies the endpoint, declaration-file exclusion and path convention,
15
+ * following the documentation skill's usage-context guidance.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSourceFilesResult is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSourceFilesResult is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSourceFilesResult is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscSourceFilesResult {
3
- /** Project-relative paths of non-declaration source files. */
21
+ /**
22
+ * Non-declaration source paths: project-relative inside cwd, absolute
23
+ * outside.
24
+ */
4
25
  files: string[];
5
26
  }
@@ -1,6 +1,23 @@
1
1
  import type { ITtscSymbolInfo } from "./ITtscSymbolInfo";
2
2
 
3
- /** Payload inside `ITtscResult.result` for `getSymbolAtPosition`. */
3
+ /**
4
+ * Payload inside `ITtscResult.result` for `getSymbolAtPosition`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * The nullable symbol follows native pointer JSON encoding, keeping successful
8
+ * absence distinct from a failed query envelope.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * A nullable symbol field holds the lookup outcome; reusable symbol metadata
11
+ * and transport failure are represented separately without another status flag.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * Absence is explicit rather than filled with a guessed identifier or symbol.
14
+ * @evidence contracts/common.md#meaningful-documentation
15
+ * JSDoc names the envelope and null meaning, following the documentation
16
+ * skill's requirement to explain absence rather than repeat the field type.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSymbolAtPositionResult is a data interface and acquires no handle, task or retained state.
18
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSymbolAtPositionResult is a data interface and chooses no algorithm or processing strategy.
19
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSymbolAtPositionResult is a data interface and coordinates no shared or repeated computation.
20
+ */
4
21
  export interface ITtscSymbolAtPositionResult {
5
22
  /** `null` when no touching token has an associated symbol. */
6
23
  symbol: ITtscSymbolInfo | null;
@@ -1,7 +1,32 @@
1
- /** A single declaration site for a symbol. */
1
+ /**
2
+ * A single declaration site for a symbol.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * Nullable file identity and byte ranges preserve the native AST declaration
6
+ * projection, including declarations without an associated source file.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * Source identity and a byte interval are sufficient for a declaration site;
9
+ * this value contains no redundant source text or compiler object references.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * A missing source file remains null; neither a placeholder filename nor a
12
+ * guessed JavaScript character range is inserted into the declaration.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * Member JSDoc explains path provenance and interval units, following the
15
+ * documentation skill's guidance for absent state and coordinates.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSymbolDeclaration is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSymbolDeclaration is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSymbolDeclaration is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscSymbolDeclaration {
3
- /** Project-relative or absolute path; `null` for synthetic declarations. */
21
+ /** Project-relative or absolute path; null when no source file is associated. */
4
22
  file: string | null;
23
+
24
+ /**
25
+ * Inclusive start offset of the declaration's first token in the source's
26
+ * UTF-8 bytes, after leading whitespace, comments and JSDoc.
27
+ */
5
28
  pos: number;
29
+
30
+ /** Exclusive end offset in the source's UTF-8 bytes. */
6
31
  end: number;
7
32
  }
@@ -1,15 +1,37 @@
1
1
  import type { ITtscSymbolDeclaration } from "./ITtscSymbolDeclaration";
2
2
 
3
- /** Symbol shape returned by `getSymbolAtPosition`. */
3
+ /**
4
+ * Symbol shape returned by `getSymbolAtPosition`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * Names, flags and declaration projections match the native checker result;
8
+ * separate displayed text avoids confusing raw internal names with presentation.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * Identity and presentation are separate, while bounded declaration sites reuse
11
+ * one site DTO and their total count explains a truncated projection directly.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * The declaration cap is the host's response-size policy, with the original
14
+ * total retained rather than pretending the shortened list is complete.
15
+ * @evidence contracts/common.md#meaningful-documentation
16
+ * JSDoc explains internal naming, printing and capped versus total declarations,
17
+ * following the documentation skill's concrete context guidance.
18
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscSymbolInfo is a data interface and acquires no handle, task or retained state.
19
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscSymbolInfo is a data interface and chooses no algorithm or processing strategy.
20
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscSymbolInfo is a data interface and coordinates no shared or repeated computation.
21
+ */
4
22
  export interface ITtscSymbolInfo {
5
23
  /** Raw symbol name, including TypeScript's internal prefix markers. */
6
24
  name: string;
25
+
7
26
  /** Printed symbol, equivalent to TypeScript's `SymbolToString(s)`. */
8
27
  text?: string;
28
+
9
29
  /** Numeric `SymbolFlags` bitmask from TypeScript-Go. */
10
30
  flags: number;
31
+
11
32
  /** Up to 16 declaration sites; see `declarationCount` for the unclamped total. */
12
33
  declarations?: ITtscSymbolDeclaration[];
34
+
13
35
  /** Total number of declarations, even when `declarations` was clamped. */
14
36
  declarationCount?: number;
15
37
  }
@@ -3,11 +3,30 @@ import type { ITtscDiagnostic } from "./ITtscDiagnostic";
3
3
  /**
4
4
  * Structured payload inside `ITtscResult.result` for `transform`.
5
5
  *
6
- * `typescript` maps source file paths (relative to `cwd`) to their
7
- * post-transform TypeScript text — useful for playgrounds that want to show the
8
- * rewritten source before it is emitted.
6
+ * `typescript` maps source paths to post-transform TypeScript text for a
7
+ * preview before emit. Paths inside `cwd` are relative; outside sources remain
8
+ * absolute.
9
+ *
10
+ * @evidence contracts/common.md#principled-implementation
11
+ * A path-keyed string record matches the native transform payload, keeping
12
+ * transformed TypeScript distinct from build's emitted JavaScript map.
13
+ * @evidence contracts/common.md#clear-and-simple-design
14
+ * A source-text map and the shared diagnostic DTO serve transform consumers;
15
+ * emitted files belong to the compile result instead of a mixed payload.
16
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
17
+ * The payload exposes actual transformed source, without treating expected
18
+ * emitted answers as a replacement for the transform result.
19
+ * @evidence contracts/common.md#meaningful-documentation
20
+ * Separate paragraphs identify the envelope and source stage; members explain
21
+ * optional diagnostics, following the documentation skill's clarity guidance.
22
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscTransformResult is a data interface and acquires no handle, task or retained state.
23
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscTransformResult is a data interface and chooses no algorithm or processing strategy.
24
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscTransformResult is a data interface and coordinates no shared or repeated computation.
9
25
  */
10
26
  export interface ITtscTransformResult {
27
+ /** Present when the native transform includes diagnostic messages. */
11
28
  diagnostics?: ITtscDiagnostic[];
29
+
30
+ /** Post-transform source text keyed by source-file paths. */
12
31
  typescript: Record<string, string>;
13
32
  }
@@ -1,6 +1,23 @@
1
1
  import type { ITtscTypeInfo } from "./ITtscTypeInfo";
2
2
 
3
- /** Payload inside `ITtscResult.result` for `getTypeAtPosition`. */
3
+ /**
4
+ * Payload inside `ITtscResult.result` for `getTypeAtPosition`.
5
+ *
6
+ * @evidence contracts/common.md#principled-implementation
7
+ * A nullable type mirrors the native optional semantic result, separately from
8
+ * the error code carried by the enclosing request envelope.
9
+ * @evidence contracts/common.md#clear-and-simple-design
10
+ * The nullable type field carries the semantic result without conflating it
11
+ * with request failure or adding a parallel state discriminator.
12
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
13
+ * No universal any/error type is fabricated for positions without type semantics.
14
+ * @evidence contracts/common.md#meaningful-documentation
15
+ * Native JSDoc identifies the endpoint and meaningful null state, following
16
+ * the documentation skill's guidance for consumer-facing context.
17
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscTypeAtPositionResult is a data interface and acquires no handle, task or retained state.
18
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscTypeAtPositionResult is a data interface and chooses no algorithm or processing strategy.
19
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscTypeAtPositionResult is a data interface and coordinates no shared or repeated computation.
20
+ */
4
21
  export interface ITtscTypeAtPositionResult {
5
22
  /** `null` when no touching token has a type. */
6
23
  type: ITtscTypeInfo | null;
@@ -1,7 +1,26 @@
1
- /** Type shape returned by `getTypeAtPosition`. */
1
+ /**
2
+ * Type shape returned by `getTypeAtPosition`.
3
+ *
4
+ * @evidence contracts/common.md#principled-implementation
5
+ * Printed text and native flag bits project the checker result through JSON
6
+ * without exposing Go checker objects or an incomplete parallel type model.
7
+ * @evidence contracts/common.md#clear-and-simple-design
8
+ * Printed text and native flags provide presentation and classification in a
9
+ * small value; structural compiler types remain owned by the native checker.
10
+ * @evidence contracts/common.md#prohibited-implementation-shortcuts
11
+ * TypeToString is the presentation authority; the consumer need not infer
12
+ * a type from source spelling or a manually maintained flag lookup.
13
+ * @evidence contracts/common.md#meaningful-documentation
14
+ * Member JSDoc names the native printing API and flag provenance, following
15
+ * the documentation skill's concrete context guidance.
16
+ * @evidenceExclude contracts/performance.md#bound-retention-and-release-resources ITtscTypeInfo is a data interface and acquires no handle, task or retained state.
17
+ * @evidenceExclude contracts/performance.md#efficient-algorithms ITtscTypeInfo is a data interface and chooses no algorithm or processing strategy.
18
+ * @evidenceExclude contracts/performance.md#reuse-equivalent-work ITtscTypeInfo is a data interface and coordinates no shared or repeated computation.
19
+ */
2
20
  export interface ITtscTypeInfo {
3
21
  /** Printed type, equivalent to TypeScript's `TypeToString(t)`. */
4
22
  text: string;
23
+
5
24
  /** Numeric `TypeFlags` bitmask from TypeScript-Go. */
6
25
  flags: number;
7
26
  }