@mintlify/cli 4.0.1754 → 4.0.1756

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.
@@ -0,0 +1,36 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+
3
+ import { AUTH_MD_URL, signup } from '../src/signup.js';
4
+
5
+ vi.mock('../src/helpers.js', async (importOriginal) => ({
6
+ ...(await importOriginal<typeof import('../src/helpers.js')>()),
7
+ isAI: () => true,
8
+ }));
9
+
10
+ afterEach(() => {
11
+ vi.unstubAllGlobals();
12
+ vi.restoreAllMocks();
13
+ });
14
+
15
+ describe('signup for agents', () => {
16
+ it('prints auth.md instead of starting the email signup', async () => {
17
+ const request = vi.fn().mockResolvedValue(new Response('# auth.md body'));
18
+ vi.stubGlobal('fetch', request);
19
+ const write = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
20
+
21
+ await signup({ firstName: 'A', lastName: 'B', company: 'C', email: 'a@example.com' });
22
+
23
+ expect(request).toHaveBeenCalledTimes(1);
24
+ expect(request.mock.calls[0]?.[0]).toBe(AUTH_MD_URL);
25
+ expect(write).toHaveBeenCalledWith('# auth.md body\n');
26
+ });
27
+
28
+ it('does not print a failed auth.md response', async () => {
29
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response('nope', { status: 502 })));
30
+ const write = vi.spyOn(process.stdout, 'write').mockImplementation(() => true);
31
+
32
+ await signup();
33
+
34
+ expect(write).not.toHaveBeenCalledWith('nope\n');
35
+ });
36
+ });
package/bin/signup.js CHANGED
@@ -19,8 +19,9 @@ import { API_URL, TOKEN_ENDPOINT } from './constants.js';
19
19
  import { CMD_EXEC_PATH, isAI } from './helpers.js';
20
20
  import { getEmailFromIdToken } from './idToken.js';
21
21
  import { getAccessToken, storeCredentials } from './keyring.js';
22
+ export const AUTH_MD_URL = 'https://mintlify.com/auth.md';
22
23
  const sendAIUsageMessage = () => {
23
- addLogs(_jsx(Text, { children: "Agent Detected - sending AI friendly prompt" }), _jsx(Text, { children: '<mint-cli-instructions>' }), _jsx(Text, { children: "You were asked to create a Mintlify account. Here is how to do that with the `mint signup` command. Fill in any values you already have from this conversation; ask the user directly for anything you don't \u2014 never invent a person's name, company, or email." }), _jsx(Text, { children: "Command: `mint signup --firstName [firstName] --lastName [lastName] --company [company] --email [email]`." }), _jsx(Text, { children: "Important: this command blocks until the user clicks a verification link sent to their email, which can take several minutes. Run it as a background task, not in the foreground \u2014 do not wait on it synchronously. You'll be notified when it finishes; then tell the user their account is ready." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
24
+ addLogs(_jsx(Text, { children: "Agent Detected - sending AI friendly prompt" }), _jsx(Text, { children: '<mint-cli-instructions>' }), _jsxs(Text, { children: ["Could not fetch the agent signup guide. Read ", AUTH_MD_URL, " directly, or create a site without an account by running `mint deploy --subdomain [subdomain]` from the documentation directory and following the instructions it prints."] }), _jsx(Text, { children: "To hand the site to the user, ask for their email (never invent one) and run `mint claim --email [email]`." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
24
25
  };
25
26
  export const sendPublishPrompt = () => __awaiter(void 0, void 0, void 0, function* () {
26
27
  if (!isAI() ||
@@ -33,14 +34,26 @@ export const sendPublishPrompt = () => __awaiter(void 0, void 0, void 0, functio
33
34
  addLog(_jsx(Text, { children: "Not published yet. Run `mint signup` or `mint login` to publish." }));
34
35
  return;
35
36
  }
36
- addLogs(_jsx(Text, { children: '<mint-cli-instructions>' }), _jsx(Text, { children: "Ready to publish? The Starter plan is free, no credit card needed." }), _jsx(Text, { children: "Offer to create the user's Mintlify account with `mint signup --firstName [firstName] --lastName [lastName] --company [company] --email [email]`. Ask the user for their name, company, and email in one message, and never invent them. Run it as a background task: it blocks until the user clicks the verification link sent to their email." }), _jsx(Text, { children: "Have an account: `mint login`." }), _jsx(Text, { children: "After the email is verified, connect GitHub in the browser tab to deploy." }), _jsx(Text, { children: "Your site will then be live at https://[subdomain].mintlify.site (`mint status` shows the exact URL)." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
37
+ addLogs(_jsx(Text, { children: '<mint-cli-instructions>' }), _jsx(Text, { children: "Ready to publish? The Starter plan is free, no credit card needed." }), _jsx(Text, { children: "Offer to create the user's Mintlify account: run `mint signup` and follow the instructions it prints." }), _jsx(Text, { children: "Have an account: `mint login`." }), _jsx(Text, { children: "Your site will then be live at https://[subdomain].mintlify.site (`mint status` shows the exact URL)." }), _jsx(Text, { children: '</mint-cli-instructions>' }));
37
38
  yield markPublishPromptShown(CMD_EXEC_PATH).catch(() => undefined);
38
39
  });
40
+ // Agents sign up through auth.md, so give them that guide instead of the email flow.
41
+ const sendAuthMd = () => __awaiter(void 0, void 0, void 0, function* () {
42
+ try {
43
+ const res = yield fetch(AUTH_MD_URL, { signal: AbortSignal.timeout(30000) });
44
+ if (!res.ok)
45
+ throw new Error(`auth.md returned ${res.status}`);
46
+ process.stdout.write(`${yield res.text()}\n`);
47
+ }
48
+ catch (_a) {
49
+ sendAIUsageMessage();
50
+ }
51
+ });
39
52
  export function signup() {
40
53
  return __awaiter(this, arguments, void 0, function* (options = {}) {
41
54
  var _a, _b, _c, _d, _e, _f, _g, _h;
42
- if (isAI() && (!options.firstName || !options.lastName || !options.company || !options.email)) {
43
- sendAIUsageMessage();
55
+ if (isAI()) {
56
+ yield sendAuthMd();
44
57
  return;
45
58
  }
46
59
  const firstName = (_a = options.firstName) !== null && _a !== void 0 ? _a : (yield input({ message: 'First name' }));