@arcteninc/core 0.0.59 ā 0.0.60
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.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"sideEffects": false,
|
|
22
22
|
"bin": {
|
|
23
|
-
"arcten
|
|
24
|
-
"arcten-update-core": "./scripts/update-core.js"
|
|
23
|
+
"arcten": "./scripts/arcten-cli.js"
|
|
25
24
|
},
|
|
26
25
|
"files": [
|
|
27
26
|
"dist",
|
|
28
27
|
"scripts/cli-extract-types-auto.ts",
|
|
29
28
|
"scripts/cli-extract-types-auto.js",
|
|
29
|
+
"scripts/arcten-cli.js",
|
|
30
30
|
"scripts/postinstall-check-version.js",
|
|
31
31
|
"scripts/update-core.js"
|
|
32
32
|
],
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Arcten CLI - Unified command interface
|
|
4
|
+
* Usage: arcten <command> [options]
|
|
5
|
+
*
|
|
6
|
+
* Commands:
|
|
7
|
+
* extract-types, tools Extract tool metadata from your project
|
|
8
|
+
* update Update @arcteninc/core to latest version
|
|
9
|
+
* help Show help message
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { spawn } = require('child_process');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
|
|
16
|
+
const commands = {
|
|
17
|
+
'extract-types': () => require('./cli-extract-types-auto.js'),
|
|
18
|
+
'tools': () => require('./cli-extract-types-auto.js'), // Alias
|
|
19
|
+
'update': () => require('./update-core.js'),
|
|
20
|
+
'help': showHelp,
|
|
21
|
+
'--help': showHelp,
|
|
22
|
+
'-h': showHelp,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function showHelp() {
|
|
26
|
+
console.log(`
|
|
27
|
+
š¦ Arcten CLI
|
|
28
|
+
|
|
29
|
+
Usage: arcten <command> [options]
|
|
30
|
+
|
|
31
|
+
Commands:
|
|
32
|
+
extract-types, tools Extract tool metadata from your project
|
|
33
|
+
Alias: arcten tools
|
|
34
|
+
|
|
35
|
+
update Update @arcteninc/core to latest version
|
|
36
|
+
Updates package.json and shows next steps
|
|
37
|
+
|
|
38
|
+
help Show this help message
|
|
39
|
+
|
|
40
|
+
Examples:
|
|
41
|
+
arcten tools Extract tool types (same as arcten extract-types)
|
|
42
|
+
arcten update Update @arcteninc/core to latest version
|
|
43
|
+
arcten help Show help
|
|
44
|
+
|
|
45
|
+
For more information, visit https://github.com/arcteninc/core
|
|
46
|
+
`);
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function main() {
|
|
51
|
+
const args = process.argv.slice(2);
|
|
52
|
+
|
|
53
|
+
if (args.length === 0) {
|
|
54
|
+
showHelp();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const command = args[0];
|
|
59
|
+
const commandArgs = args.slice(1);
|
|
60
|
+
|
|
61
|
+
if (!commands[command]) {
|
|
62
|
+
console.error(`ā Unknown command: ${command}`);
|
|
63
|
+
console.error(`\nRun 'arcten help' for available commands`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const commandHandler = commands[command];
|
|
69
|
+
if (typeof commandHandler === 'function' && commandHandler !== showHelp) {
|
|
70
|
+
// For commands that are modules, we need to handle them differently
|
|
71
|
+
// Since they're designed to run as standalone scripts, we'll spawn them
|
|
72
|
+
let scriptPath;
|
|
73
|
+
let runner = 'node';
|
|
74
|
+
|
|
75
|
+
if (command === 'update') {
|
|
76
|
+
scriptPath = path.join(__dirname, 'update-core.js');
|
|
77
|
+
} else {
|
|
78
|
+
// For extract-types/tools, try .js first, fallback to .ts with bun
|
|
79
|
+
const jsPath = path.join(__dirname, 'cli-extract-types-auto.js');
|
|
80
|
+
const tsPath = path.join(__dirname, 'cli-extract-types-auto.ts');
|
|
81
|
+
|
|
82
|
+
if (fs.existsSync(jsPath)) {
|
|
83
|
+
scriptPath = jsPath;
|
|
84
|
+
} else if (fs.existsSync(tsPath)) {
|
|
85
|
+
scriptPath = tsPath;
|
|
86
|
+
runner = 'bun'; // Use bun for TypeScript files
|
|
87
|
+
} else {
|
|
88
|
+
console.error(`ā Script not found: ${jsPath} or ${tsPath}`);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!fs.existsSync(scriptPath)) {
|
|
94
|
+
console.error(`ā Script not found: ${scriptPath}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Spawn the script with remaining args
|
|
99
|
+
const child = spawn(runner, [scriptPath, ...commandArgs], {
|
|
100
|
+
stdio: 'inherit',
|
|
101
|
+
cwd: process.cwd(),
|
|
102
|
+
shell: true // Use shell to find bun/node in PATH
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
child.on('error', (error) => {
|
|
106
|
+
console.error(`ā Failed to run command:`, error.message);
|
|
107
|
+
if (runner === 'bun' && error.code === 'ENOENT') {
|
|
108
|
+
console.error(`\nš” Bun not found. Install it: https://bun.sh`);
|
|
109
|
+
console.error(` Or ensure cli-extract-types-auto.js is compiled`);
|
|
110
|
+
}
|
|
111
|
+
process.exit(1);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
child.on('exit', (code) => {
|
|
115
|
+
process.exit(code || 0);
|
|
116
|
+
});
|
|
117
|
+
} else {
|
|
118
|
+
// For help command
|
|
119
|
+
commandHandler();
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error(`ā Error running command:`, error.message);
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
main();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = { main };
|
|
132
|
+
|
|
File without changes
|
|
@@ -83,7 +83,6 @@ async function findToolUsageFiles(projectRoot: string): Promise<string[]> {
|
|
|
83
83
|
ignore: ['**/node_modules/**', '**/dist/**', '**/.next/**', '**/build/**'],
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
console.log(`š Found ${files.length} TypeScript files to scan`);
|
|
87
86
|
return files;
|
|
88
87
|
}
|
|
89
88
|
|
|
@@ -1382,10 +1381,11 @@ async function extractFunctionMetadata(
|
|
|
1382
1381
|
* Main function
|
|
1383
1382
|
*/
|
|
1384
1383
|
async function autoDiscoverAndExtract(projectRoot: string, outputPath: string) {
|
|
1385
|
-
console.log(`\nš
|
|
1384
|
+
console.log(`\nš Discovering tools in your project...\n`);
|
|
1386
1385
|
|
|
1387
1386
|
// Find all TypeScript files
|
|
1388
1387
|
const files = await findToolUsageFiles(projectRoot);
|
|
1388
|
+
console.log(`š Scanning ${files.length} TypeScript file${files.length !== 1 ? 's' : ''}...`);
|
|
1389
1389
|
|
|
1390
1390
|
// Read tsconfig
|
|
1391
1391
|
const configPath = ts.findConfigFile(projectRoot, ts.sys.fileExists, 'tsconfig.json');
|
|
@@ -1420,19 +1420,34 @@ async function autoDiscoverAndExtract(projectRoot: string, outputPath: string) {
|
|
|
1420
1420
|
}
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
console.log(
|
|
1426
|
-
console.log(`
|
|
1423
|
+
if (allToolUsages.length === 0) {
|
|
1424
|
+
console.log(`\nā ļø No tool usages found in ArctenAgent or useAgent components`);
|
|
1425
|
+
console.log(`\nš” Make sure you're using tools like this:`);
|
|
1426
|
+
console.log(` <ArctenAgent safeTools={[getLocation, resetPassword]} />`);
|
|
1427
|
+
console.log(` or`);
|
|
1428
|
+
console.log(` useAgent({ safeTools: [getLocation, resetPassword] })\n`);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
console.log(`\n⨠Found ${allToolUsages.length} usage site${allToolUsages.length !== 1 ? 's' : ''} with ${allToolNames.size} unique tool${allToolNames.size !== 1 ? 's' : ''}:`);
|
|
1433
|
+
allToolUsages.forEach((usage, idx) => {
|
|
1434
|
+
const relativePath = path.relative(projectRoot, usage.file);
|
|
1435
|
+
const tools = Array.from(usage.toolNames);
|
|
1436
|
+
console.log(`\n ${idx + 1}. ${usage.component} in ${relativePath}`);
|
|
1437
|
+
console.log(` Tools: ${tools.map(t => `\x1b[36m${t}\x1b[0m`).join(', ')}`);
|
|
1427
1438
|
});
|
|
1428
1439
|
|
|
1429
1440
|
// Extract metadata for discovered tools
|
|
1430
|
-
console.log(`\nš Extracting
|
|
1441
|
+
console.log(`\nš Extracting type metadata...\n`);
|
|
1431
1442
|
|
|
1432
1443
|
const functionsMap: Record<string, FunctionMetadata> = {};
|
|
1433
1444
|
const discoveredFrom: string[] = [];
|
|
1434
1445
|
|
|
1435
|
-
|
|
1446
|
+
const toolNamesArray = Array.from(allToolNames);
|
|
1447
|
+
let successCount = 0;
|
|
1448
|
+
let warningCount = 0;
|
|
1449
|
+
|
|
1450
|
+
for (const toolName of toolNamesArray) {
|
|
1436
1451
|
let found = false;
|
|
1437
1452
|
|
|
1438
1453
|
// Search in all files for the definition
|
|
@@ -1445,8 +1460,10 @@ async function autoDiscoverAndExtract(projectRoot: string, outputPath: string) {
|
|
|
1445
1460
|
if (metadata) {
|
|
1446
1461
|
functionsMap[toolName] = metadata;
|
|
1447
1462
|
discoveredFrom.push(path.relative(projectRoot, result.sourceFile.fileName));
|
|
1448
|
-
|
|
1463
|
+
const relativePath = path.relative(projectRoot, result.sourceFile.fileName);
|
|
1464
|
+
console.log(` ā \x1b[32m${toolName}\x1b[0m \x1b[90m(${relativePath})\x1b[0m`);
|
|
1449
1465
|
found = true;
|
|
1466
|
+
successCount++;
|
|
1450
1467
|
break;
|
|
1451
1468
|
}
|
|
1452
1469
|
}
|
|
@@ -1454,7 +1471,8 @@ async function autoDiscoverAndExtract(projectRoot: string, outputPath: string) {
|
|
|
1454
1471
|
}
|
|
1455
1472
|
|
|
1456
1473
|
if (!found) {
|
|
1457
|
-
console.log(`
|
|
1474
|
+
console.log(` ā \x1b[33m${toolName}\x1b[0m \x1b[90m(definition not found)\x1b[0m`);
|
|
1475
|
+
warningCount++;
|
|
1458
1476
|
}
|
|
1459
1477
|
}
|
|
1460
1478
|
|
|
@@ -1505,11 +1523,24 @@ export const toolMetadata = ${JSON.stringify(output, null, 2)} as const;
|
|
|
1505
1523
|
`;
|
|
1506
1524
|
|
|
1507
1525
|
fs.writeFileSync(outputPath, tsContent);
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
console.log(
|
|
1512
|
-
|
|
1526
|
+
|
|
1527
|
+
const relativeOutput = path.relative(projectRoot, outputPath);
|
|
1528
|
+
|
|
1529
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
1530
|
+
if (successCount > 0) {
|
|
1531
|
+
console.log(`ā
Successfully extracted ${successCount} tool${successCount !== 1 ? 's' : ''}`);
|
|
1532
|
+
}
|
|
1533
|
+
if (warningCount > 0) {
|
|
1534
|
+
console.log(`ā ļø ${warningCount} tool${warningCount !== 1 ? 's' : ''} not found (check function names)`);
|
|
1535
|
+
}
|
|
1536
|
+
console.log(`š Output: \x1b[36m${relativeOutput}\x1b[0m`);
|
|
1537
|
+
console.log(`${'='.repeat(60)}\n`);
|
|
1538
|
+
|
|
1539
|
+
if (successCount > 0) {
|
|
1540
|
+
console.log(`š” Usage in your component:`);
|
|
1541
|
+
console.log(` import { toolMetadata } from './.arcten/tool-metadata';`);
|
|
1542
|
+
console.log(` useAgent({ tools: [...], toolMetadata: toolMetadata.functions })\n`);
|
|
1543
|
+
}
|
|
1513
1544
|
}
|
|
1514
1545
|
|
|
1515
1546
|
// CLI
|
|
@@ -137,7 +137,7 @@ function main() {
|
|
|
137
137
|
console.log(` Consider updating to '^${latestVersion}' in package.json`);
|
|
138
138
|
console.log(` Then run 'npm install' to get the latest version`);
|
|
139
139
|
}
|
|
140
|
-
console.log(` Or use:
|
|
140
|
+
console.log(` Or use: \x1b[36mnpx arcten update\x1b[0m`);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// Restore original directory
|
package/scripts/update-core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Manual update command for @arcteninc/core
|
|
4
|
-
* Usage:
|
|
4
|
+
* Usage: arcten update
|
|
5
5
|
*
|
|
6
6
|
* This allows users to explicitly update their package.json
|
|
7
7
|
*/
|
|
@@ -64,8 +64,7 @@ function updateVersion(packageJsonPath, packageJson, latestVersion) {
|
|
|
64
64
|
|
|
65
65
|
if (updated) {
|
|
66
66
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
67
|
-
console.log(`ā
Updated
|
|
68
|
-
console.log(` Run 'npm install' to install the latest version`);
|
|
67
|
+
console.log(`ā
Updated to \x1b[32m^${latestVersion}\x1b[0m in package.json\n`);
|
|
69
68
|
return true;
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -102,18 +101,18 @@ function main() {
|
|
|
102
101
|
const current = currentVersionMatch[1];
|
|
103
102
|
|
|
104
103
|
if (current === latestVersion) {
|
|
105
|
-
console.log(
|
|
104
|
+
console.log(`\nā
Already on latest version: \x1b[32m${latestVersion}\x1b[0m\n`);
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
console.log(
|
|
110
|
-
console.log(` Current: ${current}`);
|
|
111
|
-
console.log(` Latest: ${latestVersion}`);
|
|
108
|
+
console.log(`\nš¦ Updating @arcteninc/core\n`);
|
|
109
|
+
console.log(` Current: \x1b[33m${current}\x1b[0m`);
|
|
110
|
+
console.log(` Latest: \x1b[32m${latestVersion}\x1b[0m\n`);
|
|
112
111
|
|
|
113
112
|
if (updateVersion(packageJsonPath, packageJson, latestVersion)) {
|
|
114
|
-
console.log(
|
|
113
|
+
console.log(`š” Next steps:`);
|
|
115
114
|
console.log(` 1. Review the changes in package.json`);
|
|
116
|
-
console.log(` 2. Run
|
|
115
|
+
console.log(` 2. Run \x1b[36mnpm install\x1b[0m to install the update\n`);
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
|