@mnemonica/tactica 0.1.0 → 0.1.1
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/README.md +340 -262
- package/lib/analyzer.d.ts +195 -7
- package/lib/analyzer.js +1584 -19
- package/lib/analyzer.js.map +1 -1
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +202 -6
- package/lib/cli.js.map +1 -1
- package/lib/generator.d.ts +41 -7
- package/lib/generator.js +243 -49
- package/lib/generator.js.map +1 -1
- package/lib/graph.d.ts +4 -0
- package/lib/graph.js +11 -0
- package/lib/graph.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +39 -9
- package/lib/index.js.map +1 -1
- package/lib/topologica-analyzer.d.ts +85 -0
- package/lib/topologica-analyzer.js +509 -0
- package/lib/topologica-analyzer.js.map +1 -0
- package/lib/types.d.ts +110 -0
- package/lib/writer.d.ts +25 -13
- package/lib/writer.js +94 -51
- package/lib/writer.js.map +1 -1
- package/package.json +20 -21
- package/lib/plugin.d.ts +0 -8
- package/lib/plugin.js +0 -128
- package/lib/plugin.js.map +0 -1
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TopologicaAnalyzer = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const ts = __importStar(require("typescript"));
|
|
40
|
+
const graph_1 = require("./graph");
|
|
41
|
+
/**
|
|
42
|
+
* Analyzer for Topologica directory-based type definitions
|
|
43
|
+
* Scans directory structures to create type hierarchies like:
|
|
44
|
+
* ai-types/Sentience/Consciousness/Empathy/Gratitude/
|
|
45
|
+
*
|
|
46
|
+
* Now with AST-based property extraction from TypeScript/JavaScript files
|
|
47
|
+
*/
|
|
48
|
+
class TopologicaAnalyzer {
|
|
49
|
+
constructor() {
|
|
50
|
+
this.errors = [];
|
|
51
|
+
this.graph = new graph_1.TypeGraphImpl();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Analyze a directory structure for topologica type definitions
|
|
55
|
+
*/
|
|
56
|
+
analyzeDirectory(directoryPath) {
|
|
57
|
+
this.errors = [];
|
|
58
|
+
if (!fs.existsSync(directoryPath)) {
|
|
59
|
+
this.errors.push(`Directory does not exist: ${directoryPath}`);
|
|
60
|
+
return { types: this.graph.allTypes, errors: this.errors };
|
|
61
|
+
}
|
|
62
|
+
if (!fs.statSync(directoryPath).isDirectory()) {
|
|
63
|
+
this.errors.push(`Path is not a directory: ${directoryPath}`);
|
|
64
|
+
return { types: this.graph.allTypes, errors: this.errors };
|
|
65
|
+
}
|
|
66
|
+
this.scanDirectory(directoryPath, undefined, directoryPath);
|
|
67
|
+
return {
|
|
68
|
+
types: this.graph.allTypes,
|
|
69
|
+
errors: this.errors,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Recursively scan directory structure to build type hierarchy
|
|
74
|
+
*/
|
|
75
|
+
scanDirectory(currentPath, parentNode, rootPath) {
|
|
76
|
+
try {
|
|
77
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true });
|
|
78
|
+
for (const entry of entries) {
|
|
79
|
+
if (entry.isDirectory()) {
|
|
80
|
+
// Create type node for this directory
|
|
81
|
+
const typeName = entry.name;
|
|
82
|
+
const fullPath = parentNode ? `${parentNode.fullPath}.${typeName}` : typeName;
|
|
83
|
+
const dirPath = path.join(currentPath, entry.name);
|
|
84
|
+
// Extract properties and constructor params from the handler file if it exists
|
|
85
|
+
const { properties, constructorParams, handlerLocation } = this.extractPropertiesFromDir(dirPath);
|
|
86
|
+
// Create the type node with proper source location for Go to Definition
|
|
87
|
+
const typeNode = {
|
|
88
|
+
name: typeName,
|
|
89
|
+
fullPath: fullPath,
|
|
90
|
+
properties: properties,
|
|
91
|
+
constructorParams: constructorParams,
|
|
92
|
+
parent: parentNode,
|
|
93
|
+
children: new Map(),
|
|
94
|
+
sourceFile: handlerLocation?.filePath || dirPath,
|
|
95
|
+
line: handlerLocation?.line || 0,
|
|
96
|
+
column: handlerLocation?.column || 0,
|
|
97
|
+
constructorName: typeName
|
|
98
|
+
};
|
|
99
|
+
// Add to graph
|
|
100
|
+
if (parentNode) {
|
|
101
|
+
this.graph.addChild(parentNode, typeNode);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// Add as root type
|
|
105
|
+
this.graph.addRoot(typeNode);
|
|
106
|
+
}
|
|
107
|
+
// Scan children of this directory
|
|
108
|
+
this.scanDirectory(dirPath, typeNode, rootPath);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
this.errors.push(`Error scanning directory ${currentPath}: ${error.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Extract properties from a directory's index file
|
|
118
|
+
* Supports both .ts and .js files
|
|
119
|
+
*/
|
|
120
|
+
extractPropertiesFromDir(dirPath) {
|
|
121
|
+
const properties = new Map();
|
|
122
|
+
let constructorParams;
|
|
123
|
+
// Check for TypeScript file first, then JavaScript
|
|
124
|
+
const tsFile = path.join(dirPath, 'index.ts');
|
|
125
|
+
const jsFile = path.join(dirPath, 'index.js');
|
|
126
|
+
let targetFile;
|
|
127
|
+
if (fs.existsSync(tsFile)) {
|
|
128
|
+
targetFile = tsFile;
|
|
129
|
+
}
|
|
130
|
+
else if (fs.existsSync(jsFile)) {
|
|
131
|
+
targetFile = jsFile;
|
|
132
|
+
}
|
|
133
|
+
if (!targetFile) {
|
|
134
|
+
return { properties };
|
|
135
|
+
}
|
|
136
|
+
// Default location points to the index file (will be updated if handler found)
|
|
137
|
+
let handlerLocation;
|
|
138
|
+
try {
|
|
139
|
+
const content = fs.readFileSync(targetFile, 'utf-8');
|
|
140
|
+
const sourceFile = ts.createSourceFile(targetFile, content, ts.ScriptTarget.Latest, true);
|
|
141
|
+
// Collect type aliases from the file (e.g., SentienceData = { ... })
|
|
142
|
+
const typeAliases = this.collectTypeAliases(sourceFile);
|
|
143
|
+
// Find handler function and extract property assignments and constructor params
|
|
144
|
+
const result = this.extractPropertiesFromSourceFile(sourceFile, properties, typeAliases);
|
|
145
|
+
constructorParams = result.constructorParams;
|
|
146
|
+
// Use the handler function location if found
|
|
147
|
+
if (result.handlerLocation) {
|
|
148
|
+
handlerLocation = result.handlerLocation;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
this.errors.push(`Error parsing ${targetFile}: ${error.message}`);
|
|
153
|
+
}
|
|
154
|
+
return { properties, constructorParams, handlerLocation };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Collect type aliases from source file
|
|
158
|
+
* e.g., export type SentienceData = { awareness?: string; }
|
|
159
|
+
*/
|
|
160
|
+
collectTypeAliases(sourceFile) {
|
|
161
|
+
const typeAliases = new Map();
|
|
162
|
+
const visit = (node) => {
|
|
163
|
+
// Look for type alias declarations: export type Name = Type;
|
|
164
|
+
if (ts.isTypeAliasDeclaration(node)) {
|
|
165
|
+
const name = node.name.text;
|
|
166
|
+
typeAliases.set(name, node.type);
|
|
167
|
+
}
|
|
168
|
+
ts.forEachChild(node, visit);
|
|
169
|
+
};
|
|
170
|
+
visit(sourceFile);
|
|
171
|
+
return typeAliases;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Extract property assignments from a source file
|
|
175
|
+
* Returns constructor parameters and handler location if found
|
|
176
|
+
*/
|
|
177
|
+
extractPropertiesFromSourceFile(sourceFile, properties, typeAliases) {
|
|
178
|
+
let constructorParams;
|
|
179
|
+
let handlerLocation;
|
|
180
|
+
const visit = (node) => {
|
|
181
|
+
// Look for exported function declarations (topologica convention: one exported function per file)
|
|
182
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
183
|
+
// Check if it's exported
|
|
184
|
+
const isExported = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
185
|
+
if (isExported) {
|
|
186
|
+
this.extractThisProperties(node, properties);
|
|
187
|
+
// Extract constructor params and location from the exported function
|
|
188
|
+
if (!constructorParams) {
|
|
189
|
+
constructorParams = this.extractConstructorParams(node, typeAliases);
|
|
190
|
+
// Capture the function location
|
|
191
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile));
|
|
192
|
+
handlerLocation = {
|
|
193
|
+
filePath: sourceFile.fileName,
|
|
194
|
+
line: line + 1, // 1-based
|
|
195
|
+
column: character + 1 // 1-based
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Also check function expressions/arrow functions assigned to exports
|
|
201
|
+
else if (ts.isFunctionExpression(node) || ts.isArrowFunction(node)) {
|
|
202
|
+
this.extractThisProperties(node, properties);
|
|
203
|
+
// Extract constructor params from non-exported functions too
|
|
204
|
+
if (!constructorParams) {
|
|
205
|
+
constructorParams = this.extractConstructorParams(node, typeAliases);
|
|
206
|
+
// Capture the function location
|
|
207
|
+
const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile));
|
|
208
|
+
handlerLocation = {
|
|
209
|
+
filePath: sourceFile.fileName,
|
|
210
|
+
line: line + 1, // 1-based
|
|
211
|
+
column: character + 1 // 1-based
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
ts.forEachChild(node, visit);
|
|
216
|
+
};
|
|
217
|
+
visit(sourceFile);
|
|
218
|
+
return { constructorParams, handlerLocation };
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Extract `this.property = value` assignments from a function body
|
|
222
|
+
*/
|
|
223
|
+
extractThisProperties(func, properties) {
|
|
224
|
+
const body = func.body;
|
|
225
|
+
if (!body)
|
|
226
|
+
return;
|
|
227
|
+
const visitStatements = (node) => {
|
|
228
|
+
// Handle expression statements
|
|
229
|
+
if (ts.isExpressionStatement(node)) {
|
|
230
|
+
const expr = node.expression;
|
|
231
|
+
// Check for this.prop = value
|
|
232
|
+
if (ts.isBinaryExpression(expr) &&
|
|
233
|
+
expr.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
234
|
+
const left = expr.left;
|
|
235
|
+
const right = expr.right;
|
|
236
|
+
// Check if left side is this.property
|
|
237
|
+
if (ts.isPropertyAccessExpression(left) &&
|
|
238
|
+
left.expression.kind === ts.SyntaxKind.ThisKeyword) {
|
|
239
|
+
const propName = left.name.text;
|
|
240
|
+
const propType = this.inferType(right);
|
|
241
|
+
properties.set(propName, {
|
|
242
|
+
name: propName,
|
|
243
|
+
type: propType,
|
|
244
|
+
optional: false,
|
|
245
|
+
readonly: false
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// Check for Object.assign(this, {...})
|
|
250
|
+
if (ts.isCallExpression(expr)) {
|
|
251
|
+
const callExpr = expr;
|
|
252
|
+
if (this.isObjectAssignCall(callExpr)) {
|
|
253
|
+
this.extractFromObjectAssign(callExpr, properties);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
ts.forEachChild(node, visitStatements);
|
|
258
|
+
};
|
|
259
|
+
visitStatements(body);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Check if a call expression is Object.assign(this, ...)
|
|
263
|
+
*/
|
|
264
|
+
isObjectAssignCall(callExpr) {
|
|
265
|
+
const expr = callExpr.expression;
|
|
266
|
+
if (!ts.isPropertyAccessExpression(expr))
|
|
267
|
+
return false;
|
|
268
|
+
const objName = ts.isIdentifier(expr.expression) ? expr.expression.text : null;
|
|
269
|
+
const methodName = expr.name.text;
|
|
270
|
+
if (objName === 'Object' && methodName === 'assign') {
|
|
271
|
+
const firstArg = callExpr.arguments[0];
|
|
272
|
+
if (firstArg && firstArg.kind === ts.SyntaxKind.ThisKeyword) {
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Extract properties from Object.assign(this, data) pattern
|
|
280
|
+
*/
|
|
281
|
+
extractFromObjectAssign(callExpr, properties) {
|
|
282
|
+
// Look for the data argument (second argument)
|
|
283
|
+
const dataArg = callExpr.arguments[1];
|
|
284
|
+
if (!dataArg)
|
|
285
|
+
return;
|
|
286
|
+
// If it's an object literal, extract properties
|
|
287
|
+
if (ts.isObjectLiteralExpression(dataArg)) {
|
|
288
|
+
for (const prop of dataArg.properties) {
|
|
289
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {
|
|
290
|
+
const propName = prop.name.text;
|
|
291
|
+
const propType = this.inferType(prop.initializer);
|
|
292
|
+
properties.set(propName, {
|
|
293
|
+
name: propName,
|
|
294
|
+
type: propType,
|
|
295
|
+
optional: false,
|
|
296
|
+
readonly: false
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Extract constructor parameters from a function
|
|
304
|
+
* Similar to main analyzer - skips `this` parameter and expands data types
|
|
305
|
+
*/
|
|
306
|
+
extractConstructorParams(func, typeAliases) {
|
|
307
|
+
if (!func.parameters || func.parameters.length === 0) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
310
|
+
const params = [];
|
|
311
|
+
// Skip `this` parameter (first param) and extract data parameters
|
|
312
|
+
for (let i = 0; i < func.parameters.length; i++) {
|
|
313
|
+
const param = func.parameters[i];
|
|
314
|
+
// Skip `this` parameter (first param)
|
|
315
|
+
if (i === 0 && param.name.kind === ts.SyntaxKind.Identifier &&
|
|
316
|
+
param.name.text === 'this') {
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (!param.type)
|
|
320
|
+
continue;
|
|
321
|
+
const paramName = ts.isIdentifier(param.name) ? param.name.text : 'arg';
|
|
322
|
+
const optional = param.questionToken !== undefined || param.initializer !== undefined;
|
|
323
|
+
// Expand type to object literal if possible
|
|
324
|
+
const expandedType = this.expandTypeToObject(param.type, typeAliases);
|
|
325
|
+
const paramType = expandedType || this.typeNodeToSimpleString(param.type);
|
|
326
|
+
params.push({
|
|
327
|
+
name: paramName,
|
|
328
|
+
type: paramType,
|
|
329
|
+
optional: optional
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return params.length > 0 ? params : undefined;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Expand a type node to its object literal representation
|
|
336
|
+
* Similar to main analyzer's resolveTypeAndExtract
|
|
337
|
+
*/
|
|
338
|
+
expandTypeToObject(typeNode, typeAliases) {
|
|
339
|
+
// Direct inline type literal: { prop: type }
|
|
340
|
+
if (ts.isTypeLiteralNode(typeNode)) {
|
|
341
|
+
const props = [];
|
|
342
|
+
for (const member of typeNode.members) {
|
|
343
|
+
if (ts.isPropertySignature(member) && ts.isIdentifier(member.name)) {
|
|
344
|
+
const propName = member.name.text;
|
|
345
|
+
const opt = member.questionToken ? '?' : '';
|
|
346
|
+
const type = this.typeNodeToSimpleString(member.type);
|
|
347
|
+
props.push(`${propName}${opt}: ${type}`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return `{ ${props.join('; ')} }`;
|
|
351
|
+
}
|
|
352
|
+
// Type reference: SentienceData, etc. - try to expand from type aliases
|
|
353
|
+
if (ts.isTypeReferenceNode(typeNode) && ts.isIdentifier(typeNode.typeName)) {
|
|
354
|
+
const typeName = typeNode.typeName.text;
|
|
355
|
+
// If we have type aliases, try to expand the referenced type
|
|
356
|
+
if (typeAliases) {
|
|
357
|
+
const aliasedType = typeAliases.get(typeName);
|
|
358
|
+
if (aliasedType) {
|
|
359
|
+
const expanded = this.expandTypeToObject(aliasedType, typeAliases);
|
|
360
|
+
if (expanded)
|
|
361
|
+
return expanded;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// If not an object type alias, return the type name
|
|
365
|
+
return typeName;
|
|
366
|
+
}
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Convert a TypeScript type node to a simple string representation
|
|
371
|
+
*/
|
|
372
|
+
typeNodeToSimpleString(typeNode) {
|
|
373
|
+
if (!typeNode)
|
|
374
|
+
return 'any';
|
|
375
|
+
switch (typeNode.kind) {
|
|
376
|
+
case ts.SyntaxKind.StringKeyword:
|
|
377
|
+
return 'string';
|
|
378
|
+
case ts.SyntaxKind.NumberKeyword:
|
|
379
|
+
return 'number';
|
|
380
|
+
case ts.SyntaxKind.BooleanKeyword:
|
|
381
|
+
return 'boolean';
|
|
382
|
+
case ts.SyntaxKind.AnyKeyword:
|
|
383
|
+
return 'any';
|
|
384
|
+
case ts.SyntaxKind.ArrayType:
|
|
385
|
+
return 'Array<any>';
|
|
386
|
+
case ts.SyntaxKind.TypeReference: {
|
|
387
|
+
const typeRef = typeNode;
|
|
388
|
+
if (ts.isIdentifier(typeRef.typeName)) {
|
|
389
|
+
return typeRef.typeName.text;
|
|
390
|
+
}
|
|
391
|
+
return 'any';
|
|
392
|
+
}
|
|
393
|
+
default:
|
|
394
|
+
return 'any';
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Infer TypeScript type from an expression
|
|
399
|
+
*/
|
|
400
|
+
inferType(node) {
|
|
401
|
+
switch (node.kind) {
|
|
402
|
+
case ts.SyntaxKind.StringLiteral:
|
|
403
|
+
return 'string';
|
|
404
|
+
case ts.SyntaxKind.NumericLiteral:
|
|
405
|
+
return 'number';
|
|
406
|
+
case ts.SyntaxKind.TrueKeyword:
|
|
407
|
+
case ts.SyntaxKind.FalseKeyword:
|
|
408
|
+
return 'boolean';
|
|
409
|
+
case ts.SyntaxKind.NullKeyword:
|
|
410
|
+
return 'null';
|
|
411
|
+
case ts.SyntaxKind.UndefinedKeyword:
|
|
412
|
+
return 'undefined';
|
|
413
|
+
case ts.SyntaxKind.ArrayLiteralExpression:
|
|
414
|
+
return 'Array<any>';
|
|
415
|
+
case ts.SyntaxKind.ObjectLiteralExpression:
|
|
416
|
+
return 'object';
|
|
417
|
+
case ts.SyntaxKind.NewExpression:
|
|
418
|
+
return this.inferNewExpressionType(node);
|
|
419
|
+
case ts.SyntaxKind.ConditionalExpression:
|
|
420
|
+
return this.inferType(node.whenTrue);
|
|
421
|
+
case ts.SyntaxKind.BinaryExpression: {
|
|
422
|
+
const binExpr = node;
|
|
423
|
+
// Check for logical OR pattern: value || default
|
|
424
|
+
if (binExpr.operatorToken.kind === ts.SyntaxKind.BarBarToken) {
|
|
425
|
+
// Return the type of the right side (the default value)
|
|
426
|
+
return this.inferType(binExpr.right);
|
|
427
|
+
}
|
|
428
|
+
return 'any';
|
|
429
|
+
}
|
|
430
|
+
case ts.SyntaxKind.PropertyAccessExpression: {
|
|
431
|
+
const propAccess = node;
|
|
432
|
+
// Handle data?.property patterns
|
|
433
|
+
return this.inferType(propAccess);
|
|
434
|
+
}
|
|
435
|
+
case ts.SyntaxKind.CallExpression: {
|
|
436
|
+
const callExpr = node;
|
|
437
|
+
return this.inferCallExpressionType(callExpr);
|
|
438
|
+
}
|
|
439
|
+
default:
|
|
440
|
+
return 'any';
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Infer type from new expressions like new Date(), new Array(), etc.
|
|
445
|
+
*/
|
|
446
|
+
inferNewExpressionType(node) {
|
|
447
|
+
const expr = node.expression;
|
|
448
|
+
if (ts.isIdentifier(expr)) {
|
|
449
|
+
switch (expr.text) {
|
|
450
|
+
case 'Date':
|
|
451
|
+
return 'number'; // Date.now() returns number
|
|
452
|
+
case 'Array':
|
|
453
|
+
return 'Array<any>';
|
|
454
|
+
case 'Map':
|
|
455
|
+
return 'Map<any, any>';
|
|
456
|
+
case 'Set':
|
|
457
|
+
return 'Set<any>';
|
|
458
|
+
case 'RegExp':
|
|
459
|
+
return 'RegExp';
|
|
460
|
+
default:
|
|
461
|
+
return expr.text;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return 'any';
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Infer type from call expressions like Date.now(), parseInt(), etc.
|
|
468
|
+
*/
|
|
469
|
+
inferCallExpressionType(node) {
|
|
470
|
+
const expr = node.expression;
|
|
471
|
+
// Handle Date.now()
|
|
472
|
+
if (ts.isPropertyAccessExpression(expr)) {
|
|
473
|
+
const obj = expr.expression;
|
|
474
|
+
const method = expr.name.text;
|
|
475
|
+
if (ts.isIdentifier(obj) && obj.text === 'Date' && method === 'now') {
|
|
476
|
+
return 'number';
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
// Handle parseInt, parseFloat, String(), Number(), Boolean()
|
|
480
|
+
if (ts.isIdentifier(expr)) {
|
|
481
|
+
switch (expr.text) {
|
|
482
|
+
case 'parseInt':
|
|
483
|
+
case 'parseFloat':
|
|
484
|
+
return 'number';
|
|
485
|
+
case 'String':
|
|
486
|
+
return 'string';
|
|
487
|
+
case 'Number':
|
|
488
|
+
return 'number';
|
|
489
|
+
case 'Boolean':
|
|
490
|
+
return 'boolean';
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return 'any';
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Get the type graph
|
|
497
|
+
*/
|
|
498
|
+
getGraph() {
|
|
499
|
+
return this.graph;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Get collected errors
|
|
503
|
+
*/
|
|
504
|
+
getErrors() {
|
|
505
|
+
return this.errors;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
exports.TopologicaAnalyzer = TopologicaAnalyzer;
|
|
509
|
+
//# sourceMappingURL=topologica-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topologica-analyzer.js","sourceRoot":"","sources":["../src/topologica-analyzer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AAEjC,mCAAwC;AAExC;;;;;;GAMG;AACH,MAAa,kBAAkB;IAA/B;QACS,WAAM,GAAa,EAAE,CAAC;QACtB,UAAK,GAAG,IAAI,qBA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|
+
/** True if this is a getter property (readonly) */
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Constructor parameter info for TypeRegistry signatures */
|
|
24
|
+
export interface ConstructorParamInfo {
|
|
25
|
+
/** Parameter name (e.g., "usages", "data", "config") */
|
|
26
|
+
name: string;
|
|
27
|
+
/** The type string - can be a simple type or expanded object literal */
|
|
28
|
+
type: string;
|
|
29
|
+
optional: boolean;
|
|
20
30
|
}
|
|
21
31
|
export interface TypeNode {
|
|
22
32
|
/** Type name (e.g., "SecondType") */
|
|
@@ -25,6 +35,8 @@ export interface TypeNode {
|
|
|
25
35
|
fullPath: string;
|
|
26
36
|
/** Properties defined in this type's constructor */
|
|
27
37
|
properties: Map<string, PropertyInfo>;
|
|
38
|
+
/** Constructor parameters (for TypeRegistry constructor signature) */
|
|
39
|
+
constructorParams?: ConstructorParamInfo[];
|
|
28
40
|
/** Parent type node */
|
|
29
41
|
parent?: TypeNode;
|
|
30
42
|
/** Child types */
|
|
@@ -70,3 +82,101 @@ export interface GeneratedTypes {
|
|
|
70
82
|
/** Types that were generated */
|
|
71
83
|
types: string[];
|
|
72
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Definition info for code navigation
|
|
87
|
+
*/
|
|
88
|
+
export interface DefinitionInfo {
|
|
89
|
+
/** Type name (e.g., "AdminType") */
|
|
90
|
+
name: string;
|
|
91
|
+
/** Location in source: file.ts:Line:Col */
|
|
92
|
+
location: string;
|
|
93
|
+
/** How type was created: 'define' or 'decorate' */
|
|
94
|
+
kind: 'define' | 'decorate';
|
|
95
|
+
/** Parent type full path, null if root */
|
|
96
|
+
parent: string | null;
|
|
97
|
+
/** strictChain config option */
|
|
98
|
+
strictChain: boolean;
|
|
99
|
+
/** blockErrors config option */
|
|
100
|
+
blockErrors: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Usage info for code navigation
|
|
104
|
+
*/
|
|
105
|
+
export interface UsageInfo {
|
|
106
|
+
/** Location in source: file.ts:Line:Col */
|
|
107
|
+
location: string;
|
|
108
|
+
/** Kind of usage: instantiation, typeAnnotation, propertyAccess, lookup, reference */
|
|
109
|
+
kind: 'instantiation' | 'typeAnnotation' | 'propertyAccess' | 'lookup' | 'reference';
|
|
110
|
+
/** Code snippet */
|
|
111
|
+
code: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* JSON output for definitions.json
|
|
115
|
+
*/
|
|
116
|
+
export interface DefinitionsJson {
|
|
117
|
+
version: string;
|
|
118
|
+
generatedAt: string;
|
|
119
|
+
definitions: Record<string, DefinitionInfo>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* JSON output for usages.json
|
|
123
|
+
*/
|
|
124
|
+
export interface UsagesJson {
|
|
125
|
+
version: string;
|
|
126
|
+
generatedAt: string;
|
|
127
|
+
usages: Record<string, UsageInfo[]>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* EDS (Execution Data Storage) kind for tracking execution flow patterns
|
|
131
|
+
*/
|
|
132
|
+
export type EDSKind = 'wrap' | 'link' | 'contextConsume' | 'errorEnrich' | 'hookAttach' | 'adapterUse';
|
|
133
|
+
/**
|
|
134
|
+
* EDS info for execution data flow tracking
|
|
135
|
+
*/
|
|
136
|
+
export interface EDSInfo {
|
|
137
|
+
/** Location in source: file.ts:Line:Col */
|
|
138
|
+
location: string;
|
|
139
|
+
/** Kind of EDS usage */
|
|
140
|
+
kind: EDSKind;
|
|
141
|
+
/** Code snippet */
|
|
142
|
+
code: string;
|
|
143
|
+
/** Resolved target type if detectable */
|
|
144
|
+
targetType?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* JSON output for eds.json
|
|
148
|
+
*/
|
|
149
|
+
export interface EDSJson {
|
|
150
|
+
version: string;
|
|
151
|
+
generatedAt: string;
|
|
152
|
+
eds: Record<string, EDSInfo[]>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Flow kind for tracking native instance usage patterns
|
|
156
|
+
*/
|
|
157
|
+
export type FlowKind = 'propertyRead' | 'propertyWrite' | 'methodCall' | 'destructureRead' | 'passAsArg' | 'return' | 'spread' | 'arrayElement' | 'conditionalAccess' | 'elementAccess' | 'reassignment' | 'instantiation';
|
|
158
|
+
/**
|
|
159
|
+
* Flow info for native instance usage tracking
|
|
160
|
+
*/
|
|
161
|
+
export interface FlowInfo {
|
|
162
|
+
/** Location in source: file.ts:Line:Col */
|
|
163
|
+
location: string;
|
|
164
|
+
/** Kind of flow */
|
|
165
|
+
kind: FlowKind;
|
|
166
|
+
/** Code snippet */
|
|
167
|
+
code: string;
|
|
168
|
+
/** Property name if applicable */
|
|
169
|
+
propertyName?: string;
|
|
170
|
+
/** Resolved target type if known */
|
|
171
|
+
targetType?: string;
|
|
172
|
+
/** Context (function name, param position, etc.) */
|
|
173
|
+
context?: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* JSON output for flow.json
|
|
177
|
+
*/
|
|
178
|
+
export interface FlowJson {
|
|
179
|
+
version: string;
|
|
180
|
+
generatedAt: string;
|
|
181
|
+
flow: Record<string, FlowInfo[]>;
|
|
182
|
+
}
|