@nexiq/extension-sdk 1.0.3 → 1.0.7

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/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @nexiq/extension-sdk
2
+
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 41543d6: custom node type
8
+
9
+ ## 1.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - d9a3b3b: custom node type
14
+
15
+ ## 1.0.5
16
+
17
+ ### Patch Changes
18
+
19
+ - tom node type
package/dist/db.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type OutNode = {
2
+ id: string;
3
+ name: string;
4
+ type: string;
5
+ combo_id: string;
6
+ color: string;
7
+ radius: number;
8
+ display_name: string;
9
+ git_status: string;
10
+ meta_json: string;
11
+ };
12
+ export type OutEdge = {
13
+ id: string;
14
+ source: string;
15
+ target: string;
16
+ name: string;
17
+ kind: string;
18
+ category: string;
19
+ meta_json: string;
20
+ };
21
+ export type OutCombo = {
22
+ id: string;
23
+ name: string;
24
+ type: string;
25
+ parent_id: string;
26
+ color: string;
27
+ radius: number;
28
+ display_name: string;
29
+ collapsed: boolean;
30
+ git_status: string;
31
+ meta_json: string;
32
+ };
33
+ export type OutDetail = {
34
+ id: string;
35
+ file_name: string;
36
+ project_path: string;
37
+ line: number;
38
+ column: number;
39
+ data_json: string;
40
+ };
package/dist/db.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=db.js.map
package/dist/db.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,30 +1,91 @@
1
- import type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData } from "@nexiq/shared";
2
- export type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData };
1
+ import type { Database } from "better-sqlite3";
2
+ import type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData, GraphViewType, VariableScope, VariableLoc, PropData, TypeData, TypeDataParam, ComponentInfoRender } from "@nexiq/shared";
3
+ export type { TypeDataDeclare, ComponentFileVar, VariableName, DatabaseData, GraphViewType, VariableScope, VariableLoc, PropData, TypeData, TypeDataParam, ComponentInfoRender, };
4
+ export interface UsageOccurrence {
5
+ usageId: string;
6
+ filePath: string;
7
+ line: number;
8
+ column: number;
9
+ ownerId: string;
10
+ ownerKind: string;
11
+ accessPath?: string[] | undefined;
12
+ isOptional?: boolean | undefined;
13
+ isComputed?: boolean | undefined;
14
+ hiddenIntermediate?: string | undefined;
15
+ displayLabel?: string | undefined;
16
+ }
17
+ export interface NodeAppearance {
18
+ color?: string | undefined;
19
+ radius?: number | undefined;
20
+ }
21
+ export declare function registerNodeType(type: string, appearance: NodeAppearance): void;
22
+ export declare function getRegisteredNodeAppearance(type: string): NodeAppearance | undefined;
23
+ export interface GraphAppearance {
24
+ nodeHighlight?: string;
25
+ comboHighlight?: string;
26
+ arrowColor?: string;
27
+ directFlowColor?: string;
28
+ sideEffectFlowColor?: string;
29
+ labelColor?: string;
30
+ gitAdded?: string;
31
+ gitModified?: string;
32
+ gitDeleted?: string;
33
+ nodes?: Partial<Record<"package" | "scope" | "component" | "hook" | "renderGroup" | "sourceGroup" | "pathGroup" | "callback" | "state" | "memo" | "ref" | "effect" | "prop" | "render" | "variable" | "attribute" | "entry", NodeAppearance>> & Record<string, NodeAppearance | undefined>;
34
+ typeKeyword?: string;
35
+ typeLiteral?: string;
36
+ typeString?: string;
37
+ typeNumber?: string;
38
+ typeBoolean?: string;
39
+ typePunctuation?: string;
40
+ typeReference?: string;
41
+ typeComponent?: string;
42
+ typeDefault?: string;
43
+ genericsColor?: string;
44
+ }
45
+ export type CustomColors = GraphAppearance;
46
+ export declare const DEFAULT_GRAPH_APPEARANCE: GraphAppearance;
47
+ export declare function normalizeGraphAppearance(appearance?: GraphAppearance | null): GraphAppearance;
3
48
  export interface GraphItemPosition {
4
49
  x: number;
5
50
  y: number;
6
51
  }
