@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.
- package/LICENSE +190 -0
- package/dist/api/GraphAPI.d.ts +87 -0
- package/dist/api/GraphAPI.d.ts.map +1 -0
- package/dist/api/GraphAPI.js +212 -0
- package/dist/api/GraphAPI.js.map +1 -0
- package/dist/api/GuaranteeAPI.d.ts +147 -0
- package/dist/api/GuaranteeAPI.d.ts.map +1 -0
- package/dist/api/GuaranteeAPI.js +290 -0
- package/dist/api/GuaranteeAPI.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +214 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +441 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/CoverageAnalyzer.d.ts +65 -0
- package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
- package/dist/core/CoverageAnalyzer.js +199 -0
- package/dist/core/CoverageAnalyzer.js.map +1 -0
- package/dist/core/FileExplainer.d.ts +101 -0
- package/dist/core/FileExplainer.d.ts.map +1 -0
- package/dist/core/FileExplainer.js +140 -0
- package/dist/core/FileExplainer.js.map +1 -0
- package/dist/core/FileOverview.d.ts +124 -0
- package/dist/core/FileOverview.d.ts.map +1 -0
- package/dist/core/FileOverview.js +279 -0
- package/dist/core/FileOverview.js.map +1 -0
- package/dist/core/GrafemaUri.d.ts +66 -0
- package/dist/core/GrafemaUri.d.ts.map +1 -0
- package/dist/core/GrafemaUri.js +191 -0
- package/dist/core/GrafemaUri.js.map +1 -0
- package/dist/core/GraphBackend.d.ts +158 -0
- package/dist/core/GraphBackend.d.ts.map +1 -0
- package/dist/core/GraphBackend.js +85 -0
- package/dist/core/GraphBackend.js.map +1 -0
- package/dist/core/GraphFreshnessChecker.d.ts +33 -0
- package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
- package/dist/core/GraphFreshnessChecker.js +104 -0
- package/dist/core/GraphFreshnessChecker.js.map +1 -0
- package/dist/core/GuaranteeManager.d.ts +254 -0
- package/dist/core/GuaranteeManager.d.ts.map +1 -0
- package/dist/core/GuaranteeManager.js +447 -0
- package/dist/core/GuaranteeManager.js.map +1 -0
- package/dist/core/HashUtils.d.ts +24 -0
- package/dist/core/HashUtils.d.ts.map +1 -0
- package/dist/core/HashUtils.js +46 -0
- package/dist/core/HashUtils.js.map +1 -0
- package/dist/core/IncrementalReanalyzer.d.ts +33 -0
- package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
- package/dist/core/IncrementalReanalyzer.js +67 -0
- package/dist/core/IncrementalReanalyzer.js.map +1 -0
- package/dist/core/ResourceRegistry.d.ts +17 -0
- package/dist/core/ResourceRegistry.d.ts.map +1 -0
- package/dist/core/ResourceRegistry.js +32 -0
- package/dist/core/ResourceRegistry.js.map +1 -0
- package/dist/core/SemanticId.d.ts +159 -0
- package/dist/core/SemanticId.d.ts.map +1 -0
- package/dist/core/SemanticId.js +291 -0
- package/dist/core/SemanticId.js.map +1 -0
- package/dist/core/VersionManager.d.ts +166 -0
- package/dist/core/VersionManager.d.ts.map +1 -0
- package/dist/core/VersionManager.js +239 -0
- package/dist/core/VersionManager.js.map +1 -0
- package/dist/core/brandNodeInternal.d.ts +14 -0
- package/dist/core/brandNodeInternal.d.ts.map +1 -0
- package/dist/core/brandNodeInternal.js +4 -0
- package/dist/core/brandNodeInternal.js.map +1 -0
- package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
- package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
- package/dist/core/nodes/GuaranteeNode.js +118 -0
- package/dist/core/nodes/GuaranteeNode.js.map +1 -0
- package/dist/core/nodes/IssueNode.d.ts +73 -0
- package/dist/core/nodes/IssueNode.d.ts.map +1 -0
- package/dist/core/nodes/IssueNode.js +130 -0
- package/dist/core/nodes/IssueNode.js.map +1 -0
- package/dist/core/nodes/NodeKind.d.ts +104 -0
- package/dist/core/nodes/NodeKind.d.ts.map +1 -0
- package/dist/core/nodes/NodeKind.js +166 -0
- package/dist/core/nodes/NodeKind.js.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts +103 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.js +133 -0
- package/dist/diagnostics/DiagnosticCollector.js.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +122 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.js +300 -0
- package/dist/diagnostics/DiagnosticReporter.js.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.js +44 -0
- package/dist/diagnostics/DiagnosticWriter.js.map +1 -0
- package/dist/diagnostics/categories.d.ts +57 -0
- package/dist/diagnostics/categories.d.ts.map +1 -0
- package/dist/diagnostics/categories.js +71 -0
- package/dist/diagnostics/categories.js.map +1 -0
- package/dist/diagnostics/index.d.ts +17 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +15 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/errors/GrafemaError.d.ts +200 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -0
- package/dist/errors/GrafemaError.js +209 -0
- package/dist/errors/GrafemaError.js.map +1 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions/index.d.ts +8 -0
- package/dist/instructions/index.d.ts.map +1 -0
- package/dist/instructions/index.js +20 -0
- package/dist/instructions/index.js.map +1 -0
- package/dist/instructions/onboarding.md +133 -0
- package/dist/knowledge/KnowledgeBase.d.ts +113 -0
- package/dist/knowledge/KnowledgeBase.d.ts.map +1 -0
- package/dist/knowledge/KnowledgeBase.js +420 -0
- package/dist/knowledge/KnowledgeBase.js.map +1 -0
- package/dist/knowledge/SemanticAddressResolver.d.ts +59 -0
- package/dist/knowledge/SemanticAddressResolver.d.ts.map +1 -0
- package/dist/knowledge/SemanticAddressResolver.js +160 -0
- package/dist/knowledge/SemanticAddressResolver.js.map +1 -0
- package/dist/knowledge/git-ingest.d.ts +58 -0
- package/dist/knowledge/git-ingest.d.ts.map +1 -0
- package/dist/knowledge/git-ingest.js +301 -0
- package/dist/knowledge/git-ingest.js.map +1 -0
- package/dist/knowledge/git-queries.d.ts +86 -0
- package/dist/knowledge/git-queries.d.ts.map +1 -0
- package/dist/knowledge/git-queries.js +177 -0
- package/dist/knowledge/git-queries.js.map +1 -0
- package/dist/knowledge/index.d.ts +14 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +10 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/parser.d.ts +39 -0
- package/dist/knowledge/parser.d.ts.map +1 -0
- package/dist/knowledge/parser.js +292 -0
- package/dist/knowledge/parser.js.map +1 -0
- package/dist/knowledge/types.d.ts +133 -0
- package/dist/knowledge/types.d.ts.map +1 -0
- package/dist/knowledge/types.js +8 -0
- package/dist/knowledge/types.js.map +1 -0
- package/dist/logging/Logger.d.ts +98 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +274 -0
- package/dist/logging/Logger.js.map +1 -0
- package/dist/notation/archetypes.d.ts +36 -0
- package/dist/notation/archetypes.d.ts.map +1 -0
- package/dist/notation/archetypes.js +173 -0
- package/dist/notation/archetypes.js.map +1 -0
- package/dist/notation/fold.d.ts +25 -0
- package/dist/notation/fold.d.ts.map +1 -0
- package/dist/notation/fold.js +598 -0
- package/dist/notation/fold.js.map +1 -0
- package/dist/notation/index.d.ts +18 -0
- package/dist/notation/index.d.ts.map +1 -0
- package/dist/notation/index.js +16 -0
- package/dist/notation/index.js.map +1 -0
- package/dist/notation/lodExtractor.d.ts +32 -0
- package/dist/notation/lodExtractor.d.ts.map +1 -0
- package/dist/notation/lodExtractor.js +149 -0
- package/dist/notation/lodExtractor.js.map +1 -0
- package/dist/notation/nameShortener.d.ts +22 -0
- package/dist/notation/nameShortener.d.ts.map +1 -0
- package/dist/notation/nameShortener.js +24 -0
- package/dist/notation/nameShortener.js.map +1 -0
- package/dist/notation/perspectives.d.ts +11 -0
- package/dist/notation/perspectives.d.ts.map +1 -0
- package/dist/notation/perspectives.js +16 -0
- package/dist/notation/perspectives.js.map +1 -0
- package/dist/notation/renderer.d.ts +31 -0
- package/dist/notation/renderer.d.ts.map +1 -0
- package/dist/notation/renderer.js +315 -0
- package/dist/notation/renderer.js.map +1 -0
- package/dist/notation/traceRenderer.d.ts +39 -0
- package/dist/notation/traceRenderer.d.ts.map +1 -0
- package/dist/notation/traceRenderer.js +358 -0
- package/dist/notation/traceRenderer.js.map +1 -0
- package/dist/notation/types.d.ts +66 -0
- package/dist/notation/types.d.ts.map +1 -0
- package/dist/notation/types.js +10 -0
- package/dist/notation/types.js.map +1 -0
- package/dist/queries/NodeContext.d.ts +81 -0
- package/dist/queries/NodeContext.d.ts.map +1 -0
- package/dist/queries/NodeContext.js +196 -0
- package/dist/queries/NodeContext.js.map +1 -0
- package/dist/queries/findCallsInFunction.d.ts +62 -0
- package/dist/queries/findCallsInFunction.d.ts.map +1 -0
- package/dist/queries/findCallsInFunction.js +169 -0
- package/dist/queries/findCallsInFunction.js.map +1 -0
- package/dist/queries/findContainingFunction.d.ts +57 -0
- package/dist/queries/findContainingFunction.d.ts.map +1 -0
- package/dist/queries/findContainingFunction.js +91 -0
- package/dist/queries/findContainingFunction.js.map +1 -0
- package/dist/queries/index.d.ts +18 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +14 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/traceDataflow.d.ts +65 -0
- package/dist/queries/traceDataflow.d.ts.map +1 -0
- package/dist/queries/traceDataflow.js +754 -0
- package/dist/queries/traceDataflow.js.map +1 -0
- package/dist/queries/traceValues.d.ts +70 -0
- package/dist/queries/traceValues.d.ts.map +1 -0
- package/dist/queries/traceValues.js +373 -0
- package/dist/queries/traceValues.js.map +1 -0
- package/dist/queries/types.d.ts +166 -0
- package/dist/queries/types.d.ts.map +1 -0
- package/dist/queries/types.js +10 -0
- package/dist/queries/types.js.map +1 -0
- package/dist/schema/GraphSchemaExtractor.d.ts +53 -0
- package/dist/schema/GraphSchemaExtractor.d.ts.map +1 -0
- package/dist/schema/GraphSchemaExtractor.js +125 -0
- package/dist/schema/GraphSchemaExtractor.js.map +1 -0
- package/dist/schema/InterfaceSchemaExtractor.d.ts +73 -0
- package/dist/schema/InterfaceSchemaExtractor.d.ts.map +1 -0
- package/dist/schema/InterfaceSchemaExtractor.js +113 -0
- package/dist/schema/InterfaceSchemaExtractor.js.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +3 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +356 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.js +748 -0
- package/dist/storage/backends/RFDBServerBackend.js.map +1 -0
- package/dist/storage/backends/typeValidation.d.ts +47 -0
- package/dist/storage/backends/typeValidation.d.ts.map +1 -0
- package/dist/storage/backends/typeValidation.js +141 -0
- package/dist/storage/backends/typeValidation.js.map +1 -0
- package/dist/utils/findRfdbBinary.d.ts +67 -0
- package/dist/utils/findRfdbBinary.d.ts.map +1 -0
- package/dist/utils/findRfdbBinary.js +261 -0
- package/dist/utils/findRfdbBinary.js.map +1 -0
- package/dist/utils/lazyDownload.d.ts +43 -0
- package/dist/utils/lazyDownload.d.ts.map +1 -0
- package/dist/utils/lazyDownload.js +175 -0
- package/dist/utils/lazyDownload.js.map +1 -0
- package/dist/utils/moduleResolution.d.ts +134 -0
- package/dist/utils/moduleResolution.d.ts.map +1 -0
- package/dist/utils/moduleResolution.js +189 -0
- package/dist/utils/moduleResolution.js.map +1 -0
- package/dist/utils/resolveNodeFile.d.ts +13 -0
- package/dist/utils/resolveNodeFile.d.ts.map +1 -0
- package/dist/utils/resolveNodeFile.js +18 -0
- package/dist/utils/resolveNodeFile.js.map +1 -0
- package/dist/utils/startRfdbServer.d.ts +63 -0
- package/dist/utils/startRfdbServer.d.ts.map +1 -0
- package/dist/utils/startRfdbServer.js +142 -0
- package/dist/utils/startRfdbServer.js.map +1 -0
- package/dist/validation/PathValidator.d.ts +80 -0
- package/dist/validation/PathValidator.d.ts.map +1 -0
- package/dist/validation/PathValidator.js +252 -0
- package/dist/validation/PathValidator.js.map +1 -0
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +26 -0
- package/dist/version.js.map +1 -0
- package/package.json +50 -0
- package/src/api/GraphAPI.ts +307 -0
- package/src/api/GuaranteeAPI.ts +402 -0
- package/src/config/ConfigLoader.ts +653 -0
- package/src/config/index.ts +13 -0
- package/src/core/CoverageAnalyzer.ts +243 -0
- package/src/core/FileExplainer.ts +179 -0
- package/src/core/FileOverview.ts +397 -0
- package/src/core/GrafemaUri.ts +216 -0
- package/src/core/GraphBackend.ts +266 -0
- package/src/core/GraphFreshnessChecker.ts +145 -0
- package/src/core/GuaranteeManager.ts +684 -0
- package/src/core/HashUtils.ts +48 -0
- package/src/core/IncrementalReanalyzer.ts +106 -0
- package/src/core/ResourceRegistry.ts +39 -0
- package/src/core/SemanticId.ts +423 -0
- package/src/core/VersionManager.ts +405 -0
- package/src/core/brandNodeInternal.ts +16 -0
- package/src/core/nodes/GuaranteeNode.ts +162 -0
- package/src/core/nodes/IssueNode.ts +177 -0
- package/src/core/nodes/NodeKind.ts +192 -0
- package/src/diagnostics/DiagnosticCollector.ts +170 -0
- package/src/diagnostics/DiagnosticReporter.ts +395 -0
- package/src/diagnostics/DiagnosticWriter.ts +50 -0
- package/src/diagnostics/categories.ts +104 -0
- package/src/diagnostics/index.ts +30 -0
- package/src/errors/GrafemaError.ts +297 -0
- package/src/index.ts +261 -0
- package/src/instructions/index.ts +21 -0
- package/src/instructions/onboarding.md +133 -0
- package/src/knowledge/KnowledgeBase.ts +486 -0
- package/src/knowledge/SemanticAddressResolver.ts +191 -0
- package/src/knowledge/git-ingest.ts +402 -0
- package/src/knowledge/git-queries.ts +269 -0
- package/src/knowledge/index.ts +29 -0
- package/src/knowledge/parser.ts +294 -0
- package/src/knowledge/types.ts +146 -0
- package/src/logging/Logger.ts +303 -0
- package/src/notation/archetypes.ts +189 -0
- package/src/notation/fold.ts +696 -0
- package/src/notation/index.ts +27 -0
- package/src/notation/lodExtractor.ts +177 -0
- package/src/notation/nameShortener.ts +24 -0
- package/src/notation/perspectives.ts +18 -0
- package/src/notation/renderer.ts +394 -0
- package/src/notation/traceRenderer.ts +458 -0
- package/src/notation/types.ts +79 -0
- package/src/queries/NodeContext.ts +280 -0
- package/src/queries/findCallsInFunction.ts +249 -0
- package/src/queries/findContainingFunction.ts +124 -0
- package/src/queries/index.ts +44 -0
- package/src/queries/traceDataflow.ts +838 -0
- package/src/queries/traceValues.ts +531 -0
- package/src/queries/types.ts +191 -0
- package/src/schema/GraphSchemaExtractor.ts +177 -0
- package/src/schema/InterfaceSchemaExtractor.ts +173 -0
- package/src/schema/index.ts +5 -0
- package/src/storage/backends/RFDBServerBackend.ts +895 -0
- package/src/storage/backends/typeValidation.ts +154 -0
- package/src/utils/findRfdbBinary.ts +288 -0
- package/src/utils/lazyDownload.ts +206 -0
- package/src/utils/moduleResolution.ts +271 -0
- package/src/utils/resolveNodeFile.ts +18 -0
- package/src/utils/startRfdbServer.ts +197 -0
- package/src/validation/PathValidator.ts +334 -0
- package/src/version.ts +28 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GrafemaError - Error hierarchy for Grafema
|
|
3
|
+
*
|
|
4
|
+
* All errors extend the native JavaScript Error class for compatibility
|
|
5
|
+
* with PluginResult.errors[] (Error[]).
|
|
6
|
+
*
|
|
7
|
+
* Error types:
|
|
8
|
+
* - ConfigError: Configuration parsing/validation errors (fatal)
|
|
9
|
+
* - FileAccessError: File system access errors (error)
|
|
10
|
+
* - LanguageError: Unsupported language/parsing errors (warning)
|
|
11
|
+
* - DatabaseError: RFDB database errors (fatal)
|
|
12
|
+
* - PluginError: Plugin execution errors (error)
|
|
13
|
+
* - AnalysisError: Analysis/timeout errors (error)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { PluginPhase } from '@grafema/types';
|
|
17
|
+
import type { Diagnostic } from '../diagnostics/DiagnosticCollector.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Context for error reporting
|
|
21
|
+
*/
|
|
22
|
+
export interface ErrorContext {
|
|
23
|
+
filePath?: string;
|
|
24
|
+
lineNumber?: number;
|
|
25
|
+
phase?: PluginPhase;
|
|
26
|
+
plugin?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* JSON representation of GrafemaError
|
|
32
|
+
*/
|
|
33
|
+
export interface GrafemaErrorJSON {
|
|
34
|
+
code: string;
|
|
35
|
+
severity: 'fatal' | 'error' | 'warning';
|
|
36
|
+
message: string;
|
|
37
|
+
context: ErrorContext;
|
|
38
|
+
suggestion?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Abstract base class for all Grafema errors.
|
|
43
|
+
*
|
|
44
|
+
* Extends native Error for compatibility with PluginResult.errors[].
|
|
45
|
+
*/
|
|
46
|
+
export abstract class GrafemaError extends Error {
|
|
47
|
+
abstract readonly code: string;
|
|
48
|
+
abstract readonly severity: 'fatal' | 'error' | 'warning';
|
|
49
|
+
readonly context: ErrorContext;
|
|
50
|
+
readonly suggestion?: string;
|
|
51
|
+
|
|
52
|
+
constructor(message: string, context: ErrorContext = {}, suggestion?: string) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = this.constructor.name;
|
|
55
|
+
this.context = context;
|
|
56
|
+
this.suggestion = suggestion;
|
|
57
|
+
|
|
58
|
+
// Ensure proper prototype chain for instanceof checks
|
|
59
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
60
|
+
|
|
61
|
+
// Capture stack trace (V8 specific)
|
|
62
|
+
if (Error.captureStackTrace) {
|
|
63
|
+
Error.captureStackTrace(this, this.constructor);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Serialize error to JSON for diagnostics.log
|
|
69
|
+
*/
|
|
70
|
+
toJSON(): GrafemaErrorJSON {
|
|
71
|
+
return {
|
|
72
|
+
code: this.code,
|
|
73
|
+
severity: this.severity,
|
|
74
|
+
message: this.message,
|
|
75
|
+
context: this.context,
|
|
76
|
+
suggestion: this.suggestion,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Configuration error - config.json parsing, validation, missing required fields
|
|
83
|
+
*
|
|
84
|
+
* Severity: fatal (always)
|
|
85
|
+
* Codes: ERR_CONFIG_INVALID, ERR_CONFIG_MISSING_FIELD
|
|
86
|
+
*/
|
|
87
|
+
export class ConfigError extends GrafemaError {
|
|
88
|
+
readonly code: string;
|
|
89
|
+
readonly severity = 'fatal' as const;
|
|
90
|
+
|
|
91
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
92
|
+
super(message, context, suggestion);
|
|
93
|
+
this.code = code;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* File access error - unreadable files, missing git, permissions
|
|
99
|
+
*
|
|
100
|
+
* Severity: error (default)
|
|
101
|
+
* Codes: ERR_FILE_UNREADABLE, ERR_GIT_NOT_FOUND, ERR_GIT_ACCESS_DENIED
|
|
102
|
+
*/
|
|
103
|
+
export class FileAccessError extends GrafemaError {
|
|
104
|
+
readonly code: string;
|
|
105
|
+
readonly severity = 'error' as const;
|
|
106
|
+
|
|
107
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
108
|
+
super(message, context, suggestion);
|
|
109
|
+
this.code = code;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Language error - unsupported file type, unparseable syntax
|
|
115
|
+
*
|
|
116
|
+
* Severity: warning (always)
|
|
117
|
+
* Codes: ERR_UNSUPPORTED_LANG, ERR_PARSE_FAILURE
|
|
118
|
+
*/
|
|
119
|
+
export class LanguageError extends GrafemaError {
|
|
120
|
+
readonly code: string;
|
|
121
|
+
readonly severity = 'warning' as const;
|
|
122
|
+
|
|
123
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
124
|
+
super(message, context, suggestion);
|
|
125
|
+
this.code = code;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Database error - RFDB connection, corruption, lock
|
|
131
|
+
*
|
|
132
|
+
* Severity: fatal (always)
|
|
133
|
+
* Codes: ERR_DATABASE_LOCKED, ERR_DATABASE_CORRUPTED
|
|
134
|
+
*/
|
|
135
|
+
export class DatabaseError extends GrafemaError {
|
|
136
|
+
readonly code: string;
|
|
137
|
+
readonly severity = 'fatal' as const;
|
|
138
|
+
|
|
139
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
140
|
+
super(message, context, suggestion);
|
|
141
|
+
this.code = code;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Plugin error - plugin execution failed, dependency missing
|
|
147
|
+
*
|
|
148
|
+
* Severity: error (default)
|
|
149
|
+
* Codes: ERR_PLUGIN_FAILED, ERR_PLUGIN_DEPENDENCY_MISSING
|
|
150
|
+
*/
|
|
151
|
+
export class PluginError extends GrafemaError {
|
|
152
|
+
readonly code: string;
|
|
153
|
+
readonly severity = 'error' as const;
|
|
154
|
+
|
|
155
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
156
|
+
super(message, context, suggestion);
|
|
157
|
+
this.code = code;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Analysis error - internal analyzer failure, timeout
|
|
163
|
+
*
|
|
164
|
+
* Severity: error (default)
|
|
165
|
+
* Codes: ERR_ANALYSIS_TIMEOUT, ERR_ANALYSIS_INTERNAL
|
|
166
|
+
*/
|
|
167
|
+
export class AnalysisError extends GrafemaError {
|
|
168
|
+
readonly code: string;
|
|
169
|
+
readonly severity = 'error' as const;
|
|
170
|
+
|
|
171
|
+
constructor(message: string, code: string, context: ErrorContext = {}, suggestion?: string) {
|
|
172
|
+
super(message, context, suggestion);
|
|
173
|
+
this.code = code;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Validation error - issues found by validators during VALIDATION phase
|
|
179
|
+
*
|
|
180
|
+
* Unlike other error classes, ValidationError has CONFIGURABLE severity because
|
|
181
|
+
* validators report issues of varying importance:
|
|
182
|
+
* - warning: informational issues (unresolved calls, missing assignments)
|
|
183
|
+
* - error: problems that may indicate bugs (broken references)
|
|
184
|
+
* - fatal: critical issues that should fail the analysis
|
|
185
|
+
*
|
|
186
|
+
* Codes:
|
|
187
|
+
* - ERR_UNRESOLVED_CALL: function call doesn't resolve to definition
|
|
188
|
+
* - ERR_DISCONNECTED_NODES: graph nodes not connected to root
|
|
189
|
+
* - ERR_DISCONNECTED_NODE: individual disconnected node
|
|
190
|
+
* - ERR_MISSING_ASSIGNMENT: variable has no ASSIGNED_FROM edge
|
|
191
|
+
* - ERR_BROKEN_REFERENCE: reference to non-existent node
|
|
192
|
+
* - ERR_NO_LEAF_NODE: data flow doesn't reach leaf node
|
|
193
|
+
*/
|
|
194
|
+
export class ValidationError extends GrafemaError {
|
|
195
|
+
readonly code: string;
|
|
196
|
+
readonly severity: 'fatal' | 'error' | 'warning';
|
|
197
|
+
|
|
198
|
+
constructor(
|
|
199
|
+
message: string,
|
|
200
|
+
code: string,
|
|
201
|
+
context: ErrorContext = {},
|
|
202
|
+
suggestion?: string,
|
|
203
|
+
severity: 'fatal' | 'error' | 'warning' = 'warning'
|
|
204
|
+
) {
|
|
205
|
+
super(message, context, suggestion);
|
|
206
|
+
this.code = code;
|
|
207
|
+
this.severity = severity;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Strict mode error - reported when strictMode=true and an enricher
|
|
213
|
+
* cannot resolve a reference.
|
|
214
|
+
*
|
|
215
|
+
* Unlike other errors, StrictModeError is used to collect issues that
|
|
216
|
+
* would normally be silently skipped. All collected StrictModeErrors
|
|
217
|
+
* cause analysis to fail after the ENRICHMENT phase completes.
|
|
218
|
+
*
|
|
219
|
+
* Severity: fatal (always)
|
|
220
|
+
* Codes:
|
|
221
|
+
* - STRICT_UNRESOLVED_METHOD: Method call cannot be resolved to definition
|
|
222
|
+
* - STRICT_UNRESOLVED_CALL: Function call cannot be resolved to definition
|
|
223
|
+
* - STRICT_UNRESOLVED_ARGUMENT: Argument cannot be linked to parameter
|
|
224
|
+
* - STRICT_ALIAS_DEPTH_EXCEEDED: Alias chain too deep (potential cycle)
|
|
225
|
+
* - STRICT_BROKEN_IMPORT: Import/re-export chain broken
|
|
226
|
+
*/
|
|
227
|
+
export class StrictModeError extends GrafemaError {
|
|
228
|
+
readonly code: string;
|
|
229
|
+
readonly severity = 'fatal' as const;
|
|
230
|
+
|
|
231
|
+
constructor(
|
|
232
|
+
message: string,
|
|
233
|
+
code: string,
|
|
234
|
+
context: ErrorContext = {},
|
|
235
|
+
suggestion?: string
|
|
236
|
+
) {
|
|
237
|
+
super(message, context, suggestion);
|
|
238
|
+
this.code = code;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* A step in the resolution chain showing what was resolved before failure.
|
|
244
|
+
* Used by StrictModeError to provide context-aware error messages (REG-332).
|
|
245
|
+
*/
|
|
246
|
+
export interface ResolutionStep {
|
|
247
|
+
/** Description of what was resolved, e.g., "getUser() return" */
|
|
248
|
+
step: string;
|
|
249
|
+
/** Result of resolution, e.g., "unknown" or "User class" */
|
|
250
|
+
result: string;
|
|
251
|
+
/** File where this step occurred */
|
|
252
|
+
file?: string;
|
|
253
|
+
/** Line number */
|
|
254
|
+
line?: number;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Reasons why resolution can fail.
|
|
259
|
+
* Used by StrictModeError for context-aware suggestions (REG-332).
|
|
260
|
+
*/
|
|
261
|
+
export type ResolutionFailureReason =
|
|
262
|
+
| 'unknown_object_type' // getUser() return unknown
|
|
263
|
+
| 'class_not_imported' // User class not in scope
|
|
264
|
+
| 'method_not_found' // Class exists but no such method
|
|
265
|
+
| 'external_dependency' // From node_modules
|
|
266
|
+
| 'circular_reference' // Alias chain too deep
|
|
267
|
+
| 'builtin_method' // Built-in prototype method (not an error)
|
|
268
|
+
| 'unknown'; // Catch-all
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* StrictModeFailure - thrown when strict mode stops analysis due to fatal errors.
|
|
272
|
+
*
|
|
273
|
+
* Unlike other errors, this carries a reference to the fatal diagnostic(s)
|
|
274
|
+
* rather than duplicating the message. The CLI formats output from
|
|
275
|
+
* the diagnostic, not from error.message.
|
|
276
|
+
*
|
|
277
|
+
* This prevents the duplication issue where both error.message and
|
|
278
|
+
* DiagnosticReporter show the same error (REG-332).
|
|
279
|
+
*/
|
|
280
|
+
export class StrictModeFailure extends Error {
|
|
281
|
+
/** The fatal diagnostics that caused the failure */
|
|
282
|
+
readonly diagnostics: Diagnostic[];
|
|
283
|
+
/** Error count for summary */
|
|
284
|
+
readonly count: number;
|
|
285
|
+
/** REG-332: Number of errors suppressed by grafema-ignore comments */
|
|
286
|
+
readonly suppressedCount: number;
|
|
287
|
+
|
|
288
|
+
constructor(diagnostics: Diagnostic[], suppressedCount: number = 0) {
|
|
289
|
+
// Keep message minimal - CLI will format from diagnostics
|
|
290
|
+
super(`Strict mode: ${diagnostics.length} unresolved reference(s) found`);
|
|
291
|
+
this.name = 'StrictModeFailure';
|
|
292
|
+
this.diagnostics = diagnostics;
|
|
293
|
+
this.count = diagnostics.length;
|
|
294
|
+
this.suppressedCount = suppressedCount;
|
|
295
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
296
|
+
}
|
|
297
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @grafema/util - Query, config, and guarantee utilities for Grafema
|
|
3
|
+
*
|
|
4
|
+
* This package contains the live query layer, configuration, diagnostics,
|
|
5
|
+
* and guarantee management. Analysis is handled by grafema-orchestrator (Rust).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Error types
|
|
9
|
+
export {
|
|
10
|
+
GrafemaError,
|
|
11
|
+
ConfigError,
|
|
12
|
+
FileAccessError,
|
|
13
|
+
LanguageError,
|
|
14
|
+
DatabaseError,
|
|
15
|
+
PluginError,
|
|
16
|
+
AnalysisError,
|
|
17
|
+
ValidationError,
|
|
18
|
+
StrictModeError,
|
|
19
|
+
StrictModeFailure,
|
|
20
|
+
} from './errors/GrafemaError.js';
|
|
21
|
+
export type {
|
|
22
|
+
ErrorContext,
|
|
23
|
+
GrafemaErrorJSON,
|
|
24
|
+
ResolutionStep,
|
|
25
|
+
ResolutionFailureReason,
|
|
26
|
+
} from './errors/GrafemaError.js';
|
|
27
|
+
|
|
28
|
+
// Logging
|
|
29
|
+
export { ConsoleLogger, FileLogger, MultiLogger, createLogger } from './logging/Logger.js';
|
|
30
|
+
export type { Logger, LogLevel } from './logging/Logger.js';
|
|
31
|
+
|
|
32
|
+
// Diagnostics
|
|
33
|
+
export { DiagnosticCollector, DiagnosticReporter, DiagnosticWriter } from './diagnostics/index.js';
|
|
34
|
+
export type { Diagnostic, DiagnosticInput, ReportOptions, SummaryStats } from './diagnostics/index.js';
|
|
35
|
+
export { DIAGNOSTIC_CATEGORIES, CODE_TO_CATEGORY, getCategoryForCode, getCodesForCategory } from './diagnostics/index.js';
|
|
36
|
+
export type { DiagnosticCategory, DiagnosticCategoryKey, CodeCategoryInfo } from './diagnostics/index.js';
|
|
37
|
+
|
|
38
|
+
// Config
|
|
39
|
+
export {
|
|
40
|
+
loadConfig,
|
|
41
|
+
DEFAULT_CONFIG,
|
|
42
|
+
validateVersion,
|
|
43
|
+
validateServices,
|
|
44
|
+
validatePatterns,
|
|
45
|
+
validateWorkspace,
|
|
46
|
+
validateRouting,
|
|
47
|
+
} from './config/index.js';
|
|
48
|
+
export type { GrafemaConfig } from './config/index.js';
|
|
49
|
+
|
|
50
|
+
// Version
|
|
51
|
+
export { GRAFEMA_VERSION, getSchemaVersion } from './version.js';
|
|
52
|
+
|
|
53
|
+
// Instructions (for AI agents)
|
|
54
|
+
export { getOnboardingInstruction } from './instructions/index.js';
|
|
55
|
+
|
|
56
|
+
// Graph backend
|
|
57
|
+
export { GraphBackend, typeToKind, edgeTypeToNumber } from './core/GraphBackend.js';
|
|
58
|
+
export type { Node, Edge, EdgeType, AttrQuery, GraphStats, GraphExport } from './core/GraphBackend.js';
|
|
59
|
+
|
|
60
|
+
// RFDB
|
|
61
|
+
export { RFDBClient } from '@grafema/rfdb-client';
|
|
62
|
+
export { RFDBServerBackend } from './storage/backends/RFDBServerBackend.js';
|
|
63
|
+
|
|
64
|
+
// Core utilities
|
|
65
|
+
export {
|
|
66
|
+
computeSemanticId,
|
|
67
|
+
parseSemanticId,
|
|
68
|
+
computeDiscriminator,
|
|
69
|
+
computeSemanticIdV2,
|
|
70
|
+
parseSemanticIdV2,
|
|
71
|
+
computeContentHash
|
|
72
|
+
} from './core/SemanticId.js';
|
|
73
|
+
export type {
|
|
74
|
+
Location,
|
|
75
|
+
ScopeContext,
|
|
76
|
+
SemanticIdOptions,
|
|
77
|
+
ParsedSemanticId,
|
|
78
|
+
LocatedItem,
|
|
79
|
+
ParsedSemanticIdV2,
|
|
80
|
+
ContentHashHints
|
|
81
|
+
} from './core/SemanticId.js';
|
|
82
|
+
|
|
83
|
+
// URI format
|
|
84
|
+
export {
|
|
85
|
+
isGrafemaUri,
|
|
86
|
+
encodeFragment,
|
|
87
|
+
decodeFragment,
|
|
88
|
+
toGrafemaUri,
|
|
89
|
+
parseGrafemaUri,
|
|
90
|
+
toCompactSemanticId,
|
|
91
|
+
normalizeSemanticId
|
|
92
|
+
} from './core/GrafemaUri.js';
|
|
93
|
+
export type { ParsedGrafemaUri } from './core/GrafemaUri.js';
|
|
94
|
+
|
|
95
|
+
export { GuaranteeManager } from './core/GuaranteeManager.js';
|
|
96
|
+
export type { GuaranteeGraph } from './core/GuaranteeManager.js';
|
|
97
|
+
|
|
98
|
+
// Hash utilities
|
|
99
|
+
export { calculateFileHash, calculateFileHashAsync, calculateContentHash } from './core/HashUtils.js';
|
|
100
|
+
|
|
101
|
+
// Binary finder utilities
|
|
102
|
+
export { findBinary, findAnalyzerBinary, findRfdbBinary, findOrchestratorBinary, getBinaryNotFoundMessage, getPlatformDir, getPlatformPackageName } from './utils/findRfdbBinary.js';
|
|
103
|
+
export type { FindBinaryOptions, BinaryName } from './utils/findRfdbBinary.js';
|
|
104
|
+
|
|
105
|
+
// Lazy download
|
|
106
|
+
export { ensureBinary, downloadBinary, isDownloadable, findInGrafemaBin, getGrafemaBinDir } from './utils/lazyDownload.js';
|
|
107
|
+
|
|
108
|
+
// RFDB server lifecycle
|
|
109
|
+
export { startRfdbServer, checkExistingServer } from './utils/startRfdbServer.js';
|
|
110
|
+
export type { StartRfdbServerOptions } from './utils/startRfdbServer.js';
|
|
111
|
+
|
|
112
|
+
// Module resolution utilities
|
|
113
|
+
export {
|
|
114
|
+
resolveModulePath,
|
|
115
|
+
isRelativeImport,
|
|
116
|
+
resolveRelativeSpecifier,
|
|
117
|
+
DEFAULT_EXTENSIONS,
|
|
118
|
+
DEFAULT_INDEX_FILES
|
|
119
|
+
} from './utils/moduleResolution.js';
|
|
120
|
+
export type { ModuleResolutionOptions } from './utils/moduleResolution.js';
|
|
121
|
+
|
|
122
|
+
// Node file path resolution
|
|
123
|
+
export { resolveNodeFile } from './utils/resolveNodeFile.js';
|
|
124
|
+
|
|
125
|
+
// Type validation and path validation
|
|
126
|
+
export {
|
|
127
|
+
levenshtein,
|
|
128
|
+
checkTypoAgainstKnownTypes,
|
|
129
|
+
resetKnownNodeTypes,
|
|
130
|
+
getKnownNodeTypes
|
|
131
|
+
} from './storage/backends/typeValidation.js';
|
|
132
|
+
export { PathValidator } from './validation/PathValidator.js';
|
|
133
|
+
export type { PathValidationResult, EndpointDiff } from './validation/PathValidator.js';
|
|
134
|
+
|
|
135
|
+
// Version management
|
|
136
|
+
export { VersionManager, versionManager } from './core/VersionManager.js';
|
|
137
|
+
export type { VersionedNode, VersionConstants, EnrichOptions, ModifiedNodeInfo, ChangesSummary, ClassifyChangesResult } from './core/VersionManager.js';
|
|
138
|
+
|
|
139
|
+
// Freshness checking and incremental reanalysis
|
|
140
|
+
export { GraphFreshnessChecker } from './core/GraphFreshnessChecker.js';
|
|
141
|
+
export type { FreshnessGraph, FreshnessResult, StaleModule } from './core/GraphFreshnessChecker.js';
|
|
142
|
+
export { IncrementalReanalyzer } from './core/IncrementalReanalyzer.js';
|
|
143
|
+
export type { ReanalysisOptions, ReanalysisProgress, ReanalysisResult } from './core/IncrementalReanalyzer.js';
|
|
144
|
+
|
|
145
|
+
// Coverage
|
|
146
|
+
export { CoverageAnalyzer } from './core/CoverageAnalyzer.js';
|
|
147
|
+
export type { CoverageResult } from './core/CoverageAnalyzer.js';
|
|
148
|
+
|
|
149
|
+
// File analysis utilities
|
|
150
|
+
export { FileExplainer } from './core/FileExplainer.js';
|
|
151
|
+
export type { FileExplainResult, EnhancedNode } from './core/FileExplainer.js';
|
|
152
|
+
export { FileOverview } from './core/FileOverview.js';
|
|
153
|
+
export type {
|
|
154
|
+
FileOverviewResult,
|
|
155
|
+
ImportInfo,
|
|
156
|
+
ExportInfo,
|
|
157
|
+
FunctionOverview,
|
|
158
|
+
ClassOverview,
|
|
159
|
+
VariableOverview,
|
|
160
|
+
} from './core/FileOverview.js';
|
|
161
|
+
|
|
162
|
+
// Resource system
|
|
163
|
+
export { ResourceRegistryImpl } from './core/ResourceRegistry.js';
|
|
164
|
+
|
|
165
|
+
// API
|
|
166
|
+
export { GraphAPI } from './api/GraphAPI.js';
|
|
167
|
+
export { GuaranteeAPI } from './api/GuaranteeAPI.js';
|
|
168
|
+
export type { GuaranteeGraphBackend } from './api/GuaranteeAPI.js';
|
|
169
|
+
|
|
170
|
+
// Node kinds
|
|
171
|
+
export { isGuaranteeType, isGrafemaType } from './core/nodes/NodeKind.js';
|
|
172
|
+
|
|
173
|
+
// Issue nodes (detected problems)
|
|
174
|
+
export { IssueNode, type IssueNodeRecord, type IssueSeverity, type IssueType } from './core/nodes/IssueNode.js';
|
|
175
|
+
|
|
176
|
+
// Guarantee nodes (contract-based)
|
|
177
|
+
export { GuaranteeNode } from './core/nodes/GuaranteeNode.js';
|
|
178
|
+
export type {
|
|
179
|
+
GuaranteeNodeRecord,
|
|
180
|
+
GuaranteeNodeOptions,
|
|
181
|
+
GuaranteePriority,
|
|
182
|
+
GuaranteeStatus,
|
|
183
|
+
GuaranteeType,
|
|
184
|
+
} from './core/nodes/GuaranteeNode.js';
|
|
185
|
+
|
|
186
|
+
// Schema extraction
|
|
187
|
+
export { InterfaceSchemaExtractor, GraphSchemaExtractor } from './schema/index.js';
|
|
188
|
+
export type {
|
|
189
|
+
InterfaceSchema,
|
|
190
|
+
PropertySchema,
|
|
191
|
+
ExtractOptions,
|
|
192
|
+
GraphSchema,
|
|
193
|
+
NodeTypeSchema,
|
|
194
|
+
EdgeTypeSchema,
|
|
195
|
+
GraphExtractOptions,
|
|
196
|
+
} from './schema/index.js';
|
|
197
|
+
|
|
198
|
+
// Knowledge Base
|
|
199
|
+
export { KnowledgeBase, SemanticAddressResolver, parseSemanticAddress, parseFrontmatter, parseKBNode, serializeKBNode, parseEdgesFile, appendEdge, parseYamlArrayFile, GitIngest, parseGitLog, normalizeAuthors, getChurn, getCoChanges, getOwnership, getArchaeology } from './knowledge/index.js';
|
|
200
|
+
export type { ResolverBackend } from './knowledge/index.js';
|
|
201
|
+
export type {
|
|
202
|
+
KBNodeType,
|
|
203
|
+
KBLifecycle,
|
|
204
|
+
KBScope,
|
|
205
|
+
KBNodeBase,
|
|
206
|
+
KBDecision,
|
|
207
|
+
KBFact,
|
|
208
|
+
KBSession,
|
|
209
|
+
KBNode,
|
|
210
|
+
KBEdge,
|
|
211
|
+
KBStats,
|
|
212
|
+
KBQueryFilter,
|
|
213
|
+
ParsedSemanticAddress,
|
|
214
|
+
ResolvedAddress,
|
|
215
|
+
DanglingCodeRef,
|
|
216
|
+
} from './knowledge/index.js';
|
|
217
|
+
export type { RawCommit, FileChange, AuthorEntry, CommitEntry, IngestResult, Meta } from './knowledge/index.js';
|
|
218
|
+
export type { ChurnEntry, CoChangeEntry, OwnershipEntry, ArchaeologyEntry } from './knowledge/index.js';
|
|
219
|
+
|
|
220
|
+
// Graph Query Utilities
|
|
221
|
+
export { findCallsInFunction, findContainingFunction, traceValues, aggregateValues, NONDETERMINISTIC_PATTERNS, NONDETERMINISTIC_OBJECTS } from './queries/index.js';
|
|
222
|
+
export { traceDataflow, traceForwardBFS, traceBackwardBFS } from './queries/index.js';
|
|
223
|
+
export { buildNodeContext, getNodeDisplayName, formatEdgeMetadata, STRUCTURAL_EDGE_TYPES } from './queries/index.js';
|
|
224
|
+
export type {
|
|
225
|
+
CallInfo,
|
|
226
|
+
CallerInfo,
|
|
227
|
+
FindCallsOptions,
|
|
228
|
+
TracedValue,
|
|
229
|
+
ValueSource,
|
|
230
|
+
UnknownReason,
|
|
231
|
+
TraceValuesOptions,
|
|
232
|
+
ValueSetResult,
|
|
233
|
+
TraceValuesGraphBackend,
|
|
234
|
+
NondeterministicPattern,
|
|
235
|
+
EdgeWithNode,
|
|
236
|
+
EdgeGroup,
|
|
237
|
+
SourcePreview,
|
|
238
|
+
NodeContext,
|
|
239
|
+
BuildNodeContextOptions,
|
|
240
|
+
DataflowNode,
|
|
241
|
+
DataflowEdge,
|
|
242
|
+
DataflowBackend,
|
|
243
|
+
TraceDataflowOptions,
|
|
244
|
+
TraceDataflowResult,
|
|
245
|
+
} from './queries/index.js';
|
|
246
|
+
|
|
247
|
+
// Notation — DSL rendering engine
|
|
248
|
+
export { EDGE_ARCHETYPE_MAP, lookupEdge, generateLegend, PERSPECTIVES, renderNotation, extractSubgraph, shortenName, renderTraceNarrative } from './notation/index.js';
|
|
249
|
+
export type {
|
|
250
|
+
Archetype,
|
|
251
|
+
EdgeMapping,
|
|
252
|
+
DescribeOptions,
|
|
253
|
+
SubgraphData,
|
|
254
|
+
NotationBlock,
|
|
255
|
+
NotationLine,
|
|
256
|
+
TraceDetail,
|
|
257
|
+
TraceNarrativeOptions,
|
|
258
|
+
} from './notation/index.js';
|
|
259
|
+
|
|
260
|
+
// Re-export types for convenience
|
|
261
|
+
export type * from '@grafema/types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grafema instruction documents for AI agents.
|
|
3
|
+
*
|
|
4
|
+
* Instructions are markdown documents that guide agent behavior.
|
|
5
|
+
* They are read at runtime from the installed package.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from 'fs';
|
|
8
|
+
import { join, dirname } from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the onboarding instruction document.
|
|
15
|
+
*
|
|
16
|
+
* Returns the full markdown text of the onboarding procedure
|
|
17
|
+
* that guides an AI agent through project study and configuration.
|
|
18
|
+
*/
|
|
19
|
+
export function getOnboardingInstruction(): string {
|
|
20
|
+
return readFileSync(join(__dirname, 'onboarding.md'), 'utf-8');
|
|
21
|
+
}
|