@hubspot/cli 8.10.0 → 8.12.0-beta.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/commands/account/clean.js +1 -1
- package/commands/account/list.js +1 -1
- package/commands/account/remove.js +1 -1
- package/commands/account/rename.js +1 -1
- package/commands/account/use.js +1 -1
- package/commands/api.d.ts +4 -1
- package/commands/api.js +11 -14
- package/commands/hubdb/list.d.ts +1 -1
- package/commands/mcp/setup.d.ts +2 -0
- package/commands/mcp/setup.js +29 -1
- package/commands/project/appInstallStatus.d.ts +2 -1
- package/commands/project/appInstallStatus.js +19 -17
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.d.ts +2 -1
- package/commands/project/deploy.js +31 -14
- package/commands/project/dev/index.js +18 -64
- package/commands/project/info.d.ts +2 -1
- package/commands/project/info.js +8 -6
- package/commands/project/installApp.d.ts +2 -1
- package/commands/project/installApp.js +25 -26
- package/commands/project/list.js +1 -1
- package/commands/project/profile/add.d.ts +2 -1
- package/commands/project/profile/add.js +22 -1
- package/commands/project/profile/delete.d.ts +1 -1
- package/commands/project/release/create.d.ts +2 -1
- package/commands/project/release/create.js +68 -69
- package/commands/project/release/info.d.ts +2 -1
- package/commands/project/release/info.js +7 -6
- package/commands/project/release/list.d.ts +2 -1
- package/commands/project/release/list.js +14 -6
- package/commands/project/upload.d.ts +2 -1
- package/commands/project/upload.js +23 -17
- package/commands/project/validate.d.ts +1 -1
- package/commands/project.js +2 -2
- package/commands/testAccount/create.d.ts +2 -1
- package/commands/testAccount/create.js +7 -7
- package/commands/testAccount/importData.d.ts +1 -1
- package/lang/en.d.ts +32 -28
- package/lang/en.js +41 -37
- package/lib/commonOpts.js +6 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +1 -0
- package/lib/jsonOutput.d.ts +109 -0
- package/lib/jsonOutput.js +94 -0
- package/lib/mcp/setup.d.ts +6 -1
- package/lib/mcp/setup.js +29 -18
- package/lib/projects/builds.d.ts +2 -0
- package/lib/projects/builds.js +22 -0
- package/lib/projects/localDev/DevSessionManager.d.ts +2 -2
- package/lib/projects/localDev/DevSessionManager.js +4 -30
- package/lib/projects/localDev/helpers/account.d.ts +0 -7
- package/lib/projects/localDev/helpers/account.js +1 -80
- package/lib/projects/release.d.ts +4 -0
- package/lib/projects/release.js +90 -0
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +4 -8
- package/lib/yargs/makeWrappedYargsHandler.d.ts +5 -1
- package/lib/yargs/makeWrappedYargsHandler.js +123 -65
- package/mcp-server/Tool.d.ts +8 -3
- package/mcp-server/Tool.js +58 -32
- package/mcp-server/server.js +10 -6
- package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +10 -17
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +12 -18
- package/mcp-server/tools/cms/HsCreateTemplateTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +8 -10
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +9 -9
- package/mcp-server/tools/cms/HsListFunctionsTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +7 -7
- package/mcp-server/tools/cms/HsListTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsListTool.js +6 -10
- package/mcp-server/tools/index.js +2 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +8 -9
- package/mcp-server/tools/project/AuthAccountTool.d.ts +18 -0
- package/mcp-server/tools/project/AuthAccountTool.js +78 -0
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/CreateProjectTool.js +13 -12
- package/mcp-server/tools/project/CreateTestAccountTool.d.ts +2 -2
- package/mcp-server/tools/project/CreateTestAccountTool.js +14 -15
- package/mcp-server/tools/project/DeployProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/DeployProjectTool.js +10 -10
- package/mcp-server/tools/project/DocFetchTool.js +1 -1
- package/mcp-server/tools/project/DocsSearchTool.js +9 -3
- package/mcp-server/tools/project/FindProjectsTool.js +1 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -4
- package/mcp-server/tools/project/GetApplicationInfoTool.js +9 -4
- package/mcp-server/tools/project/GetBuildLogsTool.js +9 -3
- package/mcp-server/tools/project/GetBuildStatusTool.js +9 -3
- package/mcp-server/tools/project/GetConfigValuesTool.js +9 -3
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
- package/mcp-server/tools/project/UploadProjectTools.d.ts +2 -2
- package/mcp-server/tools/project/UploadProjectTools.js +9 -8
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/ValidateProjectTool.js +5 -4
- package/mcp-server/utils/command.d.ts +25 -2
- package/mcp-server/utils/command.js +67 -17
- package/mcp-server/utils/logger.d.ts +3 -0
- package/mcp-server/utils/logger.js +30 -0
- package/mcp-server/utils/toolUsageTracking.js +8 -1
- package/package.json +10 -8
- package/types/Yargs.d.ts +3 -1
- package/commands/project/dev/deprecatedFlow.d.ts +0 -11
- package/commands/project/dev/deprecatedFlow.js +0 -180
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +0 -43
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +0 -128
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +0 -394
|
@@ -31,10 +31,15 @@ export class GetApiUsagePatternsByAppIdTool extends Tool {
|
|
|
31
31
|
async handler({ appId, startDate, endDate, absoluteCurrentWorkingDirectory, }) {
|
|
32
32
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
33
33
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
let accountId;
|
|
35
|
+
try {
|
|
36
|
+
accountId = getConfigDefaultAccountIfExists()?.accountId;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Config file does not exist
|
|
40
|
+
}
|
|
36
41
|
if (!accountId) {
|
|
37
|
-
const authErrorMessage = `No account ID found.
|
|
42
|
+
const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
|
|
38
43
|
return formatTextContents(authErrorMessage);
|
|
39
44
|
}
|
|
40
45
|
const response = await http.get(accountId, {
|
|
@@ -70,6 +75,6 @@ export class GetApiUsagePatternsByAppIdTool extends Tool {
|
|
|
70
75
|
readOnlyHint: true,
|
|
71
76
|
openWorldHint: true,
|
|
72
77
|
},
|
|
73
|
-
}, input => this.wrappedHandler(input));
|
|
78
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
74
79
|
}
|
|
75
80
|
}
|
|
@@ -18,10 +18,15 @@ export class GetApplicationInfoTool extends Tool {
|
|
|
18
18
|
async handler({ absoluteCurrentWorkingDirectory, }) {
|
|
19
19
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let accountId;
|
|
22
|
+
try {
|
|
23
|
+
accountId = getConfigDefaultAccountIfExists()?.accountId;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Config file does not exist
|
|
27
|
+
}
|
|
23
28
|
if (!accountId) {
|
|
24
|
-
const authErrorMessage = `No account ID found.
|
|
29
|
+
const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
|
|
25
30
|
return formatTextContents(authErrorMessage);
|
|
26
31
|
}
|
|
27
32
|
const response = await http.get(accountId, {
|
|
@@ -53,6 +58,6 @@ export class GetApplicationInfoTool extends Tool {
|
|
|
53
58
|
readOnlyHint: true,
|
|
54
59
|
openWorldHint: true,
|
|
55
60
|
},
|
|
56
|
-
}, input => this.wrappedHandler(input));
|
|
61
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
57
62
|
}
|
|
58
63
|
}
|
|
@@ -64,9 +64,15 @@ export class GetBuildLogsTool extends Tool {
|
|
|
64
64
|
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, logLevel, }) {
|
|
65
65
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
66
66
|
try {
|
|
67
|
-
|
|
67
|
+
let accountId;
|
|
68
|
+
try {
|
|
69
|
+
accountId = getConfigDefaultAccountIfExists()?.accountId;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Config file does not exist
|
|
73
|
+
}
|
|
68
74
|
if (!accountId) {
|
|
69
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found.
|
|
75
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Call the auth-account tool to authenticate a HubSpot account.');
|
|
70
76
|
}
|
|
71
77
|
const { projectConfig, projectDir } = await getProjectConfig(absoluteProjectPath);
|
|
72
78
|
validateProjectConfig(projectConfig, projectDir);
|
|
@@ -121,6 +127,6 @@ export class GetBuildLogsTool extends Tool {
|
|
|
121
127
|
openWorldHint: true,
|
|
122
128
|
idempotentHint: true,
|
|
123
129
|
},
|
|
124
|
-
}, input => this.wrappedHandler(input));
|
|
130
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
125
131
|
}
|
|
126
132
|
}
|
|
@@ -109,9 +109,15 @@ export class GetBuildStatusTool extends Tool {
|
|
|
109
109
|
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, limit, }) {
|
|
110
110
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
111
111
|
try {
|
|
112
|
-
|
|
112
|
+
let accountId;
|
|
113
|
+
try {
|
|
114
|
+
accountId = getConfigDefaultAccountIfExists()?.accountId;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Config file does not exist
|
|
118
|
+
}
|
|
113
119
|
if (!accountId) {
|
|
114
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found.
|
|
120
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Call the auth-account tool to authenticate a HubSpot account.');
|
|
115
121
|
}
|
|
116
122
|
const { projectConfig, projectDir } = await getProjectConfig(absoluteProjectPath);
|
|
117
123
|
validateProjectConfig(projectConfig, projectDir);
|
|
@@ -162,6 +168,6 @@ export class GetBuildStatusTool extends Tool {
|
|
|
162
168
|
openWorldHint: true,
|
|
163
169
|
idempotentHint: true,
|
|
164
170
|
},
|
|
165
|
-
}, input => this.wrappedHandler(input));
|
|
171
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
166
172
|
}
|
|
167
173
|
}
|
|
@@ -31,9 +31,15 @@ export class GetConfigValuesTool extends Tool {
|
|
|
31
31
|
if (isLegacyProject(platformVersion)) {
|
|
32
32
|
return formatTextContents(`Can only be used on projects with a minimum platformVersion of 2025.2`);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
let accountId;
|
|
35
|
+
try {
|
|
36
|
+
accountId = getConfigDefaultAccountIfExists()?.accountId;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Config file does not exist
|
|
40
|
+
}
|
|
35
41
|
if (!accountId) {
|
|
36
|
-
const authErrorMessage = `No account ID found.
|
|
42
|
+
const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
|
|
37
43
|
return formatTextContents(authErrorMessage);
|
|
38
44
|
}
|
|
39
45
|
const schema = await getIntermediateRepresentationSchema({
|
|
@@ -65,6 +71,6 @@ export class GetConfigValuesTool extends Tool {
|
|
|
65
71
|
readOnlyHint: true,
|
|
66
72
|
openWorldHint: false,
|
|
67
73
|
},
|
|
68
|
-
}, input => this.wrappedHandler(input));
|
|
74
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -2,7 +2,7 @@ import z from 'zod';
|
|
|
2
2
|
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { McpLogger } from '../../utils/logger.js';
|
|
4
4
|
import { TextContentResponse } from '../../types.js';
|
|
5
|
-
import { Tool } from '../../Tool.js';
|
|
5
|
+
import { Tool, ToolExtra } from '../../Tool.js';
|
|
6
6
|
declare const inputSchemaZodObject: z.ZodObject<{
|
|
7
7
|
absoluteProjectPath: z.ZodString;
|
|
8
8
|
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
@@ -12,7 +12,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
12
12
|
type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
|
|
13
13
|
export declare class UploadProjectTools extends Tool<InputSchemaType> {
|
|
14
14
|
constructor(mcpServer: McpServer, logger: McpLogger);
|
|
15
|
-
handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }: InputSchemaType): Promise<TextContentResponse>;
|
|
15
|
+
handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }: InputSchemaType, extra?: ToolExtra): Promise<TextContentResponse>;
|
|
16
16
|
register(): RegisteredTool;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -3,10 +3,9 @@ import z from 'zod';
|
|
|
3
3
|
import { getAllHsProfiles } from '@hubspot/project-parsing-lib/profiles';
|
|
4
4
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
5
5
|
import { Tool } from '../../Tool.js';
|
|
6
|
-
import { runCommandInDir } from '../../utils/command.js';
|
|
7
6
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
|
|
8
7
|
import { formatTextContent, formatTextContents } from '../../utils/content.js';
|
|
9
|
-
import {
|
|
8
|
+
import { HubSpotCommand } from '../../utils/command.js';
|
|
10
9
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
11
10
|
const inputSchema = {
|
|
12
11
|
absoluteProjectPath,
|
|
@@ -27,15 +26,17 @@ export class UploadProjectTools extends Tool {
|
|
|
27
26
|
constructor(mcpServer, logger) {
|
|
28
27
|
super(mcpServer, logger, toolName);
|
|
29
28
|
}
|
|
30
|
-
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }) {
|
|
29
|
+
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }, extra) {
|
|
31
30
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
32
|
-
|
|
31
|
+
const command = new HubSpotCommand('project upload', [
|
|
32
|
+
{ name: 'force', value: true },
|
|
33
|
+
]);
|
|
33
34
|
const content = [];
|
|
34
35
|
if (uploadMessage) {
|
|
35
|
-
command
|
|
36
|
+
command.addFlag('message', uploadMessage);
|
|
36
37
|
}
|
|
37
38
|
if (profile) {
|
|
38
|
-
command
|
|
39
|
+
command.addFlag('profile', profile);
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
42
|
let hasProfiles = false;
|
|
@@ -63,7 +64,7 @@ export class UploadProjectTools extends Tool {
|
|
|
63
64
|
content,
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
const { stdout, stderr } = await
|
|
67
|
+
const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
|
|
67
68
|
const response = await formatTextContents(stdout, stderr);
|
|
68
69
|
// Add reminder about cards needing to be added to views
|
|
69
70
|
response.content.push(formatTextContent('\nIMPORTANT: If this project contains cards, remember that uploading does NOT make them live automatically. Cards must be manually added to a view in HubSpot to become visible to users.'));
|
|
@@ -80,6 +81,6 @@ export class UploadProjectTools extends Tool {
|
|
|
80
81
|
idempotentHint: true,
|
|
81
82
|
openWorldHint: true,
|
|
82
83
|
},
|
|
83
|
-
}, input => this.wrappedHandler(input));
|
|
84
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextContentResponse } from '../../types.js';
|
|
2
|
-
import { Tool } from '../../Tool.js';
|
|
2
|
+
import { Tool, ToolExtra } from '../../Tool.js';
|
|
3
3
|
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { McpLogger } from '../../utils/logger.js';
|
|
5
5
|
import { z } from 'zod';
|
|
@@ -10,7 +10,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
10
10
|
export type CreateProjectInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
11
11
|
export declare class ValidateProjectTool extends Tool<CreateProjectInputSchema> {
|
|
12
12
|
constructor(mcpServer: McpServer, logger: McpLogger);
|
|
13
|
-
handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }: CreateProjectInputSchema): Promise<TextContentResponse>;
|
|
13
|
+
handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }: CreateProjectInputSchema, extra?: ToolExtra): Promise<TextContentResponse>;
|
|
14
14
|
register(): RegisteredTool;
|
|
15
15
|
}
|
|
16
16
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
|
|
4
|
-
import { runCommandInDir } from '../../utils/command.js';
|
|
5
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
6
5
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
7
6
|
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
7
|
+
import { HubSpotCommand } from '../../utils/command.js';
|
|
8
8
|
const inputSchema = {
|
|
9
9
|
absoluteProjectPath,
|
|
10
10
|
absoluteCurrentWorkingDirectory,
|
|
@@ -16,10 +16,11 @@ export class ValidateProjectTool extends Tool {
|
|
|
16
16
|
constructor(mcpServer, logger) {
|
|
17
17
|
super(mcpServer, logger, toolName);
|
|
18
18
|
}
|
|
19
|
-
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }) {
|
|
19
|
+
async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }, extra) {
|
|
20
20
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
21
21
|
try {
|
|
22
|
-
const
|
|
22
|
+
const command = new HubSpotCommand('project validate');
|
|
23
|
+
const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
|
|
23
24
|
return formatTextContents(stdout, stderr);
|
|
24
25
|
}
|
|
25
26
|
catch (error) {
|
|
@@ -39,6 +40,6 @@ export class ValidateProjectTool extends Tool {
|
|
|
39
40
|
readOnlyHint: true,
|
|
40
41
|
openWorldHint: false,
|
|
41
42
|
},
|
|
42
|
-
}, input => this.wrappedHandler(input));
|
|
43
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import { exec } from 'node:child_process';
|
|
2
|
+
export interface Command {
|
|
3
|
+
executable: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
}
|
|
6
|
+
export type FlagValue = string | number | boolean | string[];
|
|
7
|
+
export interface Flag {
|
|
8
|
+
name: string;
|
|
9
|
+
value: FlagValue;
|
|
10
|
+
}
|
|
11
|
+
export declare class HubSpotCommand implements Command {
|
|
12
|
+
readonly executable = "hs";
|
|
13
|
+
private readonly subcommandArgs;
|
|
14
|
+
private readonly positionalArgs;
|
|
15
|
+
private readonly flags;
|
|
16
|
+
constructor(subcommand: string, flags?: Flag[]);
|
|
17
|
+
addArg(value: string): this;
|
|
18
|
+
addFlag(name: string, value: FlagValue): this;
|
|
19
|
+
get args(): string[];
|
|
20
|
+
}
|
|
21
|
+
export declare class NpxHubSpotCommand implements Command {
|
|
22
|
+
readonly executable = "npx";
|
|
23
|
+
readonly args: string[];
|
|
24
|
+
constructor(command: Command, cliPackage?: string);
|
|
25
|
+
}
|
|
2
26
|
export declare const execAsync: typeof exec.__promisify__;
|
|
3
|
-
export declare function addFlag(command: string, flagName: string, value: string | number | boolean | string[]): string;
|
|
4
27
|
export interface CommandResults {
|
|
5
28
|
stderr: string;
|
|
6
29
|
stdout: string;
|
|
7
30
|
}
|
|
8
|
-
export declare function runCommandInDir(directory: string, command: string): Promise<CommandResults>;
|
|
31
|
+
export declare function runCommandInDir(directory: string, command: Command, onData?: (chunk: string, source: 'stdout' | 'stderr') => void): Promise<CommandResults>;
|
|
@@ -1,35 +1,85 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import util from 'util';
|
|
4
|
-
import { exec } from 'node:child_process';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { exec, spawn } from 'node:child_process';
|
|
5
|
+
export class HubSpotCommand {
|
|
6
|
+
executable = 'hs';
|
|
7
|
+
subcommandArgs;
|
|
8
|
+
positionalArgs;
|
|
9
|
+
flags;
|
|
10
|
+
constructor(subcommand, flags = []) {
|
|
11
|
+
this.subcommandArgs = subcommand.trim().split(/\s+/);
|
|
12
|
+
this.positionalArgs = [];
|
|
13
|
+
this.flags = [...flags];
|
|
14
|
+
}
|
|
15
|
+
addArg(value) {
|
|
16
|
+
this.positionalArgs.push(value);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
addFlag(name, value) {
|
|
20
|
+
this.flags.push({ name, value });
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
get args() {
|
|
24
|
+
return [
|
|
25
|
+
...this.subcommandArgs,
|
|
26
|
+
...this.positionalArgs,
|
|
27
|
+
...this.flags.flatMap(({ name, value }) => Array.isArray(value)
|
|
28
|
+
? [`--${name}`, ...value.map(String)]
|
|
29
|
+
: [`--${name}`, String(value)]),
|
|
30
|
+
];
|
|
9
31
|
}
|
|
10
|
-
return `${command} --${flagName} "${value}"`;
|
|
11
32
|
}
|
|
12
|
-
export
|
|
33
|
+
export class NpxHubSpotCommand {
|
|
34
|
+
executable = 'npx';
|
|
35
|
+
args;
|
|
36
|
+
constructor(command, cliPackage = '@hubspot/cli') {
|
|
37
|
+
this.args = ['-y', '-p', cliPackage, 'hs', ...command.args];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const execAsync = util.promisify(exec);
|
|
41
|
+
export async function runCommandInDir(directory, command, onData) {
|
|
13
42
|
if (!fs.existsSync(directory)) {
|
|
14
43
|
fs.mkdirSync(directory);
|
|
15
44
|
}
|
|
16
45
|
let finalCommand = command;
|
|
17
|
-
if (command
|
|
18
|
-
|
|
46
|
+
if (command instanceof HubSpotCommand) {
|
|
47
|
+
command.addFlag('disable-usage-tracking', 'true');
|
|
19
48
|
if (process.env.HUBSPOT_MCP_STANDALONE === 'true') {
|
|
20
49
|
const cliPackage = process.env.HUBSPOT_CLI_VERSION
|
|
21
50
|
? `@hubspot/cli@${process.env.HUBSPOT_CLI_VERSION}`
|
|
22
51
|
: '@hubspot/cli';
|
|
23
|
-
finalCommand = command
|
|
52
|
+
finalCommand = new NpxHubSpotCommand(command, cliPackage);
|
|
24
53
|
}
|
|
25
|
-
finalCommand = addFlag(finalCommand, 'disable-usage-tracking', true);
|
|
26
54
|
}
|
|
27
55
|
const resolvedDir = path.resolve(directory);
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
const stdoutChunks = [];
|
|
58
|
+
const stderrChunks = [];
|
|
59
|
+
const child = spawn(finalCommand.executable, finalCommand.args, {
|
|
60
|
+
cwd: resolvedDir,
|
|
61
|
+
env: { ...process.env, INIT_CWD: resolvedDir },
|
|
62
|
+
});
|
|
63
|
+
child.stdout.on('data', (chunk) => {
|
|
64
|
+
const text = chunk.toString();
|
|
65
|
+
stdoutChunks.push(text);
|
|
66
|
+
onData?.(text, 'stdout');
|
|
67
|
+
});
|
|
68
|
+
child.stderr.on('data', (chunk) => {
|
|
69
|
+
const text = chunk.toString();
|
|
70
|
+
stderrChunks.push(text);
|
|
71
|
+
onData?.(text, 'stderr');
|
|
72
|
+
});
|
|
73
|
+
child.on('error', reject);
|
|
74
|
+
child.on('close', code => {
|
|
75
|
+
const stdout = stdoutChunks.join('');
|
|
76
|
+
const stderr = stderrChunks.join('');
|
|
77
|
+
if (code !== 0) {
|
|
78
|
+
reject(Object.assign(new Error(`Command failed: ${finalCommand.executable} ${finalCommand.args.join(' ')}\n${stderr}`), { code, stdout, stderr }));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
resolve({ stdout, stderr });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
34
84
|
});
|
|
35
85
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
export declare class McpLogger {
|
|
3
3
|
private mcpServer;
|
|
4
|
+
private invocationStorage;
|
|
4
5
|
constructor(mcpServer: McpServer);
|
|
5
6
|
private log;
|
|
6
7
|
debug(logger: string, data: unknown): void;
|
|
7
8
|
info(logger: string, data: unknown): void;
|
|
8
9
|
warn(logger: string, data: unknown): void;
|
|
9
10
|
error(logger: string, data: unknown): void;
|
|
11
|
+
runWithBuffer<T>(fn: () => Promise<T>): Promise<T>;
|
|
12
|
+
flushLogsToFile(filenamePrefix: string): string | null;
|
|
10
13
|
}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
+
import { LogBuffer } from '@hubspot/local-dev-lib/LogBuffer';
|
|
5
|
+
import { MAX_LOG_FILES } from '../../lib/constants.js';
|
|
6
|
+
const MCP_LOG_DIR = path.join(os.homedir(), '.hscli', 'logs', 'tools');
|
|
1
7
|
export class McpLogger {
|
|
2
8
|
mcpServer;
|
|
9
|
+
invocationStorage = new AsyncLocalStorage();
|
|
3
10
|
constructor(mcpServer) {
|
|
4
11
|
this.mcpServer = mcpServer;
|
|
5
12
|
}
|
|
6
13
|
log(level, logger, data) {
|
|
7
14
|
try {
|
|
15
|
+
const buffer = this.invocationStorage.getStore();
|
|
16
|
+
if (buffer) {
|
|
17
|
+
const serialized = typeof data === 'string' ? data : JSON.stringify(data);
|
|
18
|
+
buffer.record(level, [logger, serialized]);
|
|
19
|
+
}
|
|
8
20
|
this.mcpServer.sendLoggingMessage({ level, logger, data });
|
|
9
21
|
}
|
|
10
22
|
catch (error) {
|
|
@@ -26,4 +38,22 @@ export class McpLogger {
|
|
|
26
38
|
error(logger, data) {
|
|
27
39
|
this.log('error', logger, data);
|
|
28
40
|
}
|
|
41
|
+
// Runs fn in a fresh per-invocation log buffer context. All log calls made
|
|
42
|
+
// within fn (including nested async callbacks like progress chunks) record
|
|
43
|
+
// into this buffer rather than a shared one, so concurrent tool calls never
|
|
44
|
+
// intermix their logs.
|
|
45
|
+
runWithBuffer(fn) {
|
|
46
|
+
return this.invocationStorage.run(new LogBuffer(), fn);
|
|
47
|
+
}
|
|
48
|
+
flushLogsToFile(filenamePrefix) {
|
|
49
|
+
const buffer = this.invocationStorage.getStore();
|
|
50
|
+
if (!buffer) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return buffer.writeToFile({
|
|
54
|
+
dir: MCP_LOG_DIR,
|
|
55
|
+
filenamePrefix,
|
|
56
|
+
maxFiles: MAX_LOG_FILES,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
29
59
|
}
|
|
@@ -2,7 +2,14 @@ import { EventClass, getExecutionEnvironmentMeta, } from '../../lib/usageTrackin
|
|
|
2
2
|
import { getConfig, getConfigDefaultAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { sendUsageEvent } from '../../lib/api/usageTracking.js';
|
|
4
4
|
export async function trackToolUsage(toolName, meta) {
|
|
5
|
-
|
|
5
|
+
let config;
|
|
6
|
+
try {
|
|
7
|
+
config = getConfig();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
// No config file exists yet; skip tracking
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
6
13
|
if (config?.allowUsageTracking === false) {
|
|
7
14
|
return;
|
|
8
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.12.0-beta.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"!**/__tests__/**"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@hubspot/local-dev-lib": "5.
|
|
14
|
-
"@hubspot/project-parsing-lib": "0.
|
|
13
|
+
"@hubspot/local-dev-lib": "5.10.1",
|
|
14
|
+
"@hubspot/project-parsing-lib": "0.21.0",
|
|
15
15
|
"@hubspot/serverless-dev-runtime": "7.0.7",
|
|
16
|
-
"@hubspot/ui-extensions-dev-server": "2.0.
|
|
16
|
+
"@hubspot/ui-extensions-dev-server": "2.0.13",
|
|
17
17
|
"@inquirer/prompts": "7.1.0",
|
|
18
18
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
19
19
|
"archiver": "7.0.1",
|
|
@@ -40,10 +40,11 @@
|
|
|
40
40
|
"update-notifier": "7.3.1",
|
|
41
41
|
"ws": "8.20.0",
|
|
42
42
|
"yargs": "17.7.2",
|
|
43
|
-
"yargs-parser": "21.1.1"
|
|
43
|
+
"yargs-parser": "21.1.1",
|
|
44
|
+
"zod": "^4.4.3"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@hubspot/npm-scripts": "0.
|
|
47
|
+
"@hubspot/npm-scripts": "0.3.1",
|
|
47
48
|
"@types/archiver": "^6.0.3",
|
|
48
49
|
"@types/cli-progress": "^3.11.6",
|
|
49
50
|
"@types/express": "^5.0.0",
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
61
62
|
"@typescript-eslint/parser": "^8.11.0",
|
|
62
63
|
"@vitest/coverage-v8": "^2.1.9",
|
|
63
|
-
"axios": "1.
|
|
64
|
+
"axios": "1.18.1",
|
|
64
65
|
"eslint": "^8.56.0",
|
|
65
66
|
"eslint-plugin-import": "^2.31.0",
|
|
66
67
|
"husky": "^4.3.8",
|
|
@@ -123,6 +124,7 @@
|
|
|
123
124
|
"registry": "https://registry.npmjs.org/"
|
|
124
125
|
},
|
|
125
126
|
"resolutions": {
|
|
126
|
-
"eslint-visitor-keys": "4.2.0"
|
|
127
|
+
"eslint-visitor-keys": "4.2.0",
|
|
128
|
+
"@eslint-community/eslint-utils": "4.9.0"
|
|
127
129
|
}
|
|
128
130
|
}
|
package/types/Yargs.d.ts
CHANGED
|
@@ -38,9 +38,11 @@ export type OverwriteArgs = Options & {
|
|
|
38
38
|
export type StringArgType = Options & {
|
|
39
39
|
type: 'string';
|
|
40
40
|
};
|
|
41
|
-
export type JSONOutputArgs = Options & {
|
|
41
|
+
export type JSONOutputArgs<J extends Record<string, unknown> = Record<string, unknown>> = Options & {
|
|
42
42
|
json?: boolean;
|
|
43
|
+
jsonSchema?: boolean;
|
|
43
44
|
formatOutputAsJson?: boolean;
|
|
45
|
+
addJsonOutput: (data: Partial<J>) => void;
|
|
44
46
|
};
|
|
45
47
|
export type ProjectDevArgs = CommonArgs & ConfigArgs & EnvironmentArgs & {
|
|
46
48
|
profile?: string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import { ProjectConfig } from '../../../types/Projects.js';
|
|
3
|
-
import { ProjectDevArgs } from '../../../types/Yargs.js';
|
|
4
|
-
type DeprecatedProjectDevFlowArgs = {
|
|
5
|
-
args: ArgumentsCamelCase<ProjectDevArgs>;
|
|
6
|
-
accountId: number;
|
|
7
|
-
projectConfig: ProjectConfig;
|
|
8
|
-
projectDir: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function deprecatedProjectDevFlow({ args, accountId, projectConfig, projectDir, }: DeprecatedProjectDevFlowArgs): Promise<void>;
|
|
11
|
-
export {};
|