@principal-ai/principal-view-react 0.16.47 → 0.16.50
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/dist/graphify/anchor.d.ts +28 -0
- package/dist/graphify/anchor.d.ts.map +1 -0
- package/dist/graphify/anchor.js +132 -0
- package/dist/graphify/anchor.js.map +1 -0
- package/dist/graphify/consolidated.d.ts +12 -1
- package/dist/graphify/consolidated.d.ts.map +1 -1
- package/dist/graphify/ids.d.ts +19 -0
- package/dist/graphify/ids.d.ts.map +1 -0
- package/dist/graphify/ids.js +46 -0
- package/dist/graphify/ids.js.map +1 -0
- package/dist/graphify/index.d.ts +7 -0
- package/dist/graphify/index.d.ts.map +1 -1
- package/dist/graphify/index.js +4 -0
- package/dist/graphify/index.js.map +1 -1
- package/dist/graphify/kind.d.ts +23 -0
- package/dist/graphify/kind.d.ts.map +1 -0
- package/dist/graphify/kind.js +71 -0
- package/dist/graphify/kind.js.map +1 -0
- package/dist/graphify/signature.d.ts +87 -0
- package/dist/graphify/signature.d.ts.map +1 -0
- package/dist/graphify/signature.js +276 -0
- package/dist/graphify/signature.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/subsystem/ComponentDeclaration.d.ts +58 -3
- package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -1
- package/dist/subsystem/ComponentDeclaration.js +186 -53
- package/dist/subsystem/ComponentDeclaration.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +5 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +2 -2
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/formatDeclaration.d.ts.map +1 -1
- package/dist/subsystem/formatDeclaration.js +12 -1
- package/dist/subsystem/formatDeclaration.js.map +1 -1
- package/dist/subsystem/model.d.ts +1 -1
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +1 -0
- package/dist/subsystem/model.js.map +1 -1
- package/package.json +1 -1
- package/src/graphify/anchor.test.ts +124 -0
- package/src/graphify/anchor.ts +160 -0
- package/src/graphify/consolidated.ts +13 -0
- package/src/graphify/ids.ts +48 -0
- package/src/graphify/index.ts +26 -0
- package/src/graphify/kind.test.ts +108 -0
- package/src/graphify/kind.ts +114 -0
- package/src/graphify/signature.test.ts +278 -0
- package/src/graphify/signature.ts +354 -0
- package/src/index.ts +26 -0
- package/src/stories/ComponentDeclarationAudit.stories.tsx +32 -0
- package/src/subsystem/ComponentDeclaration.tsx +306 -56
- package/src/subsystem/SubsystemComponentGraph.tsx +8 -1
- package/src/subsystem/formatDeclaration.ts +13 -1
- package/src/subsystem/model.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/subsystem/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,IAAI,EACV,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3D,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,UAAU,GACV,MAAM,GACN,QAAQ,GACR,UAAU,CAAC;AAMf,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,MAAM,GACN,QAAQ,GACR,MAAM,GACN,aAAa,GACb,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,cAAc,GACd,YAAY,GACZ,SAAS,GACT,OAAO,GACP,SAAS,GACT,UAAU,GACV,YAAY,GACZ,UAAU,GACV,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,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GAAG,MAAM,CAAC,SAAS,CAAC;SACnC;QAAC,OAAO,GAAG,EAAE;YACZ,8DAA8D;YAC9D,OAAO,CAAC,IAAI,CAAC,8DAA8D,EAAE,GAAG,CAAC,CAAC;SACnF;KACF;IAED,uEAAuE;IACvE,8EAA8E;IAC9E,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,GAAG,EAAE;YACP,MAAM,CAAC,GAAI,CAAwB,CAAC,IAA8B,CAAC;YACnE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;YACjB,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;SAClB;QACD,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,GAAI,CAAwB,CAAC,IAA8B,CAAC;YACnE,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC;SAClB;KACF;IAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import type { GraphifyNode } from './types';
|
|
3
|
+
import {
|
|
4
|
+
graphifyFileStem,
|
|
5
|
+
makeGraphifyId,
|
|
6
|
+
normalizeGraphifyId,
|
|
7
|
+
} from './ids';
|
|
8
|
+
import { resolveComponentAnchor, symbolLabelVariants } from './anchor';
|
|
9
|
+
|
|
10
|
+
function node(
|
|
11
|
+
id: string,
|
|
12
|
+
label: string,
|
|
13
|
+
sourceFile: string,
|
|
14
|
+
location?: string,
|
|
15
|
+
): GraphifyNode {
|
|
16
|
+
return {
|
|
17
|
+
id,
|
|
18
|
+
label,
|
|
19
|
+
file_type: 'code',
|
|
20
|
+
source_file: sourceFile,
|
|
21
|
+
source_location: location ?? '',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('makeGraphifyId', () => {
|
|
26
|
+
test('matches graphify path+symbol slug shape', () => {
|
|
27
|
+
const stem = graphifyFileStem(
|
|
28
|
+
'packages/trail-viewer/src/mainview/views/SubsystemGraphView.tsx',
|
|
29
|
+
);
|
|
30
|
+
expect(stem).toBe(
|
|
31
|
+
'packages/trail-viewer/src/mainview/views/SubsystemGraphView',
|
|
32
|
+
);
|
|
33
|
+
expect(makeGraphifyId(stem, 'SubsystemGraphView')).toBe(
|
|
34
|
+
'packages_trail_viewer_src_mainview_views_subsystemgraphview_subsystemgraphview',
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('normalize is idempotent on ascii', () => {
|
|
39
|
+
const id = makeGraphifyId('Foo/Bar', 'Baz');
|
|
40
|
+
expect(normalizeGraphifyId(id)).toBe(id);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('symbolLabelVariants', () => {
|
|
45
|
+
test('includes call-style labels', () => {
|
|
46
|
+
expect(symbolLabelVariants('SubsystemGraphView')).toContain(
|
|
47
|
+
'SubsystemGraphView()',
|
|
48
|
+
);
|
|
49
|
+
expect(symbolLabelVariants('SessionReader.normalize')).toContain('normalize()');
|
|
50
|
+
expect(symbolLabelVariants('SessionReader.normalize')).toContain('.normalize()');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('resolveComponentAnchor', () => {
|
|
55
|
+
const file =
|
|
56
|
+
'packages/trail-viewer/src/mainview/views/SubsystemGraphView.tsx';
|
|
57
|
+
const defId = makeGraphifyId(graphifyFileStem(file), 'SubsystemGraphView');
|
|
58
|
+
const corpus: GraphifyNode[] = [
|
|
59
|
+
node(defId, 'SubsystemGraphView()', file, 'L27'),
|
|
60
|
+
node(
|
|
61
|
+
makeGraphifyId(graphifyFileStem(file)),
|
|
62
|
+
'SubsystemGraphView.tsx',
|
|
63
|
+
file,
|
|
64
|
+
'L1',
|
|
65
|
+
),
|
|
66
|
+
node(
|
|
67
|
+
makeGraphifyId(
|
|
68
|
+
graphifyFileStem('other/SessionReader.ts'),
|
|
69
|
+
'SessionReader',
|
|
70
|
+
),
|
|
71
|
+
'SessionReader',
|
|
72
|
+
'other/SessionReader.ts',
|
|
73
|
+
'L1',
|
|
74
|
+
),
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
test('exact via make_id reconstruction', () => {
|
|
78
|
+
const r = resolveComponentAnchor(corpus, {
|
|
79
|
+
file,
|
|
80
|
+
symbol: 'SubsystemGraphView',
|
|
81
|
+
});
|
|
82
|
+
expect(r.resolution).toBe('exact');
|
|
83
|
+
expect(r.node?.id).toBe(defId);
|
|
84
|
+
expect(r.node?.source_location).toBe('L27');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('exact via label when id reconstruction misses', () => {
|
|
88
|
+
const weirdId = 'weird_id_not_from_make_id';
|
|
89
|
+
const local = [
|
|
90
|
+
node(weirdId, 'subsystemGraphToExcalidrawScene()', 'packages/x.ts', 'L10'),
|
|
91
|
+
];
|
|
92
|
+
const r = resolveComponentAnchor(local, {
|
|
93
|
+
file: 'packages/x.ts',
|
|
94
|
+
symbol: 'subsystemGraphToExcalidrawScene',
|
|
95
|
+
});
|
|
96
|
+
expect(r.resolution).toBe('exact');
|
|
97
|
+
expect(r.node?.id).toBe(weirdId);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('file-only when file has nodes but symbol misses', () => {
|
|
101
|
+
const r = resolveComponentAnchor(corpus, {
|
|
102
|
+
file,
|
|
103
|
+
symbol: 'DoesNotExist',
|
|
104
|
+
});
|
|
105
|
+
expect(r.resolution).toBe('file-only');
|
|
106
|
+
expect(r.candidates.length).toBeGreaterThan(0);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('missing when file absent from graph', () => {
|
|
110
|
+
const r = resolveComponentAnchor(corpus, {
|
|
111
|
+
file: 'no/such/file.ts',
|
|
112
|
+
symbol: 'Foo',
|
|
113
|
+
});
|
|
114
|
+
expect(r.resolution).toBe('missing');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('does not bind via corpus-wide same name in another file', () => {
|
|
118
|
+
const r = resolveComponentAnchor(corpus, {
|
|
119
|
+
file: 'packages/elsewhere/SessionReader.ts',
|
|
120
|
+
symbol: 'SessionReader',
|
|
121
|
+
});
|
|
122
|
+
expect(r.resolution).toBe('missing');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a subsystem component (file + symbol) to a graphify definition node.
|
|
3
|
+
*
|
|
4
|
+
* This is component *anchoring*, not type-ref stub rewiring (`resolve.ts`).
|
|
5
|
+
* Conservative: never bind via corpus-wide same-name alone.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { GraphifyNode } from './types';
|
|
9
|
+
import type { GraphifyAnchorResolution } from './consolidated';
|
|
10
|
+
import { normalizeGraphifyLabel } from './resolve';
|
|
11
|
+
import {
|
|
12
|
+
graphifyFileStem,
|
|
13
|
+
makeGraphifyId,
|
|
14
|
+
normalizeSourcePath,
|
|
15
|
+
} from './ids';
|
|
16
|
+
|
|
17
|
+
export interface ComponentAnchorInput {
|
|
18
|
+
file?: string;
|
|
19
|
+
symbol?: string;
|
|
20
|
+
kind?: string;
|
|
21
|
+
purl?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ComponentAnchorResult {
|
|
25
|
+
resolution: GraphifyAnchorResolution;
|
|
26
|
+
node: GraphifyNode | null;
|
|
27
|
+
candidates: GraphifyNode[];
|
|
28
|
+
/** make_id strings attempted on the fast path. */
|
|
29
|
+
triedIds: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const FILE_SUFFIX_RE =
|
|
33
|
+
/\.(py|js|jsx|ts|tsx|mjs|cjs|java|go|rs|rb|php|cs|cpp|cc|c|h|hpp|pas|pp|dpr|swift|kt|scala|dart|lua|pl|pm|ex|exs|zig|vue|svelte)$/i;
|
|
34
|
+
|
|
35
|
+
function isDefinition(node: GraphifyNode): boolean {
|
|
36
|
+
if (node.file_type !== 'code') return false;
|
|
37
|
+
const file = typeof node.source_file === 'string' ? node.source_file : '';
|
|
38
|
+
if (!file) return false;
|
|
39
|
+
const label = typeof node.label === 'string' ? node.label.trim() : '';
|
|
40
|
+
return !!label && !FILE_SUFFIX_RE.test(label);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Label forms that might match a subsystem symbol on a graphify node. */
|
|
44
|
+
export function symbolLabelVariants(symbol: string): string[] {
|
|
45
|
+
const raw = symbol.trim();
|
|
46
|
+
if (!raw) return [];
|
|
47
|
+
const last = raw.includes('.') ? (raw.split('.').pop() ?? raw) : raw;
|
|
48
|
+
const variants = new Set<string>([
|
|
49
|
+
raw,
|
|
50
|
+
last,
|
|
51
|
+
`${raw}()`,
|
|
52
|
+
`${last}()`,
|
|
53
|
+
`.${last}()`,
|
|
54
|
+
`.${last}`,
|
|
55
|
+
]);
|
|
56
|
+
return [...variants];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function labelMatchesSymbol(label: string, symbol: string): boolean {
|
|
60
|
+
const variants = symbolLabelVariants(symbol);
|
|
61
|
+
const trimmed = label.trim();
|
|
62
|
+
if (variants.includes(trimmed)) return true;
|
|
63
|
+
const foldedLabel = normalizeGraphifyLabel(trimmed);
|
|
64
|
+
return variants.some((v) => normalizeGraphifyLabel(v) === foldedLabel);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function candidateIdsFor(file: string, symbol: string): string[] {
|
|
68
|
+
const stem = graphifyFileStem(file);
|
|
69
|
+
if (!stem) return [];
|
|
70
|
+
const parts = symbol.split('.').map((p) => p.trim()).filter(Boolean);
|
|
71
|
+
const ids = new Set<string>();
|
|
72
|
+
ids.add(makeGraphifyId(stem, symbol));
|
|
73
|
+
if (parts.length > 0) ids.add(makeGraphifyId(stem, ...parts));
|
|
74
|
+
if (parts.length === 2) {
|
|
75
|
+
// Class method: make_id(class_id, method) ≈ make_id(stem, Class, method)
|
|
76
|
+
ids.add(makeGraphifyId(stem, parts[0]!, parts[1]!));
|
|
77
|
+
}
|
|
78
|
+
return [...ids];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Anchor a subsystem component onto a graphify definition node.
|
|
83
|
+
*/
|
|
84
|
+
export function resolveComponentAnchor(
|
|
85
|
+
nodes: readonly GraphifyNode[],
|
|
86
|
+
input: ComponentAnchorInput,
|
|
87
|
+
): ComponentAnchorResult {
|
|
88
|
+
const file = input.file?.trim() ? normalizeSourcePath(input.file) : '';
|
|
89
|
+
const symbol = input.symbol?.trim() ?? '';
|
|
90
|
+
if (!file || !symbol) {
|
|
91
|
+
return { resolution: 'missing', node: null, candidates: [], triedIds: [] };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const byId = new Map<string, GraphifyNode>();
|
|
95
|
+
const inFile: GraphifyNode[] = [];
|
|
96
|
+
for (const node of nodes) {
|
|
97
|
+
byId.set(String(node.id), node);
|
|
98
|
+
if (!isDefinition(node)) continue;
|
|
99
|
+
const sf = normalizeSourcePath(String(node.source_file ?? ''));
|
|
100
|
+
if (sf === file) inFile.push(node);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const triedIds = candidateIdsFor(file, symbol);
|
|
104
|
+
const idHits: GraphifyNode[] = [];
|
|
105
|
+
for (const id of triedIds) {
|
|
106
|
+
const hit = byId.get(id);
|
|
107
|
+
if (!hit || !isDefinition(hit)) continue;
|
|
108
|
+
const sf = normalizeSourcePath(String(hit.source_file ?? ''));
|
|
109
|
+
if (sf === file) idHits.push(hit);
|
|
110
|
+
}
|
|
111
|
+
const uniqueIdHits = [...new Map(idHits.map((n) => [String(n.id), n])).values()];
|
|
112
|
+
if (uniqueIdHits.length === 1) {
|
|
113
|
+
return {
|
|
114
|
+
resolution: 'exact',
|
|
115
|
+
node: uniqueIdHits[0]!,
|
|
116
|
+
candidates: [],
|
|
117
|
+
triedIds,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (uniqueIdHits.length > 1) {
|
|
121
|
+
return {
|
|
122
|
+
resolution: 'ambiguous',
|
|
123
|
+
node: null,
|
|
124
|
+
candidates: uniqueIdHits,
|
|
125
|
+
triedIds,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (inFile.length === 0) {
|
|
130
|
+
return { resolution: 'missing', node: null, candidates: [], triedIds };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const labelHits = inFile.filter((n) =>
|
|
134
|
+
labelMatchesSymbol(String(n.label ?? ''), symbol),
|
|
135
|
+
);
|
|
136
|
+
if (labelHits.length === 1) {
|
|
137
|
+
return {
|
|
138
|
+
resolution: 'exact',
|
|
139
|
+
node: labelHits[0]!,
|
|
140
|
+
candidates: [],
|
|
141
|
+
triedIds,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (labelHits.length > 1) {
|
|
145
|
+
return {
|
|
146
|
+
resolution: 'ambiguous',
|
|
147
|
+
node: null,
|
|
148
|
+
candidates: labelHits,
|
|
149
|
+
triedIds,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// File has code nodes but none matched the symbol.
|
|
154
|
+
return {
|
|
155
|
+
resolution: 'file-only',
|
|
156
|
+
node: null,
|
|
157
|
+
candidates: inFile.slice(0, 8),
|
|
158
|
+
triedIds,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -190,16 +190,29 @@ export interface GraphifyExternalDetail {
|
|
|
190
190
|
label: string;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/** A standalone method selected from its owning class. */
|
|
194
|
+
export interface GraphifyMethodDetail {
|
|
195
|
+
kind: 'method';
|
|
196
|
+
/** The class that owns this method. */
|
|
197
|
+
hostClass: string;
|
|
198
|
+
/** Parameter types from `references` context `parameter_type`. */
|
|
199
|
+
parameters?: GraphifyParamInfo[];
|
|
200
|
+
/** Return type from `references` context `return_type`. */
|
|
201
|
+
returnType?: string;
|
|
202
|
+
}
|
|
203
|
+
|
|
193
204
|
/**
|
|
194
205
|
* The drill-down payload for a subsystem component.
|
|
195
206
|
*
|
|
196
207
|
* The discriminant is derived from graph structure, not read off the node:
|
|
197
208
|
* method edges → class; `()` label + no method edges → function; incoming
|
|
198
209
|
* `implements` → type; else module. `external` covers consumer stubs.
|
|
210
|
+
* `method` covers standalone method components selected from a class.
|
|
199
211
|
*/
|
|
200
212
|
export type GraphifyComponentDetail =
|
|
201
213
|
| GraphifyClassDetail
|
|
202
214
|
| GraphifyFunctionDetail
|
|
215
|
+
| GraphifyMethodDetail
|
|
203
216
|
| GraphifyTypeDetail
|
|
204
217
|
| GraphifyModuleDetail
|
|
205
218
|
| GraphifyExternalDetail;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mirror of graphify/ids.py — NFKC + casefold-ish + non-word → `_`.
|
|
3
|
+
*
|
|
4
|
+
* Definition node ids are `makeId(fileStem, ...symbolParts)`. Stub ids are
|
|
5
|
+
* intentionally different (name-only / `ref_…`); this module is for the
|
|
6
|
+
* definition path used by component anchoring.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Normalize one id string to graphify's canonical form. */
|
|
10
|
+
export function normalizeGraphifyId(s: string): string {
|
|
11
|
+
let out = s.normalize("NFKC");
|
|
12
|
+
// JS has no Unicode casefold; lowercasing + second NFKC is close enough
|
|
13
|
+
// for the Latin/ASCII identifiers we resolve in practice.
|
|
14
|
+
out = out.toLowerCase().normalize("NFKC");
|
|
15
|
+
out = out.replace(/[^\w]+/gu, "_");
|
|
16
|
+
out = out.replace(/_+/g, "_");
|
|
17
|
+
return out.replace(/^_|_$/g, "");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Build a canonical node id from path/symbol parts (graphify `make_id`). */
|
|
21
|
+
export function makeGraphifyId(...parts: string[]): string {
|
|
22
|
+
const joined = parts
|
|
23
|
+
.filter((p) => typeof p === "string" && p.length > 0)
|
|
24
|
+
.map((p) => p.replace(/^[_.]+|[_.]+$/g, ""))
|
|
25
|
+
.filter(Boolean)
|
|
26
|
+
.join("_");
|
|
27
|
+
return normalizeGraphifyId(joined);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* File stem used as the node-id prefix (graphify `_file_stem`):
|
|
32
|
+
* full path with extension dropped, posix separators.
|
|
33
|
+
*/
|
|
34
|
+
export function graphifyFileStem(file: string): string {
|
|
35
|
+
const posix = file.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
36
|
+
const lastSlash = posix.lastIndexOf("/");
|
|
37
|
+
const base = lastSlash >= 0 ? posix.slice(lastSlash + 1) : posix;
|
|
38
|
+
const dir = lastSlash >= 0 ? posix.slice(0, lastSlash + 1) : "";
|
|
39
|
+
if (!base || base === ".") return "";
|
|
40
|
+
const dot = base.lastIndexOf(".");
|
|
41
|
+
const stemBase = dot > 0 ? base.slice(0, dot) : base;
|
|
42
|
+
return `${dir}${stemBase}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Normalize a repo-relative path for source_file comparison. */
|
|
46
|
+
export function normalizeSourcePath(file: string): string {
|
|
47
|
+
return file.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
|
|
48
|
+
}
|
package/src/graphify/index.ts
CHANGED
|
@@ -43,3 +43,29 @@ export {
|
|
|
43
43
|
createGraphifyTypeResolver,
|
|
44
44
|
resolveGraphifyTypeRef,
|
|
45
45
|
} from './resolve';
|
|
46
|
+
export {
|
|
47
|
+
normalizeGraphifyId,
|
|
48
|
+
makeGraphifyId,
|
|
49
|
+
graphifyFileStem,
|
|
50
|
+
normalizeSourcePath,
|
|
51
|
+
} from './ids';
|
|
52
|
+
export type {
|
|
53
|
+
ComponentAnchorInput,
|
|
54
|
+
ComponentAnchorResult,
|
|
55
|
+
} from './anchor';
|
|
56
|
+
export {
|
|
57
|
+
resolveComponentAnchor,
|
|
58
|
+
symbolLabelVariants,
|
|
59
|
+
} from './anchor';
|
|
60
|
+
export type { InferredGraphifyKind, InferGraphifyKindResult } from './kind';
|
|
61
|
+
export { inferGraphifyKind, kindsMatch } from './kind';
|
|
62
|
+
export type {
|
|
63
|
+
GraphifyInferredSignature,
|
|
64
|
+
ClaimedSignature,
|
|
65
|
+
SignatureCompareResult,
|
|
66
|
+
} from './signature';
|
|
67
|
+
export {
|
|
68
|
+
extractNamedTypes,
|
|
69
|
+
extractGraphifySignature,
|
|
70
|
+
compareSignatures,
|
|
71
|
+
} from './signature';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import type { GraphifyEdge, GraphifyNode } from './types';
|
|
3
|
+
import { inferGraphifyKind, kindsMatch } from './kind';
|
|
4
|
+
|
|
5
|
+
function node(
|
|
6
|
+
id: string,
|
|
7
|
+
label: string,
|
|
8
|
+
sourceFile = 'src/Foo.ts',
|
|
9
|
+
extra?: Partial<GraphifyNode>,
|
|
10
|
+
): GraphifyNode {
|
|
11
|
+
return {
|
|
12
|
+
id,
|
|
13
|
+
label,
|
|
14
|
+
file_type: 'code',
|
|
15
|
+
source_file: sourceFile,
|
|
16
|
+
source_location: 'L1',
|
|
17
|
+
...extra,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function edge(
|
|
22
|
+
source: string,
|
|
23
|
+
target: string,
|
|
24
|
+
relation: string,
|
|
25
|
+
): GraphifyEdge {
|
|
26
|
+
return {
|
|
27
|
+
source,
|
|
28
|
+
target,
|
|
29
|
+
relation,
|
|
30
|
+
confidence: 'EXTRACTED',
|
|
31
|
+
source_file: 'src/Foo.ts',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe('inferGraphifyKind', () => {
|
|
36
|
+
test('outgoing method edges → class', () => {
|
|
37
|
+
const n = node('cls', 'SessionReader');
|
|
38
|
+
const edges = [edge('cls', 'cls_get', 'method')];
|
|
39
|
+
const r = inferGraphifyKind(n, edges);
|
|
40
|
+
expect(r.kind).toBe('class');
|
|
41
|
+
expect(r.evidence[0]).toContain('outgoing method');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('call-style label + no methods → function', () => {
|
|
45
|
+
const n = node('fn', 'SubsystemGraphView()');
|
|
46
|
+
const r = inferGraphifyKind(n, []);
|
|
47
|
+
expect(r.kind).toBe('function');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('method-style label + incoming method → method', () => {
|
|
51
|
+
const n = node('m', '.validate()');
|
|
52
|
+
const edges = [edge('cls', 'm', 'method')];
|
|
53
|
+
const r = inferGraphifyKind(n, edges);
|
|
54
|
+
expect(r.kind).toBe('method');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('method takes priority over call-style function', () => {
|
|
58
|
+
const n = node('m', '.generate()');
|
|
59
|
+
const edges = [edge('CodeGenerator', 'm', 'method')];
|
|
60
|
+
expect(inferGraphifyKind(n, edges).kind).toBe('method');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('incoming implements → type', () => {
|
|
64
|
+
const n = node('iface', 'StoryboardRegistryInterface');
|
|
65
|
+
const edges = [edge('MockRegistry', 'iface', 'implements')];
|
|
66
|
+
expect(inferGraphifyKind(n, edges).kind).toBe('type');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('filename label → module', () => {
|
|
70
|
+
const n = node(
|
|
71
|
+
'mod',
|
|
72
|
+
'SubsystemGraphView.tsx',
|
|
73
|
+
'packages/trail-viewer/src/mainview/views/SubsystemGraphView.tsx',
|
|
74
|
+
);
|
|
75
|
+
expect(inferGraphifyKind(n, []).kind).toBe('module');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('bare symbol with no edges → unknown', () => {
|
|
79
|
+
const n = node('x', 'INSPECTOR_KEYS');
|
|
80
|
+
expect(inferGraphifyKind(n, []).kind).toBe('unknown');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('class wins over implements on same node', () => {
|
|
84
|
+
const n = node('cls', 'TypeScriptGenerator');
|
|
85
|
+
const edges = [
|
|
86
|
+
edge('cls', 'cls_gen', 'method'),
|
|
87
|
+
edge('Other', 'cls', 'implements'),
|
|
88
|
+
];
|
|
89
|
+
expect(inferGraphifyKind(n, edges).kind).toBe('class');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('kindsMatch', () => {
|
|
94
|
+
test('exact string equality', () => {
|
|
95
|
+
expect(kindsMatch('function', 'function')).toBe(true);
|
|
96
|
+
expect(kindsMatch('class', 'function')).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('external / missing claimed skips', () => {
|
|
100
|
+
expect(kindsMatch('external', 'function')).toBe(true);
|
|
101
|
+
expect(kindsMatch(undefined, 'unknown')).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('no class≈function alias', () => {
|
|
105
|
+
expect(kindsMatch('class', 'function')).toBe(false);
|
|
106
|
+
expect(kindsMatch('function', 'class')).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
});
|