@grafema/util 0.3.0-beta

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 (324) hide show
  1. package/LICENSE +190 -0
  2. package/dist/api/GraphAPI.d.ts +87 -0
  3. package/dist/api/GraphAPI.d.ts.map +1 -0
  4. package/dist/api/GraphAPI.js +212 -0
  5. package/dist/api/GraphAPI.js.map +1 -0
  6. package/dist/api/GuaranteeAPI.d.ts +147 -0
  7. package/dist/api/GuaranteeAPI.d.ts.map +1 -0
  8. package/dist/api/GuaranteeAPI.js +290 -0
  9. package/dist/api/GuaranteeAPI.js.map +1 -0
  10. package/dist/config/ConfigLoader.d.ts +214 -0
  11. package/dist/config/ConfigLoader.d.ts.map +1 -0
  12. package/dist/config/ConfigLoader.js +441 -0
  13. package/dist/config/ConfigLoader.js.map +1 -0
  14. package/dist/config/index.d.ts +6 -0
  15. package/dist/config/index.d.ts.map +1 -0
  16. package/dist/config/index.js +5 -0
  17. package/dist/config/index.js.map +1 -0
  18. package/dist/core/CoverageAnalyzer.d.ts +65 -0
  19. package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
  20. package/dist/core/CoverageAnalyzer.js +199 -0
  21. package/dist/core/CoverageAnalyzer.js.map +1 -0
  22. package/dist/core/FileExplainer.d.ts +101 -0
  23. package/dist/core/FileExplainer.d.ts.map +1 -0
  24. package/dist/core/FileExplainer.js +140 -0
  25. package/dist/core/FileExplainer.js.map +1 -0
  26. package/dist/core/FileOverview.d.ts +124 -0
  27. package/dist/core/FileOverview.d.ts.map +1 -0
  28. package/dist/core/FileOverview.js +279 -0
  29. package/dist/core/FileOverview.js.map +1 -0
  30. package/dist/core/GrafemaUri.d.ts +66 -0
  31. package/dist/core/GrafemaUri.d.ts.map +1 -0
  32. package/dist/core/GrafemaUri.js +191 -0
  33. package/dist/core/GrafemaUri.js.map +1 -0
  34. package/dist/core/GraphBackend.d.ts +158 -0
  35. package/dist/core/GraphBackend.d.ts.map +1 -0
  36. package/dist/core/GraphBackend.js +85 -0
  37. package/dist/core/GraphBackend.js.map +1 -0
  38. package/dist/core/GraphFreshnessChecker.d.ts +33 -0
  39. package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
  40. package/dist/core/GraphFreshnessChecker.js +104 -0
  41. package/dist/core/GraphFreshnessChecker.js.map +1 -0
  42. package/dist/core/GuaranteeManager.d.ts +254 -0
  43. package/dist/core/GuaranteeManager.d.ts.map +1 -0
  44. package/dist/core/GuaranteeManager.js +447 -0
  45. package/dist/core/GuaranteeManager.js.map +1 -0
  46. package/dist/core/HashUtils.d.ts +24 -0
  47. package/dist/core/HashUtils.d.ts.map +1 -0
  48. package/dist/core/HashUtils.js +46 -0
  49. package/dist/core/HashUtils.js.map +1 -0
  50. package/dist/core/IncrementalReanalyzer.d.ts +33 -0
  51. package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
  52. package/dist/core/IncrementalReanalyzer.js +67 -0
  53. package/dist/core/IncrementalReanalyzer.js.map +1 -0
  54. package/dist/core/ResourceRegistry.d.ts +17 -0
  55. package/dist/core/ResourceRegistry.d.ts.map +1 -0
  56. package/dist/core/ResourceRegistry.js +32 -0
  57. package/dist/core/ResourceRegistry.js.map +1 -0
  58. package/dist/core/SemanticId.d.ts +159 -0
  59. package/dist/core/SemanticId.d.ts.map +1 -0
  60. package/dist/core/SemanticId.js +291 -0
  61. package/dist/core/SemanticId.js.map +1 -0
  62. package/dist/core/VersionManager.d.ts +166 -0
  63. package/dist/core/VersionManager.d.ts.map +1 -0
  64. package/dist/core/VersionManager.js +239 -0
  65. package/dist/core/VersionManager.js.map +1 -0
  66. package/dist/core/brandNodeInternal.d.ts +14 -0
  67. package/dist/core/brandNodeInternal.d.ts.map +1 -0
  68. package/dist/core/brandNodeInternal.js +4 -0
  69. package/dist/core/brandNodeInternal.js.map +1 -0
  70. package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
  71. package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
  72. package/dist/core/nodes/GuaranteeNode.js +118 -0
  73. package/dist/core/nodes/GuaranteeNode.js.map +1 -0
  74. package/dist/core/nodes/IssueNode.d.ts +73 -0
  75. package/dist/core/nodes/IssueNode.d.ts.map +1 -0
  76. package/dist/core/nodes/IssueNode.js +130 -0
  77. package/dist/core/nodes/IssueNode.js.map +1 -0
  78. package/dist/core/nodes/NodeKind.d.ts +104 -0
  79. package/dist/core/nodes/NodeKind.d.ts.map +1 -0
  80. package/dist/core/nodes/NodeKind.js +166 -0
  81. package/dist/core/nodes/NodeKind.js.map +1 -0
  82. package/dist/diagnostics/DiagnosticCollector.d.ts +103 -0
  83. package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
  84. package/dist/diagnostics/DiagnosticCollector.js +133 -0
  85. package/dist/diagnostics/DiagnosticCollector.js.map +1 -0
  86. package/dist/diagnostics/DiagnosticReporter.d.ts +122 -0
  87. package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
  88. package/dist/diagnostics/DiagnosticReporter.js +300 -0
  89. package/dist/diagnostics/DiagnosticReporter.js.map +1 -0
  90. package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
  91. package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
  92. package/dist/diagnostics/DiagnosticWriter.js +44 -0
  93. package/dist/diagnostics/DiagnosticWriter.js.map +1 -0
  94. package/dist/diagnostics/categories.d.ts +57 -0
  95. package/dist/diagnostics/categories.d.ts.map +1 -0
  96. package/dist/diagnostics/categories.js +71 -0
  97. package/dist/diagnostics/categories.js.map +1 -0
  98. package/dist/diagnostics/index.d.ts +17 -0
  99. package/dist/diagnostics/index.d.ts.map +1 -0
  100. package/dist/diagnostics/index.js +15 -0
  101. package/dist/diagnostics/index.js.map +1 -0
  102. package/dist/errors/GrafemaError.d.ts +200 -0
  103. package/dist/errors/GrafemaError.d.ts.map +1 -0
  104. package/dist/errors/GrafemaError.js +209 -0
  105. package/dist/errors/GrafemaError.js.map +1 -0
  106. package/dist/index.d.ts +75 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +76 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/instructions/index.d.ts +8 -0
  111. package/dist/instructions/index.d.ts.map +1 -0
  112. package/dist/instructions/index.js +20 -0
  113. package/dist/instructions/index.js.map +1 -0
  114. package/dist/instructions/onboarding.md +133 -0
  115. package/dist/knowledge/KnowledgeBase.d.ts +113 -0
  116. package/dist/knowledge/KnowledgeBase.d.ts.map +1 -0
  117. package/dist/knowledge/KnowledgeBase.js +420 -0
  118. package/dist/knowledge/KnowledgeBase.js.map +1 -0
  119. package/dist/knowledge/SemanticAddressResolver.d.ts +59 -0
  120. package/dist/knowledge/SemanticAddressResolver.d.ts.map +1 -0
  121. package/dist/knowledge/SemanticAddressResolver.js +160 -0
  122. package/dist/knowledge/SemanticAddressResolver.js.map +1 -0
  123. package/dist/knowledge/git-ingest.d.ts +58 -0
  124. package/dist/knowledge/git-ingest.d.ts.map +1 -0
  125. package/dist/knowledge/git-ingest.js +301 -0
  126. package/dist/knowledge/git-ingest.js.map +1 -0
  127. package/dist/knowledge/git-queries.d.ts +86 -0
  128. package/dist/knowledge/git-queries.d.ts.map +1 -0
  129. package/dist/knowledge/git-queries.js +177 -0
  130. package/dist/knowledge/git-queries.js.map +1 -0
  131. package/dist/knowledge/index.d.ts +14 -0
  132. package/dist/knowledge/index.d.ts.map +1 -0
  133. package/dist/knowledge/index.js +10 -0
  134. package/dist/knowledge/index.js.map +1 -0
  135. package/dist/knowledge/parser.d.ts +39 -0
  136. package/dist/knowledge/parser.d.ts.map +1 -0
  137. package/dist/knowledge/parser.js +292 -0
  138. package/dist/knowledge/parser.js.map +1 -0
  139. package/dist/knowledge/types.d.ts +133 -0
  140. package/dist/knowledge/types.d.ts.map +1 -0
  141. package/dist/knowledge/types.js +8 -0
  142. package/dist/knowledge/types.js.map +1 -0
  143. package/dist/logging/Logger.d.ts +98 -0
  144. package/dist/logging/Logger.d.ts.map +1 -0
  145. package/dist/logging/Logger.js +274 -0
  146. package/dist/logging/Logger.js.map +1 -0
  147. package/dist/notation/archetypes.d.ts +36 -0
  148. package/dist/notation/archetypes.d.ts.map +1 -0
  149. package/dist/notation/archetypes.js +173 -0
  150. package/dist/notation/archetypes.js.map +1 -0
  151. package/dist/notation/fold.d.ts +25 -0
  152. package/dist/notation/fold.d.ts.map +1 -0
  153. package/dist/notation/fold.js +598 -0
  154. package/dist/notation/fold.js.map +1 -0
  155. package/dist/notation/index.d.ts +18 -0
  156. package/dist/notation/index.d.ts.map +1 -0
  157. package/dist/notation/index.js +16 -0
  158. package/dist/notation/index.js.map +1 -0
  159. package/dist/notation/lodExtractor.d.ts +32 -0
  160. package/dist/notation/lodExtractor.d.ts.map +1 -0
  161. package/dist/notation/lodExtractor.js +149 -0
  162. package/dist/notation/lodExtractor.js.map +1 -0
  163. package/dist/notation/nameShortener.d.ts +22 -0
  164. package/dist/notation/nameShortener.d.ts.map +1 -0
  165. package/dist/notation/nameShortener.js +24 -0
  166. package/dist/notation/nameShortener.js.map +1 -0
  167. package/dist/notation/perspectives.d.ts +11 -0
  168. package/dist/notation/perspectives.d.ts.map +1 -0
  169. package/dist/notation/perspectives.js +16 -0
  170. package/dist/notation/perspectives.js.map +1 -0
  171. package/dist/notation/renderer.d.ts +31 -0
  172. package/dist/notation/renderer.d.ts.map +1 -0
  173. package/dist/notation/renderer.js +315 -0
  174. package/dist/notation/renderer.js.map +1 -0
  175. package/dist/notation/traceRenderer.d.ts +39 -0
  176. package/dist/notation/traceRenderer.d.ts.map +1 -0
  177. package/dist/notation/traceRenderer.js +358 -0
  178. package/dist/notation/traceRenderer.js.map +1 -0
  179. package/dist/notation/types.d.ts +66 -0
  180. package/dist/notation/types.d.ts.map +1 -0
  181. package/dist/notation/types.js +10 -0
  182. package/dist/notation/types.js.map +1 -0
  183. package/dist/queries/NodeContext.d.ts +81 -0
  184. package/dist/queries/NodeContext.d.ts.map +1 -0
  185. package/dist/queries/NodeContext.js +196 -0
  186. package/dist/queries/NodeContext.js.map +1 -0
  187. package/dist/queries/findCallsInFunction.d.ts +62 -0
  188. package/dist/queries/findCallsInFunction.d.ts.map +1 -0
  189. package/dist/queries/findCallsInFunction.js +169 -0
  190. package/dist/queries/findCallsInFunction.js.map +1 -0
  191. package/dist/queries/findContainingFunction.d.ts +57 -0
  192. package/dist/queries/findContainingFunction.d.ts.map +1 -0
  193. package/dist/queries/findContainingFunction.js +91 -0
  194. package/dist/queries/findContainingFunction.js.map +1 -0
  195. package/dist/queries/index.d.ts +18 -0
  196. package/dist/queries/index.d.ts.map +1 -0
  197. package/dist/queries/index.js +14 -0
  198. package/dist/queries/index.js.map +1 -0
  199. package/dist/queries/traceDataflow.d.ts +65 -0
  200. package/dist/queries/traceDataflow.d.ts.map +1 -0
  201. package/dist/queries/traceDataflow.js +754 -0
  202. package/dist/queries/traceDataflow.js.map +1 -0
  203. package/dist/queries/traceValues.d.ts +70 -0
  204. package/dist/queries/traceValues.d.ts.map +1 -0
  205. package/dist/queries/traceValues.js +373 -0
  206. package/dist/queries/traceValues.js.map +1 -0
  207. package/dist/queries/types.d.ts +166 -0
  208. package/dist/queries/types.d.ts.map +1 -0
  209. package/dist/queries/types.js +10 -0
  210. package/dist/queries/types.js.map +1 -0
  211. package/dist/schema/GraphSchemaExtractor.d.ts +53 -0
  212. package/dist/schema/GraphSchemaExtractor.d.ts.map +1 -0
  213. package/dist/schema/GraphSchemaExtractor.js +125 -0
  214. package/dist/schema/GraphSchemaExtractor.js.map +1 -0
  215. package/dist/schema/InterfaceSchemaExtractor.d.ts +73 -0
  216. package/dist/schema/InterfaceSchemaExtractor.d.ts.map +1 -0
  217. package/dist/schema/InterfaceSchemaExtractor.js +113 -0
  218. package/dist/schema/InterfaceSchemaExtractor.js.map +1 -0
  219. package/dist/schema/index.d.ts +5 -0
  220. package/dist/schema/index.d.ts.map +1 -0
  221. package/dist/schema/index.js +3 -0
  222. package/dist/schema/index.js.map +1 -0
  223. package/dist/storage/backends/RFDBServerBackend.d.ts +356 -0
  224. package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
  225. package/dist/storage/backends/RFDBServerBackend.js +748 -0
  226. package/dist/storage/backends/RFDBServerBackend.js.map +1 -0
  227. package/dist/storage/backends/typeValidation.d.ts +47 -0
  228. package/dist/storage/backends/typeValidation.d.ts.map +1 -0
  229. package/dist/storage/backends/typeValidation.js +141 -0
  230. package/dist/storage/backends/typeValidation.js.map +1 -0
  231. package/dist/utils/findRfdbBinary.d.ts +67 -0
  232. package/dist/utils/findRfdbBinary.d.ts.map +1 -0
  233. package/dist/utils/findRfdbBinary.js +261 -0
  234. package/dist/utils/findRfdbBinary.js.map +1 -0
  235. package/dist/utils/lazyDownload.d.ts +43 -0
  236. package/dist/utils/lazyDownload.d.ts.map +1 -0
  237. package/dist/utils/lazyDownload.js +175 -0
  238. package/dist/utils/lazyDownload.js.map +1 -0
  239. package/dist/utils/moduleResolution.d.ts +134 -0
  240. package/dist/utils/moduleResolution.d.ts.map +1 -0
  241. package/dist/utils/moduleResolution.js +189 -0
  242. package/dist/utils/moduleResolution.js.map +1 -0
  243. package/dist/utils/resolveNodeFile.d.ts +13 -0
  244. package/dist/utils/resolveNodeFile.d.ts.map +1 -0
  245. package/dist/utils/resolveNodeFile.js +18 -0
  246. package/dist/utils/resolveNodeFile.js.map +1 -0
  247. package/dist/utils/startRfdbServer.d.ts +63 -0
  248. package/dist/utils/startRfdbServer.d.ts.map +1 -0
  249. package/dist/utils/startRfdbServer.js +142 -0
  250. package/dist/utils/startRfdbServer.js.map +1 -0
  251. package/dist/validation/PathValidator.d.ts +80 -0
  252. package/dist/validation/PathValidator.d.ts.map +1 -0
  253. package/dist/validation/PathValidator.js +252 -0
  254. package/dist/validation/PathValidator.js.map +1 -0
  255. package/dist/version.d.ts +11 -0
  256. package/dist/version.d.ts.map +1 -0
  257. package/dist/version.js +26 -0
  258. package/dist/version.js.map +1 -0
  259. package/package.json +50 -0
  260. package/src/api/GraphAPI.ts +307 -0
  261. package/src/api/GuaranteeAPI.ts +402 -0
  262. package/src/config/ConfigLoader.ts +653 -0
  263. package/src/config/index.ts +13 -0
  264. package/src/core/CoverageAnalyzer.ts +243 -0
  265. package/src/core/FileExplainer.ts +179 -0
  266. package/src/core/FileOverview.ts +397 -0
  267. package/src/core/GrafemaUri.ts +216 -0
  268. package/src/core/GraphBackend.ts +266 -0
  269. package/src/core/GraphFreshnessChecker.ts +145 -0
  270. package/src/core/GuaranteeManager.ts +684 -0
  271. package/src/core/HashUtils.ts +48 -0
  272. package/src/core/IncrementalReanalyzer.ts +106 -0
  273. package/src/core/ResourceRegistry.ts +39 -0
  274. package/src/core/SemanticId.ts +423 -0
  275. package/src/core/VersionManager.ts +405 -0
  276. package/src/core/brandNodeInternal.ts +16 -0
  277. package/src/core/nodes/GuaranteeNode.ts +162 -0
  278. package/src/core/nodes/IssueNode.ts +177 -0
  279. package/src/core/nodes/NodeKind.ts +192 -0
  280. package/src/diagnostics/DiagnosticCollector.ts +170 -0
  281. package/src/diagnostics/DiagnosticReporter.ts +395 -0
  282. package/src/diagnostics/DiagnosticWriter.ts +50 -0
  283. package/src/diagnostics/categories.ts +104 -0
  284. package/src/diagnostics/index.ts +30 -0
  285. package/src/errors/GrafemaError.ts +297 -0
  286. package/src/index.ts +261 -0
  287. package/src/instructions/index.ts +21 -0
  288. package/src/instructions/onboarding.md +133 -0
  289. package/src/knowledge/KnowledgeBase.ts +486 -0
  290. package/src/knowledge/SemanticAddressResolver.ts +191 -0
  291. package/src/knowledge/git-ingest.ts +402 -0
  292. package/src/knowledge/git-queries.ts +269 -0
  293. package/src/knowledge/index.ts +29 -0
  294. package/src/knowledge/parser.ts +294 -0
  295. package/src/knowledge/types.ts +146 -0
  296. package/src/logging/Logger.ts +303 -0
  297. package/src/notation/archetypes.ts +189 -0
  298. package/src/notation/fold.ts +696 -0
  299. package/src/notation/index.ts +27 -0
  300. package/src/notation/lodExtractor.ts +177 -0
  301. package/src/notation/nameShortener.ts +24 -0
  302. package/src/notation/perspectives.ts +18 -0
  303. package/src/notation/renderer.ts +394 -0
  304. package/src/notation/traceRenderer.ts +458 -0
  305. package/src/notation/types.ts +79 -0
  306. package/src/queries/NodeContext.ts +280 -0
  307. package/src/queries/findCallsInFunction.ts +249 -0
  308. package/src/queries/findContainingFunction.ts +124 -0
  309. package/src/queries/index.ts +44 -0
  310. package/src/queries/traceDataflow.ts +838 -0
  311. package/src/queries/traceValues.ts +531 -0
  312. package/src/queries/types.ts +191 -0
  313. package/src/schema/GraphSchemaExtractor.ts +177 -0
  314. package/src/schema/InterfaceSchemaExtractor.ts +173 -0
  315. package/src/schema/index.ts +5 -0
  316. package/src/storage/backends/RFDBServerBackend.ts +895 -0
  317. package/src/storage/backends/typeValidation.ts +154 -0
  318. package/src/utils/findRfdbBinary.ts +288 -0
  319. package/src/utils/lazyDownload.ts +206 -0
  320. package/src/utils/moduleResolution.ts +271 -0
  321. package/src/utils/resolveNodeFile.ts +18 -0
  322. package/src/utils/startRfdbServer.ts +197 -0
  323. package/src/validation/PathValidator.ts +334 -0
  324. package/src/version.ts +28 -0
