@hubspot/cli 8.16.0 → 8.17.0-beta.1

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.
Files changed (39) hide show
  1. package/bin/cli.js +19 -1
  2. package/commands/cms/lighthouseScore.js +1 -1
  3. package/commands/mcp/setup.d.ts +1 -0
  4. package/commands/mcp/setup.js +8 -1
  5. package/commands/project/download.d.ts +2 -0
  6. package/commands/project/download.js +56 -16
  7. package/lang/en.d.ts +61 -6
  8. package/lang/en.js +168 -11
  9. package/lib/agentHelp.d.ts +17 -0
  10. package/lib/agentHelp.js +90 -0
  11. package/lib/app/migrate.js +2 -5
  12. package/lib/commonOpts.js +4 -0
  13. package/lib/jsonOutput/projectDownload.d.ts +1 -0
  14. package/lib/jsonOutput/projectDownload.js +1 -0
  15. package/lib/mcp/clients.d.ts +2 -1
  16. package/lib/mcp/clients.js +7 -7
  17. package/lib/mcp/setup.d.ts +1 -1
  18. package/lib/mcp/setup.js +21 -36
  19. package/lib/mcp/skills.d.ts +8 -0
  20. package/lib/mcp/skills.js +64 -0
  21. package/lib/projects/archive.d.ts +8 -0
  22. package/lib/projects/archive.js +104 -0
  23. package/lib/projects/archiveDiff.d.ts +12 -0
  24. package/lib/projects/archiveDiff.js +68 -0
  25. package/lib/projects/config.js +1 -1
  26. package/lib/projects/download.d.ts +37 -0
  27. package/lib/projects/download.js +123 -0
  28. package/lib/projects/localDev/LocalDevWatcher.js +2 -1
  29. package/lib/prompts/importDataTestAccountSelectPrompt.js +1 -1
  30. package/lib/validation.js +16 -1
  31. package/lib/yargs/makeWrappedYargsHandler.d.ts +1 -0
  32. package/lib/yargs/makeWrappedYargsHandler.js +7 -0
  33. package/mcp-server/skills/hubspot-fix-build/SKILL.md +61 -0
  34. package/mcp-server/skills/hubspot-new-app/SKILL.md +84 -0
  35. package/mcp-server/tools/project/DocFetchTool.d.ts +4 -1
  36. package/mcp-server/tools/project/DocFetchTool.js +52 -7
  37. package/mcp-server/tools/project/FindProjectsTool.js +4 -1
  38. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +1 -1
  39. package/package.json +6 -8
package/bin/cli.js CHANGED
@@ -39,6 +39,8 @@ import { initializeSpinniesManager } from '../lib/middleware/spinniesMiddleware.
39
39
  import { addCommandSuggestions } from '../lib/commandSuggestion.js';
40
40
  import { pkg } from '../lib/jsonLoader.js';
41
41
  import { parseYargsOrExit } from '../lib/yargs/parseYargsOrExit.js';
42
+ import { getRootAgentHelp, recordCommands } from '../lib/agentHelp.js';
43
+ import { hasFlag } from '../lib/utils/hasFlag.js';
42
44
  function getTerminalWidth() {
43
45
  const width = yargs().terminalWidth();
44
46
  if (width >= 100)
@@ -61,7 +63,16 @@ function handleFailure(msg, err, yargs) {
61
63
  process.exit(EXIT_CODES.ERROR);
62
64
  }
63
65
  }
64
- const argv = yargs(process.argv.slice(2))
66
+ const isAgentHelp = hasFlag('agent-help');
67
+ const isRootAgentHelp = isAgentHelp && process.argv.slice(2).every(arg => arg.startsWith('-'));
68
+ // --agent-help shows the normal help, so the command never runs. Some
69
+ // builders read process.argv directly, so --help goes there too.
70
+ if (isAgentHelp) {
71
+ process.argv.splice(process.argv.indexOf('--agent-help') + 1, 0, '--help');
72
+ }
73
+ const rootYargs = yargs(process.argv.slice(2));
74
+ const rootCommands = isRootAgentHelp ? recordCommands(rootYargs) : [];
75
+ const argv = rootYargs
65
76
  .usage('The command line interface to interact with HubSpot.')
