Skip to content

Commit 4c80527

Browse files
committed
Refactor package layout for PyPI distribution
1 parent 790d021 commit 4c80527

23 files changed

+109
-46
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
__pycache__/
2+
*.egg-info/
3+
dist/
4+
build/
5+
venv/
6+
/venv/

CLAUDE_CODE_REDESIGN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Redesign the Sleepless Agent to use **Claude Code CLI** instead of direct Claude
2424
- `src/monitor.py` - Health monitoring (no changes)
2525
- `src/results.py` - Result storage (no changes)
2626
- `src/models.py` - Data models (minor additions)
27-
- `src/daemon.py` - Main loop (changes for new executor)
27+
- `sleepless_agent/daemon.py` - Main loop (changes for new executor)
2828

2929
## What Changes
3030

@@ -399,7 +399,7 @@ Remove `ClaudeConfig` with API key requirement.
399399

400400
### 5. Daemon Integration Changes
401401

402-
#### Updated `src/daemon.py` - `SleepleassAgent.__init__()`
402+
#### Updated `sleepless_agent/daemon.py` - `SleepleassAgent.__init__()`
403403

404404
```python
405405
def __init__(self):
@@ -433,7 +433,7 @@ def __init__(self):
433433
# ... rest of initialization
434434
```
435435

436-
#### Updated `src/daemon.py` - `_execute_task()`
436+
#### Updated `sleepless_agent/daemon.py` - `_execute_task()`
437437

438438
```python
439439
async def _execute_task(self, task):

GETTING_STARTED.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Fill in:
7070
### 5. Run Agent
7171

7272
```bash
73-
python -m src.daemon
73+
python -m sleepless_agent.daemon
7474
```
7575

7676
You should see:
@@ -311,7 +311,7 @@ Filename: idea_{task_id}_{timestamp}.md
311311
cat .env | grep -E "SLACK|ANTHROPIC"
312312

313313
# 2. Bot is running
314-
pgrep -f "src.daemon"
314+
pgrep -f "sleepless_agent.daemon"
315315

316316
# 3. Logs
317317
tail -50 logs/agent.log | grep ERROR
@@ -328,7 +328,7 @@ ls -la ./workspace
328328
# Should be readable/writable
329329

330330
# Try manual tool test:
331-
python -c "from src.tools import ToolExecutor; t = ToolExecutor('./workspace'); print(t.list_files())"
331+
python -c "from sleepless_agent.tools import ToolExecutor; t = ToolExecutor('./workspace'); print(t.list_files())"
332332
```
333333

334334
### Git commits fail

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Context Machine Lab
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ setup:
2121
@echo "✓ Setup complete. Edit .env with your tokens"
2222

2323
run:
24-
python -m src.daemon
24+
python -m sleepless_agent.daemon
2525

2626
dev:
27-
PYTHONUNBUFFERED=1 python -m src.daemon
27+
PYTHONUNBUFFERED=1 python -m sleepless_agent.daemon
2828

2929
logs:
3030
tail -f logs/agent.log
3131

3232
test:
3333
@echo "Testing imports..."
34-
python -c "from src.daemon import SleepleassAgent; print('✓ Imports OK')"
34+
python -c "from sleepless_agent.daemon import SleepleassAgent; print('✓ Imports OK')"
3535

3636
db:
3737
sqlite3 data/tasks.db "SELECT id, description, status, priority FROM tasks LIMIT 10;"
@@ -78,7 +78,7 @@ stats:
7878

7979
status:
8080
@echo "=== Agent Status ==="
81-
@pgrep -f "src.daemon" > /dev/null && echo "✓ Daemon running" || echo "✗ Daemon not running"
81+
@pgrep -f "sleepless_agent.daemon" > /dev/null && echo "✓ Daemon running" || echo "✗ Daemon not running"
8282
@test -f .env && echo "✓ .env configured" || echo "✗ .env missing"
8383
@test -f data/tasks.db && echo "✓ Database exists" || echo "✗ Database missing"
8484
@echo ""

QUICK_REFERENCE.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cp .env.example .env
3030
nano .env # Add SLACK and ANTHROPIC tokens
3131

