Skip to content

AI-driven research automation system powered by Claude Code's headless mode and MCP tools

Notifications You must be signed in to change notification settings

StableMind/nightshift

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

NightShift Logo

NightShift

Automated Research Assistant System

Status Python License Tests codecov Slack

An AI-driven agent manager for scientific research automation, powered by Claude Code's headless mode and MCP tools. Now with Slack integration!

Features โ€ข Installation โ€ข Usage โ€ข TUI โ€ข Slack โ€ข Examples


Overview

NightShift is a working prototype that automates research tasks using Claude Code in headless mode. The system uses a "task planner" agent to analyze requests, select appropriate tools, and execute tasks through a staged approval workflow.

How It Works

graph TD
    A[User Request] --> B[Task Planner Agent]
    B --> C{Analyzes task<br/>Selects MCP tools<br/>Estimates resources}
    C --> D[Task Queue<br/>STAGED]
    D --> E{User Approval}
    E --> F[Executor Agent<br/>Claude headless]
    F --> G{Executes with tools<br/>Tracks file changes}
    G --> H[Notification + Results]

    style A fill:#e1f5ff
    style B fill:#fff4e1
    style D fill:#ffe1f5
    style F fill:#fff4e1
    style H fill:#e1ffe1
Loading

Project Structure

nightshift/
โ”œโ”€โ”€ core/                        # Core system components
โ”‚   โ”œโ”€โ”€ agent_manager.py         # Orchestrates Claude headless processes
โ”‚   โ”œโ”€โ”€ task_planner.py          # Plans tasks using Claude
โ”‚   โ”œโ”€โ”€ task_queue.py            # SQLite-backed task queue
โ”‚   โ”œโ”€โ”€ logger.py                # Comprehensive logging
โ”‚   โ”œโ”€โ”€ file_tracker.py          # Monitors file changes
โ”‚   โ”œโ”€โ”€ notifier.py              # Task completion notifications (Terminal + Slack)
โ”‚   โ””โ”€โ”€ config.py                # Configuration management
โ”œโ”€โ”€ integrations/                # Third-party integrations (NEW!)
โ”‚   โ”œโ”€โ”€ slack_client.py          # Slack API wrapper
โ”‚   โ”œโ”€โ”€ slack_handler.py         # Slack event routing
โ”‚   โ”œโ”€โ”€ slack_server.py          # Flask webhook server
โ”‚   โ”œโ”€โ”€ slack_formatter.py       # Block Kit message formatting
โ”‚   โ”œโ”€โ”€ slack_metadata.py        # Task metadata persistence
โ”‚   โ””โ”€โ”€ slack_middleware.py      # Request verification
โ”œโ”€โ”€ interfaces/                  # User interfaces
โ”‚   โ”œโ”€โ”€ cli.py                   # Command-line interface
โ”‚   โ””โ”€โ”€ tui/                     # Interactive terminal UI
โ”‚       โ”œโ”€โ”€ app.py               # Application factory
โ”‚       โ”œโ”€โ”€ controllers.py       # Business logic layer
โ”‚       โ”œโ”€โ”€ widgets.py           # Custom prompt_toolkit controls
โ”‚       โ”œโ”€โ”€ keybindings.py       # Keyboard shortcuts
โ”‚       โ”œโ”€โ”€ layout.py            # UI layout composition
โ”‚       โ””โ”€โ”€ models.py            # Data structures
โ””โ”€โ”€ config/                      # Configuration files
    โ””โ”€โ”€ claude-code-tools-reference.md  # MCP tools reference

Data Storage

All NightShift data is stored in ~/.nightshift/:

~/.nightshift/
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ slack_config.json       # Slack credentials (secure)
โ”œโ”€โ”€ database/
โ”‚   โ””โ”€โ”€ nightshift.db           # Task queue database
โ”œโ”€โ”€ logs/
โ”‚   โ””โ”€โ”€ nightshift_YYYYMMDD.log # Execution logs
โ”œโ”€โ”€ output/
โ”‚   โ”œโ”€โ”€ task_XXX_output.json    # Task outputs
โ”‚   โ””โ”€โ”€ task_XXX_files.json     # File change tracking
โ”œโ”€โ”€ notifications/
โ”‚   โ””โ”€โ”€ task_XXX_notification.json  # Completion summaries
โ””โ”€โ”€ slack_metadata/
    โ””โ”€โ”€ task_XXX_slack.json     # Slack context (channel, user, thread)

