You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cd90b88
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,20 @@ astonish/
174
174
175
175
## Key Patterns
176
176
177
+
### General-Purpose Abstractions Must Stay Domain-Agnostic
178
+
179
+
Astonish is a general agent platform. Most functionality is reusable across many tools, data sources, teams, and business domains. Do **not** hard-code behavior for one specific kind of result, provider, customer, resource, or answer shape inside general-purpose code.
180
+
181
+
This rule applies broadly: renderers, parsers, API handlers, UI components, prompts, channel adapters, summaries, exporters, routing, tools, stores, and orchestration logic should operate on generic contracts and reusable structure rather than on domain-specific meaning. It is acceptable to recognize structural patterns such as tables, key/value pairs, grouped lists, code blocks, attachments, typed events, or explicitly modeled metadata. It is not acceptable to add one-off branches for a particular service, resource type, customer dataset, or example response when the feature is meant to work across scenarios.
182
+
183
+
When richer behavior is needed, choose one of these approaches:
184
+
185
+
1. Define or reuse a generic structure the producer can emit, such as a Markdown table, JSON schema, typed event, or metadata field.
186
+
2. Add a domain-neutral parser for a reusable shape, such as grouped lists, records, key/value summaries, timelines, or tables.
187
+
3. Introduce an explicit typed contract only after designing it as a general platform capability, not as a special case for one tool or one answer.
188
+
189
+
Tests for general-purpose code should use neutral fixtures (`items`, `groups`, `records`, `resources`) unless the code is intentionally implementing a documented domain-specific integration. If you find yourself naming a specific external product, infrastructure resource, customer concept, or one-off example inside reusable code, stop and redesign the abstraction.
Description("Uses Slack App Manifest APIs to register /link and Slack-safe Astonish commands. You can skip this and keep managing commands manually.").
776
+
Affirmative("Yes, sync commands").
777
+
Negative("Skip").
778
+
Value(&syncCommands),
779
+
),
780
+
).Run()
781
+
ifmanifestErr!=nil {
782
+
returnmanifestErr
783
+
}
784
+
ifsyncCommands {
785
+
manifestErr=huh.NewForm(
786
+
huh.NewGroup(
787
+
huh.NewInput().
788
+
Title("Slack App ID").
789
+
Description("Found under Basic Information → App Credentials (starts with A).").
790
+
Placeholder("A1234567890").
791
+
Value(&slackAppID),
792
+
huh.NewInput().
793
+
Title("App Configuration Token").
794
+
Description("Slack configuration token for App Manifest APIs. This is not the xoxb bot token or xapp Socket Mode token.").
795
+
EchoMode(huh.EchoModePassword).
796
+
Value(&configToken),
797
+
huh.NewInput().
798
+
Title("Slash Command URL").
799
+
Description("For Events API, use https://<host>/api/slack/commands. Optional for Socket Mode if Slack accepts omitted command URLs.").
Copy file name to clipboardExpand all lines: docs/architecture/channels.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Astonish sends typing indicators on a 4-second interval loop while the agent is
35
35
### Message Flow
36
36
37
37
```
38
-
External Platform (Telegram/Email)
38
+
External Platform (Telegram/Email/Slack)
39
39
|
40
40
v
41
41
Channel Adapter:
@@ -62,8 +62,8 @@ For regular messages:
62
62
v
63
63
ChannelManager -> Channel Adapter:
64
64
- Apply credential redaction
65
-
- Format for platform (HTML for Telegram, plain for email)
66
-
- Chunk if needed (Telegram: 4096 chars, Email: unlimited)
65
+
- Format for platform (HTML for Telegram, mrkdwn/Block Kit for Slack, plain for email)
66
+
- Chunk if needed (Telegram: 4096 chars, Slack: 4000-char text fallback, Email: unlimited)
67
67
- Attach images if present
68
68
- Send to platform
69
69
```
@@ -109,12 +109,23 @@ When a fleet session is active in a channel conversation:
109
109
-**Allowlist**: Supports `["*"]` wildcard for allowing all senders.
110
110
-**Format**: Plain text (no HTML formatting needed).
111
111
112
+
### Slack Adapter
113
+
114
+
-**Transport**: Socket Mode is the default WebSocket transport; Events API mode uses `POST /api/slack/events` for webhooks.
115
+
-**Slash commands and thread commands**: Slack slash commands are delivered separately from message events. `/link <code>` is handled through Socket Mode `slash_commands` envelopes or `POST /api/slack/commands` for HTTP mode, and the adapter returns an ephemeral Slack response immediately. Other registered Astonish commands are normalized back into `InboundMessage` and routed through `ChannelManager`, so Slack reuses the same `CommandRegistry` implementation as Telegram. Slack does not support custom app slash commands inside thread reply composers, so Astonish supports app-mention commands in threads instead: `@Astonish status`, `@Astonish /status`, and `@Astonish /astonish-status` are normalized to `/status`. Because these are normal `app_mention` events, Slack includes `thread_ts`, and command responses stay in the originating thread.
116
+
-**Command registration**: When Slack App Manifest credentials are configured (`app_id` plus an app configuration token), the adapter exports the current Slack app manifest, merges Astonish-owned commands, validates the manifest, and updates it best-effort. In Socket Mode it sets `settings.socket_mode_enabled=true` and omits slash-command URLs; in Events API mode each command uses the configured HTTPS command URL. `/link` keeps its bare name because it is part of the account-linking UX; shared registry commands use Slack-safe app-prefixed aliases such as `/astonish-status` because Slack reserves many generic slash command names. Session-scoped commands such as `/new`, `/distill`, and fleet session commands are not exposed as Slack slash commands because Slack slash-command payloads do not carry `thread_ts`; users start fresh by creating a new Slack thread. The exported manifest is preserved outside the owned command entries because Slack manifest updates are exhaustive.
117
+
-**Linking before allowlist**: `/link <code>` is accepted before the sender is in the dynamic allowlist so first-time users can connect their Slack identity to their Astonish account.
118
+
-**Conversation routing**: DMs use `message.im`; channel conversations use `app_mention`; replies stay in the originating Slack thread. Slack normal messages set `ThreadID` to the Slack `thread_ts` or the top-level message timestamp, so each Slack thread maps to a distinct Astonish session.
119
+
-**Rendering**: Agent responses arrive from `ChannelManager` as generic rich text. The Slack adapter owns Slack-specific rendering in `pkg/channels/slack/render.go`: it normalizes Markdown/HTML-like output to Slack `mrkdwn`, preserves plain text and code-heavy messages as chunked text, and selectively uses Block Kit for structured summaries.
120
+
-**Block Kit enrichment**: The renderer uses `section` blocks for titles/status groups, `section.fields` for compact key/value summaries, Slack `table` blocks for generic Markdown tables and grouped inventory-style lists, and a small `context` block for non-sensitive Astonish metadata. Every Block Kit message also includes fallback text for notifications and accessibility. If a response exceeds Slack's safe block/text limits, the adapter falls back to chunked `mrkdwn` text.
121
+
112
122
### Channel Hints
113
123
114
-
Each channel injects platform-specific hints into the agent's system prompt:
124
+
Each channel injects platform-specific hints into the agent's system prompt so the model can choose an output shape suited to that platform before adapter rendering happens:
-**Email**: "Responses can be longer and more formal. Include subject-appropriate structure."
126
+
-**Slack**: Use Slack-compatible Markdown/mrkdwn-friendly formatting. For structured records, prefer compact Markdown tables when the result set is small or medium and meaningful columns exist; for long result sets, summarize first and use grouped bullets or offer more detail. This instruction is domain-agnostic and must not mention specific tools, providers, or resource types.
127
+
-**Telegram**: Keep responses concise. Avoid tables because Telegram does not render them reliably; use bullet points instead.
128
+
-**Email**: Responses can be longer and more formal. Include subject-appropriate structure.
118
129
-**Console/Studio**: No hints (default behavior).
119
130
120
131
## Key Files
@@ -128,6 +139,10 @@ Each channel injects platform-specific hints into the agent's system prompt:
0 commit comments