@xfcodeai/xfdsh 0.1.2-alpha.5

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/bin/xfdsh.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ // xfdsh 命令入口:把参数转发给产物内的 dsh 入口。
3
+ import { spawnSync } from 'node:child_process'
4
+ import { existsSync } from 'node:fs'
5
+ import { dirname, join, resolve } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+
8
+ const here = dirname(fileURLToPath(import.meta.url))
9
+ const pkgRoot = resolve(here, '..')
10
+ const entry = join(pkgRoot, 'vendor', 'node_modules', '@xfcodeai', 'dsh', 'lib', 'bin.js')
11
+
12
+ if (!existsSync(entry)) {
13
+ console.error('xfdsh: 产物未就绪,请重新安装本包(npm rebuild @xfcodeai/xfdsh)')
14
+ process.exit(1)
15
+ }
16
+ const result = spawnSync(process.execPath, [entry, ...process.argv.slice(2)], { stdio: 'inherit' })
17
+ process.exit(result.status ?? 1)
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@xfcodeai/xfdsh",
3
+ "version": "0.1.2-alpha.5",
4
+ "description": "xfdsh launcher: 下载并运行预构建的 DeepSeek Harness fork 产物",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "xfdsh": "bin/xfdsh.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "scripts"
13
+ ],
14
+ "scripts": {
15
+ "postinstall": "node scripts/install.js"
16
+ },
17
+ "engines": {
18
+ "node": ">=20"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/LunFengChen/deepseek-harness.git"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }
@@ -0,0 +1,90 @@
1
+ // xfdsh launcher 安装脚本:按平台从 GitHub Releases 下载预构建产物并解压。
2
+ // 下载源可用 XFDSH_DIST_URL 覆盖(测试用),XFDSH_REPO / XFDSH_VERSION 可覆盖仓库与版本。
3
+ import { spawnSync } from 'node:child_process'
4
+ import { createWriteStream, mkdirSync } from 'node:fs'
5
+ import { rm, writeFile } from 'node:fs/promises'
6
+ import { dirname, join, resolve } from 'node:path'
7
+ import { fileURLToPath } from 'node:url'
8
+ import { pipeline } from 'node:stream/promises'
9
+ import { Readable } from 'node:stream'
10
+
11
+ const here = dirname(fileURLToPath(import.meta.url))
12
+ const pkgRoot = resolve(here, '..')
13
+ const VERSION = process.env.XFDSH_VERSION || '0.1.2-alpha.5'
14
+ const REPO = process.env.XFDSH_REPO || 'LunFengChen/deepseek-harness'
15
+ const TAG = `dsh-v${VERSION}`
16
+
17
+ function detectTarget() {
18
+ const key = `${process.platform}-${process.arch}`
19
+ const map = {
20
+ 'darwin-arm64': ['macos', 'arm64'],
21
+ 'darwin-x64': ['macos', 'x64'],
22
+ 'linux-x64': ['linux', 'x64'],
23
+ 'linux-arm64': ['linux', 'arm64'],
24
+ 'win32-x64': ['windows', 'x64'],
25
+ }
26
+ const t = map[key]
27
+ if (!t) throw new Error(`xfdsh: 暂不支持的平台 ${key}(支持 macos arm64/x64、linux x64/arm64、windows x64)`)
28
+ return { platform: t[0], arch: t[1] }
29
+ }
30
+
31
+ async function download(url, dest) {
32
+ console.log(`xfdsh: 下载 ${url}`)
33
+ if (url.startsWith('file://')) {
34
+ // 本地文件(测试/离线用)
35
+ const fs = await import('node:fs')
36
+ fs.copyFileSync(new URL(url), dest)
37
+ return
38
+ }
39
+ const res = await fetch(url, { redirect: 'follow' })
40
+ if (!res.ok) throw new Error(`xfdsh: 下载失败 HTTP ${res.status} (${url})`)
41
+ await pipeline(Readable.fromWeb(res.body), createWriteStream(dest))
42
+ }
43
+
44
+ function extract(archive, destDir) {
45
+ mkdirSync(destDir, { recursive: true })
46
+ let r
47
+ if (archive.endsWith('.zip')) {
48
+ r = spawnSync('unzip', ['-q', '-o', archive, '-d', destDir], { stdio: 'inherit' })
49
+ if (r.status !== 0) r = spawnSync('tar', ['-xf', archive, '-C', destDir], { stdio: 'inherit' })
50
+ } else {
51
+ r = spawnSync('tar', ['-xzf', archive, '-C', destDir], { stdio: 'inherit' })
52
+ }
53
+ if (r.status !== 0) throw new Error(`xfdsh: 解压失败 (${archive})`)
54
+ }
55
+
56
+ async function main() {
57
+ const target = detectTarget()
58
+ const ext = target.platform === 'windows' ? 'zip' : 'tar.gz'
59
+ const asset = `xfdsh-${target.platform}-${target.arch}-${VERSION}.${ext}`
60
+ const vendorDir = join(pkgRoot, 'vendor')
61
+ const marker = join(vendorDir, '.xfdsh-ready')
62
+ const stamp = `${target.platform}-${target.arch}-${VERSION}`
63
+
64
+ // 幂等:产物已就绪且版本一致则跳过
65
+ const fs = await import('node:fs')
66
+ if (fs.existsSync(marker) && fs.readFileSync(marker, 'utf8') === stamp) {
67
+ console.log(`xfdsh: 产物已就绪 (${stamp})`)
68
+ return
69
+ }
70
+
71
+ const url = process.env.XFDSH_DIST_URL
72
+ ? process.env.XFDSH_DIST_URL.replaceAll('{{asset}}', asset)
73
+ : `https://github.com/${REPO}/releases/download/${TAG}/${asset}`
74
+
75
+ // 清空旧产物
76
+ await rm(vendorDir, { recursive: true, force: true })
77
+ mkdirSync(vendorDir, { recursive: true })
78
+
79
+ const archive = join(vendorDir, asset)
80
+ await download(url, archive)
81
+ extract(archive, vendorDir)
82
+ await rm(archive, { force: true })
83
+ await writeFile(marker, stamp)
84
+ console.log(`xfdsh: 产物就绪 (${stamp})`)
85
+ }
86
+
87
+ main().catch(err => {
88
+ console.error(`xfdsh: 安装失败: ${err.message}`)
89
+ process.exit(1)
90
+ })