agent-messenger 1.0.0 → 1.1.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 +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/e2e.yml.disabled +69 -0
- package/README.md +16 -14
- package/biome.json +33 -1
- package/bun.lock +63 -0
- package/dist/package.json +8 -4
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +4 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/discord/cli.js +1 -1
- package/dist/src/platforms/discord/client.d.ts.map +1 -1
- package/dist/src/platforms/discord/client.js +3 -3
- package/dist/src/platforms/discord/client.js.map +1 -1
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/user.js +10 -1
- package/dist/src/platforms/discord/commands/user.js.map +1 -1
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/discord/credential-manager.js +18 -12
- package/dist/src/platforms/discord/credential-manager.js.map +1 -1
- package/dist/src/platforms/slack/cli.js +1 -1
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/slack/credential-manager.js +20 -6
- package/dist/src/platforms/slack/credential-manager.js.map +1 -1
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/slack/token-extractor.js +34 -9
- package/dist/src/platforms/slack/token-extractor.js.map +1 -1
- package/dist/src/platforms/teams/cli.d.ts.map +1 -0
- package/dist/{cli.js → src/platforms/teams/cli.js} +11 -10
- package/dist/src/platforms/teams/cli.js.map +1 -0
- package/dist/src/platforms/teams/client.d.ts +32 -0
- package/dist/src/platforms/teams/client.d.ts.map +1 -0
- package/dist/src/platforms/teams/client.js +202 -0
- package/dist/src/platforms/teams/client.js.map +1 -0
- package/dist/src/platforms/teams/commands/auth.d.ts +14 -0
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/auth.js +176 -0
- package/dist/src/platforms/teams/commands/auth.js.map +1 -0
- package/dist/src/platforms/teams/commands/channel.d.ts +13 -0
- package/dist/src/platforms/teams/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/channel.js +97 -0
- package/dist/src/platforms/teams/commands/channel.js.map +1 -0
- package/dist/src/platforms/teams/commands/file.d.ts +12 -0
- package/dist/src/platforms/teams/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/file.js +104 -0
- package/dist/src/platforms/teams/commands/file.js.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.d.ts +5 -2
- package/dist/src/platforms/teams/commands/index.d.ts.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.js +5 -2
- package/dist/src/platforms/teams/commands/index.js.map +1 -0
- package/dist/src/platforms/teams/commands/message.d.ts +17 -0
- package/dist/src/platforms/teams/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/message.js +133 -0
- package/dist/src/platforms/teams/commands/message.js.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts +9 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.js +68 -0
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts +10 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.js +85 -0
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/teams/commands/team.d.ts +18 -0
- package/dist/src/platforms/teams/commands/team.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/team.js +130 -0
- package/dist/src/platforms/teams/commands/team.js.map +1 -0
- package/dist/src/platforms/teams/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/user.js +88 -0
- package/dist/src/platforms/teams/commands/user.js.map +1 -0
- package/dist/src/platforms/teams/credential-manager.d.ts +18 -0
- package/dist/src/platforms/teams/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/teams/credential-manager.js +81 -0
- package/dist/src/platforms/teams/credential-manager.js.map +1 -0
- package/dist/src/platforms/teams/index.d.ts +4 -0
- package/dist/src/platforms/teams/index.d.ts.map +1 -0
- package/dist/src/platforms/teams/index.js +6 -0
- package/dist/src/platforms/teams/index.js.map +1 -0
- package/dist/src/platforms/teams/token-extractor.d.ts +36 -0
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/teams/token-extractor.js +335 -0
- package/dist/src/platforms/teams/token-extractor.js.map +1 -0
- package/dist/src/platforms/teams/types.d.ts +209 -0
- package/dist/src/platforms/teams/types.d.ts.map +1 -0
- package/dist/src/platforms/teams/types.js +65 -0
- package/dist/src/platforms/teams/types.js.map +1 -0
- package/docs/teams.md +321 -0
- package/e2e/README.md +256 -0
- package/e2e/config.ts +45 -0
- package/e2e/discord.e2e.test.ts +252 -0
- package/e2e/helpers.ts +107 -0
- package/e2e/slack.e2e.test.ts +309 -0
- package/package.json +8 -4
- package/scripts/postbuild.ts +15 -0
- package/skills/agent-teams/SKILL.md +292 -0
- package/skills/agent-teams/references/authentication.md +375 -0
- package/skills/agent-teams/references/common-patterns.md +596 -0
- package/skills/agent-teams/templates/monitor-channel.sh +239 -0
- package/skills/agent-teams/templates/post-message.sh +224 -0
- package/skills/agent-teams/templates/team-summary.sh +210 -0
- package/src/cli.ts +4 -0
- package/src/platforms/discord/client.ts +3 -3
- package/src/platforms/discord/commands/auth.test.ts +48 -32
- package/src/platforms/discord/commands/channel.test.ts +54 -42
- package/src/platforms/discord/commands/file.test.ts +40 -53
- package/src/platforms/discord/commands/guild.test.ts +47 -27
- package/src/platforms/discord/commands/message.test.ts +54 -51
- package/src/platforms/discord/commands/reaction.test.ts +54 -42
- package/src/platforms/discord/commands/user.ts +12 -1
- package/src/platforms/discord/credential-manager.test.ts +137 -136
- package/src/platforms/discord/credential-manager.ts +20 -13
- package/src/platforms/discord/token-extractor.test.ts +133 -383
- package/{tests → src/platforms/slack}/cli.test.ts +3 -3
- package/{tests/slack-client.test.ts → src/platforms/slack/client.test.ts} +1 -1
- package/{tests → src/platforms/slack}/commands/auth.test.ts +25 -13
- package/{tests → src/platforms/slack}/commands/channel.test.ts +2 -2
- package/{tests → src/platforms/slack}/commands/file.test.ts +2 -2
- package/{tests → src/platforms/slack}/commands/message.test.ts +2 -2
- package/{tests → src/platforms/slack}/commands/reaction.test.ts +1 -1
- package/{tests → src/platforms/slack}/commands/snapshot.test.ts +117 -105
- package/{tests → src/platforms/slack}/commands/user.test.ts +3 -3
- package/{tests → src/platforms/slack}/commands/workspace.test.ts +44 -95
- package/{tests → src/platforms/slack}/credential-manager.test.ts +2 -2
- package/src/platforms/slack/credential-manager.ts +22 -7
- package/src/platforms/slack/token-extractor-node-test.ts +40 -0
- package/src/platforms/slack/token-extractor-node.test.ts +10 -0
- package/src/platforms/slack/token-extractor.ts +36 -10
- package/{tests → src/platforms/slack}/types.test.ts +1 -1
- package/src/platforms/teams/cli.ts +36 -0
- package/src/platforms/teams/client.test.ts +500 -0
- package/src/platforms/teams/client.ts +365 -0
- package/src/platforms/teams/commands/auth.test.ts +99 -0
- package/src/platforms/teams/commands/auth.ts +232 -0
- package/src/platforms/teams/commands/channel.test.ts +147 -0
- package/src/platforms/teams/commands/channel.ts +129 -0
- package/src/platforms/teams/commands/file.test.ts +88 -0
- package/src/platforms/teams/commands/file.ts +144 -0
- package/src/platforms/teams/commands/index.ts +12 -0
- package/src/platforms/teams/commands/message.test.ts +110 -0
- package/src/platforms/teams/commands/message.ts +188 -0
- package/src/platforms/teams/commands/reaction.test.ts +87 -0
- package/src/platforms/teams/commands/reaction.ts +104 -0
- package/src/platforms/teams/commands/snapshot.test.ts +35 -0
- package/src/platforms/teams/commands/snapshot.ts +115 -0
- package/src/platforms/teams/commands/team.test.ts +157 -0
- package/src/platforms/teams/commands/team.ts +164 -0
- package/src/platforms/teams/commands/user.test.ts +83 -0
- package/src/platforms/teams/commands/user.ts +112 -0
- package/src/platforms/teams/credential-manager.test.ts +178 -0
- package/src/platforms/teams/credential-manager.ts +92 -0
- package/src/platforms/teams/index.ts +5 -0
- package/src/platforms/teams/token-extractor.test.ts +429 -0
- package/src/platforms/teams/token-extractor.ts +462 -0
- package/src/platforms/teams/types.test.ts +226 -0
- package/src/platforms/teams/types.ts +140 -0
- package/tsconfig.json +1 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -140
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/channel.d.ts +0 -3
- package/dist/commands/channel.d.ts.map +0 -1
- package/dist/commands/channel.js +0 -118
- package/dist/commands/channel.js.map +0 -1
- package/dist/commands/file.d.ts +0 -3
- package/dist/commands/file.d.ts.map +0 -1
- package/dist/commands/file.js +0 -113
- package/dist/commands/file.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/message.d.ts +0 -3
- package/dist/commands/message.d.ts.map +0 -1
- package/dist/commands/message.js +0 -214
- package/dist/commands/message.js.map +0 -1
- package/dist/commands/reaction.d.ts +0 -3
- package/dist/commands/reaction.d.ts.map +0 -1
- package/dist/commands/reaction.js +0 -100
- package/dist/commands/reaction.js.map +0 -1
- package/dist/commands/snapshot.d.ts +0 -3
- package/dist/commands/snapshot.d.ts.map +0 -1
- package/dist/commands/snapshot.js +0 -88
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/user.d.ts.map +0 -1
- package/dist/commands/user.js +0 -96
- package/dist/commands/user.js.map +0 -1
- package/dist/commands/workspace.d.ts +0 -3
- package/dist/commands/workspace.d.ts.map +0 -1
- package/dist/commands/workspace.js +0 -89
- package/dist/commands/workspace.js.map +0 -1
- package/dist/lib/credential-manager.d.ts +0 -13
- package/dist/lib/credential-manager.d.ts.map +0 -1
- package/dist/lib/credential-manager.js +0 -58
- package/dist/lib/credential-manager.js.map +0 -1
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -3
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/ref-manager.d.ts +0 -26
- package/dist/lib/ref-manager.d.ts.map +0 -1
- package/dist/lib/ref-manager.js +0 -92
- package/dist/lib/ref-manager.js.map +0 -1
- package/dist/lib/slack-client.d.ts +0 -37
- package/dist/lib/slack-client.d.ts.map +0 -1
- package/dist/lib/slack-client.js +0 -379
- package/dist/lib/slack-client.js.map +0 -1
- package/dist/lib/token-extractor.d.ts +0 -28
- package/dist/lib/token-extractor.d.ts.map +0 -1
- package/dist/lib/token-extractor.js +0 -401
- package/dist/lib/token-extractor.js.map +0 -1
- package/dist/src/platforms/discord/client.test.d.ts +0 -2
- package/dist/src/platforms/discord/client.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/client.test.js +0 -367
- package/dist/src/platforms/discord/client.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.js +0 -65
- package/dist/src/platforms/discord/commands/auth.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.js +0 -136
- package/dist/src/platforms/discord/commands/channel.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.js +0 -83
- package/dist/src/platforms/discord/commands/file.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.js +0 -100
- package/dist/src/platforms/discord/commands/guild.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.js +0 -91
- package/dist/src/platforms/discord/commands/message.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.js +0 -115
- package/dist/src/platforms/discord/commands/reaction.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.js +0 -25
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.js +0 -103
- package/dist/src/platforms/discord/commands/user.test.js.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.d.ts +0 -2
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.js +0 -136
- package/dist/src/platforms/discord/credential-manager.test.js.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.d.ts +0 -2
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.js +0 -789
- package/dist/src/platforms/discord/token-extractor.test.js.map +0 -1
- package/dist/src/platforms/discord/types.test.d.ts +0 -2
- package/dist/src/platforms/discord/types.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/types.test.js +0 -211
- package/dist/src/platforms/discord/types.test.js.map +0 -1
- package/dist/src/shared/utils/concurrency.test.d.ts +0 -2
- package/dist/src/shared/utils/concurrency.test.d.ts.map +0 -1
- package/dist/src/shared/utils/concurrency.test.js +0 -39
- package/dist/src/shared/utils/concurrency.test.js.map +0 -1
- package/dist/tests/cli.test.d.ts +0 -2
- package/dist/tests/cli.test.d.ts.map +0 -1
- package/dist/tests/cli.test.js +0 -83
- package/dist/tests/cli.test.js.map +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +0 -3
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +0 -2
- package/dist/tests/commands/auth.test.d.ts.map +0 -1
- package/dist/tests/commands/auth.test.js +0 -304
- package/dist/tests/commands/auth.test.js.map +0 -1
- package/dist/tests/commands/channel.test.d.ts +0 -2
- package/dist/tests/commands/channel.test.d.ts.map +0 -1
- package/dist/tests/commands/channel.test.js +0 -166
- package/dist/tests/commands/channel.test.js.map +0 -1
- package/dist/tests/commands/file.test.d.ts +0 -2
- package/dist/tests/commands/file.test.d.ts.map +0 -1
- package/dist/tests/commands/file.test.js +0 -175
- package/dist/tests/commands/file.test.js.map +0 -1
- package/dist/tests/commands/message.test.d.ts +0 -2
- package/dist/tests/commands/message.test.d.ts.map +0 -1
- package/dist/tests/commands/message.test.js +0 -293
- package/dist/tests/commands/message.test.js.map +0 -1
- package/dist/tests/commands/reaction.test.d.ts +0 -2
- package/dist/tests/commands/reaction.test.d.ts.map +0 -1
- package/dist/tests/commands/reaction.test.js +0 -84
- package/dist/tests/commands/reaction.test.js.map +0 -1
- package/dist/tests/commands/snapshot.test.d.ts +0 -2
- package/dist/tests/commands/snapshot.test.d.ts.map +0 -1
- package/dist/tests/commands/snapshot.test.js +0 -280
- package/dist/tests/commands/snapshot.test.js.map +0 -1
- package/dist/tests/commands/user.test.d.ts +0 -2
- package/dist/tests/commands/user.test.d.ts.map +0 -1
- package/dist/tests/commands/user.test.js +0 -117
- package/dist/tests/commands/user.test.js.map +0 -1
- package/dist/tests/commands/workspace.test.d.ts +0 -2
- package/dist/tests/commands/workspace.test.d.ts.map +0 -1
- package/dist/tests/commands/workspace.test.js +0 -453
- package/dist/tests/commands/workspace.test.js.map +0 -1
- package/dist/tests/credential-manager.test.d.ts +0 -2
- package/dist/tests/credential-manager.test.d.ts.map +0 -1
- package/dist/tests/credential-manager.test.js +0 -199
- package/dist/tests/credential-manager.test.js.map +0 -1
- package/dist/tests/slack-client.test.d.ts +0 -2
- package/dist/tests/slack-client.test.d.ts.map +0 -1
- package/dist/tests/slack-client.test.js +0 -741
- package/dist/tests/slack-client.test.js.map +0 -1
- package/dist/tests/types.test.d.ts +0 -2
- package/dist/tests/types.test.d.ts.map +0 -1
- package/dist/tests/types.test.js +0 -215
- package/dist/tests/types.test.js.map +0 -1
- package/dist/types/index.d.ts +0 -369
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -92
- package/dist/types/index.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -2
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -5
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/output.d.ts +0 -2
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -4
- package/dist/utils/output.js.map +0 -1
- /package/dist/{cli.d.ts → src/platforms/teams/cli.d.ts} +0 -0
- /package/dist/{commands → src/platforms/teams/commands}/user.d.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test'
|
|
2
2
|
import { spawn } from 'bun'
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import { handleError } from '@/shared/utils/error-handler'
|
|
4
|
+
import { formatOutput } from '@/shared/utils/output'
|
|
5
|
+
import pkg from '../../../package.json'
|
|
6
6
|
|
|
7
7
|
describe('CLI Framework', () => {
|
|
8
8
|
describe('formatOutput utility', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
2
|
import type { WebClient } from '@slack/web-api'
|
|
3
|
-
import { SlackClient, SlackError } from '
|
|
3
|
+
import { SlackClient, SlackError } from '@/platforms/slack/client'
|
|
4
4
|
|
|
5
5
|
const mockWebClient: any = {
|
|
6
6
|
conversations: {
|
|
@@ -2,8 +2,8 @@ import { afterAll, beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
|
2
2
|
import { mkdirSync, rmSync } from 'node:fs'
|
|
3
3
|
import { homedir } from 'node:os'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
|
-
import { CredentialManager } from '
|
|
6
|
-
import { type ExtractedWorkspace, TokenExtractor } from '
|
|
5
|
+
import { CredentialManager } from '@/platforms/slack/credential-manager'
|
|
6
|
+
import { type ExtractedWorkspace, TokenExtractor } from '@/platforms/slack/token-extractor'
|
|
7
7
|
|
|
8
8
|
const testConfigDir = join(import.meta.dir, '.test-auth-config')
|
|
9
9
|
const testSlackDir = join(import.meta.dir, '.test-slack-data')
|
|
@@ -74,8 +74,9 @@ describe('TokenExtractor', () => {
|
|
|
74
74
|
|
|
75
75
|
describe('extract', () => {
|
|
76
76
|
test('throws error when Slack directory does not exist', async () => {
|
|
77
|
-
// Given: Slack directory does not exist
|
|
78
|
-
|
|
77
|
+
// Given: Slack directory does not exist (use unique path to avoid any collision)
|
|
78
|
+
const nonExistentPath = `/tmp/nonexistent-slack-${Date.now()}-${Math.random()}`
|
|
79
|
+
extractor = new TokenExtractor('darwin', nonExistentPath)
|
|
79
80
|
|
|
80
81
|
// When/Then: extract should throw
|
|
81
82
|
await expect(extractor.extract()).rejects.toThrow('Slack directory not found')
|
|
@@ -124,6 +125,7 @@ describe('Auth Commands Integration', () => {
|
|
|
124
125
|
|
|
125
126
|
beforeEach(() => {
|
|
126
127
|
rmSync(testConfigDir, { recursive: true, force: true })
|
|
128
|
+
mkdirSync(testConfigDir, { recursive: true })
|
|
127
129
|
credManager = new CredentialManager(testConfigDir)
|
|
128
130
|
})
|
|
129
131
|
|
|
@@ -350,23 +352,33 @@ describe('Output Formatting', () => {
|
|
|
350
352
|
})
|
|
351
353
|
|
|
352
354
|
describe('Error Handling', () => {
|
|
355
|
+
beforeEach(() => {
|
|
356
|
+
rmSync(testSlackDir, { recursive: true, force: true })
|
|
357
|
+
mkdirSync(testSlackDir, { recursive: true })
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
afterAll(() => {
|
|
361
|
+
rmSync(testSlackDir, { recursive: true, force: true })
|
|
362
|
+
})
|
|
363
|
+
|
|
353
364
|
test('handles missing Slack installation gracefully', async () => {
|
|
354
|
-
// Given: Slack is not installed
|
|
355
|
-
const
|
|
365
|
+
// Given: Slack is not installed (use unique path)
|
|
366
|
+
const nonExistentPath = `/tmp/nonexistent-slack-${Date.now()}-${Math.random()}`
|
|
367
|
+
const extractor = new TokenExtractor('darwin', nonExistentPath)
|
|
356
368
|
|
|
357
369
|
// When/Then: Should throw descriptive error
|
|
358
370
|
await expect(extractor.extract()).rejects.toThrow('Slack directory not found')
|
|
359
371
|
})
|
|
360
372
|
|
|
361
|
-
test('handles
|
|
362
|
-
// Given:
|
|
363
|
-
// This would require creating a corrupted LevelDB file
|
|
364
|
-
// We test that the extractor handles errors gracefully
|
|
373
|
+
test('handles empty Slack directory gracefully', async () => {
|
|
374
|
+
// Given: Slack directory exists but has no data
|
|
365
375
|
const extractor = new TokenExtractor('darwin', testSlackDir)
|
|
366
376
|
|
|
367
|
-
// When: Trying to extract from
|
|
368
|
-
|
|
369
|
-
|
|
377
|
+
// When: Trying to extract from empty directory
|
|
378
|
+
const result = await extractor.extract()
|
|
379
|
+
|
|
380
|
+
// Then: Should return empty array
|
|
381
|
+
expect(result).toEqual([])
|
|
370
382
|
})
|
|
371
383
|
|
|
372
384
|
test('handles missing Cookies database gracefully', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
|
-
import { SlackClient } from '
|
|
3
|
-
import type { SlackChannel } from '
|
|
2
|
+
import { SlackClient } from '@/platforms/slack/client'
|
|
3
|
+
import type { SlackChannel } from '@/platforms/slack/types'
|
|
4
4
|
|
|
5
5
|
describe('Channel Commands', () => {
|
|
6
6
|
let mockClient: SlackClient
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
|
-
import { SlackClient } from '
|
|
3
|
-
import type { SlackFile } from '
|
|
2
|
+
import { SlackClient } from '@/platforms/slack/client'
|
|
3
|
+
import type { SlackFile } from '@/platforms/slack/types'
|
|
4
4
|
|
|
5
5
|
describe('File Commands', () => {
|
|
6
6
|
let mockClient: SlackClient
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
|
-
import { SlackClient } from '
|
|
3
|
-
import type { SlackMessage } from '
|
|
2
|
+
import { SlackClient } from '@/platforms/slack/client'
|
|
3
|
+
import type { SlackMessage } from '@/platforms/slack/types'
|
|
4
4
|
|
|
5
5
|
describe('Message Commands', () => {
|
|
6
6
|
let mockClient: SlackClient
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, mock, test } from 'bun:test'
|
|
2
2
|
import { Command } from 'commander'
|
|
3
|
-
import { reactionCommand } from '
|
|
3
|
+
import { reactionCommand } from '@/platforms/slack/commands/reaction'
|
|
4
4
|
|
|
5
5
|
describe('reaction command', () => {
|
|
6
6
|
describe('add subcommand', () => {
|
|
@@ -1,113 +1,10 @@
|
|
|
1
|
-
import { expect,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
|
|
2
2
|
import { SlackClient } from '@/platforms/slack/client'
|
|
3
3
|
import { snapshotCommand } from '@/platforms/slack/commands/snapshot'
|
|
4
4
|
import { CredentialManager } from '@/platforms/slack/credential-manager'
|
|
5
5
|
import type { SlackChannel, SlackMessage, SlackUser } from '@/platforms/slack/types'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
CredentialManager: class {
|
|
9
|
-
async getWorkspace() {
|
|
10
|
-
return {
|
|
11
|
-
workspace_id: 'T123',
|
|
12
|
-
workspace_name: 'Test Workspace',
|
|
13
|
-
token: 'xoxc-test',
|
|
14
|
-
cookie: 'test-cookie',
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
}))
|
|
19
|
-
|
|
20
|
-
mock.module('@/platforms/slack/client', () => ({
|
|
21
|
-
SlackClient: class {
|
|
22
|
-
async testAuth() {
|
|
23
|
-
return {
|
|
24
|
-
user_id: 'U123',
|
|
25
|
-
team_id: 'T123',
|
|
26
|
-
user: 'testuser',
|
|
27
|
-
team: 'Test Workspace',
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async listChannels(): Promise<SlackChannel[]> {
|
|
31
|
-
return [
|
|
32
|
-
{
|
|
33
|
-
id: 'C123',
|
|
34
|
-
name: 'general',
|
|
35
|
-
is_private: false,
|
|
36
|
-
is_archived: false,
|
|
37
|
-
created: 1234567890,
|
|
38
|
-
creator: 'U123',
|
|
39
|
-
topic: { value: 'General discussion', creator: 'U123', last_set: 1234567890 },
|
|
40
|
-
purpose: { value: 'General channel', creator: 'U123', last_set: 1234567890 },
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: 'C456',
|
|
44
|
-
name: 'random',
|
|
45
|
-
is_private: false,
|
|
46
|
-
is_archived: false,
|
|
47
|
-
created: 1234567891,
|
|
48
|
-
creator: 'U123',
|
|
49
|
-
topic: { value: 'Random stuff', creator: 'U123', last_set: 1234567891 },
|
|
50
|
-
purpose: { value: 'Random channel', creator: 'U123', last_set: 1234567891 },
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
async getMessages(_channel: string, _limit?: number): Promise<SlackMessage[]> {
|
|
55
|
-
return [
|
|
56
|
-
{
|
|
57
|
-
ts: '1234567890.000100',
|
|
58
|
-
text: 'Hello world',
|
|
59
|
-
type: 'message',
|
|
60
|
-
user: 'U123',
|
|
61
|
-
username: 'testuser',
|
|
62
|
-
thread_ts: undefined,
|
|
63
|
-
reply_count: 0,
|
|
64
|
-
edited: undefined,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
ts: '1234567890.000200',
|
|
68
|
-
text: 'Second message',
|
|
69
|
-
type: 'message',
|
|
70
|
-
user: 'U456',
|
|
71
|
-
username: 'otheruser',
|
|
72
|
-
thread_ts: undefined,
|
|
73
|
-
reply_count: 0,
|
|
74
|
-
edited: undefined,
|
|
75
|
-
},
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
async listUsers(): Promise<SlackUser[]> {
|
|
79
|
-
return [
|
|
80
|
-
{
|
|
81
|
-
id: 'U123',
|
|
82
|
-
name: 'alice',
|
|
83
|
-
real_name: 'Alice Smith',
|
|
84
|
-
is_admin: true,
|
|
85
|
-
is_owner: false,
|
|
86
|
-
is_bot: false,
|
|
87
|
-
is_app_user: false,
|
|
88
|
-
profile: {
|
|
89
|
-
email: 'alice@example.com',
|
|
90
|
-
title: 'Engineer',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: 'U456',
|
|
95
|
-
name: 'bob',
|
|
96
|
-
real_name: 'Bob Jones',
|
|
97
|
-
is_admin: false,
|
|
98
|
-
is_owner: false,
|
|
99
|
-
is_bot: false,
|
|
100
|
-
is_app_user: false,
|
|
101
|
-
profile: {
|
|
102
|
-
email: 'bob@example.com',
|
|
103
|
-
title: 'Designer',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
}))
|
|
110
|
-
|
|
7
|
+
// Test the command structure (no mocks needed)
|
|
111
8
|
test('snapshot command exports correctly', () => {
|
|
112
9
|
expect(snapshotCommand).toBeDefined()
|
|
113
10
|
expect(typeof snapshotCommand).toBe('object')
|
|
@@ -136,6 +33,121 @@ test('snapshot command has --limit option', () => {
|
|
|
136
33
|
expect(hasLimit).toBe(true)
|
|
137
34
|
})
|
|
138
35
|
|
|
36
|
+
// Test snapshot logic using spyOn (no global mock pollution)
|
|
37
|
+
let credManagerSpy: ReturnType<typeof spyOn>
|
|
38
|
+
let clientTestAuthSpy: ReturnType<typeof spyOn>
|
|
39
|
+
let clientListChannelsSpy: ReturnType<typeof spyOn>
|
|
40
|
+
let clientListUsersSpy: ReturnType<typeof spyOn>
|
|
41
|
+
let clientGetMessagesSpy: ReturnType<typeof spyOn>
|
|
42
|
+
|
|
43
|
+
const mockChannels: SlackChannel[] = [
|
|
44
|
+
{
|
|
45
|
+
id: 'C123',
|
|
46
|
+
name: 'general',
|
|
47
|
+
is_private: false,
|
|
48
|
+
is_archived: false,
|
|
49
|
+
created: 1234567890,
|
|
50
|
+
creator: 'U123',
|
|
51
|
+
topic: { value: 'General discussion', creator: 'U123', last_set: 1234567890 },
|
|
52
|
+
purpose: { value: 'General channel', creator: 'U123', last_set: 1234567890 },
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'C456',
|
|
56
|
+
name: 'random',
|
|
57
|
+
is_private: false,
|
|
58
|
+
is_archived: false,
|
|
59
|
+
created: 1234567891,
|
|
60
|
+
creator: 'U123',
|
|
61
|
+
topic: { value: 'Random stuff', creator: 'U123', last_set: 1234567891 },
|
|
62
|
+
purpose: { value: 'Random channel', creator: 'U123', last_set: 1234567891 },
|
|
63
|
+
},
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
const mockMessages: SlackMessage[] = [
|
|
67
|
+
{
|
|
68
|
+
ts: '1234567890.000100',
|
|
69
|
+
text: 'Hello world',
|
|
70
|
+
type: 'message',
|
|
71
|
+
user: 'U123',
|
|
72
|
+
username: 'testuser',
|
|
73
|
+
thread_ts: undefined,
|
|
74
|
+
reply_count: 0,
|
|
75
|
+
edited: undefined,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
ts: '1234567890.000200',
|
|
79
|
+
text: 'Second message',
|
|
80
|
+
type: 'message',
|
|
81
|
+
user: 'U456',
|
|
82
|
+
username: 'otheruser',
|
|
83
|
+
thread_ts: undefined,
|
|
84
|
+
reply_count: 0,
|
|
85
|
+
edited: undefined,
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
const mockUsers: SlackUser[] = [
|
|
90
|
+
{
|
|
91
|
+
id: 'U123',
|
|
92
|
+
name: 'alice',
|
|
93
|
+
real_name: 'Alice Smith',
|
|
94
|
+
is_admin: true,
|
|
95
|
+
is_owner: false,
|
|
96
|
+
is_bot: false,
|
|
97
|
+
is_app_user: false,
|
|
98
|
+
profile: {
|
|
99
|
+
email: 'alice@example.com',
|
|
100
|
+
title: 'Engineer',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'U456',
|
|
105
|
+
name: 'bob',
|
|
106
|
+
real_name: 'Bob Jones',
|
|
107
|
+
is_admin: false,
|
|
108
|
+
is_owner: false,
|
|
109
|
+
is_bot: false,
|
|
110
|
+
is_app_user: false,
|
|
111
|
+
profile: {
|
|
112
|
+
email: 'bob@example.com',
|
|
113
|
+
title: 'Designer',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
beforeEach(() => {
|
|
119
|
+
// Spy on CredentialManager.prototype.getWorkspace
|
|
120
|
+
credManagerSpy = spyOn(CredentialManager.prototype, 'getWorkspace').mockResolvedValue({
|
|
121
|
+
workspace_id: 'T123',
|
|
122
|
+
workspace_name: 'Test Workspace',
|
|
123
|
+
token: 'xoxc-test',
|
|
124
|
+
cookie: 'test-cookie',
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
// Spy on SlackClient.prototype methods
|
|
128
|
+
clientTestAuthSpy = spyOn(SlackClient.prototype, 'testAuth').mockResolvedValue({
|
|
129
|
+
user_id: 'U123',
|
|
130
|
+
team_id: 'T123',
|
|
131
|
+
user: 'testuser',
|
|
132
|
+
team: 'Test Workspace',
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
clientListChannelsSpy = spyOn(SlackClient.prototype, 'listChannels').mockResolvedValue(
|
|
136
|
+
mockChannels
|
|
137
|
+
)
|
|
138
|
+
clientListUsersSpy = spyOn(SlackClient.prototype, 'listUsers').mockResolvedValue(mockUsers)
|
|
139
|
+
clientGetMessagesSpy = spyOn(SlackClient.prototype, 'getMessages').mockResolvedValue(mockMessages)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
afterEach(() => {
|
|
143
|
+
// Restore all spies
|
|
144
|
+
credManagerSpy?.mockRestore()
|
|
145
|
+
clientTestAuthSpy?.mockRestore()
|
|
146
|
+
clientListChannelsSpy?.mockRestore()
|
|
147
|
+
clientListUsersSpy?.mockRestore()
|
|
148
|
+
clientGetMessagesSpy?.mockRestore()
|
|
149
|
+
})
|
|
150
|
+
|
|
139
151
|
test('full snapshot returns workspace, channels, messages, and users', async () => {
|
|
140
152
|
const credManager = new CredentialManager()
|
|
141
153
|
const client = new SlackClient('xoxc-test', 'test-cookie')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test'
|
|
2
|
-
import { SlackClient } from '
|
|
3
|
-
import { userCommand } from '
|
|
4
|
-
import type { SlackUser } from '
|
|
2
|
+
import { SlackClient } from '@/platforms/slack/client'
|
|
3
|
+
import { userCommand } from '@/platforms/slack/commands/user'
|
|
4
|
+
import type { SlackUser } from '@/platforms/slack/types'
|
|
5
5
|
|
|
6
6
|
// Mock users
|
|
7
7
|
const mockUsers: SlackUser[] = [
|