@phnx-labs/agents-cli 1.20.0 → 1.20.4

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 (111) hide show
  1. package/CHANGELOG.md +81 -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/import.js +90 -37
  13. package/dist/commands/mcp.js +166 -10
  14. package/dist/commands/packages.js +196 -27
  15. package/dist/commands/permissions.js +21 -6
  16. package/dist/commands/profiles.d.ts +8 -0
  17. package/dist/commands/profiles.js +117 -4
  18. package/dist/commands/pull.js +4 -4
  19. package/dist/commands/routines.js +6 -6
  20. package/dist/commands/rules.js +8 -4
  21. package/dist/commands/secrets-migrate.d.ts +24 -0
  22. package/dist/commands/secrets-migrate.js +198 -0
  23. package/dist/commands/secrets-sync.d.ts +11 -0
  24. package/dist/commands/secrets-sync.js +155 -0
  25. package/dist/commands/secrets.js +74 -39
  26. package/dist/commands/skills.js +22 -5
  27. package/dist/commands/subagents.js +69 -49
  28. package/dist/commands/teams.js +48 -10
  29. package/dist/commands/utils.d.ts +33 -0
  30. package/dist/commands/utils.js +139 -0
  31. package/dist/commands/versions.js +4 -4
  32. package/dist/commands/view.d.ts +6 -0
  33. package/dist/commands/view.js +169 -8
  34. package/dist/commands/workflows.js +29 -6
  35. package/dist/index.js +4 -0
  36. package/dist/lib/acp/client.js +6 -1
  37. package/dist/lib/agents.d.ts +4 -0
  38. package/dist/lib/agents.js +41 -17
  39. package/dist/lib/auto-pull-worker.js +18 -1
  40. package/dist/lib/browser/chrome.js +4 -0
  41. package/dist/lib/browser/drivers/ssh.js +1 -1
  42. package/dist/lib/browser/profiles.d.ts +3 -3
  43. package/dist/lib/browser/profiles.js +3 -3
  44. package/dist/lib/browser/service.js +19 -0
  45. package/dist/lib/browser/types.d.ts +4 -4
  46. package/dist/lib/cli-resources.d.ts +36 -8
  47. package/dist/lib/cli-resources.js +268 -46
  48. package/dist/lib/cloud/factory.d.ts +1 -1
  49. package/dist/lib/cloud/factory.js +1 -1
  50. package/dist/lib/events.d.ts +16 -2
  51. package/dist/lib/events.js +33 -2
  52. package/dist/lib/exec.d.ts +39 -11
  53. package/dist/lib/exec.js +90 -31
  54. package/dist/lib/help.js +11 -5
  55. package/dist/lib/hooks/cache.d.ts +38 -0
  56. package/dist/lib/hooks/cache.js +242 -0
  57. package/dist/lib/hooks/profile.d.ts +33 -0
  58. package/dist/lib/hooks/profile.js +129 -0
  59. package/dist/lib/hooks.d.ts +0 -10
  60. package/dist/lib/hooks.js +68 -15
  61. package/dist/lib/import.d.ts +21 -0
  62. package/dist/lib/import.js +55 -2
  63. package/dist/lib/mcp.d.ts +15 -0
  64. package/dist/lib/mcp.js +40 -0
  65. package/dist/lib/permissions.d.ts +13 -0
  66. package/dist/lib/permissions.js +51 -1
  67. package/dist/lib/plugin-marketplace.d.ts +10 -0
  68. package/dist/lib/plugin-marketplace.js +47 -1
  69. package/dist/lib/plugins.js +15 -1
  70. package/dist/lib/profiles-presets.d.ts +26 -0
  71. package/dist/lib/profiles-presets.js +187 -8
  72. package/dist/lib/profiles.d.ts +34 -0
  73. package/dist/lib/profiles.js +112 -1
  74. package/dist/lib/pty-server.js +27 -3
  75. package/dist/lib/routines-format.d.ts +17 -5
  76. package/dist/lib/routines-format.js +37 -16
  77. package/dist/lib/routines.d.ts +1 -1
  78. package/dist/lib/routines.js +2 -2
  79. package/dist/lib/runner.js +64 -10
  80. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  81. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  82. package/dist/lib/secrets/Agents CLI.app/Contents/_CodeSignature/CodeResources +1 -9
  83. package/dist/lib/secrets/bundles.d.ts +18 -22
  84. package/dist/lib/secrets/bundles.js +75 -99
  85. package/dist/lib/secrets/index.d.ts +51 -27
  86. package/dist/lib/secrets/index.js +147 -156
  87. package/dist/lib/secrets/install-helper.d.ts +45 -0
  88. package/dist/lib/secrets/install-helper.js +165 -0
  89. package/dist/lib/secrets/linux.js +4 -4
  90. package/dist/lib/secrets/sync.d.ts +56 -0
  91. package/dist/lib/secrets/sync.js +180 -0
  92. package/dist/lib/session/render.js +4 -4
  93. package/dist/lib/session/types.d.ts +1 -1
  94. package/dist/lib/shims.d.ts +4 -1
  95. package/dist/lib/shims.js +5 -35
  96. package/dist/lib/state.d.ts +14 -1
  97. package/dist/lib/state.js +49 -5
  98. package/dist/lib/teams/agents.d.ts +5 -4
  99. package/dist/lib/teams/agents.js +47 -21
  100. package/dist/lib/teams/api.d.ts +2 -1
  101. package/dist/lib/teams/api.js +4 -3
  102. package/dist/lib/types.d.ts +57 -1
  103. package/dist/lib/types.js +2 -0
  104. package/dist/lib/usage.d.ts +27 -2
  105. package/dist/lib/usage.js +100 -17
  106. package/dist/lib/versions.d.ts +35 -1
  107. package/dist/lib/versions.js +288 -64
  108. package/package.json +13 -12
  109. package/scripts/install-helper.js +97 -0
  110. package/scripts/postinstall.js +16 -0
  111. package/dist/lib/secrets/Agents CLI.app/Contents/embedded.provisionprofile +0 -0
