@humanlayer/fold 0.0.1-rc.1
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/LICENSE +21 -0
- package/bin/foldcode.exe +2 -0
- package/package.json +45 -0
- package/postinstall.mjs +108 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HumanLayer
|
|
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.
|
package/bin/foldcode.exe
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@humanlayer/fold",
|
|
3
|
+
"version": "0.0.1-rc.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"preferUnplugged": true,
|
|
8
|
+
"bin": {
|
|
9
|
+
"foldcode": "bin/foldcode.exe"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
"postinstall.mjs"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postinstall": "node postinstall.mjs"
|
|
17
|
+
},
|
|
18
|
+
"description": "Effect-native, provider-agnostic agent loop and foldcode terminal application",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/humanlayer/fold.git",
|
|
22
|
+
"directory": "packages/fold"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/humanlayer/fold#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/humanlayer/fold/issues"
|
|
27
|
+
},
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@humanlayer/fold-linux-arm64": "0.0.1-rc.1",
|
|
30
|
+
"@humanlayer/fold-linux-x64": "0.0.1-rc.1",
|
|
31
|
+
"@humanlayer/fold-linux-x64-baseline": "0.0.1-rc.1",
|
|
32
|
+
"@humanlayer/fold-linux-arm64-musl": "0.0.1-rc.1",
|
|
33
|
+
"@humanlayer/fold-linux-x64-musl": "0.0.1-rc.1",
|
|
34
|
+
"@humanlayer/fold-linux-x64-baseline-musl": "0.0.1-rc.1",
|
|
35
|
+
"@humanlayer/fold-darwin-arm64": "0.0.1-rc.1",
|
|
36
|
+
"@humanlayer/fold-darwin-x64": "0.0.1-rc.1",
|
|
37
|
+
"@humanlayer/fold-darwin-x64-baseline": "0.0.1-rc.1",
|
|
38
|
+
"@humanlayer/fold-windows-arm64": "0.0.1-rc.1",
|
|
39
|
+
"@humanlayer/fold-windows-x64": "0.0.1-rc.1",
|
|
40
|
+
"@humanlayer/fold-windows-x64-baseline": "0.0.1-rc.1"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import childProcess from 'node:child_process'
|
|
3
|
+
import fs from 'node:fs'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import os from 'node:os'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
|
+
|
|
9
|
+
const dir = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))
|
|
12
|
+
if (manifest.private) process.exit(0)
|
|
13
|
+
const platform = os.platform() === 'win32' ? 'windows' : os.platform()
|
|
14
|
+
const arch = os.arch()
|
|
15
|
+
const base = `@humanlayer/fold-${platform}-${arch}`
|
|
16
|
+
const sourceName = platform === 'windows' ? 'foldcode.exe' : 'foldcode'
|
|
17
|
+
const target = path.join(dir, 'bin', 'foldcode.exe')
|
|
18
|
+
|
|
19
|
+
function supportsAvx2() {
|
|
20
|
+
if (arch !== 'x64') return false
|
|
21
|
+
try {
|
|
22
|
+
if (platform === 'linux') return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync('/proc/cpuinfo', 'utf8'))
|
|
23
|
+
if (platform === 'darwin') {
|
|
24
|
+
const result = childProcess.spawnSync('sysctl', ['-n', 'hw.optional.avx2_0'], {
|
|
25
|
+
encoding: 'utf8',
|
|
26
|
+
timeout: 2000,
|
|
27
|
+
})
|
|
28
|
+
return result.status === 0 && result.stdout.trim() === '1'
|
|
29
|
+
}
|
|
30
|
+
if (platform === 'windows') {
|
|
31
|
+
const command =
|
|
32
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
33
|
+
for (const executable of ['powershell.exe', 'pwsh.exe', 'pwsh', 'powershell']) {
|
|
34
|
+
const result = childProcess.spawnSync(
|
|
35
|
+
executable,
|
|
36
|
+
['-NoProfile', '-NonInteractive', '-Command', command],
|
|
37
|
+
{
|
|
38
|
+
encoding: 'utf8',
|
|
39
|
+
timeout: 3000,
|
|
40
|
+
windowsHide: true,
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
if (result.status !== 0) continue
|
|
44
|
+
const output = result.stdout.trim().toLowerCase()
|
|
45
|
+
if (output === 'true' || output === '1') return true
|
|
46
|
+
if (output === 'false' || output === '0') return false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false
|
|
50
|
+
} catch {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isMusl() {
|
|
56
|
+
if (platform !== 'linux') return false
|
|
57
|
+
if (fs.existsSync('/etc/alpine-release')) return true
|
|
58
|
+
const result = childProcess.spawnSync('ldd', ['--version'], { encoding: 'utf8' })
|
|
59
|
+
return `${result.stdout || ''}${result.stderr || ''}`.toLowerCase().includes('musl')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function candidates() {
|
|
63
|
+
if (arch !== 'x64') return [base]
|
|
64
|
+
const cpuVariants = supportsAvx2() ? ['', '-baseline'] : ['-baseline', '']
|
|
65
|
+
if (platform === 'linux' && isMusl()) return cpuVariants.map((variant) => `${base}${variant}-musl`)
|
|
66
|
+
return cpuVariants.map((variant) => `${base}${variant}`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function copy(source) {
|
|
70
|
+
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
71
|
+
fs.rmSync(target, { force: true })
|
|
72
|
+
try {
|
|
73
|
+
fs.linkSync(source, target)
|
|
74
|
+
} catch {
|
|
75
|
+
fs.copyFileSync(source, target)
|
|
76
|
+
}
|
|
77
|
+
fs.chmodSync(target, 0o755)
|
|
78
|
+
const verification = childProcess.spawnSync(target, ['--version'], { encoding: 'utf8', windowsHide: true })
|
|
79
|
+
if (verification.status !== 0) throw new Error(`Installed binary failed verification: ${verification.stderr}`)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function recover(name) {
|
|
83
|
+
const version = manifest.optionalDependencies?.[name]
|
|
84
|
+
if (!version) return false
|
|
85
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'fold-install-'))
|
|
86
|
+
try {
|
|
87
|
+
const result = childProcess.spawnSync(
|
|
88
|
+
'npm',
|
|
89
|
+
['install', '--ignore-scripts', '--no-save', '--loglevel=error', '--prefix', temp, `${name}@${version}`],
|
|
90
|
+
{ stdio: 'inherit', windowsHide: true },
|
|
91
|
+
)
|
|
92
|
+
if (result.status !== 0) return false
|
|
93
|
+
copy(path.join(temp, 'node_modules', ...name.split('/'), 'bin', sourceName))
|
|
94
|
+
return true
|
|
95
|
+
} finally {
|
|
96
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (const name of candidates()) {
|
|
101
|
+
try {
|
|
102
|
+
copy(path.join(path.dirname(require.resolve(`${name}/package.json`)), 'bin', sourceName))
|
|
103
|
+
process.exit(0)
|
|
104
|
+
} catch {
|
|
105
|
+
if (recover(name)) process.exit(0)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`No compatible foldcode binary found for ${platform}-${arch}`)
|