@harness-engineering/graph 0.2.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.
- package/LICENSE +21 -0
- package/README.md +180 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.mts +581 -0
- package/dist/index.d.ts +581 -0
- package/dist/index.js +2448 -0
- package/dist/index.mjs +2384 -0
- package/package.json +47 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const NODE_TYPES: readonly ["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation"];
|
|
4
|
+
type NodeType = (typeof NODE_TYPES)[number];
|
|
5
|
+
declare const EDGE_TYPES: readonly ["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by"];
|
|
6
|
+
type EdgeType = (typeof EDGE_TYPES)[number];
|
|
7
|
+
declare const OBSERVABILITY_TYPES: ReadonlySet<NodeType>;
|
|
8
|
+
interface SourceLocation {
|
|
9
|
+
readonly fileId: string;
|
|
10
|
+
readonly startLine: number;
|
|
11
|
+
readonly endLine: number;
|
|
12
|
+
readonly startColumn?: number;
|
|
13
|
+
readonly endColumn?: number;
|
|
14
|
+
}
|
|
15
|
+
interface GraphNode {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly type: NodeType;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly path?: string;
|
|
20
|
+
readonly location?: SourceLocation;
|
|
21
|
+
readonly content?: string;
|
|
22
|
+
readonly hash?: string;
|
|
23
|
+
readonly metadata: Record<string, unknown>;
|
|
24
|
+
readonly embedding?: readonly number[];
|
|
25
|
+
readonly lastModified?: string;
|
|
26
|
+
}
|
|
27
|
+
interface GraphEdge {
|
|
28
|
+
readonly from: string;
|
|
29
|
+
readonly to: string;
|
|
30
|
+
readonly type: EdgeType;
|
|
31
|
+
readonly confidence?: number;
|
|
32
|
+
readonly metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
interface ContextQLParams {
|
|
35
|
+
readonly rootNodeIds: readonly string[];
|
|
36
|
+
readonly maxDepth?: number;
|
|
37
|
+
readonly includeTypes?: readonly NodeType[];
|
|
38
|
+
readonly excludeTypes?: readonly NodeType[];
|
|
39
|
+
readonly includeEdges?: readonly EdgeType[];
|
|
40
|
+
readonly bidirectional?: boolean;
|
|
41
|
+
readonly pruneObservability?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface ContextQLResult {
|
|
44
|
+
readonly nodes: readonly GraphNode[];
|
|
45
|
+
readonly edges: readonly GraphEdge[];
|
|
46
|
+
readonly stats: {
|
|
47
|
+
readonly totalTraversed: number;
|
|
48
|
+
readonly totalReturned: number;
|
|
49
|
+
readonly pruned: number;
|
|
50
|
+
readonly depthReached: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface ProjectionSpec {
|
|
54
|
+
readonly fields: readonly (keyof GraphNode)[];
|
|
55
|
+
}
|
|
56
|
+
interface IngestResult {
|
|
57
|
+
readonly nodesAdded: number;
|
|
58
|
+
readonly nodesUpdated: number;
|
|
59
|
+
readonly edgesAdded: number;
|
|
60
|
+
readonly edgesUpdated: number;
|
|
61
|
+
readonly errors: readonly string[];
|
|
62
|
+
readonly durationMs: number;
|
|
63
|
+
}
|
|
64
|
+
interface GraphMetadata {
|
|
65
|
+
readonly schemaVersion: number;
|
|
66
|
+
readonly lastScanTimestamp: string;
|
|
67
|
+
readonly nodeCount: number;
|
|
68
|
+
readonly edgeCount: number;
|
|
69
|
+
}
|
|
70
|
+
declare const CURRENT_SCHEMA_VERSION = 1;
|
|
71
|
+
declare const GraphNodeSchema: z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
type: z.ZodEnum<["repository", "module", "file", "class", "interface", "function", "method", "variable", "adr", "decision", "learning", "failure", "issue", "document", "skill", "conversation", "commit", "build", "test_result", "span", "metric", "log", "layer", "pattern", "constraint", "violation"]>;
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
path: z.ZodOptional<z.ZodString>;
|
|
76
|
+
location: z.ZodOptional<z.ZodObject<{
|
|
77
|
+
fileId: z.ZodString;
|
|
78
|
+
startLine: z.ZodNumber;
|
|
79
|
+
endLine: z.ZodNumber;
|
|
80
|
+
startColumn: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
endColumn: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
fileId: string;
|
|
84
|
+
startLine: number;
|
|
85
|
+
endLine: number;
|
|
86
|
+
startColumn?: number | undefined;
|
|
87
|
+
endColumn?: number | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
fileId: string;
|
|
90
|
+
startLine: number;
|
|
91
|
+
endLine: number;
|
|
92
|
+
startColumn?: number | undefined;
|
|
93
|
+
endColumn?: number | undefined;
|
|
94
|
+
}>>;
|
|
95
|
+
content: z.ZodOptional<z.ZodString>;
|
|
96
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
97
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
98
|
+
embedding: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
99
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
id: string;
|
|
102
|
+
type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation";
|
|
103
|
+
name: string;
|
|
104
|
+
metadata: Record<string, unknown>;
|
|
105
|
+
path?: string | undefined;
|
|
106
|
+
location?: {
|
|
107
|
+
fileId: string;
|
|
108
|
+
startLine: number;
|
|
109
|
+
endLine: number;
|
|
110
|
+
startColumn?: number | undefined;
|
|
111
|
+
endColumn?: number | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
content?: string | undefined;
|
|
114
|
+
hash?: string | undefined;
|
|
115
|
+
embedding?: number[] | undefined;
|
|
116
|
+
lastModified?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
id: string;
|
|
119
|
+
type: "function" | "repository" | "module" | "file" | "class" | "interface" | "method" | "variable" | "adr" | "decision" | "learning" | "failure" | "issue" | "document" | "skill" | "conversation" | "commit" | "build" | "test_result" | "span" | "metric" | "log" | "layer" | "pattern" | "constraint" | "violation";
|
|
120
|
+
name: string;
|
|
121
|
+
metadata: Record<string, unknown>;
|
|
122
|
+
path?: string | undefined;
|
|
123
|
+
location?: {
|
|
124
|
+
fileId: string;
|
|
125
|
+
startLine: number;
|
|
126
|
+
endLine: number;
|
|
127
|
+
startColumn?: number | undefined;
|
|
128
|
+
endColumn?: number | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
content?: string | undefined;
|
|
131
|
+
hash?: string | undefined;
|
|
132
|
+
embedding?: number[] | undefined;
|
|
133
|
+
lastModified?: string | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
declare const GraphEdgeSchema: z.ZodObject<{
|
|
136
|
+
from: z.ZodString;
|
|
137
|
+
to: z.ZodString;
|
|
138
|
+
type: z.ZodEnum<["contains", "imports", "calls", "implements", "inherits", "references", "applies_to", "caused_by", "resolved_by", "documents", "violates", "specifies", "decided", "co_changes_with", "triggered_by", "failed_in", "executed_by", "measured_by"]>;
|
|
139
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by";
|
|
143
|
+
from: string;
|
|
144
|
+
to: string;
|
|
145
|
+
metadata?: Record<string, unknown> | undefined;
|
|
146
|
+
confidence?: number | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
type: "contains" | "imports" | "calls" | "implements" | "inherits" | "references" | "applies_to" | "caused_by" | "resolved_by" | "documents" | "violates" | "specifies" | "decided" | "co_changes_with" | "triggered_by" | "failed_in" | "executed_by" | "measured_by";
|
|
149
|
+
from: string;
|
|
150
|
+
to: string;
|
|
151
|
+
metadata?: Record<string, unknown> | undefined;
|
|
152
|
+
confidence?: number | undefined;
|
|
153
|
+
}>;
|
|
154
|
+
|
|
155
|
+
interface NodeQuery {
|
|
156
|
+
readonly type?: NodeType;
|
|
157
|
+
readonly name?: string;
|
|
158
|
+
readonly path?: string;
|
|
159
|
+
}
|
|
160
|
+
interface EdgeQuery {
|
|
161
|
+
readonly from?: string;
|
|
162
|
+
readonly to?: string;
|
|
163
|
+
readonly type?: EdgeType;
|
|
164
|
+
}
|
|
165
|
+
declare class GraphStore {
|
|
166
|
+
private readonly db;
|
|
167
|
+
private nodes;
|
|
168
|
+
private edges;
|
|
169
|
+
constructor();
|
|
170
|
+
addNode(node: GraphNode): void;
|
|
171
|
+
batchAddNodes(nodes: readonly GraphNode[]): void;
|
|
172
|
+
getNode(id: string): GraphNode | null;
|
|
173
|
+
findNodes(query: NodeQuery): GraphNode[];
|
|
174
|
+
removeNode(id: string): void;
|
|
175
|
+
addEdge(edge: GraphEdge): void;
|
|
176
|
+
batchAddEdges(edges: readonly GraphEdge[]): void;
|
|
177
|
+
getEdges(query: EdgeQuery): GraphEdge[];
|
|
178
|
+
getNeighbors(nodeId: string, direction?: 'outbound' | 'inbound' | 'both'): GraphNode[];
|
|
179
|
+
get nodeCount(): number;
|
|
180
|
+
get edgeCount(): number;
|
|
181
|
+
clear(): void;
|
|
182
|
+
save(dirPath: string): Promise<void>;
|
|
183
|
+
load(dirPath: string): Promise<boolean>;
|
|
184
|
+
private stripLokiMeta;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Result returned from a vector similarity search.
|
|
189
|
+
*/
|
|
190
|
+
interface VectorSearchResult {
|
|
191
|
+
id: string;
|
|
192
|
+
score: number;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A brute-force in-memory vector store that supports add, remove, and
|
|
196
|
+
* top-K cosine-similarity search.
|
|
197
|
+
*/
|
|
198
|
+
declare class VectorStore {
|
|
199
|
+
private readonly dimensions;
|
|
200
|
+
private readonly vectors;
|
|
201
|
+
constructor(dimensions: number);
|
|
202
|
+
/** Number of vectors currently stored. */
|
|
203
|
+
get size(): number;
|
|
204
|
+
/** Add a vector with the given id. Throws if dimensions do not match. */
|
|
205
|
+
add(id: string, vector: readonly number[]): void;
|
|
206
|
+
/** Remove a vector by id. Returns true if the vector existed. */
|
|
207
|
+
remove(id: string): boolean;
|
|
208
|
+
/** Check whether a vector with the given id exists. */
|
|
209
|
+
has(id: string): boolean;
|
|
210
|
+
/** Remove all stored vectors. */
|
|
211
|
+
clear(): void;
|
|
212
|
+
/**
|
|
213
|
+
* Return the top-K most similar vectors to the query, sorted by descending
|
|
214
|
+
* cosine similarity score. If the store contains fewer than topK vectors,
|
|
215
|
+
* all available results are returned.
|
|
216
|
+
*/
|
|
217
|
+
search(query: readonly number[], topK: number): VectorSearchResult[];
|
|
218
|
+
/** Serialize the store to a plain object for persistence. */
|
|
219
|
+
serialize(): {
|
|
220
|
+
dimensions: number;
|
|
221
|
+
vectors: Array<{
|
|
222
|
+
id: string;
|
|
223
|
+
vector: number[];
|
|
224
|
+
}>;
|
|
225
|
+
};
|
|
226
|
+
/** Deserialize a previously-serialized store. */
|
|
227
|
+
static deserialize(data: {
|
|
228
|
+
dimensions: number;
|
|
229
|
+
vectors: Array<{
|
|
230
|
+
id: string;
|
|
231
|
+
vector: number[];
|
|
232
|
+
}>;
|
|
233
|
+
}): VectorStore;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface SerializedGraph {
|
|
237
|
+
readonly nodes: readonly GraphNode[];
|
|
238
|
+
readonly edges: readonly GraphEdge[];
|
|
239
|
+
}
|
|
240
|
+
declare function saveGraph(dirPath: string, nodes: readonly GraphNode[], edges: readonly GraphEdge[]): Promise<void>;
|
|
241
|
+
declare function loadGraph(dirPath: string): Promise<SerializedGraph | null>;
|
|
242
|
+
|
|
243
|
+
declare class ContextQL {
|
|
244
|
+
private readonly store;
|
|
245
|
+
constructor(store: GraphStore);
|
|
246
|
+
execute(params: ContextQLParams): ContextQLResult;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
declare function project(nodes: readonly GraphNode[], spec: ProjectionSpec | undefined): Partial<GraphNode>[];
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Ingests TypeScript/JavaScript files into the graph via regex-based parsing.
|
|
253
|
+
* Future: upgrade to tree-sitter for full AST parsing.
|
|
254
|
+
*/
|
|
255
|
+
declare class CodeIngestor {
|
|
256
|
+
private readonly store;
|
|
257
|
+
constructor(store: GraphStore);
|
|
258
|
+
ingest(rootDir: string): Promise<IngestResult>;
|
|
259
|
+
private findSourceFiles;
|
|
260
|
+
private extractSymbols;
|
|
261
|
+
/**
|
|
262
|
+
* Find the closing brace for a construct starting at the given line.
|
|
263
|
+
* Uses a simple brace-counting heuristic. Returns 1-indexed line number.
|
|
264
|
+
*/
|
|
265
|
+
private findClosingBrace;
|
|
266
|
+
/**
|
|
267
|
+
* Second pass: for each function/method, check if its file content calls any other
|
|
268
|
+
* known function/method. Creates approximate "calls" edges via regex matching.
|
|
269
|
+
*/
|
|
270
|
+
private extractCallsEdges;
|
|
271
|
+
private escapeRegex;
|
|
272
|
+
private extractImports;
|
|
273
|
+
private resolveImportPath;
|
|
274
|
+
private detectLanguage;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
type GitRunner = (rootDir: string, args: string[]) => Promise<string>;
|
|
278
|
+
/**
|
|
279
|
+
* Ingests git history into the graph, creating commit nodes,
|
|
280
|
+
* triggered_by edges (file -> commit), and co_changes_with edges
|
|
281
|
+
* for files frequently modified together.
|
|
282
|
+
*/
|
|
283
|
+
declare class GitIngestor {
|
|
284
|
+
private readonly store;
|
|
285
|
+
private readonly gitRunner?;
|
|
286
|
+
constructor(store: GraphStore, gitRunner?: GitRunner | undefined);
|
|
287
|
+
ingest(rootDir: string): Promise<IngestResult>;
|
|
288
|
+
private runGit;
|
|
289
|
+
private parseGitLog;
|
|
290
|
+
private computeCoChanges;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface LinkResult {
|
|
294
|
+
readonly edgesAdded: number;
|
|
295
|
+
readonly cycles: readonly string[][];
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Post-ingestion linker that:
|
|
299
|
+
* 1. Groups files into module nodes based on directory structure
|
|
300
|
+
* 2. Detects circular dependencies in the import graph
|
|
301
|
+
*/
|
|
302
|
+
declare class TopologicalLinker {
|
|
303
|
+
private readonly store;
|
|
304
|
+
constructor(store: GraphStore);
|
|
305
|
+
link(): LinkResult;
|
|
306
|
+
private detectCycles;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
declare class KnowledgeIngestor {
|
|
310
|
+
private readonly store;
|
|
311
|
+
constructor(store: GraphStore);
|
|
312
|
+
ingestADRs(adrDir: string): Promise<IngestResult>;
|
|
313
|
+
ingestLearnings(projectPath: string): Promise<IngestResult>;
|
|
314
|
+
ingestFailures(projectPath: string): Promise<IngestResult>;
|
|
315
|
+
ingestAll(projectPath: string, opts?: {
|
|
316
|
+
adrDir?: string;
|
|
317
|
+
}): Promise<IngestResult>;
|
|
318
|
+
private linkToCode;
|
|
319
|
+
private findMarkdownFiles;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
type HttpClient = (url: string, options?: {
|
|
323
|
+
headers?: Record<string, string>;
|
|
324
|
+
}) => Promise<{
|
|
325
|
+
ok: boolean;
|
|
326
|
+
status?: number;
|
|
327
|
+
json(): Promise<unknown>;
|
|
328
|
+
}>;
|
|
329
|
+
interface ConnectorConfig {
|
|
330
|
+
apiKeyEnv?: string;
|
|
331
|
+
baseUrlEnv?: string;
|
|
332
|
+
schedule?: string;
|
|
333
|
+
lookbackDays?: number;
|
|
334
|
+
filters?: Record<string, unknown>;
|
|
335
|
+
[key: string]: unknown;
|
|
336
|
+
}
|
|
337
|
+
interface GraphConnector {
|
|
338
|
+
readonly name: string;
|
|
339
|
+
readonly source: string;
|
|
340
|
+
ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
|
|
341
|
+
}
|
|
342
|
+
interface SyncMetadata {
|
|
343
|
+
connectors: Record<string, {
|
|
344
|
+
lastSyncTimestamp: string;
|
|
345
|
+
lastResult: IngestResult;
|
|
346
|
+
}>;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
declare function linkToCode(store: GraphStore, content: string, sourceNodeId: string, edgeType: EdgeType, options?: {
|
|
350
|
+
checkPaths?: boolean;
|
|
351
|
+
}): number;
|
|
352
|
+
|
|
353
|
+
declare class SyncManager {
|
|
354
|
+
private readonly store;
|
|
355
|
+
private readonly registrations;
|
|
356
|
+
private readonly metadataPath;
|
|
357
|
+
constructor(store: GraphStore, graphDir: string);
|
|
358
|
+
registerConnector(connector: GraphConnector, config: ConnectorConfig): void;
|
|
359
|
+
sync(connectorName: string): Promise<IngestResult>;
|
|
360
|
+
syncAll(): Promise<IngestResult>;
|
|
361
|
+
getMetadata(): Promise<SyncMetadata>;
|
|
362
|
+
private loadMetadata;
|
|
363
|
+
private saveMetadata;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
declare class JiraConnector implements GraphConnector {
|
|
367
|
+
readonly name = "jira";
|
|
368
|
+
readonly source = "jira";
|
|
369
|
+
private readonly httpClient;
|
|
370
|
+
constructor(httpClient?: HttpClient);
|
|
371
|
+
ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
declare class SlackConnector implements GraphConnector {
|
|
375
|
+
readonly name = "slack";
|
|
376
|
+
readonly source = "slack";
|
|
377
|
+
private readonly httpClient;
|
|
378
|
+
constructor(httpClient?: HttpClient);
|
|
379
|
+
ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
declare class ConfluenceConnector implements GraphConnector {
|
|
383
|
+
readonly name = "confluence";
|
|
384
|
+
readonly source = "confluence";
|
|
385
|
+
private readonly httpClient;
|
|
386
|
+
constructor(httpClient?: HttpClient);
|
|
387
|
+
ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare class CIConnector implements GraphConnector {
|
|
391
|
+
readonly name = "ci";
|
|
392
|
+
readonly source = "github-actions";
|
|
393
|
+
private readonly httpClient;
|
|
394
|
+
constructor(httpClient?: HttpClient);
|
|
395
|
+
ingest(store: GraphStore, config: ConnectorConfig): Promise<IngestResult>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
interface FusionResult {
|
|
399
|
+
readonly nodeId: string;
|
|
400
|
+
readonly node: GraphNode;
|
|
401
|
+
readonly score: number;
|
|
402
|
+
readonly signals: {
|
|
403
|
+
readonly keyword: number;
|
|
404
|
+
readonly semantic: number;
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
declare class FusionLayer {
|
|
408
|
+
private readonly store;
|
|
409
|
+
private readonly vectorStore;
|
|
410
|
+
private readonly keywordWeight;
|
|
411
|
+
private readonly semanticWeight;
|
|
412
|
+
constructor(store: GraphStore, vectorStore?: VectorStore, keywordWeight?: number, semanticWeight?: number);
|
|
413
|
+
search(query: string, topK?: number, queryEmbedding?: readonly number[]): FusionResult[];
|
|
414
|
+
private extractKeywords;
|
|
415
|
+
private keywordScore;
|
|
416
|
+
private singleKeywordScore;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
interface GraphDriftData {
|
|
420
|
+
readonly staleEdges: ReadonlyArray<{
|
|
421
|
+
docNodeId: string;
|
|
422
|
+
codeNodeId: string;
|
|
423
|
+
edgeType: string;
|
|
424
|
+
codeLastModified?: string | undefined;
|
|
425
|
+
docLastModified?: string | undefined;
|
|
426
|
+
}>;
|
|
427
|
+
readonly missingTargets: readonly string[];
|
|
428
|
+
readonly freshEdges: number;
|
|
429
|
+
}
|
|
430
|
+
interface GraphDeadCodeData {
|
|
431
|
+
readonly reachableNodeIds: ReadonlySet<string>;
|
|
432
|
+
readonly unreachableNodes: ReadonlyArray<{
|
|
433
|
+
id: string;
|
|
434
|
+
type: string;
|
|
435
|
+
name: string;
|
|
436
|
+
path?: string | undefined;
|
|
437
|
+
}>;
|
|
438
|
+
readonly entryPoints: readonly string[];
|
|
439
|
+
}
|
|
440
|
+
interface GraphSnapshotSummary {
|
|
441
|
+
readonly nodeCount: number;
|
|
442
|
+
readonly edgeCount: number;
|
|
443
|
+
readonly nodesByType: Record<string, number>;
|
|
444
|
+
readonly edgesByType: Record<string, number>;
|
|
445
|
+
}
|
|
446
|
+
declare class GraphEntropyAdapter {
|
|
447
|
+
private readonly store;
|
|
448
|
+
constructor(store: GraphStore);
|
|
449
|
+
/**
|
|
450
|
+
* Find all `documents` edges and classify them as stale or missing-target.
|
|
451
|
+
*
|
|
452
|
+
* 1. Find all `documents` edges in the graph
|
|
453
|
+
* 2. For each edge, check if the target code node still exists in the store
|
|
454
|
+
* 3. If target doesn't exist -> add to missingTargets
|
|
455
|
+
* 4. If target exists -> compare lastModified timestamps to determine staleness
|
|
456
|
+
*/
|
|
457
|
+
computeDriftData(): GraphDriftData;
|
|
458
|
+
/**
|
|
459
|
+
* BFS from entry points to find reachable vs unreachable code nodes.
|
|
460
|
+
*
|
|
461
|
+
* 1. Entry points: file nodes named `index.ts` or with metadata `entryPoint: true`
|
|
462
|
+
* 2. BFS following `imports` and `calls` edges (outbound only)
|
|
463
|
+
* 3. Unreachable = code nodes NOT in visited set
|
|
464
|
+
*/
|
|
465
|
+
computeDeadCodeData(): GraphDeadCodeData;
|
|
466
|
+
/**
|
|
467
|
+
* Count all nodes and edges by type.
|
|
468
|
+
*/
|
|
469
|
+
computeSnapshotSummary(): GraphSnapshotSummary;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
interface AssembledContext {
|
|
473
|
+
readonly nodes: readonly GraphNode[];
|
|
474
|
+
readonly edges: readonly GraphEdge[];
|
|
475
|
+
readonly tokenEstimate: number;
|
|
476
|
+
readonly intent: string;
|
|
477
|
+
readonly truncated: boolean;
|
|
478
|
+
}
|
|
479
|
+
interface GraphBudget {
|
|
480
|
+
readonly total: number;
|
|
481
|
+
readonly allocations: Record<string, number>;
|
|
482
|
+
readonly density: Record<string, number>;
|
|
483
|
+
}
|
|
484
|
+
interface GraphFilterResult {
|
|
485
|
+
readonly phase: string;
|
|
486
|
+
readonly nodes: readonly GraphNode[];
|
|
487
|
+
readonly filePaths: readonly string[];
|
|
488
|
+
}
|
|
489
|
+
interface GraphCoverageReport {
|
|
490
|
+
readonly documented: readonly string[];
|
|
491
|
+
readonly undocumented: readonly string[];
|
|
492
|
+
readonly coveragePercentage: number;
|
|
493
|
+
readonly totalCodeNodes: number;
|
|
494
|
+
}
|
|
495
|
+
declare class Assembler {
|
|
496
|
+
private readonly store;
|
|
497
|
+
private readonly vectorStore;
|
|
498
|
+
private fusionLayer;
|
|
499
|
+
constructor(store: GraphStore, vectorStore?: VectorStore);
|
|
500
|
+
private getFusionLayer;
|
|
501
|
+
/**
|
|
502
|
+
* Assemble context relevant to an intent string within a token budget.
|
|
503
|
+
*/
|
|
504
|
+
assembleContext(intent: string, tokenBudget?: number): AssembledContext;
|
|
505
|
+
/**
|
|
506
|
+
* Compute a token budget allocation across node types.
|
|
507
|
+
*/
|
|
508
|
+
computeBudget(totalTokens: number, phase?: string): GraphBudget;
|
|
509
|
+
/**
|
|
510
|
+
* Filter graph nodes relevant to a development phase.
|
|
511
|
+
*/
|
|
512
|
+
filterForPhase(phase: string): GraphFilterResult;
|
|
513
|
+
/**
|
|
514
|
+
* Generate a markdown repository map from graph structure.
|
|
515
|
+
*/
|
|
516
|
+
generateMap(): string;
|
|
517
|
+
/**
|
|
518
|
+
* Check documentation coverage of code nodes.
|
|
519
|
+
*/
|
|
520
|
+
checkCoverage(): GraphCoverageReport;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
interface GraphDependencyData {
|
|
524
|
+
readonly nodes: readonly string[];
|
|
525
|
+
readonly edges: ReadonlyArray<{
|
|
526
|
+
from: string;
|
|
527
|
+
to: string;
|
|
528
|
+
importType: 'static' | 'dynamic' | 'type-only';
|
|
529
|
+
line: number;
|
|
530
|
+
}>;
|
|
531
|
+
}
|
|
532
|
+
interface GraphLayerViolation {
|
|
533
|
+
file: string;
|
|
534
|
+
imports: string;
|
|
535
|
+
fromLayer: string;
|
|
536
|
+
toLayer: string;
|
|
537
|
+
reason: 'WRONG_LAYER';
|
|
538
|
+
line: number;
|
|
539
|
+
}
|
|
540
|
+
interface LayerDef {
|
|
541
|
+
name: string;
|
|
542
|
+
patterns: string[];
|
|
543
|
+
allowedDependencies: string[];
|
|
544
|
+
}
|
|
545
|
+
declare class GraphConstraintAdapter {
|
|
546
|
+
private readonly store;
|
|
547
|
+
constructor(store: GraphStore);
|
|
548
|
+
computeDependencyGraph(): GraphDependencyData;
|
|
549
|
+
computeLayerViolations(layers: LayerDef[], rootDir: string): GraphLayerViolation[];
|
|
550
|
+
private resolveLayer;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
interface GraphImpactData {
|
|
554
|
+
readonly affectedTests: ReadonlyArray<{
|
|
555
|
+
testFile: string;
|
|
556
|
+
coversFile: string;
|
|
557
|
+
}>;
|
|
558
|
+
readonly affectedDocs: ReadonlyArray<{
|
|
559
|
+
docFile: string;
|
|
560
|
+
documentsFile: string;
|
|
561
|
+
}>;
|
|
562
|
+
readonly impactScope: number;
|
|
563
|
+
}
|
|
564
|
+
interface GraphHarnessCheckData {
|
|
565
|
+
readonly graphExists: boolean;
|
|
566
|
+
readonly nodeCount: number;
|
|
567
|
+
readonly edgeCount: number;
|
|
568
|
+
readonly constraintViolations: number;
|
|
569
|
+
readonly undocumentedFiles: number;
|
|
570
|
+
readonly unreachableNodes: number;
|
|
571
|
+
}
|
|
572
|
+
declare class GraphFeedbackAdapter {
|
|
573
|
+
private readonly store;
|
|
574
|
+
constructor(store: GraphStore);
|
|
575
|
+
computeImpactData(changedFiles: string[]): GraphImpactData;
|
|
576
|
+
computeHarnessCheckData(): GraphHarnessCheckData;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare const VERSION = "0.1.0";
|
|
580
|
+
|
|
581
|
+
export { type AssembledContext, Assembler, CIConnector, CURRENT_SCHEMA_VERSION, CodeIngestor, ConfluenceConnector, type ConnectorConfig, ContextQL, type ContextQLParams, type ContextQLResult, EDGE_TYPES, type EdgeQuery, type EdgeType, FusionLayer, type FusionResult, GitIngestor, type GitRunner, type GraphBudget, type GraphConnector, GraphConstraintAdapter, type GraphCoverageReport, type GraphDeadCodeData, type GraphDependencyData, type GraphDriftData, type GraphEdge, GraphEdgeSchema, GraphEntropyAdapter, GraphFeedbackAdapter, type GraphFilterResult, type GraphHarnessCheckData, type GraphImpactData, type GraphLayerViolation, type GraphMetadata, type GraphNode, GraphNodeSchema, type GraphSnapshotSummary, GraphStore, type HttpClient, type IngestResult, JiraConnector, KnowledgeIngestor, type LinkResult, NODE_TYPES, type NodeQuery, type NodeType, OBSERVABILITY_TYPES, type ProjectionSpec, SlackConnector, type SourceLocation, SyncManager, type SyncMetadata, TopologicalLinker, VERSION, type VectorSearchResult, VectorStore, linkToCode, loadGraph, project, saveGraph };
|