Commit Graph

90 Commits

Author SHA1 Message Date
shokollm
99a80b0c62 fix #16: cleanup - remove old/dead code and update docs
- Delete apps/telegram-bot/storage.py (replaced by adapters/storage/json_file.py)
- Delete apps/telegram-bot/__init__.py (empty file)
- Delete apps/telegram-bot/requirements-dev.txt (dev deps in pyproject.toml)
- Update SPEC.md with new hexagonal architecture (core, adapters, apps)
- Update SPEC.md command reference: /update -> /edit
- Update README.md with new project structure and quick start
- Update CONTRIBUTING.md with new architecture and dev setup
2026-04-03 15:12:31 +00:00
50b09ef721 Merge pull request 'refactor(telegram-bot): add /edit command and make bot.py minimal entrypoint' (#34) from fix/issue-14 into main 2026-04-03 16:36:27 +02:00
shokollm
67d801d9de refactor(telegram-bot): add /edit command and make bot.py minimal entrypoint
- Add cmd_edit as alias for cmd_update
- Update bot.py to import commands directly instead of via module
- Register /edit command in bot and post_init commands list
- Clean up unused imports in bot.py

Fixes #14
2026-04-03 14:27:01 +00:00
f5cb28d45c Merge pull request 'refactor(commands): use core services instead of storage module' (#33) from fix/issue-13 into main 2026-04-03 16:14:24 +02:00
44bd0488c4 Merge pull request 'feat(cli): implement CLI for jigaido bounty tracker' (#32) from fix/issue-11 into main 2026-04-03 16:14:07 +02:00
shokollm
5e6a5f16b1 Add CLI unit tests for jigaido issue #11
- Tests mock dependencies and verify command existence, flag processing, and output format
- Tests use --group-id=-1001 format (equals sign) to avoid argparse treating -1001 as a flag
- All 17 tests passing
2026-04-03 13:18:48 +00:00
shokollm
0c36aa7b88 test(commands): add unit tests for command handlers
Add comprehensive unit tests for all command handlers:
- TestHelperFunctions: is_group, get_group_id, get_user_id, get_room_id
- TestCmdBounty: lists bounties, handles empty
- TestCmdMy: shows tracked in groups, personal in DM
- TestCmdAdd: add bounty success, validation
- TestCmdUpdate: update bounty, permission denied, invalid ID
- TestCmdDelete: delete bounty, invalid ID
- TestCmdTrack: track in group, reject in DM
- TestCmdUntrack: untrack in group, reject in DM
- TestCmdStart: group vs DM behavior
- TestCmdHelp: shows all commands

Also fix conftest.py to remove obsolete fresh_db fixture
that referenced non-existent db module.

All 55 tests pass.

Addresses han's feedback on PR #33
2026-04-03 13:11:18 +00:00
shokollm
5b1634ebca refactor(commands): use core services instead of storage module
Refactor commands.py to be thin Telegram wrappers around core services.

Changes:
- Replace 'import storage' with imports from core.services and adapters.storage
- Create module-level service instances (BountyService, TrackingService)
- Update format_bounty() to work with Bounty dataclass instead of dict
- Add get_room_id() helper for unified group/DM handling
- Each command handler is now a thin wrapper that:
  1. Extracts Telegram types (update, user_id, room_id)
  2. Calls appropriate core service
  3. Formats and sends response

Kept from original:
- parse_args()
- format_bounty()
- extract_args()

Commands now use services:
- cmd_bounty: BOUNTY_SERVICE.list_bounties()
- cmd_my: BOUNTY_SERVICE.list_bounties() or TRACKING_SERVICE.get_tracked_bounties()
- cmd_add: BOUNTY_SERVICE.add_bounty()
- cmd_update: BOUNTY_SERVICE.update_bounty()
- cmd_delete: BOUNTY_SERVICE.delete_bounty()
- cmd_track: TRACKING_SERVICE.track_bounty() (groups only)
- cmd_untrack: TRACKING_SERVICE.untrack_bounty() (groups only)

Fixes #13
2026-04-03 12:39:23 +00:00
shokollm
7202eeb1d2 feat(cli): implement CLI for jigaido bounty tracker
Create cli/main.py with the following commands:
- add <text> [--link url] [--due date] - Add a new bounty
- list - List all bounties in room
- my - List tracked bounties for user
- update <id> [text] [--link url] [--due date] [--clear-link] [--clear-due]
- delete <id> - Delete a bounty
- track <id> - Track a bounty
- untrack <id> - Untrack a bounty

Context flags:
- --group-id <id> - Group context
- --user-id <id> - User context

Requires either --group-id or --user-id for all commands.

Fixes #11
2026-04-03 12:37:55 +00:00
edbc924b98 Merge pull request 'feat(adapter): implement JSON file storage adapter for issue #9' (#27) from fix/issue-9 into main 2026-04-03 14:24:06 +02:00
2a9795a0c3 Merge pull request 'feat(core): implement services for issue #8' (#26) from fix/issue-8 into main 2026-04-03 14:23:32 +02:00
shokollm
d889d0e8ab fix(adapter): add unit tests + reorganize data directories
- Add tests/test_json_file.py with unit tests for JsonFileRoomStorage and JsonFileTrackingStorage
- Reorganize data directories per han's feedback:
  - Rooms: ~/.jigaido/data/room/<room_id>.json (was ~/.jigaido/data/<room_id>.json)
  - Tracking: ~/.jigaido/data/tracking/<room_id>_<user_id>.json (was ~/.jigaido/tracking/...)
- Note: duplicate tracking is handled at TrackingService layer (returns False if already tracking), adapter allows duplicates by design
2026-04-03 11:38:42 +00:00
shokollm
3feab1d469 test(services): add unit tests for BountyService and TrackingService
- Test BountyService: add_bounty, list_bounties, get_bounty, update_bounty, delete_bounty
- Test TrackingService: track_bounty, untrack_bounty, get_tracked_bounties
- Test edge cases: permission errors, not found, duplicate tracking
2026-04-03 11:36:07 +00:00
shokollm
e79fbaddc5 feat(adapter): implement JSON file storage adapter for issue #9
Implements RoomStorage and TrackingStorage ports using JSON file persistence:
- JsonFileRoomStorage: Stores room data at ~/.jigaido/data/<room_id>.json
- JsonFileTrackingStorage: Stores tracking data at ~/.jigaido/tracking/<room_id>_<user_id>.json

Features:
- Atomic writes using tempfile + rename for data safety
- Automatic directory creation
- Implements all methods from ports.py protocols
2026-04-03 09:36:31 +00:00
shokollm
920fb70257 feat(core): implement services for issue #8
- Add BountyService for room bounty operations (group and personal)
- Add TrackingService for tracking bounty operations
- Uses RoomStorage and TrackingStorage ports
- PermissionError raised when non-creator edits/deletes
- ValueError raised when bounty not found in tracking
2026-04-03 09:26:48 +00:00
shokollm
e691abce60 Revert "Merge feat/issue-6-storage-ports: JSON file storage adapter for issue #9"
This reverts commit 9e3641a850, reversing
changes made to 8aebb763ee.
2026-04-03 08:36:04 +00:00
shokollm
9e3641a850 Merge feat/issue-6-storage-ports: JSON file storage adapter for issue #9 2026-04-03 08:26:10 +00:00
shokollm
af8eb90563 feat(adapter): implement JSON file storage adapter
Add JsonFileRoomStorage and JsonFileTrackingStorage implementations
that implement the RoomStorage and TrackingStorage ports.

- Stores room data at ~/.jigaido/data/<room_id>.json
- Stores tracking data at ~/.jigaido/tracking/<room_id>_<user_id>.json
- Implements all port methods: load, save, add_bounty, update_bounty,
  delete_bounty, get_bounty for rooms; load, save, track_bounty,
  untrack_bounty for tracking

Fixes #9
2026-04-03 08:06:51 +00:00
8aebb763ee Merge pull request 'Add core/ports.py - Storage interfaces' (#20) from feat/issue-6-storage-ports into main 2026-04-03 08:58:30 +02:00
shokollm
a237810dd2 Remove ensure_room/ensure_tracking from Protocol - tests prove not needed
Tests with SimpleRoomStorage and SimpleTrackingStorage (without ensure_*)
show that add_bounty() and track_bounty() work fine without explicit
ensure methods - they create rooms/tracking internally.

This simplifies the Protocol to only essential methods.
2026-04-03 06:48:52 +00:00
shokollm
43603659de Address PR #20 feedback:
- Removed PersonalStorage (redundant - RoomStorage handles both via room_id)
- Added ensure_room() and ensure_tracking() methods for explicit creation
- Added @runtime_checkable to Protocols for isinstance checks
- Added tests/test_ports.py with 11 unit tests for storage protocols
2026-04-02 23:57:49 +00:00
shokollm
5450d12400 Add core/ports.py - Storage interfaces
Define abstract storage interfaces (Protocols):
- RoomStorage: for room/group bounties (load, save, add/update/delete/get_bounty)
- PersonalStorage: same operations for personal/DM bounties
- TrackingStorage: for tracking data (load, save, track/untrack_bounty)
2026-04-02 22:40:11 +00:00
ddd44cb593 Merge pull request 'feat(core): implement domain dataclasses for issue #5' (#19) from feat/issue-5-core-models into main 2026-04-03 00:37:30 +02:00
shokollm
b2854393ae Address PR #19 review feedback round 3:
- TrackingData.group_id renamed to room_id (works for both group and DM)
- Removed room_id from TrackedBounty (it's just a lightweight pointer)
2026-04-02 22:34:19 +00:00
shokollm
330203e6ef Address PR #19 review feedback round 2:
- Bounty.created_by_user_id is now non-optional (always required)
- Removed is_group from RoomData (negative room_id is self-documenting)
- Added room_id to TrackedBounty to track which room bounty was tracked from
- Added clarifying docstrings explaining TrackingData vs TrackedBounty
- Updated tests to match new model structure
2026-04-02 22:24:12 +00:00
shokollm
f1ef33451c Address PR #19 review feedback: simplify models
- Remove GroupBounty/PersonalBounty subclasses, use Bounty with optional created_by_user_id
- Combine UserData/GroupData into RoomData with room_id and is_group fields
- Add group_id field to TrackingData (supports negative Telegram group IDs)
- Add test_bounty_comparison_not_equal for verifying different bounties are not equal
- Update core/__init__.py exports
2026-04-02 21:47:26 +00:00
5aebb5a814 Merge pull request 'feat(config): implement configuration management' (#18) from feat/issue-7-config into main 2026-04-02 23:43:56 +02:00
shokollm
9b8b15414f feat(config): implement configuration management for issue #7
- Create config.py with Config class
- Config precedence: ENV > config file > defaults
- data_dir: JIGAIDO_DATA_DIR env or ~/.jigaido/config.json or default
- bot_token: JIGAIDO_BOT_TOKEN env var
- ensure_data_dir() method to create data directory
- Add tests/test_config.py with 7 passing tests

Fixes #7
2026-04-02 20:16:41 +00:00
shokollm
db09a518d1 feat(core): implement domain dataclasses for issue #5
- Create core/__init__.py
- Create core/models.py with all domain dataclasses:
  - Bounty (base class)
  - GroupBounty (extends Bounty)
  - PersonalBounty (extends Bounty)
  - TrackedBounty
  - GroupData
  - TrackingData
  - UserData
- Create tests/test_models.py with 15 passing tests

Fixes #5
2026-04-02 20:15:41 +00:00
98a8c4d173 Merge pull request 'feat: Replace SQLite with per-user JSON storage (fixes #2)' (#3) from fix/issue-2-json-storage into main 2026-04-02 17:44:08 +02:00
shokollm
7c2bd09ada feat: implement new storage design per issue #2
- Storage: Change from per-user to per-group JSON files
- Data location: ~/.jigaido/ instead of apps/telegram-bot/data/
- Group bounties: data/{group_id}/group.json
- User tracking: data/{group_id}/{user_id}.json
- Personal bounties: data/{user_id}/user.json
- Update commands.py for new storage model
- Update bot.py to remove admin handlers
- Update tests to reflect created_by_user_id field
- Update SPEC.md with new design

Addresses user feedback from issue #2
2026-04-02 14:56:42 +00:00
shokollm
332d7fc60a Update issue #2 storage design with new file structure 2026-04-01 21:31:51 +00:00
shokollm
2e7b20ed81 Update issue #2 storage design with new file structure
Changed from per-user flat files to group/DM directory structure:
- data/{group_id}/group.json — group bounties
- data/{group_id}/{user_id}.json — user tracking in group
- data/{user_id}/user.json — user personal bounties (DM)
- Groups isolated, no cross-group access
- Tracking is per-group-per-user
2026-04-01 21:31:34 +00:00
shokollm
8bb964fdd0 feat: Replace SQLite with per-user JSON storage (fixes #2)
- Add storage.py with load_user(), save_user(), next_bounty_id()
- Rewrite commands.py to use JSON storage (simplified)
- Remove db.py, schema.sql, cron.py, test_db.py
- Update SPEC.md to reflect new architecture
- Admin model removed (anyone can add, creator only can edit/delete)
- No reminders in v1
2026-04-01 10:02:51 +00:00
shokollm
8647f2f4b8 Add issue template for v2 storage simplification 2026-04-01 09:53:38 +00:00
shokollm
d6f98c9163 Fix db.py connection handling and test isolation
db.py:
- Add conn.isolation_level = None to get_conn() — fixes row_factory +
  autocommit conflict. row_factory disables implicit transactions,
  so we need explicit autocommit mode.
- Remove all conn.commit() calls (unnecessary with autocommit)

pyproject.toml:
- Move pytest + pytest-asyncio to main dependencies (uv run pytest
  uses ephemeral env with main deps only)

tests/test_db.py:
- Fix test_upsert_user_updates_username to not chain upsert_user()
  calls in assert expressions (test isolation issue)
2026-04-01 09:35:17 +00:00
shokollm
965c84379b Add uv support, systemd service, and deployment tooling
- pyproject.toml: uv-native project definition (replaces requirements.txt for uv users)
- requirements.txt: kept for pip compatibility
- deploy/jigaido-bot.service: systemd service file (copy to /etc/systemd/system/)
- deploy/setup.sh: automated deployment script
- README.md: updated with uv instructions, tmux, and systemd setup
2026-04-01 09:15:41 +00:00
shokollm
7957947a04 Add tests + fix db.py SQLite commit pattern
Tests:
- tests/test_commands.py: parse_args, extract_args, format_bounty
- tests/test_db.py: full CRUD + tracking + reminders
- tests/conftest.py: temp DB fixture
- requirements-dev.txt: pytest + pytest-asyncio

db.py fixes:
- Explicit conn.commit() after every write (SQLite row_factory
  disables implicit transaction management)
- fetchone() before commit() (can't commit while cursor open)
- Functions return dict instead of sqlite3.Row
2026-04-01 08:41:44 +00:00
shokollm
9f0ad2d404 Refactor to apps/ structure
JIGAIDO is now a platform with apps/ as the container.
All telegram-bot files moved to apps/telegram-bot/:
- bot.py, commands.py, cron.py, db.py, schema.sql
- requirements.txt, .env.example, README.md
- Root now holds SPEC.md, README.md, CONTRIBUTING.md only.

Structure:
jigaido/
├── apps/
│   └── telegram-bot/
└── SPEC.md, README.md, CONTRIBUTING.md
2026-04-01 08:05:10 +00:00
shokollm
be5fe04a90 Initial commit: project scaffold, full spec, database schema, bot and cron
- SPEC.md: full project specification from design discussion
- schema.sql: SQLite database schema
- db.py: database wrapper with all query functions
- bot.py: telegram bot entrypoint
- commands.py: all command handlers with admin/creator guards
- cron.py: daily reminder job
- requirements.txt: python-telegram-bot, dateparser
- README.md, CONTRIBUTING.md
- .gitignore
2026-04-01 07:38:18 +00:00