@leo-luxy/floe 0.0.0-stage → 2.0.0

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 CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # Floe (`@leo-luxy/floe`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Floe** is a cross-platform quantitative stock screener, trend-following backtester, and AI investment research workbench for macOS, Windows, and Linux.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g @leo-luxy/floe
10
+
11
+ # Launch native desktop window
12
+ floe
13
+
14
+ # Or launch in your default web browser
15
+ floe --web
16
+
17
+ # Run environment diagnostics
18
+ floe --doctor
19
+ ```
20
+
21
+ > Tip (Mainland China network): If downloading the prebuilt runtime from GitHub Releases is slow on first launch, pass a mirror prefix:
22
+ > ```bash
23
+ > FLOE_GITHUB_MIRROR=https://ghfast.top/ floe
24
+ > ```
package/bin/floe.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Floe跨平台命令行启动器 (macOS / Windows / Linux)
4
+ * 首次运行时自动按当前操作系统与架构拉取 GitHub Release 预编译二进制包并缓存至本机,
5
+ * 后续运行零等待秒开原生桌面窗口(或传 --web 启动浏览器模式)。
6
+ */
7
+ 'use strict';
8
+
9
+ const { spawn } = require('child_process');
10
+ const { ensureBinaryInstalled } = require('../lib/installer');
11
+
12
+ async function main() {
13
+ const userArgs = process.argv.slice(2);
14
+ const pkg = require('../package.json');
15
+
16
+ if (userArgs.includes('--npm-version')) {
17
+ console.log(`Floe npm launcher v${pkg.version}`);
18
+ process.exit(0);
19
+ }
20
+
21
+ try {
22
+ const exePath = await ensureBinaryInstalled(pkg.version);
23
+ const env = Object.assign({}, process.env, {
24
+ FLOE_INSTALL_CHANNEL: 'npm',
25
+ FLOE_NPM_WRAPPER: '1',
26
+ });
27
+
28
+ const child = spawn(exePath, userArgs, {
29
+ stdio: 'inherit',
30
+ env,
31
+ });
32
+
33
+ child.on('exit', (code) => {
34
+ process.exit(code === null ? 0 : code);
35
+ });
36
+ } catch (err) {
37
+ console.error(`\n[Floe] 启动或下载预编译运行包失败: ${err.message}`);
38
+ console.error('提示:若国内网络直连 GitHub Release 较慢,可设置镜像前缀重试:');
39
+ console.error(' FLOE_GITHUB_MIRROR=https://ghfast.top/ floe\n');
40
+ process.exit(1);
41
+ }
42
+ }
43
+
44
+ main();
@@ -0,0 +1,137 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+ const https = require('https');
7
+ const http = require('http');
8
+ const { execFileSync } = require('child_process');
9
+
10
+ const GITHUB_REPO = 'Leo-luxy/Floe';
11
+
12
+ function resolvePlatformAsset(version) {
13
+ const plat = process.platform;
14
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
15
+
16
+ if (plat === 'darwin') {
17
+ return {
18
+ archiveName: `Floe-v${version}-macos-${arch}.tar.gz`,
19
+ exeRelPath: path.join('Floe', 'floe'),
20
+ isZip: false,
21
+ };
22
+ }
23
+ if (plat === 'win32') {
24
+ return {
25
+ archiveName: `Floe-v${version}-windows-x64.zip`,
26
+ exeRelPath: path.join('Floe', 'Floe.exe'),
27
+ isZip: true,
28
+ };
29
+ }
30
+ if (plat === 'linux') {
31
+ return {
32
+ archiveName: `Floe-v${version}-linux-x64.tar.gz`,
33
+ exeRelPath: path.join('Floe', 'floe'),
34
+ isZip: false,
35
+ };
36
+ }
37
+ throw new Error(`Unsupported OS platform: ${plat}-${arch}`);
38
+ }
39
+
40
+ function getCacheRoot(version) {
41
+ const home = os.homedir();
42
+ if (process.platform === 'darwin') {
43
+ return path.join(home, 'Library', 'Caches', 'Floe', `v${version}`);
44
+ }
45
+ if (process.platform === 'win32') {
46
+ const localAppData = process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local');
47
+ return path.join(localAppData, 'Floe', 'Cache', `v${version}`);
48
+ }
49
+ const xdgCache = process.env.XDG_CACHE_HOME || path.join(home, '.cache');
50
+ return path.join(xdgCache, 'floe', `v${version}`);
51
+ }
52
+
53
+ function downloadFile(url, destPath, redirectsLeft = 6) {
54
+ return new Promise((resolve, reject) => {
55
+ if (redirectsLeft <= 0) {
56
+ return reject(new Error('Too many HTTP redirects'));
57
+ }
58
+ const client = url.startsWith('https:') ? https : http;
59
+ const req = client.get(url, { headers: { 'User-Agent': 'Floe-NPM-Installer/2.0' } }, (res) => {
60
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
61
+ res.resume();
62
+ const nextUrl = new URL(res.headers.location, url).toString();
63
+ return resolve(downloadFile(nextUrl, destPath, redirectsLeft - 1));
64
+ }
65
+ if (res.statusCode !== 200) {
66
+ res.resume();
67
+ return reject(new Error(`HTTP ${res.statusCode} when fetching ${url}`));
68
+ }
69
+ const total = parseInt(res.headers['content-length'] || '0', 10);
70
+ let downloaded = 0;
71
+ let lastPct = -1;
72
+ const out = fs.createWriteStream(destPath);
73
+ res.on('data', (chunk) => {
74
+ downloaded += chunk.length;
75
+ if (total > 0) {
76
+ const pct = Math.floor((downloaded / total) * 100);
77
+ if (pct >= lastPct + 10) {
78
+ lastPct = pct;
79
+ process.stdout.write(`\r[Floe] Downloading runtime package... ${pct}%`);
80
+ }
81
+ }
82
+ });
83
+ res.pipe(out);
84
+ out.on('finish', () => {
85
+ out.close(() => {
86
+ if (total > 0) process.stdout.write('\n');
87
+ resolve();
88
+ });
89
+ });
90
+ out.on('error', reject);
91
+ });
92
+ req.on('error', reject);
93
+ });
94
+ }
95
+
96
+ async function ensureBinaryInstalled(version) {
97
+ const spec = resolvePlatformAsset(version);
98
+ const cacheDir = getCacheRoot(version);
99
+ const exePath = path.join(cacheDir, spec.exeRelPath);
100
+
101
+ if (fs.existsSync(exePath)) {
102
+ return exePath;
103
+ }
104
+
105
+ fs.mkdirSync(cacheDir, { recursive: true });
106
+ const rawUrl = `https://github.com/${GITHUB_REPO}/releases/download/v${version}/${spec.archiveName}`;
107
+ const mirrorPrefix = (process.env.FLOE_GITHUB_MIRROR || '').trim();
108
+ const downloadUrl = mirrorPrefix ? `${mirrorPrefix.replace(/\/?$/, '/')}${rawUrl}` : rawUrl;
109
+
110
+ const tmpArchive = path.join(cacheDir, spec.archiveName);
111
+ console.log(`[Floe] First-run setup: fetching ${spec.archiveName}...`);
112
+ await downloadFile(downloadUrl, tmpArchive);
113
+
114
+ console.log('[Floe] Extracting runtime bundle...');
115
+ if (spec.isZip) {
116
+ // Windows 10/11 内置 tar 或 PowerShell Expand-Archive
117
+ execFileSync('powershell', [
118
+ '-NoProfile',
119
+ '-Command',
120
+ `Expand-Archive -LiteralPath '${tmpArchive}' -DestinationPath '${cacheDir}' -Force`,
121
+ ], { stdio: 'inherit' });
122
+ } else {
123
+ execFileSync('tar', ['-xzf', tmpArchive, '-C', cacheDir], { stdio: 'inherit' });
124
+ fs.chmodSync(exePath, 0o755);
125
+ }
126
+
127
+ try {
128
+ fs.unlinkSync(tmpArchive);
129
+ } catch (_) {}
130
+
131
+ if (!fs.existsSync(exePath)) {
132
+ throw new Error(`Extracted archive did not contain expected binary: ${exePath}`);
133
+ }
134
+ return exePath;
135
+ }
136
+
137
+ module.exports = { ensureBinaryInstalled, resolvePlatformAsset };
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@leo-luxy/floe",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "Floe — Cross-platform quantitative stock screener, trend backtester, and AI research workbench (macOS / Windows / Linux)",
5
+ "keywords": [
6
+ "quant",
7
+ "stock",
8
+ "backtest",
9
+ "a-share",
10
+ "ai-research",
11
+ "floe"
12
+ ],
13
+ "homepage": "https://github.com/Leo-luxy/Floe",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/Leo-luxy/Floe.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Leo-luxy",
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
23
+ "bin": {
24
+ "floe": "bin/floe.js"
25
+ },
26
+ "files": [
27
+ "bin/",
28
+ "lib/",
29
+ "README.md"
30
+ ],
31
+ "os": [
32
+ "darwin",
33
+ "win32",
34
+ "linux"
35
+ ],
36
+ "cpu": [
37
+ "x64",
38
+ "arm64"
39
+ ]
40
+ }