Features

โœ… Implemented (Phase 1)

  • ๐Ÿง  Intelligent Task Planning Claude analyzes requests and selects appropriate MCP tools

  • ๐Ÿ”’ Staged Approval Workflow Review tasks before execution (prevents hallucinations)

  • โœ๏ธ Plan Revision Request changes to task plans with feedback before execution

  • ๐Ÿ”ง MCP Tool Integration Leverages ArXiv, Gemini, Claude, OpenAI, and other MCP servers

  • ๐Ÿ“ File Change Tracking Monitors which files were created/modified during execution

  • ๐Ÿ‘๏ธ Execution Viewer Beautiful, human-readable display of task execution sessions

  • ๐Ÿ”” Rich Notifications Detailed completion summaries with file changes

  • ๐Ÿ’ป CLI Interface Simple commands for task management

  • ๐Ÿ–ฅ๏ธ Interactive TUI Full-featured terminal UI with vim-like navigation

  • ๐Ÿ’พ Persistent Storage SQLite database, centralized data directory

  • ๐Ÿ“Š Token & Time Tracking Monitors resource usage per task

  • ๐Ÿ”„ Process Control Pause, resume, and kill running tasks

  • ๐Ÿ“ฑ Slack Integration โญ NEW! Submit tasks, approve via buttons, get completion notifications

  • ๐Ÿ”€ Concurrent Task Execution โญ NEW! Execute multiple tasks simultaneously with configurable worker pool

  • โฑ๏ธ Configurable Timeouts Set execution time limits per task (default: 15 minutes)

  • ๐Ÿ” Cross-Process Control Manage executor service from any terminal

๐Ÿšง Planned (Phase 2+)

  • ๐Ÿ“Š Real-time Progress Updates Show task progress in Slack as it executes

  • ๐Ÿ”„ Revision via Slack Request plan changes through modal dialogs

  • ๐Ÿ“ค File Uploads Upload task outputs directly to Slack channels

  • ๐Ÿ‘ฅ Multi-user Authorization Role-based access control (admin/user/viewer)

  • โšก Background Processing Full async task execution with queue workers

  • ๐Ÿ›ก๏ธ Resource Limits Auto-kill for runaway tasks, memory/CPU limits

  • ๐Ÿ” RAG Context Awareness Search documentation and past tasks

  • ๐Ÿ“š Knowledge Base Learn from errors and corrections

  • ๐Ÿ’ฌ WhatsApp Integration Mobile task management

  • ๐ŸŽฏ Specialized Task Types

    • Data analysis workflows
    • Code maintenance automation
    • Environment setup scripts

Installation

cd nightshift
pip install -e .

This installs all required dependencies including:

  • Claude Code CLI (via Claude Agent SDK)
  • prompt-toolkit (for interactive TUI)
  • Slack SDK (for Slack integration)
  • Flask (for webhook server)
  • Rich (for beautiful terminal output)

Optional: For Slack integration, you'll also need:

  • A Slack workspace and app
  • Bot token and signing secret (get via nightshift slack-setup)
  • ngrok or similar for local testing (see SLACK_QUICK_START.md)

Usage

Quick Start

๐Ÿ“ Submit a task
# Submit and wait for approval
nightshift submit "Download and summarize arxiv paper 2510.13997 using Gemini"

# Auto-approve and execute immediately
nightshift submit "Download arxiv paper 2510.13997" --auto-approve
๐Ÿ“‹ View task queue
# View all tasks
nightshift queue

# Filter by status
nightshift queue --status staged
nightshift queue --status completed
โœ… Approve and execute
nightshift approve task_3acf60c6
โœ๏ธ Revise a plan
# Request changes to a staged task plan
nightshift revise task_3acf60c6 "Use Claude instead of Gemini for summarization"

# Revise again with more feedback
nightshift revise task_3acf60c6 "Also save the summary as a PDF file"
๐Ÿ“Š View results
# Basic info
nightshift results task_3acf60c6

# Show full output (raw JSON)
nightshift results task_3acf60c6 --show-output
๐Ÿ‘๏ธ Display execution (NEW!)
# View task execution in human-readable format
# Shows Claude's responses, tool calls, and results as they happened
nightshift display task_3acf60c6

This command parses the stream-json output and displays it like an actual Claude session:

  • ๐Ÿ’ฌ Claude's messages and reasoning
  • ๐Ÿ”ง Tool calls with parameters
  • โœ… Tool results and errors
  • ๐Ÿ“Š Token usage and cost statistics

