hood-cli 0.1.0 → 0.2.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/LICENSE +15 -196
- package/README.md +24 -1
- package/dist/cli.js +160 -4
- package/dist/cli.js.map +1 -1
- package/package.json +67 -67
package/LICENSE
CHANGED
|
@@ -1,201 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
1
|
+
Copyright 2026 nirholas
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
All rights reserved.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
This software is proprietary and may not be used, copied, modified, distributed,
|
|
6
|
+
translated, or made available to any third party without the express written
|
|
7
|
+
permission of the copyright owner.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
No rights are granted by implication, estoppel, or otherwise. Use of this
|
|
10
|
+
software is subject to the terms of a separate license agreement with the
|
|
11
|
+
copyright owner.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the
|
|
44
|
-
purposes of this License, Derivative Works shall not include works
|
|
45
|
-
that remain separable from, or merely link (or bind by name) to the
|
|
46
|
-
interfaces of, the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including the
|
|
49
|
-
original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2026 nirholas
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
17
|
+
IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY CLAIM, DAMAGES, OR
|
|
18
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE,
|
|
19
|
+
ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -351,6 +351,29 @@ AES-256-GCM keystore (scrypt KDF, Node's built-in `crypto` — the same primitiv
|
|
|
351
351
|
Web3 Secret Storage spec) to `~/.config/hood/keystore.json`. The private key never touches the
|
|
352
352
|
config file or plaintext disk.
|
|
353
353
|
|
|
354
|
+
### `hood init`
|
|
355
|
+
|
|
356
|
+
The one-command onboarding wizard for the whole trading stack: this CLI's wallet, the
|
|
357
|
+
[`hood-traders`](https://github.com/nirholas/hood-traders) `llm-strategist` (bring your own key —
|
|
358
|
+
Claude, OpenAI, Groq, or OpenRouter), and the [`hood-alerts`](https://github.com/nirholas/hood-alerts)
|
|
359
|
+
Telegram bot / Discord bot / X (Twitter) auto-posting. Every step is optional — skip anything you
|
|
360
|
+
don't need with `n` or Enter.
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
hood init
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
It writes `hood-traders.env` and `hood-alerts.env` into the current directory (`--out <dir>` to
|
|
367
|
+
choose another). Copy each into the matching package as `.env` and run it:
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
cp hood-traders.env hood-traders/.env && cd hood-traders && npx hood-traders
|
|
371
|
+
cp hood-alerts.env hood-alerts/.env && cd hood-alerts && npx hood-alerts
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Needs an interactive terminal (secrets are typed, not passed as flags) — in CI or a non-interactive
|
|
375
|
+
shell, copy `hood-traders/.env.example` and `hood-alerts/.env.example` by hand instead.
|
|
376
|
+
|
|
354
377
|
## Wallet & signing
|
|
355
378
|
|
|
356
379
|
Every write command (`swap --execute`, `transfer`, `deploy-token --execute`, `config set
|
|
@@ -464,7 +487,7 @@ npm publish --access public
|
|
|
464
487
|
|
|
465
488
|
## License
|
|
466
489
|
|
|
467
|
-
|
|
490
|
+
All rights reserved. See [LICENSE](./LICENSE).
|
|
468
491
|
|
|
469
492
|
---
|
|
470
493
|
|
package/dist/cli.js
CHANGED
|
@@ -31,10 +31,10 @@ import {
|
|
|
31
31
|
} from "./chunk-CWEBZB3L.js";
|
|
32
32
|
|
|
33
33
|
// src/program.ts
|
|
34
|
-
import { Command as
|
|
34
|
+
import { Command as Command15 } from "commander";
|
|
35
35
|
import { readFileSync as readFileSync4 } from "fs";
|
|
36
36
|
import { fileURLToPath } from "url";
|
|
37
|
-
import { dirname as dirname3, join as
|
|
37
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
38
38
|
|
|
39
39
|
// src/commands/price.ts
|
|
40
40
|
import { Command } from "commander";
|
|
@@ -320,6 +320,23 @@ async function confirm(question) {
|
|
|
320
320
|
rl.close();
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
+
async function promptLine(question, envVar, fallback = "") {
|
|
324
|
+
const fromEnv = envVar ? process.env[envVar] : void 0;
|
|
325
|
+
if (fromEnv) return fromEnv;
|
|
326
|
+
if (!canPrompt()) {
|
|
327
|
+
throw guardError("An interactive answer is required.", envVar ? `Set ${envVar} or run in an interactive terminal.` : "Run in an interactive terminal.");
|
|
328
|
+
}
|
|
329
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
330
|
+
try {
|
|
331
|
+
const answer = await new Promise((resolve2) => {
|
|
332
|
+
rl.question(`${yellow("?")} ${bold(question)} `, resolve2);
|
|
333
|
+
});
|
|
334
|
+
const trimmed = answer.trim();
|
|
335
|
+
return trimmed.length > 0 ? trimmed : fallback;
|
|
336
|
+
} finally {
|
|
337
|
+
rl.close();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
323
340
|
async function readPassword(label = "Wallet password:", envVar = "HOOD_WALLET_PASSWORD") {
|
|
324
341
|
const fromEnv = process.env[envVar];
|
|
325
342
|
if (fromEnv) return fromEnv;
|
|
@@ -438,6 +455,9 @@ function printResult(json, human, asJson) {
|
|
|
438
455
|
if (asJson) printJson(json);
|
|
439
456
|
else printHuman(human());
|
|
440
457
|
}
|
|
458
|
+
function note(message) {
|
|
459
|
+
process.stderr.write(dim(message) + "\n");
|
|
460
|
+
}
|
|
441
461
|
function warn(message) {
|
|
442
462
|
process.stderr.write(yellow("! " + message) + "\n");
|
|
443
463
|
}
|
|
@@ -1947,14 +1967,149 @@ ${dim(" This is a NEW address \u2014 fund it before sending anything.")}`)
|
|
|
1947
1967
|
);
|
|
1948
1968
|
}
|
|
1949
1969
|
|
|
1970
|
+
// src/commands/init.ts
|
|
1971
|
+
import { existsSync as existsSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
1972
|
+
import { join as join2 } from "path";
|
|
1973
|
+
import { Command as Command14 } from "commander";
|
|
1974
|
+
var LLM_PROVIDERS = ["anthropic", "openai", "groq", "openrouter"];
|
|
1975
|
+
function buildEnvFiles(answers) {
|
|
1976
|
+
const traderLines = [
|
|
1977
|
+
"# Generated by `hood init` \u2014 see hood-traders/.env.example for every option.",
|
|
1978
|
+
"HOOD_NETWORK=mainnet",
|
|
1979
|
+
"HOOD_TRADERS_LIVE=0 # flip to 1 (and set ROBINHOOD_CHAIN_PRIVATE_KEY) only when you are ready to trade real funds"
|
|
1980
|
+
];
|
|
1981
|
+
if (answers.llmProvider && answers.llmApiKey) {
|
|
1982
|
+
traderLines.push("", "# llm-strategist", `HOOD_LLM_PROVIDER=${answers.llmProvider}`, `HOOD_LLM_API_KEY=${answers.llmApiKey}`);
|
|
1983
|
+
}
|
|
1984
|
+
const alertsLines = ["# Generated by `hood init` \u2014 see hood-alerts/.env.example for every option."];
|
|
1985
|
+
if (answers.telegramToken) {
|
|
1986
|
+
alertsLines.push("", "# Telegram", `HOOD_ALERTS_TELEGRAM_TOKEN=${answers.telegramToken}`);
|
|
1987
|
+
}
|
|
1988
|
+
if (answers.discordToken) {
|
|
1989
|
+
alertsLines.push("", "# Discord", `HOOD_ALERTS_DISCORD_TOKEN=${answers.discordToken}`, `HOOD_ALERTS_DISCORD_APP_ID=${answers.discordAppId ?? ""}`);
|
|
1990
|
+
}
|
|
1991
|
+
if (answers.xMode) {
|
|
1992
|
+
alertsLines.push("", "# X (Twitter)", `HOOD_ALERTS_X_MODE=${answers.xMode}`);
|
|
1993
|
+
if (answers.xMode === "official") {
|
|
1994
|
+
alertsLines.push(
|
|
1995
|
+
`HOOD_ALERTS_X_API_KEY=${answers.xApiKey ?? ""}`,
|
|
1996
|
+
`HOOD_ALERTS_X_API_SECRET=${answers.xApiSecret ?? ""}`,
|
|
1997
|
+
`HOOD_ALERTS_X_ACCESS_TOKEN=${answers.xAccessToken ?? ""}`,
|
|
1998
|
+
`HOOD_ALERTS_X_ACCESS_SECRET=${answers.xAccessSecret ?? ""}`
|
|
1999
|
+
);
|
|
2000
|
+
} else {
|
|
2001
|
+
alertsLines.push(`HOOD_ALERTS_XACTIONS_URL=${answers.xactionsUrl ?? ""}`, `HOOD_ALERTS_XACTIONS_TOKEN=${answers.xactionsToken ?? ""}`);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
return { traderEnv: traderLines.join("\n") + "\n", alertsEnv: alertsLines.join("\n") + "\n" };
|
|
2005
|
+
}
|
|
2006
|
+
function initCommand() {
|
|
2007
|
+
const cmd = new Command14("init").description("interactive setup wizard: wallet, LLM key (hood-traders), and Telegram/X (hood-alerts)").option("--out <dir>", "directory to write hood-traders.env / hood-alerts.env into", ".").action(async (opts, _command, command) => {
|
|
2008
|
+
const json = !!command?.optsWithGlobals?.().json;
|
|
2009
|
+
const assumeYes = !!command?.optsWithGlobals?.().yes;
|
|
2010
|
+
await runInit(opts.out, json, assumeYes);
|
|
2011
|
+
});
|
|
2012
|
+
return cmd;
|
|
2013
|
+
}
|
|
2014
|
+
async function runInit(outDir, json, assumeYes) {
|
|
2015
|
+
if (!canPrompt()) {
|
|
2016
|
+
throw guardError(
|
|
2017
|
+
"hood init needs an interactive terminal.",
|
|
2018
|
+
"Copy hood-traders/.env.example and hood-alerts/.env.example by hand instead, or re-run in a real TTY."
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
printHuman(`${accent("\u25C8")} ${bold("hood init")} \u2014 set up the Robinhood Chain trading stack
|
|
2022
|
+
${dim(`Every step below is optional; press Enter (or answer "n") to skip anything you don't need yet.`)}
|
|
2023
|
+
`);
|
|
2024
|
+
const answers = {};
|
|
2025
|
+
const existing = loadConfig();
|
|
2026
|
+
if (existing.walletAddress) {
|
|
2027
|
+
note(`Wallet already configured: ${existing.walletAddress}`);
|
|
2028
|
+
answers.walletAddress = existing.walletAddress;
|
|
2029
|
+
} else if (await confirm("Set up a local wallet now? (needed only for LIVE trading \u2014 skip to stay read-only/paper mode)")) {
|
|
2030
|
+
await setWallet(false, assumeYes);
|
|
2031
|
+
answers.walletAddress = loadConfig().walletAddress;
|
|
2032
|
+
}
|
|
2033
|
+
if (await confirm("Configure the llm-strategist for hood-traders? (bring your own key \u2014 Claude, OpenAI, Groq, or OpenRouter)")) {
|
|
2034
|
+
const providerAnswer = (await promptLine("Which provider \u2014 anthropic / openai / groq / openrouter?", void 0, "anthropic")).toLowerCase();
|
|
2035
|
+
if (!LLM_PROVIDERS.includes(providerAnswer)) {
|
|
2036
|
+
throw guardError(`"${providerAnswer}" is not one of: ${LLM_PROVIDERS.join(", ")}.`);
|
|
2037
|
+
}
|
|
2038
|
+
answers.llmProvider = providerAnswer;
|
|
2039
|
+
answers.llmApiKey = await readPassword(`${answers.llmProvider} API key:`, "HOOD_LLM_API_KEY");
|
|
2040
|
+
}
|
|
2041
|
+
if (await confirm("Set up the hood-alerts Telegram bot? (real-time launch/whale/premium feed)")) {
|
|
2042
|
+
note("Message @BotFather on Telegram, run /newbot, then paste the token below.");
|
|
2043
|
+
answers.telegramToken = await readPassword("Telegram bot token:", "HOOD_ALERTS_TELEGRAM_TOKEN");
|
|
2044
|
+
}
|
|
2045
|
+
if (await confirm("Set up the hood-alerts Discord bot too?")) {
|
|
2046
|
+
note("Create an app + bot at https://discord.com/developers/applications.");
|
|
2047
|
+
answers.discordToken = await readPassword("Discord bot token:", "HOOD_ALERTS_DISCORD_TOKEN");
|
|
2048
|
+
answers.discordAppId = await promptLine("Discord application id:", "HOOD_ALERTS_DISCORD_APP_ID");
|
|
2049
|
+
}
|
|
2050
|
+
if (await confirm("Set up X (Twitter) auto-posting for hood-alerts?")) {
|
|
2051
|
+
const mode = (await promptLine('Mode \u2014 "official" (X API v2, needs a paid developer tier) or "xactions" (free, self-hosted)?', void 0, "official")).toLowerCase();
|
|
2052
|
+
if (mode !== "official" && mode !== "xactions") throw guardError('Mode must be "official" or "xactions".');
|
|
2053
|
+
answers.xMode = mode;
|
|
2054
|
+
if (mode === "official") {
|
|
2055
|
+
note("developer.x.com \u2192 your app \u2192 Keys and tokens. Needs read+write access token permissions.");
|
|
2056
|
+
answers.xApiKey = await readPassword("X API key (consumer key):", "HOOD_ALERTS_X_API_KEY");
|
|
2057
|
+
answers.xApiSecret = await readPassword("X API secret (consumer secret):", "HOOD_ALERTS_X_API_SECRET");
|
|
2058
|
+
answers.xAccessToken = await readPassword("X access token:", "HOOD_ALERTS_X_ACCESS_TOKEN");
|
|
2059
|
+
answers.xAccessSecret = await readPassword("X access token secret:", "HOOD_ALERTS_X_ACCESS_SECRET");
|
|
2060
|
+
} else {
|
|
2061
|
+
note("Point this at your own running xactions instance: https://github.com/nirholas/XActions");
|
|
2062
|
+
answers.xactionsUrl = await promptLine("xactions instance URL:", "HOOD_ALERTS_XACTIONS_URL");
|
|
2063
|
+
answers.xactionsToken = await readPassword("xactions auth token:", "HOOD_ALERTS_XACTIONS_TOKEN");
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
const { traderEnv, alertsEnv } = buildEnvFiles(answers);
|
|
2067
|
+
const traderPath = join2(outDir, "hood-traders.env");
|
|
2068
|
+
const alertsPath = join2(outDir, "hood-alerts.env");
|
|
2069
|
+
if (existsSync3(traderPath) && !assumeYes && !await confirm(`${traderPath} already exists. Overwrite it?`)) {
|
|
2070
|
+
throw guardError("hood init cancelled.");
|
|
2071
|
+
}
|
|
2072
|
+
if (existsSync3(alertsPath) && !assumeYes && !await confirm(`${alertsPath} already exists. Overwrite it?`)) {
|
|
2073
|
+
throw guardError("hood init cancelled.");
|
|
2074
|
+
}
|
|
2075
|
+
writeFileSync3(traderPath, traderEnv, { mode: 384 });
|
|
2076
|
+
writeFileSync3(alertsPath, alertsEnv, { mode: 384 });
|
|
2077
|
+
const summary = {
|
|
2078
|
+
ok: true,
|
|
2079
|
+
wallet: answers.walletAddress ?? null,
|
|
2080
|
+
llmProvider: answers.llmProvider ?? null,
|
|
2081
|
+
telegram: !!answers.telegramToken,
|
|
2082
|
+
discord: !!answers.discordToken,
|
|
2083
|
+
xMode: answers.xMode ?? null,
|
|
2084
|
+
traderEnv: traderPath,
|
|
2085
|
+
alertsEnv: alertsPath
|
|
2086
|
+
};
|
|
2087
|
+
if (json) {
|
|
2088
|
+
printJson(summary);
|
|
2089
|
+
return;
|
|
2090
|
+
}
|
|
2091
|
+
printHuman(
|
|
2092
|
+
`
|
|
2093
|
+
${green("\u2713")} Wrote ${bold(traderPath)} and ${bold(alertsPath)}
|
|
2094
|
+
|
|
2095
|
+
${dim("Next steps:")}
|
|
2096
|
+
${dim("# run the trading fleet (paper mode by default \u2014 no funds move)")}
|
|
2097
|
+
cp ${traderPath} hood-traders/.env && cd hood-traders && npx hood-traders
|
|
2098
|
+
|
|
2099
|
+
${dim("# run the alert bot / real-time feed")}
|
|
2100
|
+
cp ${alertsPath} hood-alerts/.env && cd hood-alerts && npx hood-alerts
|
|
2101
|
+
`
|
|
2102
|
+
);
|
|
2103
|
+
}
|
|
2104
|
+
|
|
1950
2105
|
// src/program.ts
|
|
1951
2106
|
function readVersion() {
|
|
1952
2107
|
const here = dirname3(fileURLToPath(import.meta.url));
|
|
1953
|
-
const pkg = JSON.parse(readFileSync4(
|
|
2108
|
+
const pkg = JSON.parse(readFileSync4(join3(here, "..", "package.json"), "utf8"));
|
|
1954
2109
|
return pkg.version;
|
|
1955
2110
|
}
|
|
1956
2111
|
function createProgram() {
|
|
1957
|
-
const program2 = new
|
|
2112
|
+
const program2 = new Command15();
|
|
1958
2113
|
program2.name("hood").description("The command-line toolkit for Robinhood Chain (4663) \u2014 instant reads, guarded writes.").version(readVersion(), "-v, --version").option("--json", "machine-readable JSON output").option("--network <net>", "mainnet | testnet", "mainnet").option("--rpc <url>", "override the RPC endpoint").option("--verbose", "show raw error causes").option("--yes", "skip interactive confirmation on writes (still requires --execute)").option("--acknowledge-eligibility", "affirm Stock Token acquisition eligibility (non-US/CA/UK/CH)").option("--no-color", "disable ANSI colour").showHelpAfterError("(run `hood --help` for usage)").configureOutput({
|
|
1959
2114
|
outputError: (str, write) => write(str)
|
|
1960
2115
|
});
|
|
@@ -1971,6 +2126,7 @@ function createProgram() {
|
|
|
1971
2126
|
program2.addCommand(faucetCommand());
|
|
1972
2127
|
program2.addCommand(deployTokenCommand());
|
|
1973
2128
|
program2.addCommand(configCommand());
|
|
2129
|
+
program2.addCommand(initCommand());
|
|
1974
2130
|
return program2;
|
|
1975
2131
|
}
|
|
1976
2132
|
|