@agentrix/cli 0.0.2
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 +182 -0
- package/bin/agentrix.mjs +35 -0
- package/dist/index.cjs +16774 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +16754 -0
- package/dist/lib.cjs +19 -0
- package/dist/lib.d.cts +76 -0
- package/dist/lib.d.mts +76 -0
- package/dist/lib.mjs +11 -0
- package/dist/logger-CVOTByt5.cjs +497 -0
- package/dist/logger-f691UxTg.mjs +487 -0
- package/package.json +125 -0
- package/scripts/unpack-tools.cjs +163 -0
- package/tools/archives/difftastic-LICENSE +21 -0
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-LICENSE +3 -0
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +21 -0
- package/tools/licenses/ripgrep-LICENSE +3 -0
- package/tools/unpacked/difft +0 -0
- package/tools/unpacked/rg +0 -0
- package/tools/unpacked/ripgrep.node +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unpacks platform-specific binaries from compressed archives
|
|
5
|
+
* This script extracts the necessary tools for the current platform
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const zlib = require('zlib');
|
|
11
|
+
const tar = require('tar');
|
|
12
|
+
const os = require('os');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the platform-specific directory name
|
|
16
|
+
*/
|
|
17
|
+
function getPlatformDir() {
|
|
18
|
+
const platform = os.platform();
|
|
19
|
+
const arch = os.arch();
|
|
20
|
+
|
|
21
|
+
if (platform === 'darwin') {
|
|
22
|
+
if (arch === 'arm64') return 'arm64-darwin';
|
|
23
|
+
if (arch === 'x64') return 'x64-darwin';
|
|
24
|
+
} else if (platform === 'linux') {
|
|
25
|
+
if (arch === 'arm64') return 'arm64-linux';
|
|
26
|
+
if (arch === 'x64') return 'x64-linux';
|
|
27
|
+
} else if (platform === 'win32') {
|
|
28
|
+
if (arch === 'x64') return 'x64-win32';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error(`Unsupported platform: ${arch}-${platform}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the root tools directory
|
|
36
|
+
*/
|
|
37
|
+
function getToolsDir() {
|
|
38
|
+
// Handle both direct execution and require() calls
|
|
39
|
+
const scriptDir = __dirname;
|
|
40
|
+
return path.resolve(scriptDir, '..', 'tools');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if tools are already unpacked for current platform
|
|
45
|
+
*/
|
|
46
|
+
function areToolsUnpacked(toolsDir) {
|
|
47
|
+
const unpackedPath = path.join(toolsDir, 'unpacked');
|
|
48
|
+
|
|
49
|
+
if (!fs.existsSync(unpackedPath)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check for expected binaries
|
|
54
|
+
const isWin = os.platform() === 'win32';
|
|
55
|
+
const difftBinary = isWin ? 'difft.exe' : 'difft';
|
|
56
|
+
const rgBinary = isWin ? 'rg.exe' : 'rg';
|
|
57
|
+
|
|
58
|
+
const expectedFiles = [
|
|
59
|
+
path.join(unpackedPath, difftBinary),
|
|
60
|
+
path.join(unpackedPath, rgBinary),
|
|
61
|
+
path.join(unpackedPath, 'ripgrep.node')
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
return expectedFiles.every(file => fs.existsSync(file));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Unpack a tar.gz archive to a destination directory
|
|
69
|
+
*/
|
|
70
|
+
async function unpackArchive(archivePath, destDir) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
// Ensure destination directory exists
|
|
73
|
+
if (!fs.existsSync(destDir)) {
|
|
74
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Create read stream and extract
|
|
78
|
+
fs.createReadStream(archivePath)
|
|
79
|
+
.pipe(zlib.createGunzip())
|
|
80
|
+
.pipe(tar.extract({
|
|
81
|
+
cwd: destDir,
|
|
82
|
+
preserveMode: true,
|
|
83
|
+
preserveOwner: false
|
|
84
|
+
}))
|
|
85
|
+
.on('finish', () => {
|
|
86
|
+
// Set executable permissions for Unix systems
|
|
87
|
+
if (os.platform() !== 'win32') {
|
|
88
|
+
const files = fs.readdirSync(destDir);
|
|
89
|
+
files.forEach(file => {
|
|
90
|
+
const filePath = path.join(destDir, file);
|
|
91
|
+
const stats = fs.statSync(filePath);
|
|
92
|
+
if (stats.isFile() && !file.endsWith('.node')) {
|
|
93
|
+
// Make binary files executable
|
|
94
|
+
fs.chmodSync(filePath, 0o755);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
resolve();
|
|
99
|
+
})
|
|
100
|
+
.on('error', reject);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Main unpacking function
|
|
106
|
+
*/
|
|
107
|
+
async function unpackTools() {
|
|
108
|
+
try {
|
|
109
|
+
const platformDir = getPlatformDir();
|
|
110
|
+
const toolsDir = getToolsDir();
|
|
111
|
+
const archivesDir = path.join(toolsDir, 'archives');
|
|
112
|
+
const unpackedPath = path.join(toolsDir, 'unpacked');
|
|
113
|
+
|
|
114
|
+
// Check if already unpacked
|
|
115
|
+
if (areToolsUnpacked(toolsDir)) {
|
|
116
|
+
console.log(`Tools already unpacked for ${platformDir}`);
|
|
117
|
+
return { success: true, alreadyUnpacked: true };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log(`Unpacking tools for ${platformDir}...`);
|
|
121
|
+
|
|
122
|
+
// Create unpacked directory
|
|
123
|
+
if (!fs.existsSync(unpackedPath)) {
|
|
124
|
+
fs.mkdirSync(unpackedPath, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Unpack difftastic
|
|
128
|
+
const difftasticArchive = path.join(archivesDir, `difftastic-${platformDir}.tar.gz`);
|
|
129
|
+
if (!fs.existsSync(difftasticArchive)) {
|
|
130
|
+
throw new Error(`Archive not found: ${difftasticArchive}`);
|
|
131
|
+
}
|
|
132
|
+
await unpackArchive(difftasticArchive, unpackedPath);
|
|
133
|
+
|
|
134
|
+
// Unpack ripgrep
|
|
135
|
+
const ripgrepArchive = path.join(archivesDir, `ripgrep-${platformDir}.tar.gz`);
|
|
136
|
+
if (!fs.existsSync(ripgrepArchive)) {
|
|
137
|
+
throw new Error(`Archive not found: ${ripgrepArchive}`);
|
|
138
|
+
}
|
|
139
|
+
await unpackArchive(ripgrepArchive, unpackedPath);
|
|
140
|
+
|
|
141
|
+
console.log(`Tools unpacked successfully to ${unpackedPath}`);
|
|
142
|
+
return { success: true, alreadyUnpacked: false };
|
|
143
|
+
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error('Failed to unpack tools:', error.message);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Export for use as module
|
|
151
|
+
module.exports = { unpackTools, getPlatformDir, getToolsDir };
|
|
152
|
+
|
|
153
|
+
// Run if executed directly
|
|
154
|
+
if (require.main === module) {
|
|
155
|
+
unpackTools()
|
|
156
|
+
.then(result => {
|
|
157
|
+
process.exit(0);
|
|
158
|
+
})
|
|
159
|
+
.catch(error => {
|
|
160
|
+
console.error('Error:', error);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2025 Wilfred Hughes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2025 Wilfred Hughes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|