Perfect for debugging and understanding what happened during execution!

โŒ Cancel a task
nightshift cancel task_3acf60c6
๐Ÿ—‘๏ธ Clear all data
# With confirmation
nightshift clear

# Skip confirmation
nightshift clear --confirm
โŒจ๏ธ Shell Autocomplete (NEW!)
# Auto-detect shell and install completion
nightshift completion --install

# Show instructions for specific shell
nightshift completion --shell zsh
nightshift completion --shell bash
nightshift completion --shell fish

# Reload your shell
source ~/.zshrc  # or ~/.bashrc for bash

What gets autocompleted:

  • โœ… Commands: nightshift sub<TAB> โ†’ nightshift submit
  • โœ… Subcommands: nightshift executor st<TAB> โ†’ nightshift executor start
  • โœ… Options: nightshift queue --st<TAB> โ†’ nightshift queue --status
  • โœ… Status values: nightshift queue --status <TAB> โ†’ shows all status options
  • โœ… Task IDs (dynamic): nightshift approve task_<TAB> โ†’ shows all staged tasks
  • โœ… Context-aware task filtering:
    • approve and revise โ†’ only STAGED tasks
    • cancel โ†’ only STAGED or COMMITTED tasks
    • pause, resume, kill โ†’ only RUNNING or PAUSED tasks
    • results, display, watch โ†’ all tasks

Supported shells: Bash (4.4+), Zsh, Fish, PowerShell

This significantly improves CLI usability by reducing typos and helping discover available commands!

๐Ÿ”€ Concurrent Execution (NEW!)
# Start executor service (processes tasks in background)
nightshift executor start

# Start with custom settings
nightshift executor start --workers 5 --poll-interval 2.0

# Check executor status
nightshift executor status

# Stop executor service
nightshift executor stop

# Submit task with custom timeout (default: 900s / 15 minutes)
nightshift submit "Download paper" --timeout 300

# Submit and execute synchronously (wait for completion)
nightshift submit "Quick task" --auto-approve --sync

How it works:

  • Executor polls the queue for COMMITTED tasks and executes them concurrently
  • Configure max workers (default: 3) and poll interval (default: 1.0s)
  • Each task has a configurable timeout to prevent runaway executions
  • Tasks can be submitted from multiple terminals/Slack simultaneously
  • Executor can be controlled from any terminal using PID file tracking

Benefits:

  • โšก Multiple tasks execute in parallel
  • ๐Ÿ”„ Submit tasks while others are running
  • ๐ŸŽฏ No blocking - submit and move on
  • ๐Ÿ›ก๏ธ Timeouts prevent hanging tasks

Terminal UI (TUI)

NightShift includes a full-featured interactive terminal interface for task management.

๐Ÿ–ฅ๏ธ Launch the TUI
nightshift tui
NightShift TUI
โŒจ๏ธ Keybindings
Key Action
j / โ†“ Move down in task list
k / โ†‘ Move up in task list
Enter / a Approve selected task
r Reject/cancel task
e Review/edit task plan (opens $EDITOR)
d Delete task
Tab Cycle detail tabs (overview/execution/files/summary)
: Enter command mode
q Quit

Command mode (:):

  • :queue [status] - Filter tasks by status
  • :submit <description> - Submit new task
  • :submit! <description> - Submit and auto-approve
  • :refresh - Refresh task list
  • :help - Show available commands
  • :quit - Exit TUI

Slack Integration

NightShift can be controlled entirely through Slack, allowing you to submit tasks, approve them with buttons, and receive detailed completion notifications - all without leaving Slack!

Quick Start

๐Ÿš€ Setup (5 minutes)
  1. Create Slack App (if not already done)

    • Go to https://api.slack.com/apps
    • Create a new app for your workspace
    • Add bot token scopes: commands, chat:write, chat:write.public, files:write
    • Install to workspace and copy the Bot Token
  2. Configure NightShift

    nightshift slack-setup

    Follow prompts to enter your bot token and signing secret.

  3. Start Server

    nightshift slack-server
  4. Expose with ngrok (for testing)

    ngrok http 5000

    Copy the ngrok URL and update your Slack app settings:

    • Slash Commands URL: https://YOUR-NGROK-URL/slack/commands
    • Interactivity URL: https://YOUR-NGROK-URL/slack/interactions

๐Ÿ“– Full guide: SLACK_QUICK_START.md