3232
# 3. Run
33-
python -m src.daemon
33+
python -m sleepless_agent.daemon
3434
```
3535

3636
## Slack App Setup
@@ -67,17 +67,19 @@ Slack → SlackBot → TaskQueue (SQLite)
6767

6868
```
6969
src/
70-
├── daemon.py Main event loop
71-
├── bot.py Slack interface
72-
├── task_queue.py Task management
73-
├── claude_executor.py Claude API + tools
74-
├── tools.py File/bash operations
75-
├── scheduler.py Smart scheduling
76-
├── git_manager.py Git automation
77-
├── monitor.py Health & metrics
78-
├── models.py Database models
79-
├── config.py Config management
80-
├── results.py Result storage
70+
└── sleepless_agent/
71+
├── __init__.py Package metadata
72+
├── daemon.py Main event loop
73+
├── bot.py Slack interface
74+
├── task_queue.py Task management
75+
├── claude_executor.py Claude API + tools
76+
├── claude_code_executor.py Claude CLI wrapper
77+
├── tools.py File/bash operations
78+
├── scheduler.py Smart scheduling
79+
├── git_manager.py Git automation
80+
├── monitor.py Health & metrics
81+
├── models.py Database models
82+
└── results.py Result storage
8183
```
8284

8385
## Configuration
@@ -237,7 +239,7 @@ DEBUG=false
237239

238240
1. Read GETTING_STARTED.md for detailed setup
239241
2. Configure .env with your tokens
240-
3. Run: `python -m src.daemon`
242+
3. Run: `python -m sleepless_agent.daemon`
241243
4. Test commands in Slack
242244
5. Deploy as service using Makefile
243245
6. Monitor with `/health` and `/metrics`

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
A 24/7 AI assistant daemon that continuously works on tasks via Slack. Uses Claude Code CLI to process both random thoughts and serious jobs automatically with isolated workspaces.
44

5+
## About
6+
- Maintained by Context Machine Lab
7+
- Ships as `sleepless-agent` on PyPI (`pip install sleepless-agent`)
8+
- Automates task intake, execution, and reporting via Slack + Claude integration
9+
- Designed for continuous operation with isolated workspaces and automated git hygiene
10+
511
## Features
612

713
- 🤖 **Continuous Operation**: Runs 24/7 daemon, always ready for new tasks
@@ -68,12 +74,17 @@ Optional:
6874

6975
```bash
7076
# Terminal 1: Start the daemon
71-
python -m src.daemon
77+
python -m sleepless_agent.daemon
7278

7379
# Terminal 2 (optional): Monitor logs
7480
tail -f logs/agent.log
7581
```
7682

83+
## Releases
84+
- Latest stable: **0.1.0** – published on [PyPI](https://pypi.org/project/sleepless-agent/0.1.0/)
85+
- Install or upgrade with `pip install -U sleepless-agent`
86+
- Release notes and changelog are tracked via GitHub Releases (tag `v0.1.0` onward)
87+
7788
## Slack Commands
7889

7990
### Task Management
@@ -265,8 +276,7 @@ sqlite3 data/tasks.db "SELECT * FROM tasks;"
265276

266277
**Database locked?**
267278
- Close all other connections to tasks.db
268-
- Try: `rm data/tasks.db && python -m src.daemon`
279+
- Try: `rm data/tasks.db && python -m sleepless_agent.daemon`
269280

270281
## License
271-
272-
MIT
282+
- Released under the [MIT License](LICENSE)

com.sleepless-agent.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<array>
99
<string>/usr/local/bin/python3</string>
1010
<string>-m</string>
11-
<string>src.daemon</string>
11+
<string>sleepless_agent.daemon</string>
1212
</array>
1313
<key>WorkingDirectory</key>
1414
<string>/Users/YOUR_USERNAME/projects/sleepless-agent</string>

pyproject.toml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ build-backend = "setuptools.build_meta"
66
name = "sleepless-agent"
77
version = "0.1.0"
88
description = "24/7 AI agent that maximizes Claude usage via Slack interface"
9+
readme = "README.md"
10+
authors = [{name = "Sleepless Agent Maintainers"}]
11+
license = {file = "LICENSE"}
12+
keywords = ["ai", "automation", "agents", "slack", "anthropic"]
13+
classifiers = [
14+
"Development Status :: 3 - Alpha",
15+
"Intended Audience :: Developers",
16+
"Operating System :: OS Independent",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.11",
19+
"License :: OSI Approved :: MIT License",
20+
"Topic :: Communications :: Chat",
21+
"Topic :: Office/Business",
22+
]
923
requires-python = ">=3.11"
1024
dependencies = [
1125
"anthropic>=0.34.4",
@@ -19,4 +33,15 @@ dependencies = [
1933
]
2034

2135
[project.scripts]
22-
sleepless-agent = "src.daemon:main"
36+
sleepless-agent = "sleepless_agent.daemon:main"
37+
38+
[project.urls]
39+
Homepage = "https://github.com/context-machine-lab/sleepless-agent"
40+
Repository = "https://github.com/context-machine-lab/sleepless-agent"
41+
42+
[tool.setuptools]
43+
package-dir = {"" = "src"}
44+
45+
[tool.setuptools.packages.find]
46+
where = ["src"]
47+
include = ["sleepless_agent*"]

sleepless-agent.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ After=network.target
66
Type=simple
77
User=sleepless
88
WorkingDirectory=/opt/sleepless-agent
9-
ExecStart=/opt/sleepless-agent/venv/bin/python -m src.daemon
9+
ExecStart=/opt/sleepless-agent/venv/bin/python -m sleepless_agent.daemon
1010
Restart=on-failure
1111
RestartSec=10
1212
StandardOutput=journal

0 commit comments

Comments
 (0)