@@ -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;
@@ -8,10 +8,30 @@
8
8
  */
9
9
  import chalk from 'chalk';
10
10
  import * as fs from 'fs';
11
- import { listProfiles, readProfile, writeProfile, deleteProfile, profileExists, profileFromPreset, getPresetForProfile, } from '../lib/profiles.js';
12
- import { getPreset, listPresets } from '../lib/profiles-presets.js';
11
+ import { spawn } from 'child_process';
12
+ import { listProfiles, readProfile, writeProfile, deleteProfile, profileExists, profileFromPreset, validateProfileName, getPresetForProfile, } from '../lib/profiles.js';
13
+ import { getPreset, listPresets, expandPreset } from '../lib/profiles-presets.js';
13
14
  import { hasKeychainToken, keychainItemName, setKeychainToken, deleteKeychainToken, } from '../lib/secrets/profiles.js';
14
15
  import { isInteractiveTerminal } from './utils.js';
16
+ /**
17
+ * Pure helper: builds a Profile from collected wizard inputs. Extracted so the
18
+ * shape of preset->profile mapping for the `create` wizard is unit-testable
19
+ * without mocking @inquirer/prompts.
20
+ */
21
+ export function buildProfileFromCollection(name, preset, collected, version) {
22
+ return {
23
+ name,
24
+ host: { agent: preset.host, version },
25
+ env: { ...preset.env, ...collected },
26
+ auth: {
27
+ envVar: preset.authEnvVar,
28
+ keychainItem: keychainItemName(preset.provider),
29
+ },
30
+ description: preset.description,
31
+ preset: preset.name,
32
+ provider: preset.provider,
33
+ };
34
+ }
15
35
  /** Prompt the user for a secret value with masked input. Requires an interactive TTY. */
16
36
  async function promptForSecret(message) {
17
37
  if (!isInteractiveTerminal()) {
@@ -86,7 +106,8 @@ Built-in presets (via OpenRouter, one shared key):
86
106
  Run 'agents profiles presets' for the full list with pricing and context sizes.
87
107
 
88
108
  Typical flow:
89
- agents profiles add kimi # prompts for OpenRouter key, stored in Keychain
109
+ agents profiles create # interactive wizard for any provider
110
+ agents profiles add kimi # one-line preset (existing)
90
111
  agents run kimi "refactor this" # Claude Code UI, Kimi model responses
91
112
  agents profiles add deepseek # reuses OpenRouter key, no re-prompt
92
113
 
@@ -202,6 +223,96 @@ Examples:
202
223
  process.exit(1);
203
224
  }
204
225
  });
