ruby_todo 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 335ebe29df566a811eddbc67c2443bff069e45d3c6b93bc736d68a23e088358d
4
- data.tar.gz: a3408be015a62fa83b971effc2ace94d6b02b34a26c31b13264fbab59af8f69e
3
+ metadata.gz: 479d76323ae6c82caadc55f77626d279935b3c3737fad34c33663e40c93dce84
4
+ data.tar.gz: f31c019e25f39ff0578dcc206adf39527ddddb03f2340aa69e9e4f9d0f5db229
5
5
  SHA512:
6
- metadata.gz: 6c96743c0f93b769157410d51e0cad83a10bd589bd87bf69da09497e36e9fc3779578dbd4e63024fdf83a7774c06fcda05698e595911edb9e127e5f548f0e0e5
7
- data.tar.gz: 00e42b86e41c16193c84fdda638a6ccea20ecdca4f4af7c583808e9be552189f78b1568ac649294a38e1dca9a6be828cfe2ef4f81b46c03f5365b2ba879c00cc
6
+ metadata.gz: 4213ca4fa8ebb651299f63fdded731d705bf3979b70558c68855ae6af8602f7ec2273092fc4f9311ef5ac4b71fbd40e82398891b3acad1387be14a0617bf8c73
7
+ data.tar.gz: c8b8f3295b6cf2bdcba37e5ad45e7c28ccff04e392c7d378c0437497700f1300055e35cc5d4aa2f07b050ff24442ad4ab1734df5513346e4608cb7a97ea34a4d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [1.0.4] - 2025-03-31
2
+
3
+ * Manual release
4
+
5
+
6
+ ## [1.0.3] - 2025-03-28
7
+
8
+ * Manual release
9
+
10
+
1
11
  ## [1.0.1] - 2025-03-28
2
12
 
3
13
  * Manual release
data/README.md CHANGED
@@ -47,17 +47,17 @@ After installing the gem:
47
47
 
48
48
  2. Create your first notebook:
49
49
  ```bash
50
- $ ruby_todo notebook create "Personal"
50
+ $ ruby_todo notebook:create "Personal"
51
51
  ```
52
52
 
53
53
  3. Add your first task:
54
54
  ```bash
55
- $ ruby_todo task add "Personal" "My first task"
55
+ $ ruby_todo task:add "Personal" "My first task"
56
56
  ```
57
57
 
58
58
  4. List your tasks:
59
59
  ```bash
60
- $ ruby_todo task list "Personal"
60
+ $ ruby_todo task:list "Personal"
61
61
  ```
62
62
 
63
63
  All `ruby_todo` commands can be run from anywhere in your terminal as they're installed globally with the gem.
@@ -75,98 +75,91 @@ $ ruby_todo init
75
75
 
76
76
  Create a new notebook:
77
77
  ```bash
78
- $ ruby_todo notebook create "Work"
78
+ $ ruby_todo notebook:create "Work"
79
79
  ```
80
80
 
81
81
  List all notebooks:
82
82
  ```bash
83
- $ ruby_todo notebook list
83
+ $ ruby_todo notebook:list
84
+ ```
85
+
86
+ Set default notebook:
87
+ ```bash
88
+ $ ruby_todo notebook:set_default "Work"
84
89
  ```
85
90
 
86
91
  ### Task Management
87
92
 
88
93
  Add a task to a notebook:
89
94
  ```bash
90
- $ ruby_todo task add "Work" "Complete project documentation"
95
+ $ ruby_todo task:add "Work" "Complete project documentation"
91
96
  ```
92
97
 
93
98
  Add a task with additional details:
94
99
  ```bash
95
- $ ruby_todo task add "Work" "Complete project documentation" --description "Write the API documentation for the new features" --due_date "2024-04-10 14:00" --priority "high" --tags "project,documentation,urgent"
100
+ $ ruby_todo task:add "Work" "Complete project documentation" --description "Write the API documentation for the new features" --due_date "2024-04-10 14:00" --priority "high" --tags "project,documentation,urgent"
96
101
  ```
97
102
 
98
103
  List tasks in a notebook:
99
104
  ```bash
100
- $ ruby_todo task list "Work"
105
+ $ ruby_todo task:list "Work"
101
106
  ```
102
107
 
103
108
  Filter tasks by status:
104
109
  ```bash
105
- $ ruby_todo task list "Work" --status "in_progress"
110
+ $ ruby_todo task:list "Work" --status "in_progress"
106
111
  ```
107
112
 
108
113
  Show only overdue tasks:
109
114
  ```bash
110
- $ ruby_todo task list "Work" --overdue
115
+ $ ruby_todo task:list "Work" --overdue
111
116
  ```
112
117
 
113
118
  Show only high priority tasks:
114
119
  ```bash
115
- $ ruby_todo task list "Work" --priority "high"
120
+ $ ruby_todo task:list "Work" --priority "high"
116
121
  ```
117
122
 
118
123
  Filter by tags:
119
124
  ```bash
120
- $ ruby_todo task list "Work" --tags "urgent,important"
125
+ $ ruby_todo task:list "Work" --tags "urgent,important"
121
126
  ```
122
127
 
123
128
  View detailed information about a task:
124
129
  ```bash
125
- $ ruby_todo task show "Work" 1
130
+ $ ruby_todo task:show "Work" 1
126
131
  ```
127
132
 
128
133
  Edit a task:
129
134
  ```bash
130
- $ ruby_todo task edit "Work" 1 --title "New title" --priority "medium" --due_date "2024-04-15 10:00"
135
+ $ ruby_todo task:edit "Work" 1 --title "New title" --priority "medium" --due_date "2024-04-15 10:00"
131
136
  ```
132
137
 
133
138
  Move a task to a different status:
134
139
  ```bash
135
- $ ruby_todo task move "Work" 1 "in_progress"
140
+ $ ruby_todo task:move "Work" 1 "in_progress"
136
141
  ```
137
142
 
138
143
  Delete a task:
139
144
  ```bash
140
- $ ruby_todo task delete "Work" 1
145
+ $ ruby_todo task:delete "Work" 1
141
146
  ```
142
147
 
143
148
  ### Search
144
149
 
145
150
  Search for tasks across all notebooks:
146
151
  ```bash
147
- $ ruby_todo task search "documentation"
152
+ $ ruby_todo task:search "documentation"
148
153
  ```
149
154
 
150
155
  Search within a specific notebook:
151
156
  ```bash
152
- $ ruby_todo task search "documentation" --notebook "Work"
153
- ```
154
-
155
- ### Statistics
156
-
157
- View statistics for all notebooks:
158
- ```bash
159
- $ ruby_todo stats
160
- ```
161
-
162
- View statistics for a specific notebook:
163
- ```bash
164
- $ ruby_todo stats "Work"
157
+ $ ruby_todo task:search "documentation" --notebook "Work"
165
158
  ```
166
159
 
167
160
  ### Export and Import
168
161
 
169
- Export tasks from a notebook to JSON:
162
+ Export tasks from a notebook:
170
163
  ```bash
171
164
  $ ruby_todo export "Work" "work_export"
172
165
  ```
@@ -195,12 +188,27 @@ $ ruby_todo import "work_export.json" --notebook "New Work"
195
188
 
196
189
  Create a template:
197
190
  ```bash
198
- $ ruby_todo template create "Weekly Report" --title "Weekly Report {week}" --description "Prepare weekly report for week {week}" --priority "high" --tags "report,weekly" --due_date_offset "5d"
191
+ $ ruby_todo template:create "Weekly Report" --title "Weekly Report {week}" --description "Prepare weekly report for week {week}" --priority "high" --tags "report,weekly" --due_date_offset "5d"
199
192
  ```
200
193
 
201
194
  List all templates:
202
195
  ```bash
203
- $ ruby_todo template list
196
+ $ ruby_todo template:list
197
+ ```
198
+
199
+ Show template details:
200
+ ```bash
201
+ $ ruby_todo template:show "Weekly Report"
202
+ ```
203
+
204
+ Delete a template:
205
+ ```bash
206
+ $ ruby_todo template:delete "Weekly Report"
207
+ ```
208
+
209
+ Use a template:
210
+ ```bash
211
+ $ ruby_todo template:use "Weekly Report" "Work"
204
212
  ```
205
213
 
206
214
  ## Template Placeholders
@@ -218,13 +226,13 @@ Templates support the following placeholder types:
218
226
 
219
227
  ## AI Assistant
220
228
 
