agent-messenger 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/release.md +92 -0
- package/.claude-plugin/README.md +144 -0
- package/.claude-plugin/marketplace.json +37 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.github/workflows/ci.yml +30 -0
- package/CLAUDE.md +106 -0
- package/CONTRIBUTING.md +131 -0
- package/README.md +140 -0
- package/biome.json +34 -0
- package/bun.lock +252 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +140 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/channel.d.ts +3 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +118 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/file.d.ts +3 -0
- package/dist/commands/file.d.ts.map +1 -0
- package/dist/commands/file.js +113 -0
- package/dist/commands/file.js.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/message.d.ts +3 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +214 -0
- package/dist/commands/message.js.map +1 -0
- package/dist/commands/reaction.d.ts +3 -0
- package/dist/commands/reaction.d.ts.map +1 -0
- package/dist/commands/reaction.js +100 -0
- package/dist/commands/reaction.js.map +1 -0
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +88 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +96 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/workspace.d.ts +3 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +89 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/lib/credential-manager.d.ts +13 -0
- package/dist/lib/credential-manager.d.ts.map +1 -0
- package/dist/lib/credential-manager.js +58 -0
- package/dist/lib/credential-manager.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/ref-manager.d.ts +26 -0
- package/dist/lib/ref-manager.d.ts.map +1 -0
- package/dist/lib/ref-manager.js +92 -0
- package/dist/lib/ref-manager.js.map +1 -0
- package/dist/lib/slack-client.d.ts +37 -0
- package/dist/lib/slack-client.d.ts.map +1 -0
- package/dist/lib/slack-client.js +379 -0
- package/dist/lib/slack-client.js.map +1 -0
- package/dist/lib/token-extractor.d.ts +28 -0
- package/dist/lib/token-extractor.d.ts.map +1 -0
- package/dist/lib/token-extractor.js +401 -0
- package/dist/lib/token-extractor.js.map +1 -0
- package/dist/package.json +37 -0
- package/dist/src/cli.d.ts +5 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +22 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts +5 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -0
- package/dist/src/platforms/discord/cli.js +22 -0
- package/dist/src/platforms/discord/cli.js.map +1 -0
- package/dist/src/platforms/discord/client.d.ts +34 -0
- package/dist/src/platforms/discord/client.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.js +187 -0
- package/dist/src/platforms/discord/client.js.map +1 -0
- package/dist/src/platforms/discord/client.test.d.ts +2 -0
- package/dist/src/platforms/discord/client.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.test.js +367 -0
- package/dist/src/platforms/discord/client.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.d.ts +13 -0
- package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.js +155 -0
- package/dist/src/platforms/discord/commands/auth.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.js +65 -0
- package/dist/src/platforms/discord/commands/auth.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.d.ts +13 -0
- package/dist/src/platforms/discord/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.js +99 -0
- package/dist/src/platforms/discord/commands/channel.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.js +136 -0
- package/dist/src/platforms/discord/commands/channel.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.d.ts +13 -0
- package/dist/src/platforms/discord/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.js +99 -0
- package/dist/src/platforms/discord/commands/file.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.js +83 -0
- package/dist/src/platforms/discord/commands/file.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.d.ts +15 -0
- package/dist/src/platforms/discord/commands/guild.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.js +102 -0
- package/dist/src/platforms/discord/commands/guild.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.js +100 -0
- package/dist/src/platforms/discord/commands/guild.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +9 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/index.js +9 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +17 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.js +131 -0
- package/dist/src/platforms/discord/commands/message.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.js +91 -0
- package/dist/src/platforms/discord/commands/message.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts +12 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.js +99 -0
- package/dist/src/platforms/discord/commands/reaction.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.js +115 -0
- package/dist/src/platforms/discord/commands/reaction.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts +9 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +80 -0
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js +25 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts +3 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.js +94 -0
- package/dist/src/platforms/discord/commands/user.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.js +103 -0
- package/dist/src/platforms/discord/commands/user.test.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.d.ts +33 -0
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.js +73 -0
- package/dist/src/platforms/discord/credential-manager.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts +2 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.js +136 -0
- package/dist/src/platforms/discord/credential-manager.test.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +55 -0
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.js +462 -0
- package/dist/src/platforms/discord/token-extractor.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts +2 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.js +789 -0
- package/dist/src/platforms/discord/token-extractor.test.js.map +1 -0
- package/dist/src/platforms/discord/types.d.ts +251 -0
- package/dist/src/platforms/discord/types.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.js +74 -0
- package/dist/src/platforms/discord/types.js.map +1 -0
- package/dist/src/platforms/discord/types.test.d.ts +2 -0
- package/dist/src/platforms/discord/types.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.test.js +211 -0
- package/dist/src/platforms/discord/types.test.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts +5 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -0
- package/dist/src/platforms/slack/cli.js +22 -0
- package/dist/src/platforms/slack/cli.js.map +1 -0
- package/dist/src/platforms/slack/client.d.ts +47 -0
- package/dist/src/platforms/slack/client.d.ts.map +1 -0
- package/dist/src/platforms/slack/client.js +412 -0
- package/dist/src/platforms/slack/client.js.map +1 -0
- package/dist/src/platforms/slack/commands/auth.d.ts +3 -0
- package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/auth.js +156 -0
- package/dist/src/platforms/slack/commands/auth.js.map +1 -0
- package/dist/src/platforms/slack/commands/channel.d.ts +3 -0
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/channel.js +118 -0
- package/dist/src/platforms/slack/commands/channel.js.map +1 -0
- package/dist/src/platforms/slack/commands/file.d.ts +3 -0
- package/dist/src/platforms/slack/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/file.js +113 -0
- package/dist/src/platforms/slack/commands/file.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +9 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/index.js +9 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -0
- package/dist/src/platforms/slack/commands/message.d.ts +3 -0
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/message.js +263 -0
- package/dist/src/platforms/slack/commands/message.js.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts +3 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.js +100 -0
- package/dist/src/platforms/slack/commands/reaction.js.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts +3 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.js +87 -0
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/slack/commands/user.d.ts +3 -0
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/user.js +96 -0
- package/dist/src/platforms/slack/commands/user.js.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts +3 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.js +89 -0
- package/dist/src/platforms/slack/commands/workspace.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts +13 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/slack/credential-manager.js +58 -0
- package/dist/src/platforms/slack/credential-manager.js.map +1 -0
- package/dist/src/platforms/slack/index.d.ts +3 -0
- package/dist/src/platforms/slack/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/index.js +3 -0
- package/dist/src/platforms/slack/index.js.map +1 -0
- package/dist/src/platforms/slack/token-extractor.d.ts +28 -0
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/slack/token-extractor.js +401 -0
- package/dist/src/platforms/slack/token-extractor.js.map +1 -0
- package/dist/src/platforms/slack/types.d.ts +369 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -0
- package/dist/src/platforms/slack/types.js +92 -0
- package/dist/src/platforms/slack/types.js.map +1 -0
- package/dist/src/shared/utils/concurrency.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.js +14 -0
- package/dist/src/shared/utils/concurrency.js.map +1 -0
- package/dist/src/shared/utils/concurrency.test.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.test.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.test.js +39 -0
- package/dist/src/shared/utils/concurrency.test.js.map +1 -0
- package/dist/src/shared/utils/error-handler.d.ts +2 -0
- package/dist/src/shared/utils/error-handler.d.ts.map +1 -0
- package/dist/src/shared/utils/error-handler.js +5 -0
- package/dist/src/shared/utils/error-handler.js.map +1 -0
- package/dist/src/shared/utils/output.d.ts +2 -0
- package/dist/src/shared/utils/output.d.ts.map +1 -0
- package/dist/src/shared/utils/output.js +4 -0
- package/dist/src/shared/utils/output.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +83 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +3 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +2 -0
- package/dist/tests/commands/auth.test.d.ts.map +1 -0
- package/dist/tests/commands/auth.test.js +304 -0
- package/dist/tests/commands/auth.test.js.map +1 -0
- package/dist/tests/commands/channel.test.d.ts +2 -0
- package/dist/tests/commands/channel.test.d.ts.map +1 -0
- package/dist/tests/commands/channel.test.js +166 -0
- package/dist/tests/commands/channel.test.js.map +1 -0
- package/dist/tests/commands/file.test.d.ts +2 -0
- package/dist/tests/commands/file.test.d.ts.map +1 -0
- package/dist/tests/commands/file.test.js +175 -0
- package/dist/tests/commands/file.test.js.map +1 -0
- package/dist/tests/commands/message.test.d.ts +2 -0
- package/dist/tests/commands/message.test.d.ts.map +1 -0
- package/dist/tests/commands/message.test.js +293 -0
- package/dist/tests/commands/message.test.js.map +1 -0
- package/dist/tests/commands/reaction.test.d.ts +2 -0
- package/dist/tests/commands/reaction.test.d.ts.map +1 -0
- package/dist/tests/commands/reaction.test.js +84 -0
- package/dist/tests/commands/reaction.test.js.map +1 -0
- package/dist/tests/commands/snapshot.test.d.ts +2 -0
- package/dist/tests/commands/snapshot.test.d.ts.map +1 -0
- package/dist/tests/commands/snapshot.test.js +280 -0
- package/dist/tests/commands/snapshot.test.js.map +1 -0
- package/dist/tests/commands/user.test.d.ts +2 -0
- package/dist/tests/commands/user.test.d.ts.map +1 -0
- package/dist/tests/commands/user.test.js +117 -0
- package/dist/tests/commands/user.test.js.map +1 -0
- package/dist/tests/commands/workspace.test.d.ts +2 -0
- package/dist/tests/commands/workspace.test.d.ts.map +1 -0
- package/dist/tests/commands/workspace.test.js +453 -0
- package/dist/tests/commands/workspace.test.js.map +1 -0
- package/dist/tests/credential-manager.test.d.ts +2 -0
- package/dist/tests/credential-manager.test.d.ts.map +1 -0
- package/dist/tests/credential-manager.test.js +199 -0
- package/dist/tests/credential-manager.test.js.map +1 -0
- package/dist/tests/slack-client.test.d.ts +2 -0
- package/dist/tests/slack-client.test.d.ts.map +1 -0
- package/dist/tests/slack-client.test.js +741 -0
- package/dist/tests/slack-client.test.js.map +1 -0
- package/dist/tests/types.test.d.ts +2 -0
- package/dist/tests/types.test.d.ts.map +1 -0
- package/dist/tests/types.test.js +215 -0
- package/dist/tests/types.test.js.map +1 -0
- package/dist/types/index.d.ts +369 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +92 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/error-handler.d.ts +2 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +5 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/output.d.ts +2 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +4 -0
- package/dist/utils/output.js.map +1 -0
- package/docs/discord.md +182 -0
- package/docs/slack.md +160 -0
- package/package.json +37 -0
- package/skills/agent-discord/SKILL.md +273 -0
- package/skills/agent-discord/references/authentication.md +294 -0
- package/skills/agent-discord/references/common-patterns.md +455 -0
- package/skills/agent-discord/templates/guild-summary.sh +167 -0
- package/skills/agent-discord/templates/monitor-channel.sh +180 -0
- package/skills/agent-discord/templates/post-message.sh +173 -0
- package/skills/agent-slack/SKILL.md +268 -0
- package/skills/agent-slack/references/authentication.md +332 -0
- package/skills/agent-slack/references/common-patterns.md +527 -0
- package/skills/agent-slack/templates/monitor-channel.sh +186 -0
- package/skills/agent-slack/templates/post-message.sh +130 -0
- package/skills/agent-slack/templates/workspace-summary.sh +149 -0
- package/src/cli.ts +29 -0
- package/src/platforms/discord/cli.ts +36 -0
- package/src/platforms/discord/client.test.ts +456 -0
- package/src/platforms/discord/client.ts +281 -0
- package/src/platforms/discord/commands/auth.test.ts +72 -0
- package/src/platforms/discord/commands/auth.ts +206 -0
- package/src/platforms/discord/commands/channel.test.ts +153 -0
- package/src/platforms/discord/commands/channel.ts +127 -0
- package/src/platforms/discord/commands/file.test.ts +98 -0
- package/src/platforms/discord/commands/file.ts +134 -0
- package/src/platforms/discord/commands/guild.test.ts +117 -0
- package/src/platforms/discord/commands/guild.ts +129 -0
- package/src/platforms/discord/commands/index.ts +8 -0
- package/src/platforms/discord/commands/message.test.ts +107 -0
- package/src/platforms/discord/commands/message.ts +182 -0
- package/src/platforms/discord/commands/reaction.test.ts +123 -0
- package/src/platforms/discord/commands/reaction.ts +156 -0
- package/src/platforms/discord/commands/snapshot.test.ts +29 -0
- package/src/platforms/discord/commands/snapshot.ts +104 -0
- package/src/platforms/discord/commands/user.test.ts +115 -0
- package/src/platforms/discord/commands/user.ts +124 -0
- package/src/platforms/discord/credential-manager.test.ts +173 -0
- package/src/platforms/discord/credential-manager.ts +95 -0
- package/src/platforms/discord/token-extractor.test.ts +918 -0
- package/src/platforms/discord/token-extractor.ts +549 -0
- package/src/platforms/discord/types.test.ts +245 -0
- package/src/platforms/discord/types.ts +158 -0
- package/src/platforms/slack/cli.ts +36 -0
- package/src/platforms/slack/client.ts +466 -0
- package/src/platforms/slack/commands/auth.ts +211 -0
- package/src/platforms/slack/commands/channel.ts +158 -0
- package/src/platforms/slack/commands/file.ts +153 -0
- package/src/platforms/slack/commands/index.ts +8 -0
- package/src/platforms/slack/commands/message.ts +369 -0
- package/src/platforms/slack/commands/reaction.ts +166 -0
- package/src/platforms/slack/commands/snapshot.ts +114 -0
- package/src/platforms/slack/commands/user.ts +110 -0
- package/src/platforms/slack/commands/workspace.ts +111 -0
- package/src/platforms/slack/credential-manager.ts +74 -0
- package/src/platforms/slack/index.ts +2 -0
- package/src/platforms/slack/token-extractor.ts +496 -0
- package/src/platforms/slack/types.ts +193 -0
- package/src/shared/utils/concurrency.test.ts +53 -0
- package/src/shared/utils/concurrency.ts +20 -0
- package/src/shared/utils/error-handler.ts +4 -0
- package/src/shared/utils/output.ts +3 -0
- package/tests/cli.test.ts +94 -0
- package/tests/commands/auth.test.ts +383 -0
- package/tests/commands/channel.test.ts +185 -0
- package/tests/commands/file.test.ts +204 -0
- package/tests/commands/message.test.ts +344 -0
- package/tests/commands/reaction.test.ts +101 -0
- package/tests/commands/snapshot.test.ts +308 -0
- package/tests/commands/user.test.ts +138 -0
- package/tests/commands/workspace.test.ts +528 -0
- package/tests/credential-manager.test.ts +241 -0
- package/tests/slack-client.test.ts +916 -0
- package/tests/types.test.ts +241 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Common Patterns
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide covers typical workflows for AI agents interacting with Discord using agent-discord.
|
|
6
|
+
|
|
7
|
+
**Important**: Discord uses Snowflake IDs (large numbers like `1234567890123456789`) for channels, messages, and users. You cannot use channel names directly - always get IDs from `channel list` first.
|
|
8
|
+
|
|
9
|
+
## Pattern 1: Send a Simple Message
|
|
10
|
+
|
|
11
|
+
**Use case**: Post a notification or update to a channel
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
#!/bin/bash
|
|
15
|
+
|
|
16
|
+
# First, get channel ID from channel list
|
|
17
|
+
CHANNELS=$(agent-discord channel list)
|
|
18
|
+
CHANNEL_ID=$(echo "$CHANNELS" | jq -r '.[] | select(.name=="general") | .id')
|
|
19
|
+
|
|
20
|
+
# Send message using channel ID
|
|
21
|
+
agent-discord message send "$CHANNEL_ID" "Deployment completed successfully!"
|
|
22
|
+
|
|
23
|
+
# With error handling
|
|
24
|
+
RESULT=$(agent-discord message send "$CHANNEL_ID" "Hello world")
|
|
25
|
+
if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
26
|
+
echo "Message sent!"
|
|
27
|
+
else
|
|
28
|
+
echo "Failed: $(echo "$RESULT" | jq -r '.error')"
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**When to use**: Simple one-off messages after looking up the channel ID.
|
|
34
|
+
|
|
35
|
+
## Pattern 2: Monitor Channel for New Messages
|
|
36
|
+
|
|
37
|
+
**Use case**: Watch a channel and respond to new messages
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
#!/bin/bash
|
|
41
|
+
|
|
42
|
+
CHANNEL_ID="1234567890123456789"
|
|
43
|
+
LAST_ID=""
|
|
44
|
+
|
|
45
|
+
while true; do
|
|
46
|
+
# Get latest message
|
|
47
|
+
MESSAGES=$(agent-discord message list "$CHANNEL_ID" --limit 1)
|
|
48
|
+
LATEST_ID=$(echo "$MESSAGES" | jq -r '.[0].id // ""')
|
|
49
|
+
|
|
50
|
+
# Check if new message
|
|
51
|
+
if [ "$LATEST_ID" != "$LAST_ID" ] && [ -n "$LAST_ID" ]; then
|
|
52
|
+
CONTENT=$(echo "$MESSAGES" | jq -r '.[0].content')
|
|
53
|
+
AUTHOR=$(echo "$MESSAGES" | jq -r '.[0].author')
|
|
54
|
+
|
|
55
|
+
echo "New message from $AUTHOR: $CONTENT"
|
|
56
|
+
|
|
57
|
+
# Process message here
|
|
58
|
+
# Example: Respond to mentions
|
|
59
|
+
if echo "$CONTENT" | grep -q "bot"; then
|
|
60
|
+
agent-discord message send "$CHANNEL_ID" "You called?"
|
|
61
|
+
fi
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
LAST_ID="$LATEST_ID"
|
|
65
|
+
sleep 5
|
|
66
|
+
done
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**When to use**: Building a simple bot that reacts to messages.
|
|
70
|
+
|
|
71
|
+
**Limitations**: Polling-based, not real-time. For production bots, use Discord's Gateway API with a proper bot token.
|
|
72
|
+
|
|
73
|
+
## Pattern 3: Get Guild Overview
|
|
74
|
+
|
|
75
|
+
**Use case**: Understand server state before taking action
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
#!/bin/bash
|
|
79
|
+
|
|
80
|
+
# Get full snapshot
|
|
81
|
+
SNAPSHOT=$(agent-discord snapshot)
|
|
82
|
+
|
|
83
|
+
# Extract key information
|
|
84
|
+
GUILD_NAME=$(echo "$SNAPSHOT" | jq -r '.guild.name')
|
|
85
|
+
CHANNEL_COUNT=$(echo "$SNAPSHOT" | jq -r '.channels | length')
|
|
86
|
+
MEMBER_COUNT=$(echo "$SNAPSHOT" | jq -r '.members | length')
|
|
87
|
+
|
|
88
|
+
echo "Server: $GUILD_NAME"
|
|
89
|
+
echo "Channels: $CHANNEL_COUNT"
|
|
90
|
+
echo "Members: $MEMBER_COUNT"
|
|
91
|
+
|
|
92
|
+
# List all text channels
|
|
93
|
+
echo -e "\nChannels:"
|
|
94
|
+
echo "$SNAPSHOT" | jq -r '.channels[] | " #\(.name) (\(.id))"'
|
|
95
|
+
|
|
96
|
+
# List recent activity
|
|
97
|
+
echo -e "\nRecent messages:"
|
|
98
|
+
echo "$SNAPSHOT" | jq -r '.recent_messages[] | " [\(.channel_name)] \(.author): \(.content[0:50])"'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**When to use**: Initial context gathering, status reports, server summaries.
|
|
102
|
+
|
|
103
|
+
## Pattern 4: Find Channel by Name
|
|
104
|
+
|
|
105
|
+
**Use case**: Get channel ID from channel name
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
#!/bin/bash
|
|
109
|
+
|
|
110
|
+
get_channel_id() {
|
|
111
|
+
local channel_name=$1
|
|
112
|
+
|
|
113
|
+
CHANNELS=$(agent-discord channel list)
|
|
114
|
+
CHANNEL_ID=$(echo "$CHANNELS" | jq -r --arg name "$channel_name" '.[] | select(.name==$name) | .id')
|
|
115
|
+
|
|
116
|
+
if [ -z "$CHANNEL_ID" ]; then
|
|
117
|
+
echo "Channel #$channel_name not found" >&2
|
|
118
|
+
return 1
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
echo "$CHANNEL_ID"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Usage
|
|
125
|
+
GENERAL_ID=$(get_channel_id "general")
|
|
126
|
+
if [ $? -eq 0 ]; then
|
|
127
|
+
agent-discord message send "$GENERAL_ID" "Hello!"
|
|
128
|
+
fi
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**When to use**: When you know channel name but need the ID.
|
|
132
|
+
|
|
133
|
+
## Pattern 5: Multi-Channel Broadcast
|
|
134
|
+
|
|
135
|
+
**Use case**: Send the same message to multiple channels
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
#!/bin/bash
|
|
139
|
+
|
|
140
|
+
MESSAGE="System maintenance in 30 minutes"
|
|
141
|
+
CHANNEL_NAMES=("general" "announcements" "dev")
|
|
142
|
+
|
|
143
|
+
# Get all channels once
|
|
144
|
+
CHANNELS=$(agent-discord channel list)
|
|
145
|
+
|
|
146
|
+
for name in "${CHANNEL_NAMES[@]}"; do
|
|
147
|
+
CHANNEL_ID=$(echo "$CHANNELS" | jq -r --arg n "$name" '.[] | select(.name==$n) | .id')
|
|
148
|
+
|
|
149
|
+
if [ -z "$CHANNEL_ID" ]; then
|
|
150
|
+
echo "Channel #$name not found, skipping"
|
|
151
|
+
continue
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
echo "Posting to #$name..."
|
|
155
|
+
RESULT=$(agent-discord message send "$CHANNEL_ID" "$MESSAGE")
|
|
156
|
+
|
|
157
|
+
if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
158
|
+
echo " Posted to #$name"
|
|
159
|
+
else
|
|
160
|
+
echo " Failed to post to #$name"
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# Rate limit: Don't spam Discord API
|
|
164
|
+
sleep 1
|
|
165
|
+
done
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**When to use**: Announcements, alerts, status updates across channels.
|
|
169
|
+
|
|
170
|
+
## Pattern 6: File Upload with Context
|
|
171
|
+
|
|
172
|
+
**Use case**: Share a file with explanation
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
#!/bin/bash
|
|
176
|
+
|
|
177
|
+
CHANNEL_ID="1234567890123456789"
|
|
178
|
+
REPORT_FILE="./daily-report.pdf"
|
|
179
|
+
|
|
180
|
+
# Upload file
|
|
181
|
+
UPLOAD_RESULT=$(agent-discord file upload "$CHANNEL_ID" "$REPORT_FILE")
|
|
182
|
+
|
|
183
|
+
if echo "$UPLOAD_RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
184
|
+
FILE_ID=$(echo "$UPLOAD_RESULT" | jq -r '.id')
|
|
185
|
+
echo "File uploaded: $FILE_ID"
|
|
186
|
+
|
|
187
|
+
# Send context message
|
|
188
|
+
agent-discord message send "$CHANNEL_ID" "Daily report is ready! Key highlights:
|
|
189
|
+
- 95% test coverage
|
|
190
|
+
- 3 bugs fixed
|
|
191
|
+
- 2 new features deployed"
|
|
192
|
+
else
|
|
193
|
+
echo "Upload failed: $(echo "$UPLOAD_RESULT" | jq -r '.error')"
|
|
194
|
+
exit 1
|
|
195
|
+
fi
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**When to use**: Automated reporting, log sharing, artifact distribution.
|
|
199
|
+
|
|
200
|
+
## Pattern 7: User Lookup and Mention
|
|
201
|
+
|
|
202
|
+
**Use case**: Find a user and mention them in a message
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
#!/bin/bash
|
|
206
|
+
|
|
207
|
+
CHANNEL_ID="1234567890123456789"
|
|
208
|
+
USERNAME="john"
|
|
209
|
+
|
|
210
|
+
# Get guild members
|
|
211
|
+
USERS=$(agent-discord user list)
|
|
212
|
+
USER_ID=$(echo "$USERS" | jq -r --arg name "$USERNAME" '.[] | select(.username | contains($name)) | .id' | head -1)
|
|
213
|
+
|
|
214
|
+
if [ -z "$USER_ID" ]; then
|
|
215
|
+
echo "User $USERNAME not found"
|
|
216
|
+
exit 1
|
|
217
|
+
fi
|
|
218
|
+
|
|
219
|
+
# Send message with mention
|
|
220
|
+
agent-discord message send "$CHANNEL_ID" "Hey <@$USER_ID>, the build is ready for review!"
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**When to use**: Notifications, task assignments, code review requests.
|
|
224
|
+
|
|
225
|
+
**Note**: Discord mentions use format `<@USER_ID>`.
|
|
226
|
+
|
|
227
|
+
## Pattern 8: Reaction-Based Workflow
|
|
228
|
+
|
|
229
|
+
**Use case**: Use reactions as simple state indicators
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
#!/bin/bash
|
|
233
|
+
|
|
234
|
+
CHANNEL_ID="1234567890123456789"
|
|
235
|
+
|
|
236
|
+
# Send deployment message
|
|
237
|
+
RESULT=$(agent-discord message send "$CHANNEL_ID" "Deploying v2.1.0 to production...")
|
|
238
|
+
MSG_ID=$(echo "$RESULT" | jq -r '.id')
|
|
239
|
+
|
|
240
|
+
# Mark as in-progress
|
|
241
|
+
agent-discord reaction add "$CHANNEL_ID" "$MSG_ID" "hourglass"
|
|
242
|
+
|
|
243
|
+
# Simulate deployment
|
|
244
|
+
sleep 5
|
|
245
|
+
|
|
246
|
+
# Remove in-progress, add success
|
|
247
|
+
agent-discord reaction remove "$CHANNEL_ID" "$MSG_ID" "hourglass"
|
|
248
|
+
agent-discord reaction add "$CHANNEL_ID" "$MSG_ID" "white_check_mark"
|
|
249
|
+
|
|
250
|
+
# Send completion message
|
|
251
|
+
agent-discord message send "$CHANNEL_ID" "Deployed v2.1.0 to production successfully!"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**When to use**: Visual status tracking, workflow states, quick acknowledgments.
|
|
255
|
+
|
|
256
|
+
## Pattern 9: Error Handling and Retry
|
|
257
|
+
|
|
258
|
+
**Use case**: Robust message sending with retries
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
#!/bin/bash
|
|
262
|
+
|
|
263
|
+
send_with_retry() {
|
|
264
|
+
local channel_id=$1
|
|
265
|
+
local message=$2
|
|
266
|
+
local max_attempts=3
|
|
267
|
+
local attempt=1
|
|
268
|
+
|
|
269
|
+
while [ $attempt -le $max_attempts ]; do
|
|
270
|
+
echo "Attempt $attempt/$max_attempts..."
|
|
271
|
+
|
|
272
|
+
RESULT=$(agent-discord message send "$channel_id" "$message")
|
|
273
|
+
|
|
274
|
+
if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
275
|
+
echo "Message sent successfully!"
|
|
276
|
+
return 0
|
|
277
|
+
fi
|
|
278
|
+
|
|
279
|
+
ERROR=$(echo "$RESULT" | jq -r '.error // "Unknown error"')
|
|
280
|
+
echo "Failed: $ERROR"
|
|
281
|
+
|
|
282
|
+
# Don't retry on certain errors
|
|
283
|
+
if echo "$ERROR" | grep -q "Unknown Channel"; then
|
|
284
|
+
echo "Channel not found - not retrying"
|
|
285
|
+
return 1
|
|
286
|
+
fi
|
|
287
|
+
|
|
288
|
+
if [ $attempt -lt $max_attempts ]; then
|
|
289
|
+
sleep $((attempt * 2)) # Exponential backoff
|
|
290
|
+
fi
|
|
291
|
+
|
|
292
|
+
attempt=$((attempt + 1))
|
|
293
|
+
done
|
|
294
|
+
|
|
295
|
+
echo "Failed after $max_attempts attempts"
|
|
296
|
+
return 1
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
# Usage
|
|
300
|
+
CHANNEL_ID="1234567890123456789"
|
|
301
|
+
send_with_retry "$CHANNEL_ID" "Important message!"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**When to use**: Production scripts, critical notifications, unreliable networks.
|
|
305
|
+
|
|
306
|
+
## Pattern 10: Switch Guilds for Operations
|
|
307
|
+
|
|
308
|
+
**Use case**: Work with multiple Discord servers
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
#!/bin/bash
|
|
312
|
+
|
|
313
|
+
# List all guilds
|
|
314
|
+
GUILDS=$(agent-discord guild list)
|
|
315
|
+
echo "Available guilds:"
|
|
316
|
+
echo "$GUILDS" | jq -r '.[] | " \(.name) (\(.id)) \(if .current then "[current]" else "" end)"'
|
|
317
|
+
|
|
318
|
+
# Switch to a specific guild
|
|
319
|
+
TARGET_GUILD=$(echo "$GUILDS" | jq -r '.[] | select(.name | contains("Production")) | .id')
|
|
320
|
+
if [ -n "$TARGET_GUILD" ]; then
|
|
321
|
+
agent-discord guild switch "$TARGET_GUILD"
|
|
322
|
+
echo "Switched to Production guild"
|
|
323
|
+
fi
|
|
324
|
+
|
|
325
|
+
# Now operations use the new guild
|
|
326
|
+
agent-discord channel list
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**When to use**: Managing multiple servers, cross-server operations.
|
|
330
|
+
|
|
331
|
+
## Best Practices
|
|
332
|
+
|
|
333
|
+
### 1. Always Get Channel IDs First
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Good - look up channel ID
|
|
337
|
+
CHANNELS=$(agent-discord channel list)
|
|
338
|
+
CHANNEL_ID=$(echo "$CHANNELS" | jq -r '.[] | select(.name=="general") | .id')
|
|
339
|
+
agent-discord message send "$CHANNEL_ID" "Hello"
|
|
340
|
+
|
|
341
|
+
# Bad - hardcoded IDs without documentation
|
|
342
|
+
agent-discord message send 1234567890123456789 "Hello"
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### 2. Check for Success
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Good
|
|
349
|
+
RESULT=$(agent-discord message send "$CHANNEL_ID" "Hello")
|
|
350
|
+
if echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
351
|
+
echo "Success!"
|
|
352
|
+
else
|
|
353
|
+
echo "Failed: $(echo "$RESULT" | jq -r '.error')"
|
|
354
|
+
fi
|
|
355
|
+
|
|
356
|
+
# Bad
|
|
357
|
+
agent-discord message send "$CHANNEL_ID" "Hello" # No error checking
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 3. Rate Limit Your Requests
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Good - respect Discord API limits
|
|
364
|
+
for channel_id in "${CHANNEL_IDS[@]}"; do
|
|
365
|
+
agent-discord message send "$channel_id" "$MESSAGE"
|
|
366
|
+
sleep 1 # 1 second between requests
|
|
367
|
+
done
|
|
368
|
+
|
|
369
|
+
# Bad - rapid-fire requests
|
|
370
|
+
for channel_id in "${CHANNEL_IDS[@]}"; do
|
|
371
|
+
agent-discord message send "$channel_id" "$MESSAGE"
|
|
372
|
+
done
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### 4. Cache Channel Lists
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
# Good - fetch once, reuse
|
|
379
|
+
CHANNELS=$(agent-discord channel list)
|
|
380
|
+
for name in "${CHANNEL_NAMES[@]}"; do
|
|
381
|
+
id=$(echo "$CHANNELS" | jq -r --arg n "$name" '.[] | select(.name==$n) | .id')
|
|
382
|
+
agent-discord message send "$id" "$MESSAGE"
|
|
383
|
+
done
|
|
384
|
+
|
|
385
|
+
# Bad - fetch repeatedly
|
|
386
|
+
for name in "${CHANNEL_NAMES[@]}"; do
|
|
387
|
+
CHANNELS=$(agent-discord channel list) # Wasteful!
|
|
388
|
+
id=$(echo "$CHANNELS" | jq -r --arg n "$name" '.[] | select(.name==$n) | .id')
|
|
389
|
+
agent-discord message send "$id" "$MESSAGE"
|
|
390
|
+
done
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### 5. Use Reactions for Quick Feedback
|
|
394
|
+
|
|
395
|
+
```bash
|
|
396
|
+
# Good - reactions are lightweight
|
|
397
|
+
agent-discord reaction add "$CHANNEL_ID" "$MSG_ID" "thumbsup"
|
|
398
|
+
|
|
399
|
+
# Okay - but more verbose for simple acknowledgment
|
|
400
|
+
agent-discord message send "$CHANNEL_ID" "Acknowledged!"
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## Anti-Patterns
|
|
404
|
+
|
|
405
|
+
### Don't Poll Too Frequently
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Bad - polls every second (may get rate limited)
|
|
409
|
+
while true; do
|
|
410
|
+
agent-discord message list "$CHANNEL_ID" --limit 1
|
|
411
|
+
sleep 1
|
|
412
|
+
done
|
|
413
|
+
|
|
414
|
+
# Good - reasonable interval
|
|
415
|
+
while true; do
|
|
416
|
+
agent-discord message list "$CHANNEL_ID" --limit 1
|
|
417
|
+
sleep 10 # 10 seconds
|
|
418
|
+
done
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### Don't Ignore Errors
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
# Bad
|
|
425
|
+
agent-discord message send "$CHANNEL_ID" "Hello"
|
|
426
|
+
# Continues even if it failed
|
|
427
|
+
|
|
428
|
+
# Good
|
|
429
|
+
RESULT=$(agent-discord message send "$CHANNEL_ID" "Hello")
|
|
430
|
+
if ! echo "$RESULT" | jq -e '.id' > /dev/null 2>&1; then
|
|
431
|
+
echo "Failed to send message"
|
|
432
|
+
exit 1
|
|
433
|
+
fi
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Don't Spam Channels
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Bad - sends 100 messages
|
|
440
|
+
for i in {1..100}; do
|
|
441
|
+
agent-discord message send "$CHANNEL_ID" "Message $i"
|
|
442
|
+
done
|
|
443
|
+
|
|
444
|
+
# Good - batch into single message
|
|
445
|
+
MESSAGE="Updates:"
|
|
446
|
+
for i in {1..100}; do
|
|
447
|
+
MESSAGE="$MESSAGE\n$i. Item $i"
|
|
448
|
+
done
|
|
449
|
+
agent-discord message send "$CHANNEL_ID" "$MESSAGE"
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
## See Also
|
|
453
|
+
|
|
454
|
+
- [Authentication Guide](authentication.md) - Setting up credentials
|
|
455
|
+
- [Templates](../templates/) - Runnable example scripts
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# guild-summary.sh - Generate a comprehensive Discord guild summary
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./guild-summary.sh [--json]
|
|
7
|
+
#
|
|
8
|
+
# Options:
|
|
9
|
+
# --json Output raw JSON instead of formatted text
|
|
10
|
+
#
|
|
11
|
+
# Example:
|
|
12
|
+
# ./guild-summary.sh
|
|
13
|
+
# ./guild-summary.sh --json > summary.json
|
|
14
|
+
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
|
|
17
|
+
OUTPUT_JSON=false
|
|
18
|
+
if [ $# -gt 0 ] && [ "$1" = "--json" ]; then
|
|
19
|
+
OUTPUT_JSON=true
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
RED='\033[0;31m'
|
|
23
|
+
GREEN='\033[0;32m'
|
|
24
|
+
YELLOW='\033[1;33m'
|
|
25
|
+
BLUE='\033[0;34m'
|
|
26
|
+
CYAN='\033[0;36m'
|
|
27
|
+
BOLD='\033[1m'
|
|
28
|
+
NC='\033[0m'
|
|
29
|
+
|
|
30
|
+
if ! command -v agent-discord &> /dev/null; then
|
|
31
|
+
echo -e "${RED}Error: agent-discord not found${NC}" >&2
|
|
32
|
+
echo "" >&2
|
|
33
|
+
echo "Install it with:" >&2
|
|
34
|
+
echo " bun install -g agent-discord" >&2
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
AUTH_STATUS=$(agent-discord auth status 2>&1)
|
|
39
|
+
|
|
40
|
+
if echo "$AUTH_STATUS" | jq -e '.error' > /dev/null 2>&1; then
|
|
41
|
+
echo -e "${RED}Not authenticated!${NC}" >&2
|
|
42
|
+
echo "" >&2
|
|
43
|
+
echo "Run this to authenticate:" >&2
|
|
44
|
+
echo " agent-discord auth extract" >&2
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
CURRENT_GUILD=$(echo "$AUTH_STATUS" | jq -r '.current_guild // ""')
|
|
49
|
+
if [ -z "$CURRENT_GUILD" ]; then
|
|
50
|
+
echo -e "${RED}No guild selected!${NC}" >&2
|
|
51
|
+
echo "" >&2
|
|
52
|
+
echo "Run this to select a guild:" >&2
|
|
53
|
+
echo " agent-discord guild list" >&2
|
|
54
|
+
echo " agent-discord guild switch <guild-id>" >&2
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
echo -e "${YELLOW}Fetching guild snapshot...${NC}" >&2
|
|
59
|
+
SNAPSHOT=$(agent-discord snapshot 2>&1)
|
|
60
|
+
|
|
61
|
+
if echo "$SNAPSHOT" | jq -e '.error' > /dev/null 2>&1; then
|
|
62
|
+
echo -e "${RED}Failed to get snapshot${NC}" >&2
|
|
63
|
+
ERROR_MSG=$(echo "$SNAPSHOT" | jq -r '.error // "Unknown error"')
|
|
64
|
+
echo -e "${RED}Error: $ERROR_MSG${NC}" >&2
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
if [ "$OUTPUT_JSON" = true ]; then
|
|
69
|
+
echo "$SNAPSHOT"
|
|
70
|
+
exit 0
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
GUILD_NAME=$(echo "$SNAPSHOT" | jq -r '.guild.name // "Unknown"')
|
|
74
|
+
GUILD_ID=$(echo "$SNAPSHOT" | jq -r '.guild.id // "Unknown"')
|
|
75
|
+
|
|
76
|
+
CHANNELS=$(echo "$SNAPSHOT" | jq '.channels // []')
|
|
77
|
+
CHANNEL_COUNT=$(echo "$CHANNELS" | jq 'length')
|
|
78
|
+
TEXT_COUNT=$(echo "$CHANNELS" | jq '[.[] | select(.type == 0)] | length')
|
|
79
|
+
VOICE_COUNT=$(echo "$CHANNELS" | jq '[.[] | select(.type == 2)] | length')
|
|
80
|
+
CATEGORY_COUNT=$(echo "$CHANNELS" | jq '[.[] | select(.type == 4)] | length')
|
|
81
|
+
|
|
82
|
+
MEMBERS=$(echo "$SNAPSHOT" | jq '.members // []')
|
|
83
|
+
MEMBER_COUNT=$(echo "$MEMBERS" | jq 'length')
|
|
84
|
+
|
|
85
|
+
MESSAGES=$(echo "$SNAPSHOT" | jq '.recent_messages // []')
|
|
86
|
+
MESSAGE_COUNT=$(echo "$MESSAGES" | jq 'length')
|
|
87
|
+
|
|
88
|
+
echo ""
|
|
89
|
+
echo -e "${BOLD}${BLUE}=====================================================${NC}"
|
|
90
|
+
echo -e "${BOLD}${BLUE} Discord Guild Summary${NC}"
|
|
91
|
+
echo -e "${BOLD}${BLUE}=====================================================${NC}"
|
|
92
|
+
echo ""
|
|
93
|
+
echo -e "${BOLD}Guild:${NC} $GUILD_NAME"
|
|
94
|
+
echo -e "${BOLD}ID:${NC} $GUILD_ID"
|
|
95
|
+
echo ""
|
|
96
|
+
|
|
97
|
+
echo -e "${BOLD}${CYAN}Channels (${CHANNEL_COUNT} total)${NC}"
|
|
98
|
+
echo -e " Text: $TEXT_COUNT"
|
|
99
|
+
echo -e " Voice: $VOICE_COUNT"
|
|
100
|
+
echo -e " Categories: $CATEGORY_COUNT"
|
|
101
|
+
echo ""
|
|
102
|
+
|
|
103
|
+
echo -e "${BOLD}${CYAN}Text Channels:${NC}"
|
|
104
|
+
echo "$CHANNELS" | jq -r '
|
|
105
|
+
[.[] | select(.type == 0)] |
|
|
106
|
+
.[0:10] |
|
|
107
|
+
.[] |
|
|
108
|
+
" #\(.name) (\(.id))"
|
|
109
|
+
'
|
|
110
|
+
if [ "$TEXT_COUNT" -gt 10 ]; then
|
|
111
|
+
echo " ... and $((TEXT_COUNT - 10)) more"
|
|
112
|
+
fi
|
|
113
|
+
echo ""
|
|
114
|
+
|
|
115
|
+
echo -e "${BOLD}${CYAN}Members (${MEMBER_COUNT} shown)${NC}"
|
|
116
|
+
echo ""
|
|
117
|
+
|
|
118
|
+
echo -e "${BOLD}${CYAN}Sample Members:${NC}"
|
|
119
|
+
echo "$MEMBERS" | jq -r '
|
|
120
|
+
.[0:10] |
|
|
121
|
+
.[] |
|
|
122
|
+
" \(.username) \(if .global_name then "(\(.global_name))" else "" end) [\(.id)]"
|
|
123
|
+
'
|
|
124
|
+
if [ "$MEMBER_COUNT" -gt 10 ]; then
|
|
125
|
+
echo " ... and $((MEMBER_COUNT - 10)) more"
|
|
126
|
+
fi
|
|
127
|
+
echo ""
|
|
128
|
+
|
|
129
|
+
echo -e "${BOLD}${CYAN}Recent Activity (${MESSAGE_COUNT} messages)${NC}"
|
|
130
|
+
echo ""
|
|
131
|
+
|
|
132
|
+
if [ "$MESSAGE_COUNT" -gt 0 ]; then
|
|
133
|
+
echo -e "${BOLD}${CYAN}Latest Messages:${NC}"
|
|
134
|
+
echo "$MESSAGES" | jq -r '
|
|
135
|
+
.[0:5] |
|
|
136
|
+
.[] |
|
|
137
|
+
" [#\(.channel_name)] \(.author): \(.content[0:50])\(if (.content | length) > 50 then "..." else "" end)"
|
|
138
|
+
'
|
|
139
|
+
echo ""
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
echo -e "${BOLD}${CYAN}Quick Actions:${NC}"
|
|
143
|
+
echo ""
|
|
144
|
+
echo -e " ${GREEN}# Send message to a channel${NC}"
|
|
145
|
+
FIRST_CHANNEL=$(echo "$CHANNELS" | jq -r '[.[] | select(.type == 0)][0].id // "CHANNEL_ID"')
|
|
146
|
+
FIRST_CHANNEL_NAME=$(echo "$CHANNELS" | jq -r '[.[] | select(.type == 0)][0].name // "general"')
|
|
147
|
+
echo -e " agent-discord message send $FIRST_CHANNEL \"Hello!\""
|
|
148
|
+
echo ""
|
|
149
|
+
echo -e " ${GREEN}# List messages in #$FIRST_CHANNEL_NAME${NC}"
|
|
150
|
+
echo -e " agent-discord message list $FIRST_CHANNEL --limit 10"
|
|
151
|
+
echo ""
|
|
152
|
+
echo -e " ${GREEN}# Get user info${NC}"
|
|
153
|
+
FIRST_USER=$(echo "$MEMBERS" | jq -r '.[0].id // "USER_ID"')
|
|
154
|
+
echo -e " agent-discord user info $FIRST_USER"
|
|
155
|
+
echo ""
|
|
156
|
+
echo -e " ${GREEN}# Switch to another guild${NC}"
|
|
157
|
+
echo -e " agent-discord guild list"
|
|
158
|
+
echo -e " agent-discord guild switch <guild-id>"
|
|
159
|
+
echo ""
|
|
160
|
+
|
|
161
|
+
echo -e "${BOLD}${BLUE}=====================================================${NC}"
|
|
162
|
+
echo ""
|
|
163
|
+
|
|
164
|
+
SNAPSHOT_FILE="guild-snapshot-$(date +%Y%m%d-%H%M%S).json"
|
|
165
|
+
echo "$SNAPSHOT" > "$SNAPSHOT_FILE"
|
|
166
|
+
echo -e "${GREEN}Full snapshot saved to: $SNAPSHOT_FILE${NC}"
|
|
167
|
+
echo ""
|