Commit 481e9ba
feat: add database console and scheduled tasks (Roadmap 4.7 + 4.4) (#284)
* feat: add database console and scheduled tasks (Roadmap 4.7 + 4.4)
Database Console (4.7):
- `lvt console` (or `lvt db`) opens interactive sqlite3 shell
- Auto-detects database via DATABASE_PATH env var or app.db in cwd
- Passes -header -column flags for readable output
- Prints helpful commands (.tables, .schema, .quit)
- Clear error if sqlite3 not installed
Scheduled Tasks (4.4):
- `lvt gen task <name> --schedule <interval>` scaffolds recurring tasks
- Built on existing River job queue (lvt gen queue)
- Schedule shortcuts: @hourly, @daily, @Weekly, @every 5m
- Generates task handler in app/jobs/<name>.go
- Injects PeriodicJobs() function into worker.go
- Updates River client config with PeriodicJobs in main.go
- Tasks run automatically when app starts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add FTS5 full-text search for resources (Roadmap 4.2)
New --searchable flag on lvt gen resource:
lvt gen resource posts title content:text --searchable
When enabled:
- Generates FTS5 virtual table for all string fields (excluding files/refs)
- Creates INSERT/UPDATE/DELETE triggers to auto-sync the FTS index
- Adds Search<Resource> SQL query using FTS5 MATCH with ranking
- Handler uses FTS5 search instead of in-memory strings.Contains filtering
Without --searchable, the existing in-memory search behavior is unchanged.
Also adds SearchableFields() helper to ResourceData for template use.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address code review findings for M4 features
FTS5 search:
- Skip GetAll when search query present — go directly to FTS5 query
- TotalCount reflects FTS result count, not unfiltered total
- Validate --searchable requires at least one string field
Scheduled tasks:
- Validate schedule duration is a positive integer before emitting Go code
- Fix PeriodicJobs() comment indentation (was misaligned with slice literal)
Database console:
- Remove duplicate cwd check in findDBPath
- Handle os.Getwd() error properly
- Stop walking at project boundary (go.mod) instead of filesystem root
Code quality:
- SearchableFields() composes on NonFileFields() instead of reimplementing
- Remove stale test assertion about search comment
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address Claude review — error on missing injection point, fix blank line
- injectPeriodicJobsConfig returns error when River config target not found
- Remove spurious blank line from Searchable template block when disabled
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address PR review — panic guard, schedule sanitization, FTS logging
- Fix panic in GenTask when only flags passed (no task name)
- Use %q for schedule string in fallback to prevent source injection
- Log FTS search errors with log.Printf instead of silently swallowing
- Add marker-based fallback for PeriodicJobs config injection
- Document db alias in console help text
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: use slog for FTS errors, validate schedule format upfront
- FTS search errors logged with slog.Error (consistent with generated code)
- Add slog import conditional on Searchable
- Validate --schedule format upfront: reject unrecognized formats with
clear error listing supported options
- Document db alias in console help
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address final review — marker error, slog consistency, help docs
- Return error when PeriodicJobs marker is missing (instead of silent no-op)
- Sync single kit handler to use slog.Error for FTS (was log.Printf)
- Add RunOnStart comment in generated periodic job scaffold
- Document --searchable and --with-authz in resource help text
- Remove redundant @every entries from validSchedules map
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address final review — error propagation, import injection, tests
- Return error when time import injection target not found in worker.go
- Propagate FTS search errors instead of swallowing (return fmt.Errorf)
- Remove unused slog import conditional (error is propagated, not logged)
- Add unit tests for scheduleToGo (7 cases), isPositiveInt (8 cases),
and invalid/non-numeric schedule fallback (2 cases)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: restore deleted tests, fix RunOnStart default, remove redundant cases
Critical:
- Restore 6 deleted integration tests for GenerateQueue/GenerateJob/InjectJobWorker
- Append new scheduleToGo/isPositiveInt unit tests alongside originals
Issues:
- Change RunOnStart default to false (daily tasks shouldn't fire on every restart)
- Remove redundant @every hardcoded cases (generic parser handles them)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: reject @every 0m, improve marker error message
- isValidEverySchedule rejects "0" duration (would generate broken code)
- Clearer error when periodic job marker not found in worker.go
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c66f423 commit 481e9ba
File tree
26 files changed
+735
-33
lines changed- commands
- internal
- generator
- kits/system
- multi/templates
- jobs
- resource
- single/templates
- jobs
- resource
- ui
- testdata/golden
26 files changed
+735
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | | - | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
245 | 250 | | |
246 | 251 | | |
247 | 252 | | |
248 | | - | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| |||
0 commit comments