@mangomagic/cli 0.1.9 → 0.1.11
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 +5 -5
- package/package.json +1 -1
- package/src/index.mjs +15 -5
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ npx -y @mangomagic/cli login
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
You'll get a short code, your browser will open, you approve the device, and
|
|
10
|
-
the CLI plays the MangoMagic splash to confirm you're in. In a normal
|
|
11
|
-
`login` then drops straight into chat mode so users can start typing.
|
|
12
|
-
is cached at `~/.mangomagic/credentials.json` (mode 0600) so the next
|
|
13
|
-
auth.
|
|
10
|
+
the CLI plays the animated MangoMagic splash to confirm you're in. In a normal
|
|
11
|
+
terminal, `login` then drops straight into chat mode so users can start typing.
|
|
12
|
+
The token is cached at `~/.mangomagic/credentials.json` (mode 0600) so the next
|
|
13
|
+
runs skip auth.
|
|
14
14
|
|
|
15
15
|
## Commands
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ auth.
|
|
|
20
20
|
| `mangomagic logout` | Forget the cached token. |
|
|
21
21
|
| `mangomagic whoami` | Show the cached identity. |
|
|
22
22
|
| `mangomagic home` | Show fast wins after sign-in. |
|
|
23
|
-
| `mangomagic chat` |
|
|
23
|
+
| `mangomagic chat` | Play the splash and start an interactive natural-language session. |
|
|
24
24
|
| `mangomagic ask "..."` | Run one natural-language request. |
|
|
25
25
|
| `mangomagic tools` | Show the CLI/MCP catalog. Add `--all` for the full list or `--json` for machine-readable output. |
|
|
26
26
|
| `mangomagic tool <name> '{"json":"args"}'` | Run the same tool exposed to MCP clients. |
|
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -140,7 +140,12 @@ async function runToolCommand(argv) {
|
|
|
140
140
|
|
|
141
141
|
function shouldStartChat(argv) {
|
|
142
142
|
if (argv.includes("--home") || argv.includes("--no-chat")) return false;
|
|
143
|
-
|
|
143
|
+
if (process.env.MANGOMAGIC_CLI_NO_CHAT === "1" || process.env.CI === "true") return false;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function splashMode() {
|
|
148
|
+
return process.stdout.isTTY ? "anim" : "static";
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
async function enterChatAfterLogin(startChat) {
|
|
@@ -152,7 +157,7 @@ async function enterChatAfterLogin(startChat) {
|
|
|
152
157
|
async function login({ openInBrowser = true, startChat = false } = {}) {
|
|
153
158
|
if (loadToken()) {
|
|
154
159
|
process.stdout.write(`${DIM}You're already signed in. Run \`mangomagic logout\` first to switch accounts.${RESET}\n`);
|
|
155
|
-
await playSplash({ greetingLine: "Welcome back to MangoMagic." });
|
|
160
|
+
await playSplash({ mode: splashMode(), greetingLine: "Welcome back to MangoMagic." });
|
|
156
161
|
home();
|
|
157
162
|
await enterChatAfterLogin(startChat);
|
|
158
163
|
return;
|
|
@@ -174,12 +179,17 @@ ${BOLD}Sign in to MangoMagic${RESET}
|
|
|
174
179
|
}).then(async (creds) => {
|
|
175
180
|
saveToken(creds);
|
|
176
181
|
process.stdout.write("\n\n");
|
|
177
|
-
await playSplash({ greetingLine: "You're in. Welcome to MangoMagic." });
|
|
182
|
+
await playSplash({ mode: splashMode(), greetingLine: "You're in. Welcome to MangoMagic." });
|
|
178
183
|
home();
|
|
179
184
|
await enterChatAfterLogin(startChat);
|
|
180
185
|
});
|
|
181
186
|
}
|
|
182
187
|
|
|
188
|
+
async function enterChat() {
|
|
189
|
+
await playSplash({ mode: splashMode(), greetingLine: "Welcome to MangoMagic." });
|
|
190
|
+
await chat(actions());
|
|
191
|
+
}
|
|
192
|
+
|
|
183
193
|
function logout() {
|
|
184
194
|
clearToken();
|
|
185
195
|
process.stdout.write("Signed out.\n");
|
|
@@ -251,7 +261,7 @@ function actions() {
|
|
|
251
261
|
}
|
|
252
262
|
|
|
253
263
|
export async function run(argv) {
|
|
254
|
-
const cmd = argv[0] ??
|
|
264
|
+
const cmd = argv[0] ?? "login";
|
|
255
265
|
switch (cmd) {
|
|
256
266
|
case "login": return login({
|
|
257
267
|
openInBrowser: !argv.includes("--no-open") && process.env.MANGOMAGIC_CLI_NO_OPEN !== "1",
|
|
@@ -260,7 +270,7 @@ export async function run(argv) {
|
|
|
260
270
|
case "logout": return logout();
|
|
261
271
|
case "whoami": return whoami();
|
|
262
272
|
case "home": return home();
|
|
263
|
-
case "chat": return
|
|
273
|
+
case "chat": return enterChat();
|
|
264
274
|
case "ask": return handleNaturalLanguage(argv.slice(1).join(" "), actions());
|
|
265
275
|
case "tools": return tools({ json: argv.includes("--json"), all: argv.includes("--all") });
|
|
266
276
|
case "tool": return runToolCommand(argv.slice(1));
|