@reqlan/analytical 0.8.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +27 -2
  2. package/README.template.md +1 -1
  3. package/out/core/barrel-page.d.ts +2 -1
  4. package/out/core/barrel-page.js +18 -83
  5. package/out/core/barrel-page.js.map +1 -1
  6. package/out/core/base-discovery.d.ts +6 -0
  7. package/out/core/base-discovery.js +56 -4
  8. package/out/core/base-discovery.js.map +1 -1
  9. package/out/core/create-base.js +10 -14
  10. package/out/core/create-base.js.map +1 -1
  11. package/out/core/file-reference-resolve.js +8 -2
  12. package/out/core/file-reference-resolve.js.map +1 -1
  13. package/out/core/index-error.d.ts +3 -3
  14. package/out/core/index-error.js.map +1 -1
  15. package/out/core/index-state-types.d.ts +47 -0
  16. package/out/core/index-state-types.js +11 -0
  17. package/out/core/index-state-types.js.map +1 -0
  18. package/out/core/path-relative.d.ts +15 -0
  19. package/out/core/path-relative.js +84 -0
  20. package/out/core/path-relative.js.map +1 -0
  21. package/out/core/rqignore.js +62 -62
  22. package/out/core/rqignore.js.map +1 -1
  23. package/out/core/types.d.ts +12 -3
  24. package/out/core/types.js +4 -1
  25. package/out/core/types.js.map +1 -1
  26. package/out/core/workspace-paths.d.ts +1 -1
  27. package/out/core/workspace-paths.js +8 -44
  28. package/out/core/workspace-paths.js.map +1 -1
  29. package/out/export/build-export-snapshot.js +1 -1
  30. package/out/export/build-export-snapshot.js.map +1 -1
  31. package/out/export/export-utils.d.ts +5 -0
  32. package/out/export/export-utils.js +38 -0
  33. package/out/export/export-utils.js.map +1 -0
  34. package/out/export/write-csv-export.js +1 -1
  35. package/out/export/write-csv-export.js.map +1 -1
  36. package/out/export/write-markdown-export.js +1 -1
  37. package/out/export/write-markdown-export.js.map +1 -1
  38. package/out/index-store/base-registry.d.ts +2 -3
  39. package/out/index-store/base-registry.js +8 -4
  40. package/out/index-store/base-registry.js.map +1 -1
  41. package/out/index-store/fuzzy-search-hit.d.ts +10 -0
  42. package/out/index-store/fuzzy-search-hit.js +2 -0
  43. package/out/index-store/fuzzy-search-hit.js.map +1 -0
  44. package/out/index-store/index-diagnostics-store.d.ts +4 -0
  45. package/out/index-store/index-diagnostics-store.js +44 -88
  46. package/out/index-store/index-diagnostics-store.js.map +1 -1
  47. package/out/index-store/index-file-error.d.ts +1 -1
  48. package/out/index-store/index-parse-issues.d.ts +4 -3
  49. package/out/index-store/index-parse-issues.js +0 -38
  50. package/out/index-store/index-parse-issues.js.map +1 -1
  51. package/out/index-store/index-status.d.ts +1 -1
  52. package/out/index-store/schema.d.ts +1 -1
  53. package/out/index-store/schema.js +6 -2
  54. package/out/index-store/schema.js.map +1 -1
  55. package/out/index-store/sqlite-store.d.ts +10 -4
  56. package/out/index-store/sqlite-store.js +81 -606
  57. package/out/index-store/sqlite-store.js.map +1 -1
  58. package/out/index-store/webview-graph-queries.d.ts +7 -0
  59. package/out/index-store/webview-graph-queries.js.map +1 -1
  60. package/out/index-store/webview-table-queries.d.ts +1 -1
  61. package/out/index-store/webview-table-queries.js +9 -0
  62. package/out/index-store/webview-table-queries.js.map +1 -1
  63. package/out/index-store/workspace-index-file.d.ts +3 -14
  64. package/out/index-store/workspace-index-file.js +1 -118
  65. package/out/index-store/workspace-index-file.js.map +1 -1
  66. package/out/index-store/workspace-index-sync.d.ts +4 -17
  67. package/out/index-store/workspace-index-sync.js +29 -11
  68. package/out/index-store/workspace-index-sync.js.map +1 -1
  69. package/out/index-store/workspace-index.d.ts +36 -9
  70. package/out/index-store/workspace-index.js +223 -120
  71. package/out/index-store/workspace-index.js.map +1 -1
  72. package/out/index.d.ts +16 -39
  73. package/out/index.js +9 -23
  74. package/out/index.js.map +1 -1
  75. package/out/native/generated.d.ts +102 -0
  76. package/out/native/generated.js +4 -0
  77. package/out/native/generated.js.map +1 -0
  78. package/out/native/index.d.ts +17 -0
  79. package/out/native/index.js +12 -0
  80. package/out/native/index.js.map +1 -0
  81. package/out/native/load-native.d.ts +50 -0
  82. package/out/native/load-native.js +152 -0
  83. package/out/native/load-native.js.map +1 -0
  84. package/out/{analysis-api.d.ts → native/native-analysis-api.d.ts} +24 -20
  85. package/out/native/native-analysis-api.js +212 -0
  86. package/out/native/native-analysis-api.js.map +1 -0
  87. package/out/native/native-index-store.d.ts +5 -0
  88. package/out/native/native-index-store.js +6 -0
  89. package/out/native/native-index-store.js.map +1 -0
  90. package/out/native/native-sql-db.d.ts +135 -0
  91. package/out/native/native-sql-db.js +217 -0
  92. package/out/native/native-sql-db.js.map +1 -0
  93. package/out/native/native-workspace-index.d.ts +164 -0
  94. package/out/native/native-workspace-index.js +283 -0
  95. package/out/native/native-workspace-index.js.map +1 -0
  96. package/out/native/open-analysis-api.d.ts +16 -0
  97. package/out/native/open-analysis-api.js +21 -0
  98. package/out/native/open-analysis-api.js.map +1 -0
  99. package/out/native/parse-source.d.ts +24 -0
  100. package/out/native/parse-source.js +26 -0
  101. package/out/native/parse-source.js.map +1 -0
  102. package/package.json +18 -22
  103. package/out/analysis/analyser-registry.d.ts +0 -21
  104. package/out/analysis/analyser-registry.js +0 -33
  105. package/out/analysis/analyser-registry.js.map +0 -1
  106. package/out/analysis/completion-tracking-analyser.d.ts +0 -3
  107. package/out/analysis/completion-tracking-analyser.js +0 -37
  108. package/out/analysis/completion-tracking-analyser.js.map +0 -1
  109. package/out/analysis/deprecation-impact-analyser.d.ts +0 -3
  110. package/out/analysis/deprecation-impact-analyser.js +0 -21
  111. package/out/analysis/deprecation-impact-analyser.js.map +0 -1
  112. package/out/analysis/file-related-analyser.d.ts +0 -5
  113. package/out/analysis/file-related-analyser.js +0 -41
  114. package/out/analysis/file-related-analyser.js.map +0 -1
  115. package/out/analysis/fuzzy-search-analyser.d.ts +0 -17
  116. package/out/analysis/fuzzy-search-analyser.js +0 -25
  117. package/out/analysis/fuzzy-search-analyser.js.map +0 -1
  118. package/out/analysis/fuzzy-search-worker-client.d.ts +0 -39
  119. package/out/analysis/fuzzy-search-worker-client.js +0 -178
  120. package/out/analysis/fuzzy-search-worker-client.js.map +0 -1
  121. package/out/analysis/fuzzy-search-worker.d.ts +0 -32
  122. package/out/analysis/fuzzy-search-worker.js +0 -81
  123. package/out/analysis/fuzzy-search-worker.js.map +0 -1
  124. package/out/analysis/fuzzy-search.d.ts +0 -38
  125. package/out/analysis/fuzzy-search.js +0 -217
  126. package/out/analysis/fuzzy-search.js.map +0 -1
  127. package/out/analysis/git-dates-analyser.d.ts +0 -9
  128. package/out/analysis/git-dates-analyser.js +0 -77
  129. package/out/analysis/git-dates-analyser.js.map +0 -1
  130. package/out/analysis/list-ideas-analyser.d.ts +0 -3
  131. package/out/analysis/list-ideas-analyser.js +0 -7
  132. package/out/analysis/list-ideas-analyser.js.map +0 -1
  133. package/out/analysis/local-graph-analyser.d.ts +0 -6
  134. package/out/analysis/local-graph-analyser.js +0 -42
  135. package/out/analysis/local-graph-analyser.js.map +0 -1
  136. package/out/analysis/semantic-search-analyser.d.ts +0 -8
  137. package/out/analysis/semantic-search-analyser.js +0 -51
  138. package/out/analysis/semantic-search-analyser.js.map +0 -1
  139. package/out/analysis-api.js +0 -190
  140. package/out/analysis-api.js.map +0 -1
  141. package/out/core/analytical-store.d.ts +0 -85
  142. package/out/core/analytical-store.js +0 -143
  143. package/out/core/analytical-store.js.map +0 -1
  144. package/out/core/context-model.d.ts +0 -204
  145. package/out/core/context-model.js +0 -36
  146. package/out/core/context-model.js.map +0 -1
  147. package/out/core/context-signals.d.ts +0 -149
  148. package/out/core/context-signals.js +0 -397
  149. package/out/core/context-signals.js.map +0 -1
  150. package/out/create-runtime.d.ts +0 -47
  151. package/out/create-runtime.js +0 -79
  152. package/out/create-runtime.js.map +0 -1
  153. package/out/export/export-html.d.ts +0 -4
  154. package/out/export/export-html.js +0 -12
  155. package/out/export/export-html.js.map +0 -1
  156. package/out/export/html-export-assets.d.ts +0 -3
  157. package/out/export/html-export-assets.js +0 -1926
  158. package/out/export/html-export-assets.js.map +0 -1
  159. package/out/export/html-export-template.d.ts +0 -18
  160. package/out/export/html-export-template.js +0 -1139
  161. package/out/export/html-export-template.js.map +0 -1
  162. package/out/export/html-export-utils.d.ts +0 -86
  163. package/out/export/html-export-utils.js +0 -485
  164. package/out/export/html-export-utils.js.map +0 -1
  165. package/out/export/write-html-export.d.ts +0 -2
  166. package/out/export/write-html-export.js +0 -181
  167. package/out/export/write-html-export.js.map +0 -1
  168. package/out/graph/physics-core-source.d.ts +0 -5
  169. package/out/graph/physics-core-source.js +0 -8
  170. package/out/graph/physics-core-source.js.map +0 -1
  171. package/out/graph/physics-core.d.ts +0 -141
  172. package/out/graph/physics-core.js +0 -237
  173. package/out/graph/physics-core.js.map +0 -1
  174. package/out/index-store/idea-extractor.d.ts +0 -11
  175. package/out/index-store/idea-extractor.js +0 -351
  176. package/out/index-store/idea-extractor.js.map +0 -1
  177. package/out/index-store/overview-coverage.d.ts +0 -23
  178. package/out/index-store/overview-coverage.js +0 -254
  179. package/out/index-store/overview-coverage.js.map +0 -1
