@phnx-labs/agents-cli 1.20.0 → 1.20.3

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 (105) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +4 -4
  3. package/dist/commands/cli.js +3 -3
  4. package/dist/commands/cloud.js +1 -1
  5. package/dist/commands/commands.js +24 -7
  6. package/dist/commands/exec.js +36 -16
  7. package/dist/commands/feedback.d.ts +7 -0
  8. package/dist/commands/feedback.js +89 -0
  9. package/dist/commands/helper.d.ts +12 -0
  10. package/dist/commands/helper.js +87 -0
  11. package/dist/commands/hooks.js +86 -7
  12. package/dist/commands/mcp.js +166 -10
  13. package/dist/commands/packages.js +196 -27
  14. package/dist/commands/permissions.js +21 -6
  15. package/dist/commands/profiles.d.ts +8 -0
  16. package/dist/commands/profiles.js +117 -4
  17. package/dist/commands/pull.js +4 -4
  18. package/dist/commands/routines.js +6 -6
  19. package/dist/commands/rules.js +8 -4
  20. package/dist/commands/secrets-migrate.d.ts +24 -0
  21. package/dist/commands/secrets-migrate.js +198 -0
  22. package/dist/commands/secrets-sync.d.ts +11 -0
  23. package/dist/commands/secrets-sync.js +155 -0
  24. package/dist/commands/secrets.js +74 -39
  25. package/dist/commands/skills.js +22 -5
  26. package/dist/commands/subagents.js +69 -49
  27. package/dist/commands/teams.js +48 -10
  28. package/dist/commands/utils.d.ts +33 -0
  29. package/dist/commands/utils.js +139 -0
  30. package/dist/commands/versions.js +4 -4
  31. package/dist/commands/view.d.ts +6 -0
  32. package/dist/commands/view.js +164 -8
  33. package/dist/commands/workflows.js +29 -6
  34. package/dist/index.js +4 -0
  35. package/dist/lib/acp/client.js +6 -1
  36. package/dist/lib/agents.d.ts +4 -0
  37. package/dist/lib/agents.js +18 -14
  38. package/dist/lib/auto-pull-worker.js +18 -1
  39. package/dist/lib/browser/chrome.js +4 -0
  40. package/dist/lib/browser/drivers/ssh.js +1 -1
  41. package/dist/lib/browser/profiles.d.ts +3 -3
  42. package/dist/lib/browser/profiles.js +3 -3
  43. package/dist/lib/browser/service.js +19 -0
  44. package/dist/lib/browser/types.d.ts +4 -4
  45. package/dist/lib/cli-resources.d.ts +36 -8
  46. package/dist/lib/cli-resources.js +268 -46
  47. package/dist/lib/cloud/factory.d.ts +1 -1
  48. package/dist/lib/cloud/factory.js +1 -1
  49. package/dist/lib/events.d.ts +16 -2
  50. package/dist/lib/events.js +33 -2
  51. package/dist/lib/exec.d.ts +39 -11
  52. package/dist/lib/exec.js +90 -31
  53. package/dist/lib/help.js +11 -5
  54. package/dist/lib/hooks/cache.d.ts +38 -0
  55. package/dist/lib/hooks/cache.js +242 -0
  56. package/dist/lib/hooks/profile.d.ts +33 -0
  57. package/dist/lib/hooks/profile.js +129 -0
  58. package/dist/lib/hooks.d.ts +0 -10
  59. package/dist/lib/hooks.js +68 -15
  60. package/dist/lib/mcp.d.ts +15 -0
  61. package/dist/lib/mcp.js +40 -0
  62. package/dist/lib/permissions.d.ts +13 -0
  63. package/dist/lib/permissions.js +51 -1
  64. package/dist/lib/plugins.js +15 -1
  65. package/dist/lib/profiles-presets.d.ts +26 -0
  66. package/dist/lib/profiles-presets.js +187 -8
  67. package/dist/lib/profiles.d.ts +34 -0
  68. package/dist/lib/profiles.js +112 -1
  69. package/dist/lib/routines-format.d.ts +17 -5
  70. package/dist/lib/routines-format.js +37 -16
  71. package/dist/lib/routines.d.ts +1 -1
  72. package/dist/lib/routines.js +2 -2
  73. package/dist/lib/runner.js +64 -10
  74. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  75. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  76. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +1 -9
  77. package/dist/lib/secrets/bundles.d.ts +18 -22
  78. package/dist/lib/secrets/bundles.js +75 -99
  79. package/dist/lib/secrets/index.d.ts +51 -27
  80. package/dist/lib/secrets/index.js +147 -156
  81. package/dist/lib/secrets/install-helper.d.ts +45 -0
  82. package/dist/lib/secrets/install-helper.js +165 -0
  83. package/dist/lib/secrets/linux.js +4 -4
  84. package/dist/lib/secrets/sync.d.ts +56 -0
  85. package/dist/lib/secrets/sync.js +180 -0
  86. package/dist/lib/session/render.js +4 -4
  87. package/dist/lib/session/types.d.ts +1 -1
  88. package/dist/lib/shims.d.ts +4 -1
  89. package/dist/lib/shims.js +5 -35
  90. package/dist/lib/state.d.ts +14 -1
  91. package/dist/lib/state.js +49 -5
  92. package/dist/lib/teams/agents.d.ts +5 -4
  93. package/dist/lib/teams/agents.js +47 -21
  94. package/dist/lib/teams/api.d.ts +2 -1
  95. package/dist/lib/teams/api.js +4 -3
  96. package/dist/lib/types.d.ts +57 -1
  97. package/dist/lib/types.js +2 -0
  98. package/dist/lib/usage.d.ts +27 -2
  99. package/dist/lib/usage.js +100 -17
  100. package/dist/lib/versions.d.ts +35 -1
  101. package/dist/lib/versions.js +267 -64
  102. package/package.json +9 -8
  103. package/scripts/install-helper.js +97 -0
  104. package/scripts/postinstall.js +16 -0
  105. package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
