@arcteninc/core 0.0.95 → 0.0.96
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/package.json
CHANGED
|
@@ -87,6 +87,33 @@ async function findToolUsageFiles(projectRoot: string): Promise<string[]> {
|
|
|
87
87
|
return files;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function unwrapExpression(expr: ts.Expression): ts.Expression {
|
|
91
|
+
let current: ts.Expression = expr;
|
|
92
|
+
// Keep unwrapping as long as we're looking at wrappers
|
|
93
|
+
while (true) {
|
|
94
|
+
if (ts.isParenthesizedExpression(current)) {
|
|
95
|
+
current = current.expression;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (ts.isAsExpression(current)) {
|
|
99
|
+
current = current.expression;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (ts.isTypeAssertionExpression(current)) {
|
|
103
|
+
current = current.expression;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// satisfies expressions exist in TS 4.9+
|
|
107
|
+
// @ts-ignore - older compiler types may not have this helper
|
|
108
|
+
if (typeof ts.isSatisfiesExpression === 'function' && ts.isSatisfiesExpression(current)) {
|
|
109
|
+
current = current.expression;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return current;
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
/**
|
|
91
118
|
* Extract tool names from an expression (handles arrays, variables, useMemo, etc.)
|
|
92
119
|
*/
|
|
@@ -100,6 +127,9 @@ function extractToolNamesFromExpression(
|
|
|
100
127
|
const visited = new Set<ts.Node>();
|
|
101
128
|
|
|
102
129
|
function extractFromExpr(node: ts.Node): void {
|
|
130
|
+
if (ts.isExpression(node)) {
|
|
131
|
+
node = unwrapExpression(node);
|
|
132
|
+
}
|
|
103
133
|
if (visited.has(node)) return;
|
|
104
134
|
visited.add(node);
|
|
105
135
|
|
|
@@ -217,11 +247,7 @@ function extractToolNamesFromExpression(
|
|
|
217
247
|
return;
|
|
218
248
|
}
|
|
219
249
|
|
|
220
|
-
//
|
|
221
|
-
if (ts.isParenthesizedExpression(node)) {
|
|
222
|
-
extractFromExpr(node.expression);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
250
|
+
// Parentheses handled via unwrapExpression
|
|
225
251
|
}
|
|
226
252
|
|
|
227
253
|
extractFromExpr(expr);
|
|
@@ -331,7 +357,7 @@ function extractToolNamesFromFile(
|
|
|
331
357
|
const toolNames = new Set<string>();
|
|
332
358
|
|
|
333
359
|
if (node.arguments.length > 0) {
|
|
334
|
-
const arg = node.arguments[0];
|
|
360
|
+
const arg = unwrapExpression(node.arguments[0]);
|
|
335
361
|
if (ts.isObjectLiteralExpression(arg)) {
|
|
336
362
|
for (const prop of arg.properties) {
|
|
337
363
|
if (ts.isPropertyAssignment(prop)) {
|
|
@@ -365,7 +391,7 @@ function extractToolNamesFromFile(
|
|
|
365
391
|
// Collect ordered tool names from tools and safeTools properties
|
|
366
392
|
const allToolOrder: string[] = [];
|
|
367
393
|
if (node.arguments.length > 0) {
|
|
368
|
-
const arg = node.arguments[0];
|
|
394
|
+
const arg = unwrapExpression(node.arguments[0]);
|
|
369
395
|
if (ts.isObjectLiteralExpression(arg)) {
|
|
370
396
|
for (const prop of arg.properties) {
|
|
371
397
|
if (ts.isPropertyAssignment(prop)) {
|