Slack Commands

๐Ÿ“ Submit a task
/nightshift submit "download and summarize arxiv paper 2510.13997"

What happens:

  1. ๐Ÿ”„ Immediate response: "Planning task... (30-120s)"
  2. ๐Ÿ“‹ Approval message appears with buttons
  3. โœ… Click "Approve" โ†’ Task executes
  4. ๐Ÿ“จ Completion notification with results
๐Ÿ“‹ View queue
/nightshift queue
/nightshift queue staged

Shows all tasks or filtered by status.

๐Ÿ“Š Check status
/nightshift status task_abc123

Shows current status, creation time, and output path.

๐ŸŽ›๏ธ Process control
/nightshift pause task_abc123
/nightshift resume task_abc123
/nightshift kill task_abc123
/nightshift cancel task_abc123

Control running and queued tasks.

Interactive Buttons

Every approval message includes:

  • โœ… Approve - Execute the task
  • โŒ Reject - Cancel the task
  • โ„น๏ธ Details - View full task details (ephemeral message)

Completion Notifications

When a task completes, you'll receive a detailed notification showing:

  • What you asked for - Original task description
  • What NightShift found/created - Claude's actual response (first 1000 chars)
  • What NightShift did - List of files created/modified/deleted
  • Execution metrics - Time, tokens, status
  • Full results path - Link to complete output file

Example Slack Workflow

You: /nightshift submit "fetch today's top 3 BBC headlines"

NightShift: ๐Ÿ”„ Planning task... This may take 30-120 seconds.

[30s later]

NightShift: ๐ŸŽฏ Task Plan: task_abc123

Description: Fetch today's main headlines from the BBC news website...

Tools: WebFetch
Estimated: ~800 tokens, ~20s

[โœ… Approve] [โŒ Reject] [โ„น๏ธ Details]

You: *clicks โœ… Approve*

NightShift: โœ… Task task_abc123 approved by @you
โณ Executing...

[20s later]

NightShift: โœ… Task SUCCESS: task_abc123

What you asked for:
Fetch today's top 3 BBC headlines

What NightShift found/created:
Here are today's top 3 BBC headlines:

1. Breaking: Major Political Development - Prime Minister announces...
2. International Crisis Update - Tensions rise as...
3. Technology Breakthrough - Scientists discover...

Status: SUCCESS
Execution Time: 21.5s
Tokens Used: 465

๐Ÿ“„ Full results: ~/.nightshift/output/task_abc123_output.json

๐Ÿ“– Full documentation: TESTING_SLACK_INTEGRATION.md


Example Workflows

๐Ÿ“„ Research Paper Analysis

$ nightshift submit "Download arxiv paper 2510.13997 and summarize using Gemini"

Planning task...
โœ“ Task created: task_3acf60c6

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Task Plan โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Tools needed: mcp__arxiv__download, Read, mcp__gemini__ask, Write       โ”‚
โ”‚ Estimated: ~3500 tokens, ~90s                                           โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โธ  Status: STAGED (waiting for approval)
Run 'nightshift approve task_3acf60c6' to execute
Or 'nightshift revise task_3acf60c6 "feedback"' to request changes

$ nightshift approve task_3acf60c6

โœ“ Task approved: task_3acf60c6
โ–ถ Executing...

[... execution logs ...]

โœ“ Task completed successfully!
Token usage: 3017
Execution time: 122.9s

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
## โœ… Task Completed: task_3acf60c6

**Description:** Download the ArXiv paper with ID 2510.13997...
**Status:** SUCCESS
**Execution Time:** 122.9s
**Token Usage:** 3017

### File Changes
**Created (2):**
- โœจ 2510.13997.pdf
- โœจ arxiv_2510.13997_summary.md

**Results:** output/task_3acf60c6_output.json
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ”ง Code Repository Management

$ nightshift submit "Download the mcp-handley-lab repository from the handley-lab GitHub organization and create a pull request addressing issue #50"

Planning task...
โœ“ Task created: task_7d2a1f9b

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Task Plan โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Tools needed: Bash, Read, Write, Edit, Glob, Grep                       โ”‚
โ”‚ Estimated: ~2000 tokens, ~120s                                          โ”‚
โ”‚ Reasoning: Clone repo, analyze issue, implement fix, create PR          โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โธ  Status: STAGED (waiting for approval)
Run 'nightshift approve task_7d2a1f9b' to execute

$ nightshift approve task_7d2a1f9b

