@mangomagic/cli 0.1.9 → 0.1.10
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 +13 -4
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
|
@@ -143,6 +143,10 @@ function shouldStartChat(argv) {
|
|
|
143
143
|
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
function splashMode() {
|
|
147
|
+
return process.stdout.isTTY ? "anim" : "static";
|
|
148
|
+
}
|
|
149
|
+
|
|
146
150
|
async function enterChatAfterLogin(startChat) {
|
|
147
151
|
if (!startChat) return;
|
|
148
152
|
process.stdout.write(`\n${DIM}You're in chat mode now. Type ${BOLD}exit${RESET}${DIM} to leave.${RESET}\n`);
|
|
@@ -152,7 +156,7 @@ async function enterChatAfterLogin(startChat) {
|
|
|
152
156
|
async function login({ openInBrowser = true, startChat = false } = {}) {
|
|
153
157
|
if (loadToken()) {
|
|
154
158
|
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." });
|
|
159
|
+
await playSplash({ mode: splashMode(), greetingLine: "Welcome back to MangoMagic." });
|
|
156
160
|
home();
|
|
157
161
|
await enterChatAfterLogin(startChat);
|
|
158
162
|
return;
|
|
@@ -174,12 +178,17 @@ ${BOLD}Sign in to MangoMagic${RESET}
|
|
|
174
178
|
}).then(async (creds) => {
|
|
175
179
|
saveToken(creds);
|
|
176
180
|
process.stdout.write("\n\n");
|
|
177
|
-
await playSplash({ greetingLine: "You're in. Welcome to MangoMagic." });
|
|
181
|
+
await playSplash({ mode: splashMode(), greetingLine: "You're in. Welcome to MangoMagic." });
|
|
178
182
|
home();
|
|
179
183
|
await enterChatAfterLogin(startChat);
|
|
180
184
|
});
|
|
181
185
|
}
|
|
182
186
|
|
|
187
|
+
async function enterChat() {
|
|
188
|
+
await playSplash({ mode: splashMode(), greetingLine: "Welcome to MangoMagic." });
|
|
189
|
+
await chat(actions());
|
|
190
|
+
}
|
|
191
|
+
|
|
183
192
|
function logout() {
|
|
184
193
|
clearToken();
|
|
185
194
|
process.stdout.write("Signed out.\n");
|
|
@@ -251,7 +260,7 @@ function actions() {
|
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
export async function run(argv) {
|
|
254
|
-
const cmd = argv[0] ??
|
|
263
|
+
const cmd = argv[0] ?? "login";
|
|
255
264
|
switch (cmd) {
|
|
256
265
|
case "login": return login({
|
|
257
266
|
openInBrowser: !argv.includes("--no-open") && process.env.MANGOMAGIC_CLI_NO_OPEN !== "1",
|
|
@@ -260,7 +269,7 @@ export async function run(argv) {
|
|
|
260
269
|
case "logout": return logout();
|
|
261
270
|
case "whoami": return whoami();
|
|
262
271
|
case "home": return home();
|
|
263
|
-
case "chat": return
|
|
272
|
+
case "chat": return enterChat();
|
|
264
273
|
case "ask": return handleNaturalLanguage(argv.slice(1).join(" "), actions());
|
|
265
274
|
case "tools": return tools({ json: argv.includes("--json"), all: argv.includes("--all") });
|
|
266
275
|
case "tool": return runToolCommand(argv.slice(1));
|