@principal-ai/principal-view-react 0.16.49 → 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.
Files changed (44) hide show
  1. package/dist/graphify/anchor.d.ts +28 -0
  2. package/dist/graphify/anchor.d.ts.map +1 -0
  3. package/dist/graphify/anchor.js +132 -0
  4. package/dist/graphify/anchor.js.map +1 -0
  5. package/dist/graphify/ids.d.ts +19 -0
  6. package/dist/graphify/ids.d.ts.map +1 -0
  7. package/dist/graphify/ids.js +46 -0
  8. package/dist/graphify/ids.js.map +1 -0
  9. package/dist/graphify/index.d.ts +7 -0
  10. package/dist/graphify/index.d.ts.map +1 -1
  11. package/dist/graphify/index.js +4 -0
  12. package/dist/graphify/index.js.map +1 -1
  13. package/dist/graphify/kind.d.ts +23 -0
  14. package/dist/graphify/kind.d.ts.map +1 -0
  15. package/dist/graphify/kind.js +71 -0
  16. package/dist/graphify/kind.js.map +1 -0
  17. package/dist/graphify/signature.d.ts +87 -0
  18. package/dist/graphify/signature.d.ts.map +1 -0
  19. package/dist/graphify/signature.js +276 -0
  20. package/dist/graphify/signature.js.map +1 -0
  21. package/dist/index.d.ts +4 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +2 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/subsystem/ComponentDeclaration.d.ts +58 -3
  26. package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -1
  27. package/dist/subsystem/ComponentDeclaration.js +168 -35
  28. package/dist/subsystem/ComponentDeclaration.js.map +1 -1
  29. package/dist/subsystem/SubsystemComponentGraph.d.ts +5 -0
  30. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  31. package/dist/subsystem/SubsystemComponentGraph.js +2 -2
  32. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/graphify/anchor.test.ts +124 -0
  35. package/src/graphify/anchor.ts +160 -0
  36. package/src/graphify/ids.ts +48 -0
  37. package/src/graphify/index.ts +26 -0
  38. package/src/graphify/kind.test.ts +108 -0
  39. package/src/graphify/kind.ts +114 -0
  40. package/src/graphify/signature.test.ts +278 -0
  41. package/src/graphify/signature.ts +354 -0
  42. package/src/index.ts +26 -0
  43. package/src/subsystem/ComponentDeclaration.tsx +287 -40
  44. package/src/subsystem/SubsystemComponentGraph.tsx +8 -1