@@ -3,20 +3,49 @@ import ora from 'ora';
3
3
  import { checkbox } from '@inquirer/prompts';
4
4
  import { AGENTS, MCP_CAPABLE_AGENTS, getAllCliStates, resolveAgentName, formatAgentError, registerMcpToTargets, unregisterMcpFromTargets, listInstalledMcpsWithScope, parseMcpConfig, getMcpConfigPathForHome, agentLabel, } from '../lib/agents.js';
5
5
  import { readManifest, writeManifest, createDefaultManifest } from '../lib/manifest.js';
6
- import { listMcpServerConfigs } from '../lib/mcp.js';
6
+ import { listMcpServerConfigs, discoverMcpConfigsFromRepo, installMcpConfigCentrally, } from '../lib/mcp.js';
7
+ import { cloneRepo } from '../lib/git.js';
7
8
  import { getMcpDir } from '../lib/state.js';
8
- import { getEffectiveHome, getGlobalDefault, listInstalledVersions, getVersionHomePath, resolveInstalledAgentTargets, resolveConfiguredAgentTargets, resolveVersionAlias, } from '../lib/versions.js';
9
+ import { getEffectiveHome, getGlobalDefault, listInstalledVersions, getVersionHomePath, resolveInstalledAgentTargets, resolveConfiguredAgentTargets, resolveVersionAlias, syncResourcesToVersion, } from '../lib/versions.js';
9
10
  import { getUserAgentsDir } from '../lib/state.js';
10
- import { isPromptCancelled, isInteractiveTerminal, requireInteractiveSelection, promptRemovalTargets } from './utils.js';
11
+ import { isPromptCancelled, isInteractiveTerminal, requireInteractiveSelection, promptRemovalTargets, parseCommaSeparatedList, ensureAgentVersionsInstalled, resolveAgentTargetsAutoInstalling, resolveInstalledAgentTargetsAutoInstalling, VersionNotInstalledError, } from './utils.js';
11
12
  import { showResourceList, buildTargetsSection, } from './resource-view.js';
