@arcteninc/core 0.0.24 → 0.0.26

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.26",
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,93 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper script to run the TypeScript CLI
4
+ * Works with Node.js - no bun required!
5
+ */
6
+
7
+ import { spawn } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+ import { dirname, 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 a command is available
19
+ function checkCommand(cmd) {
20
+ return new Promise((resolve) => {
21
+ const check = spawn(cmd, ['--version'], { stdio: 'ignore', shell: true });
22
+ check.on('close', (code) => {
23
+ resolve(code === 0);
24
+ });
25
+ check.on('error', () => {
26
+ resolve(false);
27
+ });
28
+ });
29
+ }
30
+
31
+ async function main() {
32
+ if (!existsSync(tsScript)) {
33
+ console.error(`❌ Error: Script not found at ${tsScript}`);
34
+ process.exit(1);
35
+ }
36
+
37
+ const args = process.argv.slice(2);
38
+
39
+ // Try tsx first (lightweight TypeScript runner for Node.js)
40
+ // Use npx to run it without requiring installation
41
+ const hasTsx = await checkCommand('npx');
42
+
43
+ if (hasTsx) {
44
+ // Use tsx via npx - it's lightweight and works great with Node.js
45
+ const tsxProcess = spawn('npx', ['-y', 'tsx', tsScript, ...args], {
46
+ stdio: 'inherit',
47
+ shell: true
48
+ });
49
+
50
+ tsxProcess.on('close', (code) => {
51
+ process.exit(code || 0);
52
+ });
53
+
54
+ tsxProcess.on('error', (err) => {
55
+ // If tsx fails, try bun as fallback
56
+ tryBunFallback(args);
57
+ });
58
+ } else {
59
+ // Fallback to bun if npx isn't available
60
+ tryBunFallback(args);
61
+ }
62
+ }
63
+
64
+ async function tryBunFallback(args) {
65
+ const hasBun = await checkCommand('bun');
66
+
67
+ if (hasBun) {
68
+ const bunProcess = spawn('bun', [tsScript, ...args], {
69
+ stdio: 'inherit',
70
+ shell: true
71
+ });
72
+
73
+ bunProcess.on('close', (code) => {
74
+ process.exit(code || 0);
75
+ });
76
+
77
+ bunProcess.on('error', (err) => {
78
+ console.error('❌ Error: Could not run script');
79
+ console.error('Please ensure you have Node.js (with npx) or bun installed');
80
+ process.exit(1);
81
+ });
82
+ } else {
83
+ console.error('❌ Error: Could not find a TypeScript runner');
84
+ console.error('');
85
+ console.error('Please install one of the following:');
86
+ console.error(' - Node.js (comes with npx) - recommended');
87
+ console.error(' - bun: curl -fsSL https://bun.sh/install | bash');
88
+ process.exit(1);
89
+ }
90
+ }
91
+
92
+ main();
93
+
@@ -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);