52
+ export interface AppearanceOverride {
53
+ color?: string;
54
+ radius?: number;
55
+ collapsedRadius?: number;
56
+ expandedRadius?: number;
57
+ }
58
+ export interface GraphNodeDetail {
59
+ id: string;
60
+ projectPath?: string;
61
+ fileName?: string;
62
+ pureFileName?: string;
63
+ loc?: VariableLoc;
64
+ declarationKind?: "const" | "let" | "var" | "using" | "await using";
65
+ tag?: string;
66
+ componentType?: "function" | "class" | string | null;
67
+ raw?: ComponentFileVar;
68
+ scope?: VariableScope | string;
69
+ props?: PropData[];
70
+ propData?: PropData;
71
+ propType?: TypeData;
72
+ type?: "component" | "hook" | "type" | "interface" | "state" | "render" | "effect" | "memo" | "callback" | "ref" | "prop" | "jsx" | "normal" | (string & {});
73
+ typeParams?: TypeDataParam[];
74
+ extends?: string[];
75
+ children?: Record<string, ComponentInfoRender>;
76
+ hooks?: string[];
77
+ gitStatus?: "added" | "modified" | "deleted";
78
+ [key: string]: unknown;
79
+ }
7
80
  export interface GraphNodeData {
8
81
  id: string;
9
82
  name: VariableName | string;
10
- label?: {
11
- text: string;
12
- fill?: string;
13
- };
14
83
  type?: string;
15
- fileName?: string;
16
- pureFileName?: string;
17
- loc?: {
18
- line: number;
19
- column: number;
20
- };
21
84
  radius?: number;
22
85
  color?: string;
23
86
  combo?: string;
24
87
  gitStatus?: "added" | "modified" | "deleted";
25
- declarationKind?: "const" | "let" | "var" | "using" | "await using";
26
- tag?: string;
27
- raw?: ComponentFileVar;
88
+ appearanceOverride?: AppearanceOverride;
28
89
  displayName?: string;
29
90
  [key: string]: unknown;
30
91
  }
@@ -33,13 +94,26 @@ export interface GraphComboData extends GraphNodeData {
33
94
  collapsedRadius?: number;
34
95
  expandedRadius?: number;
35
96
  padding?: number;
97
+ appearanceOverride?: AppearanceOverride;
36
98
  [key: string]: unknown;
37
99
  }
38
100
  export interface GraphArrowData {
39
101
  id: string;
40
102
  source: string;
41
103
  target: string;
42
- label?: string;
104
+ name?: string;
105
+ edgeKind?: string;
106
+ category?: string;
107
+ flowRole?: "direct" | "side-effect" | null;
108
+ usageCount?: number;
109
+ usages?: UsageOccurrence[];
110
+ highlighted?: boolean;
111
+ dimmed?: boolean;
112
+ opensTo?: {
113
+ fileName: string;
114
+ line: number;
115
+ column: number;
116
+ };
43
117
  combo?: string;
44
118
  [key: string]: unknown;
45
119
  }
@@ -50,27 +124,107 @@ export interface useGraphProps {
50
124
  }
51
125
  export interface GraphViewResult extends useGraphProps {
52
126
  typeData: Record<string, TypeDataDeclare>;
127
+ details?: Record<string, GraphNodeDetail>;
128
+ }
129
+ /**
130
+ * Context provided to tasks during graph view generation.
131
+ */
132
+ export interface TaskContext {
133
+ /**
134
+ * Database instance for querying graph data.
135
+ */
136
+ db?: Database;
137
+ /**
138
+ * Root path of the project being analyzed.
139
+ */
140
+ projectRoot: string;
141
+ /**
142
+ * Specific paths within the project to focus analysis on.
143
+ */
144
+ analysisPaths?: string[];
145
+ /**
146
+ * The type of view being generated.
147
+ */
148
+ viewType: GraphViewType;
149
+ /**
150
+ * Optional pre-loaded snapshot data, for backward compatibility or when already available.
151
+ */
152
+ snapshotData?: DatabaseData;
153
+ /**
154
+ * Request-scoped cache for aggregated task data so multiple tasks do not reread SQLite.
155
+ */
156
+ taskDataCache?: DatabaseData;
157
+ /**
158
+ * Path to the original Cache Database. Native Rust tasks use this to ATTACH the database directly.
159
+ */
160
+ cacheDbPath?: string;
161
+ /**
162
+ * Optional stage profiler provided by the caller.
163
+ */
164
+ profileStage?: (name: string, startedAt: number, detail?: string) => void | Promise<void>;
165
+ /**
166
+ * Buffer for storing node, edge, and combo data in FlatBuffer format.
167
+ */
168
+ nodeDataBuffer?: SharedArrayBuffer;
169
+ /**
170
+ * Shared buffer for storing node details.
171
+ */
172
+ detailBuffer?: SharedArrayBuffer;
173
+ /**
174
+ * Serialized SQLite database buffer containing both input data and output tables.
175
+ */
176
+ sqliteBuffer?: Uint8Array;
53
177
  }
