open-index/open-npm huggingface dataset:
npm package: @stand-e/opencode-slackcode
Description: OpenCode plugin that streams session and agent activity into Slack.
Latest version: 0.1.0

# SlackIDE
SlackCode is an OpenCode plugin that streams session and agent activity into Slack.

## Requirements
- OpenCode 1.2.25 or later
- Node.js 18+
- Slack App with bot token and app token

## Installation
1. Ensure the plugin file is located at `.opencode/plugins/slackcode.ts` inside your OpenCode project.
If `.opencode/` does not exist, create it first.

2. Create `.opencode/package.json` with dependencies:
```json
{
  "name": "opencode-plugins",
  "private": true,
  "type": "module",
  "dependencies": {
    "@opencode-ai/plugin": "^1.2.25",
    "@slack/web-api": "^7.0.0",
    "js-yaml": "^4.1.0"
  }
}
```

3. Install dependencies in the `.opencode` directory:
```bash
cd .opencode
npm install
```

OpenCode will load plugins from `.opencode/plugins/` automatically.

## Install via npm (publishable package)
If you want to install this plugin via npm:
1. Build the package:
```bash
npm install
npm run build
```

2. Publish to a registry:
```bash
npm login
npm publish --access public
```

3. Add the package to your OpenCode project:
Create or edit `.opencode/package.json`:
```json
{
  "dependencies": {
    "opencode-slackcode": "^0.1.0"
  }
}
```

4. In `.opencode/opencode.json`, register the plugin package:
```json
{
  "plugins": ["opencode-slackcode"]
}
```

Then run `npm install` inside `.opencode` and start OpenCode.

## Configuration
Create `.slackcode` in your project root:
```yaml
channel: C123456
bot_token: xoxb-xxx
app_token: xapp-xxx
flush_interval_sec: 1.5
message_chunk_limit: 2000
state_path: .opencode/slack_state.json
```

Environment variable fallback:
- `SLACK_CHANNEL`
- `SLACK_BOT_TOKEN`
- `SLACK_APP_TOKEN`

## Usage
1. Start OpenCode as usual.
2. Run a session; the plugin posts a session root message in the configured channel.
3. Each agent output is streamed into its own Slack thread under that session.

Typical event flow:
1. `session.created` -> creates session root message.
2. first `message.*` for an agent -> creates a thread and posts output.
3. `session.idle` or `session.deleted` -> posts "Session finished".

Slack App notes:
1. Ensure the bot user is invited to the target channel.
2. Required scopes typically include `chat:write`, `files:write` (for large outputs).
3. If you use a private channel, invite the bot explicitly.

If you do not see messages in Slack:
- Verify the channel ID is correct and the bot is invited to that channel.
- Confirm `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` are valid.
- Ensure `.slackcode` is in the project root where OpenCode runs.

## Testing
From the project root:
```bash
cd .opencode
npm test
```

## Notes
- Session and thread state are persisted in `.opencode/slack_state.json`.
- Agent output is buffered (default 1.5s) and posted in batches.
- Output longer than 2000 characters is uploaded as a file.