@@ -0,0 +1,73 @@
1
+ /**
2
+ * IssueNode - contract for issue:* nodes
3
+ *
4
+ * Types: issue:security, issue:performance, issue:style, issue:smell
5
+ * ID format: issue:<category>#<hash>
6
+ *
7
+ * Issues represent detected problems in the codebase.
8
+ * They connect to affected code via AFFECTS edges.
9
+ */
10
+ import type { BaseNodeRecord } from '@grafema/types';
11
+ export type IssueSeverity = 'error' | 'warning' | 'info';
12
+ export type IssueType = `issue:${string}`;
13
+ export interface IssueNodeRecord extends BaseNodeRecord {
14
+ type: IssueType;
15
+ severity: IssueSeverity;
16
+ category: string;
17
+ message: string;
18
+ plugin: string;
19
+ targetNodeId?: string;
20
+ createdAt: number;
21
+ context?: Record<string, unknown>;
22
+ }
23
+ export interface IssueNodeOptions {
24
+ context?: Record<string, unknown>;
25
+ }
26
+ export declare class IssueNode {
27
+ static readonly REQUIRED: readonly ["category", "severity", "message", "plugin", "file"];
28
+ static readonly OPTIONAL: readonly ["targetNodeId", "context"];
29
+ /**
30
+ * Generate deterministic issue ID
31
+ * Format: issue:<category>#<hash12>
32
+ *
33
+ * Hash is based on plugin + file + line + column + message
34
+ * This ensures same issue = same ID across analysis runs
35
+ */
36
+ static generateId(category: string, plugin: string, file: string, line: number, column: number, message: string): string;
37
+ /**
38
+ * Create issue node
39
+ *
40
+ * @param category - Issue category (security, performance, style, smell, or custom)
41
+ * @param severity - error | warning | info
42
+ * @param message - Human-readable description
43
+ * @param plugin - Plugin name that detected this issue
44
+ * @param file - File where issue was detected
45
+ * @param line - Line number
46
+ * @param column - Column number (optional, defaults to 0)
47
+ * @param options - Optional fields (context)
48
+ */
49
+ static create(category: string, severity: IssueSeverity, message: string, plugin: string, file: string, line: number, column?: number, options?: IssueNodeOptions): IssueNodeRecord;
50
+ /**
51
+ * Validate issue node
52
+ * @returns array of error messages, empty if valid
53
+ */
54
+ static validate(node: IssueNodeRecord): string[];
55
+ /**
56
+ * Parse issue ID into components
57
+ * @param id - full ID (e.g., 'issue:security#a3f2b1c4d5e6')
58
+ * @returns { category, hash } or null if invalid
59
+ */
60
+ static parseId(id: string): {
61
+ category: string;
62
+ hash: string;
63
+ } | null;
64
+ /**
65
+ * Check if type is an issue type
66
+ */
67
+ static isIssueType(type: string): boolean;
68
+ /**
69
+ * Get all known issue categories
70
+ */
71
+ static getCategories(): string[];
72
+ }
73
+ //# sourceMappingURL=IssueNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IssueNode.d.ts","sourceRoot":"","sources":["../../../src/core/nodes/IssueNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAGzD,MAAM,MAAM,SAAS,GAAG,SAAS,MAAM,EAAE,CAAC;AAE1C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;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAKzC;;OAEG;IACH,MAAM,CAAC,aAAa,IAAI,MAAM,EAAE;CAGjC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * IssueNode - contract for issue:* nodes
3
+ *
4
+ * Types: issue:security, issue:performance, issue:style, issue:smell
5
+ * ID format: issue:<category>#<hash>
6
+ *
7
+ * Issues represent detected problems in the codebase.
8
+ * They connect to affected code via AFFECTS edges.
9
+ */
10
+ import { createHash } from 'crypto';
11
+ import { getNamespace } from './NodeKind.js';
12
+ // Valid severity levels
13
+ const VALID_SEVERITIES = ['error', 'warning', 'info'];
14
+ export class IssueNode {
15
+ static REQUIRED = ['category', 'severity', 'message', 'plugin', 'file'];
16
+ static OPTIONAL = ['targetNodeId', 'context'];
17
+ /**
18
+ * Generate deterministic issue ID
19
+ * Format: issue:<category>#<hash12>
20
+ *
21
+ * Hash is based on plugin + file + line + column + message
22
+ * This ensures same issue = same ID across analysis runs
23
+ */
24
+ static generateId(category, plugin, file, line, column, message) {
25
+ const hashInput = `${plugin}|${file}|${line}|${column}|${message}`;
26
+ const hash = createHash('sha256').update(hashInput).digest('hex').substring(0, 12);
27
+ return `issue:${category}#${hash}`;
28
+ }
29
+ /**
30
+ * Create issue node
31
+ *
32
+ * @param category - Issue category (security, performance, style, smell, or custom)
33
+ * @param severity - error | warning | info
34
+ * @param message - Human-readable description
35
+ * @param plugin - Plugin name that detected this issue
36
+ * @param file - File where issue was detected
37
+ * @param line - Line number
38
+ * @param column - Column number (optional, defaults to 0)
39
+ * @param options - Optional fields (context)
40
+ */
41
+ static create(category, severity, message, plugin, file, line, column = 0, options = {}) {
42
+ if (!category)
43
+ throw new Error('IssueNode.create: category is required');
44
+ if (!severity)
45
+ throw new Error('IssueNode.create: severity is required');
46
+ if (!VALID_SEVERITIES.includes(severity)) {
47
+ throw new Error(`IssueNode.create: invalid severity "${severity}". Valid: ${VALID_SEVERITIES.join(', ')}`);
48
+ }
49
+ if (!message)
50
+ throw new Error('IssueNode.create: message is required');
51
+ if (!plugin)
52
+ throw new Error('IssueNode.create: plugin is required');
53
+ if (!file)
54
+ throw new Error('IssueNode.create: file is required');
55
+ const type = `issue:${category}`;
56
+ const id = this.generateId(category, plugin, file, line, column, message);
57
+ const now = Date.now();
58
+ return {
59
+ id,
60
+ type,
61
+ name: message.substring(0, 100), // Truncate for display
62
+ file,
63
+ line,
64
+ column,
65
+ severity,
66
+ category,
67
+ message,
68
+ plugin,
69
+ createdAt: now,
70
+ context: options.context,
71
+ };
72
+ }
73
+ /**
74
+ * Validate issue node
75
+ * @returns array of error messages, empty if valid
76
+ */
77
+ static validate(node) {
78
+ const errors = [];
79
+ if (!IssueNode.isIssueType(node.type)) {
80
+ errors.push(`Expected issue:* type, got ${node.type}`);
81
+ }
82
+ if (!node.category) {
83
+ errors.push('Missing required field: category');
84
+ }
85
+ if (!node.severity) {
86
+ errors.push('Missing required field: severity');
87
+ }
88
+ else if (!VALID_SEVERITIES.includes(node.severity)) {
89
+ errors.push(`Invalid severity: ${node.severity}. Valid: ${VALID_SEVERITIES.join(', ')}`);
90
+ }
91
+ if (!node.message) {
92
+ errors.push('Missing required field: message');
93
+ }
94
+ if (!node.plugin) {
95
+ errors.push('Missing required field: plugin');
96
+ }
97
+ return errors;
98
+ }
99
+ /**
100
+ * Parse issue ID into components
101
+ * @param id - full ID (e.g., 'issue:security#a3f2b1c4d5e6')
102
+ * @returns { category, hash } or null if invalid
103
+ */
104
+ static parseId(id) {
105
+ if (!id)
106
+ return null;
107
+ const match = id.match(/^issue:([^#]+)#(.+)$/);
108
+ if (!match)
109
+ return null;
110
+ return {
111
+ category: match[1],
112
+ hash: match[2],
113
+ };
114
+ }
115
+ /**
116
+ * Check if type is an issue type
117
+ */
118
+ static isIssueType(type) {
119
+ if (!type)
120
+ return false;
121
+ return getNamespace(type) === 'issue';
122
+ }
123
+ /**
124
+ * Get all known issue categories
125
+ */
126
+ static getCategories() {
127
+ return ['security', 'performance', 'style', 'smell'];
128
+ }
129
+ }
130
+ //# sourceMappingURL=IssueNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IssueNode.js","sourceRoot":"","sources":["../../../src/core/nodes/IssueNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAuB7C,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAE/D,MAAM,OAAO,SAAS;IACpB,MAAM,CAAU,QAAQ,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;IAC1F,MAAM,CAAU,QAAQ,GAAG,CAAC,cAAc,EAAE,SAAS,CAAU,CAAC;IAEhE;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CACf,QAAgB,EAChB,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,OAAe;QAEf,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;QACnE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnF,OAAO,SAAS,QAAQ,IAAI,IAAI,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,CACX,QAAgB,EAChB,QAAuB,EACvB,OAAe,EACf,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,SAAiB,CAAC,EAClB,UAA4B,EAAE;QAE9B,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAA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G;IACH,MAAM,CAAC,aAAa;QAClB,OAAO,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Node Types - string type system for nodes
3
+ *
4
+ * Base types: FUNCTION, CLASS, METHOD, etc.
5
+ * Namespaced types: http:route, socketio:emit, express:router, etc.
6
+ *
7
+ * Namespace convention:
8
+ * - http:* - HTTP endpoints and requests
9
+ * - express:* - Express.js specifics
10
+ * - socketio:* - Socket.IO
11
+ * - db:* - Database queries
12
+ * - fs:* - Filesystem operations
13
+ */
14
+ export declare const NODE_TYPE: {
15
+ readonly FUNCTION: "FUNCTION";
16
+ readonly CLASS: "CLASS";
17
+ readonly METHOD: "METHOD";
18
+ readonly VARIABLE: "VARIABLE";
19
+ readonly PARAMETER: "PARAMETER";
20
+ readonly CONSTANT: "CONSTANT";
21
+ readonly LITERAL: "LITERAL";
22
+ readonly EXPRESSION: "EXPRESSION";
23
+ readonly TYPE_PARAMETER: "TYPE_PARAMETER";
24
+ readonly MODULE: "MODULE";
25
+ readonly IMPORT: "IMPORT";
26
+ readonly EXPORT: "EXPORT";
27
+ readonly CALL: "CALL";
28
+ readonly PROJECT: "PROJECT";
29
+ readonly SERVICE: "SERVICE";
30
+ readonly FILE: "FILE";
31
+ readonly SCOPE: "SCOPE";
32
+ readonly EXTERNAL: "EXTERNAL";
33
+ readonly EXTERNAL_MODULE: "EXTERNAL_MODULE";
34
+ readonly SIDE_EFFECT: "SIDE_EFFECT";
35
+ };
36
+ export type BaseNodeType = typeof NODE_TYPE[keyof typeof NODE_TYPE];
37
+ export declare const NAMESPACED_TYPE: {
38
+ readonly HTTP_ROUTE: "http:route";
39
+ readonly HTTP_REQUEST: "http:request";
40
+ readonly EXPRESS_ROUTER: "express:router";
41
+ readonly EXPRESS_MIDDLEWARE: "express:middleware";
42
+ readonly EXPRESS_MOUNT: "express:mount";
43
+ readonly SOCKETIO_EMIT: "socketio:emit";
44
+ readonly SOCKETIO_ON: "socketio:on";
45
+ readonly SOCKETIO_NAMESPACE: "socketio:namespace";
46
+ readonly DB_QUERY: "db:query";
47
+ readonly DB_CONNECTION: "db:connection";
48
+ readonly REDIS_READ: "redis:read";
49
+ readonly REDIS_WRITE: "redis:write";
50
+ readonly REDIS_DELETE: "redis:delete";
51
+ readonly REDIS_PUBLISH: "redis:publish";
52
+ readonly REDIS_SUBSCRIBE: "redis:subscribe";
53
+ readonly REDIS_TRANSACTION: "redis:transaction";
54
+ readonly REDIS_CONNECTION: "redis:connection";
55
+ readonly FS_READ: "fs:read";
56
+ readonly FS_WRITE: "fs:write";
57
+ readonly FS_OPERATION: "fs:operation";
58
+ readonly NET_REQUEST: "net:request";
59
+ readonly NET_STDIO: "net:stdio";
60
+ readonly EVENT_LISTENER: "event:listener";
61
+ readonly EVENT_EMIT: "event:emit";
62
+ readonly GUARANTEE_QUEUE: "guarantee:queue";
63
+ readonly GUARANTEE_API: "guarantee:api";
64
+ readonly GUARANTEE_PERMISSION: "guarantee:permission";
65
+ readonly GRAFEMA_PLUGIN: "grafema:plugin";
66
+ };
67
+ export type NamespacedNodeType = typeof NAMESPACED_TYPE[keyof typeof NAMESPACED_TYPE];
68
+ export type NodeType = BaseNodeType | NamespacedNodeType | string;
69
+ /**
70
+ * Check if type is namespaced (contains :)
71
+ */
72
+ export declare function isNamespacedType(nodeType: string): boolean;
73
+ /**
74
+ * Get namespace from type
75
+ * @returns namespace or null for base types
76
+ */
77
+ export declare function getNamespace(nodeType: string): string | null;
78
+ /**
79
+ * Get base name from namespaced type
80
+ */
81
+ export declare function getBaseName(nodeType: string): string;
82
+ /**
83
+ * Check if type is an endpoint (HTTP route, WebSocket handler, etc.)
84
+ */
85
+ export declare function isEndpointType(nodeType: string): boolean;
86
+ /**
87
+ * Check if type is a side effect (DB, FS, Network)
88
+ */
89
+ export declare function isSideEffectType(nodeType: string): boolean;
90
+ /**
91
+ * Check if type matches a pattern with wildcard
92
+ * @param nodeType - node type
93
+ * @param pattern - pattern (e.g., "http:*", "FUNCTION")
94
+ */
95
+ export declare function matchesTypePattern(nodeType: string, pattern: string): boolean;
96
+ /**
97
+ * Check if type is a guarantee type (guarantee:queue, guarantee:api, etc.)
98
+ */
99
+ export declare function isGuaranteeType(nodeType: string): boolean;
100
+ /**
101
+ * Check if type is a grafema internal type (grafema:plugin, etc.)
102
+ */
103
+ export declare function isGrafemaType(nodeType: string): boolean;
104
+ //# sourceMappingURL=NodeKind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeKind.d.ts","sourceRoot":"","sources":["../../../src/core/nodes/NodeKind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;CAgCZ,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,OAAO,SAAS,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAKpE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDlB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAGtF,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAIlE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAK1D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAa7E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvD"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Node Types - string type system for nodes
3
+ *
4
+ * Base types: FUNCTION, CLASS, METHOD, etc.
5
+ * Namespaced types: http:route, socketio:emit, express:router, etc.
6
+ *
7
+ * Namespace convention:
8
+ * - http:* - HTTP endpoints and requests
9
+ * - express:* - Express.js specifics
10
+ * - socketio:* - Socket.IO
11
+ * - db:* - Database queries
12
+ * - fs:* - Filesystem operations
13
+ */
14
+ // === BASE TYPES ===
15
+ // Abstract types, not tied to language or framework
16
+ export const NODE_TYPE = {
17
+ // Core code entities
18
+ FUNCTION: 'FUNCTION',
19
+ CLASS: 'CLASS',
20
+ METHOD: 'METHOD',
21
+ VARIABLE: 'VARIABLE',
22
+ PARAMETER: 'PARAMETER',
23
+ CONSTANT: 'CONSTANT',
24
+ LITERAL: 'LITERAL',
25
+ EXPRESSION: 'EXPRESSION', // Generic expression node for data flow tracking
26
+ TYPE_PARAMETER: 'TYPE_PARAMETER',
27
+ // Module system
28
+ MODULE: 'MODULE',
29
+ IMPORT: 'IMPORT',
30
+ EXPORT: 'EXPORT',
31
+ // Call graph
32
+ CALL: 'CALL', // unified METHOD_CALL + CALL_SITE
33
+ // Project structure
34
+ PROJECT: 'PROJECT',
35
+ SERVICE: 'SERVICE',
36
+ FILE: 'FILE',
37
+ SCOPE: 'SCOPE',
38
+ // External dependencies
39
+ EXTERNAL: 'EXTERNAL',
40
+ EXTERNAL_MODULE: 'EXTERNAL_MODULE',
41
+ // Generic side effects
42
+ SIDE_EFFECT: 'SIDE_EFFECT',
43
+ };
44
+ // === NAMESPACED TYPES ===
45
+ // Types specific to frameworks and libraries
46
+ export const NAMESPACED_TYPE = {
47
+ // HTTP (generic)
48
+ HTTP_ROUTE: 'http:route',
49
+ HTTP_REQUEST: 'http:request',
50
+ // Express.js
51
+ EXPRESS_ROUTER: 'express:router',
52
+ EXPRESS_MIDDLEWARE: 'express:middleware',
53
+ EXPRESS_MOUNT: 'express:mount',
54
+ // Socket.IO
55
+ SOCKETIO_EMIT: 'socketio:emit',
56
+ SOCKETIO_ON: 'socketio:on',
57
+ SOCKETIO_NAMESPACE: 'socketio:namespace',
58
+ // Database
59
+ DB_QUERY: 'db:query',
60
+ DB_CONNECTION: 'db:connection',
61
+ // Redis
62
+ REDIS_READ: 'redis:read',
63
+ REDIS_WRITE: 'redis:write',
64
+ REDIS_DELETE: 'redis:delete',
65
+ REDIS_PUBLISH: 'redis:publish',
66
+ REDIS_SUBSCRIBE: 'redis:subscribe',
67
+ REDIS_TRANSACTION: 'redis:transaction',
68
+ REDIS_CONNECTION: 'redis:connection',
69
+ // Filesystem
70
+ FS_READ: 'fs:read',
71
+ FS_WRITE: 'fs:write',
72
+ FS_OPERATION: 'fs:operation',
73
+ // Network
74
+ NET_REQUEST: 'net:request',
75
+ NET_STDIO: 'net:stdio',
76
+ // Events
77
+ EVENT_LISTENER: 'event:listener',
78
+ EVENT_EMIT: 'event:emit',
79
+ // Guarantees (contract-based)
80
+ GUARANTEE_QUEUE: 'guarantee:queue',
81
+ GUARANTEE_API: 'guarantee:api',
82
+ GUARANTEE_PERMISSION: 'guarantee:permission',
83
+ // Grafema internal (self-describing pipeline)
84
+ GRAFEMA_PLUGIN: 'grafema:plugin',
85
+ };
86
+ // === HELPERS ===
87
+ /**
88
+ * Check if type is namespaced (contains :)
89
+ */
90
+ export function isNamespacedType(nodeType) {
91
+ return nodeType !== undefined && nodeType !== null && nodeType.includes(':');
92
+ }
93
+ /**
94
+ * Get namespace from type
95
+ * @returns namespace or null for base types
96
+ */
97
+ export function getNamespace(nodeType) {
98
+ if (!nodeType || !nodeType.includes(':'))
99
+ return null;
100
+ return nodeType.split(':')[0];
101
+ }
102
+ /**
103
+ * Get base name from namespaced type
104
+ */
105
+ export function getBaseName(nodeType) {
106
+ if (!nodeType)
107
+ return '';
108
+ if (!nodeType.includes(':'))
109
+ return nodeType;
110
+ return nodeType.split(':').slice(1).join(':');
111
+ }
112
+ /**
113
+ * Check if type is an endpoint (HTTP route, WebSocket handler, etc.)
114
+ */
115
+ export function isEndpointType(nodeType) {
116
+ if (!nodeType)
117
+ return false;
118
+ const ns = getNamespace(nodeType);
119
+ return ns === 'http' || ns === 'express' || ns === 'socketio';
120
+ }
121
+ /**
122
+ * Check if type is a side effect (DB, FS, Network)
123
+ */
124
+ export function isSideEffectType(nodeType) {
125
+ if (!nodeType)
126
+ return false;
127
+ if (nodeType === NODE_TYPE.SIDE_EFFECT)
128
+ return true;
129
+ const ns = getNamespace(nodeType);
130
+ return ns === 'db' || ns === 'fs' || ns === 'net' || ns === 'redis';
131
+ }
132
+ /**
133
+ * Check if type matches a pattern with wildcard
134
+ * @param nodeType - node type
135
+ * @param pattern - pattern (e.g., "http:*", "FUNCTION")
136
+ */
137
+ export function matchesTypePattern(nodeType, pattern) {
138
+ if (!nodeType || !pattern)
139
+ return false;
140
+ // Exact match
141
+ if (nodeType === pattern)
142
+ return true;
143
+ // Wildcard match (e.g., "http:*" matches "http:route")
144
+ if (pattern.endsWith(':*')) {
145
+ const patternNs = pattern.slice(0, -2);
146
+ return getNamespace(nodeType) === patternNs;
147
+ }
148
+ return false;
149
+ }
150
+ /**
151
+ * Check if type is a guarantee type (guarantee:queue, guarantee:api, etc.)
152
+ */
153
+ export function isGuaranteeType(nodeType) {
154
+ if (!nodeType)
155
+ return false;
156
+ return getNamespace(nodeType) === 'guarantee';
157
+ }
158
+ /**
159
+ * Check if type is a grafema internal type (grafema:plugin, etc.)
160
+ */
161
+ export function isGrafemaType(nodeType) {
162
+ if (!nodeType)
163
+ return false;
164
+ return getNamespace(nodeType) === 'grafema';
165
+ }
166
+ //#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C,KAAK,WAAW,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,YAAY,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * DiagnosticCollector - Collects and filters diagnostics from plugin execution
3
+ *
4
+ * The DiagnosticCollector aggregates errors from PluginResult.errors[],
5
+ * converting both GrafemaError instances (with rich info) and plain Error
6
+ * instances (treated as generic errors) into unified Diagnostic entries.
7
+ *
8
+ * Usage:
9
+ * const collector = new DiagnosticCollector();
10
+ * collector.addFromPluginResult('INDEXING', 'JSModuleIndexer', result);
11
+ *
12
+ * if (collector.hasFatal()) {
13
+ * throw new Error('Fatal error detected');
14
+ * }
15
+ *
16
+ * console.log(collector.toDiagnosticsLog());
17
+ */
18
+ import type { PluginPhase, PluginResult } from '@grafema/types';
19
+ import { type ResolutionStep, type ResolutionFailureReason } from '../errors/GrafemaError.js';
20
+ /**
21
+ * Diagnostic entry - unified format for all errors/warnings
22
+ */
23
+ export interface Diagnostic {
24
+ code: string;
25
+ severity: 'fatal' | 'error' | 'warning' | 'info';
26
+ message: string;
27
+ file?: string;
28
+ line?: number;
29
+ phase: PluginPhase;
30
+ plugin: string;
31
+ timestamp: number;
32
+ suggestion?: string;
33
+ /** Resolution chain for context (REG-332) */
34
+ resolutionChain?: ResolutionStep[];
35
+ /** Failure reason for context-aware suggestions (REG-332) */
36
+ failureReason?: ResolutionFailureReason;
37
+ }
38
+ /**
39
+ * Diagnostic input (without timestamp, which is auto-generated)
40
+ */
41
+ export type DiagnosticInput = Omit<Diagnostic, 'timestamp'>;
42
+ /**
43
+ * DiagnosticCollector - collects, filters, and formats diagnostics
44
+ */
45
+ export declare class DiagnosticCollector {
46
+ private diagnostics;
47
+ /**
48
+ * Extract errors from PluginResult and add as diagnostics.
49
+ *
50
+ * GrafemaError instances provide rich info (code, severity, context, suggestion).
51
+ * Plain Error instances are treated as generic errors with code 'ERR_UNKNOWN'.
52
+ */
53
+ addFromPluginResult(phase: PluginPhase, plugin: string, result: PluginResult): void;
54
+ /**
55
+ * Add a diagnostic directly.
56
+ * Timestamp is set automatically.
57
+ */
58
+ add(diagnostic: DiagnosticInput): void;
59
+ /**
60
+ * Get all diagnostics.
61
+ * Returns a copy to prevent external modification.
62
+ */
63
+ getAll(): Diagnostic[];
64
+ /**
65
+ * Get diagnostics filtered by phase.
66
+ */
67
+ getByPhase(phase: PluginPhase): Diagnostic[];
68
+ /**
69
+ * Get diagnostics filtered by plugin name (case-sensitive).
70
+ */
71
+ getByPlugin(plugin: string): Diagnostic[];
72
+ /**
73
+ * Get diagnostics filtered by error code.
74
+ */
75
+ getByCode(code: string): Diagnostic[];
76
+ /**
77
+ * Check if any fatal diagnostic exists.
78
+ * Fatal errors require immediate stop of analysis.
79
+ */
80
+ hasFatal(): boolean;
81
+ /**
82
+ * Check if any error (including fatal) exists.
83
+ */
84
+ hasErrors(): boolean;
85
+ /**
86
+ * Check if any warning exists.
87
+ */
88
+ hasWarnings(): boolean;
89
+ /**
90
+ * Get total count of diagnostics.
91
+ */
92
+ count(): number;
93
+ /**
94
+ * Format diagnostics as JSON lines (one JSON object per line).
95
+ * Suitable for .grafema/diagnostics.log file.
96
+ */
97
+ toDiagnosticsLog(): string;
98
+ /**
99
+ * Clear all diagnostics.
100
+ */
101
+ clear(): void;
102
+ }
103
+ //# sourceMappingURL=DiagnosticCollector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiagnosticCollector.d.ts","sourceRoot":"","sources":["../../src/diagnostics/DiagnosticCollector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,uBAAuB,EAA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