slack.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. """``hermes slack`` subcommand parser."""
  2. from __future__ import annotations
  3. from typing import Callable
  4. def build_slack_parser(subparsers, *, cmd_slack: Callable) -> None:
  5. """Attach the ``slack`` subcommand to ``subparsers``."""
  6. slack_parser = subparsers.add_parser(
  7. "slack", help="Slack integration helpers (manifest generation, etc.)",
  8. description="Slack integration helpers for Hermes.")
  9. slack_sub = slack_parser.add_subparsers(dest="slack_command")
  10. slack_manifest = slack_sub.add_parser(
  11. "manifest",
  12. help="Print or write a Slack app manifest with every gateway command "
  13. "registered as a native slash (/btw, /stop, /model, ...)",
  14. description="Generate a Slack app manifest that registers every gateway "
  15. "command in COMMAND_REGISTRY as a first-class Slack slash "
  16. "command (matching Discord and Telegram parity). Paste the "
  17. "output into Slack app config → Features → App Manifest → "
  18. "Edit, then Save. Reinstall the app if Slack prompts for it.")
  19. slack_manifest.add_argument(
  20. "--write", nargs="?", const=True, default=None, metavar="PATH",
  21. help="Write manifest to a file instead of stdout. With no PATH "
  22. "writes to $HERMES_HOME/slack-manifest.json.")
  23. slack_manifest.add_argument("--name", default=None, help='Bot display name (default: "Hermes")')
  24. slack_manifest.add_argument(
  25. "--description", default=None, help="Bot description shown in Slack's app directory.")
  26. slack_long_description = slack_manifest.add_mutually_exclusive_group()
  27. slack_long_description.add_argument(
  28. "--long-description", default=None, metavar="TEXT",
  29. help="Set Slack's long app description (175-4,000 characters).")
  30. slack_long_description.add_argument(
  31. "--long-description-file", default=None, metavar="PATH",
  32. help=("Read Slack's long app description from a UTF-8 text file (175-4,000 characters)."))
  33. slack_manifest.add_argument(
  34. "--slashes-only", action="store_true",
  35. help="Emit only the features.slash_commands array (for merging "
  36. "into an existing manifest manually).")
  37. slack_messaging = slack_manifest.add_mutually_exclusive_group()
  38. slack_messaging.add_argument(
  39. "--no-assistant", action="store_true",
  40. help="Omit Slack AI Assistant mode (assistant_view, assistant:write "
  41. "scope, assistant_thread_* events). DMs then render as a flat chat "
  42. "where bare slash commands (/help, /new) work inline instead of "
  43. "Slack's Assistant thread pane.")
  44. slack_messaging.add_argument(
  45. "--agent-view", action="store_true",
  46. help="Emit Slack's Agent messaging experience (agent_view, "
  47. "app_home_opened + message.im) instead of the legacy assistant_view "
  48. "experience. This changes Slack's app messaging surface and cannot "
  49. "be reversed in Slack after applying the manifest.")
  50. slack_parser.set_defaults(func=cmd_slack)