221
- Ruby Todo includes an AI assistant powered by OpenAI's gpt-4o-mini model that can help you manage your tasks using natural language.
229
+ Ruby Todo includes an AI assistant that can help you manage your tasks using natural language.
222
230
 
223
231
  ### Configuration
224
232
 
225
233
  Configure your AI assistant:
226
234
  ```bash
227
- $ ruby_todo ai configure
235
+ $ ruby_todo ai:configure
228
236
  ```
229
237
 
230
238
  ### API Key Options
@@ -233,64 +241,41 @@ There are two ways to provide your OpenAI API key:
233
241
 
234
242
  1. **Configure once with the setup command** (recommended):
235
243
  ```bash
236
- $ ruby_todo ai configure
244
+ $ ruby_todo ai:configure
237
245
  ```
238
- This prompts you to enter your OpenAI API key and securely saves it in `~/.ruby_todo/ai_config.json`.
246
+ This prompts you to enter your OpenAI API key and securely saves it.
239
247
 
240
248
  2. **Use environment variables**:
241
249
  ```bash
242
250
  $ export OPENAI_API_KEY=your_api_key_here
243
- $ ruby_todo ai ask "your prompt"
244
- ```
245
-
246
- 3. **Pass the API key directly in the command**:
247
- ```bash
248
- $ ruby_todo ai ask "your prompt" --api-key=your_api_key_here
251
+ $ ruby_todo ai:ask "your prompt"
249
252
  ```
250
253
 
251
254
  ### Using the AI Assistant
252
255
 
253
- Ask the AI assistant to perform actions:
254
- ```bash
255
- $ ruby_todo ai ask "Create a new task in my Work notebook to update the documentation by next Friday"
256
- ```
257
-
258
- ```bash
259
- $ ruby_todo ai ask "Move all tasks related to the API project to in_progress status"
260
- ```
261
-
262
- ```bash
263
- $ ruby_todo ai ask "Show me all high priority tasks"
264
- ```
265
-
266
- ```bash
267
- $ ruby_todo ai ask "Create a JSON to import 5 new tasks for my upcoming vacation"
268
- ```
269
-
270
- #### Bulk Operations
271
-
272
- The AI assistant can perform bulk operations on all tasks:
256
+ Here are some example commands you can use with the AI assistant:
273
257
 
258
+ Task Creation and Management:
274
259
  ```bash
275
- $ ruby_todo ai ask "Move all tasks to todo"
260
+ $ ruby_todo ai:ask "create a new task called 'Test task creation via AI' with high priority"
261
+ $ ruby_todo ai:ask "move migrate arbitration-tf-shared to github actions"
262
+ $ ruby_todo ai:ask "move all tasks to in_progress"
276
263
  ```
277
264
 
265
+ Task Queries:
278
266
  ```bash
279
- $ ruby_todo ai ask "Move all tasks to in_progress"
267
+ $ ruby_todo ai:ask "show me all high priority tasks"
268
+ $ ruby_todo ai:ask "show me all in progress tasks"
269
+ $ ruby_todo ai:ask "show me all todo tasks"
280
270
  ```
281
271
 
272
+ Complex Operations:
282
273
  ```bash
283
- $ ruby_todo ai ask "Show me all task statistics"
274
+ $ ruby_todo ai:ask "move migrate arbitration-tf-shared and awsappman-tf-accounts-management to github actions"
275
+ $ ruby_todo ai:ask "show statistics for protectors notebook"
276
+ $ ruby_todo ai:ask "move all migrate to barracuda org tasks to done"
284
277
  ```
285
278
 
286
- Pass in an API key directly (if not configured):
287
- ```bash
288
- $ ruby_todo ai ask "What tasks are overdue?" --api-key=your_api_key_here --api=claude
289
- ```
290
-
291
- Enable verbose mode to see full AI responses:
292
- ```bash
293
- $ ruby_todo ai ask "Summarize my Work notebook" --verbose
294
- ```
279
+ The AI assistant can understand various natural language patterns and execute the appropriate commands for you.
295
280
 
296
281
  ## Development
@@ -88,7 +88,7 @@ module RubyTodo
88
88
 
89
89
  api_key = prompt.mask("Enter your API key:")
90
90
 
91
- model = "gpt-4o-mino"
91
+ model = "gpt-4o-mini"
92
92
 
93
93
  save_config(api.downcase, api_key, model)