12
- /** Parse a comma-separated --agents string into validated agent IDs and optional version targets. */
13
+ /**
14
+ * Parse a comma-separated --agents string into validated agent IDs and
15
+ * optional version targets in the manifest shape.
16
+ *
17
+ * Supports the same selector syntax as resolveAgentVersionTargets:
18
+ * - bare `agent` → manifest agents:[agent] (no version pin)
19
+ * - `agent@default` → manifest agents:[agent] (no version pin)
20
+ * - `agent@x.y.z` → manifest agentVersions[agent] = ['x.y.z']
21
+ * - `agent@all` → manifest agentVersions[agent] = every installed version
22
+ * - literal `all` → expand to all MCP-capable agents (each as `@all`)
23
+ *
24
+ * Throws VersionNotInstalledError for unknown specific versions so callers
25
+ * can prompt-and-install before retrying.
26
+ */
13
27
  function parseMcpAgentTargets(value) {
14
28
  const agents = [];
15
29
  const agentVersions = {};
16
- const targets = value
30
+ const rawTargets = value
17
31
  .split(',')
18
32
  .map((item) => item.trim())
19
33
  .filter(Boolean);
34
+ // Expand literal `all` / `all@all` into per-agent @all. Skip agents with no
35
+ // installed versions so `all` is lenient — mirrors resolveAgentVersionTargets.
36
+ const targets = [];
37
+ for (const t of rawTargets) {
38
+ if (t === 'all' || t === 'all@all') {
39
+ for (const a of MCP_CAPABLE_AGENTS) {
40
+ if (listInstalledVersions(a).length > 0) {
41
+ targets.push(`${a}@all`);
42
+ }
43
+ }
44
+ }
45
+ else {
46
+ targets.push(t);
47
+ }
48
+ }
20
49
  for (const target of targets) {
21
50
  const atIndex = target.indexOf('@');
22
51
  const agentToken = (atIndex === -1 ? target : target.slice(0, atIndex)).trim();
@@ -25,7 +54,7 @@ function parseMcpAgentTargets(value) {
25
54
  continue;
26
55
  }
27
56
  if (atIndex !== -1 && !versionToken) {
28
- throw new Error(`Missing version in --agents entry '${target}'. Use agent@x.y.z or agent@default.`);
57
+ throw new Error(`Missing version in --agents entry '${target}'. Use agent@x.y.z, agent@default, or agent@all.`);
29
58
  }
30
59
  const agentId = resolveAgentName(agentToken);
31
60
  if (!agentId || !MCP_CAPABLE_AGENTS.includes(agentId)) {
@@ -50,11 +79,23 @@ function parseMcpAgentTargets(value) {
50
79
  if (installedVersions.length === 0) {
51
80
  throw new Error(`No managed versions are installed for ${AGENTS[agentId].name}. Run: agents add ${agentId}@latest`);
52
81
  }
82
+ if (versionToken === 'all') {
83
+ const versions = agentVersions[agentId] || [];
84
+ for (const ver of installedVersions) {
85
+ if (!versions.includes(ver))
86
+ versions.push(ver);
87
+ }
88
+ agentVersions[agentId] = versions;
89
+ if (!agents.includes(agentId)) {
90
+ agents.push(agentId);
91
+ }
92
+ continue;
93
+ }
53
94
  const resolvedVersion = versionToken === 'latest'
54
95
  ? installedVersions[installedVersions.length - 1]
55
96
  : versionToken;
56
97
  if (!installedVersions.includes(resolvedVersion)) {
57
- throw new Error(`Version ${resolvedVersion} is not installed for ${AGENTS[agentId].name}. Installed versions: ${installedVersions.join(', ')}`);
98
+ throw new VersionNotInstalledError(agentId, resolvedVersion, installedVersions);
58
99
  }
59
100
  const versions = agentVersions[agentId] || [];
60
101
  if (!versions.includes(resolvedVersion)) {
@@ -140,6 +181,8 @@ When to use:
140
181
  .option('-a, --agents <list>', 'Targets: claude, codex@0.116.0', MCP_CAPABLE_AGENTS.join(','))
141
182
  .option('-s, --scope <scope>', 'user (global) or project (repo-specific)', 'user')
142
183
  .option('-t, --transport <type>', 'stdio (default) or http', 'stdio')
184
+ .option('--names <list>', 'When source is a repo: MCP server names to install (comma-separated)')
185
+ .option('-y, --yes', 'Auto-install any missing agent versions without prompting')
143
186
  .option('-H, --header <header>', 'HTTP header as name:value (repeatable)', (val, acc) => {
144
187
  acc.push(val);
145
188
  return acc;
@@ -154,8 +197,22 @@ Examples:
154
197
 
155
198
  # Add to manifest only (register later)
156
199
  agents mcp add db-server -- uvx postgres-mcp
200
+
201
+ # Install all MCP server configs from a repo's mcp/*.yaml
202
+ agents mcp add gh:user/repo --agents claude@all
203
+
204
+ # Install specific servers by name
205
+ agents mcp add gh:phnx-labs/.agents-system --names notion,figma --agents claude
157
206
  `)
158
207
  .action(async (name, commandOrUrl, options) => {
208
+ // Repo-source form: `agents mcp add gh:user/repo [--names a,b] [--agents …]`
209
+ // Mirrors `agents skills add gh:…`. Discovers <repoPath>/mcp/*.yaml,
210
+ // copies to ~/.agents/mcp/, and syncs to selected agent versions.
211
+ const isRepoSource = /^(gh:|git:|ssh:|https?:\/\/)/.test(name);
212
+ if (isRepoSource && commandOrUrl.length === 0) {
213
+ await installMcpsFromRepoSource(name, options);
214
+ return;
215
+ }
159
216
  // Registry resolution: if the user just typed `agents mcp add <name>`,
160
217
  // try looking up `<name>` in any configured MCP registry (by default the
161
218
  // official MCP Registry at registry.modelcontextprotocol.io) and derive
@@ -195,6 +252,13 @@ Examples:
195
252
  const localPath = getUserAgentsDir();
196
253
  const manifest = readManifest(localPath) || createDefaultManifest();
197
254
  manifest.mcp = manifest.mcp || {};
255
+ // Pre-flight: prompt-and-install any requested agent@version that isn't
256
+ // installed yet, before parseMcpAgentTargets validates the selector.
257
+ const okInstall = await ensureAgentVersionsInstalled(options.agents, MCP_CAPABLE_AGENTS, { yes: options.yes });
258
+ if (!okInstall) {
259
+ console.log(chalk.gray('Cancelled.'));
260
+ return;
261
+ }
198
262
  const targetConfig = parseMcpAgentTargets(options.agents);
199
263
  if (transport === 'http') {
200
264
  const url = commandOrUrl[0];
@@ -459,6 +523,7 @@ Examples:
459
523
  .command('register [name]')
460
524
  .description('Apply MCP servers from manifest to agent config files')
461
525
  .option('-a, --agents <list>', 'Override manifest targets: claude, codex@0.116.0')
526
+ .option('-y, --yes', 'Auto-install any missing agent versions without prompting')
462
527
  .addHelpText('after', `
463
528
  Examples:
464
529
  # Register all servers from manifest
@@ -495,9 +560,18 @@ Examples:
495
560
  continue;
496
561
  }
497
562
  console.log(`\n ${chalk.cyan(mcpName)}:`);
498
- const targets = options.agents
499
- ? resolveInstalledAgentTargets(options.agents, MCP_CAPABLE_AGENTS)
500
- : resolveConfiguredAgentTargets(config.agents, config.agentVersions, MCP_CAPABLE_AGENTS);
563
+ let targets;
564
+ if (options.agents) {
565
+ const resolved = await resolveInstalledAgentTargetsAutoInstalling(options.agents, MCP_CAPABLE_AGENTS, { yes: options.yes });
566
+ if (!resolved) {
567
+ console.log(chalk.gray(' Cancelled.'));
568
+ continue;
569
+ }
570
+ targets = resolved;
571
+ }
572
+ else {
573
+ targets = resolveConfiguredAgentTargets(config.agents, config.agentVersions, MCP_CAPABLE_AGENTS);
574
+ }
501
575
  const results = await registerMcpToTargets(targets, mcpName, commandOrUrl, config.scope || 'user', transport, { headers: config.headers });
502
576
  for (const result of results) {
503
577
  if (result.success) {
@@ -513,6 +587,88 @@ Examples:
513
587
  }
514
588
  });
515
589
  }
590
+ async function installMcpsFromRepoSource(source, options) {
591
+ const spinner = ora('Cloning repository...').start();
592
+ let localPath;
593
+ try {
594
+ const cloneResult = await cloneRepo(source);
595
+ localPath = cloneResult.localPath;
596
+ }
597
+ catch (err) {
598
+ spinner.fail(`Failed to clone: ${err.message}`);
599
+ process.exit(1);
600
+ }
601
+ spinner.succeed('Repository cloned');
602
+ let discovered = discoverMcpConfigsFromRepo(localPath);
603
+ if (discovered.length === 0) {
604
+ console.log(chalk.yellow('No MCP server configs found (looking for mcp/*.yaml)'));
605
+ return;
606
+ }
607
+ const requestedNames = parseCommaSeparatedList(options.names);
608
+ if (requestedNames.length > 0) {
609
+ const discoveredNames = new Set(discovered.map((s) => s.name));
610
+ const missing = requestedNames.filter((n) => !discoveredNames.has(n));
611
+ if (missing.length > 0) {
612
+ console.log(chalk.red(`\nMCP server(s) not found in source: ${missing.join(', ')}`));
613
+ console.log(chalk.gray(`Available: ${[...discoveredNames].join(', ')}`));
614
+ process.exit(1);
615
+ }
616
+ discovered = discovered.filter((s) => requestedNames.includes(s.name));
617
+ }
618
+ console.log(chalk.bold(`\nFound ${discovered.length} MCP server config(s):`));
619
+ for (const s of discovered) {
620
+ const summary = s.config.transport === 'stdio'
621
+ ? `${s.config.command}${s.config.args?.length ? ' ' + s.config.args.join(' ') : ''}`
622
+ : s.config.url ?? '';
623
+ console.log(` ${chalk.cyan(s.name)}: ${chalk.gray(summary)}`);
624
+ }
625
+ const installSpinner = ora('Installing MCP configs to ~/.agents/mcp/...').start();
626
+ let installed = 0;
627
+ for (const s of discovered) {
628
+ const result = installMcpConfigCentrally(s.path);
629
+ if (result.success) {
630
+ installed++;
631
+ }
632
+ else {
633
+ installSpinner.stop();
634
+ console.log(chalk.red(` Failed to install ${s.name}: ${result.error}`));
635
+ installSpinner.start();
636
+ }
637
+ }
638
+ installSpinner.succeed(`Installed ${installed} MCP config(s) to ~/.agents/mcp/`);
639
+ // Agent/version selection — same default as the non-repo form: every
640
+ // MCP-capable agent. Routes through resolveAgentTargetsAutoInstalling so
641
+ // a typo'd `claude@2.1.999` prompts to install (and --yes auto-installs).
642
+ const agentsValue = options.agents ?? MCP_CAPABLE_AGENTS.join(',');
643
+ let targets;
644
+ try {
645
+ const resolved = await resolveAgentTargetsAutoInstalling(agentsValue, MCP_CAPABLE_AGENTS, { yes: options.yes });
646
+ if (!resolved) {
647
+ console.log(chalk.gray('\nCancelled.'));
648
+ return;
649
+ }
650
+ targets = resolved;
651
+ }
652
+ catch (err) {
653
+ console.log(chalk.red(err.message));
654
+ process.exit(1);
655
+ }
656
+ if (targets.versionSelections.size === 0) {
657
+ console.log(chalk.gray('\nStored centrally; no agent versions selected for sync.'));
658
+ return;
659
+ }
660
+ const syncSpinner = ora('Syncing to agent versions...').start();
661
+ const mcpNames = discovered.map((s) => s.name);
662
+ let synced = 0;
663
+ for (const [agentId, versions] of targets.versionSelections) {
664
+ for (const version of versions) {
665
+ const result = syncResourcesToVersion(agentId, version, { mcp: mcpNames });
666
+ if (result.mcp.length > 0)
667
+ synced++;
668
+ }
669
+ }
670
+ syncSpinner.succeed(`Synced MCP configs to ${synced} agent version(s).`);
671
+ }
516
672
  /** Enumerate (agent, version) pairs that support MCP and have a version home. */
517
673
  function iterMcpCapableVersions(filter) {
518
674
  const out = [];
@@ -14,10 +14,13 @@ import { cloneRepo } from '../lib/git.js';
14
14
  import { discoverCommands, resolveCommandSource, installCommand, installCommandCentrally, } from '../lib/commands.js';
15
15
  import { discoverSkillsFromRepo, installSkill, installSkillCentrally, } from '../lib/skills.js';
16
16
  import { discoverHooksFromRepo, installHooks, installHooksCentrally, } from '../lib/hooks.js';
17
- import { listInstalledVersions, resolveInstalledAgentTargets, resolveConfiguredAgentTargets, syncResourcesToVersion, } from '../lib/versions.js';
18
- import { isInteractiveTerminal, isPromptCancelled, requireDestructiveArg, requireInteractiveSelection, } from './utils.js';
17
+ import { discoverWorkflowsFromRepo, installWorkflowCentrally, } from '../lib/workflows.js';
18
+ import { discoverSubagentsFromRepo, installSubagentCentrally, } from '../lib/subagents.js';
19
+ import { discoverPermissionsFromRepo, installPermissionSet, } from '../lib/permissions.js';
20
+ import { listInstalledVersions, resolveConfiguredAgentTargets, syncResourcesToVersion, } from '../lib/versions.js';
21
+ import { isInteractiveTerminal, isPromptCancelled, parseCommaSeparatedList, requireDestructiveArg, requireInteractiveSelection, resolveInstalledAgentTargetsAutoInstalling, } from './utils.js';
19
22
  import { itemPicker } from '../lib/picker.js';
20
- import { registerMcpCommandToTargets } from '../lib/mcp.js';
23
+ import { registerMcpCommandToTargets, discoverMcpConfigsFromRepo, installMcpConfigCentrally, } from '../lib/mcp.js';
21
24
  export function buildMcpPackageCommand(pkg) {
22
25
  const packageName = pkg.name || pkg.registry_name;
23
26
  if (pkg.runtime === 'node') {
@@ -326,6 +329,9 @@ When to use:
326
329
  .command('install <identifier>')
327
330
  .description('Install a package by registry name (mcp:notion), GitHub URL (gh:user/repo), or skill identifier')
328
331
  .option('-a, --agents <list>', 'Targets: claude, codex@0.116.0, or gemini@default')
332
+ .option('--types <list>', 'When source is a repo: comma-separated resource types to install (skills,workflows,commands,hooks,permissions,subagents,mcp)')
333
+ .option('--names <list>', 'When source is a repo: comma-separated resource names within the selected types')
334
+ .option('-y, --yes', 'Auto-install any missing agent versions without prompting')
329
335
  .addHelpText('after', `
330
336
  Install resolves the package type (MCP server, skill, command, hook) and installs to the specified agents. Packages can come from registries (mcp:, skill:), GitHub (gh:user/repo), or direct URLs.
331
337
 
@@ -339,6 +345,12 @@ Examples:
339
345
  # Install using GitHub shorthand
340
346
  agents install gh:user/repo --agents claude@2.1.112
341
347
 
348
+ # Install only specific resource types from a multi-resource repo
349
+ agents install gh:phnx-labs/.agents-system --types skills,workflows --agents claude@all
350
+
351
+ # Install specific resources by name
352
+ agents install gh:phnx-labs/.agents-system --types skills --names animator,composer --agents claude@all
353
+
342
354
  # Install to all installed agents (uses defaults or prompts)
343
355
  agents install mcp:postgres
344
356
 
@@ -399,9 +411,18 @@ When to use:
399
411
  }
400
412
  const cliStates = await getAllCliStates();
401
413
  const installedAgents = MCP_CAPABLE_AGENTS.filter((id) => cliStates[id]?.installed || listInstalledVersions(id).length > 0);
402
- const targets = options.agents
403
- ? resolveInstalledAgentTargets(options.agents, MCP_CAPABLE_AGENTS)
404
- : resolveConfiguredAgentTargets(installedAgents, undefined, MCP_CAPABLE_AGENTS);
414
+ let targets;
415
+ if (options.agents) {
416
+ const resolved = await resolveInstalledAgentTargetsAutoInstalling(options.agents, MCP_CAPABLE_AGENTS, { yes: options.yes });
417
+ if (!resolved) {
418
+ console.log(chalk.gray('Cancelled.'));
419
+ return;
420
+ }
421
+ targets = resolved;
422
+ }
423
+ else {
424
+ targets = resolveConfiguredAgentTargets(installedAgents, undefined, MCP_CAPABLE_AGENTS);
425
+ }
405
426
  if (targets.selectedAgents.length === 0) {
406
427
  console.log(chalk.yellow('\nNo MCP-capable agents installed.'));
407
428
  process.exit(1);
@@ -420,38 +441,95 @@ When to use:
420
441
  console.log(chalk.green('\nMCP server installed.'));
421
442
  }
422
443
  else if (resolved.type === 'git' || resolved.type === 'skill') {
423
- // Install from git source (skills/commands/hooks)
444
+ // Install from git source: sniff every resource type the repo
445
+ // contains. Optional --types narrows which kinds get installed;
446
+ // --names narrows which specific resources within those kinds.
424
447
  console.log(chalk.bold(`\nInstalling from ${resolved.source}`));
425
448
  const { localPath } = await cloneRepo(resolved.source);
426
- // Discover what's in the repo
427
- const commands = discoverCommands(localPath);
428
- const skills = discoverSkillsFromRepo(localPath);
429
- const hooks = discoverHooksFromRepo(localPath);
430
- const hasCommands = commands.length > 0;
431
- const hasSkills = skills.length > 0;
432
- const hasHooks = hooks.length > 0;
433
- if (!hasCommands && !hasSkills && !hasHooks) {
449
+ const requestedTypes = new Set(parseCommaSeparatedList(options.types));
450
+ const includeType = (type) => requestedTypes.size === 0 || requestedTypes.has(type);
451
+ const requestedNames = new Set(parseCommaSeparatedList(options.names));
452
+ const nameFilter = (items) => {
453
+ if (requestedNames.size === 0)
454
+ return items;
455
+ return items.filter((item) => requestedNames.has(item.name));
456
+ };
457
+ // Discover everything; filter to requested types up front so the
458
+ // summary table reflects what will actually be installed.
459
+ let commands = includeType('commands') ? discoverCommands(localPath) : [];
460
+ let skills = includeType('skills') ? discoverSkillsFromRepo(localPath) : [];
461
+ let hooks = includeType('hooks') ? discoverHooksFromRepo(localPath) : [];
462
+ let workflows = includeType('workflows') ? discoverWorkflowsFromRepo(localPath) : [];
463
+ let subagents = includeType('subagents') ? discoverSubagentsFromRepo(localPath) : [];
464
+ let permissions = includeType('permissions') ? discoverPermissionsFromRepo(localPath) : [];
465
+ let mcpServers = includeType('mcp') ? discoverMcpConfigsFromRepo(localPath) : [];
466
+ // --names filter applies across every discovered type. If the user
467
+ // typed a name that matched nothing, fail loud so they can fix the
468
+ // typo rather than silently install zero items.
469
+ if (requestedNames.size > 0) {
470
+ const allNames = new Set([
471
+ ...commands.map((c) => c.name),
472
+ ...skills.map((s) => s.name),
473
+ ...hooks,
474
+ ...workflows.map((w) => w.name),
475
+ ...subagents.map((s) => s.name),
476
+ ...permissions.map((p) => p.name),
477
+ ...mcpServers.map((s) => s.name),
478
+ ]);
479
+ const missing = [...requestedNames].filter((n) => !allNames.has(n));
480
+ if (missing.length > 0) {
481
+ console.log(chalk.red(`\nResource(s) not found in repo: ${missing.join(', ')}`));
482
+ console.log(chalk.gray(`Available: ${[...allNames].sort().join(', ')}`));
483
+ process.exit(1);
484
+ }
485
+ commands = nameFilter(commands);
486
+ skills = nameFilter(skills);
487
+ hooks = hooks.filter((h) => requestedNames.has(h));
488
+ workflows = nameFilter(workflows);
489
+ subagents = nameFilter(subagents);
490
+ permissions = nameFilter(permissions);
491
+ mcpServers = nameFilter(mcpServers);
492
+ }
493
+ const summary = [
494
+ { kind: 'commands', count: commands.length },
495
+ { kind: 'skills', count: skills.length },
496
+ { kind: 'hooks', count: hooks.length },
497
+ { kind: 'workflows', count: workflows.length },
498
+ { kind: 'subagents', count: subagents.length },
499
+ { kind: 'permissions', count: permissions.length },
500
+ { kind: 'mcp', count: mcpServers.length },
501
+ ].filter((s) => s.count > 0);
502
+ if (summary.length === 0) {
434
503
  console.log(chalk.yellow('No installable content found in repository.'));
504
+ if (requestedTypes.size > 0 || requestedNames.size > 0) {
505
+ console.log(chalk.gray('Try removing --types/--names to see everything the repo offers.'));
506
+ }
435
507
  process.exit(1);
436
508
  }
437
509
  console.log(chalk.bold('\nFound:'));
438
- if (hasCommands)
439
- console.log(` ${commands.length} commands`);
440
- if (hasSkills)
441
- console.log(` ${skills.length} skills`);
442
- if (hasHooks)
443
- console.log(` ${hooks.length} hooks`);
510
+ for (const { kind, count } of summary) {
511
+ console.log(` ${count} ${kind}`);
512
+ }
444
513
  const gitCliStates = await getAllCliStates();
445
514
  const installedAgents = ALL_AGENT_IDS.filter((id) => gitCliStates[id]?.installed || listInstalledVersions(id).length > 0);
446
- const targets = options.agents
447
- ? resolveInstalledAgentTargets(options.agents, ALL_AGENT_IDS)
448
- : resolveConfiguredAgentTargets(installedAgents, undefined, ALL_AGENT_IDS);
515
+ let targets;
516
+ if (options.agents) {
517
+ const resolved = await resolveInstalledAgentTargetsAutoInstalling(options.agents, ALL_AGENT_IDS, { yes: options.yes });
518
+ if (!resolved) {
519
+ console.log(chalk.gray('Cancelled.'));
520
+ return;
521
+ }
522
+ targets = resolved;
523
+ }
524
+ else {
525
+ targets = resolveConfiguredAgentTargets(installedAgents, undefined, ALL_AGENT_IDS);
526
+ }
449
527
  if (targets.selectedAgents.length === 0) {
450
528
  console.log(chalk.yellow('\nNo agents selected.'));
451
529
  return;
452
530
  }
453
531
  // Install commands
454
- if (hasCommands) {
532
+ if (commands.length > 0) {
455
533
  console.log(chalk.bold('\nInstalling commands...'));
456
534
  let directInstalled = 0;
457
535
  let syncedVersions = 0;
@@ -495,7 +573,7 @@ When to use:
495
573
  }
496
574
  }
497
575
  // Install skills
498
- if (hasSkills) {
576
+ if (skills.length > 0) {
499
577
  console.log(chalk.bold('\nInstalling skills...'));
500
578
  const directAgents = targets.directAgents.filter((agentId) => AGENTS[agentId].capabilities.skills && gitCliStates[agentId]?.installed);
501
579
  let syncedVersions = 0;
@@ -522,7 +600,7 @@ When to use:
522
600
  console.log(` Synced skills to ${syncedVersions} managed version(s)`);
523
601
  }
524
602
  // Install hooks
525
- if (hasHooks) {
603
+ if (hooks.length > 0) {
526
604
  console.log(chalk.bold('\nInstalling hooks...'));
527
605
  let syncedVersions = 0;
528
606
  const directHookAgents = targets.directAgents.filter((id) => AGENTS[id].supportsHooks && gitCliStates[id]?.installed);
@@ -543,6 +621,97 @@ When to use:
543
621
  }
544
622
  console.log(` Synced hooks to ${syncedVersions} managed version(s)`);
545
623
  }
624
+ // Install workflows
625
+ if (workflows.length > 0) {
626
+ console.log(chalk.bold('\nInstalling workflows...'));
627
+ let installed = 0;
628
+ for (const w of workflows) {
629
+ const result = installWorkflowCentrally(w.path, w.name);
630
+ if (result.success) {
631
+ installed++;
632
+ }
633
+ else {
634
+ console.log(` ${chalk.red('x')} ${w.name}: ${result.error}`);
635
+ }
636
+ }
637
+ const workflowNames = workflows.map((w) => w.name);
638
+ let syncedVersions = 0;
639
+ for (const [agentId, versions] of targets.versionSelections) {
640
+ for (const version of versions) {
641
+ const result = syncResourcesToVersion(agentId, version, { workflows: workflowNames });
642
+ if (result.workflows.length > 0)
643
+ syncedVersions++;
644
+ }
645
+ }
646
+ console.log(` Installed ${installed} workflow(s) to ~/.agents/workflows/`);
647
+ console.log(` Synced workflows to ${syncedVersions} managed version(s)`);
648
+ }
649
+ // Install subagents
650
+ if (subagents.length > 0) {
651
+ console.log(chalk.bold('\nInstalling subagents...'));
652
+ let installed = 0;
653
+ for (const s of subagents) {
654
+ const result = installSubagentCentrally(s.path, s.name);
655
+ if (result.success) {
656
+ installed++;
657
+ }
658
+ else {
659
+ console.log(` ${chalk.red('x')} ${s.name}: ${result.error}`);
660
+ }
661
+ }
662
+ const subagentNames = subagents.map((s) => s.name);
663
+ let syncedVersions = 0;
664
+ for (const [agentId, versions] of targets.versionSelections) {
665
+ for (const version of versions) {
666
+ const result = syncResourcesToVersion(agentId, version, { subagents: subagentNames });
667
+ if (result.subagents.length > 0)
668
+ syncedVersions++;
669
+ }
670
+ }
671
+ console.log(` Installed ${installed} subagent(s) to ~/.agents/subagents/`);
672
+ console.log(` Synced subagents to ${syncedVersions} managed version(s)`);
673
+ }
674
+ // Install permissions
675
+ if (permissions.length > 0) {
676
+ console.log(chalk.bold('\nInstalling permission sets...'));
677
+ let installed = 0;
678
+ for (const p of permissions) {
679
+ const result = installPermissionSet(p.path, p.name);
680
+ if (result.success) {
681
+ installed++;
682
+ }
683
+ else {
684
+ console.log(` ${chalk.red('x')} ${p.name}: ${result.error}`);
685
+ }
686
+ }
687
+ console.log(` Installed ${installed} permission set(s) to ~/.agents/permissions/`);
688
+ console.log(chalk.gray(' Apply with: agents permissions apply <name> --agents <selector>'));
689
+ }
690
+ // Install MCP server configs
691
+ if (mcpServers.length > 0) {
692
+ console.log(chalk.bold('\nInstalling MCP server configs...'));
693
+ let installed = 0;
694
+ for (const s of mcpServers) {
695
+ const result = installMcpConfigCentrally(s.path);
696
+ if (result.success) {
697
+ installed++;
698
+ }
699
+ else {
700
+ console.log(` ${chalk.red('x')} ${s.name}: ${result.error}`);
701
+ }
702
+ }
703
+ const mcpNames = mcpServers.map((s) => s.name);
704
+ let syncedVersions = 0;
705
+ for (const [agentId, versions] of targets.versionSelections) {
706
+ for (const version of versions) {
707
+ const result = syncResourcesToVersion(agentId, version, { mcp: mcpNames });
708
+ if (result.mcp.length > 0)
709
+ syncedVersions++;
710
+ }
711
+ }
712
+ console.log(` Installed ${installed} MCP config(s) to ~/.agents/mcp/`);
713
+ console.log(` Synced MCP configs to ${syncedVersions} managed version(s)`);
714
+ }
546
715
  console.log(chalk.green('\nPackage installed.'));
547
716
  }
548
717
  }
@@ -7,9 +7,9 @@ import { confirm, checkbox } from '@inquirer/prompts';
7
7
  import { AGENTS, resolveAgentName, formatAgentError, agentLabel, } from '../lib/agents.js';
8
8
  import { cloneRepo } from '../lib/git.js';
9
9
  import { PERMISSIONS_CAPABLE_AGENTS, listInstalledPermissions, discoverPermissionsFromRepo, installPermissionSet, removePermissionSet, applyPermissionsToVersion, readAgentPermissions, exportPermissionsFromPath, getDefaultPermissionSet, computePermissionsDiff, mergePermissionSets, saveDefaultPermissionSet, containsBroadGrants, } from '../lib/permissions.js';
10
- import { listInstalledVersions, getGlobalDefault, getVersionHomePath, promptAgentVersionSelection, resolveAgentVersionTargets, resolveVersionAlias, } from '../lib/versions.js';
10
+ import { listInstalledVersions, getGlobalDefault, getVersionHomePath, promptAgentVersionSelection, resolveVersionAlias, } from '../lib/versions.js';
11
11
  import { recordVersionResources } from '../lib/state.js';
12
- import { isPromptCancelled, isInteractiveTerminal, parseCommaSeparatedList, printWithPager, requireInteractiveSelection, } from './utils.js';
12
+ import { isPromptCancelled, isInteractiveTerminal, parseCommaSeparatedList, printWithPager, requireInteractiveSelection, resolveAgentTargetsAutoInstalling, } from './utils.js';
13
13
  export function shouldRefuseBroadPermissions(permissions, allowBroadPermissions) {
14
14
  return !allowBroadPermissions && permissions.some((perm) => containsBroadGrants(perm.set) !== null);
15
15
  }
@@ -279,9 +279,14 @@ Examples:
279
279
  let selectedAgents;
280
280
  let versionSelections;
281
281
  if (options.agents) {
282
- const result = resolveAgentVersionTargets(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
282
+ const result = await resolveAgentTargetsAutoInstalling(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
283
+ yes: options.yes,
283
284
  allVersions: options.all,
284
285
  });
286
+ if (!result) {
287
+ console.log(chalk.gray('Cancelled.'));
288
+ return;
289
+ }
285
290
  selectedAgents = result.selectedAgents;
286
291
  versionSelections = result.versionSelections;
287
292
  }
@@ -296,7 +301,7 @@ Examples:
296
301
  }
297
302
  }
298
303
  else {
299
- const result = await promptAgentVersionSelection(PERMISSIONS_CAPABLE_AGENTS, { skipPrompts });
304
+ const result = await promptAgentVersionSelection(PERMISSIONS_CAPABLE_AGENTS, { skipPrompts: options.yes });
300
305
  selectedAgents = result.selectedAgents;
301
306
  versionSelections = result.versionSelections;
302
307
  }
@@ -412,9 +417,14 @@ Examples:
412
417
  let selectedAgents;
413
418
  let versionSelections;
414
419
  if (options.agents) {
415
- const result = resolveAgentVersionTargets(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
420
+ const result = await resolveAgentTargetsAutoInstalling(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
421
+ yes: options.yes,
416
422
  allVersions: options.all,
417
423
  });
424
+ if (!result) {
425
+ console.log(chalk.gray('Cancelled.'));
426
+ return;
427
+ }
418
428
  selectedAgents = result.selectedAgents;
419
429
  versionSelections = result.versionSelections;
420
430
  }
@@ -537,9 +547,14 @@ Examples:
537
547
  let selectedAgents;
538
548
  let versionSelections;
539
549
  if (options.agents) {
540
- const result = resolveAgentVersionTargets(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
550
+ const result = await resolveAgentTargetsAutoInstalling(options.agents, PERMISSIONS_CAPABLE_AGENTS, {
551
+ yes: options.yes,
541
552
  allVersions: options.all,
542
553
  });
554
+ if (!result) {
555
+ console.log(chalk.gray('Cancelled.'));
556
+ return;
557
+ }
543
558
  selectedAgents = result.selectedAgents;
544
559
  versionSelections = result.versionSelections;
545
560
  }
@@ -7,5 +7,13 @@
7
7
  * through a standard agent CLI with no local proxy.
8
8
  */
9
9
  import type { Command } from 'commander';
10
+ import { type Profile } from '../lib/profiles.js';
11
+ import { type Preset } from '../lib/profiles-presets.js';
12
+ /**
13
+ * Pure helper: builds a Profile from collected wizard inputs. Extracted so the
14
+ * shape of preset->profile mapping for the `create` wizard is unit-testable
15
+ * without mocking @inquirer/prompts.
16
+ */
17
+ export declare function buildProfileFromCollection(name: string, preset: Preset, collected: Record<string, string>, version?: string): Profile;
10
18
  /** Register the `agents profiles` command tree. */
11
19
  export declare function registerProfilesCommands(program: Command): void;