@@ -0,0 +1,212 @@
1
+ import { loadNativeEngine } from './load-native.js';
2
+ export class NativeAnalysisApi {
3
+ constructor(options) {
4
+ const engine = loadNativeEngine();
5
+ this.native = engine.NativeAnalysisRuntime.open(options.workspaceRoot, options.storagePath);
6
+ }
7
+ async ensureReady() {
8
+ this.native.ensureReady();
9
+ }
10
+ async searchRequirements(query, limit = 8, options) {
11
+ const matches = this.native.searchRequirements(query, limit, options?.context);
12
+ return matches.map(match => ({
13
+ idea: toIdea(match.idea),
14
+ score: match.score ?? undefined,
15
+ reasons: match.reasons ?? undefined
16
+ }));
17
+ }
18
+ async listRequirements(limit = 50) {
19
+ return this.native.listRequirements(limit).map(toIdea);
20
+ }
21
+ async getFileContext(filePath) {
22
+ const related = this.native.getFileContext(filePath);
23
+ return {
24
+ fileUri: related.fileUri,
25
+ ideasInFile: related.ideasInFile.map(toIdea),
26
+ referencingIdeas: related.referencingIdeas.map(toIdea),
27
+ commentLinkedIdeas: related.commentLinkedIdeas.map(toIdea),
28
+ folderReferencingIdeas: related.folderReferencingIdeas.map(toIdea)
29
+ };
30
+ }
31
+ async getLocalGraph(filePath, depth = 1) {
32
+ const graph = this.native.getLocalGraph(filePath, depth);
33
+ return graph ? toGraph(graph) : undefined;
34
+ }
35
+ async summarizeSubtree(requirementName, depth = 2) {
36
+ const graph = this.native.summarizeSubtree(requirementName, depth);
37
+ return graph ? toGraph(graph) : undefined;
38
+ }
39
+ async getCompletionStatus() {
40
+ const summary = this.native.getCompletionStatus();
41
+ return {
42
+ total: summary.total,
43
+ byStatus: toCountRecord(summary.byStatus),
44
+ byTag: toCountRecord(summary.byTag),
45
+ outstanding: summary.outstanding.map(toIdea),
46
+ deprecated: summary.deprecated.map(toIdea)
47
+ };
48
+ }
49
+ async getDeprecationImpact() {
50
+ const impacts = this.native.getDeprecationImpact();
51
+ return impacts.map(impact => ({
52
+ deprecated: toIdea(impact.deprecated),
53
+ dependents: impact.dependents.map(toIdea)
54
+ }));
55
+ }
56
+ async exportHtml(request, _onProgress) {
57
+ return this.exportFormat('html', request);
58
+ }
59
+ async exportMarkdown(request, _onProgress) {
60
+ return this.exportFormat('markdown', request);
61
+ }
62
+ async exportJson(request, _onProgress) {
63
+ return this.exportFormat('json', request);
64
+ }
65
+ async exportCsv(request, _onProgress) {
66
+ return this.exportFormat('csv', request);
67
+ }
68
+ async resolveRequirementReference(name) {
69
+ return this.native.resolveRequirementReference(name).map(toIdea);
70
+ }
71
+ async resolveFileReference(pathPrefix) {
72
+ return this.native.resolveFileReference(pathPrefix);
73
+ }
74
+ listInteractions() {
75
+ return [
76
+ {
77
+ name: 'search_requirements',
78
+ description: 'Search requirements by keyword across names, summaries, tags, and references.',
79
+ parameters: { query: 'Search text', limit: 'Optional maximum number of matches' }
80
+ },
81
+ {
82
+ name: 'list_requirements',
83
+ description: 'List indexed requirements in the workspace.',
84
+ parameters: { limit: 'Optional maximum number of requirements' }
85
+ },
86
+ {
87
+ name: 'file_context',
88
+ description: 'Get requirements in, referencing, or comment-linked to a file.',
89
+ parameters: { filePath: 'Relative or absolute path to a .rq file' }
90
+ },
91
+ {
92
+ name: 'local_graph',
93
+ description: 'Get the local requirement graph around the first requirement in a file.',
94
+ parameters: { filePath: 'Relative or absolute path to a .rq file', depth: 'Optional hop depth' }
95
+ },
96
+ {
97
+ name: 'summarize_subtree',
98
+ description: 'Summarise a requirement subtree rooted at a named requirement.',
99
+ parameters: { requirementName: 'Requirement name or search text', depth: 'Optional hop depth' }
100
+ },
101
+ {
102
+ name: 'requirement_reference',
103
+ description: 'Resolve a requirement by name for compact chat or MCP context.',
104
+ parameters: { name: 'Optional requirement name or search text' }
105
+ },
106
+ {
107
+ name: 'file_reference',
108
+ description: 'Resolve requirements indexed in matching .rq files.',
109
+ parameters: { path: 'Optional path fragment filter' }
110
+ },
111
+ {
112
+ name: 'completion_status',
113
+ description: 'Summarise completion and deprecation status across the workspace graph.',
114
+ parameters: {}
115
+ },
116
+ {
117
+ name: 'export_html',
118
+ description: 'Export the requirement graph as a multi-file static HTML site.',
119
+ parameters: {
120
+ outputDir: 'Parent directory for the export folder',
121
+ exportName: 'Export folder name',
122
+ excludeSecretFiles: 'Optional: omit *.secret.rq files',
123
+ excludeIgnoredFiles: 'Optional: omit .rqignore-matched files'
124
+ }
125
+ },
126
+ {
127
+ name: 'list_interactions',
128
+ description: 'Discover available requirement graph interactions and parameters.',
129
+ parameters: {}
130
+ }
131
+ ];
132
+ }
133
+ formatIdea(idea) {
134
+ const location = `${idea.fileUri}:${idea.lineStart + 1}`;
135
+ const tags = idea.tags.length > 0 ? `\nTags: ${idea.tags.join(', ')}` : '';
136
+ const status = idea.status ? `\nStatus: ${idea.status}` : '';
137
+ return `### ${idea.name} (${location})\n${idea.summary || '(no summary)'}${status}${tags}`;
138
+ }
139
+ exportFormat(format, request) {
140
+ const dto = {
141
+ format,
142
+ outputDir: request.outputDir,
143
+ exportName: request.exportName,
144
+ workspaceRoot: request.workspaceRoot,
145
+ templateId: request.templateId,
146
+ scope: request.scope,
147
+ sourceFileUri: request.sourceFileUri,
148
+ includeRequirementsPage: request.includeRequirementsPage ?? false,
149
+ includeGraphPage: request.includeGraphPage ?? false,
150
+ printEntryFileName: request.printEntryFileName,
151
+ excludeSecretFiles: request.excludeSecretFiles ?? false,
152
+ excludeIgnoredFiles: request.excludeIgnoredFiles ?? false,
153
+ runtimeMode: request.runtimeMode,
154
+ clusterStrategy: request.clusterStrategy,
155
+ includeIdeaPages: request.includeIdeaPages ?? true,
156
+ includeFilePages: request.includeFilePages ?? true,
157
+ includeCodeFilePages: request.includeCodeFilePages ?? true,
158
+ includeClusterPages: request.includeClusterPages ?? true,
159
+ includeAttributePages: request.includeAttributePages ?? true,
160
+ includePrintPages: request.includePrintPages ?? true,
161
+ maxGraphNodes: request.maxGraphNodes,
162
+ urlBase: request.urlBase,
163
+ headerLink: request.headerLink
164
+ };
165
+ const result = this.native.exportGraph(dto);
166
+ return {
167
+ outputDir: result.outputDir,
168
+ indexFilePath: result.indexFilePath,
169
+ printFilePath: result.printFilePath,
170
+ dataFilePath: result.dataFilePath
171
+ };
172
+ }
173
+ }
174
+ function toCountRecord(counts) {
175
+ const result = {};
176
+ for (const [key, value] of Object.entries(counts ?? {})) {
177
+ if (typeof value === 'number') {
178
+ result[key] = value;
179
+ }
180
+ }
181
+ return result;
182
+ }
183
+ function toIdea(idea) {
184
+ return {
185
+ id: idea.id,
186
+ name: idea.name,
187
+ kind: idea.kind,
188
+ fileUri: idea.fileUri,
189
+ lineStart: idea.lineStart,
190
+ summary: idea.summary,
191
+ status: idea.status ?? undefined,
192
+ statusKey: idea.statusKey,
193
+ tags: idea.tags,
194
+ tagsKeys: idea.tagsKeys
195
+ };
196
+ }
197
+ function toGraph(graph) {
198
+ return {
199
+ centerId: graph.centerId,
200
+ depth: graph.depth,
201
+ nodes: graph.nodes.map(toIdea),
202
+ edges: graph.edges.map(edge => ({
203
+ id: edge.id,
204
+ sourceId: edge.sourceId,
205
+ targetId: edge.targetId ?? undefined,
206
+ targetFile: edge.targetFile ?? undefined,
207
+ kind: edge.kind,
208
+ label: edge.label ?? undefined
209
+ }))
210
+ };
211
+ }
212
+ //# sourceMappingURL=native-analysis-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-analysis-api.js","sourceRoot":"","sources":["../../src/native/native-analysis-api.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAoC,MAAM,kBAAkB,CAAC;AAkCtF,MAAM,OAAO,iBAAiB;IAG1B,YAAY,OAA+B;QACvC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAChG,CAAC;IAED,KAAK,CAAC,WAAW;QACb,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,kBAAkB,CACpB,KAAa,EACb,KAAK,GAAG,CAAC,EACT,OAAmC;QAEnC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAA6B,CAAC;QAC3G,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACzB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS;YAC/B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,SAAS;SACtC,CAAC,CAAC,CAAC;IACR,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,KAAK,GAAG,EAAE;QAC7B,OAAQ,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAyB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpF,CAAC;IAED,KAAK,CAA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AI;QACf,IAAI,EAAE,IAAI,CAAC,IAA2B;QACtC,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;QAChC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;KAC1B,CAAC;AACN,CAAC;AAED,SAAS,OAAO,CAAC,KAAuB;IACpC,OAAO;QACH,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;QAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,SAAS;YACpC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;YACxC,IAAI,EAAE,IAAI,CAAC,IAA2C;YACtD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;SACjC,CAAC,CAAC;KACN,CAAC;AACN,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Native-backed index store facade (SqliteIndexStore over rusqlite via napi).
3
+ * rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
4
+ */
5
+ export { SqliteIndexStore as NativeIndexStore } from '../index-store/sqlite-store.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Native-backed index store facade (SqliteIndexStore over rusqlite via napi).
3
+ * rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
4
+ */
5
+ export { SqliteIndexStore as NativeIndexStore } from '../index-store/sqlite-store.js';
6
+ //# sourceMappingURL=native-index-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-index-store.js","sourceRoot":"","sources":["../../src/native/native-index-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,135 @@
1
+ import type { NativeWorkspaceIndex } from './native-workspace-index.js';
2
+ /**
3
+ * Typed webview table/graph query surface implemented natively (reqlan-index queries.rs).
4
+ * Returns raw SQL rows; TS presentation mappers shape them into view rows.
5
+ */
6
+ /** Outbound + inbound raw reference rows for a single idea (both joined to ideas). */
7
+ export interface NativeReferenceBundle {
8
+ outbound: Record<string, unknown>[];
9
+ inbound: Record<string, unknown>[];
10
+ }
11
+ export interface NativeQuerySurface {
12
+ countIdeas(query: unknown): number;
13
+ listIdeasPageRows(query: unknown): Record<string, unknown>[];
14
+ listReferenceChipRows(ideaIds: string[]): Record<string, unknown>[];
15
+ countIdeasets(query: unknown): number;
16
+ listIdeasetsPageRows(query: unknown): Record<string, unknown>[];
17
+ listIdeasetMemberRows(ideasetId: string, kind: string, fileUri: string): Record<string, unknown>[];
18
+ countReferences(query: unknown): number;
19
+ listReferencesPageRows(query: unknown): Record<string, unknown>[];
20
+ listTodoIdeaRows(): Record<string, unknown>[];
21
+ listIdeasForGraphQuery(query: unknown, limit: number): {
22
+ rows: Record<string, unknown>[];
23
+ totalMatching: number;
24
+ };
25
+ listRecentGitIdeaRows(limit: number): Record<string, unknown>[];
26
+ listIdeaIdsMissingGitDates(limit: number, fileUri?: string, preferFileUri?: string): string[];
27
+ listAttributeIdeaRows(): Record<string, unknown>[];
28
+ migrateIdeasSchema(): void;
29
+ getDocumentHash(fileUri: string): string | null;
30
+ getDocumentMtimeMs(fileUri: string): number | null;
31
+ listDocumentMtimeRows(): Record<string, unknown>[];
32
+ listDocumentUris(): string[];
33
+ listAllIdeaRows(): Record<string, unknown>[];
34
+ getIdeaRow(id: string): Record<string, unknown> | null;
35
+ getIdeasInFileRows(fileUri: string): Record<string, unknown>[];
36
+ getIdeaAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
37
+ getIdeasetAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
38
+ listIdeasInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
39
+ listIdeasetsInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
40
+ getIdeasByIdsRows(ids: string[]): Record<string, unknown>[];
41
+ searchIdeaRows(search: string): Record<string, unknown>[];
42
+ listReferencesForIdea(ideaId: string): NativeReferenceBundle;
43
+ countUnresolvedForIdea(ideaId: string): number;
44
+ countEdgesFromFile(fileUri: string): number;
45
+ getEdgesFromRows(sourceId: string): Record<string, unknown>[];
46
+ getEdgesToRows(targetId: string): Record<string, unknown>[];
47
+ getEdgesForNodesRows(nodeIds: string[]): Record<string, unknown>[];
48
+ getEdgesReferencingFileRows(filePath: string): Record<string, unknown>[];
49
+ getAllEdgeRows(): Record<string, unknown>[];
50
+ listFileReferenceTargetRows(): Record<string, unknown>[];
51
+ allIdeaRawRows(): Record<string, unknown>[];
52
+ counts(): {
53
+ ideas: number;
54
+ edges: number;
55
+ };
56
+ updateDocumentMtime(fileUri: string, mtimeMs: number): void;
57
+ updateGitDates(id: string, createdAt?: string, modifiedAt?: string, changeCount?: number): void;
58
+ clearAll(): void;
59
+ removeDocuments(fileUris: string[]): void;
60
+ upsertDocument(fileUri: string, contentHash: string, ideas: unknown, edges: unknown, mtimeMs?: number): void;
61
+ }
62
+ export interface NativeSqlDbHandle extends NativeQuerySurface {
63
+ query(sql: string, params?: unknown[]): Record<string, unknown>[];
64
+ execute(sql: string, params?: unknown[]): number;
65
+ executeBatch(sql: string): void;
66
+ lastInsertRowid(): number;
67
+ close(): void;
68
+ }
69
+ export declare class NativeSqlConnection {
70
+ private readonly handle;
71
+ readonly dbPath: string;
72
+ private readonly ownsHandle;
73
+ private constructor();
74
+ static open(dbPath: string): Promise<NativeSqlConnection>;
75
+ /** Share the ideas DB connection owned by a NativeWorkspaceIndex (single writer). */
76
+ static fromWorkspaceIdeas(native: NativeWorkspaceIndex, dbPath: string): NativeSqlConnection;
77
+ /** Share the diagnostics DB connection owned by a NativeWorkspaceIndex. */
78
+ static fromWorkspaceDiagnostics(native: NativeWorkspaceIndex, dbPath: string): NativeSqlConnection;
79
+ run(sql: string, ...params: unknown[]): void;
80
+ exec(sql: string): void;
81
+ all<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, ...params: unknown[]): T[];
82
+ get<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, ...params: unknown[]): T | undefined;
83
+ lastInsertRowid(): number;
84
+ countIdeas(query: unknown): number;
85
+ listIdeasPageRows(query: unknown): Record<string, unknown>[];
86
+ listReferenceChipRows(ideaIds: string[]): Record<string, unknown>[];
87
+ countIdeasets(query: unknown): number;
88
+ listIdeasetsPageRows(query: unknown): Record<string, unknown>[];
89
+ listIdeasetMemberRows(ideasetId: string, kind: string, fileUri: string): Record<string, unknown>[];
90
+ countReferences(query: unknown): number;
91
+ listReferencesPageRows(query: unknown): Record<string, unknown>[];
92
+ listTodoIdeaRows(): Record<string, unknown>[];
93
+ listIdeasForGraphQuery(query: unknown, limit: number): {
94
+ rows: Record<string, unknown>[];
95
+ totalMatching: number;
96
+ };
97
+ listRecentGitIdeaRows(limit: number): Record<string, unknown>[];
98
+ listIdeaIdsMissingGitDates(limit: number, fileUri?: string, preferFileUri?: string): string[];
99
+ listAttributeIdeaRows(): Record<string, unknown>[];
100
+ migrateIdeasSchema(): void;
101
+ getDocumentHash(fileUri: string): string | null;
102
+ getDocumentMtimeMs(fileUri: string): number | null;
103
+ listDocumentMtimeRows(): Record<string, unknown>[];
104
+ listDocumentUris(): string[];
105
+ listAllIdeaRows(): Record<string, unknown>[];
106
+ getIdeaRow(id: string): Record<string, unknown> | null;
107
+ getIdeasInFileRows(fileUri: string): Record<string, unknown>[];
108
+ getIdeaAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
109
+ getIdeasetAtLineRow(fileUri: string, line: number): Record<string, unknown> | null;
110
+ listIdeasInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
111
+ listIdeasetsInFileWithRangeRows(fileUri: string): Record<string, unknown>[];
112
+ getIdeasByIdsRows(ids: string[]): Record<string, unknown>[];
113
+ searchIdeaRows(search: string): Record<string, unknown>[];
114
+ listReferencesForIdea(ideaId: string): NativeReferenceBundle;
115
+ countUnresolvedForIdea(ideaId: string): number;
116
+ countEdgesFromFile(fileUri: string): number;
117
+ getEdgesFromRows(sourceId: string): Record<string, unknown>[];
118
+ getEdgesToRows(targetId: string): Record<string, unknown>[];
119
+ getEdgesForNodesRows(nodeIds: string[]): Record<string, unknown>[];
120
+ getEdgesReferencingFileRows(filePath: string): Record<string, unknown>[];
121
+ getAllEdgeRows(): Record<string, unknown>[];
122
+ listFileReferenceTargetRows(): Record<string, unknown>[];
123
+ allIdeaRawRows(): Record<string, unknown>[];
124
+ counts(): {
125
+ ideas: number;
126
+ edges: number;
127
+ };
128
+ updateDocumentMtime(fileUri: string, mtimeMs: number): void;
129
+ updateGitDates(id: string, createdAt?: string, modifiedAt?: string, changeCount?: number): void;
130
+ clearAll(): void;
131
+ removeDocuments(fileUris: string[]): void;
132
+ upsertDocument(fileUri: string, contentHash: string, ideas: unknown, edges: unknown, mtimeMs?: number): void;
133
+ assertHealthy(): void;
134
+ close(): void;
135
+ }
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Thin TS wrapper around napi SQL surfaces (NativeSqlDb or NativeWorkspaceIndex).
3
+ * rq:["../../../reqlan rq/core_analysis/rust_port.rq".native_bridge]
4
+ */
5
+ import { mkdir } from 'node:fs/promises';
6
+ import { statSync } from 'node:fs';
7
+ import { dirname } from 'node:path';
8
+ import { loadNativeEngine } from './load-native.js';
9
+ function toJsonParams(params) {
10
+ return params.map(value => (value === undefined ? null : value));
11
+ }
12
+ export class NativeSqlConnection {
13
+ constructor(handle, dbPath, ownsHandle) {
14
+ this.handle = handle;
15
+ this.dbPath = dbPath;
16
+ this.ownsHandle = ownsHandle;
17
+ }
18
+ static async open(dbPath) {
19
+ await mkdir(dirname(dbPath), { recursive: true });
20
+ const engine = loadNativeEngine();
21
+ if (!engine.NativeSqlDb) {
22
+ throw new Error('NativeSqlDb is missing from the native engine; rebuild reqlan-napi.');
23
+ }
24
+ const conn = new NativeSqlConnection(engine.NativeSqlDb.open(dbPath), dbPath, true);
25
+ conn.assertHealthy();
26
+ return conn;
27
+ }
28
+ /** Share the ideas DB connection owned by a NativeWorkspaceIndex (single writer). */
29
+ static fromWorkspaceIdeas(native, dbPath) {
30
+ return new NativeSqlConnection(native.ideasSqlHandle(), dbPath, false);
31
+ }
32
+ /** Share the diagnostics DB connection owned by a NativeWorkspaceIndex. */
33
+ static fromWorkspaceDiagnostics(native, dbPath) {
34
+ return new NativeSqlConnection(native.diagnosticsSqlHandle(), dbPath, false);
35
+ }
36
+ run(sql, ...params) {
37
+ this.handle.execute(sql, toJsonParams(params));
38
+ }
39
+ exec(sql) {
40
+ this.handle.executeBatch(sql);
41
+ }
42
+ all(sql, ...params) {
43
+ return this.handle.query(sql, toJsonParams(params));
44
+ }
45
+ get(sql, ...params) {
46
+ return this.all(sql, ...params)[0];
47
+ }
48
+ lastInsertRowid() {
49
+ return this.handle.lastInsertRowid();
50
+ }
51
+ // ---- typed webview table/graph query surface (native SQL builders) ----------
52
+ countIdeas(query) {
53
+ return this.handle.countIdeas(query);
54
+ }
55
+ listIdeasPageRows(query) {
56
+ return this.handle.listIdeasPageRows(query);
57
+ }
58
+ listReferenceChipRows(ideaIds) {
59
+ return this.handle.listReferenceChipRows(ideaIds);
60
+ }
61
+ countIdeasets(query) {
62
+ return this.handle.countIdeasets(query);
63
+ }
64
+ listIdeasetsPageRows(query) {
65
+ return this.handle.listIdeasetsPageRows(query);
66
+ }
67
+ listIdeasetMemberRows(ideasetId, kind, fileUri) {
68
+ return this.handle.listIdeasetMemberRows(ideasetId, kind, fileUri);
69
+ }
70
+ countReferences(query) {
71
+ return this.handle.countReferences(query);
72
+ }
73
+ listReferencesPageRows(query) {
74
+ return this.handle.listReferencesPageRows(query);
75
+ }
76
+ listTodoIdeaRows() {
77
+ return this.handle.listTodoIdeaRows();
78
+ }
79
+ listIdeasForGraphQuery(query, limit) {
80
+ return this.handle.listIdeasForGraphQuery(query, limit);
81
+ }
82
+ listRecentGitIdeaRows(limit) {
83
+ return this.handle.listRecentGitIdeaRows(limit);
84
+ }
85
+ listIdeaIdsMissingGitDates(limit, fileUri, preferFileUri) {
86
+ return this.handle.listIdeaIdsMissingGitDates(limit, fileUri, preferFileUri);
87
+ }
88
+ listAttributeIdeaRows() {
89
+ return this.handle.listAttributeIdeaRows();
90
+ }
91
+ // ---- typed domain read/write surface (native SQL) ---------------------------
92
+ migrateIdeasSchema() {
93
+ this.handle.migrateIdeasSchema();
94
+ }
95
+ getDocumentHash(fileUri) {
96
+ return this.handle.getDocumentHash(fileUri);
97
+ }
98
+ getDocumentMtimeMs(fileUri) {
99
+ return this.handle.getDocumentMtimeMs(fileUri);
100
+ }
101
+ listDocumentMtimeRows() {
102
+ return this.handle.listDocumentMtimeRows();
103
+ }
104
+ listDocumentUris() {
105
+ return this.handle.listDocumentUris();
106
+ }
107
+ listAllIdeaRows() {
108
+ return this.handle.listAllIdeaRows();
109
+ }
110
+ getIdeaRow(id) {
111
+ return this.handle.getIdeaRow(id);
112
+ }
113
+ getIdeasInFileRows(fileUri) {
114
+ return this.handle.getIdeasInFileRows(fileUri);
115
+ }
116
+ getIdeaAtLineRow(fileUri, line) {
117
+ return this.handle.getIdeaAtLineRow(fileUri, line);
118
+ }
119
+ getIdeasetAtLineRow(fileUri, line) {
120
+ return this.handle.getIdeasetAtLineRow(fileUri, line);
121
+ }
122
+ listIdeasInFileWithRangeRows(fileUri) {
123
+ return this.handle.listIdeasInFileWithRangeRows(fileUri);
124
+ }
125
+ listIdeasetsInFileWithRangeRows(fileUri) {
126
+ return this.handle.listIdeasetsInFileWithRangeRows(fileUri);
127
+ }
128
+ getIdeasByIdsRows(ids) {
129
+ return this.handle.getIdeasByIdsRows(ids);
130
+ }
131
+ searchIdeaRows(search) {
132
+ return this.handle.searchIdeaRows(search);
133
+ }
134
+ listReferencesForIdea(ideaId) {
135
+ return this.handle.listReferencesForIdea(ideaId);
136
+ }
137
+ countUnresolvedForIdea(ideaId) {
138
+ return this.handle.countUnresolvedForIdea(ideaId);
139
+ }
140
+ countEdgesFromFile(fileUri) {
141
+ return this.handle.countEdgesFromFile(fileUri);
142
+ }
143
+ getEdgesFromRows(sourceId) {
144
+ return this.handle.getEdgesFromRows(sourceId);
145
+ }
146
+ getEdgesToRows(targetId) {
147
+ return this.handle.getEdgesToRows(targetId);
148
+ }
149
+ getEdgesForNodesRows(nodeIds) {
150
+ return this.handle.getEdgesForNodesRows(nodeIds);
151
+ }
152
+ getEdgesReferencingFileRows(filePath) {
153
+ return this.handle.getEdgesReferencingFileRows(filePath);
154
+ }
155
+ getAllEdgeRows() {
156
+ return this.handle.getAllEdgeRows();
157
+ }
158
+ listFileReferenceTargetRows() {
159
+ return this.handle.listFileReferenceTargetRows();
160
+ }
161
+ allIdeaRawRows() {
162
+ return this.handle.allIdeaRawRows();
163
+ }
164
+ counts() {
165
+ return this.handle.counts();
166
+ }
167
+ updateDocumentMtime(fileUri, mtimeMs) {
168
+ this.handle.updateDocumentMtime(fileUri, mtimeMs);
169
+ }
170
+ updateGitDates(id, createdAt, modifiedAt, changeCount) {
171
+ this.handle.updateGitDates(id, createdAt, modifiedAt, changeCount);
172
+ }
173
+ clearAll() {
174
+ this.handle.clearAll();
175
+ }
176
+ removeDocuments(fileUris) {
177
+ this.handle.removeDocuments(fileUris);
178
+ }
179
+ upsertDocument(fileUri, contentHash, ideas, edges, mtimeMs) {
180
+ this.handle.upsertDocument(fileUri, contentHash, ideas, edges, mtimeMs);
181
+ }
182
+ assertHealthy() {
183
+ const rows = this.all('PRAGMA integrity_check');
184
+ if (rows.length === 0) {
185
+ throw new Error('database disk image is malformed: integrity_check returned no rows');
186
+ }
187
+ for (const row of rows) {
188
+ const result = String(row.integrity_check ?? row.quick_check ?? Object.values(row)[0] ?? '');
189
+ if (result && result.toLowerCase() !== 'ok') {
190
+ throw new Error(`database disk image is malformed: ${result}`);
191
+ }
192
+ }
193
+ const pageCountRow = this.get('PRAGMA page_count');
194
+ const pageSizeRow = this.get('PRAGMA page_size');
195
+ const pageCount = Number(pageCountRow?.page_count ?? Object.values(pageCountRow ?? {})[0] ?? 0);
196
+ const pageSize = Number(pageSizeRow?.page_size ?? Object.values(pageSizeRow ?? {})[0] ?? 0);
197
+ if (pageCount > 0 && pageSize > 0) {
198
+ try {
199
+ const size = statSync(this.dbPath).size;
200
+ if (size < pageCount * pageSize) {
201
+ throw new Error(`database disk image is malformed: file truncated (${size} bytes, expected ${pageCount * pageSize})`);
202
+ }
203
+ }
204
+ catch (error) {
205
+ if (error instanceof Error && /malformed/i.test(error.message)) {
206
+ throw error;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ close() {
212
+ if (this.ownsHandle) {
213
+ this.handle.close();
214
+ }
215
+ }
216
+ }
217
+ //# sourceMappingURL=native-sql-db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-sql-db.js","sourceRoot":"","sources":["../../src/native/native-sql-db.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA2FpD,SAAS,YAAY,CAAC,MAAiB;IACnC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,C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