94
94
  say "Configuration saved successfully!".green
data/delete_notebooks.rb CHANGED
@@ -4,17 +4,67 @@
4
4
  require_relative "lib/ruby_todo"
5
5
  require_relative "lib/ruby_todo/database"
6
6
 
7
- # Setup the database connection
7
+ # Ensure database connection is established first
8
8
  RubyTodo::Database.setup
9
9
 
10
- # Count notebooks and tasks before deletion
11
- notebook_count = RubyTodo::Notebook.count
12
- task_count = RubyTodo::Task.count
10
+ def count_records
11
+ {
12
+ tasks: RubyTodo::Task.count,
13
+ notebooks: RubyTodo::Notebook.count,
14
+ templates: RubyTodo::Template.count
15
+ }
16
+ end
13
17
 
14
- # Delete tasks first to avoid foreign key constraint errors
15
- RubyTodo::Task.delete_all
16
- puts "Successfully deleted #{task_count} tasks."
18
+ def print_counts(counts, prefix = "")
19
+ puts "#{prefix}Tasks: #{counts[:tasks]}"
20
+ puts "#{prefix}Notebooks: #{counts[:notebooks]}"
21
+ puts "#{prefix}Templates: #{counts[:templates]}"
22
+ end
17
23
 
18
- # Then delete notebooks
19
- RubyTodo::Notebook.delete_all
20
- puts "Successfully deleted #{notebook_count} notebooks."
24
+ def reset_sqlite_sequences
25
+ connection = ActiveRecord::Base.connection
26
+ connection.tables.each do |table|
27
+ connection.execute("DELETE FROM sqlite_sequence WHERE name='#{table}'")
28
+ puts "Reset sequence counter for table: #{table}"
29
+ end
30
+ end
31
+
32
+ begin
33
+ # Get initial record counts
34
+ initial_counts = count_records
35
+ puts "\nCurrent record counts:"
36
+ print_counts(initial_counts)
37
+
38
+ puts "\nResetting database..."
39
+
40
+ # Drop all tables
41
+ ActiveRecord::Base.connection.tables.each do |table|
42
+ ActiveRecord::Base.connection.drop_table(table)
43
+ puts "Dropped table: #{table}"
44
+ end
45
+
46
+ # Recreate the database schema
47
+ puts "\nRecreating database schema..."
48
+ RubyTodo::Database.setup
49
+
50
+ # Reset sequence counters
51
+ puts "\nResetting sequence counters..."
52
+ reset_sqlite_sequences
53
+
54
+ # Verify the reset
55
+ final_counts = count_records
56
+ puts "\nFinal record counts:"
57
+ print_counts(final_counts)
58
+
59
+ puts "\nDatabase reset complete! All tables and sequence counters have been reset."
60
+ rescue ActiveRecord::ConnectionNotEstablished => e
61
+ puts "\nError: Could not establish database connection"
62
+ puts "Make sure the database directory exists at ~/.ruby_todo/"
63
+ puts "Error details: #{e.message}"
64
+ exit 1
65
+ rescue StandardError => e
66
+ puts "\nAn error occurred while resetting the database:"
67
+ puts e.message
68
+ puts e.backtrace
69
+ exit 1
70
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "param_extractor"
4
+
5
+ module RubyTodo
6
+ module AIAssistant
7
+ # Helper module for processing task-related commands
8
+ module CommandProcessor
9
+ include ParamExtractor
10
+
11
+ # Process task add commands
12
+ def process_task_add(cmd)
13
+ # More specific patterns first
14
+ case cmd
15
+ when /task:add\s+"([^"]+)"\s+"([^"]+)"(?:\s+(.*))?/, /task:add\s+'([^']+)'\s+'([^']+)'(?:\s+(.*))?/,
16
+ /task:add\s+([^\s"']+)\s+"([^"]+)"(?:\s+(.*))?/, /task:add\s+([^\s"']+)\s+'([^']+)'(?:\s+(.*))?/
17
+
18
+ notebook_name = Regexp.last_match(1)
19
+ title = Regexp.last_match(2)
20
+ params = Regexp.last_match(3)
21
+
22
+ cli_args = ["task:add", notebook_name, title]
23
+
24
+ # Extract optional parameters
25
+ extract_task_params(params, cli_args) if params
26
+
27
+ RubyTodo::CLI.start(cli_args)
28
+ # Handle cases where quotes might be missing or mixed
29
+ when /task:add\s+([^\s]+)\s+([^\s-][^-]+?)(?:\s+(.*))?/
30
+ notebook_name = Regexp.last_match(1).gsub(/["']/, "") # Remove any quotes
31
+ title = Regexp.last_match(2).gsub(/["']/, "") # Remove any quotes
32
+ params = Regexp.last_match(3)
33
+
34
+ cli_args = ["task:add", notebook_name, title]
35
+
36
+ # Process parameters
37
+ extract_task_params(params, cli_args) if params
38
+
39
+ RubyTodo::CLI.start(cli_args)
40
+ # Handle missing notebook name by using default notebook
41
+ when /task:add\s+"([^"]+)"(?:\s+(.*))?/, /task:add\s+'([^']+)'(?:\s+(.*))?/
42
+ title = Regexp.last_match(1)
43
+ params = Regexp.last_match(2)
44
+
45
+ # Get default notebook
46
+ default_notebook = RubyTodo::Notebook.default_notebook
47
+ notebook_name = default_notebook ? default_notebook.name : "default"
48
+
49
+ cli_args = ["task:add", notebook_name, title]
50
+
51
+ # Process parameters
52
+ extract_task_params(params, cli_args) if params
53
+
54
+ RubyTodo::CLI.start(cli_args)
55
+ else
56
+ say "Invalid task:add command format".red
57
+ message = "Expected: task:add \"notebook_name\" \"task_title\" [--description \"desc\"] " \
58
+ "[--priority level][--tags \"tags\"]"
59
+ say message.yellow
60
+ end
61
+ end
62
+
63
+ # Process task move commands
64
+ def process_task_move(cmd)
65
+ if cmd =~ /task:move\s+"([^"]+)"\s+(\d+)\s+(\w+)/ || cmd =~ /task:move\s+([^\s"]+)\s+(\d+)\s+(\w+)/
66
+ notebook_name = Regexp.last_match(1)
67
+ task_id = Regexp.last_match(2)
68
+ status = Regexp.last_match(3)
69
+ cli_args = ["task:move", notebook_name, task_id, status]
70
+ RubyTodo::CLI.start(cli_args)
71
+ else
72
+ say "Invalid task:move command format".red
73
+ end
74
+ end
75
+
76
+ # Process task list commands
77
+ def process_task_list(cmd)
78
+ if cmd =~ /task:list\s+"([^"]+)"(?:\s+(.*))?/
79
+ notebook_name = Regexp.last_match(1)
80
+ filters = Regexp.last_match(2)
81
+ cli_args = ["task:list", notebook_name]
82
+
83
+ # Add any filters that were specified
84
+ cli_args.concat(filters.split(/\s+/)) if filters
85
+
86
+ RubyTodo::CLI.start(cli_args)
87
+ else
88
+ say "Invalid task:list command format".red
89
+ end
90
+ end
91
+
92
+ # Process task delete commands
93
+ def process_task_delete(cmd)
94
+ if cmd =~ /task:delete\s+"([^"]+)"\s+(\d+)/
95
+ notebook_name = Regexp.last_match(1)
96
+ task_id = Regexp.last_match(2)
97
+ cli_args = ["task:delete", notebook_name, task_id]
98
+ RubyTodo::CLI.start(cli_args)
99
+ else
100
+ say "Invalid task:delete command format".red
101
+ end
102
+ end
103
+
104
+ # Process notebook create commands
105
+ def process_notebook_create(cmd)
106
+ parts = cmd.split(/\s+/)
107
+ return unless parts.size >= 2
108
+
109
+ notebook_name = parts[1]
110
+ cli_args = ["notebook:create", notebook_name]
111
+ RubyTodo::CLI.start(cli_args)
112
+ end
113
+
114
+ # Process notebook list commands
115
+ def process_notebook_list(_cmd)
116
+ RubyTodo::CLI.start(["notebook:list"])
117
+ end
118
+
119
+ # Process stats commands
120
+ def process_stats(cmd)
121
+ parts = cmd.split(/\s+/)
122
+ cli_args = ["stats"] + parts[1..]
123
+ RubyTodo::CLI.start(cli_args)
124
+ end
125
+ end
126
+ end
127
+ end