time2 2.5.0__py3-none-any.whl

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.
Files changed (38) hide show
  1. time2-2.5.0.data/data/share/time2/docs/AI_INSIGHTS.md +188 -0
  2. time2-2.5.0.data/data/share/time2/docs/CODE_WALKTHROUGH.md +222 -0
  3. time2-2.5.0.data/data/share/time2/docs/DEVELOPER_GUIDE.md +738 -0
  4. time2-2.5.0.data/data/share/time2/docs/MANUAL.md +570 -0
  5. time2-2.5.0.data/data/share/time2/docs/MODULES.md +167 -0
  6. time2-2.5.0.data/data/share/time2/docs/PACKAGING.md +189 -0
  7. time2-2.5.0.data/data/share/time2/docs/TAILSCALE_PRIVATE_ACCESS.md +157 -0
  8. time2-2.5.0.data/data/share/time2/examples/time2_data.example.json +5 -0
  9. time2-2.5.0.data/data/share/time2/examples/time2_settings.example.json +85 -0
  10. time2-2.5.0.data/data/share/time2/time2_e2_component/index.html +575 -0
  11. time2-2.5.0.data/data/share/time2/time2_matrix_component/index.html +427 -0
  12. time2-2.5.0.data/data/share/time2/time2_task_list_component/index.html +191 -0
  13. time2-2.5.0.dist-info/METADATA +447 -0
  14. time2-2.5.0.dist-info/RECORD +38 -0
  15. time2-2.5.0.dist-info/WHEEL +5 -0
  16. time2-2.5.0.dist-info/entry_points.txt +2 -0
  17. time2-2.5.0.dist-info/licenses/LICENSE +21 -0
  18. time2-2.5.0.dist-info/top_level.txt +5 -0
  19. time2_ai_cache_worker.py +76 -0
  20. time2_app/__init__.py +14 -0
  21. time2_app/ai.py +1391 -0
  22. time2_app/app.py +885 -0
  23. time2_app/budget.py +261 -0
  24. time2_app/chat.py +512 -0
  25. time2_app/cli.py +307 -0
  26. time2_app/components.py +47 -0
  27. time2_app/config.py +106 -0
  28. time2_app/models.py +610 -0
  29. time2_app/reports.py +384 -0
  30. time2_app/storage.py +373 -0
  31. time2_app/streamlit_entry.py +11 -0
  32. time2_app/tailscale_utils.py +148 -0
  33. time2_app/transcription.py +62 -0
  34. time2_app/utils.py +869 -0
  35. time2_app/views.py +5422 -0
  36. time2_jupyter_launcher.py +69 -0
  37. time2_streamlit_app.py +12 -0
  38. time2_tailscale_jupyter_launcher.py +310 -0