226
+ cmd
227
+ .command('create')
228
+ .description('Interactive profile creation wizard (any provider, with prompts for endpoints + keys).')
229
+ .option('--name <name>', 'Profile name (skips the name prompt)')
230
+ .option('--provider <provider>', 'Provider preset name (skips the provider prompt)')
231
+ .option('--no-smoke-test', 'Skip the post-create smoke test prompt')
232
+ .action(async (opts) => {
233
+ if (!isInteractiveTerminal()) {
234
+ console.error(chalk.red('agents profiles create requires an interactive terminal. Use `agents profiles add <preset>` for scriptable creation.'));
235
+ process.exit(1);
236
+ }
237
+ const { input, select, confirm } = await import('@inquirer/prompts');
238
+ const name = opts.name
239
+ ? opts.name
240
+ : await input({
241
+ message: 'Profile name',
242
+ validate: (v) => /^[a-z0-9][a-z0-9-_]{0,48}$/i.test(v) || 'lowercase alphanumeric + -_ only, max 48 chars',
243
+ });
244
+ validateProfileName(name);
245
+ if (profileExists(name)) {
246
+ const overwrite = await confirm({
247
+ message: `Profile '${name}' already exists. Overwrite?`,
248
+ default: false,
249
+ });
250
+ if (!overwrite) {
251
+ console.log(chalk.gray('Cancelled.'));
252
+ return;
253
+ }
254
+ }
255
+ const presets = listPresets();
256
+ const providerName = opts.provider
257
+ ? opts.provider
258
+ : await select({
259
+ message: 'Provider',
260
+ choices: presets.map((p) => ({
261
+ name: `${p.name.padEnd(18)} ${chalk.gray(p.description.slice(0, 70))}`,
262
+ value: p.name,
263
+ })),
264
+ });
265
+ const preset = getPreset(providerName);
266
+ if (!preset) {
267
+ console.error(chalk.red(`Unknown provider '${providerName}'. Run 'agents profiles presets' for the list.`));
268
+ process.exit(1);
269
+ }
270
+ const expanded = expandPreset(preset);
271
+ const collected = {};
272
+ for (const v of expanded.prompts) {
273
+ if (v.secret) {
274
+ collected[v.envVar] = await promptForSecret(v.prompt);
275
+ }
276
+ else {
277
+ const value = await input({
278
+ message: v.hint ? `${v.prompt} ${chalk.gray('(' + v.hint + ')')}` : v.prompt,
279
+ default: v.default,
280
+ validate: v.pattern
281
+ ? (val) => new RegExp(v.pattern).test(val) || `must match ${v.pattern}`
282
+ : undefined,
283
+ });
284
+ collected[v.envVar] = value;
285
+ }
286
+ }
287
+ if (!preset.authOptional) {
288
+ await ensureProviderToken(preset.provider, preset.signupUrl);
289
+ }
290
+ const profile = buildProfileFromCollection(name, preset, collected);
291
+ writeProfile(profile);
292
+ console.log(chalk.green(`Profile '${name}' created.`));
293
+ if (preset.docPath) {
294
+ console.log(chalk.gray(`See docs/profiles/${preset.docPath}.md for provider-specific caveats.`));
295
+ }
296
+ if (opts.smokeTest !== false) {
297
+ const run = await confirm({ message: 'Run smoke test now?', default: true });
298
+ if (run) {
299
+ console.log(chalk.gray(`Spawning: agents run ${name} "say alive in one word" (60s timeout)`));
300
+ const child = spawn(process.argv[0], [
301
+ process.argv[1],
302
+ 'run',
303
+ name,
304
+ 'say alive in one word',
305
+ '--headless',
306
+ '--timeout',
307
+ '60s',
308
+ ], { stdio: 'inherit' });
309
+ child.on('exit', (code) => process.exit(code ?? 0));
310
+ }
311
+ else {
312
+ console.log(chalk.gray(`Try later: agents run ${name} "hello"`));
313
+ }
314
+ }
315
+ });
205
316
  cmd
206
317
  .command('add <name>')
207
318
  .description('Add a profile. If <name> matches a built-in preset, the preset is applied. Prompts for API key (once per provider).')
@@ -223,7 +334,9 @@ Examples:
223
334
  console.error(chalk.gray('Or pass --preset <name> to pick explicitly.'));
224
335
  process.exit(1);
225
336
  }
226
- await ensureProviderToken(preset.provider, preset.signupUrl, opts.keyStdin);
337
+ if (!preset.authOptional) {
338
+ await ensureProviderToken(preset.provider, preset.signupUrl, opts.keyStdin);
339
+ }
227
340
  const profile = profileFromPreset(name, preset, opts.version);