@@ -0,0 +1,28 @@
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
+ import type { GraphifyNode } from './types';
8
+ import type { GraphifyAnchorResolution } from './consolidated';
9
+ export interface ComponentAnchorInput {
10
+ file?: string;
11
+ symbol?: string;
12
+ kind?: string;
13
+ purl?: string;
14
+ }
15
+ export interface ComponentAnchorResult {
16
+ resolution: GraphifyAnchorResolution;
17
+ node: GraphifyNode | null;
18
+ candidates: GraphifyNode[];
19
+ /** make_id strings attempted on the fast path. */
20
+ triedIds: string[];
21
+ }
22
+ /** Label forms that might match a subsystem symbol on a graphify node. */
23
+ export declare function symbolLabelVariants(symbol: string): string[];
24
+ /**
25
+ * Anchor a subsystem component onto a graphify definition node.
26
+ */
27
+ export declare function resolveComponentAnchor(nodes: readonly GraphifyNode[], input: ComponentAnchorInput): ComponentAnchorResult;
28
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/graphify/anchor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAQ/D,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,qBAAqB;IACrC,UAAU,EAAE,wBAAwB,CAAC;IACrC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,kDAAkD;IAClD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAaD,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAa5D;AAwBD;;GAEG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,KAAK,EAAE,oBAAoB,GACzB,qBAAqB,CAyEvB"}
@@ -0,0 +1,132 @@
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
+ import { normalizeGraphifyLabel } from './resolve';
8
+ import { graphifyFileStem, makeGraphifyId, normalizeSourcePath, } from './ids';
9
+ const FILE_SUFFIX_RE = /\.(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;
10
+ function isDefinition(node) {
11
+ if (node.file_type !== 'code')
12
+ return false;
13
+ const file = typeof node.source_file === 'string' ? node.source_file : '';
14
+ if (!file)
15
+ return false;
16
+ const label = typeof node.label === 'string' ? node.label.trim() : '';
17
+ return !!label && !FILE_SUFFIX_RE.test(label);
18
+ }
19
+ /** Label forms that might match a subsystem symbol on a graphify node. */
20
+ export function symbolLabelVariants(symbol) {
21
+ const raw = symbol.trim();
22
+ if (!raw)
23
+ return [];
24
+ const last = raw.includes('.') ? (raw.split('.').pop() ?? raw) : raw;
25
+ const variants = new Set([
26
+ raw,
27
+ last,
28
+ `${raw}()`,
29
+ `${last}()`,
30
+ `.${last}()`,
31
+ `.${last}`,
32
+ ]);
33
+ return [...variants];
34
+ }
35
+ function labelMatchesSymbol(label, symbol) {
36
+ const variants = symbolLabelVariants(symbol);
37
+ const trimmed = label.trim();
38
+ if (variants.includes(trimmed))
39
+ return true;
40
+ const foldedLabel = normalizeGraphifyLabel(trimmed);
41
+ return variants.some((v) => normalizeGraphifyLabel(v) === foldedLabel);
42
+ }
43
+ function candidateIdsFor(file, symbol) {
44
+ const stem = graphifyFileStem(file);
45
+ if (!stem)
46
+ return [];
47
+ const parts = symbol.split('.').map((p) => p.trim()).filter(Boolean);
48
+ const ids = new Set();
49
+ ids.add(makeGraphifyId(stem, symbol));
50
+ if (parts.length > 0)
51
+ ids.add(makeGraphifyId(stem, ...parts));
52
+ if (parts.length === 2) {
53
+ // Class method: make_id(class_id, method) ≈ make_id(stem, Class, method)
54
+ ids.add(makeGraphifyId(stem, parts[0], parts[1]));
55
+ }
56
+ return [...ids];
57
+ }
58
+ /**
59
+ * Anchor a subsystem component onto a graphify definition node.
60
+ */
61
+ export function resolveComponentAnchor(nodes, input) {
62
+ const file = input.file?.trim() ? normalizeSourcePath(input.file) : '';
63
+ const symbol = input.symbol?.trim() ?? '';
64
+ if (!file || !symbol) {
65
+ return { resolution: 'missing', node: null, candidates: [], triedIds: [] };
66
+ }
67
+ const byId = new Map();
68
+ const inFile = [];
69
+ for (const node of nodes) {
70
+ byId.set(String(node.id), node);
71
+ if (!isDefinition(node))
72
+ continue;
73
+ const sf = normalizeSourcePath(String(node.source_file ?? ''));
74
+ if (sf === file)
75
+ inFile.push(node);
76
+ }
77
+ const triedIds = candidateIdsFor(file, symbol);
78
+ const idHits = [];
79
+ for (const id of triedIds) {
80
+ const hit = byId.get(id);
81
+ if (!hit || !isDefinition(hit))
82
+ continue;
83
+ const sf = normalizeSourcePath(String(hit.source_file ?? ''));
84
+ if (sf === file)
85
+ idHits.push(hit);
86
+ }
87
+ const uniqueIdHits = [...new Map(idHits.map((n) => [String(n.id), n])).values()];
88
+ if (uniqueIdHits.length === 1) {
89
+ return {
90
+ resolution: 'exact',
91
+ node: uniqueIdHits[0],
92
+ candidates: [],
93
+ triedIds,
94
+ };
95
+ }
96
+ if (uniqueIdHits.length > 1) {
97
+ return {
98
+ resolution: 'ambiguous',
99
+ node: null,
100
+ candidates: uniqueIdHits,
101
+ triedIds,
102
+ };
103
+ }
104
+ if (inFile.length === 0) {
105
+ return { resolution: 'missing', node: null, candidates: [], triedIds };
106
+ }
107
+ const labelHits = inFile.filter((n) => labelMatchesSymbol(String(n.label ?? ''), symbol));
108
+ if (labelHits.length === 1) {
109
+ return {
110
+ resolution: 'exact',
111
+ node: labelHits[0],
112
+ candidates: [],
113
+ triedIds,
114
+ };
115
+ }
116
+ if (labelHits.length > 1) {
117
+ return {
118
+ resolution: 'ambiguous',
119
+ node: null,
120
+ candidates: labelHits,
121
+ triedIds,
122
+ };
123
+ }
124
+ // File has code nodes but none matched the symbol.
125
+ return {
126
+ resolution: 'file-only',
127
+ node: null,
128
+ candidates: inFile.slice(0, 8),
129
+ triedIds,
130
+ };
131
+ }
132
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.js","sourceRoot":"","sources":["../../src/graphify/anchor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACnB,MAAM,OAAO,CAAC;AAiBf,MAAM,cAAc,GACnB,mIAAmI,CAAC;AAErI,SAAS,YAAY,CAAC,IAAkB;IACvC,IAAI,IAAI,CAAC,SAAS,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAC5C,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EA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+ /**
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
+ /** Normalize one id string to graphify's canonical form. */
9
+ export declare function normalizeGraphifyId(s: string): string;
10
+ /** Build a canonical node id from path/symbol parts (graphify `make_id`). */
11
+ export declare function makeGraphifyId(...parts: string[]): string;
12
+ /**
13
+ * File stem used as the node-id prefix (graphify `_file_stem`):
14
+ * full path with extension dropped, posix separators.
15
+ */
16
+ export declare function graphifyFileStem(file: string): string;
17
+ /** Normalize a repo-relative path for source_file comparison. */
18
+ export declare function normalizeSourcePath(file: string): string;
19
+ //# sourceMappingURL=ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../src/graphify/ids.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAQrD;AAED,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAOzD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASrD;AAED,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -0,0 +1,46 @@
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
+ /** Normalize one id string to graphify's canonical form. */
9
+ export function normalizeGraphifyId(s) {
10
+ let out = s.normalize("NFKC");
11
+ // JS has no Unicode casefold; lowercasing + second NFKC is close enough
12
+ // for the Latin/ASCII identifiers we resolve in practice.
13
+ out = out.toLowerCase().normalize("NFKC");
14
+ out = out.replace(/[^\w]+/gu, "_");
15
+ out = out.replace(/_+/g, "_");
16
+ return out.replace(/^_|_$/g, "");
17
+ }
18
+ /** Build a canonical node id from path/symbol parts (graphify `make_id`). */
19
+ export function makeGraphifyId(...parts) {
20
+ const joined = parts
21
+ .filter((p) => typeof p === "string" && p.length > 0)
22
+ .map((p) => p.replace(/^[_.]+|[_.]+$/g, ""))
23
+ .filter(Boolean)
24
+ .join("_");
25
+ return normalizeGraphifyId(joined);
26
+ }
27
+ /**
28
+ * File stem used as the node-id prefix (graphify `_file_stem`):
29
+ * full path with extension dropped, posix separators.
30
+ */
31
+ export function graphifyFileStem(file) {
32
+ const posix = file.replace(/\\/g, "/").replace(/^\.\//, "");
33
+ const lastSlash = posix.lastIndexOf("/");
34
+ const base = lastSlash >= 0 ? posix.slice(lastSlash + 1) : posix;
35
+ const dir = lastSlash >= 0 ? posix.slice(0, lastSlash + 1) : "";
36
+ if (!base || base === ".")
37
+ return "";
38
+ const dot = base.lastIndexOf(".");
39
+ const stemBase = dot > 0 ? base.slice(0, dot) : base;
40
+ return `${dir}${stemBase}`;
41
+ }
42
+ /** Normalize a repo-relative path for source_file comparison. */
43
+ export function normalizeSourcePath(file) {
44
+ return file.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
45
+ }
46
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/graphify/ids.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,4DAA4D;AAC5D,MAAM,UAAU,mBAAmB,CAAC,CAAS;IAC5C,IAAI,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9B,wEAAwE;IACxE,0DAA0D;IAC1D,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,SAAS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,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,OAAO,GAAG,GAAG,GAAG,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3E,CAAC"}
@@ -8,4 +8,11 @@ export type { JsonValue, GraphifyFileType, GraphifyConfidence, GraphifyNodeType,
8
8
  export type { GraphifyAnchorResolution, SubsystemGraphifyAnchor, GraphifyMethodInfo, GraphifyPropertyInfo, GraphifyParamInfo, GraphifyCallInfo, GraphifyReferenceInfo, GraphifyImportInfo, GraphifyClassDetail, GraphifyFunctionDetail, GraphifyTypeDetail, GraphifyModuleDetail, GraphifyExternalDetail, GraphifyComponentDetail, GraphifyEdgeRef, } from './consolidated';
9
9
  export type { GraphifyTypeRefStatus, GraphifyTypeRefResolution, } from './resolve';
10
10
  export { normalizeGraphifyLabel, createGraphifyTypeResolver, resolveGraphifyTypeRef, } from './resolve';
11
+ export { normalizeGraphifyId, makeGraphifyId, graphifyFileStem, normalizeSourcePath, } from './ids';
12
+ export type { ComponentAnchorInput, ComponentAnchorResult, } from './anchor';
13
+ export { resolveComponentAnchor, symbolLabelVariants, } from './anchor';
14
+ export type { InferredGraphifyKind, InferGraphifyKindResult } from './kind';
15
+ export { inferGraphifyKind, kindsMatch } from './kind';
16
+ export type { GraphifyInferredSignature, ClaimedSignature, SignatureCompareResult, } from './signature';
17
+ export { extractNamedTypes, extractGraphifySignature, compareSignatures, } from './signature';
11
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphify/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphify/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,OAAO,CAAC;AACf,YAAY,EACV,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACvD,YAAY,EACV,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -5,4 +5,8 @@
5
5
  * graphify output (nodes, links, hyperedges) inside this library.
6
6
  */
7
7
  export { normalizeGraphifyLabel, createGraphifyTypeResolver, resolveGraphifyTypeRef, } from './resolve';
8
+ export { normalizeGraphifyId, makeGraphifyId, graphifyFileStem, normalizeSourcePath, } from './ids';
9
+ export { resolveComponentAnchor, symbolLabelVariants, } from './anchor';
10
+ export { inferGraphifyKind, kindsMatch } from './kind';
11
+ export { extractNamedTypes, extractGraphifySignature, compareSignatures, } from './signature';
8
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphify/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphify/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,OAAO,CAAC;AAKf,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAMvD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Infer a subsystem-style kind from a graphify node + edges.
3
+ *
4
+ * Graphify does not store `kind` on nodes (everything is `file_type: "code"`).
5
+ * Class vs function vs type is derived from structure — same rules as
6
+ * `GraphifyComponentDetail` in consolidated.ts.
7
+ */
8
+ import type { GraphifyEdge, GraphifyNode } from './types';
9
+ /** Kind inferred from graph structure (never read off the node). */
10
+ export type InferredGraphifyKind = 'class' | 'function' | 'method' | 'type' | 'module' | 'unknown';
11
+ export interface InferGraphifyKindResult {
12
+ kind: InferredGraphifyKind;
13
+ evidence: string[];
14
+ }
15
+ /**
16
+ * Infer kind for a definition node from its label and incident edges.
17
+ *
18
+ * Priority: class → method → function → type → module → unknown.
19
+ */
20
+ export declare function inferGraphifyKind(node: GraphifyNode, edges: readonly GraphifyEdge[]): InferGraphifyKindResult;
21
+ /** Strict claimed-vs-inferred check (no class≈function alias). */
22
+ export declare function kindsMatch(claimed: string | undefined, inferred: InferredGraphifyKind): boolean;
23
+ //# sourceMappingURL=kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/graphify/kind.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,oEAAoE;AACpE,MAAM,MAAM,oBAAoB,GAC7B,OAAO,GACP,UAAU,GACV,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,CAAC;AAEb,MAAM,WAAW,uBAAuB;IACvC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAqBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,SAAS,YAAY,EAAE,GAC5B,uBAAuB,CAqDzB;AAED,kEAAkE;AAClE,wBAAgB,UAAU,CACzB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,QAAQ,EAAE,oBAAoB,GAC5B,OAAO,CAGT"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Infer a subsystem-style kind from a graphify node + edges.
3
+ *
4
+ * Graphify does not store `kind` on nodes (everything is `file_type: "code"`).
5
+ * Class vs function vs type is derived from structure — same rules as
6
+ * `GraphifyComponentDetail` in consolidated.ts.
7
+ */
8
+ const FILE_LABEL_RE = /\.(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;
9
+ function isMethodStyleLabel(label) {
10
+ return label.trim().startsWith('.');
11
+ }
12
+ function isCallStyleLabel(label) {
13
+ return label.trim().endsWith('()');
14
+ }
15
+ function isFilenameLabel(label, sourceFile) {
16
+ const trimmed = label.trim();
17
+ if (FILE_LABEL_RE.test(trimmed))
18
+ return true;
19
+ if (!sourceFile)
20
+ return false;
21
+ const base = sourceFile.replace(/\\/g, '/').split('/').pop() ?? '';
22
+ return !!base && trimmed === base;
23
+ }
24
+ /**
25
+ * Infer kind for a definition node from its label and incident edges.
26
+ *
27
+ * Priority: class → method → function → type → module → unknown.
28
+ */
29
+ export function inferGraphifyKind(node, edges) {
30
+ const id = String(node.id);
31
+ const label = String(node.label ?? '').trim();
32
+ const sourceFile = typeof node.source_file === 'string' ? node.source_file : '';
33
+ const evidence = [];
34
+ const outgoingMethod = edges.filter((e) => String(e.source) === id && e.relation === 'method');
35
+ if (outgoingMethod.length > 0) {
36
+ evidence.push(`${outgoingMethod.length} outgoing method edge(s)`);
37
+ return { kind: 'class', evidence };
38
+ }
39
+ const incomingMethod = edges.filter((e) => String(e.target) === id && e.relation === 'method');
40
+ if (incomingMethod.length > 0 && isMethodStyleLabel(label)) {
41
+ evidence.push(`incoming method edge from ${String(incomingMethod[0].source)}`, `label ${label}`);
42
+ return { kind: 'method', evidence };
43
+ }
44
+ if (isCallStyleLabel(label)) {
45
+ evidence.push(`call-style label ${label}`);
46
+ return { kind: 'function', evidence };
47
+ }
48
+ const incomingImplements = edges.filter((e) => String(e.target) === id && e.relation === 'implements');
49
+ if (incomingImplements.length > 0) {
50
+ evidence.push(`${incomingImplements.length} incoming implements edge(s)`);
51
+ return { kind: 'type', evidence };
52
+ }
53
+ if (node.type === 'module' || isFilenameLabel(label, sourceFile)) {
54
+ evidence.push(node.type === 'module'
55
+ ? 'node.type=module'
56
+ : `filename label ${label}`);
57
+ return { kind: 'module', evidence };
58
+ }
59
+ if (label)
60
+ evidence.push(`unclassified label ${label}`);
61
+ else
62
+ evidence.push('no classifying signals');
63
+ return { kind: 'unknown', evidence };
64
+ }
65
+ /** Strict claimed-vs-inferred check (no class≈function alias). */
66
+ export function kindsMatch(claimed, inferred) {
67
+ if (!claimed || claimed === 'external')
68
+ return true;
69
+ return claimed === inferred;
70
+ }
71
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../../src/graphify/kind.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,MAAM,aAAa,GAClB,mIAAmI,CAAC;AAErI,SAAS,kBAAkB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,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AQ,CAAC,IAAI,CACZ,IAAI,CAAC,IAAI,KAAK,QAAQ;YACrB,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,kBAAkB,KAAK,EAAE,CAC5B,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;KACpC;IAED,IAAI,KAAK;QAAE,QAAQ,CAAC,IAAI,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;;QACnD,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC7C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACtC,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,UAAU,CACzB,OAA2B,EAC3B,QAA8B;IAE9B,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,OAAO,KAAK,QAAQ,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Signature / params verification against graphify `references` edges.
3
+ *
4
+ * Graphify does not store arity or parameter names — only `parameter_type` /
5
+ * `return_type` edges to type nodes (unions become multiple edges). Comparison
6
+ * is therefore **named type bags**, not positional arity.
7
+ *
8
+ * Many TS/JS functions have no such edges yet. When graphify has no signature
9
+ * signal, the check is skipped (not a hard fail) so Verify can still gate on
10
+ * kind. When graphify *does* emit types, claimed detail must match.
11
+ */
12
+ import type { GraphifyEdge, GraphifyNode } from './types';
13
+ /** Inferred signature from graphify edges (no param names). */
14
+ export interface GraphifyInferredSignature {
15
+ parameters: Array<{
16
+ type: string;
17
+ nodeId: string;
18
+ }>;
19
+ returnType?: string;
20
+ returnTypeNodeId?: string;
21
+ /**
22
+ * Types reachable only via `generic_arg` edges (Promise<X>, Array<X>,
23
+ * Omit<X,…>, Map<…>). Kept out of `parameters`/`returnType` — not read
24
+ * by the bag comparison — so skipped cases can be told apart.
25
+ */
26
+ genericArgs?: Array<{
27
+ type: string;
28
+ nodeId: string;
29
+ }>;
30
+ /**
31
+ * Count of `inline_parameter` self-edges (anonymous object-literal params).
32
+ * Graphify emits one per anon param only with its `--inline-params` flag.
33
+ */
34
+ inlineParameters?: number;
35
+ /** True when at least one parameter_type or return_type edge exists. */
36
+ hasSignal: boolean;
37
+ }
38
+ export interface ClaimedSignature {
39
+ parameters?: Array<{
40
+ name?: string;
41
+ type: string;
42
+ }>;
43
+ returnType?: string;
44
+ }
45
+ /**
46
+ * Granular skip classification. `signature_skipped` means "graphify has no
47
+ * parameter_type/return_type edges to compare", but *why* matters for future
48
+ * work:
49
+ * - `no_claimed_types`: authored detail has no named types (primitives/inline).
50
+ * - `generic_arg_only`: claimed types resolve, but only as `generic_arg`
51
+ * (Promise/Omit/Map/Array wrappers) — this extractor does not read them.
52
+ * - `partially_generic_arg`: some, not all, claimed types resolve as generic_arg.
53
+ * - `unresolved_claimed_types`: claimed names have no edges at all
54
+ * (global/npm types, or a dropped same-file label collision).
55
+ */
56
+ export type SignatureSkipCode = 'no_claimed_types' | 'generic_arg_only' | 'partially_generic_arg' | 'unresolved_claimed_types';
57
+ export interface SignatureCompareResult {
58
+ match: boolean;
59
+ /** Skipped because graphify had no parameter/return type edges. */
60
+ skipped: boolean;
61
+ reason?: string;
62
+ /** Granular skip classification when `skipped` is true. */
63
+ skipCode?: SignatureSkipCode;
64
+ claimed: {
65
+ parameterTypes: string[];
66
+ returnTypes: string[];
67
+ };
68
+ inferred: {
69
+ parameterTypes: string[];
70
+ returnTypes: string[];
71
+ };
72
+ }
73
+ /**
74
+ * Pull comparable named type identifiers out of an authored / graphify type
75
+ * string. Skips primitives, inline object types, and known wrappers.
76
+ */
77
+ export declare function extractNamedTypes(typeStr: string): string[];
78
+ /** Collect parameter_type / return_type edges for a callable node. */
79
+ export declare function extractGraphifySignature(nodeId: string, edges: readonly GraphifyEdge[], nodesById: ReadonlyMap<string, GraphifyNode>): GraphifyInferredSignature;
80
+ /**
81
+ * Compare authored function/method detail signature to graphify edges.
82
+ *
83
+ * - No graphify signal → skipped (match=true).
84
+ * - Otherwise named-type bags for params and return must match exactly.
85
+ */
86
+ export declare function compareSignatures(claimed: ClaimedSignature | undefined, inferred: GraphifyInferredSignature): SignatureCompareResult;
87
+ //# sourceMappingURL=signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/graphify/signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,+DAA+D;AAC/D,MAAM,WAAW,yBAAyB;IACzC,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wEAAwE;IACxE,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAC1B,kBAAkB,GAClB,kBAAkB,GAClB,uBAAuB,GACvB,0BAA0B,CAAC;AAE9B,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,mEAAmE;IACnE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,C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