@arcteninc/core 0.0.24 → 0.0.25

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcteninc/core",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -20,11 +20,12 @@
20
20
  },
21
21
  "sideEffects": false,
22
22
  "bin": {
23
- "arcten-extract-types": "./scripts/cli-extract-types-auto.ts"
23
+ "arcten-extract-types": "./scripts/cli-extract-types-auto.js"
24
24
  },
25
25
  "files": [
26
26
  "dist",
27
- "scripts/cli-extract-types-auto.ts"
27
+ "scripts/cli-extract-types-auto.ts",
28
+ "scripts/cli-extract-types-auto.js"
28
29
  ],
29
30
  "scripts": {
30
31
  "dev": "vite build --watch",
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper script to run the TypeScript CLI with bun
4
+ * Works with both npm and bun
5
+ */
6
+
7
+ import { spawn } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+ import { dirname, join, resolve } from 'path';
10
+ import { existsSync } from 'fs';
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Path to the TypeScript script - resolve relative to this wrapper
16
+ const tsScript = resolve(__dirname, 'cli-extract-types-auto.ts');
17
+
18
+ // Check if bun is available
19
+ function checkBun() {
20
+ return new Promise((resolve) => {
21
+ const bunCheck = spawn('bun', ['--version'], { stdio: 'ignore' });
22
+ bunCheck.on('close', (code) => {
23
+ resolve(code === 0);
24
+ });
25
+ bunCheck.on('error', () => {
26
+ resolve(false);
27
+ });
28
+ });
29
+ }
30
+
31
+ async function main() {
32
+ const hasBun = await checkBun();
33
+
34
+ if (!hasBun) {
35
+ console.error('❌ Error: bun is required to run arcten-extract-types');
36
+ console.error('');
37
+ console.error('Please install bun:');
38
+ console.error(' curl -fsSL https://bun.sh/install | bash');
39
+ console.error('');
40
+ console.error('Or use bunx instead of npx:');
41
+ console.error(' bunx arcten-extract-types .');
42
+ process.exit(1);
43
+ }
44
+
45
+ if (!existsSync(tsScript)) {
46
+ console.error(`❌ Error: Script not found at ${tsScript}`);
47
+ process.exit(1);
48
+ }
49
+
50
+ // Run the TypeScript script with bun
51
+ const args = process.argv.slice(2);
52
+ const bunProcess = spawn('bun', [tsScript, ...args], {
53
+ stdio: 'inherit',
54
+ shell: true
55
+ });
56
+
57
+ bunProcess.on('close', (code) => {
58
+ process.exit(code || 0);
59
+ });
60
+
61
+ bunProcess.on('error', (err) => {
62
+ console.error('❌ Error running script:', err.message);
63
+ process.exit(1);
64
+ });
65
+ }
66
+
67
+ main();
68
+
@@ -78,11 +78,25 @@ function extractToolNamesFromExpression(
78
78
  if (ts.isSpreadElement(element)) {
79
79
  // Handle spread: [...someArray]
80
80
  extractFromExpr(element.expression);
81
+ } else if (ts.isArrowFunction(element) || ts.isFunctionExpression(element)) {
82
+ // Skip anonymous functions - they don't have names to extract
83
+ // Example: tools: [function getStatus() { ... }] - this should have a name
84
+ if (ts.isFunctionExpression(element) && element.name) {
85
+ toolNames.add(element.name.getText(sourceFile));
86
+ }
87
+ // For arrow functions without names, skip them
81
88
  } else {
82
89
  const name = element.getText(sourceFile).trim();
83
90
  // Remove any object property access (e.g., tools.getOrders -> getOrders)
84
91
  const simpleName = name.split('.').pop() || name;
85
- if (simpleName && simpleName !== 'undefined' && simpleName !== 'null') {
92
+ // Skip if it looks like code (contains operators, semicolons, etc.)
93
+ if (simpleName &&
94
+ simpleName !== 'undefined' &&
95
+ simpleName !== 'null' &&
96
+ !simpleName.includes('?') &&
97
+ !simpleName.includes(';') &&
98
+ !simpleName.includes('=>') &&
99
+ simpleName.length < 100) {
86
100
  toolNames.add(simpleName);
87
101
  }
88
102
  }
@@ -329,9 +343,9 @@ function findFunctionDefinition(
329
343
 
330
344
  function visitForImports(node: ts.Node) {
331
345
  if (ts.isImportDeclaration(node)) {
332
- const moduleSpecifier = node.moduleClause;
333
- if (moduleSpecifier && ts.isImportClause(moduleSpecifier)) {
334
- const namedBindings = moduleSpecifier.namedBindings;
346
+ const importClause = node.importClause;
347
+ if (importClause) {
348
+ const namedBindings = importClause.namedBindings;
335
349
  if (namedBindings && ts.isNamedImports(namedBindings)) {
336
350
  for (const element of namedBindings.elements) {
337
351
  const importedName = element.name.getText(sourceFile);