@@ -0,0 +1,188 @@
1
+ # AI Insights
2
+
3
+ time-2.0.5 adds an optional `AI Insights` tab.
4
+
5
+ The AI layer is intentionally separate from the main task model:
6
+
7
+ - It reads task and mind-log data.
8
+ - It computes deterministic scores first.
9
+ - It can send a compact selected-date/range summary to a local
10
+ `llama-cpp-python` model or an OpenAI-compatible API endpoint.
11
+ - It does not edit tasks automatically.
12
+ - The app still runs if `llama-cpp-python` is not installed.
13
+
14
+ ## Optional Install
15
+
16
+ Install the base app first:
17
+
18
+ ```bash
19
+ pip install -r requirements.txt
20
+ ```
21
+
22
+ Install local LLM support only on the laptop that will run the model:
23
+
24
+ ```bash
25
+ pip install -r requirements-llm.txt
26
+ ```
27
+
28
+ Put the model at the default path or change the path in the `AI Insights` tab:
29
+
30
+ ```text
31
+ ./Models/Qwen2.5-7B-Instruct-Q4_K_M.gguf
32
+ ```
33
+
34
+ If you prefer an API provider, no extra Python package is needed. Configure:
35
+
36
+ ```text
37
+ Settings -> LLM defaults -> OpenAI-compatible API
38
+ ```
39
+
40
+ Use a base URL such as `http://127.0.0.1:8000/v1`, a model name, optional API
41
+ key, and timeout. API mode sends the selected task, mind-state, audio,
42
+ transcript, and budget context to that endpoint, so use a trusted local or
43
+ private server for personal data.
44
+
45
+ ## Current AI Functions
46
+
47
+ - Daily or date-range summary.
48
+ - Period support score.
49
+ - Data availability score.
50
+ - Score breakdown plot.
51
+ - Attention flags.
52
+ - Tiny next-action candidates.
53
+ - Momentum score from worked minutes.
54
+ - Completion score from done/left/cancelled work.
55
+ - Mindfulness/data check-in score from mind logs.
56
+ - Stability score from reschedules.
57
+ - Data availability plot.
58
+ - attention support detectors for time blindness, forgotten tasks, energy budget,
59
+ reschedule reasons, morning launch, evening shutdown, data honesty, routine
60
+ adherence, deadline heat, victory evidence, context switching, and recovery.
61
+ - Local or API LLM review using your selected provider.
62
+ - Downloadable AI insight markdown.
63
+ - Cached deterministic reports for today, last 7 days, and last 30 days.
64
+ - Optional cached LLM reports.
65
+ - Project counts in the AI report payload.
66
+ - Audio-log evidence in the AI report payload.
67
+
68
+ ## Score And Detector Settings
69
+
70
+ Open:
71
+
72
+ ```text
73
+ Settings -> AI score and detector settings
74
+ ```
75
+
76
+ You can tune:
77
+
78
+ - Support-score weights for data capture, momentum, completion, mind logs, and
79
+ stability.
80
+ - Momentum target minutes per day.
81
+ - Reschedule penalty.
82
+ - Low-data threshold.
83
+ - Edit contact minutes, which adds a small closed session when a task is edited
84
+ outside an already-running session.
85
+ - Forgotten-task deadline window.
86
+ - High energy-cost and recovery-energy thresholds.
87
+ - Context-switching thresholds.
88
+ - Morning available minutes.
89
+ - Routine matching window.
90
+
91
+ These settings affect the `AI Insights` tab, cached reports, exported period
92
+ reports, and the `daily_scores` context sent to AI Chat.
93
+
94
+ ## Provider And Model Settings
95
+
96
+ In `Settings -> LLM defaults` or `AI Insights -> LLM settings`, choose the
97
+ provider. For local mode, use `Choose file` to select the `.gguf` model file.
98
+ The model path is a file path, not just a folder path.
99
+
100
+ ## AI Cache
101
+
102
+ The cache stores ready-made reports in the configured AI cache folder. By
103
+ default, the cache folder is inside the main data folder:
104
+
105
+ ```text
106
+ time2_ai_cache
107
+ ```
108
+
109
+ The app refreshes cached reports when the `AI Insights` tab is opened and the
110
+ refresh interval has passed. This keeps the common windows ready:
111
+
112
+ - Today.
113
+ - Last 7 days.
114
+ - Last 30 days.
115
+
116
+ Deterministic reports are fast and safe to keep enabled. LLM cache is optional
117
+ because the local model can take a while to run. In time-2.0.5, scheduled LLM
118
+ cache uses local llama.cpp only; manual AI Insights and AI Chat can use either
119
+ local or API mode.
120
+
121
+ ## Optional Background Worker
122
+
123
+ For true regular refreshes while the laptop is on, run:
124
+
125
+ ```bash
126
+ python time2_ai_cache_worker.py
127
+ ```
128
+
129
+ Run once and exit:
130
+
131
+ ```bash
132
+ python time2_ai_cache_worker.py --once --no-llm
133
+ ```
134
+
135
+ Run one forced LLM cache refresh:
136
+
137
+ ```bash
138
+ python time2_ai_cache_worker.py --once --force --include-llm
139
+ ```
140
+
141
+ The worker reads the same settings as the app and writes into the same AI cache
142
+ folder.
143
+
144
+ ## Implemented Detector Modules
145
+
146
+ - Time-blindness detector: flags days where plans existed but no session,
147
+ comment, or mind log was recorded.
148
+ - Forgotten-task radar: surfaces active tasks with no session/comment evidence
149
+ and an approaching deadline.
150
+ - Energy budget: compares high energy-cost touched tasks with active recovery
151
+ candidates.
152
+ - Reschedule reason clustering: groups planned/deadline movement reasons.
153
+ - Morning launch plan: suggests a 3-item plan from urgency, importance, energy,
154
+ and available time.
155
+ - Evening shutdown review: summarizes the latest day in the range and picks a
156
+ safe next bookmark.
157
+ - Data honesty score: shows whether each day has enough evidence to interpret.
158
+ - Routine adherence: compares enabled daily routines against session/mind-log
159
+ evidence.
160
+ - Deadline heat forecast: highlights active deadlines whose urgency is high
161
+ relative to worked minutes.
162
+ - Victory evidence: turns completed tasks and sessions into confidence lines.
163
+ - Context-switching meter: estimates fragmentation from short sessions and area
164
+ switching.
165
+ - Recovery recommendation: suggests lower-friction follow-up work after heavy
166
+ energy-cost periods.
167
+
168
+ ## Local Model Notes
169
+
170
+ The app uses the same basic pattern as your starter code:
171
+
172
+ ```python
173
+ from llama_cpp import Llama
174
+
175
+ llm = Llama(
176
+ model_path="./Models/Qwen2.5-7B-Instruct-Q4_K_M.gguf",
177
+ n_ctx=32768,
178
+ verbose=False,
179
+ logits_all=False,
180
+ )
181
+
182
+ response = llm.create_chat_completion(
183
+ messages=[{"role": "user", "content": "Hello World"}]
184
+ )
185
+ ```
186
+
187
+ The app wraps this in `time2_app/ai.py` and caches the loaded model so it does
188
+ not reload on every Streamlit rerun.
@@ -0,0 +1,222 @@
1
+ # Code Walkthrough
2
+
3
+ This file gives a compact walkthrough of the source layers. For a fuller
4
+ developer handoff, use `docs/DEVELOPER_GUIDE.md`.
5
+
6
+ ## Entry Point
7
+
8
+ `time2_streamlit_app.py` imports `run_app()` from `time2_app.app` and calls it.
9
+ Keep this file small so JupyterLab always has one stable file to run.
10
+
11
+ When installed as a package, the `time2` command runs
12
+ `time2_app/streamlit_entry.py`. That module also imports and calls `run_app()`,
13
+ but it lives inside the package so Streamlit can find it after wheel
14
+ installation.
15
+
16
+ `time2_app/cli.py` provides:
17
+
18
+ - `time2 run`
19
+ - `time2 doctor`
20
+ - `time2 install-optionals`
21
+ - `time2 tailscale`
22
+
23
+ ## App Composition
24
+
25
+ `time2_app/app.py` does the page-level work:
26
+
27
+ - Sets Streamlit page config.
28
+ - Loads settings.
29
+ - Applies theme CSS.
30
+ - Loads the board.
31
+ - Shows top metrics.
32
+ - Creates the tabs.
33
+ - Calls the view functions.
34
+ - Handles Data tab import/restore.
35
+ - Handles Add-tab flexible planned-time windows.
36
+ - Places AI Chat and Reports/PDF as separate tabs.
37
+
38
+ ## Data Model
39
+
40
+ `time2_app/models.py` is the center of the app's meaning.
41
+
42
+ - `Time2Item` is one task or event.
43
+ - `Time2Session` is one focused work session.
44
+ - `Time2Reschedule` records movement of planned time or deadline.
45
+ - `Time2Comment` records notes, blockers, reflections, and reasons.
46
+ - `Time2MindLog` records a mind state without requiring a task.
47
+ - `Time2AudioLog` records uploaded or browser-recorded meeting/audio file
48
+ metadata and optional Whisper transcript metadata.
49
+ - `Time2Board` owns all items, mind logs, and audio log metadata.
50
+
51
+ The model is where methods like `mark_done()`, `cancel()`, `start_session()`,
52
+ `stop_session()`, `reschedule()`, and `stats()` belong.
53
+
54
+ ## Storage
55
+
56
+ `time2_app/storage.py` owns disk behavior.
57
+
58
+ It writes:
59
+
60
+ - Main board JSON.
61
+ - One-file-per-task JSON files.
62
+ - One-file-per-mind-log JSON files.
63
+ - Uploaded and browser-recorded meeting/audio files.
64
+ - Backup JSON files.
65
+ - AI chat JSON files.
66
+ - Exported PDF/HTML/TXT/JSON report files.
67
+ - The `time2_budget/` folder is created here, while month-file logic lives in
68
+ `budget.py`.
69
+
70
+ It also resolves user-selected folders from Settings. Relative folders are
71
+ resolved from the app working directory; absolute folders are used as entered.
72
+ The main board path comes from `data_file_path(settings)`, which points to
73
+ `time2_data.json` inside the selected main data folder.
74
+
75
+ ## Views
76
+
77
+ `time2_app/views.py` owns Streamlit screens and interactions.
78
+
79
+ It contains reusable render functions for:
80
+
81
+ - Task lists and editable task cards.
82
+ - Task-level audio upload, microphone recording, transcript display, and
83
+ transcribe-now controls.
84
+ - Planning filters.
85
+ - Eisenhower matrix.
86
+ - E2 plot.
87
+ - Mind logs.
88
+ - Budget tab and budget settings.
89
+ - Browser audio recording controls.
90
+ - Audio transcription settings.
91
+ - Pending/done/cancelled boards.
92
+ - Dashboard search and sorting.
93
+ - AI Chat data selection, saved-chat UI, and local LLM parameter controls.
94
+ - Reports/PDF export controls.
95
+ - Private-access/Tailscale status controls.
96
+ - Settings forms.
97
+
98
+ ## AI
99
+
100
+ `time2_app/ai.py` owns optional AI analytics.
101
+
102
+ It computes deterministic reports before any model call:
103
+
104
+ - Daily rows.
105
+ - Data availability.
106
+ - Period scores.
107
+ - Status, area, mind-state, session, and reschedule counts.
108
+
109
+ When the user clicks `Generate AI insight`, the view sends that compact report
110
+ to `run_llm_report()`. Local mode loads `llama-cpp-python` lazily; API mode calls
111
+ an OpenAI-compatible `/chat/completions` endpoint with the configured base URL,
112
+ model, optional key, and timeout.
113
+
114
+ `refresh_ai_cache()` writes cached reports for today, last 7 days, and last 30
115
+ days. The Streamlit tab can refresh this cache when opened. For true regular
116
+ refreshes, `time2_ai_cache_worker.py` can run as a separate process.
117
+
118
+ ## AI Chat
119
+
120
+ `time2_app/chat.py` owns saved chat files and selected prompt context.
121
+
122
+ It can include:
123
+
124
+ - Tasks.
125
+ - Sessions.
126
+ - Comments.
127
+ - Mind logs.
128
+ - Audio transcripts.
129
+ - Budget entries.
130
+ - Daily score summaries.
131
+
132
+ The module builds a compact JSON context and sends it to the selected local/API
133
+ chat runner. The chat is read-only in time-2.0.5.
134
+
135
+ ## Reports
136
+
137
+ `time2_app/reports.py` owns report text, HTML, JSON, and dependency-free PDF
138
+ generation. It supports task reports, period reports, dashboard/all-task
139
+ reports, mind-state reports, budget reports, AI chat reports, and full raw
140
+ snapshots.
141
+
142
+ ## Budget
143
+
144
+ `time2_app/budget.py` owns budget data that should not be mixed into task
145
+ history.
146
+
147
+ It provides:
148
+
149
+ - `BudgetEntry`
150
+ - Category normalization
151
+ - Custom month-end period calculation
152
+ - Monthly JSON load/save helpers
153
+ - Budget reports with income, expense, savings, surplus, class summaries, and
154
+ overspending flags
155
+
156
+ Budget files are written under the selected data folder:
157
+
158
+ ```text
159
+ time2_budget/budget_YYYY_MM.json
160
+ ```
161
+
162
+ ## Transcription
163
+
164
+ `time2_app/transcription.py` owns optional Whisper support.
165
+
166
+ The module imports `whisper` lazily inside `load_whisper_model()`, so the app
167
+ can start even when `openai-whisper` is not installed. Views call
168
+ `save_audio_upload_log()` for both uploaded files and microphone recordings,
169
+ optionally run Whisper, and store a transcript status.
170
+
171
+ `Auto detect` is the default transcription mode. In that mode,
172
+ `transcribe_audio_file()` does not pass a forced language to Whisper; it stores
173
+ the detected language code/name from Whisper's result when available.
174
+
175
+ ## Components
176
+
177
+ `time2_app/components.py` registers custom browser components. Their HTML/JS
178
+ lives in separate folders so the Python side can stay clean.
179
+
180
+ The component folders are:
181
+
182
+ - `time2_matrix_component/`
183
+ - `time2_e2_component/`
184
+ - `time2_task_list_component/`
185
+
186
+ In installed wheels these folders are packaged under `share/time2/`.
187
+ `components.py` checks both the source checkout location and the installed data
188
+ location.
189
+
190
+ ## Private Access
191
+
192
+ `time2_app/tailscale_utils.py` owns optional Tailscale command detection and
193
+ execution. The CLI and Settings screen both use it.
194
+
195
+ It can:
196
+
197
+ - find the `tailscale` command;
198
+ - show install links/commands;
199
+ - start `tailscale up` for sign-in;
200
+ - start `tailscale serve`;
201
+ - parse private Serve URLs from status output.
202
+
203
+ It does not silently install or expose anything. The caller must be responding
204
+ to a user command or button press.
205
+
206
+ ## Settings and Theme
207
+
208
+ `time2_app/config.py` defines default settings.
209
+
210
+ `time2_app/utils.py` loads settings, validates custom option lists, parses
211
+ dates/times, normalizes projects, creates IDs, and builds the CSS theme.
212
+
213
+ ## Import and Restore
214
+
215
+ The Data tab calls `import_uploaded_json()` from `time2_app/app.py`.
216
+
217
+ That function accepts:
218
+
219
+ - A raw board JSON containing `items`.
220
+ - A backup JSON containing `board` and optionally `settings`.
221
+
222
+ After import, the app saves the board and writes a backup.