@principal-ai/subsystems-react 0.56.32 → 0.56.34
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 +1 -44
- package/dist/graphify/anchor.d.ts.map +1 -1
- package/dist/graphify/anchor.js +1 -172
- package/dist/graphify/anchor.js.map +1 -1
- package/dist/graphify/consolidated.d.ts +1 -258
- package/dist/graphify/consolidated.d.ts.map +1 -1
- package/dist/graphify/consolidated.js +1 -10
- package/dist/graphify/consolidated.js.map +1 -1
- package/dist/graphify/construct.d.ts +1 -40
- package/dist/graphify/construct.d.ts.map +1 -1
- package/dist/graphify/construct.js +1 -99
- package/dist/graphify/construct.js.map +1 -1
- package/dist/graphify/ids.d.ts +1 -18
- package/dist/graphify/ids.d.ts.map +1 -1
- package/dist/graphify/ids.js +1 -45
- package/dist/graphify/ids.js.map +1 -1
- package/dist/graphify/resolve.d.ts +1 -47
- package/dist/graphify/resolve.d.ts.map +1 -1
- package/dist/graphify/resolve.js +1 -82
- package/dist/graphify/resolve.js.map +1 -1
- package/dist/graphify/signature.d.ts +1 -86
- package/dist/graphify/signature.d.ts.map +1 -1
- package/dist/graphify/signature.js +1 -275
- package/dist/graphify/signature.js.map +1 -1
- package/dist/graphify/types.d.ts +1 -140
- package/dist/graphify/types.d.ts.map +1 -1
- package/dist/graphify/types.js +1 -7
- package/dist/graphify/types.js.map +1 -1
- package/dist/subsystem/IssueList.d.ts.map +1 -1
- package/dist/subsystem/IssueList.js +4 -1
- package/dist/subsystem/IssueList.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +3 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +16 -2
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +6 -0
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +16 -1
- package/dist/subsystem/containerCard.js.map +1 -1
- package/package.json +3 -3
- package/src/graphify/anchor.ts +1 -206
- package/src/graphify/consolidated.ts +1 -298
- package/src/graphify/construct.ts +1 -153
- package/src/graphify/ids.ts +1 -48
- package/src/graphify/resolve.ts +1 -115
- package/src/graphify/signature.ts +1 -354
- package/src/graphify/types.ts +1 -164
- package/src/subsystem/IssueList.category.test.ts +11 -0
- package/src/subsystem/IssueList.tsx +4 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +20 -3
- package/src/subsystem/containerCard.test.ts +30 -0
- package/src/subsystem/containerCard.tsx +34 -1
|
@@ -9,6 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
9
9
|
* lets the two cards read as one notation, and what keeps each card's chrome a
|
|
10
10
|
* known quantity for the layout that has to reserve room for it.
|
|
11
11
|
*/
|
|
12
|
+
import { Fragment } from 'react';
|
|
12
13
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
13
14
|
import { TechMark } from './techIcons';
|
|
14
15
|
/**
|
|
@@ -95,6 +96,20 @@ export const OPEN_FOOTER_PAD = TOGGLE_INSET + TOGGLE_SIZE + 8;
|
|
|
95
96
|
* chrome rather than held inside it.
|
|
96
97
|
*/
|
|
97
98
|
export const OPEN_SIDE_PAD = OPEN_FOOTER_PAD;
|
|
99
|
+
/** Split path-like labels at `/`, keeping each segment (and its slash) together. */
|
|
100
|
+
export function containerLabelChunks(label) {
|
|
101
|
+
return label.split(/(\s+)/).flatMap((part) => {
|
|
102
|
+
if (!part.includes('/') || /^\s+$/.test(part)) {
|
|
103
|
+
return [{ text: part, pathSegment: false, breakAfter: false }];
|
|
104
|
+
}
|
|
105
|
+
const segments = part.split('/');
|
|
106
|
+
return segments.map((segment, index) => ({
|
|
107
|
+
text: `${segment}${index < segments.length - 1 ? '/' : ''}`,
|
|
108
|
+
pathSegment: true,
|
|
109
|
+
breakAfter: index < segments.length - 1,
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
98
113
|
/**
|
|
99
114
|
* The two rows at the top of every container card: label, then technology.
|
|
100
115
|
*
|
|
@@ -129,7 +144,7 @@ export function ContainerCardHeader({ label, Icon, iconLabel, color, iconColor,
|
|
|
129
144
|
overflow: 'hidden',
|
|
130
145
|
textAlign: centered ? 'center' : 'left',
|
|
131
146
|
minWidth: 0,
|
|
132
|
-
}, children: label }), Icon && (_jsx("span", { "aria-label": iconLabel, style: {
|
|
147
|
+
}, children: containerLabelChunks(label).map((chunk, index) => (_jsxs(Fragment, { children: [chunk.pathSegment ? (_jsx("span", { style: { whiteSpace: 'nowrap' }, children: chunk.text })) : (chunk.text), chunk.breakAfter && _jsx("wbr", {})] }, index))) }), Icon && (_jsx("span", { "aria-label": iconLabel, style: {
|
|
133
148
|
display: 'inline-flex',
|
|
134
149
|
flexShrink: 0,
|
|
135
150
|
color: iconColor ?? color,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerCard.js","sourceRoot":"","sources":["../../src/subsystem/containerCard.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;AAC1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,gEAAgE;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B,yCAAyC;AACzC,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B,uDAAuD;AACvD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAE1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AC,EAAE,aACxE,KAAK,IAAI,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,GAAI,EACpC,eACE,KAAK,EAAE;oCACL,UAAU,EAAE,GAAG;oCACf,UAAU,EAAE,QAAQ;oCACpB,QAAQ,EAAE,QAAQ;oCAClB,YAAY,EAAE,UAAU;oCACxB,QAAQ,EAAE,CAAC;iCACZ,YAEA,QAAQ,GACJ,IACF,CACR,EACA,KAAK,IAAI,CACR,gBACE,KAAK,EAAE;4BACL,UAAU,EAAE,CAAC;4BACb,aAAa,EAAE,CAAC;4BAChB,OAAO,EAAE,aAAa;4BACtB,UAAU,EAAE,QAAQ;4BACpB,GAAG,EAAE,CAAC;yBACP,aAEA,KAAK,CAAC,KAAK,EACZ,KAAC,KAAK,CAAC,IAAI,IAAC,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,GAAI,IACtC,CACR,IACI,IACN,CACJ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principal-ai/subsystems-react",
|
|
3
|
-
"version": "0.56.
|
|
3
|
+
"version": "0.56.34",
|
|
4
4
|
"description": "React UI for Subsystem Models — graph, Pierre code views, and session-event feeds",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@pierre/diffs": ">=1.6.0",
|
|
40
40
|
"@principal-ade/industry-theme": "^0.1.7",
|
|
41
|
-
"@principal-ai/subsystems-core": "^0.51.
|
|
41
|
+
"@principal-ai/subsystems-core": "^0.51.5",
|
|
42
42
|
"react": "^18.0.0 || ^19.0.0",
|
|
43
43
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
44
44
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@pierre/diffs": "1.6.2",
|
|
47
47
|
"@principal-ade/industry-theme": "0.1.7",
|
|
48
48
|
"@principal-ai/agent-monitoring": "^0.3.38",
|
|
49
|
-
"@principal-ai/subsystems-core": "^0.51.
|
|
49
|
+
"@principal-ai/subsystems-core": "^0.51.5",
|
|
50
50
|
"@storybook/addon-docs": "10.1.2",
|
|
51
51
|
"@storybook/addon-links": "10.1.2",
|
|
52
52
|
"@storybook/addon-onboarding": "10.1.2",
|
package/src/graphify/anchor.ts
CHANGED
|
@@ -1,206 +1 @@
|
|
|
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
|
-
}
|
|
161
|
-
|
|
162
|
-
export type UniqueDefinitionBySymbolResult =
|
|
163
|
-
| { status: 'unique'; node: GraphifyNode }
|
|
164
|
-
| { status: 'ambiguous'; candidates: GraphifyNode[] }
|
|
165
|
-
| { status: 'none' };
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Corpus-wide definition lookup by symbol label only (no claimed file).
|
|
169
|
-
* Used when the model’s file path is missing and we want a deterministic
|
|
170
|
-
* relocate if exactly one defining file still declares the symbol.
|
|
171
|
-
*
|
|
172
|
-
* Unique means a single `source_file` among matching definition nodes.
|
|
173
|
-
*/
|
|
174
|
-
export function findUniqueDefinitionBySymbol(
|
|
175
|
-
nodes: readonly GraphifyNode[],
|
|
176
|
-
symbol: string,
|
|
177
|
-
): UniqueDefinitionBySymbolResult {
|
|
178
|
-
const trimmed = symbol.trim();
|
|
179
|
-
if (!trimmed) return { status: 'none' };
|
|
180
|
-
|
|
181
|
-
const hits: GraphifyNode[] = [];
|
|
182
|
-
for (const node of nodes) {
|
|
183
|
-
if (!isDefinition(node)) continue;
|
|
184
|
-
if (!labelMatchesSymbol(String(node.label ?? ''), trimmed)) continue;
|
|
185
|
-
hits.push(node);
|
|
186
|
-
}
|
|
187
|
-
if (hits.length === 0) return { status: 'none' };
|
|
188
|
-
|
|
189
|
-
const byFile = new Map<string, GraphifyNode[]>();
|
|
190
|
-
for (const n of hits) {
|
|
191
|
-
const sf = normalizeSourcePath(String(n.source_file ?? ''));
|
|
192
|
-
if (!sf) continue;
|
|
193
|
-
const list = byFile.get(sf) ?? [];
|
|
194
|
-
list.push(n);
|
|
195
|
-
byFile.set(sf, list);
|
|
196
|
-
}
|
|
197
|
-
if (byFile.size === 0) return { status: 'none' };
|
|
198
|
-
if (byFile.size > 1) {
|
|
199
|
-
return {
|
|
200
|
-
status: 'ambiguous',
|
|
201
|
-
candidates: hits.slice(0, 12),
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
const only = [...byFile.values()][0]!;
|
|
205
|
-
return { status: 'unique', node: only[0]! };
|
|
206
|
-
}
|
|
1
|
+
export * from '@principal-ai/subsystems-core/graphify/anchor';
|
|
@@ -1,298 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Graphify consolidated / drill-down types.
|
|
3
|
-
*
|
|
4
|
-
* graphify stores the graph in flat, normalized form — class vs function vs
|
|
5
|
-
* type is NOT a node attribute (every code node is `file_type: "code"`); it is
|
|
6
|
-
* derived from graph structure. These types rebuild that structure from the raw
|
|
7
|
-
* edges so a UI can show a drill-down modal for a subsystem component or jump
|
|
8
|
-
* to its definition file.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
GraphifyConfidence,
|
|
13
|
-
GraphifyFileType,
|
|
14
|
-
GraphifyRelation,
|
|
15
|
-
} from './types';
|
|
16
|
-
|
|
17
|
-
/** How a subsystem component resolved to a graphify node. */
|
|
18
|
-
export type GraphifyAnchorResolution = 'exact' | 'file-only' | 'ambiguous' | 'missing';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The bridge between a facet component and the graphify graph.
|
|
22
|
-
*
|
|
23
|
-
* `nodeId` is reconstructed from the component's `file` + `symbol` via the id
|
|
24
|
-
* slug scheme; `resolution` says how confident that reconstruction is.
|
|
25
|
-
* `source_file` + `source_location` are the "open the definition" primitive.
|
|
26
|
-
*/
|
|
27
|
-
export interface SubsystemGraphifyAnchor {
|
|
28
|
-
/** Resolved graphify node id. */
|
|
29
|
-
nodeId: string;
|
|
30
|
-
/** PURL of the repo the node lives in (pkg:github/owner/repo). */
|
|
31
|
-
purl: string;
|
|
32
|
-
/** How the anchor resolved — the honesty signal for verification. */
|
|
33
|
-
resolution: GraphifyAnchorResolution;
|
|
34
|
-
/** Human-readable node label from the graph. */
|
|
35
|
-
label: string;
|
|
36
|
-
/** Repo-relative path of the node's source file. */
|
|
37
|
-
source_file: string;
|
|
38
|
-
/** `L<line>` — the line of the definition for a file-open jump. */
|
|
39
|
-
source_location?: string;
|
|
40
|
-
/** Node classification from the graph. */
|
|
41
|
-
file_type: GraphifyFileType;
|
|
42
|
-
/** Leiden community id. */
|
|
43
|
-
community?: number | null;
|
|
44
|
-
/** Human-readable community label. */
|
|
45
|
-
community_name?: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// ---------------------------------------------------------------------------
|
|
49
|
-
// Leaf info types — each backed by a specific graphify edge pattern
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
/** A method on a class-like node (`method` edge from the class). */
|
|
53
|
-
export interface GraphifyMethodInfo {
|
|
54
|
-
/** The method's own node id. */
|
|
55
|
-
nodeId: string;
|
|
56
|
-
/** Display name from the label (`.get()` → `get`). */
|
|
57
|
-
name: string;
|
|
58
|
-
/** Typed parameters from `references` edges with context `parameter_type`. */
|
|
59
|
-
parameters?: GraphifyParamInfo[];
|
|
60
|
-
/** Return type from a `references` edge with context `return_type`. */
|
|
61
|
-
returnType?: string;
|
|
62
|
-
/** Backing edge target for `returnType`, when the graph had one. */
|
|
63
|
-
returnTypeRef?: GraphifyReferenceInfo;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** A property/field on a class- or type-like node. */
|
|
67
|
-
export interface GraphifyPropertyInfo {
|
|
68
|
-
/** Field name — present when graphify emits a `defines` node (C++). */
|
|
69
|
-
name: string;
|
|
70
|
-
/** Field type from a `references` edge with context `field`. */
|
|
71
|
-
type?: string;
|
|
72
|
-
/** Backing edge target for `type`, when the graph had one. */
|
|
73
|
-
typeRef?: GraphifyReferenceInfo;
|
|
74
|
-
/** The field's own node id when it exists (e.g. C++ `defines` nodes). */
|
|
75
|
-
nodeId?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* A single typed parameter of a function (`references` context `parameter_type`).
|
|
80
|
-
*
|
|
81
|
-
* `ref.nodeId` is the resolvable half: it targets the type's definition node
|
|
82
|
-
* when graphify resolved the reference, or a sourceless stub node when the
|
|
83
|
-
* name was ambiguous / external (see `resolveGraphifyTypeRef`).
|
|
84
|
-
*/
|
|
85
|
-
export interface GraphifyParamInfo {
|
|
86
|
-
/** Parameter name — not captured by graphify; left undefined. */
|
|
87
|
-
name?: string;
|
|
88
|
-
/** Parameter type. */
|
|
89
|
-
type: string;
|
|
90
|
-
/** Backing `references[parameter_type|generic_arg]` edge target. */
|
|
91
|
-
ref?: GraphifyReferenceInfo;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** One call relationship, in either direction. */
|
|
95
|
-
export interface GraphifyCallInfo {
|
|
96
|
-
/** The other endpoint's node id (caller for `callers`, callee for `callees`). */
|
|
97
|
-
nodeId: string;
|
|
98
|
-
/** The other endpoint's display label. */
|
|
99
|
-
name: string;
|
|
100
|
-
/** `L<line>` of the call site. */
|
|
101
|
-
source_location?: string;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** A type-name reference to a node (`references` edge with a context). */
|
|
105
|
-
export interface GraphifyReferenceInfo {
|
|
106
|
-
/** The referenced node id. */
|
|
107
|
-
nodeId: string;
|
|
108
|
-
/** The referenced node's display label. */
|
|
109
|
-
name: string;
|
|
110
|
-
/** Reference context (e.g. `type`, `field`, `generic_arg`, `attribute`). */
|
|
111
|
-
context?: string;
|
|
112
|
-
/** `L<line>` of the reference site. */
|
|
113
|
-
source_location?: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// ---------------------------------------------------------------------------
|
|
117
|
-
// Discriminated union — the drill-down payload
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
|
|
120
|
-
/** A class-like node: owns outgoing `method` edges. */
|
|
121
|
-
export interface GraphifyClassDetail {
|
|
122
|
-
kind: 'class';
|
|
123
|
-
/** Methods connected via `method` edges. */
|
|
124
|
-
methods: GraphifyMethodInfo[];
|
|
125
|
-
/** Fields from `defines`/`references` context `field`. */
|
|
126
|
-
properties: GraphifyPropertyInfo[];
|
|
127
|
-
/** `inherits` edge targets. */
|
|
128
|
-
extends: string[];
|
|
129
|
-
/** `implements` edge targets. */
|
|
130
|
-
implements: string[];
|
|
131
|
-
/** Incoming `calls` — graphify models constructor calls as calls into the class. */
|
|
132
|
-
instantiations: GraphifyCallInfo[];
|
|
133
|
-
/** Everywhere the type name is referenced (`references` edges). */
|
|
134
|
-
references: GraphifyReferenceInfo[];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** A function-like node: label ends `name()` with no `method` edges. */
|
|
138
|
-
export interface GraphifyFunctionDetail {
|
|
139
|
-
kind: 'function';
|
|
140
|
-
/** Parameter types from `references` context `parameter_type`. */
|
|
141
|
-
parameters: GraphifyParamInfo[];
|
|
142
|
-
/** Return type from `references` context `return_type`. */
|
|
143
|
-
returnType?: string;
|
|
144
|
-
/** Backing edge target for `returnType`, when the graph had one. */
|
|
145
|
-
returnTypeRef?: GraphifyReferenceInfo;
|
|
146
|
-
/** Incoming `calls` edges. */
|
|
147
|
-
callers: GraphifyCallInfo[];
|
|
148
|
-
/** Outgoing `calls` edges. */
|
|
149
|
-
callees: GraphifyCallInfo[];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** One generic type parameter, e.g. `T` or `K extends keyof StudioMessages`. */
|
|
153
|
-
export interface GraphifyTypeParamInfo {
|
|
154
|
-
name: string;
|
|
155
|
-
/** Constraint written after `extends` (or language equivalent). */
|
|
156
|
-
constraint?: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/** A callable/function type: `(params) => returnType`. */
|
|
160
|
-
export interface GraphifyCallableTypeInfo {
|
|
161
|
-
parameters?: GraphifyParamInfo[];
|
|
162
|
-
returnType?: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** One enum member, with its optional literal value. */
|
|
166
|
-
export interface GraphifyEnumMemberInfo {
|
|
167
|
-
name: string;
|
|
168
|
-
value?: string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/** A type-like node (interface/struct): revealed by incoming `implements` edges. */
|
|
172
|
-
export interface GraphifyTypeDetail {
|
|
173
|
-
kind: 'type';
|
|
174
|
-
/** Struct/interface fields. */
|
|
175
|
-
properties: GraphifyPropertyInfo[];
|
|
176
|
-
/** Nodes referencing this type name. */
|
|
177
|
-
usedBy: GraphifyReferenceInfo[];
|
|
178
|
-
/** Nodes that `inherits`/`implements` this type. */
|
|
179
|
-
implementors: string[];
|
|
180
|
-
/** Generic type parameters, e.g. `<K extends keyof StudioMessages>`. */
|
|
181
|
-
generics?: GraphifyTypeParamInfo[];
|
|
182
|
-
/** Callable type — `(params) => returnType` (TS/Go/Rust fn, Java lambda). */
|
|
183
|
-
signature?: GraphifyCallableTypeInfo;
|
|
184
|
-
/** Enum members (name, optional literal value). */
|
|
185
|
-
enumMembers?: GraphifyEnumMemberInfo[];
|
|
186
|
-
/** Alias whose RHS is a plain reference, e.g. `StudioMessages[K]`. */
|
|
187
|
-
aliasOf?: string;
|
|
188
|
-
/** Simple union of alternatives, e.g. `'started' | 'stopped'`. */
|
|
189
|
-
unionOf?: string[];
|
|
190
|
-
/**
|
|
191
|
-
* Verbatim RHS — the escape hatch for shapes the structured fields can't
|
|
192
|
-
* express (mapped/conditional/template-literal/infer types, `typeof`/utility
|
|
193
|
-
* compositions, C pointers, Rust trait objects). Wins over every shape above.
|
|
194
|
-
*/
|
|
195
|
-
rhs?: string;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/** A facet-only component with no graphify node (external consumer stub). */
|
|
199
|
-
export interface GraphifyExternalDetail {
|
|
200
|
-
kind: 'external';
|
|
201
|
-
/** Facet-only label; there is no backing graph data. */
|
|
202
|
-
label?: string;
|
|
203
|
-
/**
|
|
204
|
-
* Authored key/value facts about the dependency (endpoints, install command,
|
|
205
|
-
* db path). Mirrors the model document's `external.attributes`; graphify never
|
|
206
|
-
* populates it, it is authored alongside the facet.
|
|
207
|
-
*/
|
|
208
|
-
attributes?: GraphifyCustomEntityAttribute[];
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** A single authored attribute on a custom entity — free-form key/value. */
|
|
212
|
-
export interface GraphifyCustomEntityAttribute {
|
|
213
|
-
key: string;
|
|
214
|
-
value: string;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* A custom-entity (actor — Person/agent/queue) declaration. Authored, never
|
|
219
|
-
* extracted: there is no graphify node for a Person. `attributes` are
|
|
220
|
-
* free-form key/value pairs surfaced in the declaration panel; the base
|
|
221
|
-
* component fields carry the node identity (`entityKind`, `color`, `purpose`).
|
|
222
|
-
*/
|
|
223
|
-
export interface GraphifyCustomEntityDetail {
|
|
224
|
-
kind: 'custom_entity';
|
|
225
|
-
attributes: GraphifyCustomEntityAttribute[];
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* A retained-state node (`kind: 'store'`): state and its contract, no
|
|
230
|
-
* behavior. `kind` is the node's verifiable anchor — a store anchors to a
|
|
231
|
-
* *state location* (module consts, a file or db), not to a declaration.
|
|
232
|
-
* When a class manages the store's access, that is a SEPARATE node
|
|
233
|
-
* (`kind: 'class'`, methods = the access mechanism) joined by
|
|
234
|
-
* `writes`/`reads` — never merged into one hybrid node. This payload
|
|
235
|
-
* renders as state declarations (`declare const …`), never as a class
|
|
236
|
-
* stub.
|
|
237
|
-
*/
|
|
238
|
-
export interface GraphifyStoreDetail {
|
|
239
|
-
kind: 'store';
|
|
240
|
-
/** The retained state members (module-level consts or class fields). */
|
|
241
|
-
properties: GraphifyPropertyInfo[];
|
|
242
|
-
/**
|
|
243
|
-
* Where the retained state physically lives / who mediates access. Authored
|
|
244
|
-
* — graphify cannot infer it: `memory` = process-lifetime RAM, `disk` =
|
|
245
|
-
* this process reads/writes the filesystem, `external` = mediated by another
|
|
246
|
-
* system (db/service; carries no `process`).
|
|
247
|
-
*/
|
|
248
|
-
storage?: 'memory' | 'disk' | 'external';
|
|
249
|
-
/**
|
|
250
|
-
* The type of the retained state itself — a store declares its type the way
|
|
251
|
-
* every other declaration does (`Map<string, FeedState>`, `Set<Listener>`,
|
|
252
|
-
* a table's row type). Orthogonal to `storage`.
|
|
253
|
-
*/
|
|
254
|
-
valueType?: string;
|
|
255
|
-
/** Backing edge target for `valueType`, when the graph has one. */
|
|
256
|
-
valueTypeRef?: GraphifyReferenceInfo;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** A standalone method selected from its owning class. */
|
|
260
|
-
export interface GraphifyMethodDetail {
|
|
261
|
-
kind: 'method';
|
|
262
|
-
/** The class that owns this method. */
|
|
263
|
-
hostClass: string;
|
|
264
|
-
/** Parameter types from `references` context `parameter_type`. */
|
|
265
|
-
parameters?: GraphifyParamInfo[];
|
|
266
|
-
/** Return type from `references` context `return_type`. */
|
|
267
|
-
returnType?: string;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* The structured declaration payload for a subsystem component (click panel).
|
|
272
|
-
*
|
|
273
|
-
* The discriminant is derived from graph structure, not read off the node:
|
|
274
|
-
* method edges → class; `()` label + no method edges → function; incoming
|
|
275
|
-
* `implements` → type. File/module Graphify nodes are not subsystem
|
|
276
|
-
* declaration kinds — anchor to a concrete export instead. `external`
|
|
277
|
-
* covers consumer stubs. `method` covers standalone method components
|
|
278
|
-
* selected from a class.
|
|
279
|
-
*/
|
|
280
|
-
export type GraphifyComponentDetail =
|
|
281
|
-
| GraphifyClassDetail
|
|
282
|
-
| GraphifyFunctionDetail
|
|
283
|
-
| GraphifyMethodDetail
|
|
284
|
-
| GraphifyTypeDetail
|
|
285
|
-
| GraphifyExternalDetail
|
|
286
|
-
| GraphifyCustomEntityDetail
|
|
287
|
-
| GraphifyStoreDetail;
|
|
288
|
-
|
|
289
|
-
/** A raw graphify edge backing a facet claim (verification + provenance). */
|
|
290
|
-
export interface GraphifyEdgeRef {
|
|
291
|
-
source: string;
|
|
292
|
-
target: string;
|
|
293
|
-
relation: GraphifyRelation;
|
|
294
|
-
confidence: GraphifyConfidence;
|
|
295
|
-
confidence_score?: number;
|
|
296
|
-
source_file: string;
|
|
297
|
-
source_location?: string;
|
|
298
|
-
}
|
|
1
|
+
export * from '@principal-ai/subsystems-core/graphify/consolidated';
|