228
341
  writeProfile(profile);
229
342
  console.log(chalk.green(`Profile '${name}' added.`));
@@ -13,8 +13,8 @@ import { getUserAgentsDir, ensureAgentsDir, getEnabledExtraRepos, } from '../lib
13
13
  import { isGitRepo, pullRepo, isSystemRepoOrigin, } from '../lib/git.js';
14
14
  import * as fs from 'fs';
15
15
  import * as path from 'path';
16
- import { installVersion, listInstalledVersions, getGlobalDefault, setGlobalDefault, getVersionHomePath, syncResourcesToVersion, getAvailableResources, getActuallySyncedResources, getNewResources, hasNewResources, promptNewResourceSelection, promptResourceSelection, resolveConfiguredAgentTargets, } from '../lib/versions.js';
17
- import { listCliStatus, installCli, describeMethod, selectInstallMethod, } from '../lib/cli-resources.js';
16
+ import { installVersion, listInstalledVersions, getGlobalDefault, setGlobalDefault, getVersionHomePath, syncResourcesToVersion, getAvailableResources, getActuallySyncedResources, getNewResources, getProjectOnlyResources, hasNewResources, promptNewResourceSelection, promptResourceSelection, resolveConfiguredAgentTargets, } from '../lib/versions.js';
17
+ import { listCliStatus, installCli, describeMethod, describeCheck, selectInstallMethod, } from '../lib/cli-resources.js';
18
18
  import { ensureShimCurrent, isShimsInPath, addShimsToPath, getPathSetupInstructions, switchConfigSymlink, switchHomeFileSymlinks, } from '../lib/shims.js';
19
19
  import { parseHookManifest, registerHooksToSettings } from '../lib/hooks.js';
20
20
  import { setHelpSections } from '../lib/help.js';
@@ -219,7 +219,7 @@ export function registerPullCommand(program) {
219
219
  if (!defaultVer)
220
220
  continue;
221
221
  const actuallySynced = getActuallySyncedResources(agentId, defaultVer);
222
- const newResources = getNewResources(available, actuallySynced);
222
+ const newResources = getNewResources(available, actuallySynced, getProjectOnlyResources());
223
223
  const hasAnySynced = actuallySynced.commands.length > 0 ||
224
224
  actuallySynced.skills.length > 0 ||
225
225
  actuallySynced.hooks.length > 0 ||
@@ -401,7 +401,7 @@ export function registerPullCommand(program) {
401
401
  }
402
402
  }
403
403
  else {
404
- console.log(chalk.yellow(` install ran but \`${s.manifest.check}\` still fails`));
404
+ console.log(chalk.yellow(` install ran but \`${describeCheck(s.manifest.check)}\` still fails`));
405
405
  }
406
406
  }
407
407
  }
@@ -11,7 +11,7 @@ import * as fs from 'fs';
11
11
  import * as path from 'path';
12
12
  import * as yaml from 'yaml';
13
13
  import { isDaemonRunning, signalDaemonReload, startDaemon, stopDaemon, readDaemonPid, readDaemonLog, } from '../lib/daemon.js';
14
- import { humanizeCron, humanizeNextRun, formatRepoLink } from '../lib/routines-format.js';
14
+ import { humanizeCron, humanizeNextRun, formatRepoLink, REPO_DISPLAY_MAX } from '../lib/routines-format.js';
15
15
  import { listJobs as listAllJobs, deleteJob, readJob, validateJob, writeJob, setJobEnabled, listRuns, getLatestRun, getRunDir, getJobPath, parseAtTime, } from '../lib/routines.js';
16
16
  import { getRoutinesDir } from '../lib/state.js';
17
17
  import { safeJoin } from '../lib/paths.js';
@@ -133,13 +133,13 @@ export function registerRoutinesCommands(program) {
133
133
  }
134
134
  console.log(chalk.bold('Scheduled Jobs\n'));
135
135
  // OSC 8 hyperlink helper — renders as a clickable link in supporting terminals.
136
- // In terminals that do not support OSC 8 the escape sequences are ignored and
137
- // the label is displayed as plain text.
138
- const link = (label, url) => url ? `\x1b]8;;${url}\x07${label}\x1b]8;;\x07` : label;
136
+ // Guarded on process.stdout.isTTY so that piped/redirected output never
137
+ // contains raw ESC ] 8 ;; ... BEL escape sequences.
138
+ const link = (label, url) => url && process.stdout.isTTY ? `\x1b]8;;${url}\x07${label}\x1b]8;;\x07` : label;
139
139
  const now = new Date();
