Commit Graph

16 Commits

Author SHA1 Message Date
joakim 40c09d6a8a feat: Phase 4 - Offline & merge enhancements
- Added 'opal sync merge' command for initial database merge
- Support for merge strategies: prefer-local, prefer-server, smart (default)
- Offline queue already implemented in Phase 2
- Conflict warning display already implemented in Phase 2-3
- Full offline mode support with automatic queueing when server unreachable
2026-01-05 16:19:49 +01:00
joakim e6710eb19f feat: Phase 2 - Sync infrastructure
- Created sync client for communicating with API server
- Implemented conflict resolution strategies (last-write-wins, server-wins, client-wins)
- Added offline change queue for queuing changes when server is unreachable
- Implemented merge logic for local and remote task lists
- Added conflict logging to sync_conflicts.log
- Created bidirectional sync with pull/push operations
- Extended Config struct with sync settings (URL, API key, client ID, strategy, offline queue)
- Added SyncResult display with user-friendly output
- Sync handlers already implemented in Phase 1 (GetChanges, PushChanges)
2026-01-05 16:17:18 +01:00
joakim ba0cfc08e3 feat: Phase 1 - Core API server with authentication
- Added database schema for users, api_keys, sync_state, change_log, and sync_config
- Implemented API key generation and validation with bcrypt hashing
- Created Chi-based REST API server with endpoints for:
  - Task CRUD operations (create, read, update, delete)
  - Task actions (complete, start, stop)
  - Tag management (list, add, remove)
  - Projects listing
  - Health check endpoint
- Added middleware for authentication and CORS
- Implemented change log tracking with triggers (key:value format)
- Added configurable change log retention (default 30 days)
- Created server CLI commands (opal server start, opal server keygen)
- Dependencies added: golang.org/x/crypto/bcrypt, github.com/go-chi/chi/v5
2026-01-05 16:14:49 +01:00
joakim 9bde1aefea Migrate table formatting to go-pretty for proper UTF-8 and ANSI handling
Replace manual string-based table formatting with jedib0t/go-pretty/v6/table
library to fix alignment issues with Norwegian characters (æøå) and ANSI
color codes.

Changes:
- Migrate FormatTaskList() to use go-pretty table
- Migrate FormatTaskDetail() to use clean table format
- Migrate FormatProjects() and FormatTagCounts() for consistency
- Remove truncate() function (no longer needed)
- Configure StyleLight with Unicode box-drawing characters
- Set proper column widths and alignment

Fixes:
- Priority column now center-aligned under 'Pri'
- Norwegian characters (æøå) display and align correctly
- Tags column properly aligned
- Description field truncates at 40 chars with proper UTF-8 handling
- All ANSI color codes handled automatically
- Consistent formatting across all table views

All existing color functions work unchanged. UTF-8 and ANSI codes are
handled automatically by go-pretty's width calculation.
2026-01-05 13:41:46 +01:00
joakim d0b46beeec Add support for daily, weekly, monthly, yearly recurrence patterns
Previously, only numeric forms (1d, 1w, 1m, 1y) and plural word forms
(days, weeks, months, years) were supported for recurrence patterns.
The common adverbial forms (daily, weekly, monthly, yearly) would fail
with 'invalid recurrence pattern' error.

Now users can use natural language recurrence patterns:
- recur:daily   -> 1 day interval
- recur:weekly  -> 7 day interval
- recur:monthly -> 30 day interval
- recur:yearly  -> 365 day interval

Added test coverage for all four new patterns.
2026-01-05 10:36:21 +01:00
joakim 2afa4c6ee0 Phase 4: Implement relative date expressions
- Add parseRelativeExpression() to detect pattern: attr+/-duration
- Add resolveDateValue() to resolve absolute or relative dates
- Add applyDateAttribute() helper for date attributes with relative support
- Track attribute order in Modifier struct (AttributeOrder field)
- Refactor Apply() and ApplyToNew() to process attrs in order
- Support chaining: due:mon scheduled:due-3d wait:scheduled-1d
- Support addition and subtraction: due+1y, wait-2d
- Add comprehensive test suite for relative expressions
- Error if referencing undefined date attribute
- All 38+ tests passing
2026-01-05 10:05:20 +01:00
joakim cd476cfc99 Phase 3: Implement date format parsers and duration extensions
- Add month name parsing (jan, january, feb, etc.) with year logic
- Add day+month parsing (21jan, Jan21, 21January, etc.) in all case variations
- Add period boundaries (sod, eod, sow, eow, som, eom, soy, eoy)
- Add special keywords (later, someday -> 2150-01-01)
- Add duration-as-date offset (2d, 3w, etc. means X from now)
- Add named duration aliases (daily, weekly, monthly, yearly)
- Enhance ParseRecurrencePattern to support min, sec, hrs and word forms
- Implement time-of-day parsing (mon:15:35, tomorrow:0800, 15:35)
- Add comprehensive test suite (50+ tests total)
- All tests passing
2026-01-05 09:59:46 +01:00
joakim 43bbefbc00 Phase 2: Add config support for week_start_day and default_due_time
- Add WeekStartDay and DefaultDueTime fields to Config struct
- Set defaults: week_start_day=monday, default_due_time=empty
- Add GetWeekStart() and GetDefaultDueTime() helper methods
- Update ParseDate() to use configured week start day
- All tests passing
2026-01-05 09:55:33 +01:00
joakim b37e2dfc39 Phase 1: Refactor DateParser structure
- Create DateParser struct with configurable base time and week start
- Add placeholder methods for new parsing features
- Implement time-of-day parsing foundation (splitDateTime, parseTimeOfDay)
- Maintain backward compatibility with existing ParseDate() function
- Update tests to use new DateParser API
- All 33 existing tests passing
2026-01-05 09:54:58 +01:00
joakim a68d701d14 Fix three critical UX issues in opal-task
Issue 1: Fix recurrence calculation for overdue tasks
- Use completion date (End) as base for next instance, not original due date
- If task due Monday completed Wednesday, next is Wednesday+7d not Monday+7d
- Fallback to Due date if End is not set
- Update test to verify new behavior

