Skip to content

SpaceCorps/sc-agent

Repository files navigation

sc-agent (SpaceCorps Agent) ⚡🤖

A self-hosted personal AI coding companion. Connects Anthropic's official claude-code CLI under the hood to Slack and Discord, powered by a unified workspace and local brainwares memory indexing. Perfect for hosting on Sliplane.


Key Features

  • 💬 Slack & Discord Gateways: Talk to your personal coding agent via Slack direct messages/mentions or a Discord channel.
  • 🐚 Interactive Claude Code CLI: Runs @anthropic-ai/claude-code under the hood inside a pseudoterminal (PTY) session, capturing its rich output and piping your chat inputs back to it.
  • 🧠 Brainwares Vault Support: Operates on a single, shared workspace utilizing the bw CLI. Updates code-linked memories and logs conceptual markdown notes (guides, tasks, plans) without code files.
  • 🎛️ Command Line Config (sca): A clean TypeScript-based CLI to configure your Slack tokens, Discord tokens, API keys, and workspace directory.
  • 🐳 Sliplane / Docker Ready: Fully containerized multi-stage build compiling the Rust bw CLI and packing the Node/TypeScript daemon.

Installation & Local Setup

1. Build and Link the CLI

To test or run locally, install dependencies and link the sca command:

git clone https://github.com/SpaceCorps/sc-agent.git
cd sc-agent
npm install
npm run build
npm link

This registers the global sca executable on your system.

2. Configure Your Credentials

Use the sca config utility to set up your integration credentials:

# Configure Anthropic API Key
sca config set anthropic_api_key "sk-ant-..."

# Configure Slack Bot integration (Socket Mode)
sca config set slack_bot_token "xoxb-..."
sca config set slack_app_token "xapp-..."

# Configure Discord Bot integration
sca config set discord_token "..."

# (Optional) Customize the workspace directory
sca config set workspace_path "/Users/yourname/workspace"

Verify your setup by running:

sca status

3. Run the Daemon

Start the bot runner daemon in the foreground:

sca start

CLI Reference (sca)

Command Arguments Description
sca start None Starts the Slack and Discord bot listeners in the foreground.
sca config set <key> <value> Save a token or setting to ~/.config/sc-agent/config.json.
sca config get <key> Print a saved configuration value.
sca config list None Display all configuration keys (with masked tokens).
sca status None Verify configuration, detect system CLI tools (bw, claude), and inspect the workspace.

How it works (Piping PTY to Messaging Channels)

  1. When you mention the bot on Slack or Discord, the daemon checks if a PTY session is running for the workspace.
  2. If none is active, it boots up npx @anthropic-ai/claude-code using node-pty.
  3. The PTY output is captured, stripped of ANSI color codes, and buffered.
  4. Once the PTY stream pauses for 1.5 seconds, the daemon forwards the accumulated text block back as a reply.
  5. Any subsequent reply you send is written to the PTY's stdin.
  6. To manually terminate or reset the session, send /cancel or /stop in the chat.

Sliplane Deployment

Sliplane will deploy the project using the included Dockerfile.

  1. Create Service: Link your fork of SpaceCorps/sc-agent on Sliplane.
  2. Environment Variables: Define the required tokens:
    • ANTHROPIC_API_KEY
    • SLACK_BOT_TOKEN
    • SLACK_APP_TOKEN
    • DISCORD_TOKEN
  3. Mount Storage: Mount a persistent volume at /workspace and /root/.config to ensure your configuration and workspace code/git state persist across container restarts.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors