-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrift.rb
More file actions
98 lines (84 loc) · 3.79 KB
/
Copy pathrift.rb
File metadata and controls
98 lines (84 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Homebrew formula for RIFT.
#
# This file lives at: Formula/rift.rb in the Nexstone/homebrew-tap repo.
# Users install via: brew install Nexstone/tap/rift
#
# IMPORTANT — this is the source-of-truth copy. The tap repo's copy must
# stay in sync. The release workflow auto-bumps the `version`, `url`, and
# `sha256` on every tag.
class Rift < Formula
desc "Quant trading infrastructure for Hyperliquid (CLI + research + MCP server)"
homepage "https://nexstone.io"
# ── Versioned source — bumped automatically by .github/workflows/release.yml
url "https://github.com/Nexstone/rift/archive/refs/tags/v0.1.3.tar.gz"
sha256 "166d9cf7a49bb3e51eb1b2a10529c4c8e2a5a1c25dbc23bca8c2a0109f21dda0"
license "Apache-2.0"
# ── Runtime dependencies
depends_on "node@20"
depends_on "python@3.13"
def install
# Pin the Python interpreter so the venv we create points at the same
# python brew installed (not whatever 3.x happens to be first on PATH).
python_bin = Formula["python@3.13"].opt_bin/"python3.13"
npm_bin = Formula["node@20"].opt_bin/"npm"
# ── 1. Python engine: create an isolated venv inside libexec and
# install rift-engine-core, the consolidated distribution that
# bundles all 10 internal namespace packages.
venv = libexec/"python-venv"
system python_bin, "-m", "venv", venv
system venv/"bin/python", "-m", "pip", "install", "--upgrade", "pip", "wheel"
system venv/"bin/python", "-m", "pip", "install", "rift-engine-core==#{version}"
# ── 2. TS CLI: install globally into libexec so we don't pollute the
# user's global npm directory.
npm_prefix = libexec/"npm"
npm_prefix.mkpath
ENV["NPM_CONFIG_PREFIX"] = npm_prefix
system npm_bin, "install", "-g", "@nexstone/rift-cli@#{version}"
# ── 3. Wrapper script that runs the CLI with the engine's venv on PATH.
# The TS CLI auto-detects `rift-engine` on PATH; setting
# RIFT_ENGINE_BINARY explicitly pins it to the libexec venv even if
# a stray rift-engine is installed elsewhere on the user's system.
(bin/"rift").write <<~SHELL
#!/usr/bin/env bash
# Auto-generated by Homebrew. Do not edit by hand.
export PATH="#{venv}/bin:#{Formula["node@20"].opt_bin}:$PATH"
export RIFT_ENGINE_BINARY="#{venv}/bin/rift-engine"
exec "#{npm_prefix}/bin/rift" "$@"
SHELL
chmod 0755, bin/"rift"
end
def post_install
# Make sure ~/.rift exists so the user doesn't trip on `rift auth setup`
# creating it with the wrong permissions.
rift_home = Pathname.new(Dir.home)/".rift"
rift_home.mkpath
rift_home.chmod(0700)
end
def caveats
<<~EOS
RIFT installed. Next steps:
1. Verify the install:
rift doctor
2. Configure secrets (only needed for `rift sync` + live trading):
cp #{etc}/rift/env.example ~/.rift/.env
$EDITOR ~/.rift/.env
chmod 600 ~/.rift/.env
3. Set up a wallet for live trading (when ready):
rift auth setup
4. Read before trading real money:
https://github.com/Nexstone/rift/blob/main/KNOWN_ISSUES.md
https://github.com/Nexstone/rift/blob/main/docs/AUTH_AND_EXECUTION.md
RIFT is software, not financial advice. Trading perpetual futures
can result in total loss of capital. The shipped `trend_follow`
strategy is explicitly demo-only.
EOS
end
test do
# Sanity smoke — `rift --version` should print the version we installed.
assert_match version.to_s, shell_output("#{bin}/rift --version")
# Doctor exits non-zero only on hard failures (missing deps, broken Python).
# We don't assert exit 0 here because doctor warns on "no wallet configured"
# which is the expected post-install state.
system bin/"rift", "doctor"
end
end