178
+ /**
179
+ * Helper to retrieve required graph data from either TaskContext.snapshotData or TaskContext.db.
180
+ * It handles workspace databases and qualifies IDs to avoid collisions.
181
+ */
182
+ export declare function getTaskData(context: TaskContext): DatabaseData;
183
+ /**
184
+ * A task that contributes to the construction of a graph view.
185
+ */
54
186
  export interface GraphViewTask {
55
187
  id: string;
56
188
  priority: number;
57
- run: (data: DatabaseData, result: GraphViewResult, batch?: Partial<DatabaseData>) => GraphViewResult;
189
+ extensionPath?: string;
190
+ /**
191
+ * Run the task to update the graph result.
192
+ *
193
+ * @param result The current graph result to be updated
194
+ * @param context Context containing database and project information
195
+ * @returns Updated GraphViewResult
196
+ */
197
+ run?: (result: GraphViewResult, context: TaskContext) => GraphViewResult;
198
+ /**
199
+ * Run the task using buffers for improved performance.
200
+ *
201
+ * @param nodeData Shared buffer for node/edge/combo data
202
+ * @param detailBuffer Shared buffer for node details
203
+ * @param context Context containing database and project information
204
+ */
205
+ runBuffer?: (nodeData: SharedArrayBuffer, detailBuffer: SharedArrayBuffer, context: TaskContext) => number | void;
206
+ /**
207
+ * Run the task using an in-memory SQLite database.
208
+ * The database is expected to be initialized with input data and out_* tables.
209
+ */
210
+ runSqlite?: (context: TaskContext) => void | Promise<void> | Uint8Array | Promise<Uint8Array>;
58
211
  }
59
- export interface DetailSectionProps {
212
+ export interface DetailSectionProps<TGraph = unknown> {
60
213
  selectedId: string;
61
214
  item: GraphNodeData | GraphComboData;
62
- graph: unknown;
215
+ graph: TGraph;
63
216
  projectPath: string;
64
217
  typeData: Record<string, TypeDataDeclare>;
218
+ detail?: GraphNodeDetail;
65
219
  onSelect?: (id: string) => void;
66
220
  renderNodes?: GraphNodeData[];
67
221
  }
68
- export interface DetailSection {
222
+ export interface DetailSection<TGraph = unknown> {
69
223
  id: string;
70
224
  title: string;
71
225
  priority: number;
72
- component: React.ComponentType<DetailSectionProps>;
73
- shouldShow: (item: GraphNodeData | GraphComboData) => boolean;
226
+ component: React.ComponentType<DetailSectionProps<TGraph>>;
227
+ shouldShow: (item: GraphNodeData | GraphComboData, detail?: GraphNodeDetail) => boolean;
74
228
  defaultOpen?: boolean;
75
229
  }
76
230
  export interface MCPToolHandlerArgs {
@@ -84,11 +238,15 @@ export interface MCPTool {
84
238
  inputSchema: Record<string, unknown>;
85
239
  handler: (args: MCPToolHandlerArgs) => Promise<unknown>;
86
240
  }
87
- export interface Extension {
241
+ export interface Extension<TGraph = unknown> {
88
242
  id: string;
89
243
  viewTasks?: Record<string, GraphViewTask[]>;
90
- detailSections?: DetailSection[];
244
+ detailSections?: DetailSection<TGraph>[];
91
245
  mcpTools?: MCPTool[];
246
+ nodeTypes?: Record<string, NodeAppearance>;
92
247
  }
93
- export * from "./tasks/componentTask.js";
94
- export * from "./tasks/gitTask.js";
248
+ /**
249
+ * Initialize standard output tables in a SQLite database for extension results.
250
+ */
251
+ export declare function initOutputTables(db: Database): void;
252
+ export type * from "./db.js";