140
140
  const NAME_W = 24;
141
141
  const AGENT_W = 10;
142
- const REPO_W = 24;
142
+ const REPO_W = REPO_DISPLAY_MAX;
143
143
  const SCHED_W = 22;
144
144
  const ENABLED_W = 10;
145
145
  const NEXT_W = 22;
@@ -184,7 +184,7 @@ export function registerRoutinesCommands(program) {
184
184
  .option('-a, --agent <agent>', 'Which agent runs this routine: claude, codex, gemini, cursor, or opencode')
185
185
  .option('--workflow <name>', 'Run an installed workflow (~/.agents/workflows/<name>) via `agents run`. Mutually exclusive with --agent.')
186
186
  .option('-p, --prompt <prompt>', 'Task instruction for the agent')
187
- .option('-m, --mode <mode>', 'Execution mode: plan (read-only) or edit (can write files)', 'plan')
187
+ .option('-m, --mode <mode>', "Execution mode: plan (read-only), edit (can write files), auto (smart classifier), or skip (bypass all permission prompts). 'full' accepted as alias for skip.", 'plan')
188
188
  .option('-e, --effort <effort>', 'Reasoning effort: low | medium | high | xhigh | max | auto', 'auto')
189
189
  .option('-t, --timeout <timeout>', 'Kill the agent if it runs longer than this (e.g., 10m, 2h, 3d, 1w; max 1w)', '10m')
190
190
  .option('--timezone <tz>', 'Interpret schedule in this timezone (e.g., America/Los_Angeles)')
@@ -7,11 +7,11 @@ import { select, checkbox } from '@inquirer/prompts';
7
7
  import { AGENTS, ALL_AGENT_IDS, resolveAgentName, formatAgentError, agentLabel, } from '../lib/agents.js';
8
8
  import { cloneRepo } from '../lib/git.js';
9
9
  import { discoverInstructionsFromRepo, discoverRuleFilesFromRepo, installInstructionsCentrally, uninstallInstructions, listInstalledInstructionsWithScope, instructionsExists, getInstructionsContent, listCentralRules, } from '../lib/rules/rules.js';
10
- import { listInstalledVersions, getGlobalDefault, resolveVersionAlias, syncResourcesToVersion, promptAgentVersionSelection, getVersionHomePath, resolveAgentVersionTargets, } from '../lib/versions.js';
10
+ import { listInstalledVersions, getGlobalDefault, resolveVersionAlias, syncResourcesToVersion, promptAgentVersionSelection, getVersionHomePath, } from '../lib/versions.js';
11
11
  import { recordVersionResources, getActiveRulesPreset, setActiveRulesPreset } from '../lib/state.js';
12
12
  import { discoverRulesLayers } from '../lib/rules/compose.js';
13
13
  import * as yaml from 'yaml';
14
- import { isPromptCancelled, formatPath, isInteractiveTerminal, parseCommaSeparatedList, printWithPager, requireInteractiveSelection, requireDestructiveArg, } from './utils.js';
14
+ import { isPromptCancelled, formatPath, isInteractiveTerminal, parseCommaSeparatedList, printWithPager, requireInteractiveSelection, requireDestructiveArg, resolveAgentTargetsAutoInstalling, } from './utils.js';
15
15
  /** Register the `agents rules` command tree (list, add, view, remove). */
16
16
  export function registerRulesCommands(program) {
17
17
  const rulesCmd = program
@@ -317,13 +317,17 @@ Examples:
317
317
  let selectedAgents;
318
318
  let versionSelections;
319
319
  if (options.agents) {
320
- const result = resolveAgentVersionTargets(options.agents, ALL_AGENT_IDS);
320
+ const result = await resolveAgentTargetsAutoInstalling(options.agents, ALL_AGENT_IDS, { yes: options.yes });
321
+ if (!result) {
322
+ console.log(chalk.gray('Cancelled.'));
323
+ return;
324
+ }
321
325
  selectedAgents = result.selectedAgents;
322
326
  versionSelections = result.versionSelections;
323
327
  }
324
328
  else {
325
329
  const result = await promptAgentVersionSelection(ALL_AGENT_IDS, {
326
- skipPrompts: options.yes || !isInteractiveTerminal(),
330
+ skipPrompts: options.yes,
327
331
  });
328
332
  selectedAgents = result.selectedAgents;
329
333
  versionSelections = result.versionSelections;