โœ“ Task approved: task_7d2a1f9b
โ–ถ Executing...

[... cloning repository ...]
[... analyzing issue #50 ...]
[... implementing fix ...]
[... creating pull request ...]

โœ“ Task completed successfully!
Token usage: 1847
Execution time: 98.3s

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
## โœ… Task Completed: task_7d2a1f9b

**Description:** Download the mcp-handley-lab repository...
**Status:** SUCCESS
**Execution Time:** 98.3s
**Token Usage:** 1847

### File Changes
**Created (1):**
- โœจ mcp-handley-lab/ (repository directory)

**Modified (3):**
- ๐Ÿ“ mcp-handley-lab/src/fix_file.py
- ๐Ÿ“ mcp-handley-lab/tests/test_fix.py
- ๐Ÿ“ mcp-handley-lab/README.md

**Pull Request:** https://github.com/handley-lab/mcp-handley-lab/pull/123
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โœ๏ธ Plan Revision Workflow

$ nightshift submit "Analyze the latest trends in quantum computing"

Planning task...
โœ“ Task created: task_9b4e2c1a

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Task Plan โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Enhanced prompt: Search for and analyze recent quantum computing papers โ”‚
โ”‚ Tools needed: WebSearch, Write                                          โ”‚
โ”‚ Estimated: ~1500 tokens, ~60s                                           โ”‚
โ”‚ Reasoning: Use web search to find trends, compile analysis              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โธ  Status: STAGED (waiting for approval)
Run 'nightshift approve task_9b4e2c1a' to execute
Or 'nightshift revise task_9b4e2c1a "feedback"' to request changes

$ nightshift revise task_9b4e2c1a "Focus on arxiv papers from 2024, not web search"

Revising plan based on feedback...
โœ“ Plan revised: task_9b4e2c1a

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Revised Plan โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Revised prompt: Search arxiv for quantum computing papers from 2024... โ”‚
โ”‚ Tools needed: mcp__arxiv__search, Read, mcp__gemini__ask, Write        โ”‚
โ”‚ Estimated: ~2500 tokens, ~120s                                          โ”‚
โ”‚ Changes: Switched from WebSearch to ArXiv tools, added Gemini for      โ”‚
โ”‚          analysis, increased time estimate for paper processing         โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Status: STAGED (waiting for approval)
Run 'nightshift approve task_9b4e2c1a' to execute
Or 'nightshift revise task_9b4e2c1a "more feedback"' to revise again

$ nightshift approve task_9b4e2c1a

โœ“ Task approved: task_9b4e2c1a
โ–ถ Executing...

[... execution with revised plan ...]

โœ“ Task completed successfully!

Development Notes

Technical Details

Core Architecture

  • ๐ŸŽฏ Task planner uses claude -p with --json-schema to ensure structured output
  • โš™๏ธ Executor uses claude -p with --verbose --output-format stream-json
  • ๐Ÿ“ธ File tracking takes snapshots before/after execution
  • โฑ๏ธ Configurable timeouts per task (default: 900s / 15 minutes)
  • ๐Ÿ”Œ All Claude calls are subprocess executions (no SDK)
  • ๐Ÿ”€ ThreadPoolExecutor for concurrent task execution (not ProcessPoolExecutor, since Claude CLI already spawns subprocesses)
  • ๐Ÿ—„๏ธ SQLite WAL mode for concurrent database access
  • ๐Ÿ”’ Atomic task acquisition with BEGIN IMMEDIATE to prevent race conditions
  • ๐Ÿ“ PID file tracking for cross-process executor control

Slack Integration

  • ๐Ÿ” HMAC-SHA256 signature verification for all webhook requests
  • โฐ Timestamp-based replay attack prevention (5-minute window)
  • ๐Ÿšฆ Rate limiting: 10/min for commands, 20/min for interactions
  • ๐Ÿงต Threading support for async planning and execution
  • ๐Ÿ’พ Metadata persistence for tracking Slack context (channel, user, thread)
  • ๐Ÿ“ฆ Block Kit formatting for rich interactive messages

Security

  • Credentials stored in ~/.nightshift/config/ (never in git)
  • Request body caching for signature verification
  • DM channel detection (use user_id instead of channel_id)
  • Graceful error handling with user feedback

Built with Claude Code โ€ข Powered by MCP

Made with โค๏ธ for researchers and developers

About

AI-driven research automation system powered by Claude Code's headless mode and MCP tools

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%