@mintlify/cli 4.0.1562 → 4.0.1564
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/__test__/agent.test.ts +64 -0
- package/bin/agent.js +42 -0
- package/bin/helpers.js +2 -1
- package/bin/telemetry/track.js +18 -11
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/agent.ts +56 -0
- package/src/helpers.tsx +2 -3
- package/src/telemetry/track.ts +19 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1564",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@inquirer/prompts": "7.9.0",
|
|
48
|
-
"@mintlify/common": "1.0.
|
|
49
|
-
"@mintlify/link-rot": "3.0.
|
|
48
|
+
"@mintlify/common": "1.0.1190",
|
|
49
|
+
"@mintlify/link-rot": "3.0.1396",
|
|
50
50
|
"@mintlify/models": "0.0.363",
|
|
51
|
-
"@mintlify/prebuild": "1.0.
|
|
52
|
-
"@mintlify/previewing": "4.0.
|
|
51
|
+
"@mintlify/prebuild": "1.0.1348",
|
|
52
|
+
"@mintlify/previewing": "4.0.1420",
|
|
53
53
|
"@mintlify/validation": "0.1.881",
|
|
54
54
|
"adm-zip": "0.6.0",
|
|
55
55
|
"chalk": "5.2.0",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"keytar": "7.9.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@mintlify/editor": "0.0.
|
|
89
|
+
"@mintlify/editor": "0.0.443",
|
|
90
90
|
"@mintlify/ts-config": "2.0.2",
|
|
91
91
|
"@tsconfig/recommended": "1.0.2",
|
|
92
92
|
"@types/detect-port": "1.3.2",
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"vitest": "2.1.9",
|
|
106
106
|
"vitest-mock-process": "1.0.4"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "d18fa7197a4fcc80769296fe9473aae90d73995c"
|
|
109
109
|
}
|
package/src/agent.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
|
|
3
|
+
type Env = NodeJS.ProcessEnv;
|
|
4
|
+
type Check = (env: Env) => boolean;
|
|
5
|
+
|
|
6
|
+
const set =
|
|
7
|
+
(...names: string[]): Check =>
|
|
8
|
+
(env) =>
|
|
9
|
+
names.some((name) => Boolean(env[name]));
|
|
10
|
+
const matches =
|
|
11
|
+
(name: string, pattern: RegExp): Check =>
|
|
12
|
+
(env) =>
|
|
13
|
+
pattern.test(env[name] ?? '');
|
|
14
|
+
const noTTY =
|
|
15
|
+
(check: Check): Check =>
|
|
16
|
+
(env) =>
|
|
17
|
+
!process.stdout.isTTY && check(env);
|
|
18
|
+
|
|
19
|
+
const AGENTS: Array<[name: string, check: Check]> = [
|
|
20
|
+
[
|
|
21
|
+
'cursor-cli',
|
|
22
|
+
(env) => set('CURSOR_AGENT')(env) || env.CURSOR_EXTENSION_HOST_ROLE === 'agent-exec',
|
|
23
|
+
],
|
|
24
|
+
['kimi', set('KIMI_PLUGIN_ROOT')],
|
|
25
|
+
['grok', set('GROK_PLUGIN_ROOT', 'GROK_PLUGIN_DATA')],
|
|
26
|
+
['gemini_cli', set('GEMINI_CLI')],
|
|
27
|
+
['cline', set('CLINE_ACTIVE')],
|
|
28
|
+
[
|
|
29
|
+
'codex_cli',
|
|
30
|
+
set('CODEX_SANDBOX', 'CODEX_CI', 'CODEX_THREAD_ID', 'CODEX_SANDBOX_NETWORK_DISABLED'),
|
|
31
|
+
],
|
|
32
|
+
['antigravity', set('ANTIGRAVITY_AGENT', 'ANTIGRAVITY_CLI_ALIAS')],
|
|
33
|
+
['augment-cli', set('AUGMENT_AGENT')],
|
|
34
|
+
['open_code', (env) => set('OPENCODE')(env) || noTTY(set('OPENCODE_CLIENT'))(env)],
|
|
35
|
+
['goose', noTTY(set('GOOSE_PROVIDER'))],
|
|
36
|
+
['junie', set('JUNIE_DATA', 'JUNIE_SHIM_PATH')],
|
|
37
|
+
['pi', matches('PATH', /\.pi[\\/]agent/)],
|
|
38
|
+
['cowork', (env) => set('CLAUDE_CODE_IS_COWORK')(env) && set('CLAUDECODE', 'CLAUDE_CODE')(env)],
|
|
39
|
+
['claude_code', (env) => set('CLAUDECODE', 'CLAUDE_CODE')(env) || env.TERM_PROGRAM === 'claude'],
|
|
40
|
+
['github-copilot', noTTY(set('COPILOT_MODEL', 'COPILOT_ALLOW_ALL'))],
|
|
41
|
+
['openclaw', set('OPENCLAW_SHELL')],
|
|
42
|
+
['devin', (env) => matches('EDITOR', /devin/)(env) || existsSync('/opt/.devin')],
|
|
43
|
+
['replit', noTTY(set('REPL_ID'))],
|
|
44
|
+
['kiro', noTTY(matches('TERM_PROGRAM', /kiro/))],
|
|
45
|
+
['cursor', noTTY(set('CURSOR_TRACE_ID'))],
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export function detectAgent(env: Env = process.env): string | undefined {
|
|
49
|
+
const explicit = (env.AI_AGENT || env.AGENT)?.trim();
|
|
50
|
+
if (explicit) return explicit.toLowerCase();
|
|
51
|
+
return AGENTS.find(([, check]) => check(env))?.[0];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isCI(env: Env = process.env): boolean {
|
|
55
|
+
return Boolean(env.CI && env.CI !== 'false' && env.CI !== '0');
|
|
56
|
+
}
|
package/src/helpers.tsx
CHANGED
|
@@ -25,6 +25,7 @@ import { promisify } from 'node:util';
|
|
|
25
25
|
import path from 'path';
|
|
26
26
|
import type { ArgumentsCamelCase } from 'yargs';
|
|
27
27
|
|
|
28
|
+
import { detectAgent } from './agent.js';
|
|
28
29
|
import { shutdownPostHog } from './telemetry/client.js';
|
|
29
30
|
|
|
30
31
|
export const CMD_EXEC_PATH = process.cwd();
|
|
@@ -257,9 +258,7 @@ export const terminate = async (code: number) => {
|
|
|
257
258
|
export const execFileAsync = promisify(execFile);
|
|
258
259
|
|
|
259
260
|
export function isAI(): boolean {
|
|
260
|
-
return (
|
|
261
|
-
!process.stdin.isTTY || process.env.CLAUDECODE === '1' || process.env.TERM_PROGRAM === 'claude'
|
|
262
|
-
);
|
|
261
|
+
return !process.stdin.isTTY || detectAgent() !== undefined;
|
|
263
262
|
}
|
|
264
263
|
|
|
265
264
|
export const detectPackageManager = async ({ packageName }: { packageName: string }) => {
|
package/src/telemetry/track.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
|
|
3
|
+
import { detectAgent, isCI } from '../agent.js';
|
|
3
4
|
import { isTelemetryEnabled } from '../config.js';
|
|
4
5
|
import { TELEMETRY_ASYNC_TIMEOUT_MS, TELEMETRY_IDENTITY_TIMEOUT_MS } from '../constants.js';
|
|
5
|
-
import { getVersions
|
|
6
|
+
import { getVersions } from '../helpers.js';
|
|
6
7
|
import { getAccessToken, getUserEmail, storeUserEmail } from '../keyring.js';
|
|
7
8
|
import { fetchCliStatus } from '../status.js';
|
|
8
9
|
import { deferShutdownUntil, getPostHogClient } from './client.js';
|
|
@@ -14,6 +15,19 @@ export interface TrackCommandOptions {
|
|
|
14
15
|
subdomain?: string;
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
function getEnvironmentProperties(): Record<string, unknown> {
|
|
19
|
+
const agent = detectAgent();
|
|
20
|
+
return {
|
|
21
|
+
os: os.platform(),
|
|
22
|
+
arch: os.arch(),
|
|
23
|
+
node_version: process.version,
|
|
24
|
+
is_ai_agent: agent !== undefined,
|
|
25
|
+
ai_agent: agent,
|
|
26
|
+
is_ci: isCI(),
|
|
27
|
+
is_tty: Boolean(process.stdin.isTTY),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
17
31
|
async function captureWithTimeout(
|
|
18
32
|
event: string,
|
|
19
33
|
properties: Record<string, unknown>
|
|
@@ -63,10 +77,7 @@ export async function trackCommand({
|
|
|
63
77
|
await captureWithTimeout('cli.command.executed', {
|
|
64
78
|
command,
|
|
65
79
|
cli_version: cliVersion,
|
|
66
|
-
|
|
67
|
-
arch: os.arch(),
|
|
68
|
-
node_version: process.version,
|
|
69
|
-
is_ai_agent: isAI(),
|
|
80
|
+
...getEnvironmentProperties(),
|
|
70
81
|
subdomain,
|
|
71
82
|
...(email ? { email, $set: { email } } : {}),
|
|
72
83
|
});
|
|
@@ -84,9 +95,7 @@ async function trackLoginEvent(event: string, extra?: Record<string, unknown>):
|
|
|
84
95
|
await captureWithTimeout(event, {
|
|
85
96
|
...extra,
|
|
86
97
|
cli_version: cliVersion,
|
|
87
|
-
|
|
88
|
-
arch: os.arch(),
|
|
89
|
-
node_version: process.version,
|
|
98
|
+
...getEnvironmentProperties(),
|
|
90
99
|
});
|
|
91
100
|
} catch {}
|
|
92
101
|
}
|
|
@@ -114,10 +123,7 @@ export async function trackEvent(
|
|
|
114
123
|
await captureWithTimeout(event, {
|
|
115
124
|
...properties,
|
|
116
125
|
cli_version: cliVersion,
|
|
117
|
-
|
|
118
|
-
arch: os.arch(),
|
|
119
|
-
node_version: process.version,
|
|
120
|
-
is_ai_agent: isAI(),
|
|
126
|
+
...getEnvironmentProperties(),
|
|
121
127
|
});
|
|
122
128
|
} catch {}
|
|
123
129
|
}
|
|
@@ -130,9 +136,7 @@ export async function trackTelemetryPreferenceChange(options: { enabled: boolean
|
|
|
130
136
|
await captureWithTimeout('cli.telemetry.preference_changed', {
|
|
131
137
|
enabled: options.enabled,
|
|
132
138
|
cli_version: cliVersion,
|
|
133
|
-
|
|
134
|
-
arch: os.arch(),
|
|
135
|
-
node_version: process.version,
|
|
139
|
+
...getEnvironmentProperties(),
|
|
136
140
|
});
|
|
137
141
|
} catch {}
|
|
138
142
|
}
|