66
77
  .middleware([
67
78
  setCLILogLevel,
@@ -98,6 +109,10 @@ const argv = yargs(process.argv.slice(2))
98
109
  default: false,
99
110
  hidden: true,
100
111
  type: 'boolean',
112
+ })
113
+ .option('agent-help', {
114
+ describe: lib.commonOpts.options.agentHelp,
115
+ type: 'boolean',
101
116
  })
102
117
  .check(performChecks)
103
118
  // Getting started / important
@@ -126,6 +141,9 @@ const argv = yargs(process.argv.slice(2))
126
141
  .command(doctorCommand)
127
142
  .command(mcpCommand)
128
143
  .command(upgradeCommand);
144
+ if (isRootAgentHelp) {
145
+ argv.epilogue(await getRootAgentHelp(rootCommands));
146
+ }
129
147
  const parser = addCommandSuggestions(argv)
130
148
  .help()
131
149
  .alias('h', 'help')
@@ -113,7 +113,7 @@ async function handler(args) {
113
113
  desktopScoreStatus = data;
114
114
  }
115
115
  let mobileScoreStatus = 'COMPLETED';
116
- if (includeDesktopScore) {
116
+ if (includeMobileScore) {
117
117
  const { data } = await getLighthouseScoreStatus(derivedAccountId, {
118
118
  themeId: requestResult.mobileId,
119
119
  });
@@ -3,6 +3,7 @@ interface MCPSetupArgs extends CommonArgs {
3
3
  client?: string[];
4
4
  standalone?: boolean;
5
5
  cliVersion?: string;
6
+ skills?: string[];
6
7
  }
7
8
  declare const mcpSetupCommand: YargsCommandModule<unknown, MCPSetupArgs>;
8
9
  export default mcpSetupCommand;
@@ -3,6 +3,7 @@ import { makeYargsBuilder } from '../../lib/yargsUtils.js';
3
3
  import { commands } from '../../lang/en.js';
4
4
  import { makeWrappedYargsHandler } from '../../lib/yargs/makeWrappedYargsHandler.js';
5
5
  import { configureMcpServer, supportedTools } from '../../lib/mcp/setup.js';
6
+ import { MCP_SKILL_NAMES } from '../../lib/mcp/skills.js';
6
7
  const command = ['setup'];
7
8
  const describe = commands.mcp.setup.describe;
8
9
  async function handler(args) {
@@ -12,6 +13,7 @@ async function handler(args) {
12
13
  targets: args.client,
13
14
  standalone: args.standalone,
14
15
  cliVersion: args.cliVersion,
16
+ skills: args.skills,
15
17
  });
16
18
  }
17
19
  catch (e) {
@@ -33,6 +35,11 @@ function setupBuilder(yargs) {
33
35
  describe: commands.mcp.setup.args.cliVersion,
34
36
  type: 'string',
35
37
  });
38
+ yargs.option('skills', {
39
+ describe: commands.mcp.setup.args.skills,
40
+ type: 'array',
41
+ choices: MCP_SKILL_NAMES,
42
+ });
36
43
  yargs.check(argv => {
37
44
  if (argv.cliVersion !== undefined && argv.standalone !== true) {
38
45
  throw new Error(commands.mcp.setup.errors.cliVersionRequiresStandalone);
@@ -41,7 +48,7 @@ function setupBuilder(yargs) {
41
48
  });
42
49
  yargs.example([
43
50
  [
44
- '$0 mcp setup --client claude --no-standalone',
51
+ '$0 mcp setup --client claude --no-standalone --skills hubspot-new-app hubspot-fix-build',
45
52
  commands.mcp.setup.examples.nonInteractive,
46
53
  ],
47
54
  [
@@ -4,6 +4,8 @@ export type ProjectDownloadArgs = CommonArgs & ConfigArgs & AccountArgs & Enviro
4
4
  project?: string;
5
5
  dest?: string;
6
6
  build?: number;
7
+ force?: boolean;
8
+ keepLocalFiles?: boolean;
7
9
  };
8
10
  declare const projectDownloadCommand: YargsCommandModule<unknown, ProjectDownloadArgs>;
9
11
  export default projectDownloadCommand;
@@ -1,10 +1,9 @@
1
- import path from 'path';
2
- import { getCwd, sanitizeFileName } from '@hubspot/local-dev-lib/path';
3
- import { extractZipArchive } from '@hubspot/local-dev-lib/archive';
4
1
  import { downloadProject, fetchProjectBuilds, } from '@hubspot/local-dev-lib/api/projects';
5
2
  import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
6
3
  import { isPromptExitError } from '../../lib/errors/PromptExitError.js';
7
- import { getIsInProject } from '../../lib/projects/config.js';
4
+ import { confirmPrompt } from '../../lib/prompts/promptUtils.js';
5
+ import { archiveDestExists, moveSourceToProjectArchive, } from '../../lib/projects/archive.js';
6
+ import { describeArchiveLocation, extractBuild, getDisplayPath, getLocalProject, handleArchivedSource, resolveDownloadDestination, } from '../../lib/projects/download.js';
8
7
  import { downloadProjectPrompt } from '../../lib/prompts/downloadProjectPrompt.js';
9
8
  import { commands } from '../../lang/en.js';
10
9
  import { uiLogger } from '../../lib/ui/logger.js';
@@ -15,15 +14,14 @@ import { ProjectDownloadSchema, } from '../../lib/jsonOutput/projectDownload.js'
15
14
  const command = 'download';
16
15
  const describe = commands.project.download.describe;
17
16
  async function handler(args) {
18
- const { dest, build, derivedAccountId, exit, addJsonOutput } = args;
19
- const isInProjectDir = getIsInProject();
20
- if (isInProjectDir) {
21
- uiLogger.error(commands.project.download.warnings.cannotDownloadWithinProject);
22
- return exit(EXIT_CODES.ERROR);
23
- }
17
+ const { project: projectArg, dest, build, force, keepLocalFiles, derivedAccountId, formatOutputAsJson, exit, addJsonOutput, } = args;
24
18
  let buildNumberToDownload = build;
25
19
  try {
26
- const { project: projectName } = await downloadProjectPrompt(args);
20
+ const localProject = getLocalProject();
21
+ const { project: projectName } = await downloadProjectPrompt({
22
+ ...args,
23
+ project: projectArg || localProject?.projectName,
24
+ });
27
25
  if (!buildNumberToDownload) {
28
26
  const { data: projectBuildsResult } = await fetchProjectBuilds(derivedAccountId, projectName);
29
27
  const { results: projectBuilds } = projectBuildsResult;
@@ -36,16 +34,46 @@ async function handler(args) {
36
34
  uiLogger.error(commands.project.download.errors.noBuildIdToDownload);
37
35
  return exit(EXIT_CODES.ERROR);
38
36
  }
39
- const sanitizedProjectName = sanitizeFileName(projectName);
40
- const absoluteDestPath = dest
41
- ? path.resolve(getCwd(), dest, sanitizedProjectName)
42
- : path.resolve(getCwd(), sanitizedProjectName);
37
+ const { absoluteDestPath, archivePlan } = resolveDownloadDestination({
38
+ projectName,
39
+ dest,
40
+ localProject,
41
+ });
42
+ if (archivePlan && archiveDestExists(archivePlan.archiveDest)) {
43
+ uiLogger.error(commands.project.download.errors.archiveAlreadyExists(getDisplayPath(archivePlan.archiveDest)));
44
+ return exit(EXIT_CODES.ERROR);
45
+ }
46
+ if (archivePlan && !force && !formatOutputAsJson) {
47
+ uiLogger.warn(commands.project.download.warnings.sourceWillBeArchived(describeArchiveLocation(archivePlan)));
48
+ uiLogger.log('');
49
+ const confirmed = await confirmPrompt(commands.project.download.prompts.confirmDownload(buildNumberToDownload, projectName), { defaultAnswer: false });
50
+ if (!confirmed) {
51
+ uiLogger.log(commands.project.download.logs.downloadCancelled);
52
+ return exit(EXIT_CODES.SUCCESS);
53
+ }
54
+ }
43
55
  const { data: zippedProject } = await downloadProject(derivedAccountId, projectName, buildNumberToDownload);
44
- await extractZipArchive(zippedProject, sanitizeFileName(projectName), path.resolve(absoluteDestPath));
56
+ if (archivePlan) {
57
+ moveSourceToProjectArchive(archivePlan.projectDir, archivePlan.srcDir);
58
+ }
59
+ await extractBuild({
60
+ zippedProject,
61
+ projectName,
62
+ absoluteDestPath,
63
+ archivePlan,
64
+ });
65
+ if (archivePlan) {
66
+ await handleArchivedSource({
67
+ archivePlan,
68
+ keepLocalFiles,
69
+ canPrompt: !force && !formatOutputAsJson,
70
+ });
71
+ }
45
72
  addJsonOutput({
46
73
  projectName,
47
74
  buildId: buildNumberToDownload,
48
75
  dest: absoluteDestPath,
76
+ archiveDest: archivePlan?.archiveDest,
49
77
  });
50
78
  uiLogger.log(commands.project.download.logs.downloadSucceeded(buildNumberToDownload, projectName));
51
79
  return exit(EXIT_CODES.SUCCESS);
@@ -76,12 +104,24 @@ function projectDownloadBuilder(yargs) {
76
104
  alias: ['build-id'],
77
105
  type: 'number',
78
106
  },
107
+ force: {
108
+ describe: commands.project.download.options.force.describe,
109
+ type: 'boolean',
110
+ },
111
+ 'keep-local-files': {
112
+ describe: commands.project.download.options.keepLocalFiles.describe,
113
+ type: 'boolean',
114
+ },
79
115
  });
80
116
  yargs.example([
81
117
  [
82
118
  '$0 project download --project=myProject --dest=myProjectFolder',
83
119
  commands.project.download.examples.default,
84
120
  ],
121
+ [
122
+ '$0 project download --build=3',
123
+ commands.project.download.examples.currentProject,
124
+ ],
85
125
  [
86
126
  '$0 project download --project=myProject --json',
87
127
  commands.project.download.examples.json,
package/lang/en.d.ts CHANGED
@@ -1326,7 +1326,6 @@ export declare const commands: {
1326
1326
  claudeCode: string;
1327
1327
  cursor: string;
1328
1328
  devin: string;
1329
- gemini: string;
1330
1329
  opencode: string;
1331
1330
  vsCode: string;
1332
1331
  other: string;
@@ -1334,6 +1333,7 @@ export declare const commands: {
1334
1333
  client: string;
1335
1334
  standalone: string;
1336
1335
  cliVersion: string;
1336
+ skills: string;
1337
1337
  docsSearch: string;
1338
1338
  };
1339
1339
  examples: {
@@ -1359,10 +1359,6 @@ export declare const commands: {
1359
1359
  cursorNotFound: string;
1360
1360
  failedToConfigureCursor: string;
1361
1361
  configuredCursor: string;
1362
- configuringGemini: string;
1363
- configuredGemini: string;
1364
- geminiNotFound: string;
1365
- geminiInstallFailed: string;
1366
1362
  alreadyInstalled: string;
1367
1363
  configuringDevin: string;
1368
1364
  devinNotFound: string;
@@ -1377,18 +1373,27 @@ export declare const commands: {
1377
1373
  configuredVsCode: string;
1378
1374
  vsCodeNotFound: string;
1379
1375
  vsCodeVersionUnsupported: string;
1376
+ installingSkills: string;
1377
+ installedSkills: (skillNames: string[], targetDirs: string[]) => string;
1378
+ failedToInstallSkills: string;
1380
1379
  };
1381
1380
  otherInstructions: {
1382
1381
  header: string;
1383
1382
  docsNote: string;
1384
1383
  commandLabel: string;
1385
1384
  jsonLabel: string;
1385
+ skillsNote: (skillsDir: string) => string;
1386
1386
  };
1387
1387
  prompts: {
1388
1388
  targets: string;
1389
1389
  targetsRequired: string;
1390
1390
  standaloneMode: string;
1391
1391
  cliVersion: string;
1392
+ selectSkills: string;
1393
+ };
1394
+ skillDescriptions: {
1395
+ newApp: string;
1396
+ fixBuild: string;
1392
1397
  };
1393
1398
  };
1394
1399
  start: {
@@ -2007,24 +2012,43 @@ export declare const commands: {
2007
2012
  describe: string;
2008
2013
  examples: {
2009
2014
  default: string;
2015
+ currentProject: string;
2010
2016
  json: string;
2011
2017
  };
2012
2018
  logs: {
2013
2019
  downloadCancelled: string;
2014
2020
  downloadSucceeded: (buildId: number, projectName: string) => string;
2021
+ filesOnlyInArchive: (files: string[], hiddenCount: number, diffFilePath?: string) => string;
2022
+ filesCopiedBack: (copiedCount: number, srcPath: string) => string;
2023
+ sourceContentsArchived: (archiveLocation: string) => string;
2015
2024
  };
2016
2025
  errors: {
2017
2026
  downloadFailed: string;
2018
2027
  projectNotFound: (projectName: string, accountId: string) => string;
2019
2028
  noBuildIdToDownload: string;
2029
+ restoreFailed: (archiveDest: string) => string;
2030
+ archiveAlreadyExists: (archiveDest: string) => string;
2020
2031
  };
2021
2032
  warnings: {
2022
- cannotDownloadWithinProject: string;
2033
+ filesNotCopiedBack: (failedCount: number) => string;
2034
+ sourceWillBeArchived: (archiveLocation: string) => string;
2035
+ sourceRestored: string;
2036
+ };
2037
+ archiveLocation: (archivePath: string) => string;
2038
+ prompts: {
2039
+ confirmCopyFilesBack: (fileCount: number) => string;
2040
+ confirmDownload: (buildId: number, projectName: string) => string;
2023
2041
  };
2024
2042
  options: {
2025
2043
  build: {
2026
2044
  describe: string;
2027
2045
  };
2046
+ force: {
2047
+ describe: string;
2048
+ };
2049
+ keepLocalFiles: {
2050
+ describe: string;
2051
+ };
2028
2052
  project: {
2029
2053
  describe: string;
2030
2054
  };
@@ -3385,6 +3409,28 @@ export declare const lib: {
3385
3409
  noSchemaForCommand: string;
3386
3410
  validationFailed: string;
3387
3411
  };
3412
+ agentHelp: {
3413
+ headings: {
3414
+ conventions: string;
3415
+ jsonOutput: string;
3416
+ workflows: string;
3417
+ exitCodes: string;
3418
+ commands: string;
3419
+ };
3420
+ conventions: string[];
3421
+ jsonOutput: {
3422
+ schema: string;
3423
+ noSchema: string;
3424
+ };
3425
+ workflows: {
3426
+ title: string;
3427
+ steps: {
3428
+ command: string;
3429
+ description: string;
3430
+ }[];
3431
+ }[];
3432
+ exitCodes: string;
3433
+ };
3388
3434
  DevServerManager: {
3389
3435
  portConflict: (port: string) => string;
3390
3436
  notInitialized: string;
@@ -3612,6 +3658,12 @@ export declare const lib: {
3612
3658
  generateSafeFilenameDifferentiator: {
3613
3659
  failedToCheckFiles: string;
3614
3660
  };
3661
+ archive: {
3662
+ errors: {
3663
+ archiveNotFound: (archiveDest: string) => string;
3664
+ srcDirInsideArchive: (srcDir: string) => string;
3665
+ };
3666
+ };
3615
3667
  validateProjectConfig: {
3616
3668
  configNotFound: string;
3617
3669
  };
@@ -3865,6 +3917,7 @@ export declare const lib: {
3865
3917
  useEnv: string;
3866
3918
  jsonOutput: string;
3867
3919
  jsonSchema: string;
3920
+ agentHelp: string;
3868
3921
  debug: string;
3869
3922
  color: string;
3870
3923
  };
@@ -3925,6 +3978,7 @@ export declare const lib: {
3925
3978
  message: (dataFileNames: string[], cliAccount: HubSpotConfigAccount | null) => string;
3926
3979
  };
3927
3980
  importDataTestAccountSelectPrompt: {
3981
+ message: string;
3928
3982
  errors: {
3929
3983
  noAccountsFound: string;
3930
3984
  noChildTestAccountsFound: (parentAccountId: number) => string;
@@ -4452,6 +4506,7 @@ export declare const lib: {
4452
4506
  oauth2AccessTokenNotFound: (accountId: number) => string;
4453
4507
  personalAccessKeyMissing: (accountId: number) => string;
4454
4508
  personalAccessKeyTokenRetrievalFailed: (accountId: number) => string;
4509
+ accessTokenMissing: (accountId: number) => string;
4455
4510
  authConfigurationMissing: (accountId: number) => string;
4456
4511
  availableCMSModes: (modes: string) => string;
4457
4512
  invalidCmsPublishMode: (cmsPublishMode: string, modesMessage: string) => string;