Issue 2: Fix description parsing to work without quotes
- Add parseAddArgs() to extract description from non-modifier words
- Description = all words that don't start with +, -, or contain :
- Enables: opal add buy groceries +shop carrots → 'buy groceries carrots'
- Validate description is required (error if only modifiers)
- Validate recurring tasks require due date

Issue 3: Implement flexible command syntax
- Add preprocessArgs() to parse arguments before Cobra routing
- Detect command position and split filters (left) from modifiers (right)
- Rewrite os.Args so Cobra routes correctly
- Enable both 'opal 2 done' and 'opal done 2' syntax
- Commands without modifiers accept filters on either side
- Commands with modifiers enforce [filters] command [modifiers]
- Add confirmation for modify without filters (modifies all tasks)

All commands updated to use preprocessed ParsedArgs from context.
All tests passing (33 tests).
2026-01-04 21:24:14 +01:00
joakim 6e6c3dbea4 Implement opal-task Phases 6-8: Complete CLI Implementation
Phase 6: Display and Basic Commands
- Add display.go with colored formatting for tasks, projects, tags
- Implement cmd/root.go with Cobra command structure
- Implement cmd/list.go for listing and filtering tasks
- Implement cmd/add.go with support for regular and recurring tasks
- Implement cmd/done.go with bulk completion and confirmation

Phase 7: Advanced Commands
- Implement cmd/modify.go for updating task attributes
- Implement cmd/delete.go with soft delete confirmation
- Implement cmd/start.go and cmd/stop.go for task timing
- Implement cmd/count.go for counting filtered tasks
- Implement cmd/projects.go and cmd/tags.go for aggregation

Phase 8: Integration and Polish
- Update main.go to use CLI commands
- Add colored output with fatih/color
- Format task lists with proper alignment
- Highlight overdue tasks in red, upcoming in yellow
- Test end-to-end workflow: add, list, done, recurring tasks
- Verify recurrence spawning works correctly

All CLI commands functional and tested!
2026-01-04 18:17:04 +01:00
joakim cb4b7ac14b Implement opal-task Phase 5: Recurrence Implementation
- Complete SpawnNextInstance() for creating recurring task instances
- Implement automatic next instance spawning on task completion
- Add support for 'until' date to expire recurrences
- Copy tags from template to new instances
- Add comprehensive recurrence tests (6 tests, all passing)
- Test pattern parsing, formatting, next due calculation
- Test end-to-end recurring task workflow
- Test expiration with until dates
2026-01-04 18:13:32 +01:00
joakim 9704731739 Implement opal-task Phase 4: WorkingSet
- Implement BuildWorkingSet() to create ephemeral display ID mappings
- Implement LoadWorkingSet() to restore from database
- Add GetTaskByDisplayID() for ID resolution
- Add GetTasks() and Size() helper methods
- Persist working set to SQLite working_set table
- Add comprehensive tests (5 tests, all passing)
- Support filtered working sets
2026-01-04 18:11:59 +01:00
joakim c99a4a2d95 Implement opal-task Phase 3: Filter and Modifier Parsing
- Add filter.go: Parse filters (+tag, -tag, attribute:value, IDs)
- Implement Filter.ToSQL() for WHERE clause generation
- Add modifier.go: Parse modifiers (set/clear attributes, add/remove tags)
- Implement Modifier.Apply() to update existing tasks
- Add dateparse.go: Smart date parsing (ISO, today, tomorrow, weekdays)
- Implement nextWeekday logic (smart Sunday interpretation)
- Update GetTasks() to accept Filter parameter
- Add CreateTaskWithModifier() for task creation with modifiers
- Add comprehensive test suite (13 new tests, all passing)
- Support filtering by status, project, priority, tags, UUIDs, display IDs
- Support modifying priority, project, dates, recurrence, tags
2026-01-04 14:48:43 +01:00
joakim 7c6ec97c62 Implement opal-task Phase 2: Core Task Model CRUD
- Add complete CRUD operations: CreateTask, GetTask, GetTasks, Save
- Implement tag operations: AddTag, RemoveTag, GetTags
- Add task lifecycle methods: Complete, Delete, StartTask, StopTask
- Implement SQL type conversion helpers for nullable fields
- Add comprehensive test suite with 9 passing tests
- Fix timestamp handling (Created/Modified as Unix timestamps)
- Implement soft delete (status change) and hard delete options
2026-01-04 14:44:24 +01:00
joakim 9b5261b34c Implement opal-task Phase 1: Database foundation
- Add SQLite database with schema for tasks, tags, and working_set
- Implement config management with Viper (opal.yml)
- Create Task struct with proper types (*time.Time, Priority int)
- Add database migration system
- Implement recurrence pattern parsing (1d, 1w, 1m, 1y)
- Setup project structure with cmd/ and internal/engine/
- Add dependencies: sqlite3, uuid, cobra, viper, color
2026-01-04 14:41:16 +01:00