anymous 1.3.2 → 1.3.3
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 +15 -15
- package/bin/anymous.js +0 -0
- package/package.json +13 -13
- package/postinstall.mjs +214 -214
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# js
|
|
2
|
-
|
|
3
|
-
To install dependencies:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
bun install
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
To run:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bun run index.ts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
This project was created using `bun init` in bun v1.2.12. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
1
|
+
# js
|
|
2
|
+
|
|
3
|
+
To install dependencies:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run index.ts
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This project was created using `bun init` in bun v1.2.12. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
package/bin/anymous.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.3.
|
|
9
|
+
"version": "1.3.3",
|
|
10
10
|
"description": "AI-powered reverse engineering platform",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"homepage": "https://github.com/anymousdark/anymous",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"x64"
|
|
25
25
|
],
|
|
26
26
|
"optionalDependencies": {
|
|
27
|
-
"anymous-linux-arm64-musl": "1.3.
|
|
28
|
-
"anymous-linux-x64": "1.3.
|
|
29
|
-
"anymous-darwin-x64-baseline": "1.3.
|
|
30
|
-
"anymous-windows-arm64": "1.3.
|
|
31
|
-
"anymous-linux-arm64": "1.3.
|
|
32
|
-
"anymous-darwin-arm64": "1.3.
|
|
33
|
-
"anymous-windows-x64-baseline": "1.3.
|
|
34
|
-
"anymous-linux-x64-baseline-musl": "1.3.
|
|
35
|
-
"anymous-linux-x64-baseline": "1.3.
|
|
36
|
-
"anymous-windows-x64": "1.3.
|
|
37
|
-
"anymous-darwin-x64": "1.3.
|
|
38
|
-
"anymous-linux-x64-musl": "1.3.
|
|
27
|
+
"anymous-linux-arm64-musl": "1.3.3",
|
|
28
|
+
"anymous-linux-x64": "1.3.3",
|
|
29
|
+
"anymous-darwin-x64-baseline": "1.3.3",
|
|
30
|
+
"anymous-windows-arm64": "1.3.3",
|
|
31
|
+
"anymous-linux-arm64": "1.3.3",
|
|
32
|
+
"anymous-darwin-arm64": "1.3.3",
|
|
33
|
+
"anymous-windows-x64-baseline": "1.3.3",
|
|
34
|
+
"anymous-linux-x64-baseline-musl": "1.3.3",
|
|
35
|
+
"anymous-linux-x64-baseline": "1.3.3",
|
|
36
|
+
"anymous-windows-x64": "1.3.3",
|
|
37
|
+
"anymous-darwin-x64": "1.3.3",
|
|
38
|
+
"anymous-linux-x64-musl": "1.3.3"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import childProcess from "child_process"
|
|
4
|
-
import fs from "fs"
|
|
5
|
-
import os from "os"
|
|
6
|
-
import path from "path"
|
|
7
|
-
import { createRequire } from "module"
|
|
8
|
-
import { fileURLToPath } from "url"
|
|
9
|
-
|
|
10
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
-
const require = createRequire(import.meta.url)
|
|
12
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
|
|
13
|
-
|
|
14
|
-
const platformMap = {
|
|
15
|
-
darwin: "darwin",
|
|
16
|
-
linux: "linux",
|
|
17
|
-
win32: "windows",
|
|
18
|
-
}
|
|
19
|
-
const archMap = {
|
|
20
|
-
x64: "x64",
|
|
21
|
-
arm64: "arm64",
|
|
22
|
-
arm: "arm",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const platform = platformMap[os.platform()] ?? os.platform()
|
|
26
|
-
const arch = archMap[os.arch()] ?? os.arch()
|
|
27
|
-
const base = `anymous-${platform}-${arch}`
|
|
28
|
-
const sourceBinary = platform === "windows" ? "anymous.exe" : "anymous"
|
|
29
|
-
const targetBinary = path.join(__dirname, "bin", "anymous.exe")
|
|
30
|
-
|
|
31
|
-
function supportsAvx2() {
|
|
32
|
-
if (arch !== "x64") return false
|
|
33
|
-
|
|
34
|
-
if (platform === "linux") {
|
|
35
|
-
try {
|
|
36
|
-
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
37
|
-
} catch {
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (platform === "darwin") {
|
|
43
|
-
try {
|
|
44
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
45
|
-
encoding: "utf8",
|
|
46
|
-
timeout: 1500,
|
|
47
|
-
})
|
|
48
|
-
if (result.status !== 0) return false
|
|
49
|
-
return (result.stdout || "").trim() === "1"
|
|
50
|
-
} catch {
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (platform === "windows") {
|
|
56
|
-
const command =
|
|
57
|
-
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
58
|
-
|
|
59
|
-
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
60
|
-
try {
|
|
61
|
-
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
62
|
-
encoding: "utf8",
|
|
63
|
-
timeout: 3000,
|
|
64
|
-
windowsHide: true,
|
|
65
|
-
})
|
|
66
|
-
if (result.status !== 0) continue
|
|
67
|
-
const output = (result.stdout || "").trim().toLowerCase()
|
|
68
|
-
if (output === "true" || output === "1") return true
|
|
69
|
-
if (output === "false" || output === "0") return false
|
|
70
|
-
} catch {
|
|
71
|
-
continue
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function isMusl() {
|
|
80
|
-
if (platform !== "linux") return false
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
84
|
-
} catch {
|
|
85
|
-
// Ignore filesystem probes that are blocked by the host.
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
90
|
-
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
91
|
-
} catch {
|
|
92
|
-
return false
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function packageNames() {
|
|
97
|
-
const baseline = arch === "x64" && !supportsAvx2()
|
|
98
|
-
|
|
99
|
-
if (platform === "linux") {
|
|
100
|
-
if (isMusl()) {
|
|
101
|
-
if (arch === "x64")
|
|
102
|
-
return baseline
|
|
103
|
-
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
104
|
-
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
105
|
-
return [`${base}-musl`, base]
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (arch === "x64")
|
|
109
|
-
return baseline
|
|
110
|
-
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
111
|
-
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
112
|
-
return [base, `${base}-musl`]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
|
|
116
|
-
return [base]
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function resolveBinary(name) {
|
|
120
|
-
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
121
|
-
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
|
|
122
|
-
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
|
|
123
|
-
return binaryPath
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function installPackage(name) {
|
|
127
|
-
const version = packageJson.optionalDependencies?.[name]
|
|
128
|
-
if (!version) return
|
|
129
|
-
|
|
130
|
-
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "anymous-install-"))
|
|
131
|
-
try {
|
|
132
|
-
const result = childProcess.spawnSync(
|
|
133
|
-
"npm",
|
|
134
|
-
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
135
|
-
{ stdio: "inherit", windowsHide: true },
|
|
136
|
-
)
|
|
137
|
-
if (result.status !== 0) return
|
|
138
|
-
const packageDir = path.join(temp, "node_modules", name)
|
|
139
|
-
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
|
|
140
|
-
return true
|
|
141
|
-
} finally {
|
|
142
|
-
fs.rmSync(temp, { recursive: true, force: true })
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function copyBinary(source, target) {
|
|
147
|
-
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
148
|
-
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
149
|
-
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
150
|
-
try {
|
|
151
|
-
fs.linkSync(source, target)
|
|
152
|
-
} catch {
|
|
153
|
-
fs.copyFileSync(source, target)
|
|
154
|
-
}
|
|
155
|
-
fs.chmodSync(target, 0o755)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function verifyBinary() {
|
|
159
|
-
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
160
|
-
encoding: "utf8",
|
|
161
|
-
stdio: "ignore",
|
|
162
|
-
windowsHide: true,
|
|
163
|
-
})
|
|
164
|
-
return result.status === 0
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function copySkills() {
|
|
168
|
-
const source = path.join(path.dirname(__dirname), "skills")
|
|
169
|
-
if (!fs.existsSync(source)) return
|
|
170
|
-
|
|
171
|
-
const configRoot =
|
|
172
|
-
process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config")
|
|
173
|
-
const target = path.join(configRoot, "anymous", "skills")
|
|
174
|
-
fs.mkdirSync(target, { recursive: true })
|
|
175
|
-
for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
|
|
176
|
-
const s = path.join(source, entry.name)
|
|
177
|
-
const t = path.join(target, entry.name)
|
|
178
|
-
if (fs.existsSync(t)) fs.rmSync(t, { recursive: true, force: true })
|
|
179
|
-
fs.cpSync(s, t, { recursive: true })
|
|
180
|
-
}
|
|
181
|
-
return true
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function main() {
|
|
185
|
-
for (const name of packageNames()) {
|
|
186
|
-
try {
|
|
187
|
-
copyBinary(resolveBinary(name), targetBinary)
|
|
188
|
-
if (verifyBinary()) break
|
|
189
|
-
} catch {
|
|
190
|
-
if (installPackage(name) && verifyBinary()) break
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (!fs.existsSync(targetBinary)) {
|
|
195
|
-
throw new Error(
|
|
196
|
-
`It seems your package manager failed to install the right anymous CLI package. Try manually installing ${packageNames()
|
|
197
|
-
.map((name) => JSON.stringify(name))
|
|
198
|
-
.join(" or ")}.`,
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
copySkills()
|
|
204
|
-
} catch (error) {
|
|
205
|
-
console.error("anymous: could not install bundled skills:", error.message)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
main()
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error(error.message)
|
|
213
|
-
process.exit(1)
|
|
214
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import childProcess from "child_process"
|
|
4
|
+
import fs from "fs"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import path from "path"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
import { fileURLToPath } from "url"
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
|
|
13
|
+
|
|
14
|
+
const platformMap = {
|
|
15
|
+
darwin: "darwin",
|
|
16
|
+
linux: "linux",
|
|
17
|
+
win32: "windows",
|
|
18
|
+
}
|
|
19
|
+
const archMap = {
|
|
20
|
+
x64: "x64",
|
|
21
|
+
arm64: "arm64",
|
|
22
|
+
arm: "arm",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const platform = platformMap[os.platform()] ?? os.platform()
|
|
26
|
+
const arch = archMap[os.arch()] ?? os.arch()
|
|
27
|
+
const base = `anymous-${platform}-${arch}`
|
|
28
|
+
const sourceBinary = platform === "windows" ? "anymous.exe" : "anymous"
|
|
29
|
+
const targetBinary = path.join(__dirname, "bin", "anymous.exe")
|
|
30
|
+
|
|
31
|
+
function supportsAvx2() {
|
|
32
|
+
if (arch !== "x64") return false
|
|
33
|
+
|
|
34
|
+
if (platform === "linux") {
|
|
35
|
+
try {
|
|
36
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
37
|
+
} catch {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (platform === "darwin") {
|
|
43
|
+
try {
|
|
44
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
45
|
+
encoding: "utf8",
|
|
46
|
+
timeout: 1500,
|
|
47
|
+
})
|
|
48
|
+
if (result.status !== 0) return false
|
|
49
|
+
return (result.stdout || "").trim() === "1"
|
|
50
|
+
} catch {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (platform === "windows") {
|
|
56
|
+
const command =
|
|
57
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
58
|
+
|
|
59
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
60
|
+
try {
|
|
61
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
62
|
+
encoding: "utf8",
|
|
63
|
+
timeout: 3000,
|
|
64
|
+
windowsHide: true,
|
|
65
|
+
})
|
|
66
|
+
if (result.status !== 0) continue
|
|
67
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
68
|
+
if (output === "true" || output === "1") return true
|
|
69
|
+
if (output === "false" || output === "0") return false
|
|
70
|
+
} catch {
|
|
71
|
+
continue
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function isMusl() {
|
|
80
|
+
if (platform !== "linux") return false
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
84
|
+
} catch {
|
|
85
|
+
// Ignore filesystem probes that are blocked by the host.
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
90
|
+
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
91
|
+
} catch {
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function packageNames() {
|
|
97
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
98
|
+
|
|
99
|
+
if (platform === "linux") {
|
|
100
|
+
if (isMusl()) {
|
|
101
|
+
if (arch === "x64")
|
|
102
|
+
return baseline
|
|
103
|
+
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
104
|
+
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
105
|
+
return [`${base}-musl`, base]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (arch === "x64")
|
|
109
|
+
return baseline
|
|
110
|
+
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
111
|
+
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
112
|
+
return [base, `${base}-musl`]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
|
|
116
|
+
return [base]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function resolveBinary(name) {
|
|
120
|
+
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
121
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
|
|
122
|
+
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
|
|
123
|
+
return binaryPath
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function installPackage(name) {
|
|
127
|
+
const version = packageJson.optionalDependencies?.[name]
|
|
128
|
+
if (!version) return
|
|
129
|
+
|
|
130
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "anymous-install-"))
|
|
131
|
+
try {
|
|
132
|
+
const result = childProcess.spawnSync(
|
|
133
|
+
"npm",
|
|
134
|
+
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
135
|
+
{ stdio: "inherit", windowsHide: true },
|
|
136
|
+
)
|
|
137
|
+
if (result.status !== 0) return
|
|
138
|
+
const packageDir = path.join(temp, "node_modules", name)
|
|
139
|
+
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
|
|
140
|
+
return true
|
|
141
|
+
} finally {
|
|
142
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function copyBinary(source, target) {
|
|
147
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
148
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
149
|
+
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
150
|
+
try {
|
|
151
|
+
fs.linkSync(source, target)
|
|
152
|
+
} catch {
|
|
153
|
+
fs.copyFileSync(source, target)
|
|
154
|
+
}
|
|
155
|
+
fs.chmodSync(target, 0o755)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function verifyBinary() {
|
|
159
|
+
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
160
|
+
encoding: "utf8",
|
|
161
|
+
stdio: "ignore",
|
|
162
|
+
windowsHide: true,
|
|
163
|
+
})
|
|
164
|
+
return result.status === 0
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function copySkills() {
|
|
168
|
+
const source = path.join(path.dirname(__dirname), "skills")
|
|
169
|
+
if (!fs.existsSync(source)) return
|
|
170
|
+
|
|
171
|
+
const configRoot =
|
|
172
|
+
process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config")
|
|
173
|
+
const target = path.join(configRoot, "anymous", "skills")
|
|
174
|
+
fs.mkdirSync(target, { recursive: true })
|
|
175
|
+
for (const entry of fs.readdirSync(source, { withFileTypes: true })) {
|
|
176
|
+
const s = path.join(source, entry.name)
|
|
177
|
+
const t = path.join(target, entry.name)
|
|
178
|
+
if (fs.existsSync(t)) fs.rmSync(t, { recursive: true, force: true })
|
|
179
|
+
fs.cpSync(s, t, { recursive: true })
|
|
180
|
+
}
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function main() {
|
|
185
|
+
for (const name of packageNames()) {
|
|
186
|
+
try {
|
|
187
|
+
copyBinary(resolveBinary(name), targetBinary)
|
|
188
|
+
if (verifyBinary()) break
|
|
189
|
+
} catch {
|
|
190
|
+
if (installPackage(name) && verifyBinary()) break
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!fs.existsSync(targetBinary)) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`It seems your package manager failed to install the right anymous CLI package. Try manually installing ${packageNames()
|
|
197
|
+
.map((name) => JSON.stringify(name))
|
|
198
|
+
.join(" or ")}.`,
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
copySkills()
|
|
204
|
+
} catch (error) {
|
|
205
|
+
console.error("anymous: could not install bundled skills:", error.message)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
main()
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error(error.message)
|
|
213
|
+
process.exit(1)
|
|
214
|
+
}
|